StudioWelcome: Pause splash close timer while restart dialog is active

Fixes: QDS-3332
Change-Id: I16e6646202c97453b76a5e3a848b733ad460514c
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
Miikka Heikkinen
2021-02-09 13:42:12 +02:00
parent 5f5f38e028
commit 7e0f0e470e
2 changed files with 31 additions and 3 deletions

View File

@@ -64,6 +64,7 @@ namespace Internal {
const char DO_NOT_SHOW_SPLASHSCREEN_AGAIN_KEY[] = "StudioSplashScreen";
QPointer<QQuickWidget> s_view = nullptr;
static StudioWelcomePlugin *s_pluginInstance = nullptr;
static bool isUsageStatistic(const ExtensionSystem::PluginSpec *spec)
{
@@ -115,10 +116,14 @@ public:
plugin->setEnabledBySettings(b);
ExtensionSystem::PluginManager::writeSettings();
// pause remove splash timer while dialog is open otherwise splash crashes upon removal
s_pluginInstance->pauseRemoveSplashTimer();
const QString restartText = tr("The change will take effect after restart.");
Core::RestartDialog restartDialog(Core::ICore::dialogParent(), restartText);
restartDialog.exec();
s_pluginInstance->resumeRemoveSplashTimer();
setupModel();
}
@@ -270,10 +275,14 @@ void StudioWelcomePlugin::showSystemSettings()
Core::ICore::infoBar()->globallySuppressInfo("WarnCrashReporting");
// pause remove splash timer while settings dialog is open otherwise splash crashes upon removal
int splashAutoCloseRemainingTime = m_removeSplashTimer.remainingTime(); // milliseconds
m_removeSplashTimer.stop();
pauseRemoveSplashTimer();
Core::ICore::showOptionsDialog(Core::Constants::SETTINGS_ID_SYSTEM);
m_removeSplashTimer.start(splashAutoCloseRemainingTime);
resumeRemoveSplashTimer();
}
StudioWelcomePlugin::StudioWelcomePlugin()
{
s_pluginInstance = this;
}
StudioWelcomePlugin::~StudioWelcomePlugin()
@@ -359,6 +368,20 @@ bool StudioWelcomePlugin::delayedInitialize()
return false;
}
void StudioWelcomePlugin::pauseRemoveSplashTimer()
{
if (m_removeSplashTimer.isActive()) {
m_removeSplashRemainingTime = m_removeSplashTimer.remainingTime(); // milliseconds
m_removeSplashTimer.stop();
}
}
void StudioWelcomePlugin::resumeRemoveSplashTimer()
{
if (!m_removeSplashTimer.isActive())
m_removeSplashTimer.start(m_removeSplashRemainingTime);
}
WelcomeMode::WelcomeMode()
{
setDisplayName(tr("Studio"));

View File

@@ -42,15 +42,20 @@ public slots:
void showSystemSettings();
public:
StudioWelcomePlugin();
~StudioWelcomePlugin() final;
bool initialize(const QStringList &arguments, QString *errorString) override;
void extensionsInitialized() override;
bool delayedInitialize() override;
void pauseRemoveSplashTimer();
void resumeRemoveSplashTimer();
private:
class WelcomeMode *m_welcomeMode = nullptr;
QTimer m_removeSplashTimer;
int m_removeSplashRemainingTime = 0;
};
} // namespace Internal