// For license of this file, see /LICENSE.md. #ifndef TOOLBAR_H #define TOOLBAR_H #include #include #include #include class BaseBar { public: // Returns all actions which can be added to the toolbar. virtual QList availableActions() const = 0; // Returns all actions which are currently included // in the toolbar. virtual QList activatedActions() const = 0; // Sets new "actions" to the toolbar and perhaps saves the toolbar // state into the settings. virtual void saveAndSetActions(const QStringList& actions) = 0; // Returns list of default actions. virtual QStringList defaultActions() const = 0; // Returns list of saved actions. virtual QStringList savedActions() const = 0; // Loads the toolbar state from settings. virtual void loadSavedActions(); // Converts action names to actions. virtual QList convertActions(const QStringList& actions) = 0; // Loads list of actions into the bar. virtual void loadSpecificActions(const QList& actions, bool initial_load = false) = 0; protected: QAction* findMatchingAction(const QString& action, const QList& actions) const; }; class BaseToolBar : public QToolBar, public BaseBar { Q_OBJECT public: enum class SearchFields { SearchTitleOnly = 1, SearchAll = 2 }; explicit BaseToolBar(const QString& title, QWidget* parent = nullptr); virtual ~BaseToolBar(); protected: void saveToolButtonSelection(const QString& button_name, const QString& setting_name, const QList& actions) const; void activateAction(const QString& action_name, QWidgetAction* widget_action); void addActionToMenu(QMenu* menu, const QIcon& icon, const QString& title, const QVariant& value, const QString& name); void drawNumberOfCriterias(QToolButton* btn, int count); }; #endif // TOOLBAR_H