Fix button being present in other pages

This commit is contained in:
timoreo
2022-01-28 19:32:42 +01:00
parent 8b790a6dd9
commit efc44c56a6
4 changed files with 20 additions and 9 deletions

View File

@ -76,6 +76,20 @@ void WideBar::addSeparator()
m_entries.push_back(entry);
}
void WideBar::insertActionBefore(QAction* before, QAction* action){
auto iter = std::find_if(m_entries.begin(), m_entries.end(), [before](BarEntry * entry) {
return entry->wideAction == before;
});
if(iter == m_entries.end()) {
return;
}
auto entry = new BarEntry();
entry->qAction = insertWidget((*iter)->qAction, new ActionButton(action, this));
entry->wideAction = action;
entry->type = BarEntry::Action;
m_entries.insert(iter, entry);
}
void WideBar::insertSpacer(QAction* action)
{
auto iter = std::find_if(m_entries.begin(), m_entries.end(), [action](BarEntry * entry) {

View File

@ -18,6 +18,7 @@ public:
void addAction(QAction *action);
void addSeparator();
void insertSpacer(QAction *action);
void insertActionBefore(QAction *before, QAction *action);
QMenu *createContextMenu(QWidget *parent = nullptr, const QString & title = QString());
private: