diff --git a/spinetoolbox/ui_main.py b/spinetoolbox/ui_main.py index e0dd5d114..42eb210c8 100644 --- a/spinetoolbox/ui_main.py +++ b/spinetoolbox/ui_main.py @@ -44,6 +44,7 @@ QMenu, QMessageBox, QScrollArea, + QStyleFactory, QToolButton, QVBoxLayout, QWidget, @@ -128,6 +129,7 @@ def __init__(self): from .ui.mainwindow import Ui_MainWindow # pylint: disable=import-outside-toplevel super().__init__(flags=Qt.Window) + self.set_app_style() self.set_error_mode() self._qsettings = QSettings("SpineProject", "Spine Toolbox", self) self._update_qsettings() @@ -315,6 +317,14 @@ def connect_signals(self): self.kernel_shutdown.connect(self._handle_kernel_shutdown) self.persistent_console_requested.connect(self._setup_persistent_console, Qt.BlockingQueuedConnection) + @staticmethod + def set_app_style(): + """Sets app style on Windows to 'windowsvista' or to a default if not available.""" + if sys.platform == "win32": + if "windowsvista" not in QStyleFactory.keys(): + return + QApplication.setStyle("windowsvista") + @staticmethod def set_error_mode(): """Sets Windows error mode to show all error dialog boxes from subprocesses. diff --git a/tests/mock_helpers.py b/tests/mock_helpers.py index c7c991487..e81edc73b 100644 --- a/tests/mock_helpers.py +++ b/tests/mock_helpers.py @@ -22,10 +22,13 @@ def create_toolboxui(): """Returns ToolboxUI, where QSettings among others has been mocked.""" - with mock.patch("spinetoolbox.plugin_manager.PluginManager.load_installed_plugins"), mock.patch( - "spinetoolbox.ui_main.QSettings.value" - ) as mock_qsettings_value: + with mock.patch( + "spinetoolbox.ui_main.QSettings.value") as mock_qsettings_value, mock.patch( + "spinetoolbox.ui_main.ToolboxUI.set_app_style") as mock_set_app_style, mock.patch( + "spinetoolbox.plugin_manager.PluginManager.load_installed_plugins" + ): mock_qsettings_value.side_effect = qsettings_value_side_effect + mock_set_app_style.return_value = True toolbox = ToolboxUI() return toolbox @@ -41,16 +44,15 @@ def create_project(toolbox, project_dir): def create_toolboxui_with_project(project_dir): """Returns ToolboxUI with a project instance where QSettings among others has been mocked.""" - with mock.patch("spinetoolbox.ui_main.ToolboxUI.save_project"), mock.patch( - "spinetoolbox.ui_main.QSettings.value" - ) as mock_qsettings_value, mock.patch("spinetoolbox.ui_main.QSettings.setValue"), mock.patch( - "spinetoolbox.ui_main.QSettings.sync" - ), mock.patch( - "spinetoolbox.plugin_manager.PluginManager.load_installed_plugins" - ), mock.patch( - "spinetoolbox.ui_main.QScrollArea.setWidget" - ): + with mock.patch("spinetoolbox.ui_main.QSettings.value") as mock_qsettings_value, mock.patch( + "spinetoolbox.ui_main.ToolboxUI.set_app_style") as mock_set_app_style, mock.patch( + "spinetoolbox.ui_main.ToolboxUI.save_project"), mock.patch( + "spinetoolbox.ui_main.QSettings.setValue"), mock.patch( + "spinetoolbox.ui_main.QSettings.sync"), mock.patch( + "spinetoolbox.plugin_manager.PluginManager.load_installed_plugins"), mock.patch( + "spinetoolbox.ui_main.QScrollArea.setWidget"): mock_qsettings_value.side_effect = qsettings_value_side_effect + mock_set_app_style.return_value = True toolbox = ToolboxUI() toolbox.create_project(project_dir) return toolbox