From 364d401b39d47cc0840613c87fa7d4858fe6229f Mon Sep 17 00:00:00 2001 From: Manu <3916435+m3nu@users.noreply.github.com> Date: Sat, 3 Oct 2020 14:27:31 +0800 Subject: [PATCH] Reuse existing window when bringing to front. (#674) --- src/vorta/application.py | 3 ++- tests/conftest.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/vorta/application.py b/src/vorta/application.py index eca9e7da..32ef8d77 100644 --- a/src/vorta/application.py +++ b/src/vorta/application.py @@ -88,7 +88,8 @@ class VortaApp(QtSingleApplication): self.backup_progress_event.emit(translate('messages', msg['message'])) def open_main_window_action(self): - self.main_window = MainWindow(self) + if not self._main_window_exists(): + self.main_window = MainWindow(self) self.main_window.show() self.main_window.raise_() diff --git a/tests/conftest.py b/tests/conftest.py index f462a420..475e7470 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -8,7 +8,7 @@ from unittest.mock import MagicMock import vorta from vorta.models import (RepoModel, RepoPassword, BackupProfileModel, SourceFileModel, SettingsModel, ArchiveModel, WifiSettingModel, EventLogModel, SchemaVersion) - +from vorta.views.main_window import MainWindow models = [RepoModel, RepoPassword, BackupProfileModel, SourceFileModel, SettingsModel, ArchiveModel, WifiSettingModel, EventLogModel, SchemaVersion] @@ -40,7 +40,7 @@ def init_db(qapp): source_dir = SourceFileModel(dir='/tmp/another', repo=new_repo) source_dir.save() - qapp.open_main_window_action() + qapp.main_window = MainWindow(qapp) # Re-open main window to apply mock data in UI @pytest.fixture(scope='session', autouse=True)