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

Custom Task Turn to Main Line: dde-file-manager Clears Search History

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 committed May 6, 2024
1 parent 3a4b50c commit c43b418
Show file tree
Hide file tree
Showing 18 changed files with 2,799 additions and 485 deletions.
4 changes: 3 additions & 1 deletion src/dfm-base/base/application/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,13 @@ bool Application::syncAppAttribute()
return appSetting()->sync();
}

QVariant Application::genericAttribute(Application::GenericAttribute ga)
QVariant Application::genericAttribute(Application::GenericAttribute ga, const QVariant &value)
{
const QString group(QT_STRINGIFY(GenericAttribute));
const QMetaEnum &me = QMetaEnum::fromType<GenericAttribute>();
const QString key = QString::fromLatin1(me.valueToKey(ga)).remove(0, 1);
if (value.isValid())
return genericSetting()->value(group, key, value);

return genericSetting()->value(group, key);
}
Expand Down
3 changes: 2 additions & 1 deletion src/dfm-base/base/application/application.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class Application : public QObject
kShowDeleteConfirmDialog, // display the delete confirmation dialog
kHideLoopPartitions, // hide loop partitions
kShowThunmbnailInRemote, // show file thumbnail in remote dir
KDisplaySearchHistory, // display search history
};

Q_ENUM(GenericAttribute)
Expand All @@ -78,7 +79,7 @@ class Application : public QObject
static void setAppAttribute(ApplicationAttribute aa, const QVariant &value);
static bool syncAppAttribute();

static QVariant genericAttribute(GenericAttribute ga);
static QVariant genericAttribute(GenericAttribute ga, const QVariant &value = QVariant());
static void setGenericAttribute(GenericAttribute ga, const QVariant &value);
static bool syncGenericAttribute();

Expand Down
6 changes: 6 additions & 0 deletions src/dfm-base/base/configs/settingbackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ using namespace dfmbase;
#define LV2_GROUP_OPEN_ACTION "00_base.00_open_action"
#define LV2_GROUP_NEW_TAB_WINDOWS "00_base.01_new_tab_windows"
#define LV2_GROUP_FILES_AND_FOLDERS "00_base.02_files_and_folders"
#define LV2_GROUP_OTHERS "00_base.03_others"

#define TOP_GROUP_WORKSPACE "02_workspace"
#define LV2_GROUP_VIEW "02_workspace.00_view"
Expand Down Expand Up @@ -57,6 +58,7 @@ BidirectionHash<QString, Application::GenericAttribute> SettingBackendPrivate::k
{ LV2_GROUP_COMPUTER_VIEW ".01_hide_builtin_partition", Application::kHiddenSystemPartition },
{ LV2_GROUP_COMPUTER_VIEW ".02_hide_loop_partitions", Application::kHideLoopPartitions },
{ LV2_GROUP_COMPUTER_VIEW ".04_show_filesystemtag_on_diskicon", Application::kShowFileSystemTagOnDiskIcon },
{ LV2_GROUP_OTHERS ".00_display_search_history", Application::KDisplaySearchHistory },
};

SettingBackend::SettingBackend(QObject *parent)
Expand Down Expand Up @@ -288,6 +290,10 @@ void SettingBackend::initBasicSettingConfig()
ins->addCheckBoxConfig(LV2_GROUP_FILES_AND_FOLDERS ".02_mixed_sort",
tr("Mix sorting of files and folders"),
false);
ins->addGroup(LV2_GROUP_OTHERS, tr("Others"));
ins->addCheckBoxConfig(LV2_GROUP_OTHERS ".00_display_search_history",
tr("Display search history"),
true);
}

void SettingBackend::initWorkspaceSettingConfig()
Expand Down
23 changes: 23 additions & 0 deletions src/dfm-base/utils/dialogmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,29 @@ int DialogManager::showUnableToVistDir(const QString &dir)
return code;
}

int DialogManager::showClearSearchHistories()
{
QString clearSearch = tr("Are you sure clear search histories?");
QStringList buttonTexts;
buttonTexts.append(tr("Cancel","button"));
buttonTexts.append(tr("Confirm","button"));

DDialog d;

if (!d.parentWidget()) {
d.setWindowFlags(d.windowFlags() | Qt::WindowStaysOnTopHint);
}
d.setIcon(QIcon::fromTheme("dialog-warning"));
d.setTitle(clearSearch);
d.addButton(buttonTexts[0], true, DDialog::ButtonNormal);
d.addButton(buttonTexts[1], false, DDialog::ButtonWarning);
d.setDefaultButton(1);
d.getButton(1)->setFocus();
d.moveToCenter();
int code = d.exec();
return code;
}

DFMBASE_NAMESPACE::GlobalEventType DialogManager::showBreakSymlinkDialog(const QString &targetName, const QUrl &linkfile)
{
DDialog d(qApp->activeWindow());
Expand Down
1 change: 1 addition & 0 deletions src/dfm-base/utils/dialogmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class DialogManager : public QObject
void showRenameBusyErrDialog();
int showRenameNameDotBeginDialog();
int showUnableToVistDir(const QString &dir);
int showClearSearchHistories();

// link file not exist
DFMBASE_NAMESPACE::GlobalEventType showBreakSymlinkDialog(const QString &targetName, const QUrl &linkfile);
Expand Down
Loading

0 comments on commit c43b418

Please sign in to comment.