def __init__(self, lineedit, title, button_text, parent, icon=None): QtGui.QDialog.__init__(self, parent) self.setWindowTitle(title) self.setMinimumWidth(333) self.label = QtGui.QLabel() self.label.setText(title) self.lineedit = lineedit() self.setFocusProxy(self.lineedit) if icon is None: icon = icons.ok() self.ok_button = qtutils.create_button(text=button_text, icon=icon) self.close_button = qtutils.close_button() self.button_layout = qtutils.hbox(defs.no_margin, defs.button_spacing, qtutils.STRETCH, self.ok_button, self.close_button) self.main_layout = qtutils.vbox(defs.margin, defs.spacing, self.label, self.lineedit, self.button_layout) self.setLayout(self.main_layout) qtutils.connect_button(self.ok_button, self.accept) qtutils.connect_button(self.close_button, self.reject) self.connect(self.lineedit, SIGNAL('textChanged(QString)'), self.text_changed) self.connect(self.lineedit, SIGNAL('return()'), self.accept) self.setWindowModality(Qt.WindowModal) self.ok_button.setEnabled(False)
def __init__(self, parent=None): QtGui.QDialog.__init__(self, parent) self.setWindowTitle(N_('About git-cola')) self.setWindowModality(Qt.WindowModal) self.label = QtGui.QLabel() self.pixmap = QtGui.QPixmap(icons.name_from_basename('logo-top.png')) #self.label.setStyleSheet('QWidget {background: #000; }') self.label.setPixmap(self.pixmap) self.label.setAlignment(Qt.AlignRight | Qt.AlignTop) palette = self.label.palette() palette.setColor(QtGui.QPalette.Window, Qt.black) self.label.setAutoFillBackground(True) self.label.setPalette(palette) self.text = MonoTextView(self) self.text.setReadOnly(True) self.text.setPlainText(COPYRIGHT) self.close_button = qtutils.close_button() self.close_button.setDefault(True) self.button_layout = qtutils.hbox(defs.spacing, defs.margin, qtutils.STRETCH, self.close_button) self.main_layout = qtutils.vbox(defs.no_margin, defs.spacing, self.label, self.text, self.button_layout) self.setLayout(self.main_layout) self.resize(666, 420) qtutils.connect_button(self.close_button, self.accept)
def __init__(self, model, parent=None, title=None, multiselect=True, syntax=True): QtGui.QDialog.__init__(self, parent) self.model = model if title: self.setWindowTitle(title) self.commit_list = QtGui.QListWidget() if multiselect: mode = QtGui.QAbstractItemView.ExtendedSelection else: mode = QtGui.QAbstractItemView.SingleSelection self.commit_list.setSelectionMode(mode) self.commit_list.setAlternatingRowColors(True) self.commit_text = DiffTextEdit(self, whitespace=False) self.label = QtGui.QLabel() self.label.setText(N_('Revision Expression:')) self.revision = QtGui.QLineEdit() self.revision.setReadOnly(True) self.select_button = qtutils.ok_button(N_('Select'), enabled=False, default=True) self.close_button = qtutils.close_button() # Make the list widget slighty larger self.splitter = qtutils.splitter(Qt.Vertical, self.commit_list, self.commit_text) self.splitter.setSizes([100, 150]) self.input_layout = qtutils.hbox(defs.no_margin, defs.spacing, self.label, self.revision, self.select_button, self.close_button) self.main_layout = qtutils.vbox(defs.margin, defs.margin, self.splitter, self.input_layout) self.setLayout(self.main_layout) self.connect(self.commit_list, SIGNAL('itemSelectionChanged()'), self.commit_sha1_selected) self.connect(self.commit_list, SIGNAL('itemDoubleClicked(QListWidgetItem*)'), self.commit_sha1_double_clicked) qtutils.connect_button(self.select_button, self.accept) qtutils.connect_button(self.close_button, self.reject) self.resize(700, 420)
def __init__(self, title, parent=None): standard.Dialog.__init__(self, parent) self.setWindowTitle(title) if parent is not None: self.setWindowModality(Qt.ApplicationModal) # Construct the process self.proc = QtCore.QProcess(self) self.exitstatus = 0 self.out = '' self.err = '' # Create the text browser self.output_text = QtGui.QTextBrowser(self) self.output_text.setAcceptDrops(False) self.output_text.setTabChangesFocus(True) self.output_text.setUndoRedoEnabled(False) self.output_text.setReadOnly(True) self.output_text.setAcceptRichText(False) # Create abort / close buttons # Start with abort disabled - will be enabled when the process is run. self.button_abort = qtutils.create_button(text=N_('Abort'), enabled=False) self.button_close = qtutils.close_button() # Put them in a horizontal layout at the bottom. self.button_box = QtGui.QDialogButtonBox(self) self.button_box.addButton(self.button_abort, QtGui.QDialogButtonBox.RejectRole) self.button_box.addButton(self.button_close, QtGui.QDialogButtonBox.AcceptRole) # Connect the signals to the process self.connect(self.proc, SIGNAL('readyReadStandardOutput()'), self.read_stdout) self.connect(self.proc, SIGNAL('readyReadStandardError()'), self.read_stderr) self.connect(self.proc, SIGNAL('finished(int)'), self.finishProc) self.connect(self.proc, SIGNAL('stateChanged(QProcess::ProcessState)'), self.stateChanged) qtutils.connect_button(self.button_abort, self.abortProc) qtutils.connect_button(self.button_close, self.close) self._layout = qtutils.vbox(defs.margin, defs.spacing, self.output_text, self.button_box) self.setLayout(self._layout) self.resize(720, 420)
def __init__(self, model, parent=None): standard.Dialog.__init__(self, parent=parent) self.setWindowTitle(N_('Preferences')) if parent is not None: self.setWindowModality(QtCore.Qt.WindowModal) self.resize(600, 360) self.tab_bar = QtGui.QTabBar() self.tab_bar.setDrawBase(False) self.tab_bar.addTab(N_('All Repositories')) self.tab_bar.addTab(N_('Current Repository')) self.tab_bar.addTab(N_('Settings')) self.user_form = RepoFormWidget(model, self, source='user') self.repo_form = RepoFormWidget(model, self, source='repo') self.options_form = SettingsFormWidget(model, self) self.stack_widget = QtGui.QStackedWidget() self.stack_widget.addWidget(self.user_form) self.stack_widget.addWidget(self.repo_form) self.stack_widget.addWidget(self.options_form) self.close_button = qtutils.close_button() self.button_layout = qtutils.hbox(defs.no_margin, defs.spacing, qtutils.STRETCH, self.close_button) self.main_layout = qtutils.vbox(defs.margin, defs.spacing, self.tab_bar, self.stack_widget, self.button_layout) self.setLayout(self.main_layout) self.connect(self.tab_bar, SIGNAL('currentChanged(int)'), self.stack_widget.setCurrentIndex) self.connect(self.stack_widget, SIGNAL('currentChanged(int)'), self.update_widget) qtutils.connect_button(self.close_button, self.accept) qtutils.add_close_action(self) self.update_widget(0)
def __init__(self, model, select_file=False, parent=None): QtGui.QDialog.__init__(self, parent) self.setAttribute(Qt.WA_MacMetalStyle) if parent is not None: self.setWindowModality(Qt.WindowModal) # updated for use by commands self.model = model # widgets self.tree = GitTreeWidget(parent=self) self.close = qtutils.close_button() if select_file: text = N_('Select') else: text = N_('Save') self.save = qtutils.create_button(text=text, enabled=False, default=True) # layouts self.btnlayt = qtutils.hbox(defs.margin, defs.spacing, qtutils.STRETCH, self.close, self.save) self.layt = qtutils.vbox(defs.margin, defs.spacing, self.tree, self.btnlayt) self.setLayout(self.layt) # connections if select_file: self.connect(self.tree, SIGNAL('path_chosen(PyQt_PyObject)'), self.path_chosen) else: self.connect(self.tree, SIGNAL('path_chosen(PyQt_PyObject)'), self.save_path) self.connect(self.tree, SIGNAL('selectionChanged()'), self.selection_changed, Qt.QueuedConnection) qtutils.connect_button(self.close, self.reject) qtutils.connect_button(self.save, self.save_blob)
def __init__(self, parent): QtGui.QDialog.__init__(self, parent) self.setWindowModality(Qt.WindowModal) self.add_btn = qtutils.create_button(text=N_('Add Remote'), icon=icons.ok(), enabled=False) self.close_btn = qtutils.close_button() def lineedit(hint): widget = text.HintedLineEdit(hint) widget.hint.enable(True) metrics = QtGui.QFontMetrics(widget.font()) widget.setMinimumWidth(metrics.width('_' * 32)) return widget self.setWindowTitle(N_('Add remote')) self.name = lineedit(N_('Name for the new remote')) self.url = lineedit('git://git.example.com/repo.git') self._form = qtutils.form(defs.margin, defs.spacing, (N_('Name'), self.name), (N_('URL'), self.url)) self._btn_layout = qtutils.hbox(defs.no_margin, defs.button_spacing, qtutils.STRETCH, self.add_btn, self.close_btn) self._layout = qtutils.vbox(defs.margin, defs.spacing, self._form, self._btn_layout) self.setLayout(self._layout) self.connect(self.name, SIGNAL('textChanged(QString)'), self.validate) self.connect(self.url, SIGNAL('textChanged(QString)'), self.validate) qtutils.connect_button(self.add_btn, self.accept) qtutils.connect_button(self.close_btn, self.reject)
def __init__(self, parent=None): Dialog.__init__(self, parent) self.setAttribute(Qt.WA_MacMetalStyle) self.setWindowTitle(N_('Search')) if parent is not None: self.setWindowModality(Qt.WindowModal) self.edit_action = qtutils.add_action(self, N_('Edit'), self.edit, hotkeys.EDIT) self.refresh_action = qtutils.add_action(self, N_('Refresh'), self.search, *hotkeys.REFRESH_HOTKEYS) self.input_label = QtGui.QLabel('git grep') self.input_label.setFont(diff_font()) self.input_txt = HintedLineEdit(N_('command-line arguments'), self) self.input_txt.hint.enable(True) self.regexp_combo = combo = QtGui.QComboBox() combo.setToolTip(N_('Choose the "git grep" regular expression mode')) items = [N_('Basic Regexp'), N_('Extended Regexp'), N_('Fixed String')] combo.addItems(items) combo.setCurrentIndex(0) combo.setEditable(False) combo.setItemData(0, N_('Search using a POSIX basic regular expression'), Qt.ToolTipRole) combo.setItemData( 1, N_('Search using a POSIX extended regular expression'), Qt.ToolTipRole) combo.setItemData(2, N_('Search for a fixed string'), Qt.ToolTipRole) combo.setItemData(0, '--basic-regexp', Qt.UserRole) combo.setItemData(1, '--extended-regexp', Qt.UserRole) combo.setItemData(2, '--fixed-strings', Qt.UserRole) self.result_txt = GrepTextView(N_('grep result...'), self) self.result_txt.hint.enable(True) self.edit_button = qtutils.edit_button() qtutils.button_action(self.edit_button, self.edit_action) self.refresh_button = qtutils.refresh_button() qtutils.button_action(self.refresh_button, self.refresh_action) text = N_('Shell arguments') tooltip = N_('Parse arguments using a shell.\n' 'Queries with spaces will require "double quotes".') self.shell_checkbox = qtutils.checkbox(text=text, tooltip=tooltip, checked=False) self.close_button = qtutils.close_button() self.refresh_group = Group(self.refresh_action, self.refresh_button) self.refresh_group.setEnabled(False) self.edit_group = Group(self.edit_action, self.edit_button) self.edit_group.setEnabled(False) self.input_layout = qtutils.hbox(defs.no_margin, defs.button_spacing, self.input_label, self.input_txt, self.regexp_combo) self.bottom_layout = qtutils.hbox(defs.no_margin, defs.button_spacing, self.edit_button, self.refresh_button, self.shell_checkbox, qtutils.STRETCH, self.close_button) self.mainlayout = qtutils.vbox(defs.margin, defs.no_spacing, self.input_layout, self.result_txt, self.bottom_layout) self.setLayout(self.mainlayout) self.worker_thread = GrepThread(self) self.connect( self.worker_thread, SIGNAL('result(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)'), self.process_result, Qt.QueuedConnection) self.connect(self.input_txt, SIGNAL('textChanged(QString)'), lambda s: self.search()) self.connect(self.regexp_combo, SIGNAL('currentIndexChanged(int)'), lambda x: self.search()) self.connect(self.result_txt, SIGNAL('leave()'), lambda: self.input_txt.setFocus()) qtutils.add_action(self.input_txt, 'Focus Results', self.focus_results, hotkeys.DOWN, *hotkeys.ACCEPT) qtutils.add_action(self, 'Focus Input', self.focus_input, hotkeys.FOCUS) qtutils.connect_toggle(self.shell_checkbox, lambda x: self.search()) qtutils.connect_button(self.close_button, self.close) qtutils.add_close_action(self) if not self.restore_state(): width, height = qtutils.default_size(parent, 666, 420) self.resize(width, height)
def __init__(self, parent=None): super(ApplyPatches, self).__init__(parent=parent) self.setAttribute(Qt.WA_MacMetalStyle) self.setWindowTitle(N_('Apply Patches')) self.setAcceptDrops(True) if parent is not None: self.setWindowModality(Qt.WindowModal) self.curdir = core.getcwd() self.inner_drag = False self.usage = QtGui.QLabel() self.usage.setText(N_(""" <p> Drag and drop or use the <strong>Add</strong> button to add patches to the list </p> """)) self.tree = PatchTreeWidget(parent=self) self.tree.setHeaderHidden(True) self.add_button = qtutils.create_toolbutton( text=N_('Add'), icon=icons.add(), tooltip=N_('Add patches (+)')) self.remove_button = qtutils.create_toolbutton( text=N_('Remove'), icon=icons.remove(), tooltip=N_('Remove selected (Delete)')) self.apply_button = qtutils.create_button( text=N_('Apply'), icon=icons.ok()) self.close_button = qtutils.close_button() self.add_action = qtutils.add_action(self, N_('Add'), self.add_files, hotkeys.ADD_ITEM) self.remove_action = qtutils.add_action(self, N_('Remove'), self.tree.remove_selected, hotkeys.DELETE, hotkeys.BACKSPACE, hotkeys.REMOVE_ITEM) self.top_layout = qtutils.hbox(defs.no_margin, defs.button_spacing, self.add_button, self.remove_button, qtutils.STRETCH, self.usage) self.bottom_layout = qtutils.hbox(defs.no_margin, defs.button_spacing, self.apply_button, qtutils.STRETCH, self.close_button) self.main_layout = qtutils.vbox(defs.margin, defs.spacing, self.top_layout, self.tree, self.bottom_layout) self.setLayout(self.main_layout) qtutils.connect_button(self.add_button, self.add_files) qtutils.connect_button(self.remove_button, self.tree.remove_selected) qtutils.connect_button(self.apply_button, self.apply_patches) qtutils.connect_button(self.close_button, self.close) if not self.restore_state(): self.resize(666, 420)
def __init__(self, model, parent=None): Dialog.__init__(self, parent=parent) self.model = model self.stashes = [] self.revids = [] self.names = [] self.setWindowTitle(N_('Stash')) self.setAttribute(QtCore.Qt.WA_MacMetalStyle) if parent is not None: self.setWindowModality(QtCore.Qt.WindowModal) self.resize(parent.width(), 420) else: self.resize(700, 420) self.stash_list = QtGui.QListWidget(self) self.stash_text = DiffTextEdit(self) self.button_apply = qtutils.create_toolbutton( text=N_('Apply'), tooltip=N_('Apply the selected stash'), icon=icons.ok()) self.button_save = qtutils.create_toolbutton( text=N_('Save'), tooltip=N_('Save modified state to new stash'), icon=icons.save()) self.button_drop = qtutils.create_toolbutton( text=N_('Drop'), tooltip=N_('Drop the selected stash'), icon=icons.discard()) self.button_close = qtutils.close_button() self.keep_index = qtutils.checkbox(text=N_('Keep Index'), checked=True) # Arrange layouts self.splitter = qtutils.splitter(Qt.Horizontal, self.stash_list, self.stash_text) self.btn_layt = qtutils.hbox(defs.no_margin, defs.spacing, self.button_save, self.button_apply, self.button_drop, self.keep_index, qtutils.STRETCH, self.button_close) self.main_layt = qtutils.vbox(defs.margin, defs.spacing, self.splitter, self.btn_layt) self.setLayout(self.main_layt) self.splitter.setSizes([self.width()//3, self.width()*2//3]) self.update_from_model() self.update_actions() self.setTabOrder(self.button_save, self.button_apply) self.setTabOrder(self.button_apply, self.button_drop) self.setTabOrder(self.button_drop, self.keep_index) self.setTabOrder(self.keep_index, self.button_close) self.connect(self.stash_list, SIGNAL('itemSelectionChanged()'), self.item_selected) qtutils.connect_button(self.button_apply, self.stash_apply) qtutils.connect_button(self.button_save, self.stash_save) qtutils.connect_button(self.button_drop, self.stash_drop) qtutils.connect_button(self.button_close, self.close)
def __init__(self, parent=None, settings=None): standard.Dialog.__init__(self, parent, save_settings=True) self.setWindowTitle(N_("git-cola")) self.repodir = None self.runtask = qtutils.RunTask(parent=self) self.progress = standard.ProgressDialog("", "", self) self.new_button = qtutils.create_button(text=N_("New..."), icon=icons.new()) self.open_button = qtutils.create_button(text=N_("Open..."), icon=icons.repo()) self.clone_button = qtutils.create_button(text=N_("Clone..."), icon=icons.cola()) self.close_button = qtutils.close_button() if settings is None: settings = Settings() settings.load() self.settings = settings self.bookmarks_label = QtGui.QLabel(N_("Select Repository...")) self.bookmarks_label.setAlignment(Qt.AlignCenter) self.bookmarks_model = QtGui.QStandardItemModel() item = QtGui.QStandardItem(N_("Select manually...")) item.setEditable(False) self.bookmarks_model.appendRow(item) added = set() all_repos = settings.bookmarks + settings.recent for repo in all_repos: if repo in added: continue added.add(repo) item = QtGui.QStandardItem(repo) item.setEditable(False) self.bookmarks_model.appendRow(item) selection_mode = QtGui.QAbstractItemView.SingleSelection self.bookmarks = QtGui.QListView() self.bookmarks.setSelectionMode(selection_mode) self.bookmarks.setAlternatingRowColors(True) self.bookmarks.setModel(self.bookmarks_model) if not all_repos: self.bookmarks_label.setMinimumHeight(1) self.bookmarks.setMinimumHeight(1) self.bookmarks_label.hide() self.bookmarks.hide() self.button_layout = qtutils.hbox( defs.no_margin, defs.spacing, self.open_button, self.clone_button, self.new_button, qtutils.STRETCH, self.close_button, ) self.main_layout = qtutils.vbox( defs.margin, defs.spacing, self.bookmarks_label, self.bookmarks, self.button_layout ) self.setLayout(self.main_layout) qtutils.connect_button(self.open_button, self.open_repo) qtutils.connect_button(self.clone_button, self.clone_repo) qtutils.connect_button(self.new_button, self.new_repo) qtutils.connect_button(self.close_button, self.reject) self.connect(self.bookmarks, SIGNAL("activated(QModelIndex)"), self.open_bookmark) if not self.restore_state(settings=settings): screen = QtGui.QApplication.instance().desktop() self.setGeometry(screen.width() // 4, screen.height() // 4, screen.width() // 2, screen.height() // 2)
def __init__(self, cfg, model, parent=None): QtGui.QDialog.__init__(self, parent) self.cfg = cfg self.model = model if parent is not None: self.setWindowModality(Qt.WindowModal) self.setAttribute(Qt.WA_MacMetalStyle) # Widgets self.title_label = QtGui.QLabel() self.revision_label = QtGui.QLabel() self.revision_label.setText(N_('Revision to Merge')) self.revision = completion.GitRefLineEdit() self.revision.setFocus() self.revision.setToolTip(N_('Revision to Merge')) self.radio_local = qtutils.radio(text=N_('Local Branch'), checked=True) self.radio_remote = qtutils.radio(text=N_('Tracking Branch')) self.radio_tag = qtutils.radio(text=N_('Tag')) self.revisions = QtGui.QListWidget() self.revisions.setAlternatingRowColors(True) self.button_viz = qtutils.create_button(text=N_('Visualize'), icon=icons.visualize()) tooltip = N_('Squash the merged commit(s) into a single commit') self.checkbox_squash = qtutils.checkbox(text=N_('Squash'), tooltip=tooltip) tooltip = N_('Always create a merge commit when enabled, ' 'even when the merge is a fast-forward update') self.checkbox_noff = qtutils.checkbox(text=N_('No fast forward'), tooltip=tooltip, checked=False) self.checkbox_noff_state = False tooltip = N_('Commit the merge if there are no conflicts. ' 'Uncheck to leave the merge uncommitted') self.checkbox_commit = qtutils.checkbox(text=N_('Commit'), tooltip=tooltip, checked=True) self.checkbox_commit_state = True text = N_('Create Signed Commit') checked = cfg.get('cola.signcommits', False) tooltip = N_('GPG-sign the merge commit') self.checkbox_sign = qtutils.checkbox(text=text, checked=checked, tooltip=tooltip) self.button_close = qtutils.close_button() icon = icons.merge() self.button_merge = qtutils.create_button(text=N_('Merge'), icon=icon) # Layouts self.revlayt = qtutils.hbox(defs.no_margin, defs.spacing, self.revision_label, self.revision, qtutils.STRETCH, self.title_label) self.radiolayt = qtutils.hbox(defs.no_margin, defs.spacing, self.radio_local, self.radio_remote, self.radio_tag) self.buttonlayt = qtutils.hbox( defs.no_margin, defs.button_spacing, self.button_viz, qtutils.STRETCH, self.checkbox_squash, self.checkbox_noff, self.checkbox_commit, self.checkbox_sign, self.button_close, self.button_merge) self.mainlayt = qtutils.vbox(defs.margin, defs.spacing, self.radiolayt, self.revisions, self.revlayt, self.buttonlayt) self.setLayout(self.mainlayt) # Signal/slot connections self.connect(self.revision, SIGNAL('textChanged(QString)'), self.update_title) self.connect(self.revisions, SIGNAL('itemSelectionChanged()'), self.revision_selected) qtutils.connect_button(self.button_close, self.reject) qtutils.connect_button(self.checkbox_squash, self.toggle_squash) qtutils.connect_button(self.radio_local, self.update_revisions) qtutils.connect_button(self.radio_remote, self.update_revisions) qtutils.connect_button(self.radio_tag, self.update_revisions) qtutils.connect_button(self.button_merge, self.merge_revision) qtutils.connect_button(self.button_viz, self.viz_revision) # Observer messages model.add_observer(model.message_updated, self.update_all) self.update_all() self.resize(700, 400)
def __init__(self, opts, settings=None, parent=None): standard.Dialog.__init__(self, parent=parent) self.opts = opts self.setAttribute(Qt.WA_MacMetalStyle) self.setWindowTitle(N_('Create Tag')) if parent is not None: self.setWindowModality(QtCore.Qt.WindowModal) # Tag label self.tag_name_label = QtGui.QLabel(self) self.tag_name_label.setText(N_('Name')) self.tag_name = text.HintedLineEdit(N_('vX.Y.Z'), self) self.tag_name.set_value(opts.name) self.tag_name.setToolTip(N_('Specifies the tag name')) # Sign Tag self.sign_label = QtGui.QLabel(self) self.sign_label.setText(N_('Sign Tag')) tooltip = N_('Whether to sign the tag (git tag -s)') self.sign_tag = qtutils.checkbox(checked=True, tooltip=tooltip) # Tag message self.tag_msg_label = QtGui.QLabel(self) self.tag_msg_label.setText(N_('Message')) self.tag_msg = text.HintedTextEdit(N_('Tag message...'), self) self.tag_msg.setToolTip(N_('Specifies the tag message')) self.tag_msg.hint.enable(True) # Revision self.rev_label = QtGui.QLabel(self) self.rev_label.setText(N_('Revision')) self.revision = completion.GitRefLineEdit() self.revision.setText(self.opts.ref) self.revision.setToolTip(N_('Specifies the SHA-1 to tag')) # Buttons self.create_button = qtutils.create_button(text=N_('Create Tag'), icon=icons.tag()) self.close_button = qtutils.close_button() # Form layout for inputs self.input_layout = qtutils.form(defs.margin, defs.spacing, (self.tag_name_label, self.tag_name), (self.tag_msg_label, self.tag_msg), (self.rev_label, self.revision), (self.sign_label, self.sign_tag)) self.button_layout = qtutils.hbox(defs.no_margin, defs.spacing, qtutils.STRETCH, self.create_button, self.close_button) self.main_layt = qtutils.vbox(defs.margin, defs.spacing, self.input_layout, self.button_layout) self.setLayout(self.main_layt) qtutils.connect_button(self.close_button, self.close) qtutils.connect_button(self.create_button, self.create_tag) if not self.restore_state(settings=settings): self.resize(defs.scale(720), defs.scale(210))
def __init__(self, parent=None): standard.Dialog.__init__(self, parent) self.setAttribute(Qt.WA_MacMetalStyle) self.setWindowTitle(N_('Find Files')) if parent is not None: self.setWindowModality(Qt.WindowModal) self.input_label = QtGui.QLabel(os.path.basename(core.getcwd()) + '/') self.input_txt = completion.GitTrackedLineEdit(hint=N_('<path> ...')) self.input_txt.hint.enable(True) self.tree = filetree.FileTree(parent=self) self.edit_button = qtutils.edit_button() self.edit_button.setShortcut(hotkeys.EDIT) text = cmds.OpenDefaultApp.name() icon = icons.default_app() self.open_default_button = qtutils.create_button(text=text, icon=icon) self.open_default_button.setShortcut(hotkeys.PRIMARY_ACTION) self.button_group = Group(self.edit_button, self.open_default_button) self.button_group.setEnabled(False) self.refresh_button = qtutils.refresh_button() self.refresh_button.setShortcut(hotkeys.REFRESH) self.help_button = qtutils.create_button( text=N_('Help'), tooltip=N_('Show help\nShortcut: ?'), icon=icons.question()) self.close_button = qtutils.close_button() self.input_layout = qtutils.hbox(defs.no_margin, defs.button_spacing, self.input_label, self.input_txt) self.bottom_layout = qtutils.hbox(defs.no_margin, defs.button_spacing, self.edit_button, self.open_default_button, self.refresh_button, self.help_button, qtutils.STRETCH, self.close_button) self.main_layout = qtutils.vbox(defs.margin, defs.no_spacing, self.input_layout, self.tree, self.bottom_layout) self.setLayout(self.main_layout) self.setFocusProxy(self.input_txt) self.worker_thread = FindFilesThread(self) self.connect(self.worker_thread, SIGNAL('result(PyQt_PyObject)'), self.process_result, Qt.QueuedConnection) self.connect(self.input_txt, SIGNAL('textChanged(QString)'), lambda s: self.search()) self.connect(self.input_txt, SIGNAL('activated()'), self.focus_tree) self.connect(self.input_txt, SIGNAL('down()'), self.focus_tree) self.connect(self.input_txt, SIGNAL('enter()'), self.focus_tree) self.connect(self.input_txt, SIGNAL('return()'), self.focus_tree) self.connect(self.tree, SIGNAL('itemSelectionChanged()'), self.tree_item_selection_changed) self.connect(self.tree, SIGNAL('up()'), self.focus_input) self.connect(self.tree, SIGNAL('space()'), self.open_default) qtutils.add_action(self, 'Focus Input', self.focus_input, hotkeys.FOCUS, hotkeys.FINDER) self.show_help_action = qtutils.add_action(self, N_('Show Help'), show_help, hotkeys.QUESTION) qtutils.connect_button(self.edit_button, self.edit) qtutils.connect_button(self.open_default_button, self.open_default) qtutils.connect_button(self.refresh_button, self.search) qtutils.connect_button(self.help_button, show_help) qtutils.connect_button(self.close_button, self.close) qtutils.add_close_action(self) if not self.restore_state(): width, height = qtutils.default_size(parent, 666, 420) self.resize(width, height)
def __init__(self, parent, a=None, b=None, expr=None, title=None, hide_expr=False): QtGui.QDialog.__init__(self, parent) self.setAttribute(Qt.WA_MacMetalStyle) self.a = a self.b = b self.diff_expr = expr if title is None: title = N_('git-cola diff') self.setWindowTitle(title) self.setWindowModality(QtCore.Qt.WindowModal) self.expr = completion.GitRefLineEdit(parent=self) if expr is not None: self.expr.setText(expr) if expr is None or hide_expr: self.expr.hide() self.tree = filetree.FileTree(parent=self) self.diff_button = qtutils.create_button(text=N_('Compare'), icon=icons.diff(), enabled=False) self.close_button = qtutils.close_button() self.button_layout = qtutils.hbox(defs.no_margin, defs.spacing, qtutils.STRETCH, self.diff_button, self.close_button) self.main_layout = qtutils.vbox(defs.margin, defs.spacing, self.expr, self.tree, self.button_layout) self.setLayout(self.main_layout) self.connect(self.tree, SIGNAL('itemSelectionChanged()'), self.tree_selection_changed) self.connect(self.tree, SIGNAL('itemDoubleClicked(QTreeWidgetItem*,int)'), self.tree_double_clicked) self.connect(self.expr, SIGNAL('textChanged(QString)'), self.text_changed) self.connect(self.tree, SIGNAL('up()'), self.focus_input) self.connect(self.expr, SIGNAL('activated()'), self.focus_tree) self.connect(self.expr, SIGNAL('down()'), self.focus_tree) self.connect(self.expr, SIGNAL('enter()'), self.focus_tree) self.connect(self.expr, SIGNAL('return()'), self.focus_tree) qtutils.connect_button(self.diff_button, self.diff) qtutils.connect_button(self.close_button, self.close) qtutils.add_action(self, 'Focus Input', self.focus_input, hotkeys.FOCUS) qtutils.add_close_action(self) self.resize(720, 420) self.refresh()
def __init__(self, model, action, title, parent=None, icon=None): """Customizes the dialog based on the remote action """ standard.Dialog.__init__(self, parent=parent) self.model = model self.action = action self.filtered_remote_branches = [] self.selected_remotes = [] self.setAttribute(Qt.WA_MacMetalStyle) self.setWindowTitle(title) if parent is not None: self.setWindowModality(Qt.WindowModal) self.runtask = qtutils.RunTask(parent=self) self.progress = ProgressDialog(title, N_('Updating'), self) self.local_label = QtGui.QLabel() self.local_label.setText(N_('Local Branch')) self.local_branch = QtGui.QLineEdit() self.local_branches = QtGui.QListWidget() self.local_branches.addItems(self.model.local_branches) self.remote_label = QtGui.QLabel() self.remote_label.setText(N_('Remote')) self.remote_name = QtGui.QLineEdit() self.remotes = QtGui.QListWidget() if action == PUSH: self.remotes.setSelectionMode( QtGui.QAbstractItemView.ExtendedSelection) self.remotes.addItems(self.model.remotes) self.remote_branch_label = QtGui.QLabel() self.remote_branch_label.setText(N_('Remote Branch')) self.remote_branch = QtGui.QLineEdit() self.remote_branches = QtGui.QListWidget() self.remote_branches.addItems(self.model.remote_branches) text = N_('Fast Forward Only ') self.ffwd_only_checkbox = qtutils.checkbox(text=text, checked=True) self.tags_checkbox = qtutils.checkbox(text=N_('Include tags ')) self.rebase_checkbox = qtutils.checkbox(text=N_('Rebase ')) if icon is None: icon = icons.ok() self.action_button = qtutils.create_button(text=title, icon=icon) self.close_button = qtutils.close_button() self.buttons = utils.Group(self.action_button, self.close_button) self.local_branch_layout = qtutils.hbox(defs.small_margin, defs.spacing, self.local_label, self.local_branch) self.remote_branch_layout = qtutils.hbox(defs.small_margin, defs.spacing, self.remote_label, self.remote_name) self.remote_branches_layout = qtutils.hbox(defs.small_margin, defs.spacing, self.remote_branch_label, self.remote_branch) self.options_layout = qtutils.hbox( defs.no_margin, defs.button_spacing, qtutils.STRETCH, self.ffwd_only_checkbox, self.tags_checkbox, self.rebase_checkbox, self.action_button, self.close_button) if action == PUSH: widgets = ( self.remote_branch_layout, self.remotes, self.local_branch_layout, self.local_branches, self.remote_branches_layout, self.remote_branches, self.options_layout, ) else: # fetch and pull widgets = ( self.remote_branch_layout, self.remotes, self.remote_branches_layout, self.remote_branches, self.local_branch_layout, self.local_branches, self.options_layout, ) self.main_layout = qtutils.vbox(defs.no_margin, defs.spacing, *widgets) self.setLayout(self.main_layout) default_remote = gitcmds.default_remote() or 'origin' remotes = self.model.remotes if default_remote in remotes: idx = remotes.index(default_remote) if self.select_remote(idx): self.remote_name.setText(default_remote) else: if self.select_first_remote(): self.remote_name.setText(remotes[0]) # Trim the remote list to just the default remote self.update_remotes() self.set_field_defaults() # Setup signals and slots self.connect(self.remotes, SIGNAL('itemSelectionChanged()'), self.update_remotes) self.connect(self.local_branches, SIGNAL('itemSelectionChanged()'), self.update_local_branches) self.connect(self.remote_branches, SIGNAL('itemSelectionChanged()'), self.update_remote_branches) connect_button(self.action_button, self.action_callback) connect_button(self.close_button, self.close) qtutils.add_action(self, N_('Close'), self.close, QtGui.QKeySequence.Close, 'Esc') if action == PULL: self.tags_checkbox.hide() self.ffwd_only_checkbox.hide() self.local_label.hide() self.local_branch.hide() self.local_branches.hide() self.remote_branch.setFocus() else: self.rebase_checkbox.hide() if not self.restore_state(): self.resize(666, 420) self.remote_name.setFocus()
def __init__(self, model, action, title, parent=None, icon=None): """Customizes the dialog based on the remote action """ standard.Dialog.__init__(self, parent=parent) self.model = model self.action = action self.filtered_remote_branches = [] self.selected_remotes = [] self.setAttribute(Qt.WA_MacMetalStyle) self.setWindowTitle(title) if parent is not None: self.setWindowModality(Qt.WindowModal) self.runtask = qtutils.RunTask(parent=self) self.progress = ProgressDialog(title, N_('Updating'), self) self.local_label = QtGui.QLabel() self.local_label.setText(N_('Local Branch')) self.local_branch = QtGui.QLineEdit() self.local_branches = QtGui.QListWidget() self.local_branches.addItems(self.model.local_branches) self.remote_label = QtGui.QLabel() self.remote_label.setText(N_('Remote')) self.remote_name = QtGui.QLineEdit() self.remotes = QtGui.QListWidget() if action == PUSH: self.remotes.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection) self.remotes.addItems(self.model.remotes) self.remote_branch_label = QtGui.QLabel() self.remote_branch_label.setText(N_('Remote Branch')) self.remote_branch = QtGui.QLineEdit() self.remote_branches = QtGui.QListWidget() self.remote_branches.addItems(self.model.remote_branches) text = N_('Fast Forward Only ') self.ffwd_only_checkbox = qtutils.checkbox(text=text, checked=True) self.tags_checkbox = qtutils.checkbox(text=N_('Include tags ')) self.rebase_checkbox = qtutils.checkbox(text=N_('Rebase ')) if icon is None: icon = icons.ok() self.action_button = qtutils.create_button(text=title, icon=icon) self.close_button = qtutils.close_button() self.buttons = utils.Group(self.action_button, self.close_button) self.local_branch_layout = qtutils.hbox(defs.small_margin, defs.spacing, self.local_label, self.local_branch) self.remote_branch_layout = qtutils.hbox(defs.small_margin, defs.spacing, self.remote_label, self.remote_name) self.remote_branches_layout = qtutils.hbox(defs.small_margin, defs.spacing, self.remote_branch_label, self.remote_branch) self.options_layout = qtutils.hbox(defs.no_margin, defs.button_spacing, qtutils.STRETCH, self.ffwd_only_checkbox, self.tags_checkbox, self.rebase_checkbox, self.action_button, self.close_button) if action == PUSH: widgets = ( self.remote_branch_layout, self.remotes, self.local_branch_layout, self.local_branches, self.remote_branches_layout, self.remote_branches, self.options_layout, ) else: # fetch and pull widgets = ( self.remote_branch_layout, self.remotes, self.remote_branches_layout, self.remote_branches, self.local_branch_layout, self.local_branches, self.options_layout, ) self.main_layout = qtutils.vbox(defs.no_margin, defs.spacing, *widgets) self.setLayout(self.main_layout) default_remote = gitcmds.default_remote() or 'origin' remotes = self.model.remotes if default_remote in remotes: idx = remotes.index(default_remote) if self.select_remote(idx): self.remote_name.setText(default_remote) else: if self.select_first_remote(): self.remote_name.setText(remotes[0]) # Trim the remote list to just the default remote self.update_remotes() self.set_field_defaults() # Setup signals and slots self.connect(self.remotes, SIGNAL('itemSelectionChanged()'), self.update_remotes) self.connect(self.local_branches, SIGNAL('itemSelectionChanged()'), self.update_local_branches) self.connect(self.remote_branches, SIGNAL('itemSelectionChanged()'), self.update_remote_branches) connect_button(self.action_button, self.action_callback) connect_button(self.close_button, self.close) qtutils.add_action(self, N_('Close'), self.close, QtGui.QKeySequence.Close, 'Esc') if action == PULL: self.tags_checkbox.hide() self.ffwd_only_checkbox.hide() self.local_label.hide() self.local_branch.hide() self.local_branches.hide() self.remote_branch.setFocus() else: self.rebase_checkbox.hide() if not self.restore_state(): self.resize(666, 420) self.remote_name.setFocus()
def __init__(self, cfg, model, parent=None): QtGui.QDialog.__init__(self, parent) self.cfg = cfg self.model = model if parent is not None: self.setWindowModality(Qt.WindowModal) self.setAttribute(Qt.WA_MacMetalStyle) # Widgets self.title_label = QtGui.QLabel() self.revision_label = QtGui.QLabel() self.revision_label.setText(N_("Revision to Merge")) self.revision = completion.GitRefLineEdit() self.revision.setFocus() self.revision.setToolTip(N_("Revision to Merge")) self.radio_local = qtutils.radio(text=N_("Local Branch"), checked=True) self.radio_remote = qtutils.radio(text=N_("Tracking Branch")) self.radio_tag = qtutils.radio(text=N_("Tag")) self.revisions = QtGui.QListWidget() self.revisions.setAlternatingRowColors(True) self.button_viz = qtutils.create_button(text=N_("Visualize"), icon=icons.visualize()) tooltip = N_("Squash the merged commit(s) into a single commit") self.checkbox_squash = qtutils.checkbox(text=N_("Squash"), tooltip=tooltip) tooltip = N_("Always create a merge commit when enabled, " "even when the merge is a fast-forward update") self.checkbox_noff = qtutils.checkbox(text=N_("No fast forward"), tooltip=tooltip, checked=False) self.checkbox_noff_state = False tooltip = N_("Commit the merge if there are no conflicts. " "Uncheck to leave the merge uncommitted") self.checkbox_commit = qtutils.checkbox(text=N_("Commit"), tooltip=tooltip, checked=True) self.checkbox_commit_state = True text = N_("Create Signed Commit") checked = cfg.get("cola.signcommits", False) tooltip = N_("GPG-sign the merge commit") self.checkbox_sign = qtutils.checkbox(text=text, checked=checked, tooltip=tooltip) self.button_close = qtutils.close_button() icon = icons.merge() self.button_merge = qtutils.create_button(text=N_("Merge"), icon=icon) # Layouts self.revlayt = qtutils.hbox( defs.no_margin, defs.spacing, self.revision_label, self.revision, qtutils.STRETCH, self.title_label ) self.radiolayt = qtutils.hbox(defs.no_margin, defs.spacing, self.radio_local, self.radio_remote, self.radio_tag) self.buttonlayt = qtutils.hbox( defs.no_margin, defs.button_spacing, self.button_viz, qtutils.STRETCH, self.checkbox_squash, self.checkbox_noff, self.checkbox_commit, self.checkbox_sign, self.button_close, self.button_merge, ) self.mainlayt = qtutils.vbox( defs.margin, defs.spacing, self.radiolayt, self.revisions, self.revlayt, self.buttonlayt ) self.setLayout(self.mainlayt) # Signal/slot connections self.connect(self.revision, SIGNAL("textChanged(QString)"), self.update_title) self.connect(self.revisions, SIGNAL("itemSelectionChanged()"), self.revision_selected) qtutils.connect_button(self.button_close, self.reject) qtutils.connect_button(self.checkbox_squash, self.toggle_squash) qtutils.connect_button(self.radio_local, self.update_revisions) qtutils.connect_button(self.radio_remote, self.update_revisions) qtutils.connect_button(self.radio_tag, self.update_revisions) qtutils.connect_button(self.button_merge, self.merge_revision) qtutils.connect_button(self.button_viz, self.viz_revision) # Observer messages model.add_observer(model.message_updated, self.update_all) self.update_all() self.resize(700, 400)
def __init__(self, parent): standard.Dialog.__init__(self, parent) self.setWindowTitle(N_('Recently Modified Files')) self.setWindowModality(Qt.WindowModal) count = 8 self.update_thread = UpdateFileListThread(count) self.count = QtGui.QSpinBox() self.count.setMinimum(0) self.count.setMaximum(10000) self.count.setValue(count) self.count.setSuffix(N_(' commits ago')) self.count_label = QtGui.QLabel() self.count_label.setText(N_('Showing changes since')) self.refresh_button = qtutils.refresh_button(enabled=False) self.tree = GitTreeWidget(parent=self) self.tree_model = GitFileTreeModel(self) self.tree.setModel(self.tree_model) self.expand_button = qtutils.create_button(text=N_('Expand all'), icon=icons.unfold()) self.collapse_button = qtutils.create_button(text=N_('Collapse all'), icon=icons.fold()) self.edit_button = qtutils.edit_button(enabled=False, default=True) self.close_button = qtutils.close_button() self.top_layout = qtutils.hbox(defs.no_margin, defs.spacing, self.count_label, self.count, qtutils.STRETCH, self.refresh_button) self.button_layout = qtutils.hbox(defs.no_margin, defs.spacing, self.expand_button, self.collapse_button, qtutils.STRETCH, self.edit_button, self.close_button) self.main_layout = qtutils.vbox(defs.margin, defs.spacing, self.top_layout, self.tree, self.button_layout) self.setLayout(self.main_layout) self.connect(self.tree, SIGNAL('selectionChanged()'), self.selection_changed) self.connect(self.tree, SIGNAL('path_chosen(PyQt_PyObject)'), self.edit_file) self.connect(self.count, SIGNAL('valueChanged(int)'), self.count_changed) self.connect(self.count, SIGNAL('editingFinished()'), self.refresh) self.connect(self.update_thread, SIGNAL('filenames(PyQt_PyObject)'), self.set_filenames, Qt.QueuedConnection) qtutils.connect_button(self.refresh_button, self.refresh) qtutils.connect_button(self.expand_button, self.tree.expandAll) qtutils.connect_button(self.collapse_button, self.tree.collapseAll) qtutils.connect_button(self.close_button, self.accept) qtutils.connect_button(self.edit_button, self.edit_selected) qtutils.add_action(self, N_('Refresh'), self.refresh, hotkeys.REFRESH) self.update_thread.start()
def __init__(self, parent=None): QtGui.QDialog.__init__(self, parent) self.setWindowTitle(N_('Edit Remotes')) if parent is not None: self.setWindowModality(Qt.WindowModal) width = max(640, parent.width()) height = max(480, parent.height()) self.resize(width, height) else: self.resize(720, 300) self.default_hint = N_('' 'Add and remove remote repositories using the \n' 'Add(+) and Delete(-) buttons on the left-hand side.\n' '\n' 'Remotes can be renamed by selecting one from the list\n' 'and pressing "enter", or by double-clicking.') self.remote_list = [] self.remotes = QtGui.QListWidget() self.remotes.setToolTip(N_( 'Remote git repositories - double-click to rename')) self.info = text.HintedTextView(self.default_hint, self) font = self.info.font() metrics = QtGui.QFontMetrics(font) width = metrics.width('_' * 42) height = metrics.height() * 13 self.info.setMinimumWidth(width) self.info.setMinimumHeight(height) self.info_thread = RemoteInfoThread(self) icon = icons.add() tooltip = N_('Add new remote git repository') self.add_btn = qtutils.create_toolbutton(icon=icon, tooltip=tooltip) self.refresh_btn = qtutils.create_toolbutton(icon=icons.sync(), tooltip=N_('Refresh')) self.delete_btn = qtutils.create_toolbutton(icon=icons.remove(), tooltip=N_('Delete remote')) self.close_btn = qtutils.close_button() self._top_layout = qtutils.splitter(Qt.Horizontal, self.remotes, self.info) width = self._top_layout.width() self._top_layout.setSizes([width//4, width*3//4]) self._button_layout = qtutils.hbox(defs.margin, defs.spacing, self.add_btn, self.delete_btn, self.refresh_btn, qtutils.STRETCH, self.close_btn) self._layout = qtutils.vbox(defs.margin, defs.spacing, self._top_layout, self._button_layout) self.setLayout(self._layout) self.refresh() qtutils.connect_button(self.add_btn, self.add) qtutils.connect_button(self.delete_btn, self.delete) qtutils.connect_button(self.refresh_btn, self.refresh) qtutils.connect_button(self.close_btn, self.close) self.connect(self.info_thread, SIGNAL('info(PyQt_PyObject)'), self.info.set_value, Qt.QueuedConnection) self.connect(self.remotes, SIGNAL('itemChanged(QListWidgetItem*)'), self.remote_renamed) self.connect(self.remotes, SIGNAL('itemSelectionChanged()'), self.selection_changed)
def __init__(self, parent=None): super(ApplyPatches, self).__init__(parent=parent) self.setAttribute(Qt.WA_MacMetalStyle) self.setWindowTitle(N_('Apply Patches')) self.setAcceptDrops(True) if parent is not None: self.setWindowModality(Qt.WindowModal) self.curdir = core.getcwd() self.inner_drag = False self.usage = QtGui.QLabel() self.usage.setText( N_(""" <p> Drag and drop or use the <strong>Add</strong> button to add patches to the list </p> """)) self.tree = PatchTreeWidget(parent=self) self.tree.setHeaderHidden(True) self.add_button = qtutils.create_toolbutton( text=N_('Add'), icon=icons.add(), tooltip=N_('Add patches (+)')) self.remove_button = qtutils.create_toolbutton( text=N_('Remove'), icon=icons.remove(), tooltip=N_('Remove selected (Delete)')) self.apply_button = qtutils.create_button(text=N_('Apply'), icon=icons.ok()) self.close_button = qtutils.close_button() self.add_action = qtutils.add_action(self, N_('Add'), self.add_files, hotkeys.ADD_ITEM) self.remove_action = qtutils.add_action(self, N_('Remove'), self.tree.remove_selected, hotkeys.DELETE, hotkeys.BACKSPACE, hotkeys.REMOVE_ITEM) self.top_layout = qtutils.hbox(defs.no_margin, defs.button_spacing, self.add_button, self.remove_button, qtutils.STRETCH, self.usage) self.bottom_layout = qtutils.hbox(defs.no_margin, defs.button_spacing, self.apply_button, qtutils.STRETCH, self.close_button) self.main_layout = qtutils.vbox(defs.margin, defs.spacing, self.top_layout, self.tree, self.bottom_layout) self.setLayout(self.main_layout) qtutils.connect_button(self.add_button, self.add_files) qtutils.connect_button(self.remove_button, self.tree.remove_selected) qtutils.connect_button(self.apply_button, self.apply_patches) qtutils.connect_button(self.close_button, self.close) if not self.restore_state(): self.resize(666, 420)
def __init__(self, parent, name, opts): standard.Dialog.__init__(self, parent) self.name = name self.opts = opts try: values = self.VALUES[name] except KeyError: values = self.VALUES[name] = {} self.setWindowModality(Qt.ApplicationModal) 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.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() if self.opts.get('argprompt'): try: # Remember the previous value saved_value = values['argstxt'] self.argstxt.setText(saved_value) except KeyError: pass else: 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) if not opts.get('revprompt'): self.revselect.hide() # Close/Run buttons self.closebtn = qtutils.close_button() self.runbtn = qtutils.create_button(text=N_('Run'), default=True, icon=icons.ok()) self.argslayt = qtutils.hbox(defs.margin, defs.spacing, self.argslabel, self.argstxt) self.btnlayt = qtutils.hbox(defs.margin, defs.spacing, qtutils.STRETCH, self.closebtn, self.runbtn) self.layt = qtutils.vbox(defs.margin, defs.spacing, self.prompt, self.argslayt, self.revselect, self.btnlayt) self.setLayout(self.layt) self.connect(self.argstxt, SIGNAL('textChanged(QString)'), self._argstxt_changed) qtutils.connect_button(self.closebtn, self.reject) qtutils.connect_button(self.runbtn, self.accept) # Widen the dialog by default self.resize(666, self.height())
def __init__(self, parent=None, settings=None): standard.Dialog.__init__(self, parent, save_settings=True) self.setWindowTitle(N_('git-cola')) self.repodir = None self.runtask = qtutils.RunTask(parent=self) self.progress = standard.ProgressDialog('', '', self) self.new_button = qtutils.create_button(text=N_('New...'), icon=icons.new()) self.open_button = qtutils.create_button(text=N_('Open...'), icon=icons.repo()) self.clone_button = qtutils.create_button(text=N_('Clone...'), icon=icons.cola()) self.close_button = qtutils.close_button() if settings is None: settings = Settings() settings.load() self.settings = settings self.bookmarks_label = QtGui.QLabel(N_('Select Repository...')) self.bookmarks_label.setAlignment(Qt.AlignCenter) self.bookmarks_model = QtGui.QStandardItemModel() item = QtGui.QStandardItem(N_('Select manually...')) item.setEditable(False) self.bookmarks_model.appendRow(item) added = set() all_repos = settings.bookmarks + settings.recent for repo in all_repos: if repo in added: continue added.add(repo) item = QtGui.QStandardItem(repo) item.setEditable(False) self.bookmarks_model.appendRow(item) selection_mode = QtGui.QAbstractItemView.SingleSelection self.bookmarks = QtGui.QListView() self.bookmarks.setSelectionMode(selection_mode) self.bookmarks.setAlternatingRowColors(True) self.bookmarks.setModel(self.bookmarks_model) if not all_repos: self.bookmarks_label.setMinimumHeight(1) self.bookmarks.setMinimumHeight(1) self.bookmarks_label.hide() self.bookmarks.hide() self.button_layout = qtutils.hbox(defs.no_margin, defs.spacing, self.open_button, self.clone_button, self.new_button, qtutils.STRETCH, self.close_button) self.main_layout = qtutils.vbox(defs.margin, defs.spacing, self.bookmarks_label, self.bookmarks, self.button_layout) self.setLayout(self.main_layout) qtutils.connect_button(self.open_button, self.open_repo) qtutils.connect_button(self.clone_button, self.clone_repo) qtutils.connect_button(self.new_button, self.new_repo) qtutils.connect_button(self.close_button, self.reject) self.connect(self.bookmarks, SIGNAL('activated(QModelIndex)'), self.open_bookmark) if not self.restore_state(settings=settings): screen = QtGui.QApplication.instance().desktop() self.setGeometry(screen.width() // 4, screen.height() // 4, screen.width() // 2, screen.height() // 2)
def __init__(self, parent=None): Dialog.__init__(self, parent) self.setAttribute(Qt.WA_MacMetalStyle) self.setWindowTitle(N_('Search')) if parent is not None: self.setWindowModality(Qt.WindowModal) self.edit_action = qtutils.add_action( self, N_('Edit'), self.edit, hotkeys.EDIT) self.refresh_action = qtutils.add_action( self, N_('Refresh'), self.search, *hotkeys.REFRESH_HOTKEYS) self.input_label = QtGui.QLabel('git grep') self.input_label.setFont(diff_font()) self.input_txt = HintedLineEdit(N_('command-line arguments'), self) self.input_txt.hint.enable(True) self.regexp_combo = combo = QtGui.QComboBox() combo.setToolTip(N_('Choose the "git grep" regular expression mode')) items = [N_('Basic Regexp'), N_('Extended Regexp'), N_('Fixed String')] combo.addItems(items) combo.setCurrentIndex(0) combo.setEditable(False) combo.setItemData(0, N_('Search using a POSIX basic regular expression'), Qt.ToolTipRole) combo.setItemData(1, N_('Search using a POSIX extended regular expression'), Qt.ToolTipRole) combo.setItemData(2, N_('Search for a fixed string'), Qt.ToolTipRole) combo.setItemData(0, '--basic-regexp', Qt.UserRole) combo.setItemData(1, '--extended-regexp', Qt.UserRole) combo.setItemData(2, '--fixed-strings', Qt.UserRole) self.result_txt = GrepTextView(N_('grep result...'), self) self.result_txt.hint.enable(True) self.edit_button = qtutils.edit_button() qtutils.button_action(self.edit_button, self.edit_action) self.refresh_button = qtutils.refresh_button() qtutils.button_action(self.refresh_button, self.refresh_action) text = N_('Shell arguments') tooltip = N_('Parse arguments using a shell.\n' 'Queries with spaces will require "double quotes".') self.shell_checkbox = qtutils.checkbox(text=text, tooltip=tooltip, checked=False) self.close_button = qtutils.close_button() self.refresh_group = Group(self.refresh_action, self.refresh_button) self.refresh_group.setEnabled(False) self.edit_group = Group(self.edit_action, self.edit_button) self.edit_group.setEnabled(False) self.input_layout = qtutils.hbox(defs.no_margin, defs.button_spacing, self.input_label, self.input_txt, self.regexp_combo) self.bottom_layout = qtutils.hbox(defs.no_margin, defs.button_spacing, self.edit_button, self.refresh_button, self.shell_checkbox, qtutils.STRETCH, self.close_button) self.mainlayout = qtutils.vbox(defs.margin, defs.no_spacing, self.input_layout, self.result_txt, self.bottom_layout) self.setLayout(self.mainlayout) self.worker_thread = GrepThread(self) self.connect(self.worker_thread, SIGNAL('result(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)'), self.process_result, Qt.QueuedConnection) self.connect(self.input_txt, SIGNAL('textChanged(QString)'), lambda s: self.search()) self.connect(self.regexp_combo, SIGNAL('currentIndexChanged(int)'), lambda x: self.search()) self.connect(self.result_txt, SIGNAL('leave()'), lambda: self.input_txt.setFocus()) qtutils.add_action(self.input_txt, 'Focus Results', self.focus_results, hotkeys.DOWN, *hotkeys.ACCEPT) qtutils.add_action(self, 'Focus Input', self.focus_input, hotkeys.FOCUS) qtutils.connect_toggle(self.shell_checkbox, lambda x: self.search()) qtutils.connect_button(self.close_button, self.close) qtutils.add_close_action(self) if not self.restore_state(): width, height = qtutils.default_size(parent, 666, 420) self.resize(width, height)
def __init__(self, model, parent=None): Dialog.__init__(self, parent=parent) self.model = model self.stashes = [] self.revids = [] self.names = [] self.setWindowTitle(N_('Stash')) self.setAttribute(QtCore.Qt.WA_MacMetalStyle) if parent is not None: self.setWindowModality(QtCore.Qt.WindowModal) self.resize(parent.width(), 420) else: self.resize(700, 420) self.stash_list = QtGui.QListWidget(self) self.stash_text = DiffTextEdit(self) self.button_apply = qtutils.create_toolbutton( text=N_('Apply'), tooltip=N_('Apply the selected stash'), icon=icons.ok()) self.button_save = qtutils.create_toolbutton( text=N_('Save'), tooltip=N_('Save modified state to new stash'), icon=icons.save()) self.button_drop = qtutils.create_toolbutton( text=N_('Drop'), tooltip=N_('Drop the selected stash'), icon=icons.discard()) self.button_close = qtutils.close_button() self.keep_index = qtutils.checkbox(text=N_('Keep Index'), checked=True) # Arrange layouts self.splitter = qtutils.splitter(Qt.Horizontal, self.stash_list, self.stash_text) self.btn_layt = qtutils.hbox(defs.no_margin, defs.spacing, self.button_save, self.button_apply, self.button_drop, self.keep_index, qtutils.STRETCH, self.button_close) self.main_layt = qtutils.vbox(defs.margin, defs.spacing, self.splitter, self.btn_layt) self.setLayout(self.main_layt) self.splitter.setSizes([self.width() // 3, self.width() * 2 // 3]) self.update_from_model() self.update_actions() self.setTabOrder(self.button_save, self.button_apply) self.setTabOrder(self.button_apply, self.button_drop) self.setTabOrder(self.button_drop, self.keep_index) self.setTabOrder(self.keep_index, self.button_close) self.connect(self.stash_list, SIGNAL('itemSelectionChanged()'), self.item_selected) qtutils.connect_button(self.button_apply, self.stash_apply) qtutils.connect_button(self.button_save, self.stash_save) qtutils.connect_button(self.button_drop, self.stash_drop) qtutils.connect_button(self.button_close, self.close)
def __init__(self, parent): standard.Dialog.__init__(self, parent) self.setAttribute(Qt.WA_MacMetalStyle) self.setWindowTitle(N_('Search')) self.mode_combo = QtGui.QComboBox() self.browse_button = create_toolbutton(icon=icons.folder(), tooltip=N_('Browse...')) self.query = QtGui.QLineEdit() self.start_date = QtGui.QDateEdit() self.start_date.setCurrentSection(QtGui.QDateTimeEdit.YearSection) self.start_date.setCalendarPopup(True) self.start_date.setDisplayFormat(N_('yyyy-MM-dd')) self.end_date = QtGui.QDateEdit() self.end_date.setCurrentSection(QtGui.QDateTimeEdit.YearSection) self.end_date.setCalendarPopup(True) self.end_date.setDisplayFormat(N_('yyyy-MM-dd')) icon = icons.search() self.search_button = qtutils.create_button(text=N_('Search'), icon=icon, default=True) self.max_count = QtGui.QSpinBox() self.max_count.setMinimum(5) self.max_count.setMaximum(9995) self.max_count.setSingleStep(5) self.max_count.setValue(500) self.commit_list = QtGui.QListWidget() self.commit_list.setMinimumSize(QtCore.QSize(1, 1)) self.commit_list.setAlternatingRowColors(True) selection_mode = QtGui.QAbstractItemView.SingleSelection self.commit_list.setSelectionMode(selection_mode) self.commit_text = DiffTextEdit(self, whitespace=False) self.button_export = qtutils.create_button(text=N_('Export Patches'), icon=icons.diff()) self.button_cherrypick = qtutils.create_button(text=N_('Cherry Pick'), icon=icons.save()) self.button_close = qtutils.close_button() self.top_layout = qtutils.hbox(defs.no_margin, defs.button_spacing, self.query, self.start_date, self.end_date, self.browse_button, self.search_button, qtutils.STRETCH, self.mode_combo, self.max_count) self.splitter = qtutils.splitter(Qt.Vertical, self.commit_list, self.commit_text) self.bottom_layout = qtutils.hbox(defs.no_margin, defs.spacing, self.button_export, self.button_cherrypick, qtutils.STRETCH, self.button_close) self.main_layout = qtutils.vbox(defs.margin, defs.spacing, self.top_layout, self.splitter, self.bottom_layout) self.setLayout(self.main_layout) if self.parent(): self.resize(self.parent().width(), self.parent().height()) else: self.resize(720, 500)
def __init__(self, parent): standard.Dialog.__init__(self, parent=parent) self.BRANCH_POINT = N_('*** Branch Point ***') self.SANDBOX = N_('*** Sandbox ***') self.LOCAL = N_('Local') self.setWindowTitle(N_('Branch Diff Viewer')) self.remote_branches = gitcmds.branch_list(remote=True) self.local_branches = gitcmds.branch_list(remote=False) self.top_widget = QtGui.QWidget() self.bottom_widget = QtGui.QWidget() self.left_combo = QtGui.QComboBox() self.left_combo.addItem(N_('Local')) self.left_combo.addItem(N_('Remote')) self.left_combo.setCurrentIndex(0) self.right_combo = QtGui.QComboBox() self.right_combo.addItem(N_('Local')) self.right_combo.addItem(N_('Remote')) self.right_combo.setCurrentIndex(1) self.left_list = QtGui.QListWidget() self.right_list = QtGui.QListWidget() self.button_spacer = QtGui.QSpacerItem(1, 1, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.button_compare = qtutils.create_button(text=N_('Compare'), icon=icons.diff()) self.button_close = qtutils.close_button() self.diff_files = standard.TreeWidget() self.diff_files.headerItem().setText(0, N_('File Differences')) self.top_grid_layout = qtutils.grid( defs.no_margin, defs.spacing, (self.left_combo, 0, 0, 1, 1), (self.left_list, 1, 0, 1, 1), (self.right_combo, 0, 1, 1, 1), (self.right_list, 1, 1, 1, 1)) self.top_widget.setLayout(self.top_grid_layout) self.bottom_grid_layout = qtutils.grid( defs.no_margin, defs.spacing, (self.diff_files, 0, 0, 1, 4), (self.button_spacer, 1, 1, 1, 1), (self.button_compare, 1, 2, 1, 1), (self.button_close, 1, 3, 1, 1)) self.bottom_widget.setLayout(self.bottom_grid_layout) self.splitter = qtutils.splitter(Qt.Vertical, self.top_widget, self.bottom_widget) self.main_layout = qtutils.vbox(defs.margin, defs.spacing, self.splitter) self.setLayout(self.main_layout) self.resize(658, 350) connect_button(self.button_close, self.accept) connect_button(self.button_compare, self.compare) self.connect(self.diff_files, SIGNAL('itemDoubleClicked(QTreeWidgetItem*,int)'), self.compare) self.connect(self.left_combo, SIGNAL('currentIndexChanged(int)'), lambda x: self.update_combo_boxes(left=True)) self.connect(self.right_combo, SIGNAL('currentIndexChanged(int)'), lambda x: self.update_combo_boxes(left=False)) self.connect(self.left_list, SIGNAL('itemSelectionChanged()'), self.update_diff_files) self.connect(self.right_list, SIGNAL('itemSelectionChanged()'), self.update_diff_files) self.update_combo_boxes(left=True) self.update_combo_boxes(left=False) # Pre-select the 0th elements item = self.left_list.item(0) if item: self.left_list.setCurrentItem(item) self.left_list.setItemSelected(item, True) item = self.right_list.item(0) if item: self.right_list.setCurrentItem(item) self.right_list.setItemSelected(item, True)
def __init__(self, ref, shortref=None, parent=None): QtGui.QDialog.__init__(self, parent) if parent is not None: self.setWindowModality(Qt.WindowModal) # input self.ref = ref if shortref is None: shortref = ref # outputs self.fmt = None filename = '%s-%s' % (os.path.basename(core.getcwd()), shortref) self.prefix = filename + '/' self.filename = filename # widgets self.setWindowTitle(N_('Save Archive')) self.filetext = QtGui.QLineEdit() self.filetext.setText(self.filename) self.browse = qtutils.create_toolbutton(icon=icons.file_zip()) self.format_strings = ( git.archive('--list')[STDOUT].rstrip().splitlines()) self.format_combo = QtGui.QComboBox() self.format_combo.setEditable(False) self.format_combo.addItems(self.format_strings) self.close_button = qtutils.close_button() self.save_button = qtutils.create_button(text=N_('Save'), icon=icons.save(), default=True) self.prefix_label = QtGui.QLabel() self.prefix_label.setText(N_('Prefix')) self.prefix_text = QtGui.QLineEdit() self.prefix_text.setText(self.prefix) self.prefix_group = ExpandableGroupBox() self.prefix_group.setTitle(N_('Advanced')) # layouts self.filelayt = qtutils.hbox(defs.no_margin, defs.spacing, self.browse, self.filetext, self.format_combo) self.prefixlayt = qtutils.hbox(defs.margin, defs.spacing, self.prefix_label, self.prefix_text) self.prefix_group.setLayout(self.prefixlayt) self.prefix_group.set_expanded(False) self.btnlayt = qtutils.hbox(defs.no_margin, defs.spacing, qtutils.STRETCH, self.close_button, self.save_button) self.mainlayt = qtutils.vbox(defs.margin, defs.no_spacing, self.filelayt, self.prefix_group, qtutils.STRETCH, self.btnlayt) self.setLayout(self.mainlayt) self.resize(defs.scale(520), defs.scale(10)) # initial setup; done before connecting to avoid # signal/slot side-effects if 'tar.gz' in self.format_strings: idx = self.format_strings.index('tar.gz') elif 'zip' in self.format_strings: idx = self.format_strings.index('zip') else: idx = 0 self.format_combo.setCurrentIndex(idx) self.update_filetext_for_format(idx) # connections self.connect(self.filetext, SIGNAL('textChanged(QString)'), self.filetext_changed) self.connect(self.prefix_text, SIGNAL('textChanged(QString)'), self.prefix_text_changed) self.connect(self.format_combo, SIGNAL('currentIndexChanged(int)'), self.update_filetext_for_format) self.connect(self.prefix_group, SIGNAL('expanded(bool)'), self.prefix_group_expanded) self.connect(self, SIGNAL('accepted()'), self.archive_saved) qtutils.connect_button(self.browse, self.choose_filename) qtutils.connect_button(self.close_button, self.reject) qtutils.connect_button(self.save_button, self.save_archive)
def __init__(self, model, parent=None): Dialog.__init__(self, parent=parent) self.setAttribute(Qt.WA_MacMetalStyle) self.setWindowTitle(N_('Create Branch')) if parent is not None: self.setWindowModality(Qt.WindowModal) 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(N_('Create Branch')) self.progress.setWindowModality(Qt.WindowModal) self.branch_name_label = QtGui.QLabel() self.branch_name_label.setText(N_('Branch Name')) self.branch_name = QtGui.QLineEdit() self.rev_label = QtGui.QLabel() self.rev_label.setText(N_('Starting Revision')) self.revision = completion.GitRefLineEdit() current = gitcmds.current_branch() if current: self.revision.setText(current) self.local_radio = qtutils.radio(text=N_('Local branch'), checked=True) self.remote_radio = qtutils.radio(text=N_('Tracking branch')) self.tag_radio = qtutils.radio(text=N_('Tag')) self.branch_list = QtGui.QListWidget() self.update_existing_label = QtGui.QLabel() self.update_existing_label.setText(N_('Update Existing Branch:')) self.no_update_radio = qtutils.radio(text=N_('No')) self.ffwd_only_radio = qtutils.radio(text=N_('Fast Forward Only'), checked=True) self.reset_radio = qtutils.radio(text=N_('Reset')) text = N_('Fetch Tracking Branch') self.fetch_checkbox = qtutils.checkbox(text=text, checked=True) text = N_('Checkout After Creation') self.checkout_checkbox = qtutils.checkbox(text=text, checked=True) icon = icons.branch() self.create_button = qtutils.create_button(text=N_('Create Branch'), icon=icon, default=True) self.close_button = qtutils.close_button() self.rev_start_group = QtGui.QGroupBox() self.rev_start_group.setTitle(N_('Starting Revision')) self.option_group = QtGui.QGroupBox() self.option_group.setTitle(N_('Options')) self.options_checkbox_layout = qtutils.vbox(defs.margin, defs.spacing, self.fetch_checkbox, self.checkout_checkbox) self.options_bottom_layout = qtutils.hbox(defs.margin, defs.spacing, self.options_checkbox_layout, qtutils.STRETCH) self.branch_name_layout = qtutils.hbox(defs.margin, defs.spacing, self.branch_name_label, self.branch_name) self.rev_start_radiobtn_layout = qtutils.hbox(defs.margin, defs.spacing, self.local_radio, self.remote_radio, self.tag_radio, qtutils.STRETCH) self.rev_start_textinput_layout = qtutils.hbox(defs.no_margin, defs.spacing, self.rev_label, self.revision) self.rev_start_layout = qtutils.vbox(defs.no_margin, defs.spacing, self.rev_start_radiobtn_layout, self.branch_list, self.rev_start_textinput_layout) self.rev_start_group.setLayout(self.rev_start_layout) self.options_radio_layout = qtutils.hbox(defs.no_margin, defs.spacing, self.update_existing_label, self.no_update_radio, self.ffwd_only_radio, self.reset_radio) self.options_grp_layout = qtutils.vbox(defs.no_margin, defs.spacing, self.options_radio_layout, self.options_bottom_layout) self.option_group.setLayout(self.options_grp_layout) self.buttons_layout = qtutils.hbox(defs.margin, defs.spacing, self.create_button, self.close_button) self.options_section_layout = qtutils.hbox(defs.no_margin, defs.spacing, self.option_group, self.buttons_layout) self.main_layout = qtutils.vbox(defs.margin, defs.spacing, self.branch_name_layout, self.rev_start_group, 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_SIGNAL), self.thread_command, Qt.QueuedConnection) self.connect(self.thread, SIGNAL('done(PyQt_PyObject)'), self.thread_done, Qt.QueuedConnection) self.resize(555, 333) self.display_model()
def __init__(self, parent=None): QtGui.QDialog.__init__(self, parent) self.setWindowTitle(N_('Edit Remotes')) if parent is not None: self.setWindowModality(Qt.WindowModal) width = max(640, parent.width()) height = max(480, parent.height()) self.resize(width, height) else: self.resize(720, 300) self.default_hint = N_( '' 'Add and remove remote repositories using the \n' 'Add(+) and Delete(-) buttons on the left-hand side.\n' '\n' 'Remotes can be renamed by selecting one from the list\n' 'and pressing "enter", or by double-clicking.') self.remote_list = [] self.remotes = QtGui.QListWidget() self.remotes.setToolTip( N_('Remote git repositories - double-click to rename')) self.info = text.HintedTextView(self.default_hint, self) font = self.info.font() metrics = QtGui.QFontMetrics(font) width = metrics.width('_' * 42) height = metrics.height() * 13 self.info.setMinimumWidth(width) self.info.setMinimumHeight(height) self.info_thread = RemoteInfoThread(self) icon = icons.add() tooltip = N_('Add new remote git repository') self.add_btn = qtutils.create_toolbutton(icon=icon, tooltip=tooltip) self.refresh_btn = qtutils.create_toolbutton(icon=icons.sync(), tooltip=N_('Refresh')) self.delete_btn = qtutils.create_toolbutton( icon=icons.remove(), tooltip=N_('Delete remote')) self.close_btn = qtutils.close_button() self._top_layout = qtutils.splitter(Qt.Horizontal, self.remotes, self.info) width = self._top_layout.width() self._top_layout.setSizes([width // 4, width * 3 // 4]) self._button_layout = qtutils.hbox(defs.margin, defs.spacing, self.add_btn, self.delete_btn, self.refresh_btn, qtutils.STRETCH, self.close_btn) self._layout = qtutils.vbox(defs.margin, defs.spacing, self._top_layout, self._button_layout) self.setLayout(self._layout) self.refresh() qtutils.connect_button(self.add_btn, self.add) qtutils.connect_button(self.delete_btn, self.delete) qtutils.connect_button(self.refresh_btn, self.refresh) qtutils.connect_button(self.close_btn, self.close) self.connect(self.info_thread, SIGNAL('info(PyQt_PyObject)'), self.info.set_value, Qt.QueuedConnection) self.connect(self.remotes, SIGNAL('itemChanged(QListWidgetItem*)'), self.remote_renamed) self.connect(self.remotes, SIGNAL('itemSelectionChanged()'), self.selection_changed)
def __init__(self, parent=None): QtGui.QDialog.__init__(self, parent) self.setWindowTitle(N_('git-cola')) self.repodir = None self.task_runner = TaskRunner(self) self.progress = ProgressDialog('', '', self) self.new_button = qtutils.create_button(text=N_('New...'), icon=icons.new()) self.open_button = qtutils.create_button(text=N_('Open...'), icon=icons.repo()) self.clone_button = qtutils.create_button(text=N_('Clone...'), icon=icons.cola()) self.close_button = qtutils.close_button() settings = Settings() settings.load() self.bookmarks_label = QtGui.QLabel(N_('Select Repository...')) self.bookmarks_label.setAlignment(Qt.AlignCenter) self.bookmarks_model = QtGui.QStandardItemModel() item = QtGui.QStandardItem(N_('Select manually...')) item.setEditable(False) self.bookmarks_model.appendRow(item) added = set() all_repos = settings.bookmarks + settings.recent for repo in all_repos: if repo in added: continue added.add(repo) item = QtGui.QStandardItem(repo) item.setEditable(False) self.bookmarks_model.appendRow(item) selection_mode = QtGui.QAbstractItemView.SingleSelection self.bookmarks = QtGui.QListView() self.bookmarks.setSelectionMode(selection_mode) self.bookmarks.setAlternatingRowColors(True) self.bookmarks.setModel(self.bookmarks_model) if not all_repos: self.bookmarks_label.setMinimumHeight(1) self.bookmarks.setMinimumHeight(1) self.bookmarks_label.hide() self.bookmarks.hide() self.button_layout = qtutils.hbox(defs.no_margin, defs.spacing, self.open_button, self.clone_button, self.new_button, qtutils.STRETCH, self.close_button) self.main_layout = qtutils.vbox(defs.margin, defs.spacing, self.bookmarks_label, self.bookmarks, self.button_layout) self.setLayout(self.main_layout) qtutils.connect_button(self.open_button, self.open_repo) qtutils.connect_button(self.clone_button, self.clone_repo) qtutils.connect_button(self.new_button, self.new_repo) qtutils.connect_button(self.close_button, self.reject) self.connect(self.bookmarks, SIGNAL('activated(QModelIndex)'), self.open_bookmark)