Skip to content

Commit

Permalink
fix: [Search] The clear search dialog show multiple times.
Browse files Browse the repository at this point in the history
Add the window id, let the parent window get the signal
and clear the search history.

Log: fix issue
Bug: https://pms.uniontech.com/bug-view-259865.html
  • Loading branch information
GongHeng2017 committed Jun 24, 2024
1 parent 33133ae commit 211060d
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/dfm-base/base/application/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -307,7 +307,7 @@ void Application::appAttributeTrigger(TriggerAttribute ta)
break;
}
case kClearSearchHistory:
Q_EMIT instance()->clearSearchHistory();
Q_EMIT instance()->clearSearchHistory(winId);
break;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/dfm-base/base/application/application.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
5 changes: 4 additions & 1 deletion src/dfm-base/dialogs/settingsdialog/settingdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <dfm-base/base/application/application.h>
#include <dfm-base/base/application/settings.h>
#include <dfm-base/utils/windowutils.h>
#include <dfm-base/widgets/filemanagerwindowsmanager.h>

#include <dtkcore_global.h>
#include <DSettingsOption>
Expand Down Expand Up @@ -134,10 +135,12 @@ void SettingDialog::loadSettings(const QString & /*templateFile*/)
QPointer<QCheckBox> SettingDialog::kAutoMountCheckBox = nullptr;
QPointer<QCheckBox> SettingDialog::kAutoMountOpenCheckBox = nullptr;
QSet<QString> 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);
Expand Down Expand Up @@ -296,7 +299,7 @@ QPair<QWidget *, QWidget *> SettingDialog::createPushButton(QObject *opt)
layout->addWidget(button, 0, Qt::AlignRight);

connect(button, &DPushButton::clicked, option, [=] {
Application::appAttributeTrigger(static_cast<Application::TriggerAttribute>(attributeType));
Application::appAttributeTrigger(static_cast<Application::TriggerAttribute>(attributeType), parentWid);
});

return qMakePair(new QLabel(desc), rightWidget);
Expand Down
1 change: 1 addition & 0 deletions src/dfm-base/dialogs/settingsdialog/settingdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class SettingDialog : public DSettingsDialog
static QPointer<QCheckBox> kAutoMountOpenCheckBox;
static QSet<QString> kHiddenSettingItems;
QPointer<DSettings> dtkSettings;
static quint64 parentWid;
};
}
#endif // DFMSETTINGDIALOG_H
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 211060d

Please sign in to comment.