15#include <QDialogButtonBox>
23#include "moc_qgspanelwidgetstack.cpp"
35 mMenuButton->setStyleSheet( QStringLiteral(
"QToolButton::menu-indicator { image: none; }" ) );
44 Qt::UniqueConnection );
45 mStackedWidget->insertWidget( 0, panel );
46 mStackedWidget->setCurrentIndex( 0 );
52 return qobject_cast<QgsPanelWidget *>( mStackedWidget->widget( 0 ) );
60 QWidget *widget = mStackedWidget->widget( 0 );
63 mStackedWidget->removeWidget( widget );
64 return qobject_cast<QgsPanelWidget *>( widget );
74 for (
int i = mStackedWidget->count() - 1; i >= 0; i-- )
76 if (
QgsPanelWidget *panelWidget = qobject_cast<QgsPanelWidget *>( mStackedWidget->widget( i ) ) )
78 mStackedWidget->removeWidget( panelWidget );
79 if ( panelWidget->autoDelete() )
81 panelWidget->deleteLater();
84 else if ( QWidget *widget = mStackedWidget->widget( i ) )
86 mStackedWidget->removeWidget( widget );
87 widget->deleteLater();
94 this->updateBreadcrumb();
99 return qobject_cast<QgsPanelWidget *>( mStackedWidget->currentWidget() );
104 if (
const QgsPanelWidget *widget = qobject_cast<const QgsPanelWidget *>( mStackedWidget->currentWidget() ) )
106 if ( widget->applySizeConstraintsToStack() )
107 return widget->sizeHint();
109 return QWidget::sizeHint();
114 if (
const QgsPanelWidget *widget = qobject_cast<const QgsPanelWidget *>( mStackedWidget->currentWidget() ) )
116 if ( widget->applySizeConstraintsToStack() )
117 return widget->minimumSizeHint();
120 return QWidget::minimumSizeHint();
126 if ( mStackedWidget->currentIndex() <= 0 )
136 setUpdatesEnabled(
false );
137 mStackedWidget->setUpdatesEnabled(
false );
139 for (
int i = mStackedWidget->count() - 1; i > 0; --i )
141 if (
QgsPanelWidget *panelWidget = qobject_cast<QgsPanelWidget *>( mStackedWidget->widget( i ) ) )
143 panelWidget->acceptPanel();
146 setUpdatesEnabled(
true );
147 mStackedWidget->setUpdatesEnabled(
true );
157 const int index = mStackedWidget->addWidget( panel );
158 mStackedWidget->setCurrentIndex( index );
169 mStackedWidget->setCurrentIndex( mStackedWidget->currentIndex() - 1 );
170 mStackedWidget->removeWidget( panel );
173 panel->deleteLater();
176 if ( mStackedWidget->currentIndex() == 0 )
186 this->updateBreadcrumb();
191 if ( e->button() == Qt::BackButton )
199 if ( e->key() == Qt::Key_Escape )
205void QgsPanelWidgetStack::updateBreadcrumb()
208 const auto constMTitles = mTitles;
209 for (
const QString &title : constMTitles )
211 breadcrumb += QStringLiteral(
" %1 >" ).arg( title );
214 breadcrumb.chop( 1 );
215 mTitleText->setText( breadcrumb );
218void QgsPanelWidgetStack::updateMenuButton()
222 mMenuButton->setVisible(
true );
223 mMenuButton->setToolTip(
currentPanel()->menuButtonTooltip() );
224 mMenuButton->setMenu( menu );
228 mMenuButton->setVisible(
false );