def __init__(self, parent=None): qt.QFlowLayoutWidget.__init__(self, parent) layout = self.layout() self.stage_button = create_button(text='Stage', layout=layout) self.unstage_button = create_button(text='Unstage', layout=layout) self.rescan_button = create_button(text='Rescan', layout=layout) self.fetch_button = create_button(text='Fetch...', layout=layout) self.push_button = create_button(text='Push...', layout=layout) self.pull_button = create_button(text='Pull...', layout=layout) self.stash_button = create_button(text='Stash...', layout=layout) layout.addStretch() self.setMinimumHeight(30) # Add callbacks connect_button(self.rescan_button, cmds.run(cmds.RescanAndRefresh)) connect_button(self.fetch_button, remote.fetch) connect_button(self.push_button, remote.push) connect_button(self.pull_button, remote.pull) connect_button(self.stash_button, stash.stash) connect_button(self.stage_button, self.stage) connect_button(self.unstage_button, self.unstage)
def __init__(self, parent, name, opts): standard.Dialog.__init__(self, parent) self.name = name self.opts = opts self.setWindowModality(Qt.ApplicationModal) self.layt = QtGui.QVBoxLayout() self.layt.setMargin(defs.margin) self.layt.setSpacing(defs.spacing) self.setLayout(self.layt) title = opts.get('title') if title: self.setWindowTitle(os.path.expandvars(title)) self.prompt = QtGui.QLabel() prompt = opts.get('prompt') if prompt: self.prompt.setText(os.path.expandvars(prompt)) self.layt.addWidget(self.prompt) self.argslabel = QtGui.QLabel() if 'argprompt' not in opts or opts.get('argprompt') is True: argprompt = N_('Arguments') else: argprompt = opts.get('argprompt') self.argslabel.setText(argprompt) self.argstxt = QtGui.QLineEdit() self.argslayt = QtGui.QHBoxLayout() self.argslayt.addWidget(self.argslabel) self.argslayt.addWidget(self.argstxt) self.layt.addLayout(self.argslayt) if not self.opts.get('argprompt'): self.argslabel.setMinimumSize(1, 1) self.argstxt.setMinimumSize(1, 1) self.argstxt.hide() self.argslabel.hide() revs = ( (N_('Local Branch'), gitcmds.branch_list(remote=False)), (N_('Tracking Branch'), gitcmds.branch_list(remote=True)), (N_('Tag'), gitcmds.tag_list()), ) if 'revprompt' not in opts or opts.get('revprompt') is True: revprompt = N_('Revision') else: revprompt = opts.get('revprompt') self.revselect = RevisionSelector(self, revs) self.revselect.set_revision_label(revprompt) self.layt.addWidget(self.revselect) if not opts.get('revprompt'): self.revselect.hide() # Close/Run buttons self.btnlayt = QtGui.QHBoxLayout() self.btnlayt.addStretch() self.closebtn = qt.create_button(text=N_('Close'), layout=self.btnlayt) self.runbtn = qt.create_button(text=N_('Run'), layout=self.btnlayt) self.runbtn.setDefault(True) self.layt.addLayout(self.btnlayt) # Widen the dialog by default self.resize(666, self.height()) qtutils.connect_button(self.closebtn, self.reject) qtutils.connect_button(self.runbtn, self.accept)
def __init__(self, opts, parent): standard.Dialog.__init__(self, parent=parent) self.setWindowModality(QtCore.Qt.WindowModal) self.setAttribute(Qt.WA_MacMetalStyle) self.setWindowTitle(self.tr('Create Tag')) self.opts = opts self.main_layt = QtGui.QVBoxLayout(self) self.main_layt.setContentsMargins(6, 12, 6, 6) # Form layout for inputs self.input_form_layt = QtGui.QFormLayout() self.input_form_layt.setFieldGrowthPolicy(QtGui.QFormLayout.ExpandingFieldsGrow) # Tag label self.tag_name_label = QtGui.QLabel(self) self.tag_name_label.setText(self.tr('Name')) self.input_form_layt.setWidget(0, QtGui.QFormLayout.LabelRole, self.tag_name_label) self.tag_name = text.HintedLineEdit('vX.Y.Z', self) self.tag_name.setToolTip(self.tr('Specifies the tag name')) self.input_form_layt.setWidget(0, QtGui.QFormLayout.FieldRole, self.tag_name) # Sign Tag self.sign_label = QtGui.QLabel(self) self.sign_label.setText(self.tr('Sign Tag')) self.input_form_layt.setWidget(1, QtGui.QFormLayout.LabelRole, self.sign_label) self.sign_tag = QtGui.QCheckBox(self) self.sign_tag.setToolTip( self.tr('Whether to sign the tag (git tag -s)')) self.input_form_layt.setWidget(1, QtGui.QFormLayout.FieldRole, self.sign_tag) self.main_layt.addLayout(self.input_form_layt) # Tag message self.tag_msg_label = QtGui.QLabel(self) self.tag_msg_label.setText(self.tr('Message')) self.input_form_layt.setWidget(2, QtGui.QFormLayout.LabelRole, self.tag_msg_label) self.tag_msg = text.HintedTextEdit('Tag message...', self) self.tag_msg.setToolTip(self.tr('Specifies the tag message')) self.tag_msg.enable_hint(True) self.input_form_layt.setWidget(2, QtGui.QFormLayout.FieldRole, self.tag_msg) # Revision self.rev_label = QtGui.QLabel(self) self.rev_label.setText(self.tr('Revision')) self.input_form_layt.setWidget(3, QtGui.QFormLayout.LabelRole, self.rev_label) self.revision = completion.GitRefLineEdit() self.revision.setText(self.opts.revision) self.revision.setToolTip(self.tr('Specifies the SHA-1 to tag')) self.input_form_layt.setWidget(3, QtGui.QFormLayout.FieldRole, self.revision) # Buttons self.button_hbox_layt = QtGui.QHBoxLayout() self.button_hbox_layt.addStretch() self.create_button = qt.create_button(text='Create Tag', icon=qtutils.git_icon()) self.button_hbox_layt.addWidget(self.create_button) self.main_layt.addLayout(self.button_hbox_layt) self.close_button = qt.create_button(text='Close') self.button_hbox_layt.addWidget(self.close_button) connect_button(self.close_button, self.accept) connect_button(self.create_button, self.create_tag) self.resize(506, 295)
def __init__(self, model, parent=None): Dialog.__init__(self, parent=parent) self.setWindowModality(Qt.WindowModal) self.setAttribute(Qt.WA_MacMetalStyle) self.setWindowTitle(self.tr('Create Branch')) self.model = model self.opts = CreateOpts(model) self.thread = CreateThread(self.opts, self) self.progress = QtGui.QProgressDialog(self) self.progress.setRange(0, 0) self.progress.setCancelButton(None) self.progress.setWindowTitle(self.tr('Create Branch')) self.progress.setWindowModality(Qt.WindowModal) self.branch_name_label = QtGui.QLabel() self.branch_name_label.setText(self.tr('Branch Name')) self.branch_name = QtGui.QLineEdit() self.rev_label = QtGui.QLabel() self.rev_label.setText(self.tr('Starting Revision')) self.revision = completion.GitRefLineEdit() current = gitcmds.current_branch() if current: self.revision.setText(current) self.local_radio = QtGui.QRadioButton() self.local_radio.setText(self.tr('Local Branch')) self.local_radio.setChecked(True) self.remote_radio = QtGui.QRadioButton() self.remote_radio.setText(self.tr('Tracking Branch')) self.tag_radio = QtGui.QRadioButton() self.tag_radio.setText(self.tr('Tag')) self.branch_list = QtGui.QListWidget() self.update_existing_label = QtGui.QLabel() self.update_existing_label.setText(self.tr('Update Existing Branch:')) self.no_update_radio = QtGui.QRadioButton() self.no_update_radio.setText(self.tr('No')) self.ffwd_only_radio = QtGui.QRadioButton() self.ffwd_only_radio.setText(self.tr('Fast Forward Only')) self.ffwd_only_radio.setChecked(True) self.reset_radio = QtGui.QRadioButton() self.reset_radio.setText(self.tr('Reset')) self.options_bottom_layout = QtGui.QHBoxLayout() self.options_checkbox_layout = QtGui.QVBoxLayout() self.fetch_checkbox = QtGui.QCheckBox() self.fetch_checkbox.setText(self.tr('Fetch Tracking Branch')) self.fetch_checkbox.setChecked(True) self.options_checkbox_layout.addWidget(self.fetch_checkbox) self.checkout_checkbox = QtGui.QCheckBox() self.checkout_checkbox.setText(self.tr('Checkout After Creation')) self.checkout_checkbox.setChecked(True) self.options_checkbox_layout.addWidget(self.checkout_checkbox) self.options_bottom_layout.addLayout(self.options_checkbox_layout) self.options_bottom_layout.addStretch() self.create_button = qt.create_button(text='Create Branch', icon=qtutils.git_icon()) self.create_button.setDefault(True) self.close_button = qt.create_button(text='Close') self.branch_name_layout = QtGui.QHBoxLayout() self.branch_name_layout.addWidget(self.branch_name_label) self.branch_name_layout.addWidget(self.branch_name) self.rev_start_radiobtn_layout = QtGui.QHBoxLayout() self.rev_start_radiobtn_layout.addWidget(self.local_radio) self.rev_start_radiobtn_layout.addWidget(self.remote_radio) self.rev_start_radiobtn_layout.addWidget(self.tag_radio) self.rev_start_radiobtn_layout.addStretch() self.rev_start_textinput_layout = QtGui.QHBoxLayout() self.rev_start_textinput_layout.setMargin(0) self.rev_start_textinput_layout.setSpacing(defs.spacing) self.rev_start_textinput_layout.addWidget(self.rev_label) self.rev_start_textinput_layout.addWidget(self.revision) self.rev_start_group = QtGui.QGroupBox() self.rev_start_group.setTitle(self.tr('Starting Revision')) self.rev_start_layout = QtGui.QVBoxLayout(self.rev_start_group) self.rev_start_layout.setMargin(defs.margin) self.rev_start_layout.setSpacing(defs.spacing) self.rev_start_layout.addLayout(self.rev_start_radiobtn_layout) self.rev_start_layout.addWidget(self.branch_list) self.rev_start_layout.addLayout(self.rev_start_textinput_layout) self.options_radio_layout = QtGui.QHBoxLayout() self.options_radio_layout.addWidget(self.update_existing_label) self.options_radio_layout.addWidget(self.no_update_radio) self.options_radio_layout.addWidget(self.ffwd_only_radio) self.options_radio_layout.addWidget(self.reset_radio) self.option_group = QtGui.QGroupBox() self.option_group.setTitle(self.tr('Options')) self.options_grp_layout = QtGui.QVBoxLayout(self.option_group) self.options_grp_layout.setMargin(defs.margin) self.options_grp_layout.setSpacing(defs.spacing) self.options_grp_layout.addLayout(self.options_radio_layout) self.options_grp_layout.addLayout(self.options_bottom_layout) self.buttons_layout = QtGui.QHBoxLayout() self.buttons_layout.setMargin(defs.margin) self.buttons_layout.setSpacing(defs.spacing) self.buttons_layout.addWidget(self.create_button) self.buttons_layout.addWidget(self.close_button) self.options_section_layout = QtGui.QHBoxLayout() self.options_section_layout.setMargin(defs.margin) self.options_section_layout.setSpacing(defs.spacing) self.options_section_layout.addWidget(self.option_group) self.options_section_layout.addLayout(self.buttons_layout) self.main_layout = QtGui.QVBoxLayout() self.main_layout.setMargin(defs.margin) self.main_layout.setSpacing(defs.spacing) self.main_layout.addLayout(self.branch_name_layout) self.main_layout.addWidget(self.rev_start_group) self.main_layout.addLayout(self.options_section_layout) self.setLayout(self.main_layout) qtutils.connect_button(self.close_button, self.reject) qtutils.connect_button(self.create_button, self.create_branch) qtutils.connect_button(self.local_radio, self.display_model) qtutils.connect_button(self.remote_radio, self.display_model) qtutils.connect_button(self.tag_radio, self.display_model) self.connect(self.branch_list, SIGNAL('itemSelectionChanged()'), self.branch_item_changed) self.connect(self.thread, SIGNAL('command'), self.thread_command) self.connect(self.thread, SIGNAL('done'), self.thread_done) self.resize(555, 333) self.display_model()
def __init__(self, model, parent): MainWindow.__init__(self, parent) # Default size; this is thrown out when save/restore is used self.resize(987, 610) self.model = model self.prefs_model = prefs_model = PreferencesModel() # Internal field used by import/export_state(). # Change this whenever dockwidgets are removed. self.widget_version = 1 # Keeps track of merge messages we've seen self.merge_message_hash = '' self.setAcceptDrops(True) self.setAttribute(Qt.WA_MacMetalStyle) # Dockwidget options qtcompat.set_common_dock_options(self) cfg = gitcfg.instance() self.classic_dockable = (cfg.get('cola.browserdockable') or cfg.get('cola.classicdockable')) if self.classic_dockable: self.classicdockwidget = create_dock('Browser', self) self.classicwidget = classic_widget(self) self.classicdockwidget.setWidget(self.classicwidget) # "Actions" widget self.actionsdockwidget = create_dock('Action', self) self.actionsdockwidgetcontents = qt.QFlowLayoutWidget(self) layout = self.actionsdockwidgetcontents.layout() self.stage_button = create_button(text='Stage', layout=layout) self.unstage_button = create_button(text='Unstage', layout=layout) self.rescan_button = create_button(text='Rescan', layout=layout) self.fetch_button = create_button(text='Fetch...', layout=layout) self.push_button = create_button(text='Push...', layout=layout) self.pull_button = create_button(text='Pull...', layout=layout) self.stash_button = create_button(text='Stash...', layout=layout) layout.addStretch() self.actionsdockwidget.setWidget(self.actionsdockwidgetcontents) # "Repository Status" widget self.statusdockwidget = create_dock('Status', self) self.statusdockwidget.setWidget(StatusWidget(self)) # "Commit Message Editor" widget self.position_label = QtGui.QLabel() font = qtutils.default_monospace_font() font.setPointSize(int(font.pointSize() * 0.8)) self.position_label.setFont(font) self.commitdockwidget = create_dock('Commit', self) titlebar = self.commitdockwidget.titleBarWidget() titlebar.add_corner_widget(self.position_label) self.commitmsgeditor = CommitMessageEditor(model, self) relay_signal(self, self.commitmsgeditor, SIGNAL(signals.amend_mode)) relay_signal(self, self.commitmsgeditor, SIGNAL(signals.signoff)) relay_signal(self, self.commitmsgeditor, SIGNAL(signals.load_previous_message)) self.commitdockwidget.setWidget(self.commitmsgeditor) # "Console" widget self.logwidget = LogWidget() self.logdockwidget = create_dock('Console', self) self.logdockwidget.setWidget(self.logwidget) cola.notifier().connect(signals.log_cmd, self.logwidget.log) # "Diff Viewer" widget self.diffdockwidget = create_dock('Diff', self) self.diffeditor = DiffEditor(self.diffdockwidget) self.diffdockwidget.setWidget(self.diffeditor) # All Actions self.menu_unstage_all = add_action(self, 'Unstage All', emit(self, signals.unstage_all)) self.menu_unstage_all.setIcon(qtutils.icon('remove.svg')) self.menu_unstage_selected = add_action(self, 'Unstage From Commit', emit(self, signals.unstage_selected)) self.menu_unstage_selected.setIcon(qtutils.icon('remove.svg')) self.menu_show_diffstat = add_action(self, 'Diffstat', emit(self, signals.diffstat), 'Alt+D') self.menu_stage_modified = add_action(self, 'Stage Changed Files To Commit', emit(self, signals.stage_modified), 'Alt+A') self.menu_stage_modified.setIcon(qtutils.icon('add.svg')) self.menu_stage_untracked = add_action(self, 'Stage All Untracked', emit(self, signals.stage_untracked), 'Alt+U') self.menu_stage_untracked.setIcon(qtutils.icon('add.svg')) self.menu_export_patches = add_action(self, 'Export Patches...', guicmds.export_patches, 'Alt+E') self.menu_preferences = add_action(self, 'Preferences', lambda: preferences(model=prefs_model), QtGui.QKeySequence.Preferences, 'Ctrl+O') self.menu_edit_remotes = add_action(self, 'Edit Remotes...', lambda: editremotes.edit().exec_()) self.menu_rescan = add_action(self, 'Rescan', emit(self, signals.rescan_and_refresh), 'Ctrl+R') self.menu_rescan.setIcon(qtutils.reload_icon()) self.menu_browse_recent = add_action(self, 'Recently Modified Files...', browse_recent, 'Shift+Ctrl+E') self.menu_cherry_pick = add_action(self, 'Cherry-Pick...', guicmds.cherry_pick, 'Ctrl+P') self.menu_load_commitmsg = add_action(self, 'Load Commit Message...', guicmds.load_commitmsg) self.menu_save_tarball = add_action(self, 'Save As Tarball/Zip...', self.save_archive) self.menu_quit = add_action(self, 'Quit', self.close, 'Ctrl+Q') self.menu_manage_bookmarks = add_action(self, 'Bookmarks...', manage_bookmarks) self.menu_grep = add_action(self, 'Grep', guicmds.grep) self.menu_merge_local = add_action(self, 'Merge...', merge.local_merge) self.menu_merge_abort = add_action(self, 'Abort Merge...', merge.abort_merge) self.menu_fetch = add_action(self, 'Fetch...', remote.fetch) self.menu_push = add_action(self, 'Push...', remote.push) self.menu_pull = add_action(self, 'Pull...', remote.pull) self.menu_open_repo = add_action(self, 'Open...', guicmds.open_repo) self.menu_open_repo.setIcon(qtutils.open_icon()) self.menu_stash = add_action(self, 'Stash...', stash.stash, 'Alt+Shift+S') self.menu_clone_repo = add_action(self, 'Clone...', guicmds.clone_repo) self.menu_clone_repo.setIcon(qtutils.git_icon()) self.menu_help_docs = add_action(self, 'Documentation', resources.show_html_docs, QtGui.QKeySequence.HelpContents) self.menu_help_shortcuts = add_action(self, 'Keyboard Shortcuts', show_shortcuts, QtCore.Qt.Key_Question) self.menu_visualize_current = add_action(self, 'Visualize Current Branch...', emit(self, signals.visualize_current)) self.menu_visualize_all = add_action(self, 'Visualize All Branches...', emit(self, signals.visualize_all)) self.menu_search_commits = add_action(self, 'Search...', search) self.menu_browse_branch = add_action(self, 'Browse Current Branch...', guicmds.browse_current) self.menu_browse_other_branch = add_action(self, 'Browse Other Branch...', guicmds.browse_other) self.menu_load_commitmsg_template = add_action(self, 'Get Commit Message Template', emit(self, signals.load_commit_template)) self.menu_help_about = add_action(self, 'About', launch_about_dialog) self.menu_branch_diff = add_action(self, 'SHA-1...', guicmds.diff_revision) self.menu_diff_expression = add_action(self, 'Expression...', guicmds.diff_expression) self.menu_branch_compare = add_action(self, 'Branches...', compare_branches) self.menu_create_tag = add_action(self, 'Create Tag...', create_tag) self.menu_create_branch = add_action(self, 'Create...', create_new_branch, 'Ctrl+B') self.menu_delete_branch = add_action(self, 'Delete...', guicmds.branch_delete) self.menu_checkout_branch = add_action(self, 'Checkout...', guicmds.checkout_branch, 'Alt+B') self.menu_rebase_branch = add_action(self, 'Rebase...', guicmds.rebase) self.menu_branch_review = add_action(self, 'Review...', guicmds.review_branch) self.menu_classic = add_action(self, 'Browser...', cola_classic) self.menu_classic.setIcon(qtutils.git_icon()) self.menu_dag = add_action(self, 'DAG...', lambda: git_dag(self.model)) self.menu_dag.setIcon(qtutils.git_icon()) # Relayed actions if not self.classic_dockable: # These shortcuts conflict with those from the # 'Browser' widget so don't register them when # the browser is a dockable tool. status_tree = self.statusdockwidget.widget().tree self.addAction(status_tree.up) self.addAction(status_tree.down) self.addAction(status_tree.process_selection) self.addAction(status_tree.launch_difftool) # Create the application menu self.menubar = QtGui.QMenuBar(self) # File Menu self.file_menu = create_menu('&File', self.menubar) self.file_menu.addAction(self.menu_preferences) self.file_menu.addSeparator() self.file_menu.addAction(self.menu_open_repo) self.menu_open_recent = self.file_menu.addMenu(tr('Open Recent')) self.file_menu.addSeparator() self.file_menu.addAction(self.menu_clone_repo) self.file_menu.addAction(self.menu_manage_bookmarks) self.file_menu.addSeparator() self.file_menu.addAction(self.menu_edit_remotes) self.file_menu.addAction(self.menu_rescan) self.file_menu.addSeparator() self.file_menu.addAction(self.menu_browse_recent) self.file_menu.addSeparator() self.file_menu.addAction(self.menu_load_commitmsg) self.file_menu.addAction(self.menu_load_commitmsg_template) self.file_menu.addSeparator() self.file_menu.addAction(self.menu_save_tarball) self.file_menu.addAction(self.menu_quit) # Add to menubar self.menubar.addAction(self.file_menu.menuAction()) # Commit Menu self.commit_menu = create_menu('Co&mmit', self.menubar) self.commit_menu.setTitle(tr('Commit@@verb')) self.commit_menu.addAction(self.menu_stage_modified) self.commit_menu.addAction(self.menu_stage_untracked) self.commit_menu.addSeparator() self.commit_menu.addAction(self.menu_unstage_all) self.commit_menu.addAction(self.menu_unstage_selected) self.commit_menu.addSeparator() self.commit_menu.addAction(self.menu_search_commits) # Add to menubar self.menubar.addAction(self.commit_menu.menuAction()) # Branch Menu self.branch_menu = create_menu('B&ranch', self.menubar) self.branch_menu.addAction(self.menu_branch_review) self.branch_menu.addSeparator() self.branch_menu.addAction(self.menu_create_branch) self.branch_menu.addAction(self.menu_checkout_branch) self.branch_menu.addAction(self.menu_rebase_branch) self.branch_menu.addAction(self.menu_delete_branch) self.branch_menu.addSeparator() self.branch_menu.addAction(self.menu_browse_branch) self.branch_menu.addAction(self.menu_browse_other_branch) self.branch_menu.addSeparator() self.branch_menu.addAction(self.menu_visualize_current) self.branch_menu.addAction(self.menu_visualize_all) # Add to menubar self.menubar.addAction(self.branch_menu.menuAction()) # Actions menu self.actions_menu = create_menu('Act&ions', self.menubar) self.actions_menu.addAction(self.menu_merge_local) self.actions_menu.addAction(self.menu_stash) self.actions_menu.addSeparator() self.actions_menu.addAction(self.menu_fetch) self.actions_menu.addAction(self.menu_push) self.actions_menu.addAction(self.menu_pull) self.actions_menu.addSeparator() self.actions_menu.addAction(self.menu_create_tag) self.actions_menu.addSeparator() self.actions_menu.addAction(self.menu_export_patches) self.actions_menu.addAction(self.menu_cherry_pick) self.actions_menu.addSeparator() self.actions_menu.addAction(self.menu_merge_abort) self.actions_menu.addAction(self.menu_grep) # Add to menubar self.menubar.addAction(self.actions_menu.menuAction()) # Diff Menu self.diff_menu = create_menu('&Diff', self.menubar) self.diff_menu.addAction(self.menu_branch_diff) self.diff_menu.addAction(self.menu_diff_expression) self.diff_menu.addAction(self.menu_branch_compare) self.diff_menu.addSeparator() self.diff_menu.addAction(self.menu_show_diffstat) # Add to menubar self.menubar.addAction(self.diff_menu.menuAction()) # Tools Menu self.tools_menu = create_menu('&Tools', self.menubar) self.tools_menu.addAction(self.menu_classic) self.tools_menu.addAction(self.menu_dag) self.tools_menu.addSeparator() if self.classic_dockable: self.tools_menu.addAction(self.classicdockwidget.toggleViewAction()) self.setup_dockwidget_tools_menu() self.menubar.addAction(self.tools_menu.menuAction()) # Help Menu self.help_menu = create_menu('&Help', self.menubar) self.help_menu.addAction(self.menu_help_docs) self.help_menu.addAction(self.menu_help_shortcuts) self.help_menu.addAction(self.menu_help_about) # Add to menubar self.menubar.addAction(self.help_menu.menuAction()) # Set main menu self.setMenuBar(self.menubar) # Arrange dock widgets top = Qt.TopDockWidgetArea bottom = Qt.BottomDockWidgetArea self.addDockWidget(top, self.commitdockwidget) if self.classic_dockable: self.addDockWidget(top, self.classicdockwidget) self.addDockWidget(top, self.statusdockwidget) self.addDockWidget(top, self.actionsdockwidget) self.addDockWidget(bottom, self.logdockwidget) if self.classic_dockable: self.tabifyDockWidget(self.classicdockwidget, self.commitdockwidget) self.tabifyDockWidget(self.logdockwidget, self.diffdockwidget) # Listen for model notifications model.add_observer(model.message_updated, self._update_view) prefs_model.add_observer(prefs_model.message_config_updated, self._config_updated) # Set a default value self.show_cursor_position(1, 0) # Add button callbacks connect_button(self.rescan_button, emit(self, signals.rescan_and_refresh)) connect_button(self.fetch_button, remote.fetch) connect_button(self.push_button, remote.push) connect_button(self.pull_button, remote.pull) connect_button(self.stash_button, stash.stash) connect_button(self.stage_button, self.stage) connect_button(self.unstage_button, self.unstage) self.connect(self.menu_open_recent, SIGNAL('aboutToShow()'), self.build_recent_menu) self.connect(self.commitmsgeditor, SIGNAL('cursorPosition(int,int)'), self.show_cursor_position) self.connect(self, SIGNAL('update'), self._update_callback) self.connect(self, SIGNAL('install_config_actions'), self._install_config_actions) # Install .git-config-defined actions self._config_task = None self.install_config_actions() # Restore saved settings qtutils.apply_state(self) self.statusdockwidget.widget().setFocus() log(0, version.git_version_str() + '\ncola version ' + version.version())
def __init__(self, parent=None): standard.Dialog.__init__(self, parent=parent) self.setWindowTitle(self.tr("Create Branch")) self.resize(555, 333) self._main_layt = QtGui.QVBoxLayout(self) self._main_layt.setMargin(defs.margin) self._main_layt.setSpacing(defs.spacing) self._branch_name_layt = QtGui.QHBoxLayout() self._branch_name_label = QtGui.QLabel(self) self._branch_name_label.setText(self.tr("Branch Name")) self._branch_name_layt.addWidget(self._branch_name_label) # Exposed self.local_branch = QtGui.QLineEdit(self) self._branch_name_layt.addWidget(self.local_branch) self._main_layt.addLayout(self._branch_name_layt) self._rev_start_grp = QtGui.QGroupBox(self) self._rev_start_grp.setTitle(self.tr("Starting Revision")) self._rev_start_vbox_layt = QtGui.QVBoxLayout(self._rev_start_grp) self._rev_start_vbox_layt.setMargin(defs.margin) self._rev_start_vbox_layt.setSpacing(defs.spacing) self._rev_start_textinput_layt = QtGui.QHBoxLayout() self._rev_start_textinput_layt.setSpacing(defs.spacing) self._rev_label = QtGui.QLabel(self._rev_start_grp) self._rev_label.setText(self.tr("Revision Expression:")) self._rev_start_textinput_layt.addWidget(self._rev_label) # Exposed self.revision = QtGui.QLineEdit(self._rev_start_grp) self._rev_start_textinput_layt.addWidget(self.revision) self._rev_start_vbox_layt.addLayout(self._rev_start_textinput_layt) self._rev_start_radiobtn_layt = QtGui.QHBoxLayout() # Exposed self.local_radio = QtGui.QRadioButton(self._rev_start_grp) self.local_radio.setText(self.tr("Local Branch")) self.local_radio.setChecked(True) self._rev_start_radiobtn_layt.addWidget(self.local_radio) # Exposed self.remote_radio = QtGui.QRadioButton(self._rev_start_grp) self.remote_radio.setText(self.tr("Tracking Branch")) self._rev_start_radiobtn_layt.addWidget(self.remote_radio) # Exposed self.tag_radio = QtGui.QRadioButton(self._rev_start_grp) self.tag_radio.setText(self.tr("Tag")) self._rev_start_radiobtn_layt.addWidget(self.tag_radio) self._radio_spacer = QtGui.QSpacerItem(1, 1, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self._rev_start_radiobtn_layt.addItem(self._radio_spacer) self._rev_start_vbox_layt.addLayout(self._rev_start_radiobtn_layt) # Exposed self.branch_list = QtGui.QListWidget(self._rev_start_grp) self._rev_start_vbox_layt.addWidget(self.branch_list) self._main_layt.addWidget(self._rev_start_grp) self._options_section_layt = QtGui.QHBoxLayout() self._options_section_layt.setMargin(defs.margin) self._options_section_layt.setSpacing(defs.spacing) self._option_grpbox = QtGui.QGroupBox(self) self._option_grpbox.setTitle(self.tr("Options")) self._options_grp_layt = QtGui.QVBoxLayout(self._option_grpbox) self._options_grp_layt.setMargin(defs.margin) self._options_grp_layt.setSpacing(defs.spacing) self._options_radio_layt = QtGui.QHBoxLayout() self._update_existing_label = QtGui.QLabel(self._option_grpbox) self._update_existing_label.setText(self.tr("Update Existing Branch:")) self._options_radio_layt.addWidget(self._update_existing_label) # Exposed self.no_update_radio = QtGui.QRadioButton(self._option_grpbox) self.no_update_radio.setText(self.tr("No")) self._options_radio_layt.addWidget(self.no_update_radio) # Exposed self.ffwd_only_radio = QtGui.QRadioButton(self._option_grpbox) self.ffwd_only_radio.setText(self.tr("Fast Forward Only")) self.ffwd_only_radio.setChecked(True) self._options_radio_layt.addWidget(self.ffwd_only_radio) # Exposed self.reset_radio = QtGui.QRadioButton(self._option_grpbox) self.reset_radio.setText(self.tr("Reset")) self._options_radio_layt.addWidget(self.reset_radio) self._options_grp_layt.addLayout(self._options_radio_layt) self._options_bottom_layt = QtGui.QHBoxLayout() self._options_checkbox_layt = QtGui.QVBoxLayout() self.fetch_checkbox = QtGui.QCheckBox(self._option_grpbox) self.fetch_checkbox.setText(self.tr("Fetch Tracking Branch")) self.fetch_checkbox.setChecked(True) self._options_checkbox_layt.addWidget(self.fetch_checkbox) self.checkout_checkbox = QtGui.QCheckBox(self._option_grpbox) self.checkout_checkbox.setText(self.tr("Checkout After Creation")) self.checkout_checkbox.setChecked(True) self._options_checkbox_layt.addWidget(self.checkout_checkbox) self._options_bottom_layt.addLayout(self._options_checkbox_layt) self._options_spacer = QtGui.QSpacerItem(1, 1, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self._options_bottom_layt.addItem(self._options_spacer) self._options_grp_layt.addLayout(self._options_bottom_layt) self._options_section_layt.addWidget(self._option_grpbox) self._buttons_layt = QtGui.QHBoxLayout() self._buttons_layt.setMargin(defs.margin) self._buttons_layt.setSpacing(defs.spacing) # Exposed self.create_button = qt.create_button(text="Create Branch", icon=qtutils.git_icon()) self.create_button.setDefault(True) self._buttons_layt.addWidget(self.create_button) # Exposed self.cancel_button = qt.create_button(text="Cancel") self._buttons_layt.addWidget(self.cancel_button) self._options_section_layt.addLayout(self._buttons_layt) self._main_layt.addLayout(self._options_section_layt) qtutils.connect_button(self.cancel_button, self.reject)
def __init__(self, opts, parent): standard.Dialog.__init__(self, parent=parent) self.setWindowModality(QtCore.Qt.WindowModal) self.setAttribute(Qt.WA_MacMetalStyle) self.setWindowTitle(N_('Create Tag')) self.opts = opts self.main_layt = QtGui.QVBoxLayout(self) self.main_layt.setContentsMargins(6, 12, 6, 6) # Form layout for inputs self.input_form_layt = QtGui.QFormLayout() self.input_form_layt.setFieldGrowthPolicy( QtGui.QFormLayout.ExpandingFieldsGrow) # Tag label self.tag_name_label = QtGui.QLabel(self) self.tag_name_label.setText(N_('Name')) self.input_form_layt.setWidget(0, QtGui.QFormLayout.LabelRole, self.tag_name_label) self.tag_name = text.HintedLineEdit('vX.Y.Z', self) self.tag_name.setToolTip(N_('Specifies the tag name')) self.input_form_layt.setWidget(0, QtGui.QFormLayout.FieldRole, self.tag_name) # Sign Tag self.sign_label = QtGui.QLabel(self) self.sign_label.setText(N_('Sign Tag')) self.input_form_layt.setWidget(1, QtGui.QFormLayout.LabelRole, self.sign_label) self.sign_tag = QtGui.QCheckBox(self) self.sign_tag.setToolTip(N_('Whether to sign the tag (git tag -s)')) self.input_form_layt.setWidget(1, QtGui.QFormLayout.FieldRole, self.sign_tag) self.main_layt.addLayout(self.input_form_layt) # Tag message self.tag_msg_label = QtGui.QLabel(self) self.tag_msg_label.setText(N_('Message')) self.input_form_layt.setWidget(2, QtGui.QFormLayout.LabelRole, self.tag_msg_label) self.tag_msg = text.HintedTextEdit(N_('Tag message...'), self) self.tag_msg.setToolTip(N_('Specifies the tag message')) self.tag_msg.enable_hint(True) self.input_form_layt.setWidget(2, QtGui.QFormLayout.FieldRole, self.tag_msg) # Revision self.rev_label = QtGui.QLabel(self) self.rev_label.setText(N_('Revision')) self.input_form_layt.setWidget(3, QtGui.QFormLayout.LabelRole, self.rev_label) self.revision = completion.GitRefLineEdit() self.revision.setText(self.opts.revision) self.revision.setToolTip(N_('Specifies the SHA-1 to tag')) self.input_form_layt.setWidget(3, QtGui.QFormLayout.FieldRole, self.revision) # Buttons self.button_hbox_layt = QtGui.QHBoxLayout() self.button_hbox_layt.addStretch() self.create_button = qt.create_button(text=N_('Create Tag'), icon=qtutils.git_icon()) self.button_hbox_layt.addWidget(self.create_button) self.main_layt.addLayout(self.button_hbox_layt) self.close_button = qt.create_button(text=N_('Close')) self.button_hbox_layt.addWidget(self.close_button) connect_button(self.close_button, self.accept) connect_button(self.create_button, self.create_tag) self.resize(506, 295)
def __init__(self, parent, name, opts): standard.StandardDialog.__init__(self, parent) self.name = name self.opts = opts self.layt = QtGui.QVBoxLayout() self.layt.setMargin(10) self.setLayout(self.layt) title = opts.get("title") if title: self.setWindowTitle(os.path.expandvars(title)) self.prompt = QtGui.QLabel() prompt = opts.get("prompt") if prompt: self.prompt.setText(os.path.expandvars(prompt)) self.layt.addWidget(self.prompt) self.argslabel = QtGui.QLabel() if "argprompt" not in opts or opts.get("argprompt") is True: argprompt = i18n.gettext("Arguments") else: argprompt = opts.get("argprompt") self.argslabel.setText(argprompt) self.argstxt = QtGui.QLineEdit() self.argslayt = QtGui.QHBoxLayout() self.argslayt.addWidget(self.argslabel) self.argslayt.addWidget(self.argstxt) self.layt.addLayout(self.argslayt) if not self.opts.get("argprompt"): self.argslabel.setMinimumSize(1, 1) self.argstxt.setMinimumSize(1, 1) self.argstxt.hide() self.argslabel.hide() revs = ( ("Local Branch", gitcmds.branch_list(remote=False)), ("Tracking Branch", gitcmds.branch_list(remote=True)), ("Tag", gitcmds.tag_list()), ) if "revprompt" not in opts or opts.get("revprompt") is True: revprompt = i18n.gettext("Revision") else: revprompt = opts.get("revprompt") self.revselect = revselect.RevisionSelector(self, revs=revs) self.revselect.set_revision_label(revprompt) self.layt.addWidget(self.revselect) if not opts.get("revprompt"): self.revselect.hide() # Close/Run buttons self.btnlayt = QtGui.QHBoxLayout() self.btnspacer = QtGui.QSpacerItem(1, 1, QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.Minimum) self.btnlayt.addItem(self.btnspacer) self.closebtn = qt.create_button(self.tr("Close"), self.btnlayt) self.runbtn = qt.create_button(self.tr("Run"), self.btnlayt) self.runbtn.setDefault(True) self.layt.addLayout(self.btnlayt) self.connect(self.closebtn, SIGNAL("clicked()"), self.reject) self.connect(self.runbtn, SIGNAL("clicked()"), self.accept) # Widen the dialog by default self.resize(666, self.height())
def __init__(self, model, parent): standard.MainWindow.__init__(self, parent) # Default size; this is thrown out when save/restore is used self.resize(987, 610) self.model = model self.prefs_model = prefs_model = PreferencesModel() # Internal field used by import/export_state(). # Change this whenever dockwidgets are removed. self.widget_version = 1 # Keeps track of merge messages we've seen self.merge_message_hash = '' self.setAcceptDrops(True) # Dockwidget options qtcompat.set_common_dock_options(self) self.classic_dockable = gitcfg.instance().get('cola.classicdockable') if self.classic_dockable: self.classicdockwidget = create_dock('Cola Classic', self) self.classicwidget = classic_widget(self) self.classicdockwidget.setWidget(self.classicwidget) # "Actions" widget self.actiondockwidget = create_dock('Actions', self) self.actiondockwidgetcontents = qt.QFlowLayoutWidget(self) layout = self.actiondockwidgetcontents.layout() self.stage_button = create_button('Stage', layout) self.unstage_button = create_button('Unstage', layout) self.rescan_button = create_button('Rescan', layout) self.fetch_button = create_button('Fetch...', layout) self.push_button = create_button('Push...', layout) self.pull_button = create_button('Pull...', layout) self.stash_button = create_button('Stash...', layout) self.alt_button = create_button('Exit Diff Mode', layout) self.alt_button.hide() layout.addStretch() self.actiondockwidget.setWidget(self.actiondockwidgetcontents) # "Repository Status" widget self.statusdockwidget = create_dock('Repository Status', self) self.statusdockwidget.setWidget(StatusWidget(self)) # "Commit Message Editor" widget self.commitdockwidget = create_dock('Commit Message Editor', self) self.commitmsgeditor = CommitMessageEditor(model, self) relay_signal(self, self.commitmsgeditor, SIGNAL(signals.amend_mode)) relay_signal(self, self.commitmsgeditor, SIGNAL(signals.signoff)) relay_signal(self, self.commitmsgeditor, SIGNAL(signals.load_previous_message)) self.commitdockwidget.setWidget(self.commitmsgeditor) # "Command Output" widget logwidget = qtutils.logger() logwidget.setFont(diff_font()) self.logdockwidget = create_dock('Command Output', self) self.logdockwidget.setWidget(logwidget) # "Diff Viewer" widget self.diffdockwidget = create_dock('Diff Viewer', self) self.diff_viewer = DiffTextEdit(self.diffdockwidget) self.diffdockwidget.setWidget(self.diff_viewer) # All Actions self.menu_unstage_all = add_action(self, 'Unstage All', emit(self, signals.unstage_all)) self.menu_unstage_all.setIcon(qtutils.icon('remove.svg')) self.menu_unstage_selected = add_action(self, 'Unstage From Commit', emit(self, signals.unstage_selected)) self.menu_unstage_selected.setIcon(qtutils.icon('remove.svg')) self.menu_show_diffstat = add_action(self, 'Diffstat', emit(self, signals.diffstat), 'Ctrl+D') self.menu_stage_modified = add_action(self, 'Stage Changed Files To Commit', emit(self, signals.stage_modified), 'Alt+A') self.menu_stage_modified.setIcon(qtutils.icon('add.svg')) self.menu_stage_untracked = add_action(self, 'Stage All Untracked', emit(self, signals.stage_untracked), 'Alt+U') self.menu_stage_untracked.setIcon(qtutils.icon('add.svg')) self.menu_export_patches = add_action(self, 'Export Patches...', guicmds.export_patches, 'Ctrl+E') self.menu_preferences = add_action(self, 'Preferences', lambda: preferences(model=prefs_model), QtGui.QKeySequence.Preferences, 'Ctrl+O') self.menu_rescan = add_action(self, 'Rescan', emit(self, signals.rescan), 'Ctrl+R') self.menu_rescan.setIcon(qtutils.reload_icon()) self.menu_cherry_pick = add_action(self, 'Cherry-Pick...', guicmds.cherry_pick, 'Ctrl+P') self.menu_load_commitmsg = add_action(self, 'Load Commit Message...', guicmds.load_commitmsg) self.menu_quit = add_action(self, 'Quit', self.close, 'Ctrl+Q') self.menu_manage_bookmarks = add_action(self, 'Bookmarks...', manage_bookmarks) self.menu_grep = add_action(self, 'Grep', guicmds.grep) self.menu_merge_local = add_action(self, 'Merge...', merge.local_merge) self.menu_merge_abort = add_action(self, 'Abort Merge...', merge.abort_merge) self.menu_fetch = add_action(self, 'Fetch...', guicmds.fetch) self.menu_push = add_action(self, 'Push...', guicmds.push) self.menu_pull = add_action(self, 'Pull...', guicmds.pull) self.menu_open_repo = add_action(self, 'Open...', guicmds.open_repo) self.menu_open_repo.setIcon(qtutils.open_icon()) self.menu_stash = add_action(self, 'Stash...', stash.stash, 'Alt+Shift+S') self.menu_diff_branch = add_action(self, 'Apply Changes From Branch...', guicmds.diff_branch) self.menu_branch_compare = add_action(self, 'Branches...', compare.branch_compare) self.menu_clone_repo = add_action(self, 'Clone...', guicmds.clone_repo) self.menu_clone_repo.setIcon(qtutils.git_icon()) self.menu_help_docs = add_action(self, 'Documentation', lambda: self.model.git.web__browse(resources.html_docs()), QtGui.QKeySequence.HelpContents) self.menu_commit_compare = add_action(self, 'Commits...', compare.compare) self.menu_commit_compare_file = add_action(self, 'Commits Touching File...', compare.compare_file) self.menu_visualize_current = add_action(self, 'Visualize Current Branch...', emit(self, signals.visualize_current)) self.menu_visualize_all = add_action(self, 'Visualize All Branches...', emit(self, signals.visualize_all)) self.menu_search_commits = add_action(self, 'Search...', search.search) self.menu_browse_branch = add_action(self, 'Browse Current Branch...', guicmds.browse_current) self.menu_browse_other_branch = add_action(self, 'Browse Other Branch...', guicmds.browse_other) self.menu_load_commitmsg_template = add_action(self, 'Get Commit Message Template', emit(self, signals.load_commit_template)) self.menu_help_about = add_action(self, 'About', launch_about_dialog) self.menu_branch_diff = add_action(self, 'SHA-1...', guicmds.branch_diff) self.menu_diff_expression = add_action(self, 'Expression...', guicmds.diff_expression) self.menu_create_tag = add_action(self, 'Create Tag...', createtag.create_tag) self.menu_create_branch = add_action(self, 'Create...', create_new_branch, 'Ctrl+B') self.menu_delete_branch = add_action(self, 'Delete...', guicmds.branch_delete) self.menu_checkout_branch = add_action(self, 'Checkout...', guicmds.checkout_branch, 'Alt+B') self.menu_rebase_branch = add_action(self, 'Rebase...', guicmds.rebase) self.menu_branch_review = add_action(self, 'Review...', guicmds.review_branch) self.menu_classic = add_action(self, 'Cola Classic...', cola_classic) self.menu_classic.setIcon(qtutils.git_icon()) self.menu_dag = add_action(self, 'DAG...', lambda: git_dag(self.model)) self.menu_dag.setIcon(qtutils.git_icon()) # Create the application menu self.menubar = QtGui.QMenuBar(self) # File Menu self.file_menu = create_menu('&File', self.menubar) self.file_menu.addAction(self.menu_preferences) self.file_menu.addSeparator() self.file_menu.addAction(self.menu_open_repo) self.file_menu.addAction(self.menu_clone_repo) self.file_menu.addAction(self.menu_manage_bookmarks) self.file_menu.addSeparator() self.file_menu.addAction(self.menu_rescan) self.file_menu.addSeparator() self.file_menu.addSeparator() self.file_menu.addAction(self.menu_load_commitmsg) self.file_menu.addAction(self.menu_load_commitmsg_template) self.file_menu.addSeparator() self.file_menu.addAction(self.menu_quit) # Add to menubar self.menubar.addAction(self.file_menu.menuAction()) # Commit Menu self.commit_menu = create_menu('Co&mmit', self.menubar) self.commit_menu.setTitle(tr('Commit@@verb')) self.commit_menu.addAction(self.menu_stage_modified) self.commit_menu.addAction(self.menu_stage_untracked) self.commit_menu.addSeparator() self.commit_menu.addAction(self.menu_unstage_all) self.commit_menu.addAction(self.menu_unstage_selected) self.commit_menu.addSeparator() self.commit_menu.addAction(self.menu_search_commits) # Add to menubar self.menubar.addAction(self.commit_menu.menuAction()) # Branch Menu self.branch_menu = create_menu('B&ranch', self.menubar) self.branch_menu.addAction(self.menu_branch_review) self.branch_menu.addSeparator() self.branch_menu.addAction(self.menu_create_branch) self.branch_menu.addAction(self.menu_checkout_branch) self.branch_menu.addAction(self.menu_rebase_branch) self.branch_menu.addAction(self.menu_delete_branch) self.branch_menu.addSeparator() self.branch_menu.addAction(self.menu_browse_branch) self.branch_menu.addAction(self.menu_browse_other_branch) self.branch_menu.addSeparator() self.branch_menu.addAction(self.menu_visualize_current) self.branch_menu.addAction(self.menu_visualize_all) self.branch_menu.addSeparator() self.branch_menu.addAction(self.menu_diff_branch) # Add to menubar self.menubar.addAction(self.branch_menu.menuAction()) # Actions menu self.actions_menu = create_menu('Act&ions', self.menubar) self.actions_menu.addAction(self.menu_merge_local) self.actions_menu.addAction(self.menu_stash) self.actions_menu.addSeparator() self.actions_menu.addAction(self.menu_fetch) self.actions_menu.addAction(self.menu_push) self.actions_menu.addAction(self.menu_pull) self.actions_menu.addSeparator() self.actions_menu.addAction(self.menu_create_tag) self.actions_menu.addSeparator() self.actions_menu.addAction(self.menu_export_patches) self.actions_menu.addAction(self.menu_cherry_pick) self.actions_menu.addSeparator() self.actions_menu.addAction(self.menu_merge_abort) self.actions_menu.addAction(self.menu_grep) # Add to menubar self.menubar.addAction(self.actions_menu.menuAction()) # Diff Menu self.diff_menu = create_menu('&Diff', self.menubar) self.diff_menu.addAction(self.menu_branch_diff) self.diff_menu.addAction(self.menu_diff_expression) self.diff_menu.addSeparator() self.diff_menu.addAction(self.menu_branch_compare) self.diff_menu.addAction(self.menu_commit_compare) self.diff_menu.addAction(self.menu_commit_compare_file) self.diff_menu.addSeparator() self.diff_menu.addAction(self.menu_show_diffstat) # Add to menubar self.menubar.addAction(self.diff_menu.menuAction()) # Tools Menu self.tools_menu = create_menu('&Tools', self.menubar) self.tools_menu.addAction(self.menu_classic) self.tools_menu.addAction(self.menu_dag) self.tools_menu.addSeparator() if self.classic_dockable: self.tools_menu.addAction(self.classicdockwidget.toggleViewAction()) self.tools_menu.addAction(self.diffdockwidget.toggleViewAction()) self.tools_menu.addAction(self.actiondockwidget.toggleViewAction()) self.tools_menu.addAction(self.commitdockwidget.toggleViewAction()) self.tools_menu.addAction(self.statusdockwidget.toggleViewAction()) self.tools_menu.addAction(self.logdockwidget.toggleViewAction()) self.menubar.addAction(self.tools_menu.menuAction()) # Help Menu self.help_menu = create_menu('&Help', self.menubar) self.help_menu.addAction(self.menu_help_docs) self.help_menu.addAction(self.menu_help_about) # Add to menubar self.menubar.addAction(self.help_menu.menuAction()) # Set main menu self.setMenuBar(self.menubar) # Arrange dock widgets top = Qt.TopDockWidgetArea bottom = Qt.BottomDockWidgetArea self.addDockWidget(top, self.commitdockwidget) if self.classic_dockable: self.addDockWidget(top, self.classicdockwidget) self.addDockWidget(top, self.statusdockwidget) self.addDockWidget(top, self.actiondockwidget) self.addDockWidget(bottom, self.logdockwidget) if self.classic_dockable: self.tabifyDockWidget(self.classicdockwidget, self.commitdockwidget) self.tabifyDockWidget(self.logdockwidget, self.diffdockwidget) # Listen for model notifications model.add_message_observer(model.message_mode_changed, self._mode_changed) model.add_message_observer(model.message_updated, self._update_view) prefs_model.add_message_observer(prefs_model.message_config_updated, self._config_updated) # Add button callbacks connect_button(self.rescan_button, emit(self, signals.rescan)) connect_button(self.alt_button, emit(self, signals.reset_mode)) connect_button(self.fetch_button, guicmds.fetch) connect_button(self.push_button, guicmds.push) connect_button(self.pull_button, guicmds.pull) connect_button(self.stash_button, stash.stash) connect_button(self.stage_button, self.stage) connect_button(self.unstage_button, self.unstage) self.connect(self, SIGNAL('update'), self._update_callback) self.connect(self, SIGNAL('apply_state'), self.apply_state) self.connect(self, SIGNAL('install_config_actions'), self._install_config_actions) # Install .git-config-defined actions self._config_task = None self.install_config_actions() # Restore saved settings self._gui_state_task = None self._load_gui_state() log(0, self.model.git_version + '\ncola version ' + version.version())
def __init__(self, model, parent): standard.MainWindow.__init__(self, parent) # Default size; this is thrown out when save/restore is used self.resize(987, 610) self.model = model self.prefs_model = prefs_model = PreferencesModel() # Internal field used by import/export_state(). # Change this whenever dockwidgets are removed. self.widget_version = 1 # Keeps track of merge messages we've seen self.merge_message_hash = "" self.setAcceptDrops(True) # Dockwidget options qtcompat.set_common_dock_options(self) self.classic_dockable = gitcfg.instance().get("cola.classicdockable") if self.classic_dockable: self.classicdockwidget = create_dock("Cola Classic", self) self.classicwidget = classic_widget(self) self.classicdockwidget.setWidget(self.classicwidget) # "Actions" widget self.actionsdockwidget = create_dock("Actions", self) self.actionsdockwidgetcontents = qt.QFlowLayoutWidget(self) layout = self.actionsdockwidgetcontents.layout() self.stage_button = create_button(text="Stage", layout=layout) self.unstage_button = create_button(text="Unstage", layout=layout) self.rescan_button = create_button(text="Rescan", layout=layout) self.fetch_button = create_button(text="Fetch...", layout=layout) self.push_button = create_button(text="Push...", layout=layout) self.pull_button = create_button(text="Pull...", layout=layout) self.stash_button = create_button(text="Stash...", layout=layout) self.alt_button = create_button(text="Exit Diff Mode", layout=layout) self.alt_button.hide() layout.addStretch() self.actionsdockwidget.setWidget(self.actionsdockwidgetcontents) # "Repository Status" widget self.statusdockwidget = create_dock("Repository Status", self) self.statusdockwidget.setWidget(StatusWidget(self)) # "Commit Message Editor" widget self.commitdockwidget = create_dock("Commit Message Editor", self) self.commitmsgeditor = CommitMessageEditor(model, self) relay_signal(self, self.commitmsgeditor, SIGNAL(signals.amend_mode)) relay_signal(self, self.commitmsgeditor, SIGNAL(signals.signoff)) relay_signal(self, self.commitmsgeditor, SIGNAL(signals.load_previous_message)) self.commitdockwidget.setWidget(self.commitmsgeditor) # "Command Output" widget logwidget = qtutils.logger() logwidget.setFont(diff_font()) self.logdockwidget = create_dock("Command Output", self) self.logdockwidget.setWidget(logwidget) # "Diff Viewer" widget self.diffdockwidget = create_dock("Diff Viewer", self) self.diff_viewer = DiffTextEdit(self.diffdockwidget) self.diffdockwidget.setWidget(self.diff_viewer) # All Actions self.menu_unstage_all = add_action(self, "Unstage All", emit(self, signals.unstage_all)) self.menu_unstage_all.setIcon(qtutils.icon("remove.svg")) self.menu_unstage_selected = add_action(self, "Unstage From Commit", emit(self, signals.unstage_selected)) self.menu_unstage_selected.setIcon(qtutils.icon("remove.svg")) self.menu_show_diffstat = add_action(self, "Diffstat", emit(self, signals.diffstat), "Alt+D") self.menu_stage_modified = add_action( self, "Stage Changed Files To Commit", emit(self, signals.stage_modified), "Alt+A" ) self.menu_stage_modified.setIcon(qtutils.icon("add.svg")) self.menu_stage_untracked = add_action( self, "Stage All Untracked", emit(self, signals.stage_untracked), "Alt+U" ) self.menu_stage_untracked.setIcon(qtutils.icon("add.svg")) self.menu_export_patches = add_action(self, "Export Patches...", guicmds.export_patches, "Alt+E") self.menu_preferences = add_action( self, "Preferences", lambda: preferences(model=prefs_model), QtGui.QKeySequence.Preferences, "Ctrl+O" ) self.menu_rescan = add_action(self, "Rescan", emit(self, signals.rescan_and_refresh), "Ctrl+R") self.menu_rescan.setIcon(qtutils.reload_icon()) self.menu_browse_recent = add_action(self, "Recently Modified Files...", browse_recent, "Shift+Ctrl+E") self.menu_cherry_pick = add_action(self, "Cherry-Pick...", guicmds.cherry_pick, "Ctrl+P") self.menu_load_commitmsg = add_action(self, "Load Commit Message...", guicmds.load_commitmsg) self.menu_quit = add_action(self, "Quit", self.close, "Ctrl+Q") self.menu_manage_bookmarks = add_action(self, "Bookmarks...", manage_bookmarks) self.menu_grep = add_action(self, "Grep", guicmds.grep) self.menu_merge_local = add_action(self, "Merge...", merge.local_merge) self.menu_merge_abort = add_action(self, "Abort Merge...", merge.abort_merge) self.menu_fetch = add_action(self, "Fetch...", guicmds.fetch) self.menu_push = add_action(self, "Push...", guicmds.push) self.menu_pull = add_action(self, "Pull...", guicmds.pull) self.menu_open_repo = add_action(self, "Open...", guicmds.open_repo) self.menu_open_repo.setIcon(qtutils.open_icon()) self.menu_stash = add_action(self, "Stash...", stash.stash, "Alt+Shift+S") self.menu_diff_branch = add_action(self, "Apply Changes From Branch...", guicmds.diff_branch) self.menu_branch_compare = add_action(self, "Branches...", compare.branch_compare) self.menu_clone_repo = add_action(self, "Clone...", guicmds.clone_repo) self.menu_clone_repo.setIcon(qtutils.git_icon()) self.menu_help_docs = add_action( self, "Documentation", resources.show_html_docs, QtGui.QKeySequence.HelpContents ) self.menu_help_shortcuts = add_action(self, "Keyboard Shortcuts", show_shortcuts, QtCore.Qt.Key_Question) self.menu_commit_compare = add_action(self, "Commits...", compare.compare) self.menu_commit_compare_file = add_action(self, "Commits Touching File...", compare.compare_file) self.menu_visualize_current = add_action( self, "Visualize Current Branch...", emit(self, signals.visualize_current) ) self.menu_visualize_all = add_action(self, "Visualize All Branches...", emit(self, signals.visualize_all)) self.menu_search_commits = add_action(self, "Search...", search.search) self.menu_browse_branch = add_action(self, "Browse Current Branch...", guicmds.browse_current) self.menu_browse_other_branch = add_action(self, "Browse Other Branch...", guicmds.browse_other) self.menu_load_commitmsg_template = add_action( self, "Get Commit Message Template", emit(self, signals.load_commit_template) ) self.menu_help_about = add_action(self, "About", launch_about_dialog) self.menu_branch_diff = add_action(self, "SHA-1...", guicmds.branch_diff) self.menu_diff_expression = add_action(self, "Expression...", guicmds.diff_expression) self.menu_create_tag = add_action(self, "Create Tag...", createtag.create_tag) self.menu_create_branch = add_action(self, "Create...", create_new_branch, "Ctrl+B") self.menu_delete_branch = add_action(self, "Delete...", guicmds.branch_delete) self.menu_checkout_branch = add_action(self, "Checkout...", guicmds.checkout_branch, "Alt+B") self.menu_rebase_branch = add_action(self, "Rebase...", guicmds.rebase) self.menu_branch_review = add_action(self, "Review...", guicmds.review_branch) self.menu_classic = add_action(self, "Cola Classic...", cola_classic) self.menu_classic.setIcon(qtutils.git_icon()) self.menu_dag = add_action(self, "DAG...", lambda: git_dag(self.model)) self.menu_dag.setIcon(qtutils.git_icon()) # Relayed actions status_tree = self.statusdockwidget.widget().tree self.addAction(status_tree.up) self.addAction(status_tree.down) self.addAction(status_tree.process_selection) self.addAction(status_tree.launch_difftool) # Create the application menu self.menubar = QtGui.QMenuBar(self) # File Menu self.file_menu = create_menu("&File", self.menubar) self.file_menu.addAction(self.menu_preferences) self.file_menu.addSeparator() self.file_menu.addAction(self.menu_open_repo) self.file_menu.addAction(self.menu_clone_repo) self.file_menu.addAction(self.menu_manage_bookmarks) self.file_menu.addSeparator() self.file_menu.addAction(self.menu_rescan) self.file_menu.addSeparator() self.file_menu.addAction(self.menu_browse_recent) self.file_menu.addSeparator() self.file_menu.addAction(self.menu_load_commitmsg) self.file_menu.addAction(self.menu_load_commitmsg_template) self.file_menu.addSeparator() self.file_menu.addAction(self.menu_quit) # Add to menubar self.menubar.addAction(self.file_menu.menuAction()) # Commit Menu self.commit_menu = create_menu("Co&mmit", self.menubar) self.commit_menu.setTitle(tr("Commit@@verb")) self.commit_menu.addAction(self.menu_stage_modified) self.commit_menu.addAction(self.menu_stage_untracked) self.commit_menu.addSeparator() self.commit_menu.addAction(self.menu_unstage_all) self.commit_menu.addAction(self.menu_unstage_selected) self.commit_menu.addSeparator() self.commit_menu.addAction(self.menu_search_commits) # Add to menubar self.menubar.addAction(self.commit_menu.menuAction()) # Branch Menu self.branch_menu = create_menu("B&ranch", self.menubar) self.branch_menu.addAction(self.menu_branch_review) self.branch_menu.addSeparator() self.branch_menu.addAction(self.menu_create_branch) self.branch_menu.addAction(self.menu_checkout_branch) self.branch_menu.addAction(self.menu_rebase_branch) self.branch_menu.addAction(self.menu_delete_branch) self.branch_menu.addSeparator() self.branch_menu.addAction(self.menu_browse_branch) self.branch_menu.addAction(self.menu_browse_other_branch) self.branch_menu.addSeparator() self.branch_menu.addAction(self.menu_visualize_current) self.branch_menu.addAction(self.menu_visualize_all) self.branch_menu.addSeparator() self.branch_menu.addAction(self.menu_diff_branch) # Add to menubar self.menubar.addAction(self.branch_menu.menuAction()) # Actions menu self.actions_menu = create_menu("Act&ions", self.menubar) self.actions_menu.addAction(self.menu_merge_local) self.actions_menu.addAction(self.menu_stash) self.actions_menu.addSeparator() self.actions_menu.addAction(self.menu_fetch) self.actions_menu.addAction(self.menu_push) self.actions_menu.addAction(self.menu_pull) self.actions_menu.addSeparator() self.actions_menu.addAction(self.menu_create_tag) self.actions_menu.addSeparator() self.actions_menu.addAction(self.menu_export_patches) self.actions_menu.addAction(self.menu_cherry_pick) self.actions_menu.addSeparator() self.actions_menu.addAction(self.menu_merge_abort) self.actions_menu.addAction(self.menu_grep) # Add to menubar self.menubar.addAction(self.actions_menu.menuAction()) # Diff Menu self.diff_menu = create_menu("&Diff", self.menubar) self.diff_menu.addAction(self.menu_branch_diff) self.diff_menu.addAction(self.menu_diff_expression) self.diff_menu.addSeparator() self.diff_menu.addAction(self.menu_branch_compare) self.diff_menu.addAction(self.menu_commit_compare) self.diff_menu.addAction(self.menu_commit_compare_file) self.diff_menu.addSeparator() self.diff_menu.addAction(self.menu_show_diffstat) # Add to menubar self.menubar.addAction(self.diff_menu.menuAction()) # Tools Menu self.tools_menu = create_menu("&Tools", self.menubar) self.tools_menu.addAction(self.menu_classic) self.tools_menu.addAction(self.menu_dag) self.tools_menu.addSeparator() if self.classic_dockable: self.tools_menu.addAction(self.classicdockwidget.toggleViewAction()) self.setup_dockwidget_tools_menu() self.menubar.addAction(self.tools_menu.menuAction()) # Help Menu self.help_menu = create_menu("&Help", self.menubar) self.help_menu.addAction(self.menu_help_docs) self.help_menu.addAction(self.menu_help_shortcuts) self.help_menu.addAction(self.menu_help_about) # Add to menubar self.menubar.addAction(self.help_menu.menuAction()) # Set main menu self.setMenuBar(self.menubar) # Arrange dock widgets top = Qt.TopDockWidgetArea bottom = Qt.BottomDockWidgetArea self.addDockWidget(top, self.commitdockwidget) if self.classic_dockable: self.addDockWidget(top, self.classicdockwidget) self.addDockWidget(top, self.statusdockwidget) self.addDockWidget(top, self.actionsdockwidget) self.addDockWidget(bottom, self.logdockwidget) if self.classic_dockable: self.tabifyDockWidget(self.classicdockwidget, self.commitdockwidget) self.tabifyDockWidget(self.logdockwidget, self.diffdockwidget) # Listen for model notifications model.add_message_observer(model.message_mode_changed, self._mode_changed) model.add_message_observer(model.message_updated, self._update_view) prefs_model.add_message_observer(prefs_model.message_config_updated, self._config_updated) # Add button callbacks connect_button(self.rescan_button, emit(self, signals.rescan_and_refresh)) connect_button(self.alt_button, emit(self, signals.reset_mode)) connect_button(self.fetch_button, guicmds.fetch) connect_button(self.push_button, guicmds.push) connect_button(self.pull_button, guicmds.pull) connect_button(self.stash_button, stash.stash) connect_button(self.stage_button, self.stage) connect_button(self.unstage_button, self.unstage) self.connect(self, SIGNAL("update"), self._update_callback) self.connect(self, SIGNAL("apply_state"), self.apply_state) self.connect(self, SIGNAL("install_config_actions"), self._install_config_actions) # Install .git-config-defined actions self._config_task = None self.install_config_actions() # Restore saved settings self._gui_state_task = None self._load_gui_state() log(0, self.model.git_version + "\ncola version " + version.version())
def __init__(self, parent, name, opts): standard.Dialog.__init__(self, parent) self.setWindowModality(QtCore.Qt.ApplicationModal) self.name = name self.opts = opts self.layt = QtGui.QVBoxLayout() self.layt.setMargin(10) self.setLayout(self.layt) title = opts.get('title') if title: self.setWindowTitle(os.path.expandvars(title)) self.prompt = QtGui.QLabel() prompt = opts.get('prompt') if prompt: self.prompt.setText(os.path.expandvars(prompt)) self.layt.addWidget(self.prompt) self.argslabel = QtGui.QLabel() if 'argprompt' not in opts or opts.get('argprompt') is True: argprompt = qtutils.tr('Arguments') else: argprompt = opts.get('argprompt') self.argslabel.setText(argprompt) self.argstxt = QtGui.QLineEdit() self.argslayt = QtGui.QHBoxLayout() self.argslayt.addWidget(self.argslabel) self.argslayt.addWidget(self.argstxt) self.layt.addLayout(self.argslayt) if not self.opts.get('argprompt'): self.argslabel.setMinimumSize(1, 1) self.argstxt.setMinimumSize(1, 1) self.argstxt.hide() self.argslabel.hide() revs = ( ('Local Branch', gitcmds.branch_list(remote=False)), ('Tracking Branch', gitcmds.branch_list(remote=True)), ('Tag', gitcmds.tag_list()), ) if 'revprompt' not in opts or opts.get('revprompt') is True: revprompt = qtutils.tr('Revision') else: revprompt = opts.get('revprompt') self.revselect = RevisionSelector(self, revs) self.revselect.set_revision_label(revprompt) self.layt.addWidget(self.revselect) if not opts.get('revprompt'): self.revselect.hide() # Close/Run buttons self.btnlayt = QtGui.QHBoxLayout() self.btnlayt.addStretch() self.closebtn = qt.create_button(self.tr('Close'), self.btnlayt) self.runbtn = qt.create_button(self.tr('Run'), self.btnlayt) self.runbtn.setDefault(True) self.layt.addLayout(self.btnlayt) self.connect(self.closebtn, SIGNAL('clicked()'), self.reject) self.connect(self.runbtn, SIGNAL('clicked()'), self.accept) # Widen the dialog by default self.resize(666, self.height())
def __init__(self, parent=None): MainWindowBase.__init__(self, parent) # Default size; this is thrown out when save/restore is used self.resize(987, 610) # Dockwidget options qtcompat.set_common_dock_options(self) self.classic_dockable = gitcfg.instance().get('cola.classicdockable') if self.classic_dockable: self.classicdockwidget = self.create_dock('Cola Classic') self.classicwidget = classic.widget(parent=self) self.classicdockwidget.setWidget(self.classicwidget) # "Actions" widget self.actiondockwidget = self.create_dock('Actions') self.actiondockwidgetcontents = qt.QFlowLayoutWidget(parent=self) layout = self.actiondockwidgetcontents.layout() self.rescan_button = qt.create_button('Rescan', layout) self.stage_button = qt.create_button('Stage', layout) self.unstage_button = qt.create_button('Unstage', layout) self.fetch_button = qt.create_button('Fetch...', layout) self.push_button = qt.create_button('Push...', layout) self.pull_button = qt.create_button('Pull...', layout) self.stash_button = qt.create_button('Stash...', layout) self.alt_button = qt.create_button('Exit Diff Mode', layout) self.alt_button.hide() layout.addStretch() self.actiondockwidget.setWidget(self.actiondockwidgetcontents) # "Repository Status" widget self.statusdockwidget = self.create_dock('Repository Status') self.statusdockwidget.setWidget(status.StatusWidget(self)) # "Commit Message Editor" widget self.commitdockwidget = self.create_dock('Commit Message Editor') self.commitdockwidgetcontents = QtGui.QWidget() self.commitdockwidgetlayout = QtGui.QVBoxLayout(self.commitdockwidgetcontents) self.commitdockwidgetlayout.setMargin(0) self.commitdockwidgetlayout.setSpacing(0) self.commitmsg = QtGui.QTextEdit(self.commitdockwidgetcontents) self.commitmsg.setMinimumSize(QtCore.QSize(1, 1)) policy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Minimum) self.commitmsg.setSizePolicy(policy) self.commitmsg.setLineWrapMode(QtGui.QTextEdit.NoWrap) self.commitmsg.setAcceptRichText(False) self.commit_ctrls_layt = QtGui.QHBoxLayout() self.commit_ctrls_layt.setSpacing(4) self.commit_ctrls_layt.setMargin(4) # Sign off and commit buttons self.signoff_button = qt.create_toolbutton(self, text='Sign Off', tooltip='Sign off on this commit', icon=qtutils.apply_icon()) self.commit_button = qt.create_toolbutton(self, text='Commit@@verb', tooltip='Commit staged changes', icon=qtutils.save_icon()) # Position display self.position_label = QtGui.QLabel(self.actiondockwidgetcontents) self.position_label.setAlignment(Qt.AlignCenter | Qt.AlignVCenter) # Amend checkbox self.amend_checkbox = QtGui.QCheckBox(self.commitdockwidgetcontents) self.amend_checkbox.setText(tr('Amend Last Commit')) self.commit_ctrls_layt.addWidget(self.signoff_button) self.commit_ctrls_layt.addWidget(self.commit_button) self.commit_ctrls_layt.addWidget(self.position_label) self.commit_ctrls_layt.addStretch() self.commit_ctrls_layt.addWidget(self.amend_checkbox) self.commitdockwidgetlayout.addWidget(self.commitmsg) self.commitdockwidgetlayout.addLayout(self.commit_ctrls_layt) self.commitdockwidget.setWidget(self.commitdockwidgetcontents) # "Command Output" widget logwidget = qtutils.logger() self.logdockwidget = self.create_dock('Command Output') self.logdockwidget.setWidget(logwidget) # "Diff Viewer" widget self.diffdockwidget = self.create_dock('Diff Viewer') self.diffdockwidgetcontents = QtGui.QWidget() self.diffdockwidgetlayout = QtGui.QVBoxLayout(self.diffdockwidgetcontents) self.diffdockwidgetlayout.setMargin(0) self.display_text = QtGui.QTextEdit(self.diffdockwidgetcontents) self.display_text.setMinimumSize(QtCore.QSize(1, 1)) self.display_text.setLineWrapMode(QtGui.QTextEdit.NoWrap) self.display_text.setReadOnly(True) self.display_text.setAcceptRichText(False) self.display_text.setCursorWidth(2) self.display_text.setTextInteractionFlags(Qt.LinksAccessibleByKeyboard | Qt.LinksAccessibleByMouse | Qt.TextBrowserInteraction | Qt.TextSelectableByKeyboard | Qt.TextSelectableByMouse) self.diffdockwidgetlayout.addWidget(self.display_text) self.diffdockwidget.setWidget(self.diffdockwidgetcontents) # All Actions self.menu_unstage_selected = self.create_action('Unstage From Commit') self.menu_show_diffstat = self.create_action('Diffstat') self.menu_stage_modified =\ self.create_action('Stage Changed Files To Commit') self.menu_stage_untracked = self.create_action('Stage All Untracked') self.menu_export_patches = self.create_action('Export Patches...') self.menu_cut = self.create_action('Cut') self.menu_copy = self.create_action('Copy', local=True) self.menu_paste = self.create_action('Paste') self.menu_select_all = self.create_action('Select All') self.menu_options = self.create_action('Preferences') self.menu_delete = self.create_action('Delete') self.menu_undo = self.create_action('Undo') self.menu_redo = self.create_action('Redo') self.menu_rescan = self.create_action('Rescan') self.menu_cherry_pick = self.create_action('Cherry-Pick...') self.menu_unstage_all = self.create_action('Unstage All') self.menu_load_commitmsg = self.create_action('Load Commit Message...') self.menu_quit = self.create_action('Quit') self.menu_search_revision = self.create_action('Revision ID...') self.menu_search_path =\ self.create_action('Commits Touching Path(s)...') self.menu_search_revision_range =\ self.create_action('Revision Range...') self.menu_search_date_range = self.create_action('Latest Commits...') self.menu_search_diff =\ self.create_action('Content Introduced in Commit...') self.menu_search_author = self.create_action('Commits By Author...') self.menu_search_committer =\ self.create_action('Commits By Committer...') self.menu_manage_bookmarks = self.create_action('Bookmarks...') self.menu_save_bookmark = self.create_action('Bookmark Current...') self.menu_grep = self.create_action('Grep') self.menu_merge_local = self.create_action('Merge...') self.menu_merge_abort = self.create_action('Abort Merge...') self.menu_fetch = self.create_action('Fetch...') self.menu_push = self.create_action('Push...') self.menu_pull = self.create_action('Pull...') self.menu_open_repo = self.create_action('Open...') self.menu_stash = self.create_action('Stash...') self.menu_diff_branch =\ self.create_action('Apply Changes From Branch...') self.menu_branch_compare = self.create_action('Branches...') self.menu_clone_repo = self.create_action('Clone...') self.menu_help_docs = self.create_action('Documentation') self.menu_commit_compare = self.create_action('Commits...') self.menu_visualize_current =\ self.create_action('Visualize Current Branch...') self.menu_visualize_all =\ self.create_action('Visualize All Branches...') self.menu_browse_commits = self.create_action('Browse...') self.menu_search_commits = self.create_action('Search...') self.menu_browse_branch =\ self.create_action('Browse Current Branch...') self.menu_browse_other_branch =\ self.create_action('Browse Other Branch...') self.menu_load_commitmsg_template =\ self.create_action('Get Commit Message Template') self.menu_commit_compare_file =\ self.create_action('Commits Touching File...') self.menu_help_about = self.create_action('About') self.menu_branch_diff = self.create_action('SHA-1...') self.menu_diff_expression = self.create_action('Expression...') self.menu_create_tag = self.create_action('Create Tag...') self.menu_create_branch = self.create_action('Create...') self.menu_delete_branch = self.create_action('Delete...') self.menu_checkout_branch = self.create_action('Checkout...') self.menu_rebase_branch = self.create_action('Rebase...') self.menu_branch_review = self.create_action('Review...') self.menu_classic = self.create_action('Cola Classic...') self.menu_dag = self.create_action('DAG...') # Create the application menu self.menubar = QtGui.QMenuBar(self) # File Menu self.file_menu = self.create_menu('&File', self.menubar) self.file_menu.addAction(self.menu_open_repo) self.file_menu.addAction(self.menu_clone_repo) self.file_menu.addSeparator() self.file_menu.addAction(self.menu_rescan) self.file_menu.addSeparator() self.file_menu.addAction(self.menu_manage_bookmarks) self.file_menu.addAction(self.menu_save_bookmark) self.file_menu.addSeparator() self.file_menu.addAction(self.menu_load_commitmsg) self.file_menu.addAction(self.menu_load_commitmsg_template) self.file_menu.addSeparator() self.file_menu.addAction(self.menu_quit) # Add to menubar self.menubar.addAction(self.file_menu.menuAction()) # Edit Menu self.edit_menu = self.create_menu('&Edit', self.menubar) self.edit_menu.addAction(self.menu_undo) self.edit_menu.addAction(self.menu_redo) self.edit_menu.addSeparator() self.edit_menu.addAction(self.menu_cut) self.edit_menu.addAction(self.menu_copy) self.edit_menu.addAction(self.menu_paste) self.edit_menu.addAction(self.menu_delete) self.edit_menu.addSeparator() self.edit_menu.addAction(self.menu_select_all) self.edit_menu.addSeparator() self.edit_menu.addAction(self.menu_options) # Add to menubar self.menubar.addAction(self.edit_menu.menuAction()) # Commit Menu self.commit_menu = self.create_menu('Co&mmit', self.menubar) self.commit_menu.addAction(self.menu_stage_modified) self.commit_menu.addAction(self.menu_stage_untracked) self.commit_menu.addSeparator() self.commit_menu.addAction(self.menu_unstage_all) self.commit_menu.addAction(self.menu_unstage_selected) self.commit_menu.addSeparator() self.commit_menu.addAction(self.menu_browse_commits) self.commit_menu.addAction(self.menu_search_commits) # Add to menubar self.menubar.addAction(self.commit_menu.menuAction()) # Branch Menu self.branch_menu = self.create_menu('B&ranch', self.menubar) self.branch_menu.addAction(self.menu_branch_review) self.branch_menu.addSeparator() self.branch_menu.addAction(self.menu_create_branch) self.branch_menu.addAction(self.menu_checkout_branch) self.branch_menu.addAction(self.menu_rebase_branch) self.branch_menu.addAction(self.menu_delete_branch) self.branch_menu.addSeparator() self.branch_menu.addAction(self.menu_browse_branch) self.branch_menu.addAction(self.menu_browse_other_branch) self.branch_menu.addSeparator() self.branch_menu.addAction(self.menu_visualize_current) self.branch_menu.addAction(self.menu_visualize_all) self.branch_menu.addSeparator() self.branch_menu.addAction(self.menu_diff_branch) # Add to menubar self.menubar.addAction(self.branch_menu.menuAction()) # Actions menu self.actions_menu = self.create_menu('Act&ions', self.menubar) self.actions_menu.addAction(self.menu_merge_local) self.actions_menu.addAction(self.menu_stash) self.actions_menu.addSeparator() self.actions_menu.addAction(self.menu_fetch) self.actions_menu.addAction(self.menu_push) self.actions_menu.addAction(self.menu_pull) self.actions_menu.addSeparator() self.actions_menu.addAction(self.menu_create_tag) self.actions_menu.addSeparator() self.actions_menu.addAction(self.menu_export_patches) self.actions_menu.addAction(self.menu_cherry_pick) self.actions_menu.addSeparator() self.actions_menu.addAction(self.menu_merge_abort) self.actions_menu.addAction(self.menu_grep) # Add to menubar self.menubar.addAction(self.actions_menu.menuAction()) # Diff Menu self.diff_menu = self.create_menu('&Diff', self.menubar) self.diff_menu.addAction(self.menu_branch_diff) self.diff_menu.addAction(self.menu_diff_expression) self.diff_menu.addSeparator() self.diff_menu.addAction(self.menu_branch_compare) self.diff_menu.addAction(self.menu_commit_compare) self.diff_menu.addAction(self.menu_commit_compare_file) self.diff_menu.addSeparator() self.diff_menu.addAction(self.menu_show_diffstat) # Add to menubar self.menubar.addAction(self.diff_menu.menuAction()) # Tools Menu self.tools_menu = self.create_menu('&Tools', self.menubar) self.tools_menu.addAction(self.menu_classic) self.tools_menu.addAction(self.menu_dag) self.tools_menu.addSeparator() if self.classic_dockable: self.tools_menu.addAction(self.classicdockwidget.toggleViewAction()) self.tools_menu.addAction(self.diffdockwidget.toggleViewAction()) self.tools_menu.addAction(self.actiondockwidget.toggleViewAction()) self.tools_menu.addAction(self.commitdockwidget.toggleViewAction()) self.tools_menu.addAction(self.statusdockwidget.toggleViewAction()) self.tools_menu.addAction(self.logdockwidget.toggleViewAction()) self.menubar.addAction(self.tools_menu.menuAction()) # Help Menu self.help_menu = self.create_menu('&Help', self.menubar) self.help_menu.addAction(self.menu_help_docs) self.help_menu.addAction(self.menu_help_about) # Add to menubar self.menubar.addAction(self.help_menu.menuAction()) # Set main menu self.setMenuBar(self.menubar) # Shortcuts self.menu_show_diffstat.setShortcut(tr('Ctrl+D')) self.menu_stage_modified.setShortcut(tr('Alt+A')) self.menu_stage_untracked.setShortcut(tr('Alt+U')) self.menu_export_patches.setShortcut(tr('Ctrl+E')) self.menu_cut.setShortcut(QtGui.QKeySequence.Cut) self.menu_copy.setShortcut(QtGui.QKeySequence.Copy) self.menu_paste.setShortcut(QtGui.QKeySequence.Paste) self.menu_select_all.setShortcut(QtGui.QKeySequence.SelectAll) self.menu_options.setShortcut(tr('Ctrl+O')) self.menu_delete.setShortcut(tr('Del')) self.menu_undo.setShortcut(tr('Ctrl+Z')) self.menu_redo.setShortcut(tr('Ctrl+Shift+Z')) self.menu_rescan.setShortcut(tr('Ctrl+R')) self.menu_cherry_pick.setShortcut(tr('Ctrl+P')) self.menu_quit.setShortcut(tr('Ctrl+Q')) self.menu_create_branch.setShortcut(tr('Ctrl+B')) self.menu_checkout_branch.setShortcut(tr('Alt+B')) self.menu_stash.setShortcut(tr('Alt+Shift+S')) self.menu_help_docs.setShortcut(tr('F1')) # Arrange dock widgets top = Qt.TopDockWidgetArea bottom = Qt.BottomDockWidgetArea self.addDockWidget(top, self.commitdockwidget) if self.classic_dockable: self.addDockWidget(top, self.classicdockwidget) self.addDockWidget(top, self.statusdockwidget) self.addDockWidget(top, self.actiondockwidget) self.addDockWidget(bottom, self.logdockwidget) if self.classic_dockable: self.tabifyDockWidget(self.classicdockwidget, self.commitdockwidget) self.tabifyDockWidget(self.logdockwidget, self.diffdockwidget)
def __init__(self, parent): standard.Dialog.__init__(self, parent=parent) self.setWindowModality(QtCore.Qt.WindowModal) self.setWindowTitle(self.tr('Create Tag')) self.resize(506, 295) self._main_layt = QtGui.QVBoxLayout(self) self._main_layt.setContentsMargins(6, 12, 6, 6) # Form layout for inputs self._input_form_layt = QtGui.QFormLayout() self._input_form_layt.setFieldGrowthPolicy(QtGui.QFormLayout.ExpandingFieldsGrow) # Tag label self._tag_name_label = QtGui.QLabel(self) self._tag_name_label.setText(self.tr('Name')) self._input_form_layt.setWidget(0, QtGui.QFormLayout.LabelRole, self._tag_name_label) self.tag_name = QtGui.QLineEdit(self) self.tag_name.setToolTip(self.tr('Specifies the tag name')) self._input_form_layt.setWidget(0, QtGui.QFormLayout.FieldRole, self.tag_name) # Sign Tag self._sign_label = QtGui.QLabel(self) self._sign_label.setText(self.tr('Sign Tag')) self._input_form_layt.setWidget(1, QtGui.QFormLayout.LabelRole, self._sign_label) self.sign_tag = QtGui.QCheckBox(self) self.sign_tag.setToolTip( self.tr('Whether to sign the tag (git tag -s)')) self._input_form_layt.setWidget(1, QtGui.QFormLayout.FieldRole, self.sign_tag) self._main_layt.addLayout(self._input_form_layt) # Tag message self._tag_msg_label = QtGui.QLabel(self) self._tag_msg_label.setText(self.tr('Message')) self._input_form_layt.setWidget(2, QtGui.QFormLayout.LabelRole, self._tag_msg_label) # Exposed self.tag_msg = QtGui.QTextEdit(self) self.tag_msg.setAcceptRichText(False) self.tag_msg.setToolTip(self.tr('Specifies the tag message')) self.tag_msg.setFont(diff_font()) self._input_form_layt.setWidget(2, QtGui.QFormLayout.FieldRole, self.tag_msg) # Revision self._rev_label = QtGui.QLabel(self) self._rev_label.setText(self.tr('Revision')) self._input_form_layt.setWidget(3, QtGui.QFormLayout.LabelRole, self._rev_label) # Exposed self.revision = QtGui.QComboBox(self) self.revision.setEditable(True) self.revision.setToolTip(self.tr('Specifies the SHA-1 to tag')) self._input_form_layt.setWidget(3, QtGui.QFormLayout.FieldRole, self.revision) # Buttons self._button_hbox_layt = QtGui.QHBoxLayout() self._button_spacer = QtGui.QSpacerItem(1, 1, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self._button_hbox_layt.addItem(self._button_spacer) self.create_button = qt.create_button(text='Create Tag', icon=qtutils.git_icon()) self._button_hbox_layt.addWidget(self.create_button) self._main_layt.addLayout(self._button_hbox_layt) self.close_button = qt.create_button(text='Close') self._button_hbox_layt.addWidget(self.close_button) self.connect(self.close_button, SIGNAL('clicked()'), self.accept)