Skip to content

Commit

Permalink
feat: Custom Task Turn to Main Line: dde-file-manager Clears Search H…
Browse files Browse the repository at this point in the history
…istory

Add option to clear file manager search records in settings

Log: Custom Task Turn to Main Line: dde-file-manager Clears Search History
Task: https://pms.uniontech.com/bug-view-252515.html
  • Loading branch information
liyigang1 authored and deepin-bot[bot] committed May 11, 2024
1 parent 04d33a8 commit b25c65e
Show file tree
Hide file tree
Showing 12 changed files with 543 additions and 458 deletions.
7 changes: 6 additions & 1 deletion src/dfm-base/base/application/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ Settings *Application::dataPersistence()
void Application::appAttributeTrigger(TriggerAttribute ta)
{
switch (ta) {
case kRestoreViewMode:
case kRestoreViewMode: {
auto defaultViewMode = appAttribute(Application::kViewMode).toInt();
auto settings = appObtuselySetting();

Expand All @@ -304,6 +304,11 @@ void Application::appAttributeTrigger(TriggerAttribute ta)

if (instance())
Q_EMIT instance()->viewModeChanged(defaultViewMode);
break;
}
case kClearSearchHistory:
Q_EMIT instance()->clearSearchHistory();
break;
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/dfm-base/base/application/application.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ class Application : public QObject
Q_ENUM(GenericAttribute)

enum TriggerAttribute {
kRestoreViewMode // restore defualt view mode to all dir
kRestoreViewMode, // restore defualt view mode to all dir
kClearSearchHistory // clear search history
};

Q_ENUM(TriggerAttribute)
Expand Down Expand Up @@ -110,6 +111,7 @@ class Application : public QObject

void genericSettingCreated(Settings *settings);
void appSettingCreated(Settings *settings);
void clearSearchHistory();

protected:
Application(ApplicationPrivate *dd, QObject *parent = nullptr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <dfm-base/base/schemefactory.h>
#include <dfm-base/utils/fileutils.h>
#include <dfm-base/base/configs/dconfig/dconfigmanager.h>
#include <dfm-base/base/application/application.h>

#include <dfm-framework/event/event.h>

Expand Down Expand Up @@ -125,6 +126,8 @@ void AddressBarPrivate::initConnect()
initUiForSizeMode();
});
#endif
connect(Application::instance(), &Application::clearSearchHistory, this,
&AddressBarPrivate::onClearSearchHistory);
}

void AddressBarPrivate::initUiForSizeMode()
Expand Down Expand Up @@ -362,6 +365,13 @@ int AddressBarPrivate::showClearSearchHistory()
return code;
}

void AddressBarPrivate::onClearSearchHistory()
{
auto result = showClearSearchHistory();
if (result == DDialog::Accepted)
q->clearSearchHistory();
}


void AddressBarPrivate::requestCompleteByUrl(const QUrl &url)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ public Q_SLOTS:
void onDConfigValueChanged(const QString &config, const QString &key);
void filterHistory(const QString &text);
int showClearSearchHistory();
void onClearSearchHistory();

protected:
virtual bool eventFilterResize(AddressBar *addressbar, QResizeEvent *event);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ inline constexpr char kIndexInternal[] { SEARCH_SETTING_GROUP ".00_index_interna
inline constexpr char kIndexExternal[] { SEARCH_SETTING_GROUP ".01_index_external" };
inline constexpr char kFulltextSearch[] { SEARCH_SETTING_GROUP ".02_fulltext_search" };
inline constexpr char kDisplaySearchHistory[] { SEARCH_SETTING_GROUP ".03_display_search_history" };
inline constexpr char kClearSearchHistory[] { SEARCH_SETTING_GROUP ".04_clear_search_history" };
}

namespace DConfig {
Expand Down
6 changes: 6 additions & 0 deletions src/plugins/filemanager/dfmplugin-search/search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,12 @@ void Search::regSearchSettingConfig()
DConfig::kDisplaySearchHistory,
val);
});
SettingJsonGenerator::instance()->addConfig(SearchSettings::kClearSearchHistory,
{ { "key", "04_clear_search_history" },
{ "desc", tr("Clear dde-file-manager Search Records") },
{ "text", tr("Clean up") },
{ "type", "pushButton" },
{ "trigger", QVariant(Application::kClearSearchHistory) } });
}

void Search::bindEvents()
Expand Down
162 changes: 86 additions & 76 deletions translations/dde-file-manager.ts

Large diffs are not rendered by default.

162 changes: 86 additions & 76 deletions translations/dde-file-manager_bo.ts

Large diffs are not rendered by default.

162 changes: 86 additions & 76 deletions translations/dde-file-manager_ug.ts

Large diffs are not rendered by default.

162 changes: 86 additions & 76 deletions translations/dde-file-manager_zh_CN.ts

Large diffs are not rendered by default.

162 changes: 86 additions & 76 deletions translations/dde-file-manager_zh_HK.ts

Large diffs are not rendered by default.

162 changes: 86 additions & 76 deletions translations/dde-file-manager_zh_TW.ts

Large diffs are not rendered by default.

0 comments on commit b25c65e

Please sign in to comment.