15#include <QDialogButtonBox>
34 mMenuButton->setStyleSheet( QStringLiteral(
"QToolButton::menu-indicator { image: none; }" ) );
43 Qt::UniqueConnection );
44 mStackedWidget->insertWidget( 0, panel );
45 mStackedWidget->setCurrentIndex( 0 );
51 return qobject_cast<QgsPanelWidget *>( mStackedWidget->widget( 0 ) );
59 QWidget *widget = mStackedWidget->widget( 0 );
62 mStackedWidget->removeWidget( widget );
63 return qobject_cast<QgsPanelWidget *>( widget );
73 for (
int i = mStackedWidget->count() - 1; i >= 0; i-- )
75 if (
QgsPanelWidget *panelWidget = qobject_cast<QgsPanelWidget *>( mStackedWidget->widget( i ) ) )
77 mStackedWidget->removeWidget( panelWidget );
78 if ( panelWidget->autoDelete() )
80 panelWidget->deleteLater();
83 else if ( QWidget *widget = mStackedWidget->widget( i ) )
85 mStackedWidget->removeWidget( widget );
86 widget->deleteLater();
93 this->updateBreadcrumb();
98 return qobject_cast<QgsPanelWidget *>( mStackedWidget->currentWidget() );
103 if (
const QgsPanelWidget *widget = qobject_cast<const QgsPanelWidget *>( mStackedWidget->currentWidget() ) )
105 if ( widget->applySizeConstraintsToStack() )
106 return widget->sizeHint();
108 return QWidget::sizeHint();
113 if (
const QgsPanelWidget *widget = qobject_cast<const QgsPanelWidget *>( mStackedWidget->currentWidget() ) )
115 if ( widget->applySizeConstraintsToStack() )
116 return widget->minimumSizeHint();
119 return QWidget::minimumSizeHint();
125 if ( mStackedWidget->currentIndex() <= 0 )
135 setUpdatesEnabled(
false );
136 mStackedWidget->setUpdatesEnabled(
false );
138 for (
int i = mStackedWidget->count() - 1; i > 0; --i )
140 if (
QgsPanelWidget *panelWidget = qobject_cast<QgsPanelWidget *>( mStackedWidget->widget( i ) ) )
142 panelWidget->acceptPanel();
145 setUpdatesEnabled(
true );
146 mStackedWidget->setUpdatesEnabled(
true );
156 const int index = mStackedWidget->addWidget( panel );
157 mStackedWidget->setCurrentIndex( index );
168 mStackedWidget->setCurrentIndex( mStackedWidget->currentIndex() - 1 );
169 mStackedWidget->removeWidget( panel );
172 panel->deleteLater();
175 if ( mStackedWidget->currentIndex() == 0 )
185 this->updateBreadcrumb();
190 if ( e->button() == Qt::BackButton )
198 if ( e->key() == Qt::Key_Escape )
204void QgsPanelWidgetStack::updateBreadcrumb()
207 const auto constMTitles = mTitles;
208 for (
const QString &title : constMTitles )
210 breadcrumb += QStringLiteral(
" %1 >" ).arg( title );
213 breadcrumb.chop( 1 );
214 mTitleText->setText( breadcrumb );
217void QgsPanelWidgetStack::updateMenuButton()
221 mMenuButton->setVisible(
true );
222 mMenuButton->setToolTip(
currentPanel()->menuButtonTooltip() );
223 mMenuButton->setMenu( menu );
227 mMenuButton->setVisible(
false );