-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added Settings menu to Main Window with Theme options #2144
Changes from 18 commits
ac10be4
5fd9e4f
b273e9b
1cf26c5
6858cfd
bcd2064
fa10f23
f51c7e5
4235c4f
e2591ee
313df52
c5030eb
4072aa7
1c11c49
21fdbc3
e7ea985
050079b
056df53
44467f5
884cec4
764091e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#2144: MI UI theme can be changed in runtime via a settings menu |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,197 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ui version="4.0"> | ||
<class>SettingsWindow</class> | ||
<widget class="QMainWindow" name="SettingsWindow"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>454</width> | ||
<height>444</height> | ||
</rect> | ||
</property> | ||
<property name="maximumSize"> | ||
<size> | ||
<width>456</width> | ||
<height>449</height> | ||
</size> | ||
</property> | ||
<property name="windowTitle"> | ||
<string>MainWindow</string> | ||
</property> | ||
<widget class="QWidget" name="centralwidget"> | ||
<property name="sizePolicy"> | ||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding"> | ||
<horstretch>0</horstretch> | ||
<verstretch>0</verstretch> | ||
</sizepolicy> | ||
</property> | ||
<widget class="QWidget" name="verticalWidget" native="true"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>10</x> | ||
<y>10</y> | ||
<width>1921</width> | ||
<height>951</height> | ||
</rect> | ||
</property> | ||
<property name="sizePolicy"> | ||
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding"> | ||
<horstretch>1</horstretch> | ||
<verstretch>1</verstretch> | ||
</sizepolicy> | ||
</property> | ||
<layout class="QVBoxLayout" name="verticalLayout_2"> | ||
<item> | ||
<widget class="QTabWidget" name="settingsTabWidget"> | ||
<property name="sizePolicy"> | ||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding"> | ||
<horstretch>1</horstretch> | ||
<verstretch>1</verstretch> | ||
</sizepolicy> | ||
</property> | ||
<property name="currentIndex"> | ||
<number>0</number> | ||
</property> | ||
<widget class="QWidget" name="appearanceTab"> | ||
<attribute name="title"> | ||
<string>Appearance</string> | ||
</attribute> | ||
<widget class="QWidget" name="formLayoutWidget"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>10</x> | ||
<y>10</y> | ||
<width>411</width> | ||
<height>361</height> | ||
</rect> | ||
</property> | ||
<layout class="QFormLayout" name="formLayout"> | ||
<item row="0" column="0"> | ||
<widget class="QLabel" name="themeLabel"> | ||
<property name="text"> | ||
<string>Theme:</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="0" column="1"> | ||
<widget class="QComboBox" name="themeName"> | ||
<property name="sizePolicy"> | ||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed"> | ||
<horstretch>0</horstretch> | ||
<verstretch>0</verstretch> | ||
</sizepolicy> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="1" column="0"> | ||
<widget class="QLabel" name="menuFontSizeLabel"> | ||
<property name="text"> | ||
<string>Menu font size:</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="1" column="1"> | ||
<widget class="QComboBox" name="menuFontSizeChoice"> | ||
<property name="sizePolicy"> | ||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed"> | ||
<horstretch>0</horstretch> | ||
<verstretch>0</verstretch> | ||
</sizepolicy> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="2" column="0"> | ||
<widget class="QLabel" name="useOsThemeLabel"> | ||
<property name="text"> | ||
<string>Dark mode:</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="2" column="1"> | ||
<widget class="QCheckBox" name="darkModeCheckBox"> | ||
<property name="text"> | ||
<string/> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="3" column="0"> | ||
<widget class="QLabel" name="label"> | ||
<property name="text"> | ||
<string>Use OS defaults: </string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="3" column="1"> | ||
<widget class="QCheckBox" name="osDefaultsCheckBox"> | ||
<property name="text"> | ||
<string/> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="4" column="0" colspan="2"> | ||
<spacer name="verticalSpacer"> | ||
<property name="orientation"> | ||
<enum>Qt::Vertical</enum> | ||
</property> | ||
<property name="sizeHint" stdset="0"> | ||
<size> | ||
<width>20</width> | ||
<height>40</height> | ||
</size> | ||
</property> | ||
</spacer> | ||
</item> | ||
</layout> | ||
</widget> | ||
</widget> | ||
<widget class="QWidget" name="performanceTab"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The performance tabs seems to have snuck into this PR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this happened because I had the .ui file open in QT Designer and it didnt switch properly when changing between the two branches, i'll fix it now |
||
<attribute name="title"> | ||
<string>Performance</string> | ||
</attribute> | ||
<widget class="QWidget" name="formLayoutWidget_2"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>10</x> | ||
<y>10</y> | ||
<width>411</width> | ||
<height>361</height> | ||
</rect> | ||
</property> | ||
<layout class="QFormLayout" name="formLayout_2"> | ||
<item row="0" column="0"> | ||
<widget class="QLabel" name="processesLabel"> | ||
<property name="text"> | ||
<string>Processes (applies on restart): </string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="0" column="1"> | ||
<widget class="QSpinBox" name="processesSpinBox"/> | ||
</item> | ||
<item row="1" column="1"> | ||
<spacer name="verticalSpacer_2"> | ||
<property name="orientation"> | ||
<enum>Qt::Vertical</enum> | ||
</property> | ||
<property name="sizeHint" stdset="0"> | ||
<size> | ||
<width>20</width> | ||
<height>40</height> | ||
</size> | ||
</property> | ||
</spacer> | ||
</item> | ||
</layout> | ||
</widget> | ||
</widget> | ||
</widget> | ||
</item> | ||
</layout> | ||
</widget> | ||
</widget> | ||
<widget class="QStatusBar" name="statusbar"/> | ||
</widget> | ||
<resources/> | ||
<connections/> | ||
</ui> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,10 @@ | |
from collections.abc import Iterable | ||
|
||
import numpy as np | ||
from PyQt5.QtCore import QSettings, Qt | ||
from PyQt5.QtGui import QFont, QPalette, QColor | ||
from PyQt5.QtWidgets import QTabBar, QApplication, QTreeWidgetItem | ||
from qt_material import apply_stylesheet | ||
|
||
from mantidimaging.core.data import ImageStack | ||
from mantidimaging.core.data.dataset import StrictDataset, MixedDataset, _get_stack_data_type | ||
|
@@ -29,6 +32,8 @@ | |
|
||
RECON_TEXT = "Recon" | ||
|
||
settings = QSettings('mantidproject', 'Mantid Imaging') | ||
|
||
Comment on lines
+35
to
+36
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this is used There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, I put the comment in the wrong place, should have been in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes you're right, thats a remnant of me refactoring some things from the view to the presenter |
||
|
||
class StackId(NamedTuple): | ||
id: uuid.UUID | ||
|
@@ -828,3 +833,61 @@ def _create_strict_dataset_stack_name(stack_type: str, dataset_name: str) -> str | |
|
||
def is_dataset_strict(self, ds_id: uuid.UUID) -> bool: | ||
return self.model.is_dataset_strict(ds_id) | ||
|
||
def do_update_UI(self) -> None: | ||
if settings.value('use_os_defaults', defaultValue='True') == 'True': | ||
extra_style = settings.value('extra_style_default') | ||
theme = 'Fusion' | ||
override_os_theme = 'False' | ||
else: | ||
extra_style = settings.value('extra_style') | ||
use_dark_mode = settings.value('use_dark_mode') | ||
theme = settings.value('theme_selection') | ||
override_os_theme = settings.value('override_os_theme') | ||
os_theme = settings.value('os_theme') | ||
font = QFont(settings.value('default_font_family'), int(extra_style['font_size'].replace('px', ''))) | ||
for window in [ | ||
self.view, self.view.recon, self.view.live_viewer, self.view.spectrum_viewer, self.view.filters, | ||
self.view.settings_window | ||
]: | ||
if window: | ||
QApplication.instance().setFont(font) | ||
window.setStyleSheet(theme) | ||
if theme == 'Fusion': | ||
if override_os_theme == 'False': | ||
if os_theme == 'Light': | ||
self.use_fusion_light_mode() | ||
elif os_theme == 'Dark': | ||
self.use_fusion_dark_mode() | ||
else: | ||
if use_dark_mode == 'True': | ||
self.use_fusion_dark_mode() | ||
else: | ||
self.use_fusion_light_mode() | ||
QApplication.instance().setFont(font) | ||
window.setStyleSheet(theme) | ||
else: | ||
apply_stylesheet(window, theme=theme, invert_secondary=False, extra=extra_style) | ||
|
||
@staticmethod | ||
def use_fusion_dark_mode() -> None: | ||
palette = QPalette() | ||
palette.setColor(QPalette.Window, QColor(53, 53, 53)) | ||
palette.setColor(QPalette.WindowText, Qt.white) | ||
palette.setColor(QPalette.Base, QColor(25, 25, 25)) | ||
palette.setColor(QPalette.AlternateBase, QColor(53, 53, 53)) | ||
palette.setColor(QPalette.ToolTipBase, Qt.black) | ||
palette.setColor(QPalette.ToolTipText, Qt.white) | ||
palette.setColor(QPalette.Text, Qt.white) | ||
palette.setColor(QPalette.Button, QColor(53, 53, 53)) | ||
palette.setColor(QPalette.ButtonText, Qt.white) | ||
palette.setColor(QPalette.BrightText, Qt.red) | ||
palette.setColor(QPalette.Link, QColor(42, 130, 218)) | ||
palette.setColor(QPalette.Highlight, QColor(42, 130, 218)) | ||
palette.setColor(QPalette.HighlightedText, Qt.black) | ||
QApplication.instance().setPalette(palette) | ||
|
||
@staticmethod | ||
def use_fusion_light_mode() -> None: | ||
palette = QPalette() | ||
QApplication.instance().setPalette(palette) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to be here, there is similar code in
mantidimaging/main.py
.