1 // For license of this file, see <project-root-folder>/LICENSE.md.
2 
3 #ifndef TOOLBAR_H
4 #define TOOLBAR_H
5 
6 #include <QToolBar>
7 
8 class BaseBar {
9   public:
10 
11     // Returns all actions which can be added to the toolbar.
12     virtual QList<QAction*> availableActions() const = 0;
13 
14     // Returns all actions which are currently included
15     // in the toolbar.
16     virtual QList<QAction*> activatedActions() const = 0;
17 
18     // Sets new "actions" to the toolbar and perhaps saves the toolbar
19     // state into the settings.
20     virtual void saveAndSetActions(const QStringList& actions) = 0;
21 
22     // Returns list of default actions.
23     virtual QStringList defaultActions() const = 0;
24 
25     // Returns list of saved actions.
26     virtual QStringList savedActions() const = 0;
27 
28     // Loads the toolbar state from settings.
29     virtual void loadSavedActions();
30 
31     // Converts action names to actions.
32     virtual QList<QAction*> convertActions(const QStringList& actions) = 0;
33 
34     // Loads list of actions into the bar.
35     virtual void loadSpecificActions(const QList<QAction*>& actions, bool initial_load = false) = 0;
36 
37   protected:
38     QAction* findMatchingAction(const QString& action, const QList<QAction*>& actions) const;
39 };
40 
41 class BaseToolBar : public QToolBar, public BaseBar {
42   Q_OBJECT
43 
44   public:
45     explicit BaseToolBar(const QString& title, QWidget* parent = nullptr);
46     virtual ~BaseToolBar();
47 };
48 
49 #endif // TOOLBAR_H
50