diff --git a/src/dfm-base/base/application/application.cpp b/src/dfm-base/base/application/application.cpp index 1b1e48cdcc..485f930e9a 100644 --- a/src/dfm-base/base/application/application.cpp +++ b/src/dfm-base/base/application/application.cpp @@ -276,7 +276,7 @@ Settings *Application::dataPersistence() return dpGlobal; } -void Application::appAttributeTrigger(TriggerAttribute ta) +void Application::appAttributeTrigger(TriggerAttribute ta, quint64 winId) { switch (ta) { case kRestoreViewMode: { @@ -307,7 +307,7 @@ void Application::appAttributeTrigger(TriggerAttribute ta) break; } case kClearSearchHistory: - Q_EMIT instance()->clearSearchHistory(); + Q_EMIT instance()->clearSearchHistory(winId); break; } } diff --git a/src/dfm-base/base/application/application.h b/src/dfm-base/base/application/application.h index 2b8c1a1dad..ec81826ee8 100644 --- a/src/dfm-base/base/application/application.h +++ b/src/dfm-base/base/application/application.h @@ -93,7 +93,7 @@ class Application : public QObject static Settings *dataPersistence(); - static void appAttributeTrigger(TriggerAttribute ta); + static void appAttributeTrigger(TriggerAttribute ta, quint64 winId); Q_SIGNALS: void appAttributeChanged(ApplicationAttribute aa, const QVariant &value); @@ -111,7 +111,7 @@ class Application : public QObject void genericSettingCreated(Settings *settings); void appSettingCreated(Settings *settings); - void clearSearchHistory(); + void clearSearchHistory(quint64 winId); protected: Application(ApplicationPrivate *dd, QObject *parent = nullptr); diff --git a/src/dfm-base/dialogs/settingsdialog/settingdialog.cpp b/src/dfm-base/dialogs/settingsdialog/settingdialog.cpp index fd9800ddb0..07416aba85 100644 --- a/src/dfm-base/dialogs/settingsdialog/settingdialog.cpp +++ b/src/dfm-base/dialogs/settingsdialog/settingdialog.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -134,10 +135,12 @@ void SettingDialog::loadSettings(const QString & /*templateFile*/) QPointer SettingDialog::kAutoMountCheckBox = nullptr; QPointer SettingDialog::kAutoMountOpenCheckBox = nullptr; QSet SettingDialog::kHiddenSettingItems {}; +quint64 SettingDialog::parentWid { 0 }; SettingDialog::SettingDialog(QWidget *parent) : DSettingsDialog(parent) { + parentWid = FMWindowsIns.findWindowId(parent); // TODO(xust): move to server plugin. widgetFactory()->registerWidget("mountCheckBox", &SettingDialog::createAutoMountCheckBox); widgetFactory()->registerWidget("openCheckBox", &SettingDialog::createAutoMountOpenCheckBox); @@ -296,7 +299,7 @@ QPair SettingDialog::createPushButton(QObject *opt) layout->addWidget(button, 0, Qt::AlignRight); connect(button, &DPushButton::clicked, option, [=] { - Application::appAttributeTrigger(static_cast(attributeType)); + Application::appAttributeTrigger(static_cast(attributeType), parentWid); }); return qMakePair(new QLabel(desc), rightWidget); diff --git a/src/dfm-base/dialogs/settingsdialog/settingdialog.h b/src/dfm-base/dialogs/settingsdialog/settingdialog.h index 362a0028aa..ab4f43a584 100644 --- a/src/dfm-base/dialogs/settingsdialog/settingdialog.h +++ b/src/dfm-base/dialogs/settingsdialog/settingdialog.h @@ -43,6 +43,7 @@ class SettingDialog : public DSettingsDialog static QPointer kAutoMountOpenCheckBox; static QSet kHiddenSettingItems; QPointer dtkSettings; + static quint64 parentWid; }; } #endif // DFMSETTINGDIALOG_H diff --git a/src/plugins/filemanager/core/dfmplugin-titlebar/views/addressbar.cpp b/src/plugins/filemanager/core/dfmplugin-titlebar/views/addressbar.cpp index 6a707f2921..2bed7357d8 100644 --- a/src/plugins/filemanager/core/dfmplugin-titlebar/views/addressbar.cpp +++ b/src/plugins/filemanager/core/dfmplugin-titlebar/views/addressbar.cpp @@ -365,8 +365,12 @@ int AddressBarPrivate::showClearSearchHistory() return code; } -void AddressBarPrivate::onClearSearchHistory() +void AddressBarPrivate::onClearSearchHistory(quint64 winId) { + quint64 id = FMWindowsIns.findWindowId(q); + if (id != winId) + return; + auto result = showClearSearchHistory(); if (result == DDialog::Accepted) q->clearSearchHistory(); diff --git a/src/plugins/filemanager/core/dfmplugin-titlebar/views/private/addressbar_p.h b/src/plugins/filemanager/core/dfmplugin-titlebar/views/private/addressbar_p.h index 48e4c9d07d..84f68832df 100644 --- a/src/plugins/filemanager/core/dfmplugin-titlebar/views/private/addressbar_p.h +++ b/src/plugins/filemanager/core/dfmplugin-titlebar/views/private/addressbar_p.h @@ -110,7 +110,7 @@ public Q_SLOTS: void onDConfigValueChanged(const QString &config, const QString &key); void filterHistory(const QString &text); int showClearSearchHistory(); - void onClearSearchHistory(); + void onClearSearchHistory(quint64 winId); protected: virtual bool eventFilterResize(AddressBar *addressbar, QResizeEvent *event);