diff options
| author | Felix Ernst <[email protected]> | 2024-02-23 09:45:53 +0000 |
|---|---|---|
| committer | Felix Ernst <[email protected]> | 2024-02-23 09:45:53 +0000 |
| commit | 796332d63a32e6fdea83001f4a14c03a8b81228b (patch) | |
| tree | e11b940756b8752261f275e30c97cfaeba96095e /src | |
| parent | 41bd0d27fa6f6e9953751dfed6865460082ade6d (diff) | |
Avoid searching for the knetattach service on startup
The installed services might change while Dolphin is running, so it is
better to only search when they are actually needed instead.
The very first time such a search happens (e.g. after updating the
system), is also somewhat slow, which could slow down the very first
Dolphin startup.
This commit might also produce a very slight general startup speed
improvement. However, the measured change is within the margin of
error.
Diffstat (limited to 'src')
| -rw-r--r-- | src/dolphinnavigatorswidgetaction.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/dolphinnavigatorswidgetaction.cpp b/src/dolphinnavigatorswidgetaction.cpp index 865c493bc..f45589dbb 100644 --- a/src/dolphinnavigatorswidgetaction.cpp +++ b/src/dolphinnavigatorswidgetaction.cpp @@ -253,8 +253,8 @@ QPushButton *DolphinNavigatorsWidgetAction::newNetworkFolderButton(const Dolphin { auto networkFolderButton = new QPushButton(QIcon::fromTheme(QStringLiteral("folder-add")), i18nc("@action:button", "Add Network Folder"), parent); networkFolderButton->setFlat(true); - KService::Ptr service = KService::serviceByDesktopName(QStringLiteral("org.kde.knetattach")); - connect(networkFolderButton, &QPushButton::clicked, this, [networkFolderButton, service]() { + connect(networkFolderButton, &QPushButton::clicked, this, [networkFolderButton]() { + const KService::Ptr service = KService::serviceByDesktopName(QStringLiteral("org.kde.knetattach")); auto *job = new KIO::ApplicationLauncherJob(service, networkFolderButton); auto *delegate = new KNotificationJobUiDelegate; delegate->setAutoErrorHandlingEnabled(true); @@ -262,8 +262,14 @@ QPushButton *DolphinNavigatorsWidgetAction::newNetworkFolderButton(const Dolphin job->start(); }); networkFolderButton->hide(); - connect(urlNavigator, &KUrlNavigator::urlChanged, this, [networkFolderButton, urlNavigator, service]() { - networkFolderButton->setVisible(service && urlNavigator->locationUrl().scheme() == QLatin1String("remote")); + connect(urlNavigator, &KUrlNavigator::urlChanged, this, [networkFolderButton, urlNavigator]() { + if (urlNavigator->locationUrl().scheme() == QLatin1String("remote")) { + // Looking up a service can be a bit slow, so we only do it now when it becomes necessary. + const KService::Ptr service = KService::serviceByDesktopName(QStringLiteral("org.kde.knetattach")); + networkFolderButton->setVisible(service); + } else { + networkFolderButton->setVisible(false); + } }); return networkFolderButton; } |
