Debian Codegraph @

src/librssguard/gui/toolbars/basetoolbar.h

raw symbols SCIP
1 // For license of this file, see <project-root-folder>/LICENSE.md.
2
3 #ifndef TOOLBAR_H
4 #define TOOLBAR_H
5
6 #include <QMenu>
7 #include <QToolBar>
8 #include <QToolButton>
9 #include <QWidgetAction>
10
11 class BaseBar {
12 public:
13 // Returns all actions which can be added to the toolbar.
14 virtual QList<QAction*> availableActions() const = 0;
15
16 // Returns all actions which are currently included
17 // in the toolbar.
18 virtual QList<QAction*> activatedActions() const = 0;
19
20 // Sets new "actions" to the toolbar and perhaps saves the toolbar
21 // state into the settings.
22 virtual void saveAndSetActions(const QStringList& actions) = 0;
23
24 // Returns list of default actions.
25 virtual QStringList defaultActions() const = 0;
26
27 // Returns list of saved actions.
28 virtual QStringList savedActions() const = 0;
29
30 // Loads the toolbar state from settings.
31 virtual void loadSavedActions();
32
33 // Returns list of actions which are created solely by this toolbar.
34 // NOTE: These actions are added to global list of actions which can be
35 // bound to keyboard shortcuts.
36 virtual QList<QAction*> extraActions() const;
37
38 // Converts action names to actions.
39 virtual QList<QAction*> convertActions(const QStringList& actions) = 0;
40
41 // Loads list of actions into the bar.
42 virtual void loadSpecificActions(const QList<QAction*>& actions, bool initial_load = false) = 0;
43
44 protected:
45 QAction* findMatchingAction(const QString& action, const QList<QAction*>& actions) const;
46 };
47
48 class BaseToolBar : public QToolBar, public BaseBar {
49 Q_OBJECT
50
51 public:
52 enum class SearchFields {
53 SearchTitleOnly = 1,
54 SearchAll = 2
55 };
56
57 explicit BaseToolBar(const QString& title, QWidget* parent = nullptr);
58 virtual ~BaseToolBar();
59
60 protected:
61 void saveToolButtonSelection(const QString& button_name,
62 const QString& setting_name,
63 const QList<QAction*>& actions) const;
64 void activateAction(const QString& action_name, QWidgetAction* widget_action);
65 void addActionToMenu(QMenu* menu,
66 const QIcon& icon,
67 const QString& title,
68 const QString& tooltip_suffix,
69 const QVariant& value,
70 const QString& object_name);
71 void drawNumberOfCriterias(QToolButton* btn, int count);
72 };
73
74 #endif // TOOLBAR_H