Skip to content
Snippets Groups Projects
Commit d2b76693 authored by Andreas Bolin's avatar Andreas Bolin
Browse files

Fixed bug with QSettings on PySide2

parent 4048bc1d
No related branches found
No related tags found
1 merge request!78Add scheduler GUI
Pipeline #72852 passed
......@@ -77,8 +77,6 @@ if __debug__:
uic.compileUiDir('.', map=(lambda dir,file: (dir, 'ui_' + file)))
except:
try: # PySide2, try manual compile
print("fail!")
exit(1)
import subprocess
os_ = sys.platform
if os_.startswith('linux'):
......@@ -120,9 +118,9 @@ class MainWindow(QMainWindow, Ui_MainWindow):
super(MainWindow, self).__init__()
self._schedules = {}
self._schedule_id = 0
#QIcon.setThemeSearchPaths(':/resources')
QIcon.setThemeName('breeze')
pprint(QIcon.themeSearchPaths())
log.debug('themeName: \'{}\''.format(QIcon.themeName()))
log.debug('themeSearchPaths: {}'.format(QIcon.themeSearchPaths()))
self._init_ui()
self._init_graphics_view()
self._read_settings()
......@@ -295,7 +293,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
buttons: list[QAbstractButton] = box.buttons()
buttons[0].setText(self.tr('&Exit'))
buttons[1].setText(self.tr('&Cancel'))
checkbox = QCheckBox(self.tr('Don\'t ask again'))
checkbox = QCheckBox(self.tr('&Don\'t ask again'))
box.setCheckBox(checkbox)
ret = box.exec_()
......@@ -328,7 +326,9 @@ class MainWindow(QMainWindow, Ui_MainWindow):
def _write_settings(self) -> None:
"""Write settings from MainWindow to Settings."""
s = QSettings()
s.setValue('mainwindow/geometry', self.saveGeometry()) # window: pos, size
s.setValue('mainwindow/maximized', self.isMaximized()) # window: maximized, in X11 - alwas False
s.setValue('mainwindow/pos', self.pos()) # window: pos
s.setValue('mainwindow/size', self.size()) # window: size
s.setValue('mainwindow/state', self.saveState()) # toolbars, dockwidgets: pos, size
s.setValue('mainwindow/menu/node_info', self.menu_node_info.isChecked())
s.setValue('mainwindow/splitter/state', self.splitter_center.saveState())
......@@ -341,10 +341,14 @@ class MainWindow(QMainWindow, Ui_MainWindow):
def _read_settings(self) -> None:
"""Read settings from Settings to MainWindow."""
s = QSettings()
self.restoreGeometry( s.value('mainwindow/geometry', type=QByteArray))
self.restoreState( s.value('mainwindow/state', type=QByteArray))
self.menu_node_info.setChecked( s.value('mainwindow/menu/node_info', True, type=bool))
self.splitter_center.restoreState( s.value('mainwindow/splitter/state', type=QByteArray))
if s.value('mainwindow/maximized', defaultValue=False, type=bool):
self.showMaximized()
else:
self.move( s.value('mainwindow/pos', defaultValue=self.pos()))
self.resize( s.value('mainwindow/size', defaultValue=self.size()))
self.restoreState( s.value('mainwindow/state', defaultValue=QByteArray()))
self.menu_node_info.setChecked( s.value('mainwindow/menu/node_info', defaultValue=True, type=bool))
self.splitter_center.restoreState( s.value('mainwindow/splitter/state', defaultValue=QByteArray()))
log.debug('Settings read from \'{}\'.'.format(s.fileName()))
......
......@@ -76,7 +76,7 @@
<x>0</x>
<y>0</y>
<width>800</width>
<height>22</height>
<height>20</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
......@@ -166,7 +166,8 @@
</widget>
<action name="menu_load_from_file">
<property name="icon">
<iconset theme="document-open-folder"/>
<iconset theme="document-open-folder">
<normaloff>.</normaloff>.</iconset>
</property>
<property name="text">
<string>&amp;Load Schedule From File...</string>
......@@ -183,7 +184,8 @@
</action>
<action name="menu_save">
<property name="icon">
<iconset theme="document-save"/>
<iconset theme="document-save">
<normaloff>.</normaloff>.</iconset>
</property>
<property name="text">
<string>&amp;Save</string>
......@@ -202,9 +204,6 @@
<property name="checked">
<bool>true</bool>
</property>
<property name="icon">
<iconset theme="application-menu"/>
</property>
<property name="text">
<string>&amp;Node Info</string>
</property>
......@@ -217,7 +216,8 @@
</action>
<action name="menu_quit">
<property name="icon">
<iconset theme="application-exit"/>
<iconset theme="application-exit">
<normaloff>.</normaloff>.</iconset>
</property>
<property name="text">
<string>&amp;Quit</string>
......@@ -228,7 +228,8 @@
</action>
<action name="menu_save_as">
<property name="icon">
<iconset theme="document-save-as"/>
<iconset theme="document-save-as">
<normaloff>.</normaloff>.</iconset>
</property>
<property name="text">
<string>Save &amp;As...</string>
......
......@@ -139,6 +139,5 @@
<file>icons/breeze/status/22@2x/dialog-error.svg</file>
<file>icons/breeze/status/22@3x/dialog-error.svg</file>
<file>icons/breeze/status/64/dialog-error.svg</file>
<file>icons/breeze/status/48/dialog-warning.svg</file>
</qresource>
</RCC>
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment