From 59864bf1b6e75db34e5a07e8c9ad7b8ae9fe1d3a Mon Sep 17 00:00:00 2001 From: Jim Broadus Date: Sat, 20 Feb 2021 21:35:32 -0800 Subject: [PATCH] application: Add a Starting() slot to Application Add a slot that is invoked when the main application loop starts. This can be used to perform setup tasks after the initialization has occurred. Initial use is to hide a splash. --- src/core/application.cpp | 4 ++++ src/core/application.h | 1 + src/main.cpp | 4 ++++ 3 files changed, 9 insertions(+) diff --git a/src/core/application.cpp b/src/core/application.cpp index e32aef8d3..b63d60b4c 100644 --- a/src/core/application.cpp +++ b/src/core/application.cpp @@ -252,6 +252,10 @@ void Application::MoveToThread(QObject* object, QThread* thread) { void Application::AddError(const QString& message) { emit ErrorAdded(message); } +void Application::Starting() { + qLog(Debug) << "Application starting"; +} + QString Application::language_without_region() const { const int underscore = language_name_.indexOf('_'); if (underscore != -1) { diff --git a/src/core/application.h b/src/core/application.h index d09547c1f..079c43ae2 100644 --- a/src/core/application.h +++ b/src/core/application.h @@ -114,6 +114,7 @@ class Application : public QObject { void MoveToThread(QObject* object, QThread* thread); public slots: + void Starting(); void AddError(const QString& message); void ReloadSettings(); void OpenSettingsDialogAtPage(SettingsDialog::Page page); diff --git a/src/main.cpp b/src/main.cpp index 7737d112c..2f7d53828 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -460,6 +460,10 @@ int main(int argc, char* argv[]) { QObject::connect(&a, SIGNAL(messageReceived(QString)), &w, SLOT(CommandlineOptionsReceived(QString))); + // Use a queued connection so the invokation occurs after the application + // loop starts. + QMetaObject::invokeMethod(&app, "Starting", Qt::QueuedConnection); + int ret = a.exec(); return ret;