diff options
| author | isanae <14251494+isanae@users.noreply.github.com> | 2020-02-18 17:22:29 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-02-18 17:22:29 -0500 |
| commit | 8c2814c9dc0d92e1ab015cde33eee8dcf880e265 (patch) | |
| tree | 19b00758324fac115b466c51c3fe6f17ccd42375 | |
| parent | cfb05d72be19ce0413f1de776eb3b2c150807e83 (diff) | |
| parent | 8e3ab9fb6614e93239662cab8b0bb726285a255e (diff) | |
Merge pull request #1000 from Al12rs/startup_performance
Startup performance
| -rw-r--r-- | src/downloadmanager.cpp | 9 | ||||
| -rw-r--r-- | src/downloadmanager.h | 2 | ||||
| -rw-r--r-- | src/main.cpp | 44 | ||||
| -rw-r--r-- | src/mainwindow.cpp | 13 | ||||
| -rw-r--r-- | src/organizercore.cpp | 14 | ||||
| -rw-r--r-- | src/organizercore.h | 1 | ||||
| -rw-r--r-- | src/settings.cpp | 10 | ||||
| -rw-r--r-- | src/settings.h | 4 |
8 files changed, 66 insertions, 31 deletions
diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp index 1fc7e184..a93182b4 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); } @@ -296,7 +298,8 @@ void DownloadManager::setOutputDirectory(const QString &outputDirectory) void DownloadManager::setSupportedExtensions(const QStringList &extensions) { m_SupportedExtensions = extensions; - refreshList(); + // this happens only during initialization so don't refresh yet as that will + // happen later during initDownloadView } void DownloadManager::setShowHidden(bool showHidden) diff --git a/src/downloadmanager.h b/src/downloadmanager.h index 140970b8..c837f006 100644 --- a/src/downloadmanager.h +++ b/src/downloadmanager.h @@ -159,7 +159,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/main.cpp b/src/main.cpp index 2f4c80a1..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"); + } } } @@ -643,6 +647,7 @@ int runApplication(MOApplication &application, SingleInstance &instance, game->gameDirectory().absolutePath()); organizer.updateExecutablesList(); + organizer.updateModInfoFromDisc(); QString selectedProfileName = determineProfile(arguments, settings); organizer.setCurrentProfile(selectedProfileName); @@ -696,12 +701,18 @@ int runApplication(MOApplication &application, SingleInstance &instance, } } - QPixmap pixmap(splashPath); - QSplashScreen splash(pixmap); + QPixmap pixmap; + + QSplashScreen splash(nullptr); - settings.geometry().centerOnMainWindowMonitor(&splash); - splash.show(); - splash.activateWindow(); + if (useSplash) { + pixmap = QPixmap(splashPath); + splash.setPixmap(pixmap); + + settings.geometry().centerOnMainWindowMonitor(&splash); + splash.show(); + splash.activateWindow(); + } QString apiKey; if (settings.nexus().apiKey(apiKey)) { @@ -733,14 +744,15 @@ 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); + + 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/mainwindow.cpp b/src/mainwindow.cpp index de1be9fe..8f2dd250 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"); @@ -5282,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"); diff --git a/src/organizercore.cpp b/src/organizercore.cpp index c4f9e081..04d78ca8 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()); @@ -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()); @@ -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(); } 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();
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<bool>(m_Settings, "Settings", "use_splash", true); +} + +void Settings::setUseSplash(bool b) +{ + set(m_Settings, "Settings", "use_splash", b); +} + std::optional<QVersionNumber> Settings::version() const { if (auto v=getOptional<QString>(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; |
