]> cloud.milkyroute.net Git - dolphin.git/blob - src/search/popup.h
Clazy fix
[dolphin.git] / src / search / popup.h
1 /*
2 This file is part of the KDE project
3 SPDX-FileCopyrightText: 2024 Felix Ernst <felixernst@kde.org>
4
5 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
6 */
7
8 #ifndef POPUP_H
9 #define POPUP_H
10
11 #include "dolphinquery.h"
12 #include "updatablestateinterface.h"
13 #include "widgetmenu.h"
14
15 #include <KMessageWidget>
16
17 #include <QUrl>
18
19 class KContextualHelpButton;
20 class QRadioButton;
21 class QToolButton;
22
23 namespace Search
24 {
25 class DateSelector;
26 class FileTypeSelector;
27 class MinimumRatingSelector;
28 class TagsSelector;
29
30 /** @returns the localized name for the Filenamesearch search tool for use in user interfaces. */
31 QString filenamesearchUiName();
32
33 /** @returns the localized name for the Baloo search tool for use in user interfaces. */
34 QString balooUiName();
35
36 /**
37 * This object contains most of the UI to set the search configuration.
38 */
39 class Popup : public WidgetMenu, public UpdatableStateInterface
40 {
41 Q_OBJECT
42
43 public:
44 explicit Popup(std::shared_ptr<const DolphinQuery> dolphinQuery, QWidget *parent = nullptr);
45
46 Q_SIGNALS:
47 /** Is emitted whenever settings have changed and a new search might be necessary. */
48 void configurationChanged(const Search::DolphinQuery &dolphinQuery);
49
50 /**
51 * Requests for @p message with the given @p messageType to be shown to the user in a non-modal way.
52 */
53 void showMessage(const QString &message, KMessageWidget::MessageType messageType);
54
55 /**
56 * Requests for a progress update to be shown to the user in a non-modal way.
57 * @param currentlyRunningTaskTitle The task that is currently progressing.
58 * @param installationProgressPercent The current percentage of completion.
59 */
60 void showInstallationProgress(const QString &currentlyRunningTaskTitle, int installationProgressPercent);
61
62 private:
63 QWidget *init() override;
64
65 void updateState(const std::shared_ptr<const DolphinQuery> &dolphinQuery) override;
66
67 private Q_SLOTS:
68 /**
69 * Opens KFind if KFind is installed.
70 * If KFind is not installed, this method asynchronously starts a Filelight installation using DolphinPackageInstaller. @see DolphinPackageInstaller.
71 * Installation success or failure is reported through showMessage(). @see Popup::showMessage().
72 * Installation progress is reported through showInstallationProgress(). @see Popup::showInstallationProgress().
73 */
74 void slotKFindButtonClicked();
75
76 private:
77 QRadioButton *m_searchInFileNamesRadioButton = nullptr;
78 QRadioButton *m_searchInFileContentsRadioButton = nullptr;
79 QRadioButton *m_filenamesearchRadioButton = nullptr;
80 KContextualHelpButton *m_filenamesearchContextualHelpButton = nullptr;
81 QRadioButton *m_balooRadioButton = nullptr;
82 KContextualHelpButton *m_balooContextualHelpButton = nullptr;
83 /** A container widget for easy showing/hiding of all selectors. */
84 QWidget *m_selectorsLayoutWidget = nullptr;
85 /** Allows to set the file type each search result is expected to have. */
86 FileTypeSelector *m_typeSelector = nullptr;
87 /** Allows to set a date since when each search result needs to have been modified. */
88 DateSelector *m_dateSelector = nullptr;
89 /** Allows selecting the minimum rating search results are expected to have. */
90 MinimumRatingSelector *m_ratingSelector = nullptr;
91 /** Allows to set tags which each search result is required to have. */
92 TagsSelector *m_tagsSelector = nullptr;
93 /** A button that allows installing or opening KFind. */
94 QToolButton *m_kFindButton = nullptr;
95 };
96
97 }
98
99 #endif // POPUP_H