From dcd40e043519239bf595d76ae37b0636ac0ca045 Mon Sep 17 00:00:00 2001 From: David Aguilar Date: Sat, 3 Oct 2009 18:40:36 -0700 Subject: [PATCH] Death to .ui: Add an 'OptionsView' class to replace the .ui file Signed-off-by: David Aguilar --- cola/views/__init__.py | 4 +- cola/views/option.py | 246 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 248 insertions(+), 2 deletions(-) create mode 100644 cola/views/option.py diff --git a/cola/views/__init__.py b/cola/views/__init__.py index c4c3bcf5..2a3c7ea0 100644 --- a/cola/views/__init__.py +++ b/cola/views/__init__.py @@ -15,6 +15,7 @@ from PyQt4.QtCore import SIGNAL from cola import core from cola.views.standard import create_standard_view +from cola.views.option import OptionsView from cola.views.syntax import DiffSyntaxHighlighter try: @@ -24,7 +25,6 @@ try: from cola.gui.compare import Ui_compare from cola.gui.createbranch import Ui_createbranch from cola.gui.items import Ui_items - from cola.gui.options import Ui_options from cola.gui.remote import Ui_remote from cola.gui.stash import Ui_stash except ImportError: @@ -32,7 +32,7 @@ except ImportError: 'Try running "make" in the cola source tree.\n') sys.exit(-1) -OptionsView = create_standard_view(Ui_options, QDialog) + BranchCompareView = create_standard_view(Ui_branchview, QDialog) CreateBranchView = create_standard_view(Ui_createbranch, QDialog) BookmarkView = create_standard_view(Ui_bookmark, QDialog) diff --git a/cola/views/option.py b/cola/views/option.py new file mode 100644 index 00000000..44e0bc31 --- /dev/null +++ b/cola/views/option.py @@ -0,0 +1,246 @@ +from PyQt4 import QtCore +from PyQt4 import QtGui +from PyQt4.QtCore import SIGNAL + +from cola.views import standard + + +class OptionsView(standard.StandardDialog): + def __init__(self, parent=None): + standard.StandardDialog.__init__(self, parent=parent) + #self.setWindowModality(QtCore.Qt.ApplicationModal) + self.setWindowTitle(self.tr('Options')) + self.resize(608, 425) + + self._main_layt = QtGui.QVBoxLayout(self) + self._main_grid = QtGui.QGridLayout() + self._diff_font_label = QtGui.QLabel(self) + self._diff_font_label.setText(self.tr('Diff/Console Font')) + self._main_grid.addWidget(self._diff_font_label, 0, 0, 1, 1) + + # Exposed + self.global_cola_fontdiff_size = QtGui.QSpinBox(self) + self.global_cola_fontdiff_size.setMinimum(8) + self.global_cola_fontdiff_size.setProperty('value', QtCore.QVariant(12)) + self._main_grid.addWidget(self.global_cola_fontdiff_size, 0, 1, 1, 1) + + # Exposed + self.global_cola_fontdiff = QtGui.QFontComboBox(self) + self.global_cola_fontdiff.setFontFilters(QtGui.QFontComboBox.MonospacedFonts) + self._main_grid.addWidget(self.global_cola_fontdiff, 0, 2, 1, 2) + + self._tab_width_label = QtGui.QLabel(self) + self._tab_width_label.setText(self.tr('Tab Width')) + self._main_grid.addWidget(self._tab_width_label, 1, 0, 1, 1) + + # Exposed + self.global_cola_tabwidth = QtGui.QSpinBox(self) + self.global_cola_tabwidth.setWrapping(True) + self.global_cola_tabwidth.setMaximum(42) + self.global_cola_tabwidth.setProperty('value', QtCore.QVariant(8)) + self._main_grid.addWidget(self.global_cola_tabwidth, 1, 1, 1, 1) + + # Exposed + self.global_cola_savewindowsettings = QtGui.QCheckBox(self) + self.global_cola_savewindowsettings.setText(self.tr('Save GUI Settings')) + self._main_grid.addWidget(self.global_cola_savewindowsettings, 1, 2, 1, 1) + + # Exposed + self.global_merge_keepbackup = QtGui.QCheckBox(self) + self.global_merge_keepbackup.setText(self.tr('Save *.orig Merge Backups')) + self._main_grid.addWidget(self.global_merge_keepbackup, 1, 3, 1, 1) + + self._editor_label = QtGui.QLabel(self) + self._editor_label.setText(self.tr('Editor')) + self._main_grid.addWidget(self._editor_label, 2, 0, 1, 1) + + # Exposed + self.global_gui_editor = QtGui.QLineEdit(self) + self._main_grid.addWidget(self.global_gui_editor, 2, 1, 1, 1) + + self._difftool_label = QtGui.QLabel(self) + self._difftool_label.setText(self.tr('Diff Tool')) + self._main_grid.addWidget(self._difftool_label, 2, 2, 1, 1) + + # Exposed + self.global_diff_tool = QtGui.QLineEdit(self) + self._main_grid.addWidget(self.global_diff_tool, 2, 3, 1, 1) + + self._historybrowser_label = QtGui.QLabel(self) + self._historybrowser_label.setText(self.tr('History Browser')) + self._main_grid.addWidget(self._historybrowser_label, 3, 0, 1, 1) + + # Exposed + self.global_gui_historybrowser = QtGui.QLineEdit(self) + self._main_grid.addWidget(self.global_gui_historybrowser, + 3, 1, 1, 1) + + self._mergetool_label = QtGui.QLabel(self) + self._mergetool_label.setText(self.tr('Merge Tool')) + self._main_grid.addWidget(self._mergetool_label, 3, 2, 1, 1) + + # Exposed + self.global_merge_tool = QtGui.QLineEdit(self) + self._main_grid.addWidget(self.global_merge_tool, 3, 3, 1, 1) + + self._main_layt.addLayout(self._main_grid) + + self._repo_horiz_layt = QtGui.QHBoxLayout() + self._repo_horiz_layt.setSpacing(3) + + # Exposed + self.local_groupbox = QtGui.QGroupBox(self) + self.local_groupbox.setTitle(self.tr('Local Repository')) + + self._local_repo_layt = QtGui.QGridLayout(self.local_groupbox) + + self._local_user_name_label = QtGui.QLabel(self.local_groupbox) + self._local_user_name_label.setText(self.tr('User Name')) + self._local_repo_layt.addWidget(self._local_user_name_label, + 0, 0, 1, 1) + + # Exposed + self.local_user_name = QtGui.QLineEdit(self.local_groupbox) + + self._local_repo_layt.addWidget(self.local_user_name, + 0, 1, 1, 2) + + self._local_user_email_label = QtGui.QLabel(self.local_groupbox) + self._local_user_email_label.setText(self.tr('Email Address')) + self._local_repo_layt.addWidget(self._local_user_email_label, + 1, 0, 1, 1) + + # Exposed + self.local_user_email = QtGui.QLineEdit(self.local_groupbox) + self._local_repo_layt.addWidget(self.local_user_email, + 1, 1, 1, 2) + + self._local_merge_verb_label = QtGui.QLabel(self.local_groupbox) + self._local_merge_verb_label.setText(self.tr('Merge Verbosity')) + self._local_repo_layt.addWidget(self._local_merge_verb_label, + 2, 0, 1, 2) + + # Exposed + self.local_merge_verbosity = QtGui.QSpinBox(self.local_groupbox) + self.local_merge_verbosity.setMinimum(0) + self.local_merge_verbosity.setMaximum(5) + self.local_merge_verbosity.setProperty('value', QtCore.QVariant(5)) + self._local_repo_layt.addWidget(self.local_merge_verbosity, + 2, 2, 1, 1) + + self._local_diffctxt_label = QtGui.QLabel(self.local_groupbox) + self._local_diffctxt_label.setText(self.tr('Number of Diff Context Lines')) + self._local_repo_layt.addWidget(self._local_diffctxt_label, + 3, 0, 1, 2) + + # Exposed + self.local_gui_diffcontext = QtGui.QSpinBox(self.local_groupbox) + self.local_gui_diffcontext.setMinimum(2) + self.local_gui_diffcontext.setProperty('value', QtCore.QVariant(5)) + self._local_repo_layt.addWidget(self.local_gui_diffcontext, + 3, 2, 1, 1) + + # Exposed + self.local_merge_summary = QtGui.QCheckBox(self.local_groupbox) + self.local_merge_summary.setText(self.tr('Summarize Merge Commits')) + self._local_repo_layt.addWidget(self.local_merge_summary, + 4, 0, 1, 2) + + # Exposed + self.local_merge_diffstat = QtGui.QCheckBox(self.local_groupbox) + self.local_merge_diffstat.setText(self.tr('Show Diffstat After Merge')) + self._local_repo_layt.addWidget(self.local_merge_diffstat, + 5, 0, 1, 2) + + self._repo_horiz_layt.addWidget(self.local_groupbox) + + self._global_repo_grp = QtGui.QGroupBox(self) + self._global_repo_grp.setTitle(self.tr('Global (All Repositories)')) + + self._global_repo_lyt = QtGui.QGridLayout(self._global_repo_grp) + self._global_user_name_label = QtGui.QLabel(self._global_repo_grp) + self._global_user_name_label.setText(self.tr('User Name')) + self._global_repo_lyt.addWidget(self._global_user_name_label, + 0, 0, 1, 1) + + # Exposed + self.global_user_name = QtGui.QLineEdit(self._global_repo_grp) + self._global_repo_lyt.addWidget(self.global_user_name, + 0, 1, 1, 2) + + self._global_user_email_label = QtGui.QLabel(self._global_repo_grp) + self._global_user_email_label.setText(self.tr('Email Address')) + self._global_repo_lyt.addWidget(self._global_user_email_label, + 1, 0, 1, 1) + + # Exposed + self.global_user_email = QtGui.QLineEdit(self._global_repo_grp) + self._global_repo_lyt.addWidget(self.global_user_email, + 1, 1, 1, 2) + + self._global_merge_verb_label = QtGui.QLabel(self._global_repo_grp) + self._global_merge_verb_label.setText(self.tr('Merge Verbosity')) + self._global_repo_lyt.addWidget(self._global_merge_verb_label, + 2, 0, 1, 2) + + # Exposed + self.global_merge_verbosity = QtGui.QSpinBox(self._global_repo_grp) + self.global_merge_verbosity.setMinimum(0) + self.global_merge_verbosity.setMaximum(5) + self.global_merge_verbosity.setProperty('value', QtCore.QVariant(5)) + self._global_repo_lyt.addWidget(self.global_merge_verbosity, + 2, 2, 1, 1) + + self._global_diffctxt_label = QtGui.QLabel(self._global_repo_grp) + self._global_diffctxt_label.setText( + self.tr('Number of Diff Context Lines')) + self._global_repo_lyt.addWidget(self._global_diffctxt_label, + 3, 0, 1, 2) + + # Exposed + self.global_gui_diffcontext = QtGui.QSpinBox(self._global_repo_grp) + self.global_gui_diffcontext.setMinimum(2) + self.global_gui_diffcontext.setProperty('value', QtCore.QVariant(5)) + self._global_repo_lyt.addWidget(self.global_gui_diffcontext, 3, 2, 1, 1) + + # Exposed + self.global_merge_summary = QtGui.QCheckBox(self._global_repo_grp) + self.global_merge_summary.setText(self.tr('Summarize Merge Commits')) + self._global_repo_lyt.addWidget(self.global_merge_summary, 4, 0, 1, 2) + + # Exposed + self.global_merge_diffstat = QtGui.QCheckBox(self._global_repo_grp) + self.global_merge_diffstat.setText(self.tr('Show Diffstat After Merge')) + self._global_repo_lyt.addWidget(self.global_merge_diffstat, 5, 0, 1, 2) + + self._repo_horiz_layt.addWidget(self._global_repo_grp) + self._main_layt.addLayout(self._repo_horiz_layt) + + # Save/Cancel buttons + self._button_layt = QtGui.QHBoxLayout() + self._button_spacer = QtGui.QSpacerItem(1, 1, + QtGui.QSizePolicy.Expanding, + QtGui.QSizePolicy.Minimum) + self._button_layt.addItem(self._button_spacer) + + # Exposed + self.save_button = QtGui.QPushButton(self) + self.save_button.setText(self.tr('Save')) + self.save_button.setDefault(True) + self._button_layt.addWidget(self.save_button) + + # Exposed + self.cancel_button = QtGui.QPushButton(self) + self.cancel_button.setText(self.tr('Cancel')) + self._button_layt.addWidget(self.cancel_button) + self._main_layt.addLayout(self._button_layt) + + self.connect(self.cancel_button, SIGNAL('released()'), self.reject) + + +if __name__ == "__main__": + import sys + app = QtGui.QApplication(sys.argv) + options = OptionsView() + options.show() + sys.exit(app.exec_()) -- 2.11.4.GIT