Commit 6815b411 authored by LACROIX Romain's avatar LACROIX Romain
Browse files

Bugfix: to support multiple menu bars, we must have a stack per bar, the stack...

Bugfix: to support multiple menu bars, we must have a stack per bar, the stack variable can not be shared between all bars.
Fixes #67
parent 22ce6947
Pipeline #171159 passed with stage
in 0 seconds
......@@ -398,8 +398,6 @@ void dtkWidgetsMenuBarContainerSlide::touch(const QVector<dtkWidgetsMenu *>& men
// dtkWidgetsMenuBarContainer implementation
// ///////////////////////////////////////////////////////////////////
QList<dtkWidgetsMenu *> stack;
dtkWidgetsMenuBarContainer::dtkWidgetsMenuBarContainer(QWidget *parent) : dtkWidgetsOverlayPane(parent)
{
this->slider = new dtkWidgetsOverlayPaneSlider;
......@@ -418,8 +416,8 @@ dtkWidgetsMenuBarContainer::dtkWidgetsMenuBarContainer(QWidget *parent) : dtkWid
return;
dtkWidgetsMenu *menu = nullptr;
if (::stack.count())
menu = ::stack.takeLast();
if (this->stack.count())
menu = this->stack.takeLast();
this->switchToPrevSlide(menu);
});
......@@ -430,6 +428,11 @@ dtkWidgetsMenuBarContainer::~dtkWidgetsMenuBarContainer(void)
}
int dtkWidgetsMenuBarContainer::stackCount(void) const
{
return stack.count();
}
void dtkWidgetsMenuBarContainer::setCurrentIndex(int index, std::function<void ()>& callback)
{
if (this->slider->is_in_transition)
......@@ -450,7 +453,7 @@ void dtkWidgetsMenuBarContainer::setCurrentIndex(int index, std::function<void (
this->slider->setCurrentIndex(index, ca);
};
if (::stack.count())
if (this->stack.count())
this->switchToRoot(cb);
else
cb();
......@@ -468,8 +471,8 @@ void dtkWidgetsMenuBarContainer::switchToRoot(std::function<void(void)> &callbac
static std::function<void(void)> cb = [=](void) -> void
{
while (!::stack.isEmpty())
this->slider->remSlide(this->slides[::stack.takeLast()]);
while (!this->stack.isEmpty())
this->slider->remSlide(this->slides[this->stack.takeLast()]);
callback();
......@@ -488,8 +491,8 @@ void dtkWidgetsMenuBarContainer::switchToPrevSlide(dtkWidgetsMenu *m)
if (m)
emit q->left(m);
if (::stack.count())
this->navigator->setMenu(::stack.last());
if (this->stack.count())
this->navigator->setMenu(this->stack.last());
else
this->navigator->setMenu(0);
......@@ -506,8 +509,8 @@ void dtkWidgetsMenuBarContainer::switchToPrevSlide(dtkWidgetsMenu *m)
this->slider->slideToPrevious(callback);
}
if(::stack.count())
emit q->entered(::stack.last());
if(this->stack.count())
emit q->entered(this->stack.last());
}
void dtkWidgetsMenuBarContainer::switchToNextSlide(dtkWidgetsMenu *m)
......@@ -515,15 +518,15 @@ void dtkWidgetsMenuBarContainer::switchToNextSlide(dtkWidgetsMenu *m)
if (this->slider->is_in_transition)
return;
if(::stack.count())
emit q->left(::stack.last());
if(this->stack.count())
emit q->left(this->stack.last());
this->slider->addSlide(fa::cogs, this->slides[m]);
this->slider->slideToNext();
this->navigator->setMenu(m);
::stack << m;
this->stack << m;
emit q->entered(m);
}
......@@ -533,7 +536,7 @@ void dtkWidgetsMenuBarContainer::touch(void)
if (this->slider->is_in_transition)
return;
::stack.clear();
this->stack.clear();
navigator->setMenu(0);
this->master_slide->touch(this->master_menus, this);
}
......@@ -543,7 +546,7 @@ void dtkWidgetsMenuBarContainer::touch(dtkWidgetsMenuBar *mb)
if (this->slider->is_in_transition)
return;
::stack.clear();
this->stack.clear();
navigator->setMenu(0);
if(!this->master_slide) {
......@@ -576,7 +579,7 @@ void dtkWidgetsMenuBarContainer::decr(void)
this->slider->decr();
::stack.takeLast();
this->stack.takeLast();
}
void dtkWidgetsMenuBarContainer::build(const QVector<dtkWidgetsMenu *>& menus)
......@@ -1123,7 +1126,7 @@ QDebug operator<<(QDebug debug, const dtkWidgetsMenuBar &c)
{
debug << "MenuBar state in ";
debug << "d->layout->count() = " << c.d->layout->count();
debug << "::stack.count() = " << ::stack.count();
debug << "d->c->stackCount() = " << c.d->c->stackCount();
//c.d->c->slider->print();
return debug;
}
......@@ -1132,7 +1135,7 @@ QDebug operator<<(QDebug debug, dtkWidgetsMenuBar *c)
{
debug << "MenuBar state in ";
debug << "d->layout->count() = " << c->d->layout->count();
debug << "::stack.count() = " << ::stack.count();
debug << "d->c->stackCount() = " << c->d->c->stackCount();
//c->d->c->slider->print();
return debug;
}
......
......@@ -83,11 +83,13 @@ public:
public:
QVector<dtkWidgetsMenu *> master_menus;
int stackCount(void) const;
// /////////////////////////////////////////////////////////////////////////////
private:
friend class dtkWidgetsMenuBarButton;
QList<dtkWidgetsMenu *> stack;
};
// ///////////////////////////////////////////////////////////////////
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment