-
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
Conversation
I am also finding that it gets stuck in dark mode. Not quite sure, but might be to do with the dark mode check box being Also wondering if |
On IDAaaS you can use xfce4-appearance-settings to change font sizes |
Printing out the typings used in
gives:
so using Do you know the steps to reproduce getting stuck in dark mode on Linux as I cant seem to reproduce it in Windows. |
Steps to reproduce on linux. This might be because the qsettings in linux are in ini/toml format, so don't have a type and are treated as strings by default. |
Checking the settings type in linux I get:
so looks like it would be a better idea to store the settings as strictly strings to be consistent in Linux and Windows, good catch! |
9dcf0fd
to
8935817
Compare
The default font family and size are found via QFont and then stored in QSettings. For Windows, this is "MS Shell Dlg 2" and font size 12. Once the font size is changed in the settings, the default size is overridden. May be an idea to employ a "Return to defaults" button in the future. Current QSettings are: They are stored in |
mantidimaging/main.py
Outdated
if theme_selection: | ||
q_application.setStyle(settings.value('theme_selection')) | ||
|
||
default_font = QFont('-1') |
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.
For me on linux I needed to change this to just default_font = QFont()
to get the OS value. With the -1
it will always give 12, Noto Sans.
QFontInfo(QFont('-1')).pointSize()=12
QFontInfo(QFont('-1')).family()='Noto Sans'
QFontInfo(QFont()).pointSize()=14
QFontInfo(QFont()).family()='Times New Roman'
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.
Using QFont() on windows gives the default pointsize as 8, even when the scalling is changed and the Main Window looks like this:
(mantidimaging-dev) C:\Users\ddb29996\mantidimaging>python -m mantidimaging
default_font_info.pointSize: 8
default_font_info.family: MS Shell Dlg 2
It seems like grabbing the default font is something that is only useful for Linux as the scaling options in windows seem to take care of it
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.
I'm happy for the check to only be on linux. One last thing to try is getting it from a widget.
QWidget().font().pointSize()
QWidget().font().family()
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.
Could some of the logic be made simpler if there was a "Use system theme" check box.
This could be a solution because the Using a "Use system theme" check box which is checked on first startup and then forces the defaults to be used would simplify things |
In Windows, setting the monitor to a scaling of 100% (with 250% recommended) leads to
Setting the same monitor to 400% leads to:
where the font size is the same relative to the text in other programs on that monitor. |
So I guess use default_font_info to get the system font on linux only |
I think its fine to use on both Windows and Linux, Windows seems to handle the fonts well as it interacts with the scaling well. It looks like it just uses the font size as one relative to the scaling rather than an "absolute" font size |
c469837
to
1de82ae
Compare
1de82ae
to
21fdbc3
Compare
Testing on Linux
The OS font is now being displayed correctly on Linux |
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.
This is working much better now. Just a couple of small code issues, and the performance tab.
I see some sizing issues if I use the material theme. And there seems to be case where some text in the image views does not adjust. But happy to merge once commented issues are done, and deal with these later.
settings = QtCore.QSettings('mantidproject', 'Mantid Imaging') | ||
|
||
if not settings.contains("theme_selection") or settings.value("theme_selection") is None: | ||
settings.setValue('theme_selection', 'Fusion') |
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
.
</layout> | ||
</widget> | ||
</widget> | ||
<widget class="QWidget" name="performanceTab"> |
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.
The performance tabs seems to have snuck into this PR.
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.
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
settings = QSettings('mantidproject', 'Mantid Imaging') | ||
|
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.
I don't think this is used
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.
settings
is used in do_update_UI()
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')
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.
Sorry, I put the comment in the wrong place, should have been in view.py
line 58. I think that one is not used
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.
Yes you're right, thats a remnant of me refactoring some things from the view to the presenter
Yes there are some positioning and sizing issues when using the qt_material themes but to fix this would take some modification of the themes style sheets which may take some time. I think it would be best to note that these themes are "experimental" and come back to it at a later PR |
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.
Thanks
Issue
closes #2143 and #2099.
Description
A Settings menu has been added via File -> Settings in the Main Window. Clicking on the Settings option opens up a new window where more settings can be added in the future. There is an option to change the current theme of the program to the standard "Fusion" theme or one of the many
qt-material
themes. By changing the theme, all windows of MI will be updated to the new theme during Runtime so the user can see them in real time. The new settings are saved viaQSettings
and are checked on startup so once changed to the users liking, it does not need to be changed again!If "Fusion" is the chosen theme, then a dark mode can be activated by clicking on the "dark mode" checkbox. This checkbox is disabled if any of the
qt-material
themes are chosen as light/dark is specified in the names of theqt-material
themes.Future work can be done via
qt-material
to make more custom themes chosen be the user.Testing
make check
Acceptance Criteria
Theme Testing
To simulate a "first time start-up", you need to run
QSettings.clear()
with the appropriate arguments before starting MI. For example you could addsettings.clear()
on line 51 ofmantidimaging/gui/windows/main/presenter.py
, then start MI. This will cause MI to crash on startup but this is good enough to just clear all QSettings for MI. You can then remove thesettings.clear()
line and start MI as usual.Font Testing
OS Theme check
Documentation
Will add release note!