From 285690fee98fd04f943f8d876cb654db0bb405af Mon Sep 17 00:00:00 2001 From: Johannes Pohl Date: Sun, 16 Apr 2017 18:04:05 +0200 Subject: [PATCH] add dark theme for #240 --- src/urh/controller/OptionsController.py | 19 +++++++-------- src/urh/main.py | 31 +++++++++++++++++++++---- src/urh/ui/ui_options.py | 20 +++++++++++----- ui/options.ui | 28 +++++++++++++++++----- 4 files changed, 72 insertions(+), 26 deletions(-) diff --git a/src/urh/controller/OptionsController.py b/src/urh/controller/OptionsController.py index 03b731c371..ed8751bfa1 100644 --- a/src/urh/controller/OptionsController.py +++ b/src/urh/controller/OptionsController.py @@ -40,8 +40,7 @@ def __init__(self, installed_plugins, highlighted_plugins=None, parent=None): self.ui.groupBoxNativeOptions.setVisible(sys.platform != "win32") self.ui.labelWindowsError.setVisible(sys.platform == "win32" and platform.architecture()[0] != "64bit") - self.ui.checkBoxAlignLabels.setChecked(constants.SETTINGS.value("align_labels", True, bool)) - self.ui.checkBoxFallBackTheme.setChecked(constants.SETTINGS.value('use_fallback_theme', False, bool)) + self.ui.comboBoxTheme.setCurrentIndex(constants.SETTINGS.value("theme_index", 0, int)) self.ui.checkBoxShowConfirmCloseDialog.setChecked( not constants.SETTINGS.value('not_show_close_dialog', False, bool)) self.ui.checkBoxHoldShiftToDrag.setChecked(constants.SETTINGS.value('hold_shift_to_drag', False, bool)) @@ -124,7 +123,7 @@ def create_connects(self): self.ui.chkBoxDeviceEnabled.clicked.connect(self.on_chk_box_device_enabled_clicked) self.ui.rbGnuradioBackend.clicked.connect(self.on_rb_gnuradio_backend_clicked) self.ui.rbNativeBackend.clicked.connect(self.on_rb_native_backend_clicked) - self.ui.checkBoxFallBackTheme.clicked.connect(self.on_checkbox_fallback_theme_clicked) + self.ui.comboBoxTheme.currentIndexChanged.connect(self.on_combo_box_theme_index_changed) self.ui.checkBoxShowConfirmCloseDialog.clicked.connect(self.on_checkbox_confirm_close_dialog_clicked) self.ui.checkBoxHoldShiftToDrag.clicked.connect(self.on_checkbox_hold_shift_to_drag_clicked) self.ui.checkBoxAlignLabels.clicked.connect(self.on_checkbox_align_labels_clicked) @@ -296,17 +295,17 @@ def on_double_spinbox_ram_threshold_value_changed(self): constants.SETTINGS.setValue("ram_threshold", val / 100) @pyqtSlot(bool) - def on_checkbox_fallback_theme_clicked(self, use_fallback: bool): - constants.SETTINGS.setValue('use_fallback_theme', use_fallback) - if use_fallback: + def on_checkbox_confirm_close_dialog_clicked(self, checked: bool): + constants.SETTINGS.setValue("not_show_close_dialog", not checked) + + @pyqtSlot(int) + def on_combo_box_theme_index_changed(self, index: int): + constants.SETTINGS.setValue('theme_index', index) + if index > 0: QApplication.instance().setStyle(QStyleFactory.create("Fusion")) else: QApplication.instance().setStyle(constants.SETTINGS.value("default_theme", type=str)) - @pyqtSlot(bool) - def on_checkbox_confirm_close_dialog_clicked(self, checked: bool): - constants.SETTINGS.setValue("not_show_close_dialog", not checked) - @pyqtSlot(bool) def on_checkbox_hold_shift_to_drag_clicked(self, checked: bool): constants.SETTINGS.setValue("hold_shift_to_drag", checked) diff --git a/src/urh/main.py b/src/urh/main.py index fedbcff785..be7c2e792b 100755 --- a/src/urh/main.py +++ b/src/urh/main.py @@ -6,8 +6,8 @@ import os import sys -from PyQt5.QtCore import QTimer -from PyQt5.QtGui import QPalette, QIcon +from PyQt5.QtCore import QTimer, Qt +from PyQt5.QtGui import QPalette, QIcon, QColor from PyQt5.QtWidgets import QApplication, QWidget, QStyleFactory locale.setlocale(locale.LC_ALL, '') @@ -74,7 +74,7 @@ def main(): from urh.controller.MainController import MainController from urh import constants - if constants.SETTINGS.value("use_fallback_theme", False, bool): + if constants.SETTINGS.value("theme_index", 0, int) > 0: os.environ['QT_QPA_PLATFORMTHEME'] = 'fusion' app = QApplication(sys.argv) @@ -86,9 +86,32 @@ def main(): constants.SETTINGS.setValue("default_theme", app.style().objectName()) - if constants.SETTINGS.value("use_fallback_theme", False, bool): + if constants.SETTINGS.value("theme_index", 0, int) > 0: app.setStyle(QStyleFactory.create("Fusion")) + if constants.SETTINGS.value("theme_index", 0, int) == 2: + palette = QPalette() + background_color = QColor(56, 60, 74) + text_color = QColor(211, 218, 227).lighter() + palette.setColor(QPalette.Window, background_color) + palette.setColor(QPalette.WindowText, text_color) + palette.setColor(QPalette.Base, background_color) + palette.setColor(QPalette.AlternateBase, background_color) + palette.setColor(QPalette.ToolTipBase, background_color) + palette.setColor(QPalette.ToolTipText, text_color) + palette.setColor(QPalette.Text, text_color) + + palette.setColor(QPalette.Button, background_color) + palette.setColor(QPalette.ButtonText, text_color) + + palette.setColor(QPalette.BrightText, Qt.red) + palette.setColor(QPalette.Disabled, QPalette.Text, Qt.darkGray) + palette.setColor(QPalette.Disabled, QPalette.ButtonText, Qt.darkGray) + + palette.setColor(QPalette.Highlight, QColor(200, 50, 0)) + palette.setColor(QPalette.HighlightedText, text_color) + app.setPalette(palette) + main_window = MainController() if sys.platform == "darwin": diff --git a/src/urh/ui/ui_options.py b/src/urh/ui/ui_options.py index f2041ce893..a83806331a 100644 --- a/src/urh/ui/ui_options.py +++ b/src/urh/ui/ui_options.py @@ -130,9 +130,15 @@ def setupUi(self, DialogOptions): self.checkBoxAlignLabels = QtWidgets.QCheckBox(self.tabView) self.checkBoxAlignLabels.setObjectName("checkBoxAlignLabels") self.verticalLayout_4.addWidget(self.checkBoxAlignLabels) - self.checkBoxFallBackTheme = QtWidgets.QCheckBox(self.tabView) - self.checkBoxFallBackTheme.setObjectName("checkBoxFallBackTheme") - self.verticalLayout_4.addWidget(self.checkBoxFallBackTheme) + self.label_9 = QtWidgets.QLabel(self.tabView) + self.label_9.setObjectName("label_9") + self.verticalLayout_4.addWidget(self.label_9) + self.comboBoxTheme = QtWidgets.QComboBox(self.tabView) + self.comboBoxTheme.setObjectName("comboBoxTheme") + self.comboBoxTheme.addItem("") + self.comboBoxTheme.addItem("") + self.comboBoxTheme.addItem("") + self.verticalLayout_4.addWidget(self.comboBoxTheme) spacerItem2 = QtWidgets.QSpacerItem(20, 383, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) self.verticalLayout_4.addItem(spacerItem2) self.tabWidget.addTab(self.tabView, "") @@ -302,7 +308,7 @@ def setupUi(self, DialogOptions): self.verticalLayout_6.addWidget(self.tabWidget) self.retranslateUi(DialogOptions) - self.tabWidget.setCurrentIndex(5) + self.tabWidget.setCurrentIndex(2) QtCore.QMetaObject.connectSlotsByName(DialogOptions) def retranslateUi(self, DialogOptions): @@ -331,8 +337,10 @@ def retranslateUi(self, DialogOptions): self.checkBoxHoldShiftToDrag.setText(_translate("DialogOptions", "Hold shift to drag")) self.checkBoxPauseTime.setText(_translate("DialogOptions", "Show pauses as time")) self.checkBoxAlignLabels.setText(_translate("DialogOptions", "Align on labels")) - self.checkBoxFallBackTheme.setToolTip(_translate("DialogOptions", "Tick this option if you experience problems with you current Qt theme like no colors in table headers.")) - self.checkBoxFallBackTheme.setText(_translate("DialogOptions", "Use fallback application theme [RESTART REQUIRED]")) + self.label_9.setText(_translate("DialogOptions", "Choose application theme (requires restart):")) + self.comboBoxTheme.setItemText(0, _translate("DialogOptions", "native look (default)")) + self.comboBoxTheme.setItemText(1, _translate("DialogOptions", "fallback theme")) + self.comboBoxTheme.setItemText(2, _translate("DialogOptions", "fallback theme (dark)")) self.tabWidget.setTabText(self.tabWidget.indexOf(self.tabView), _translate("DialogOptions", "View")) self.btnAddLabelType.setText(_translate("DialogOptions", "...")) self.btnRemoveLabeltype.setText(_translate("DialogOptions", "...")) diff --git a/ui/options.ui b/ui/options.ui index a7c5518abc..dea7fe0b48 100644 --- a/ui/options.ui +++ b/ui/options.ui @@ -17,7 +17,7 @@ - 5 + 2 @@ -269,15 +269,31 @@ - - - Tick this option if you experience problems with you current Qt theme like no colors in table headers. - + - Use fallback application theme [RESTART REQUIRED] + Choose application theme (requires restart): + + + + + native look (default) + + + + + fallback theme + + + + + fallback theme (dark) + + + +