Commit c1a4e8e3 authored by WINTZ Julien's avatar WINTZ Julien

Fixing inner stack of menus in the context of dynamic layer deletions.

parent f50f91a2
......@@ -376,9 +376,13 @@ dtkWidgetsMenuBarContainer::dtkWidgetsMenuBarContainer(QWidget *parent) : dtkWid
{
dtkWidgetsMenu *menu = nullptr;
// qDebug() << "dtkWidgetsMenuBarContainer::dtkWidgetsMenuBarContainer" << Q_FUNC_INFO << 1 << ::stack;
if (::stack.count())
menu = ::stack.takeLast();
// qDebug() << "dtkWidgetsMenuBarContainer::dtkWidgetsMenuBarContainer" << Q_FUNC_INFO << 2 << ::stack;
this->switchToPrevSlide(menu);
});
}
......@@ -405,10 +409,14 @@ void dtkWidgetsMenuBarContainer::setCurrentIndex(int index, std::function<void (
this->slider->setCurrentIndex(index, ca);
};
// qDebug() << Q_FUNC_INFO << 1 << ::stack;
if (::stack.count())
this->switchToRoot(cb);
else
cb();
// qDebug() << Q_FUNC_INFO << 2 << ::stack;
}
void dtkWidgetsMenuBarContainer::switchToRoot(std::function<void(void)> &callback)
......@@ -420,9 +428,13 @@ void dtkWidgetsMenuBarContainer::switchToRoot(std::function<void(void)> &callbac
static std::function<void(void)> cb = [=](void) -> void
{
// qDebug() << "dtkWidgetsMenuBarContainer::switchToRoot" << Q_FUNC_INFO << 1 << ::stack;
while (!::stack.isEmpty())
this->slider->remSlide(this->slides[::stack.takeLast()]);
// qDebug() << "dtkWidgetsMenuBarContainer::switchToRoot" << Q_FUNC_INFO << 2 << ::stack;
callback();
this->slider->blockSignals(false);
......@@ -436,6 +448,8 @@ void dtkWidgetsMenuBarContainer::switchToPrevSlide(dtkWidgetsMenu *m)
{
emit q->left(m);
// qDebug() << Q_FUNC_INFO << 1 << ::stack;
if (::stack.count())
this->navigator->setMenu(::stack.last());
else
......@@ -443,7 +457,11 @@ void dtkWidgetsMenuBarContainer::switchToPrevSlide(dtkWidgetsMenu *m)
std::function<void()> callback = [=] (void) -> void
{
// qDebug() << "dtkWidgetsMenuBarContainer::switchToPrevSlide" << Q_FUNC_INFO << 1 << ::stack;
this->slider->remSlide(this->slides[m]);
// qDebug() << "dtkWidgetsMenuBarContainer::switchToPrevSlide" << Q_FUNC_INFO << 2 << ::stack;
};
if (!m) {
......@@ -454,6 +472,8 @@ void dtkWidgetsMenuBarContainer::switchToPrevSlide(dtkWidgetsMenu *m)
this->slider->slideToPrevious(callback);
}
// qDebug() << Q_FUNC_INFO << 2 << ::stack;
if(::stack.count())
emit q->entered(::stack.last());
}
......@@ -468,8 +488,12 @@ void dtkWidgetsMenuBarContainer::switchToNextSlide(dtkWidgetsMenu *m)
this->navigator->setMenu(m);
// qDebug() << Q_FUNC_INFO << 1 << ::stack;
::stack << m;
// qDebug() << Q_FUNC_INFO << 2 << ::stack;
emit q->entered(m);
}
......@@ -497,6 +521,11 @@ void dtkWidgetsMenuBarContainer::touch(dtkWidgetsMenuBar *mb)
this->buildChildSlide(mm);
}
void dtkWidgetsMenuBarContainer::decr(void)
{
::stack.takeLast();
}
void dtkWidgetsMenuBarContainer::build(const QVector<dtkWidgetsMenu *>& menus)
{
if(!this->master_slide) {
......@@ -885,6 +914,11 @@ void dtkWidgetsMenuBar::touch(void)
d->c->touch(this);
}
void dtkWidgetsMenuBar::decr(void)
{
d->c->decr();
}
// /////////////////////////////////////////////////////////////////////////////
#include "dtkWidgetsMenuBar.moc"
......
......@@ -114,9 +114,12 @@ public:
public slots:
void setFixedHeight(int);
#pragma mark - Dynamism
public slots:
void touch(void);
void decr(void);
protected:
void resizeEvent(QResizeEvent *) override;
void mousePressEvent(QMouseEvent *event) override;
......
......@@ -54,6 +54,9 @@ public slots:
void switchToPrevSlide(dtkWidgetsMenu *);
void switchToNextSlide(dtkWidgetsMenu *);
public:
void decr(void); // NOTE: Use with caution
public:
void build(const QVector<dtkWidgetsMenu *>&);
void buildChildSlide(dtkWidgetsMenu *);
......
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