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