refactor: clean up WideBar a bit

Signed-off-by: flow <flowlnlnln@gmail.com>
This commit is contained in:
flow
2022-11-19 11:55:40 -03:00
parent 347ae0a9ad
commit 2367903ac6
2 changed files with 68 additions and 77 deletions

View File

@ -2,17 +2,16 @@
#include <QAction>
#include <QMap>
#include <QMenu>
#include <QToolBar>
class QMenu;
class WideBar : public QToolBar {
Q_OBJECT
public:
explicit WideBar(const QString& title, QWidget* parent = nullptr);
explicit WideBar(QWidget* parent = nullptr);
virtual ~WideBar();
~WideBar() override = default;
void addAction(QAction* action);
void addSeparator();
@ -25,10 +24,14 @@ class WideBar : public QToolBar {
QMenu* createContextMenu(QWidget* parent = nullptr, const QString& title = QString());
private:
struct BarEntry;
struct BarEntry {
enum class Type { None, Action, Separator, Spacer } type = Type::None;
QAction* bar_action = nullptr;
QAction* menu_action = nullptr;
};
auto getMatching(QAction* act) -> QList<BarEntry*>::iterator;
auto getMatching(QAction* act) -> QList<BarEntry>::iterator;
private:
QList<BarEntry*> m_entries;
QList<BarEntry> m_entries;
};