During the Dolphin settings revamp
(https://invent.kde.org/system/dolphin/-/commit/
489b56b68bb29e81337e115c490eea4403001b71?)
this QUrl had been forgot to add back so that the
FoldersTabsSettingsPage knows what is the current url.
This change checks for the main window of dolphin, then gets
the URL of it whenever useCurrentLocation is called.
However, when this is used as KCM, the button is not
created, since there it doesn't make sense.
BUG:491753
# The settings are still accessible from the hamburger menu
add_library(kcm_dolphinviewmodes MODULE)
add_library(kcm_dolphingeneral MODULE)
# The settings are still accessible from the hamburger menu
add_library(kcm_dolphinviewmodes MODULE)
add_library(kcm_dolphingeneral MODULE)
+ target_compile_definitions(kcm_dolphingeneral PUBLIC IS_KCM)
target_sources(kcm_dolphinviewmodes PRIVATE
settings/kcm/kcmdolphinviewmodes.cpp
target_sources(kcm_dolphinviewmodes PRIVATE
settings/kcm/kcmdolphinviewmodes.cpp
#include <KMessageBox>
#include <KProtocolManager>
#include <KMessageBox>
#include <KProtocolManager>
+#ifndef IS_KCM
+#include <QApplication>
+#endif
#include <QButtonGroup>
#include <QCheckBox>
#include <QFileDialog>
#include <QButtonGroup>
#include <QCheckBox>
#include <QFileDialog>
QHBoxLayout *buttonBoxLayout = new QHBoxLayout(m_buttonBoxLayoutContainer);
buttonBoxLayout->setContentsMargins(0, 0, 0, 0);
QHBoxLayout *buttonBoxLayout = new QHBoxLayout(m_buttonBoxLayoutContainer);
buttonBoxLayout->setContentsMargins(0, 0, 0, 0);
QPushButton *useCurrentButton = new QPushButton(i18nc("@action:button", "Use Current Location"));
buttonBoxLayout->addWidget(useCurrentButton);
connect(useCurrentButton, &QPushButton::clicked, this, &FoldersTabsSettingsPage::useCurrentLocation);
QPushButton *useCurrentButton = new QPushButton(i18nc("@action:button", "Use Current Location"));
buttonBoxLayout->addWidget(useCurrentButton);
connect(useCurrentButton, &QPushButton::clicked, this, &FoldersTabsSettingsPage::useCurrentLocation);
QPushButton *useDefaultButton = new QPushButton(i18nc("@action:button", "Use Default Location"));
buttonBoxLayout->addWidget(useDefaultButton);
connect(useDefaultButton, &QPushButton::clicked, this, &FoldersTabsSettingsPage::useDefaultLocation);
QPushButton *useDefaultButton = new QPushButton(i18nc("@action:button", "Use Default Location"));
buttonBoxLayout->addWidget(useDefaultButton);
connect(useDefaultButton, &QPushButton::clicked, this, &FoldersTabsSettingsPage::useDefaultLocation);
void FoldersTabsSettingsPage::useCurrentLocation()
{
void FoldersTabsSettingsPage::useCurrentLocation()
{
+#ifndef IS_KCM
+ DolphinMainWindow *mainWindow = nullptr;
+ const auto topLevelWidgets = QApplication::allWidgets();
+ for (const auto widget : topLevelWidgets) {
+ if (qobject_cast<DolphinMainWindow *>(widget)) {
+ mainWindow = static_cast<DolphinMainWindow *>(widget);
+ break;
+ }
+ }
+
+ if (mainWindow) {
+ m_url = mainWindow->activeViewContainer()->url();
+ }
+#endif
m_homeUrl->setText(m_url.toDisplayString(QUrl::PreferLocalFile));
}
m_homeUrl->setText(m_url.toDisplayString(QUrl::PreferLocalFile));
}