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() );
95 if (
const QgsPanelWidget *widget = qobject_cast<const QgsPanelWidget *>( mStackedWidget->currentWidget() ) )
97 if ( widget->applySizeConstraintsToStack() )
98 return widget->sizeHint();
100 return QWidget::sizeHint();
105 if (
const QgsPanelWidget *widget = qobject_cast<const QgsPanelWidget *>( mStackedWidget->currentWidget() ) )
107 if ( widget->applySizeConstraintsToStack() )
108 return widget->minimumSizeHint();
111 return QWidget::minimumSizeHint();
117 if ( mStackedWidget->currentIndex() <= 0 )
127 setUpdatesEnabled(
false );
128 mStackedWidget->setUpdatesEnabled(
false );
130 for (
int i = mStackedWidget->count() - 1; i > 0; --i )
132 if (
QgsPanelWidget *panelWidget = qobject_cast<QgsPanelWidget *>( mStackedWidget->widget( i ) ) )
134 panelWidget->acceptPanel();
137 setUpdatesEnabled(
true );
138 mStackedWidget->setUpdatesEnabled(
true );
148 const int index = mStackedWidget->addWidget( panel );
149 mStackedWidget->setCurrentIndex( index );
160 mStackedWidget->setCurrentIndex( mStackedWidget->currentIndex() - 1 );
161 mStackedWidget->removeWidget( panel );
164 panel->deleteLater();
167 if ( mStackedWidget->currentIndex() == 0 )
177 this->updateBreadcrumb();
182 if ( e->button() == Qt::BackButton )
190 if ( e->key() == Qt::Key_Escape )
196 void QgsPanelWidgetStack::updateBreadcrumb()
199 const auto constMTitles = mTitles;
200 for (
const QString &title : constMTitles )
202 breadcrumb += QStringLiteral(
" %1 >" ).arg( title );
205 breadcrumb.chop( 1 );
206 mTitleText->setText( breadcrumb );
209 void QgsPanelWidgetStack::updateMenuButton()
213 mMenuButton->setVisible(
true );
214 mMenuButton->setToolTip(
currentPanel()->menuButtonTooltip() );
215 mMenuButton->setMenu( menu );
219 mMenuButton->setVisible(
false );