|
4 | 4 |
|
5 | 5 | from PyQt4 import QtGui
|
6 | 6 | from PyQt4 import QtCore
|
7 |
| -from PyQt4.QtCore import Qt |
8 | 7 | from PyQt4.QtCore import SIGNAL
|
9 | 8 |
|
10 | 9 | import cola
|
|
15 | 14 | from cola import qtutils
|
16 | 15 | from cola import settings
|
17 | 16 | from cola import signals
|
18 |
| -from cola import resources |
19 | 17 | from cola.compat import set
|
20 | 18 | from cola.qtutils import SLOT
|
21 |
| -from cola.views import dag |
22 |
| -from cola.views import about |
23 | 19 | from cola.views import actions as actionsmod
|
24 | 20 | from cola.views.syntax import DiffSyntaxHighlighter
|
25 | 21 | from cola.views.mainwindow import MainWindow
|
26 |
| -from cola.controllers import classic |
27 |
| -from cola.controllers import compare |
28 |
| -from cola.controllers import createtag |
29 |
| -from cola.controllers import merge |
30 |
| -from cola.controllers import search as smod |
31 |
| -from cola.controllers import stash |
32 |
| -from cola.controllers.bookmark import manage_bookmarks |
33 |
| -from cola.controllers.bookmark import save_bookmark |
34 |
| -from cola.controllers.createbranch import create_new_branch |
35 |
| -from cola.controllers.options import update_options |
36 | 22 |
|
37 | 23 |
|
38 | 24 | class MainView(MainWindow):
|
@@ -72,105 +58,9 @@ def __init__(self, parent=None):
|
72 | 58 | # Change this whenever dockwidgets are removed.
|
73 | 59 | self._widget_version = 1
|
74 | 60 |
|
75 |
| - self.model = cola.model() |
76 | 61 | self.model.add_message_observer(self.model.message_updated,
|
77 | 62 | self._update_view)
|
78 | 63 |
|
79 |
| - # Listen for text and amend messages |
80 |
| - cola.notifier().connect(signals.diff_text, self.set_display) |
81 |
| - cola.notifier().connect(signals.mode, self._mode_changed) |
82 |
| - cola.notifier().connect(signals.amend, self.amend_checkbox.setChecked) |
83 |
| - |
84 |
| - # Broadcast the amend mode |
85 |
| - self.connect(self.amend_checkbox, SIGNAL('toggled(bool)'), |
86 |
| - SLOT(signals.amend_mode)) |
87 |
| - |
88 |
| - # Add button callbacks |
89 |
| - self._relay_button(self.alt_button, signals.reset_mode) |
90 |
| - self._relay_button(self.rescan_button, signals.rescan) |
91 |
| - |
92 |
| - self._connect_button(self.signoff_button, self.signoff) |
93 |
| - self._connect_button(self.stage_button, self.stage) |
94 |
| - self._connect_button(self.unstage_button, self.unstage) |
95 |
| - self._connect_button(self.commit_button, self.commit) |
96 |
| - self._connect_button(self.fetch_button, guicmds.fetch_slot(self)) |
97 |
| - self._connect_button(self.push_button, guicmds.push_slot(self)) |
98 |
| - self._connect_button(self.pull_button, guicmds.pull_slot(self)) |
99 |
| - self._connect_button(self.stash_button, lambda: stash.stash(parent=self)) |
100 |
| - |
101 |
| - # Menu actions |
102 |
| - actions = [ |
103 |
| - (self.menu_quit, self.close), |
104 |
| - (self.menu_branch_compare, compare.branch_compare), |
105 |
| - (self.menu_branch_diff, guicmds.branch_diff), |
106 |
| - (self.menu_branch_review, guicmds.review_branch), |
107 |
| - (self.menu_browse_branch, guicmds.browse_current), |
108 |
| - (self.menu_browse_other_branch, guicmds.browse_other), |
109 |
| - (self.menu_browse_commits, guicmds.browse_commits), |
110 |
| - (self.menu_create_tag, createtag.create_tag), |
111 |
| - (self.menu_create_branch, create_new_branch), |
112 |
| - (self.menu_checkout_branch, guicmds.checkout_branch), |
113 |
| - (self.menu_delete_branch, guicmds.branch_delete), |
114 |
| - (self.menu_rebase_branch, guicmds.rebase), |
115 |
| - (self.menu_clone_repo, guicmds.clone_repo), |
116 |
| - (self.menu_commit_compare, compare.compare), |
117 |
| - (self.menu_commit_compare_file, compare.compare_file), |
118 |
| - (self.menu_cherry_pick, guicmds.cherry_pick), |
119 |
| - (self.menu_diff_expression, guicmds.diff_expression), |
120 |
| - (self.menu_diff_branch, guicmds.diff_branch), |
121 |
| - (self.menu_export_patches, guicmds.export_patches), |
122 |
| - (self.menu_help_about, about.launch_about_dialog), |
123 |
| - (self.menu_help_docs, |
124 |
| - lambda: self.model.git.web__browse(resources.html_docs())), |
125 |
| - (self.menu_load_commitmsg, guicmds.load_commitmsg_slot(self)), |
126 |
| - (self.menu_load_commitmsg_template, |
127 |
| - SLOT(signals.load_commit_template)), |
128 |
| - (self.menu_manage_bookmarks, manage_bookmarks), |
129 |
| - (self.menu_save_bookmark, save_bookmark), |
130 |
| - (self.menu_merge_local, merge.local_merge), |
131 |
| - (self.menu_merge_abort, merge.abort_merge), |
132 |
| - (self.menu_fetch, guicmds.fetch_slot(self)), |
133 |
| - (self.menu_push, guicmds.push_slot(self)), |
134 |
| - (self.menu_pull, guicmds.pull_slot(self)), |
135 |
| - (self.menu_open_repo, guicmds.open_repo_slot(self)), |
136 |
| - (self.menu_options, update_options), |
137 |
| - (self.menu_rescan, SLOT(signals.rescan)), |
138 |
| - (self.menu_grep, guicmds.grep), |
139 |
| - (self.menu_search_commits, smod.search), |
140 |
| - (self.menu_show_diffstat, SLOT(signals.diffstat)), |
141 |
| - (self.menu_stash, lambda: stash.stash(parent=self)), |
142 |
| - (self.menu_stage_modified, SLOT(signals.stage_modified)), |
143 |
| - (self.menu_stage_untracked, SLOT(signals.stage_untracked)), |
144 |
| - (self.menu_unstage_selected, SLOT(signals.unstage_selected)), |
145 |
| - (self.menu_unstage_all, SLOT(signals.unstage_all)), |
146 |
| - (self.menu_visualize_all, SLOT(signals.visualize_all)), |
147 |
| - (self.menu_visualize_current, SLOT(signals.visualize_current)), |
148 |
| - # TODO This edit menu stuff should/could be command objects |
149 |
| - (self.menu_cut, self.action_cut), |
150 |
| - (self.menu_copy, self.action_copy), |
151 |
| - (self.menu_paste, self.commitmsg.paste), |
152 |
| - (self.menu_delete, self.action_delete), |
153 |
| - (self.menu_select_all, self.commitmsg.selectAll), |
154 |
| - (self.menu_undo, self.commitmsg.undo), |
155 |
| - (self.menu_redo, self.commitmsg.redo), |
156 |
| - (self.menu_classic, classic.cola_classic), |
157 |
| - (self.menu_dag, lambda: dag.git_dag(self.model, self)), |
158 |
| - ] |
159 |
| - |
160 |
| - # Diff Actions |
161 |
| - if hasattr(Qt, 'WidgetWithChildrenShortcut'): |
162 |
| - # We can only enable this shortcut on newer versions of Qt |
163 |
| - # that support WidgetWithChildrenShortcut otherwise we get |
164 |
| - # an ambiguous shortcut error. |
165 |
| - self.diff_copy = QtGui.QAction(self.display_text) |
166 |
| - self.diff_copy.setShortcut(QtGui.QKeySequence.Copy) |
167 |
| - self.diff_copy.setShortcutContext(Qt.WidgetWithChildrenShortcut) |
168 |
| - self.display_text.addAction(self.diff_copy) |
169 |
| - actions.append((self.diff_copy, self.copy_display,)) |
170 |
| - |
171 |
| - for menu, callback in actions: |
172 |
| - self.connect(menu, SIGNAL('triggered()'), callback) |
173 |
| - |
174 | 64 | # Install UI wrappers for command objects
|
175 | 65 | actionsmod.install_command_wrapper(self)
|
176 | 66 | guicmds.install_command_wrapper(self)
|
@@ -223,13 +113,6 @@ def _install_config_actions(self, names):
|
223 | 113 | for name in names:
|
224 | 114 | menu.addAction(name, SLOT(signals.run_config_action, name))
|
225 | 115 |
|
226 |
| - def _relay_button(self, button, signal): |
227 |
| - callback = SLOT(signal) |
228 |
| - self._connect_button(button, callback) |
229 |
| - |
230 |
| - def _connect_button(self, button, callback): |
231 |
| - self.connect(button, SIGNAL('clicked()'), callback) |
232 |
| - |
233 | 116 | def _update_view(self):
|
234 | 117 | self.emit(SIGNAL('update'))
|
235 | 118 |
|
@@ -266,42 +149,6 @@ def _update_callback(self):
|
266 | 149 | cola.notifier().broadcast(signals.load_commit_message,
|
267 | 150 | core.decode(merge_msg_path))
|
268 | 151 |
|
269 |
| - def _mode_changed(self, mode): |
270 |
| - """React to mode changes; hide/show the "Exit Diff Mode" button.""" |
271 |
| - if mode in (self.model.mode_review, |
272 |
| - self.model.mode_diff, |
273 |
| - self.model.mode_diff_expr): |
274 |
| - self.alt_button.setMinimumHeight(40) |
275 |
| - self.alt_button.show() |
276 |
| - else: |
277 |
| - self.alt_button.setMinimumHeight(1) |
278 |
| - self.alt_button.hide() |
279 |
| - |
280 |
| - def set_display(self, text): |
281 |
| - """Set the diff text display.""" |
282 |
| - scrollbar = self.display_text.verticalScrollBar() |
283 |
| - scrollvalue = scrollbar.value() |
284 |
| - if text is not None: |
285 |
| - self.display_text.setPlainText(text) |
286 |
| - scrollbar.setValue(scrollvalue) |
287 |
| - |
288 |
| - def action_cut(self): |
289 |
| - self.action_copy() |
290 |
| - self.action_delete() |
291 |
| - |
292 |
| - def action_copy(self): |
293 |
| - cursor = self.commitmsg.textCursor() |
294 |
| - selection = cursor.selection().toPlainText() |
295 |
| - qtutils.set_clipboard(selection) |
296 |
| - |
297 |
| - def action_delete(self): |
298 |
| - self.commitmsg.textCursor().removeSelectedText() |
299 |
| - |
300 |
| - def copy_display(self): |
301 |
| - cursor = self.display_text.textCursor() |
302 |
| - selection = cursor.selection().toPlainText() |
303 |
| - qtutils.set_clipboard(selection) |
304 |
| - |
305 | 152 | def diff_selection(self):
|
306 | 153 | cursor = self.display_text.textCursor()
|
307 | 154 | offset = cursor.position()
|
@@ -525,7 +372,9 @@ def diff_context_menu_setup(self):
|
525 | 372 | lambda: guicmds.goto_grep(self.selected_line()))
|
526 | 373 |
|
527 | 374 | menu.addSeparator()
|
528 |
| - menu.addAction(self.tr('Copy'), self.copy_display) |
| 375 | + menu.addAction('Copy', self.display_text.copy) |
| 376 | + menu.addAction('Select All', self.display_text.selectAll) |
| 377 | + |
529 | 378 | return menu
|
530 | 379 |
|
531 | 380 | def signoff(self):
|
|
0 commit comments