Commit c98f3488 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧
Browse files

Improve startup time when not opening the main page

We were loading it upon load and then hiding it, triggering a bunch of
things we do not need yet.
This improves startup time when opening for updates or to search applications.
parent cff214d9
......@@ -96,7 +96,7 @@ public:
}
};
DiscoverObject::DiscoverObject(CompactMode mode)
DiscoverObject::DiscoverObject(CompactMode mode, const QVariantMap &initialProperties)
: QObject()
, m_engine(new QQmlApplicationEngine)
, m_mode(mode)
......@@ -139,6 +139,7 @@ DiscoverObject::DiscoverObject(CompactMode mode)
plugin->initializeEngine(m_engine, uri);
plugin->registerTypes(uri);
m_engine->setInitialProperties(initialProperties);
m_engine->rootContext()->setContextProperty(QStringLiteral("app"), this);
m_engine->rootContext()->setContextProperty(QStringLiteral("discoverAboutData"), QVariant::fromValue(KAboutData::applicationData()));
......
......@@ -41,7 +41,7 @@ class DiscoverObject : public QObject
enum CompactMode { Auto, Compact, Full };
Q_ENUM(CompactMode)
explicit DiscoverObject(CompactMode mode);
explicit DiscoverObject(CompactMode mode, const QVariantMap &initialProperties);
~DiscoverObject() override;
QStringList modes() const;
......
......@@ -131,7 +131,13 @@ int main(int argc, char** argv)
KDBusService* service = new KDBusService(KDBusService::Unique, &app);
mainWindow = new DiscoverObject(s_decodeCompactMode->value(parser->value(QStringLiteral("compact")), DiscoverObject::Full));
{
auto options = parser->optionNames();
options.removeAll(QStringLiteral("backends"));
options.removeAll(QStringLiteral("test"));
bool hasOptions = !options.isEmpty() || !parser->positionalArguments().isEmpty();
mainWindow = new DiscoverObject(s_decodeCompactMode->value(parser->value(QStringLiteral("compact")), DiscoverObject::Full), {{QStringLiteral("defaultStartup"), !hasOptions}});
}
QObject::connect(&app, &QCoreApplication::aboutToQuit, mainWindow, &DiscoverObject::deleteLater);
QObject::connect(service, &KDBusService::activateRequested, mainWindow, [mainWindow](const QStringList &arguments, const QString &/*workingDirectory*/){
if (!mainWindow->rootObject())
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment