15 #include <QDialogButtonBox>
16 #include <QPushButton>
34 mMenuButton->setStyleSheet( QStringLiteral(
"QToolButton::menu-indicator { image: none; }" ) );
43 Qt::UniqueConnection );
44 mStackedWidget->insertWidget( 0, panel );
45 mStackedWidget->setCurrentIndex( 0 );
50 return qobject_cast<QgsPanelWidget *>( mStackedWidget->widget( 0 ) );
58 QWidget *widget = mStackedWidget->widget( 0 );
59 mStackedWidget->removeWidget( widget );
60 return qobject_cast<QgsPanelWidget *>( widget );
65 for (
int i = mStackedWidget->count() - 1; i >= 0; i-- )
67 if (
QgsPanelWidget *panelWidget = qobject_cast<QgsPanelWidget *>( mStackedWidget->widget( i ) ) )
69 mStackedWidget->removeWidget( panelWidget );
70 if ( panelWidget->autoDelete() )
72 panelWidget->deleteLater();
75 else if ( QWidget *widget = mStackedWidget->widget( i ) )
77 mStackedWidget->removeWidget( widget );
78 widget->deleteLater();
85 this->updateBreadcrumb();
90 return qobject_cast<QgsPanelWidget *>( mStackedWidget->currentWidget() );
96 if ( mStackedWidget->currentIndex() <= 0 )
106 setUpdatesEnabled(
false );
107 mStackedWidget->setUpdatesEnabled(
false );
109 for (
int i = mStackedWidget->count() - 1; i > 0; --i )
111 if (
QgsPanelWidget *panelWidget = qobject_cast<QgsPanelWidget *>( mStackedWidget->widget( i ) ) )
113 panelWidget->acceptPanel();
116 setUpdatesEnabled(
true );
117 mStackedWidget->setUpdatesEnabled(
true );
127 int index = mStackedWidget->addWidget( panel );
128 mStackedWidget->setCurrentIndex( index );
139 mStackedWidget->setCurrentIndex( mStackedWidget->currentIndex() - 1 );
140 mStackedWidget->removeWidget( panel );
143 panel->deleteLater();
146 if ( mStackedWidget->currentIndex() == 0 )
156 this->updateBreadcrumb();
161 if ( e->button() == Qt::BackButton )
169 if ( e->key() == Qt::Key_Escape )
175 void QgsPanelWidgetStack::updateBreadcrumb()
178 const auto constMTitles = mTitles;
179 for ( QString title : constMTitles )
181 breadcrumb += QStringLiteral(
" %1 >" ).arg( title );
184 breadcrumb.chop( 1 );
185 mTitleText->setText( breadcrumb );
188 void QgsPanelWidgetStack::updateMenuButton()
192 mMenuButton->setVisible(
true );
193 mMenuButton->setToolTip(
currentPanel()->menuButtonTooltip() );
194 mMenuButton->setMenu( menu );
198 mMenuButton->setVisible(
false );