def done(self, exit_code): qtutils.save_state(self) return Dialog.done(self, exit_code)
def __init__(self, parent): Dialog.__init__(self, parent) self.setAttribute(Qt.WA_MacMetalStyle) self.setWindowModality(Qt.WindowModal) self.input_label = QtGui.QLabel('git grep') self.input_label.setFont(diff_font()) hint = 'command-line arguments' self.input_txt = GrepLineEdit(hint, self) self.input_txt.enable_hint(True) hint = 'grep result...' self.result_txt = GrepTextView(hint, self) self.result_txt.enable_hint(True) self.edit_button = QtGui.QPushButton(self.tr('Edit')) self.edit_button.setIcon(qtutils.open_file_icon()) self.edit_button.setEnabled(False) self.edit_button.setShortcut(cmds.Edit.SHORTCUT) self.refresh_button = QtGui.QPushButton(self.tr('Refresh')) self.refresh_button.setIcon(qtutils.reload_icon()) self.refresh_button.setShortcut(QtGui.QKeySequence.Refresh) self.shell_checkbox = QtGui.QCheckBox(self.tr('Shell arguments')) self.shell_checkbox.setToolTip( 'Parse arguments using a shell.\n' 'Queries with spaces will require "double quotes".') self.shell_checkbox.setChecked(False) self.close_button = QtGui.QPushButton(self.tr('Close')) self.input_layout = QtGui.QHBoxLayout() self.input_layout.setMargin(0) self.input_layout.setSpacing(defs.button_spacing) self.bottom_layout = QtGui.QHBoxLayout() self.bottom_layout.setMargin(0) self.bottom_layout.setSpacing(defs.button_spacing) self.mainlayout = QtGui.QVBoxLayout() self.mainlayout.setMargin(defs.margin) self.mainlayout.setSpacing(defs.spacing) self.input_layout.addWidget(self.input_label) self.input_layout.addWidget(self.input_txt) self.bottom_layout.addWidget(self.edit_button) self.bottom_layout.addWidget(self.refresh_button) self.bottom_layout.addWidget(self.shell_checkbox) self.bottom_layout.addStretch() self.bottom_layout.addWidget(self.close_button) self.mainlayout.addLayout(self.input_layout) self.mainlayout.addWidget(self.result_txt) self.mainlayout.addLayout(self.bottom_layout) self.setLayout(self.mainlayout) self.grep_thread = GrepThread(self) self.connect(self.grep_thread, SIGNAL('result'), self.process_result) self.connect(self.input_txt, SIGNAL('textChanged(QString)'), self.input_txt_changed) self.connect(self.input_txt, SIGNAL('returnPressed()'), lambda: self.result_txt.setFocus()) qtutils.connect_button(self.edit_button, self.edit) qtutils.connect_button(self.refresh_button, self.search) qtutils.connect_button(self.close_button, self.close) qtutils.add_close_action(self) if not qtutils.apply_state(self): self.resize(666, 420)
def done(self, exit_code): self.save_state() return Dialog.done(self, exit_code)
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.input_label = QtGui.QLabel('git grep') self.input_label.setFont(diff_font()) self.input_txt = HintedLineEdit(N_('command-line arguments'), self) self.input_txt.enable_hint(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.enable_hint(True) self.edit_button = QtGui.QPushButton(N_('Edit')) self.edit_button.setIcon(qtutils.open_file_icon()) self.edit_button.setEnabled(False) self.edit_button.setShortcut(cmds.Edit.SHORTCUT) self.refresh_button = QtGui.QPushButton(N_('Refresh')) self.refresh_button.setIcon(qtutils.reload_icon()) self.refresh_button.setShortcut(QtGui.QKeySequence.Refresh) self.shell_checkbox = QtGui.QCheckBox(N_('Shell arguments')) self.shell_checkbox.setToolTip( N_('Parse arguments using a shell.\n' 'Queries with spaces will require "double quotes".')) self.shell_checkbox.setChecked(False) self.close_button = QtGui.QPushButton(N_('Close')) 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'), self.process_result) 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, Qt.Key_Down, Qt.Key_Enter, Qt.Key_Return) qtutils.add_action(self, 'Focus Input', self.focus_input, 'Ctrl+L') qtutils.connect_button(self.edit_button, self.edit) qtutils.connect_button(self.refresh_button, self.search) 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): Dialog.__init__(self, parent) self.setAttribute(Qt.WA_MacMetalStyle) self.setWindowModality(Qt.WindowModal) self.input_label = QtGui.QLabel('git grep') self.input_label.setFont(diff_font()) hint = N_('command-line arguments') self.input_txt = HintedLineEdit(hint, self) self.input_txt.enable_hint(True) hint = N_('grep result...') self.result_txt = GrepTextView(hint, self) self.result_txt.enable_hint(True) self.edit_button = QtGui.QPushButton(N_('Edit')) self.edit_button.setIcon(qtutils.open_file_icon()) self.edit_button.setEnabled(False) self.edit_button.setShortcut(cmds.Edit.SHORTCUT) self.refresh_button = QtGui.QPushButton(N_('Refresh')) self.refresh_button.setIcon(qtutils.reload_icon()) self.refresh_button.setShortcut(QtGui.QKeySequence.Refresh) self.shell_checkbox = QtGui.QCheckBox(N_('Shell arguments')) self.shell_checkbox.setToolTip( N_('Parse arguments using a shell.\n' 'Queries with spaces will require "double quotes".')) self.shell_checkbox.setChecked(False) self.close_button = QtGui.QPushButton(N_('Close')) self.input_layout = QtGui.QHBoxLayout() self.input_layout.setMargin(0) self.input_layout.setSpacing(defs.button_spacing) self.bottom_layout = QtGui.QHBoxLayout() self.bottom_layout.setMargin(0) self.bottom_layout.setSpacing(defs.button_spacing) self.mainlayout = QtGui.QVBoxLayout() self.mainlayout.setMargin(defs.margin) self.mainlayout.setSpacing(defs.spacing) self.input_layout.addWidget(self.input_label) self.input_layout.addWidget(self.input_txt) self.bottom_layout.addWidget(self.edit_button) self.bottom_layout.addWidget(self.refresh_button) self.bottom_layout.addWidget(self.shell_checkbox) self.bottom_layout.addStretch() self.bottom_layout.addWidget(self.close_button) self.mainlayout.addLayout(self.input_layout) self.mainlayout.addWidget(self.result_txt) self.mainlayout.addLayout(self.bottom_layout) self.setLayout(self.mainlayout) self.grep_thread = GrepThread(self) self.connect(self.grep_thread, SIGNAL('result'), self.process_result) self.connect(self.input_txt, SIGNAL('textChanged(QString)'), self.input_txt_changed) self.connect(self.result_txt, SIGNAL('leave()'), lambda: self.input_txt.setFocus()) qtutils.add_action(self.input_txt, 'FocusResults', lambda: self.result_txt.setFocus(), Qt.Key_Down, Qt.Key_Enter, Qt.Key_Return) qtutils.connect_button(self.edit_button, self.edit) qtutils.connect_button(self.refresh_button, self.search) qtutils.connect_button(self.close_button, self.close) qtutils.add_close_action(self) if not qtutils.apply_state(self): self.resize(666, 420)
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 = QtGui.QRadioButton() self.local_radio.setText(N_('Local branch')) self.local_radio.setChecked(True) self.remote_radio = QtGui.QRadioButton() self.remote_radio.setText(N_('Tracking branch')) self.tag_radio = QtGui.QRadioButton() self.tag_radio.setText(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 = QtGui.QRadioButton() self.no_update_radio.setText(N_('No')) self.ffwd_only_radio = QtGui.QRadioButton() self.ffwd_only_radio.setText(N_('Fast Forward Only')) self.ffwd_only_radio.setChecked(True) self.reset_radio = QtGui.QRadioButton() self.reset_radio.setText(N_('Reset')) self.fetch_checkbox = QtGui.QCheckBox() self.fetch_checkbox.setText(N_('Fetch Tracking Branch')) self.fetch_checkbox.setChecked(True) self.checkout_checkbox = QtGui.QCheckBox() self.checkout_checkbox.setText(N_('Checkout After Creation')) self.checkout_checkbox.setChecked(True) self.create_button = qtutils.create_button(text=N_('Create Branch'), icon=qtutils.git_icon()) self.create_button.setDefault(True) self.close_button = qtutils.create_button(text=N_('Close')) 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, 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 =\ self.toolbutton(N_('Apply'), N_('Apply the selected stash'), qtutils.apply_icon()) self.button_save =\ self.toolbutton(N_('Save'), N_('Save modified state to new stash'), qtutils.save_icon()) self.button_drop = \ self.toolbutton(N_('Drop'), N_('Drop the selected stash'), qtutils.discard_icon()) self.button_close = \ self.pushbutton(N_('Close'), N_('Close'), qtutils.close_icon()) self.keep_index = QtGui.QCheckBox(self) self.keep_index.setText(N_('Keep Index')) self.keep_index.setChecked(True) # Arrange layouts self.main_layt = QtGui.QVBoxLayout() self.main_layt.setMargin(defs.margin) self.main_layt.setSpacing(defs.spacing) self.btn_layt = QtGui.QHBoxLayout() self.btn_layt.setMargin(defs.no_margin) self.btn_layt.setSpacing(defs.spacing) self.splitter = QtGui.QSplitter() self.splitter.setHandleWidth(defs.handle_width) self.splitter.setOrientation(QtCore.Qt.Horizontal) self.splitter.setChildrenCollapsible(True) self.splitter.setStretchFactor(0, 1) self.splitter.setStretchFactor(1, 1) self.splitter.insertWidget(0, self.stash_list) self.splitter.insertWidget(1, self.stash_text) self.btn_layt.addWidget(self.button_save) self.btn_layt.addWidget(self.button_apply) self.btn_layt.addWidget(self.button_drop) self.btn_layt.addWidget(self.keep_index) self.btn_layt.addStretch() self.btn_layt.addWidget(self.button_close) self.main_layt.addWidget(self.splitter) self.main_layt.addLayout(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): 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): Dialog.__init__(self, parent) self.setAttribute(Qt.WA_MacMetalStyle) self.setWindowTitle(N_('Search')) if parent is not None: self.setWindowModality(Qt.WindowModal) 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.enable_hint(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.enable_hint(True) self.edit_button = QtGui.QPushButton(N_('Edit')) self.edit_button.setIcon(qtutils.open_file_icon()) self.edit_button.setEnabled(False) self.edit_button.setShortcut(cmds.Edit.SHORTCUT) self.refresh_button = QtGui.QPushButton(N_('Refresh')) self.refresh_button.setIcon(qtutils.reload_icon()) self.refresh_button.setShortcut(QtGui.QKeySequence.Refresh) self.shell_checkbox = QtGui.QCheckBox(N_('Shell arguments')) self.shell_checkbox.setToolTip( N_('Parse arguments using a shell.\n' 'Queries with spaces will require "double quotes".')) self.shell_checkbox.setChecked(False) self.close_button = QtGui.QPushButton(N_('Close')) self.input_layout = QtGui.QHBoxLayout() self.input_layout.setMargin(0) self.input_layout.setSpacing(defs.button_spacing) self.bottom_layout = QtGui.QHBoxLayout() self.bottom_layout.setMargin(0) self.bottom_layout.setSpacing(defs.button_spacing) self.mainlayout = QtGui.QVBoxLayout() self.mainlayout.setMargin(defs.margin) self.mainlayout.setSpacing(defs.spacing) self.input_layout.addWidget(self.input_label) self.input_layout.addWidget(self.input_txt) self.input_layout.addWidget(self.regexp_combo) self.bottom_layout.addWidget(self.edit_button) self.bottom_layout.addWidget(self.refresh_button) self.bottom_layout.addWidget(self.shell_checkbox) self.bottom_layout.addStretch() self.bottom_layout.addWidget(self.close_button) self.mainlayout.addLayout(self.input_layout) self.mainlayout.addWidget(self.result_txt) self.mainlayout.addLayout(self.bottom_layout) self.setLayout(self.mainlayout) self.grep_thread = GrepThread(self) self.connect(self.grep_thread, SIGNAL('result'), self.process_result) 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, 'FocusResults', lambda: self.result_txt.setFocus(), Qt.Key_Down, Qt.Key_Enter, Qt.Key_Return) qtutils.add_action(self, 'FocusSearch', lambda: self.input_txt.setFocus(), 'Ctrl+l') qtutils.connect_button(self.edit_button, self.edit) qtutils.connect_button(self.refresh_button, self.search) 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(): self.resize(666, 420)
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.setAttribute(QtCore.Qt.WA_MacMetalStyle) self.model = model self.stashes = [] self.revids = [] self.names = [] self.setWindowModality(QtCore.Qt.WindowModal) self.setWindowTitle(N_('Stash')) if parent: self.resize(parent.width(), 420) else: self.resize(700, 420) self.stash_list = QtGui.QListWidget(self) self.stash_text = DiffTextEdit(self) self.button_apply =\ self.toolbutton(N_('Apply'), N_('Apply the selected stash'), qtutils.apply_icon()) self.button_save =\ self.toolbutton(N_('Save'), N_('Save modified state to new stash'), qtutils.save_icon()) self.button_drop = \ self.toolbutton(N_('Drop'), N_('Drop the selected stash'), qtutils.discard_icon()) self.button_close = \ self.pushbutton(N_('Close'), N_('Close'), qtutils.close_icon()) self.keep_index = QtGui.QCheckBox(self) self.keep_index.setText(N_('Keep Index')) self.keep_index.setChecked(True) # Arrange layouts self.main_layt = QtGui.QVBoxLayout() self.main_layt.setMargin(defs.margin) self.main_layt.setSpacing(defs.spacing) self.btn_layt = QtGui.QHBoxLayout() self.btn_layt.setMargin(0) self.btn_layt.setSpacing(defs.spacing) self.splitter = QtGui.QSplitter() self.splitter.setHandleWidth(defs.handle_width) self.splitter.setOrientation(QtCore.Qt.Horizontal) self.splitter.setChildrenCollapsible(True) self.splitter.setStretchFactor(0, 1) self.splitter.setStretchFactor(1, 1) self.splitter.insertWidget(0, self.stash_list) self.splitter.insertWidget(1, self.stash_text) self.btn_layt.addWidget(self.button_save) self.btn_layt.addWidget(self.button_apply) self.btn_layt.addWidget(self.button_drop) self.btn_layt.addWidget(self.keep_index) self.btn_layt.addStretch() self.btn_layt.addWidget(self.button_close) self.main_layt.addWidget(self.splitter) self.main_layt.addLayout(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, 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 =\ self.toolbutton(N_('Apply'), N_('Apply the selected stash'), qtutils.apply_icon()) self.button_save =\ self.toolbutton(N_('Save'), N_('Save modified state to new stash'), qtutils.save_icon()) self.button_drop = \ self.toolbutton(N_('Drop'), N_('Drop the selected stash'), qtutils.discard_icon()) self.button_close = \ self.pushbutton(N_('Close'), N_('Close'), qtutils.close_icon()) self.keep_index = QtGui.QCheckBox(self) self.keep_index.setText(N_('Keep Index')) self.keep_index.setChecked(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, 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)