1 // For license of this file, see <project-root-folder>/LICENSE.md. 2 3 #ifndef TOOLBAREDITOR_H 4 #define TOOLBAREDITOR_H 5 6 #include <QWidget> 7 8 #include "ui_toolbareditor.h" 9 10 namespace Ui { 11 class ToolBarEditor; 12 } 13 14 class BaseBar; 15 16 class ToolBarEditor : public QWidget { 17 Q_OBJECT 18 19 public: 20 explicit ToolBarEditor(QWidget* parent = nullptr); 21 22 // Toolbar operations. 23 void loadFromToolBar(BaseBar* tool_bar); 24 void saveToolBar(); 25 26 QListWidget* activeItemsWidget() const; 27 QListWidget* availableItemsWidget() const; 28 29 protected: 30 virtual bool eventFilter(QObject* object, QEvent* event); 31 32 private slots: 33 void updateActionsAvailability(); 34 35 // Insert common controls. 36 void insertSpacer(); 37 void insertSeparator(); 38 39 void moveActionDown(); 40 void moveActionUp(); 41 42 void addSelectedAction(); 43 void deleteSelectedAction(); 44 void deleteAllActions(); 45 46 void resetToolBar(); 47 48 signals: 49 void setupChanged(); 50 51 private: 52 void loadEditor(const QList<QAction*>& activated_actions, const QList<QAction*>& available_actions); 53 54 QScopedPointer<Ui::ToolBarEditor> m_ui; 55 BaseBar* m_toolBar; 56 }; 57 activeItemsWidget()58inline QListWidget* ToolBarEditor::activeItemsWidget() const { 59 return m_ui->m_listActivatedActions; 60 } 61 availableItemsWidget()62inline QListWidget* ToolBarEditor::availableItemsWidget() const { 63 return m_ui->m_listAvailableActions; 64 } 65 66 #endif // TOOLBAREDITOR_H 67