From 60c86e7cee8b3accd8c9654b9a5e60d76a406923 Mon Sep 17 00:00:00 2001 From: AL <26797547+Al12rs@users.noreply.github.com> Date: Sun, 16 Feb 2020 15:40:28 +0100 Subject: Move modInfo loadFromDisc to it's own function --- src/main.cpp | 1 + src/organizercore.cpp | 4 ++-- src/organizercore.h | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/main.cpp b/src/main.cpp index 2f4c80a1..b1b5c850 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -643,6 +643,7 @@ int runApplication(MOApplication &application, SingleInstance &instance, game->gameDirectory().absolutePath()); organizer.updateExecutablesList(); + organizer.updateModInfoFromDisc(); QString selectedProfileName = determineProfile(arguments, settings); organizer.setCurrentProfile(selectedProfileName); diff --git a/src/organizercore.cpp b/src/organizercore.cpp index c4f9e081..18c8bcd4 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -200,9 +200,9 @@ void OrganizerCore::updateExecutablesList() } m_ExecutablesList.load(managedGame(), m_Settings); +} - // TODO this has nothing to do with executables list move to an appropriate - // function! +void OrganizerCore::updateModInfoFromDisc() { ModInfo::updateFromDisc( m_Settings.paths().mods(), &m_DirectoryStructure, m_PluginContainer, m_Settings.interface().displayForeign(), managedGame()); diff --git a/src/organizercore.h b/src/organizercore.h index 4ee6ddc5..a63dc959 100644 --- a/src/organizercore.h +++ b/src/organizercore.h @@ -105,6 +105,7 @@ public: void setManagedGame(MOBase::IPluginGame *game); void updateExecutablesList(); + void updateModInfoFromDisc(); void checkForUpdates(); void startMOUpdate(); -- cgit v1.3.1 From c4059f0dfe636a137085e1cf86ffc13a3142c59a Mon Sep 17 00:00:00 2001 From: AL <26797547+Al12rs@users.noreply.github.com> Date: Sun, 16 Feb 2020 15:42:49 +0100 Subject: Avoid refreshing the profile again when initializing the pforilebox --- src/mainwindow.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index de1be9fe..d42eabac 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1659,6 +1659,15 @@ void MainWindow::on_profileBox_currentIndexChanged(int index) m_OrganizerCore.saveCurrentLists(); } + // Avoid doing any refresh if currentProfile is already set but previous index was -1 + // as it means that this is happening during initialization so everything has already been set. + if (previousIndex == -1 + && m_OrganizerCore.currentProfile() != nullptr + && m_OrganizerCore.currentProfile()->exists() + && ui->profileBox->currentText() == m_OrganizerCore.currentProfile()->name()){ + return; + } + // ensure the new index is valid if (index < 0 || index >= ui->profileBox->count()) { log::debug("invalid profile index, using last profile"); -- cgit v1.3.1 From e33d0f9d35fd8c97dfca413da9a927afd8196631 Mon Sep 17 00:00:00 2001 From: AL <26797547+Al12rs@users.noreply.github.com> Date: Sun, 16 Feb 2020 15:44:13 +0100 Subject: Avoid updating the downloadView when it hasn't even been initialized. --- src/mainwindow.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index d42eabac..8f2dd250 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -5291,6 +5291,10 @@ void MainWindow::initDownloadView() void MainWindow::updateDownloadView() { + // this means downlaodTab initialization hasnt happened yet + if (ui->downloadView->model() == nullptr) { + return; + } // set the view attribute and default row sizes if (m_OrganizerCore.settings().interface().compactDownloads()) { ui->downloadView->setProperty("downloadView", "compact"); -- cgit v1.3.1 From c02fbe89c7ecb65b39698a014b506be3fc77b853 Mon Sep 17 00:00:00 2001 From: AL <26797547+Al12rs@users.noreply.github.com> Date: Sun, 16 Feb 2020 15:49:35 +0100 Subject: Allow not refreshing downloads when setting their folder, for example during init. --- src/downloadmanager.cpp | 6 ++++-- src/downloadmanager.h | 2 +- src/organizercore.cpp | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp index 7b416d50..bbf2f79e 100644 --- a/src/downloadmanager.cpp +++ b/src/downloadmanager.cpp @@ -281,14 +281,16 @@ void DownloadManager::pauseAll() } -void DownloadManager::setOutputDirectory(const QString &outputDirectory) +void DownloadManager::setOutputDirectory(const QString &outputDirectory, const bool refresh) { QStringList directories = m_DirWatcher.directories(); if (directories.length() != 0) { m_DirWatcher.removePaths(directories); } m_OutputDirectory = QDir::fromNativeSeparators(outputDirectory); - refreshList(); + if (refresh) { + refreshList(); + } m_DirWatcher.addPath(m_OutputDirectory); } diff --git a/src/downloadmanager.h b/src/downloadmanager.h index 4fc61cad..d6342f22 100644 --- a/src/downloadmanager.h +++ b/src/downloadmanager.h @@ -158,7 +158,7 @@ public: * * @param outputDirectory the new output directory **/ - void setOutputDirectory(const QString &outputDirectory); + void setOutputDirectory(const QString &outputDirectory, const bool refresh = true); /** * @brief disables feedback from the downlods fileSystemWhatcher untill disableDownloadsWatcherEnd() is called diff --git a/src/organizercore.cpp b/src/organizercore.cpp index 18c8bcd4..12302df2 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -106,7 +106,7 @@ OrganizerCore::OrganizerCore(Settings &settings) , m_ArchivesInit(false) , m_PluginListsWriter(std::bind(&OrganizerCore::savePluginList, this)) { - m_DownloadManager.setOutputDirectory(m_Settings.paths().downloads()); + m_DownloadManager.setOutputDirectory(m_Settings.paths().downloads(), false); NexusInterface::instance(m_PluginContainer)->setCacheDirectory( m_Settings.paths().cache()); -- cgit v1.3.1 From edc7f3d5b26c3e087308f518f4c7c6e3a6115e4a Mon Sep 17 00:00:00 2001 From: AL <26797547+Al12rs@users.noreply.github.com> Date: Sun, 16 Feb 2020 15:50:51 +0100 Subject: Avoid refreshing when setting downloads supported extensions as it only happens during init. --- src/downloadmanager.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp index bbf2f79e..4c4adcec 100644 --- a/src/downloadmanager.cpp +++ b/src/downloadmanager.cpp @@ -298,7 +298,9 @@ void DownloadManager::setOutputDirectory(const QString &outputDirectory, const b void DownloadManager::setSupportedExtensions(const QStringList &extensions) { m_SupportedExtensions = extensions; - refreshList(); + // this happens only during initialization so don't refresh yet as the refresh will + // later during initDownloadView + //refreshList(); } void DownloadManager::setShowHidden(bool showHidden) -- cgit v1.3.1 From 29b331817c5aecea3870d4a57694e46950ae362c Mon Sep 17 00:00:00 2001 From: AL <26797547+Al12rs@users.noreply.github.com> Date: Mon, 17 Feb 2020 02:11:42 +0100 Subject: Remove duplicated updateFromDisc() call during refresh comment mentioned that it was needed but it was very old and testing would suggest this is no longer the case. --- src/organizercore.cpp | 8 -------- 1 file changed, 8 deletions(-) (limited to 'src') diff --git a/src/organizercore.cpp b/src/organizercore.cpp index 12302df2..04d78ca8 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -1426,14 +1426,6 @@ void OrganizerCore::directory_refreshed() void OrganizerCore::profileRefresh() { - // have to refresh mods twice (again in refreshModList), otherwise the refresh - // isn't complete. Not sure why - ModInfo::updateFromDisc( - m_Settings.paths().mods(), &m_DirectoryStructure, - m_PluginContainer, m_Settings.interface().displayForeign(), managedGame()); - - m_CurrentProfile->refreshModStatus(); - refreshModList(); } -- cgit v1.3.1 From 112f91357e20b4a1638b6deeff1c71dfea66eb72 Mon Sep 17 00:00:00 2001 From: AL <26797547+Al12rs@users.noreply.github.com> Date: Mon, 17 Feb 2020 02:34:56 +0100 Subject: Reduce overhead introduced by splashscreen by not letting it wait on the mainwindow and instead immediately close --- src/main.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/main.cpp b/src/main.cpp index b1b5c850..e9c1acd8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -734,14 +734,13 @@ int runApplication(MOApplication &application, SingleInstance &instance, QObject::connect(&instance, SIGNAL(messageSent(QString)), &organizer, SLOT(externalMessage(QString))); - // this must be before readSettings(), see DockFixer in mainwindow.cpp - splash.finish(&mainWindow); - log::debug("displaying main window"); mainWindow.show(); mainWindow.activateWindow(); - splash.finish(&mainWindow); + // don't pass mainwindow as it just waits half a second for it + // instead of proceding + splash.finish(nullptr); res = application.exec(); mainWindow.close(); -- cgit v1.3.1 From 5043a930cedd67d8d9fde67462373ea181c30a08 Mon Sep 17 00:00:00 2001 From: AL <26797547+Al12rs@users.noreply.github.com> Date: Mon, 17 Feb 2020 03:26:47 +0100 Subject: Add setting to disable splash since it can cause load time increase use_spash=true by default. It's not exposed to the ui for now. --- src/main.cpp | 42 +++++++++++++++++++++++++++--------------- src/settings.cpp | 10 ++++++++++ src/settings.h | 4 ++++ 3 files changed, 41 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/main.cpp b/src/main.cpp index e9c1acd8..4b291e75 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -596,13 +596,17 @@ int runApplication(MOApplication &application, SingleInstance &instance, checkPathsForSanity(*game, settings); - if (splashPath.startsWith(':')) { - // currently using MO splash, see if the plugin contains one - QString pluginSplash + bool useSplash = settings.useSplash(); + + if (useSplash) { + if (splashPath.startsWith(':')) { + // currently using MO splash, see if the plugin contains one + QString pluginSplash = QString(":/%1/splash").arg(game->gameShortName()); - QImage image(pluginSplash); - if (!image.isNull()) { - image.save(dataPath + "/splash.png"); + QImage image(pluginSplash); + if (!image.isNull()) { + image.save(dataPath + "/splash.png"); + } } } @@ -697,12 +701,18 @@ int runApplication(MOApplication &application, SingleInstance &instance, } } - QPixmap pixmap(splashPath); - QSplashScreen splash(pixmap); + QPixmap pixmap; + + QSplashScreen splash(nullptr); + + if (useSplash) { + pixmap = QPixmap(splashPath); + splash.setPixmap(pixmap); - settings.geometry().centerOnMainWindowMonitor(&splash); - splash.show(); - splash.activateWindow(); + settings.geometry().centerOnMainWindowMonitor(&splash); + splash.show(); + splash.activateWindow(); + } QString apiKey; if (settings.nexus().apiKey(apiKey)) { @@ -737,10 +747,12 @@ int runApplication(MOApplication &application, SingleInstance &instance, log::debug("displaying main window"); mainWindow.show(); mainWindow.activateWindow(); - - // don't pass mainwindow as it just waits half a second for it - // instead of proceding - splash.finish(nullptr); + + if (useSplash) { + // don't pass mainwindow as it just waits half a second for it + // instead of proceding + splash.finish(nullptr); + } res = application.exec(); mainWindow.close(); diff --git a/src/settings.cpp b/src/settings.cpp index eff68aca..4431e7d9 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -199,6 +199,16 @@ void Settings::setUsePrereleases(bool b) set(m_Settings, "Settings", "use_prereleases", b); } +bool Settings::useSplash() const +{ + return get(m_Settings, "Settings", "use_splash", true); +} + +void Settings::setUseSplash(bool b) +{ + set(m_Settings, "Settings", "use_splash", b); +} + std::optional Settings::version() const { if (auto v=getOptional(m_Settings, "General", "version")) { diff --git a/src/settings.h b/src/settings.h index 0e5238b1..678226c1 100644 --- a/src/settings.h +++ b/src/settings.h @@ -720,6 +720,10 @@ public: bool usePrereleases() const; void setUsePrereleases(bool b); + // whether to use spascreen or not + // + bool useSplash() const; + void setUseSplash(bool b); GameSettings& game(); const GameSettings& game() const; -- cgit v1.3.1 From 8e3ab9fb6614e93239662cab8b0bb726285a255e Mon Sep 17 00:00:00 2001 From: AL <26797547+Al12rs@users.noreply.github.com> Date: Mon, 17 Feb 2020 11:00:27 +0100 Subject: Cleanup commented code --- src/downloadmanager.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp index 4c4adcec..270a7222 100644 --- a/src/downloadmanager.cpp +++ b/src/downloadmanager.cpp @@ -298,9 +298,8 @@ void DownloadManager::setOutputDirectory(const QString &outputDirectory, const b void DownloadManager::setSupportedExtensions(const QStringList &extensions) { m_SupportedExtensions = extensions; - // this happens only during initialization so don't refresh yet as the refresh will - // later during initDownloadView - //refreshList(); + // this happens only during initialization so don't refresh yet as that will + // happen later during initDownloadView } void DownloadManager::setShowHidden(bool showHidden) -- cgit v1.3.1