refactor: clean up WideBar a bit
Signed-off-by: flow <flowlnlnln@gmail.com>
This commit is contained in:
parent
347ae0a9ad
commit
2367903ac6
2 changed files with 68 additions and 77 deletions
|
@ -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;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue