feat(WideBar): allow hiding buttons with right-click

Signed-off-by: flow <flowlnlnln@gmail.com>
This commit is contained in:
flow
2022-11-19 13:39:43 -03:00
parent 2367903ac6
commit 6e1639551b
2 changed files with 64 additions and 1 deletions

View File

@ -5,6 +5,8 @@
#include <QMenu>
#include <QToolBar>
#include <memory>
class WideBar : public QToolBar {
Q_OBJECT
@ -22,6 +24,7 @@ class WideBar : public QToolBar {
void insertActionAfter(QAction* after, QAction* action);
QMenu* createContextMenu(QWidget* parent = nullptr, const QString& title = QString());
void contextMenuEvent(QContextMenuEvent*) override;
private:
struct BarEntry {
@ -34,4 +37,8 @@ class WideBar : public QToolBar {
private:
QList<BarEntry> m_entries;
// Menu to toggle visibility from buttons in the bar
std::unique_ptr<QMenu> m_bar_menu = nullptr;
enum class MenuState { Fresh, Dirty } m_menu_state = MenuState::Dirty;
};