Skip to content

Commit

Permalink
add dark theme for #240
Browse files Browse the repository at this point in the history
  • Loading branch information
jopohl committed Apr 16, 2017
1 parent 4c58df5 commit 285690f
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 26 deletions.
19 changes: 9 additions & 10 deletions src/urh/controller/OptionsController.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
31 changes: 27 additions & 4 deletions src/urh/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, '')
Expand Down Expand Up @@ -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)
Expand All @@ -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":
Expand Down
20 changes: 14 additions & 6 deletions src/urh/ui/ui_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, "")
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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", "..."))
Expand Down
28 changes: 22 additions & 6 deletions ui/options.ui
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>5</number>
<number>2</number>
</property>
<widget class="QWidget" name="tabInterpretation">
<attribute name="title">
Expand Down Expand Up @@ -269,15 +269,31 @@
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBoxFallBackTheme">
<property name="toolTip">
<string>Tick this option if you experience problems with you current Qt theme like no colors in table headers.</string>
</property>
<widget class="QLabel" name="label_9">
<property name="text">
<string>Use fallback application theme [RESTART REQUIRED]</string>
<string>Choose application theme (requires restart):</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBoxTheme">
<item>
<property name="text">
<string>native look (default)</string>
</property>
</item>
<item>
<property name="text">
<string>fallback theme</string>
</property>
</item>
<item>
<property name="text">
<string>fallback theme (dark)</string>
</property>
</item>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
Expand Down

0 comments on commit 285690f

Please sign in to comment.