From e097443771f9ab350a1cbedd009e34be5079b6e7 Mon Sep 17 00:00:00 2001 From: Nathan Date: Thu, 7 Jul 2016 09:22:30 +1000 Subject: [PATCH] Fix globe plugin --- python/gui/gui.sip | 1 + python/gui/qgsmaplayerconfigwidgetfactory.sip | 4 + python/gui/qgspanelwidget.sip | 72 ---------- python/gui/qgspanelwidgetstack.sip | 71 +++++++++ .../raster/qgsrastertransparencywidget.sip | 2 +- src/app/qgslayerstylingwidget.cpp | 2 +- src/app/qgsvectorlayerproperties.cpp | 16 ++- src/gui/CMakeLists.txt | 2 + src/gui/qgsmaplayerconfigwidgetfactory.h | 12 ++ src/gui/qgspanelwidget.cpp | 112 +-------------- src/gui/qgspanelwidget.h | 78 ---------- src/gui/qgspanelwidgetstack.cpp | 135 ++++++++++++++++++ src/gui/qgspanelwidgetstack.h | 101 +++++++++++++ src/plugins/globe/globe_plugin.cpp | 4 +- .../globe/qgsglobevectorlayerproperties.cpp | 24 +++- .../globe/qgsglobevectorlayerproperties.h | 22 ++- .../qgsglobevectorlayerpropertiespage.ui | 8 +- src/ui/qgsmapstylingwidgetbase.ui | 28 +++- 18 files changed, 400 insertions(+), 294 deletions(-) create mode 100644 python/gui/qgspanelwidgetstack.sip create mode 100644 src/gui/qgspanelwidgetstack.cpp create mode 100644 src/gui/qgspanelwidgetstack.h diff --git a/python/gui/gui.sip b/python/gui/gui.sip index db87d45e755..a9eac813576 100644 --- a/python/gui/gui.sip +++ b/python/gui/gui.sip @@ -136,6 +136,7 @@ %Include qgsorderbydialog.sip %Include qgsowssourceselect.sip %Include qgspanelwidget.sip +%Include qgspanelwidgetstack.sip %Include qgspixmaplabel.sip %Include qgspluginmanagerinterface.sip %Include qgsprevieweffect.sip diff --git a/python/gui/qgsmaplayerconfigwidgetfactory.sip b/python/gui/qgsmaplayerconfigwidgetfactory.sip index 06231485b97..362b6d409ab 100644 --- a/python/gui/qgsmaplayerconfigwidgetfactory.sip +++ b/python/gui/qgsmaplayerconfigwidgetfactory.sip @@ -29,6 +29,10 @@ class QgsMapLayerConfigWidgetFactory */ virtual QString title() const; + virtual bool supportsStyleDock() const; + + virtual bool supportLayerPropertiesDialog() const; + /** * @brief Check if the layer is supported for this widget. * @return True if this layer is supported for this widget diff --git a/python/gui/qgspanelwidget.sip b/python/gui/qgspanelwidget.sip index f800fdfc4cf..c1fee46b14b 100644 --- a/python/gui/qgspanelwidget.sip +++ b/python/gui/qgspanelwidget.sip @@ -156,75 +156,3 @@ class QgsPanelWidgetWrapper: public QgsPanelWidget */ QWidget* widget(); }; - -/** - * A stack widget to manage panels in the interface. Handles the open and close events - * for added panels. - * Any widgets that want to have a non blocking panel based interface should use this - * class to manage the panels. - */ -class QgsPanelWidgetStack: public QWidget -{ -%TypeHeaderCode -#include "qgspanelwidget.h" -%End - public: - - /** - * A stack widget to manage panels in the interface. Handles the open and close events - * for added panels. - * @param parent - */ - QgsPanelWidgetStack( QWidget* parent = nullptr ); - - /** - * Adds the main widget to the stack and selects it for the user - * The main widget can not be closed and only the showPanel signal is attached - * to handle children widget opening panels. - * @param panel The panel to set as the first widget in the stack. - */ - void addMainPanel( QgsPanelWidget* panel ); - - /** - * The main widget that is set in the stack. The main widget can not be closed - * and doesn't display a back button. - * @return The main QgsPanelWidget that is active in the stack. - */ - QgsPanelWidget* mainWidget(); - - /** - * Removes the main widget from the stack and transfers ownsership to the - * caller. - * @return The main widget that is set in the stack. - */ - QgsPanelWidget* takeMainWidget(); - - /** - * Clear the stack of all widgets. Unless the panels autoDelete is set to false - * the widget will be deleted. - */ - void clear(); - - - public slots: - /** - * Accept the current active widget in the stack. - * - * Calls the panelAccepeted signal on the active widget. - */ - void acceptCurrentPanel(); - - /** - * Show a panel in the stack widget. Will connect to the panels showPanel event to handle - * nested panels. Auto switches the the given panel for the user. - * @param panel The panel to show. - */ - void showPanel( QgsPanelWidget* panel ); - - /** - * Closes the panel in the widget. Will also delete the widget. - * This slot is normally auto connected to panelAccepted when a panel is shown. - * @param panel The panel to close. - */ - void closePanel( QgsPanelWidget* panel ); -}; diff --git a/python/gui/qgspanelwidgetstack.sip b/python/gui/qgspanelwidgetstack.sip new file mode 100644 index 00000000000..e13357945f6 --- /dev/null +++ b/python/gui/qgspanelwidgetstack.sip @@ -0,0 +1,71 @@ +/** + * A stack widget to manage panels in the interface. Handles the open and close events + * for added panels. + * Any widgets that want to have a non blocking panel based interface should use this + * class to manage the panels. + */ +class QgsPanelWidgetStack: public QWidget +{ +%TypeHeaderCode +#include "qgspanelwidgetstack.h" +%End + public: + + /** + * A stack widget to manage panels in the interface. Handles the open and close events + * for added panels. + * @param parent + */ + QgsPanelWidgetStack( QWidget* parent = nullptr ); + + /** + * Adds the main widget to the stack and selects it for the user + * The main widget can not be closed and only the showPanel signal is attached + * to handle children widget opening panels. + * @param panel The panel to set as the first widget in the stack. + */ + void addMainPanel( QgsPanelWidget* panel ); + + /** + * The main widget that is set in the stack. The main widget can not be closed + * and doesn't display a back button. + * @return The main QgsPanelWidget that is active in the stack. + */ + QgsPanelWidget* mainWidget(); + + /** + * Removes the main widget from the stack and transfers ownsership to the + * caller. + * @return The main widget that is set in the stack. + */ + QgsPanelWidget* takeMainWidget(); + + /** + * Clear the stack of all widgets. Unless the panels autoDelete is set to false + * the widget will be deleted. + */ + void clear(); + + + public slots: + /** + * Accept the current active widget in the stack. + * + * Calls the panelAccepeted signal on the active widget. + */ + void acceptCurrentPanel(); + + /** + * Show a panel in the stack widget. Will connect to the panels showPanel event to handle + * nested panels. Auto switches the the given panel for the user. + * @param panel The panel to show. + */ + void showPanel( QgsPanelWidget* panel ); + + /** + * Closes the panel in the widget. Will also delete the widget. + * This slot is normally auto connected to panelAccepted when a panel is shown. + * @param panel The panel to close. + */ + void closePanel( QgsPanelWidget* panel ); +}; diff --git a/python/gui/raster/qgsrastertransparencywidget.sip b/python/gui/raster/qgsrastertransparencywidget.sip index b09340ead01..8729d72e1e3 100644 --- a/python/gui/raster/qgsrastertransparencywidget.sip +++ b/python/gui/raster/qgsrastertransparencywidget.sip @@ -1,7 +1,7 @@ /** * @brief Widget to control a layers transparency and related options */ -class QgsRasterTransparencyWidget: QgsPanelWidgetStack +class QgsRasterTransparencyWidget: QgsMapLayerConfigWidget { %TypeHeaderCode #include diff --git a/src/app/qgslayerstylingwidget.cpp b/src/app/qgslayerstylingwidget.cpp index bc15c1db79b..3db58d91915 100644 --- a/src/app/qgslayerstylingwidget.cpp +++ b/src/app/qgslayerstylingwidget.cpp @@ -173,7 +173,7 @@ void QgsLayerStylingWidget::setLayer( QgsMapLayer *layer ) Q_FOREACH ( QgsMapLayerConfigWidgetFactory* factory, mPageFactories ) { - if ( factory->supportsLayer( layer ) ) + if ( factory->supportsStyleDock() && factory->supportsLayer( layer ) ) { QListWidgetItem* item = new QListWidgetItem( factory->icon(), QString() ); mOptionsListWidget->addItem( item ); diff --git a/src/app/qgsvectorlayerproperties.cpp b/src/app/qgsvectorlayerproperties.cpp index b6a013852fa..d4c70829b62 100644 --- a/src/app/qgsvectorlayerproperties.cpp +++ b/src/app/qgsvectorlayerproperties.cpp @@ -329,19 +329,21 @@ void QgsVectorLayerProperties::setLabelCheckBox() void QgsVectorLayerProperties::addPropertiesPageFactory( QgsMapLayerConfigWidgetFactory* factory ) { + if ( !factory->supportLayerPropertiesDialog() ) + { + return; + } + QListWidgetItem* item = new QListWidgetItem(); item->setIcon( factory->icon() ); item->setText( factory->title() ); item->setToolTip( factory->title() ); - if ( item ) - { - mOptionsListWidget->addItem( item ); + mOptionsListWidget->addItem( item ); - QgsMapLayerConfigWidget* page = factory->createWidget( mLayer, nullptr, false, this ); - mLayerPropertiesPages << page; - mOptionsStackedWidget->addWidget( page ); - } + QgsMapLayerConfigWidget* page = factory->createWidget( mLayer, nullptr, false, this ); + mLayerPropertiesPages << page; + mOptionsStackedWidget->addWidget( page ); } void QgsVectorLayerProperties::insertField() diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index cf8d1af09f5..fc352e49355 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -275,6 +275,7 @@ SET(QGIS_GUI_SRCS qgsowssourceselect.cpp qgssourceselectdialog.cpp qgspanelwidget.cpp + qgspanelwidgetstack.cpp qgspixmaplabel.cpp qgspluginmanagerinterface.cpp qgsprevieweffect.cpp @@ -425,6 +426,7 @@ SET(QGIS_GUI_MOC_HDRS qgsowssourceselect.h qgssourceselectdialog.h qgspanelwidget.h + qgspanelwidgetstack.h qgspixmaplabel.h qgspluginmanagerinterface.h qgsprevieweffect.h diff --git a/src/gui/qgsmaplayerconfigwidgetfactory.h b/src/gui/qgsmaplayerconfigwidgetfactory.h index 17525e78ded..abcdcbd13c3 100644 --- a/src/gui/qgsmaplayerconfigwidgetfactory.h +++ b/src/gui/qgsmaplayerconfigwidgetfactory.h @@ -47,6 +47,18 @@ class GUI_EXPORT QgsMapLayerConfigWidgetFactory */ virtual QString title() const { return QString(); } + /** + * Flag if widget is supported for use in style dock. + * @return True if supported + */ + virtual bool supportsStyleDock() const { return false; } + + /** + * Flag if widget is supported for use in layer properties dialog. + * @return True if supported + */ + virtual bool supportLayerPropertiesDialog() const { return false; } + /** * @brief Check if the layer is supported for this widget. * @return True if this layer is supported for this widget diff --git a/src/gui/qgspanelwidget.cpp b/src/gui/qgspanelwidget.cpp index 7bf43d2bdd5..fa009c3311d 100644 --- a/src/gui/qgspanelwidget.cpp +++ b/src/gui/qgspanelwidget.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include "qgspanelwidget.h" #include "qgslogger.h" @@ -84,117 +85,6 @@ void QgsPanelWidget::keyPressEvent( QKeyEvent *event ) } } -QgsPanelWidgetStack::QgsPanelWidgetStack( QWidget *parent ) - : QWidget( parent ) -{ - setupUi( this ); - clear(); - - connect( mBackButton, SIGNAL( pressed() ), this, SLOT( acceptCurrentPanel() ) ); -} - -void QgsPanelWidgetStack::addMainPanel( QgsPanelWidget *panel ) -{ - // TODO Don't allow adding another main widget or else that would be strange for the user. - connect( panel, SIGNAL( showPanel( QgsPanelWidget* ) ), this, SLOT( showPanel( QgsPanelWidget* ) ), - // using unique connection because addMainPanel() may be called multiple times - // for a panel, so showPanel() slot could be invoked more times from one signal - Qt::UniqueConnection ); - mStackedWidget->insertWidget( 0, panel ); - mStackedWidget->setCurrentIndex( 0 ); -} - -QgsPanelWidget *QgsPanelWidgetStack::mainWidget() -{ - return qobject_cast( mStackedWidget->widget( 0 ) ); -} - -QgsPanelWidget *QgsPanelWidgetStack::takeMainWidget() -{ - QWidget* widget = mStackedWidget->widget( 0 ); - mStackedWidget->removeWidget( widget ); - return qobject_cast( widget ); -} - -void QgsPanelWidgetStack::clear() -{ - for ( int i = mStackedWidget->count(); i >= 0; i-- ) - { - if ( QgsPanelWidget* panelWidget = qobject_cast( mStackedWidget->widget( i ) ) ) - { - mStackedWidget->removeWidget( panelWidget ); - if ( panelWidget->autoDelete() ) - { - panelWidget->deleteLater(); - } - } - else if ( QWidget* widget = mStackedWidget->widget( i ) ) - { - mStackedWidget->removeWidget( widget ); - widget->deleteLater(); - } - } - mTitles.clear(); - mTitleText->hide(); - mBackButton->hide(); - this->updateBreadcrumb(); -} - -void QgsPanelWidgetStack::acceptCurrentPanel() -{ - // You can't accept the main panel. - if ( mStackedWidget->currentIndex() == 0 ) - return; - - QgsPanelWidget* widget = qobject_cast( mStackedWidget->currentWidget() ); - widget->acceptPanel(); -} - -void QgsPanelWidgetStack::showPanel( QgsPanelWidget *panel ) -{ - mTitles.push( panel->panelTitle() ); - - connect( panel, SIGNAL( panelAccepted( QgsPanelWidget* ) ), this, SLOT( closePanel( QgsPanelWidget* ) ) ); - connect( panel, SIGNAL( showPanel( QgsPanelWidget* ) ), this, SLOT( showPanel( QgsPanelWidget* ) ) ); - - int index = mStackedWidget->addWidget( panel ); - mStackedWidget->setCurrentIndex( index ); - mBackButton->show(); - mTitleText->show(); - - this->updateBreadcrumb(); -} - -void QgsPanelWidgetStack::closePanel( QgsPanelWidget *panel ) -{ - mTitles.pop(); - mStackedWidget->setCurrentIndex( mStackedWidget->currentIndex() - 1 ); - mStackedWidget->removeWidget( panel ); - if ( panel->autoDelete() ) - { - panel->deleteLater(); - } - - if ( mStackedWidget->currentIndex() == 0 ) - { - mBackButton->hide(); - mTitleText->hide(); - } - this->updateBreadcrumb(); -} - -void QgsPanelWidgetStack::updateBreadcrumb() -{ - QString breadcrumb; - Q_FOREACH ( QString title, mTitles ) - { - breadcrumb += QString( " %1 >" ).arg( title ); - } - // Remove the last - breadcrumb.chop( 1 ); - mTitleText->setText( breadcrumb ); -} - QgsPanelWidgetWrapper::QgsPanelWidgetWrapper( QWidget *widget, QWidget *parent ) : QgsPanelWidget( parent ) , mWidget( widget ) diff --git a/src/gui/qgspanelwidget.h b/src/gui/qgspanelwidget.h index 91a49dcd8e8..aee623d6f0d 100644 --- a/src/gui/qgspanelwidget.h +++ b/src/gui/qgspanelwidget.h @@ -17,12 +17,8 @@ #include #include -#include #include -#include "ui_qgsrenderercontainerbase.h" - - /** \ingroup gui * @brief Base class for any widget that can be shown as a inline panel */ @@ -188,78 +184,4 @@ class GUI_EXPORT QgsPanelWidgetWrapper: public QgsPanelWidget }; - -/** \ingroup gui - * A stack widget to manage panels in the interface. Handles the open and close events - * for added panels. - * Any widgets that want to have a non blocking panel based interface should use this - * class to manage the panels. - */ -class GUI_EXPORT QgsPanelWidgetStack : public QWidget, private Ui::QgsRendererWidgetContainerBase -{ - Q_OBJECT - public: - - /** - * A stack widget to manage panels in the interface. Handles the open and close events - * for added panels. - * @param parent - */ - QgsPanelWidgetStack( QWidget* parent = nullptr ); - - /** - * Adds the main widget to the stack and selects it for the user - * The main widget can not be closed and only the showPanel signal is attached - * to handle children widget opening panels. - * @param panel The panel to set as the first widget in the stack. - */ - void addMainPanel( QgsPanelWidget* panel ); - - /** - * The main widget that is set in the stack. The main widget can not be closed - * and doesn't display a back button. - * @return The main QgsPanelWidget that is active in the stack. - */ - QgsPanelWidget* mainWidget(); - - /** - * Removes the main widget from the stack and transfers ownsership to the - * caller. - * @return The main widget that is set in the stack. - */ - QgsPanelWidget* takeMainWidget(); - - /** - * Clear the stack of all widgets. Unless the panels autoDelete is set to false - * the widget will be deleted. - */ - void clear(); - - public slots: - /** - * Accept the current active widget in the stack. - * - * Calls the panelAccepeted signal on the active widget. - */ - void acceptCurrentPanel(); - - /** - * Show a panel in the stack widget. Will connect to the panels showPanel event to handle - * nested panels. Auto switches the the given panel for the user. - * @param panel The panel to show. - */ - void showPanel( QgsPanelWidget* panel ); - - /** - * Closes the panel in the widget. Will also delete the widget. - * This slot is normally auto connected to panelAccepted when a panel is shown. - * @param panel The panel to close. - */ - void closePanel( QgsPanelWidget* panel ); - private: - void updateBreadcrumb(); - QStack mTitles; -}; - - #endif // QGSPANELWIDGET_H diff --git a/src/gui/qgspanelwidgetstack.cpp b/src/gui/qgspanelwidgetstack.cpp new file mode 100644 index 00000000000..3b153dad5c2 --- /dev/null +++ b/src/gui/qgspanelwidgetstack.cpp @@ -0,0 +1,135 @@ +/*************************************************************************** + qgspanelwidget.cpp + --------------------- + begin : June 2016 + copyright : (C) 2016 by Nathan Woodrow + email : + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +#include +#include +#include +#include + +#include "qgslogger.h" + +#include "qgspanelwidgetstack.h" + +#include "qgspanelwidget.h" + +QgsPanelWidgetStack::QgsPanelWidgetStack( QWidget *parent ) + : QWidget( parent ) +{ + setupUi( this ); + clear(); + + connect( mBackButton, SIGNAL( pressed() ), this, SLOT( acceptCurrentPanel() ) ); +} + +void QgsPanelWidgetStack::addMainPanel( QgsPanelWidget *panel ) +{ + // TODO Don't allow adding another main widget or else that would be strange for the user. + connect( panel, SIGNAL( showPanel( QgsPanelWidget* ) ), this, SLOT( showPanel( QgsPanelWidget* ) ), + // using unique connection because addMainPanel() may be called multiple times + // for a panel, so showPanel() slot could be invoked more times from one signal + Qt::UniqueConnection ); + mStackedWidget->insertWidget( 0, panel ); + mStackedWidget->setCurrentIndex( 0 ); +} + +QgsPanelWidget *QgsPanelWidgetStack::mainWidget() +{ + return qobject_cast( mStackedWidget->widget( 0 ) ); +} + +QgsPanelWidget *QgsPanelWidgetStack::takeMainWidget() +{ + QWidget* widget = mStackedWidget->widget( 0 ); + mStackedWidget->removeWidget( widget ); + return qobject_cast( widget ); +} + +void QgsPanelWidgetStack::clear() +{ + for ( int i = mStackedWidget->count(); i >= 0; i-- ) + { + if ( QgsPanelWidget* panelWidget = qobject_cast( mStackedWidget->widget( i ) ) ) + { + mStackedWidget->removeWidget( panelWidget ); + if ( panelWidget->autoDelete() ) + { + panelWidget->deleteLater(); + } + } + else if ( QWidget* widget = mStackedWidget->widget( i ) ) + { + mStackedWidget->removeWidget( widget ); + widget->deleteLater(); + } + } + mTitles.clear(); + mTitleText->hide(); + mBackButton->hide(); + this->updateBreadcrumb(); +} + +void QgsPanelWidgetStack::acceptCurrentPanel() +{ + // You can't accept the main panel. + if ( mStackedWidget->currentIndex() == 0 ) + return; + + QgsPanelWidget* widget = qobject_cast( mStackedWidget->currentWidget() ); + widget->acceptPanel(); +} + +void QgsPanelWidgetStack::showPanel( QgsPanelWidget *panel ) +{ + mTitles.push( panel->panelTitle() ); + + connect( panel, SIGNAL( panelAccepted( QgsPanelWidget* ) ), this, SLOT( closePanel( QgsPanelWidget* ) ) ); + connect( panel, SIGNAL( showPanel( QgsPanelWidget* ) ), this, SLOT( showPanel( QgsPanelWidget* ) ) ); + + int index = mStackedWidget->addWidget( panel ); + mStackedWidget->setCurrentIndex( index ); + mBackButton->show(); + mTitleText->show(); + + this->updateBreadcrumb(); +} + +void QgsPanelWidgetStack::closePanel( QgsPanelWidget *panel ) +{ + mTitles.pop(); + mStackedWidget->setCurrentIndex( mStackedWidget->currentIndex() - 1 ); + mStackedWidget->removeWidget( panel ); + if ( panel->autoDelete() ) + { + panel->deleteLater(); + } + + if ( mStackedWidget->currentIndex() == 0 ) + { + mBackButton->hide(); + mTitleText->hide(); + } + this->updateBreadcrumb(); +} + +void QgsPanelWidgetStack::updateBreadcrumb() +{ + QString breadcrumb; + Q_FOREACH ( QString title, mTitles ) + { + breadcrumb += QString( " %1 >" ).arg( title ); + } + // Remove the last + breadcrumb.chop( 1 ); + mTitleText->setText( breadcrumb ); +} diff --git a/src/gui/qgspanelwidgetstack.h b/src/gui/qgspanelwidgetstack.h new file mode 100644 index 00000000000..228e7f6b4cc --- /dev/null +++ b/src/gui/qgspanelwidgetstack.h @@ -0,0 +1,101 @@ +/*************************************************************************** + qgspanelwidgetstack.h + --------------------- + begin : June 2016 + copyright : (C) 2016 by Nathan Woodrow + email : + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +#ifndef QGSPANELWIDGETSTACK_H +#define QGSPANELWIDGETSTACK_H + +#include +#include +#include +#include + +#include "qgspanelwidget.h" + +#include "ui_qgsrenderercontainerbase.h" + + +/** \ingroup gui + * A stack widget to manage panels in the interface. Handles the open and close events + * for added panels. + * Any widgets that want to have a non blocking panel based interface should use this + * class to manage the panels. + */ +class GUI_EXPORT QgsPanelWidgetStack : public QWidget, private Ui::QgsRendererWidgetContainerBase +{ + Q_OBJECT + public: + + /** + * A stack widget to manage panels in the interface. Handles the open and close events + * for added panels. + * @param parent + */ + QgsPanelWidgetStack( QWidget* parent = nullptr ); + + /** + * Adds the main widget to the stack and selects it for the user + * The main widget can not be closed and only the showPanel signal is attached + * to handle children widget opening panels. + * @param panel The panel to set as the first widget in the stack. + */ + void addMainPanel( QgsPanelWidget* panel ); + + /** + * The main widget that is set in the stack. The main widget can not be closed + * and doesn't display a back button. + * @return The main QgsPanelWidget that is active in the stack. + */ + QgsPanelWidget* mainWidget(); + + /** + * Removes the main widget from the stack and transfers ownsership to the + * caller. + * @return The main widget that is set in the stack. + */ + QgsPanelWidget* takeMainWidget(); + + /** + * Clear the stack of all widgets. Unless the panels autoDelete is set to false + * the widget will be deleted. + */ + void clear(); + + public slots: + /** + * Accept the current active widget in the stack. + * + * Calls the panelAccepeted signal on the active widget. + */ + void acceptCurrentPanel(); + + /** + * Show a panel in the stack widget. Will connect to the panels showPanel event to handle + * nested panels. Auto switches the the given panel for the user. + * @param panel The panel to show. + */ + void showPanel( QgsPanelWidget* panel ); + + /** + * Closes the panel in the widget. Will also delete the widget. + * This slot is normally auto connected to panelAccepted when a panel is shown. + * @param panel The panel to close. + */ + void closePanel( QgsPanelWidget* panel ); + private: + void updateBreadcrumb(); + QStack mTitles; +}; + + +#endif // QGSPANELWIDGETSTACK_H diff --git a/src/plugins/globe/globe_plugin.cpp b/src/plugins/globe/globe_plugin.cpp index 7005e232c1e..aa5723e1e9c 100644 --- a/src/plugins/globe/globe_plugin.cpp +++ b/src/plugins/globe/globe_plugin.cpp @@ -272,7 +272,7 @@ void GlobePlugin::initGui() mQGisIface->addPluginToMenu( tr( "&Globe" ), mActionToggleGlobe ); mLayerPropertiesFactory = new QgsGlobeLayerPropertiesFactory( this ); - mQGisIface->registerMapLayerPropertiesFactory( mLayerPropertiesFactory ); + mQGisIface->registerMapLayerConfigWidgetFactory( mLayerPropertiesFactory ); connect( mActionToggleGlobe, SIGNAL( triggered( bool ) ), this, SLOT( setGlobeEnabled( bool ) ) ); connect( mLayerPropertiesFactory, SIGNAL( layerSettingsChanged( QgsMapLayer* ) ), this, SLOT( layerChanged( QgsMapLayer* ) ) ); @@ -1090,7 +1090,7 @@ void GlobePlugin::unload() } mQGisIface->removePluginMenu( tr( "&Globe" ), mActionToggleGlobe ); mQGisIface->removeToolBarIcon( mActionToggleGlobe ); - mQGisIface->unregisterMapLayerPropertiesFactory( mLayerPropertiesFactory ); + mQGisIface->unregisterMapLayerConfigWidgetFactory( mLayerPropertiesFactory ); delete mLayerPropertiesFactory; mLayerPropertiesFactory = 0; delete mSettingsDialog; diff --git a/src/plugins/globe/qgsglobevectorlayerproperties.cpp b/src/plugins/globe/qgsglobevectorlayerproperties.cpp index ba756861e11..f6c77c410bb 100644 --- a/src/plugins/globe/qgsglobevectorlayerproperties.cpp +++ b/src/plugins/globe/qgsglobevectorlayerproperties.cpp @@ -34,8 +34,8 @@ QgsGlobeVectorLayerConfig* QgsGlobeVectorLayerConfig::getConfig( QgsVectorLayer* /////////////////////////////////////////////////////////////////////////////// -QgsGlobeVectorLayerPropertiesPage::QgsGlobeVectorLayerPropertiesPage( QgsVectorLayer* layer, QWidget *parent ) - : QgsVectorLayerPropertiesPage( parent ) +QgsGlobeVectorLayerPropertiesPage::QgsGlobeVectorLayerPropertiesPage( QgsVectorLayer* layer, QgsMapCanvas *canvas, QWidget *parent ) + : QgsMapLayerConfigWidget( layer, canvas, parent ) , mLayer( layer ) { setupUi( this ); @@ -190,17 +190,27 @@ QgsGlobeLayerPropertiesFactory::QgsGlobeLayerPropertiesFactory( QObject *parent connect( QgsProject::instance(), SIGNAL( writeMapLayer( QgsMapLayer*, QDomElement&, QDomDocument& ) ), this, SLOT( writeGlobeVectorLayerConfig( QgsMapLayer*, QDomElement&, QDomDocument& ) ) ); } -QgsVectorLayerPropertiesPage* QgsGlobeLayerPropertiesFactory::createVectorLayerPropertiesPage( QgsVectorLayer* layer, QWidget* parent ) +QgsMapLayerConfigWidget *QgsGlobeLayerPropertiesFactory::createWidget( QgsMapLayer *layer, QgsMapCanvas *canvas, bool dockWidget, QWidget *parent ) const { - QgsGlobeVectorLayerPropertiesPage* propsPage = new QgsGlobeVectorLayerPropertiesPage( layer, parent ); + Q_UNUSED( dockWidget ); + QgsGlobeVectorLayerPropertiesPage* propsPage = new QgsGlobeVectorLayerPropertiesPage( qobject_cast( layer ), canvas, parent ); connect( propsPage, SIGNAL( layerSettingsChanged( QgsMapLayer* ) ), this, SIGNAL( layerSettingsChanged( QgsMapLayer* ) ) ); return propsPage; } -QListWidgetItem* QgsGlobeLayerPropertiesFactory::createVectorLayerPropertiesItem( QgsVectorLayer* layer, QListWidget* view ) +QIcon QgsGlobeLayerPropertiesFactory::icon() const { - Q_UNUSED( layer ); - return new QListWidgetItem( QIcon( ":/globe/icon.svg" ), tr( "Globe" ), view ); + return QIcon( ":/globe/icon.svg" ); +} + +QString QgsGlobeLayerPropertiesFactory::title() const +{ + return tr( "Globe" ); +} + +bool QgsGlobeLayerPropertiesFactory::supportsLayer( QgsMapLayer *layer ) const +{ + return layer->type() == QgsMapLayer::VectorLayer; } void QgsGlobeLayerPropertiesFactory::readGlobeVectorLayerConfig( QgsMapLayer* mapLayer, const QDomElement& elem ) diff --git a/src/plugins/globe/qgsglobevectorlayerproperties.h b/src/plugins/globe/qgsglobevectorlayerproperties.h index 9ebd645f405..95b25c82608 100644 --- a/src/plugins/globe/qgsglobevectorlayerproperties.h +++ b/src/plugins/globe/qgsglobevectorlayerproperties.h @@ -16,8 +16,11 @@ #ifndef QGSGLOBEVECTORLAYERPROPERTIES_H #define QGSGLOBEVECTORLAYERPROPERTIES_H +#include + #include "ui_qgsglobevectorlayerpropertiespage.h" -#include +#include +#include #include class QgsGlobeVectorLayerConfig; @@ -79,12 +82,12 @@ class QgsGlobeVectorLayerConfig : public QObject }; -class QgsGlobeVectorLayerPropertiesPage : public QgsVectorLayerPropertiesPage, private Ui::QgsGlobeVectorLayerPropertiesPage +class QgsGlobeVectorLayerPropertiesPage : public QgsMapLayerConfigWidget, private Ui::QgsGlobeVectorLayerPropertiesPage { Q_OBJECT public: - explicit QgsGlobeVectorLayerPropertiesPage( QgsVectorLayer* layer, QWidget *parent = 0 ); + explicit QgsGlobeVectorLayerPropertiesPage( QgsVectorLayer* layer, QgsMapCanvas* canvas, QWidget *parent = 0 ); public slots: virtual void apply(); @@ -102,13 +105,20 @@ class QgsGlobeVectorLayerPropertiesPage : public QgsVectorLayerPropertiesPage, p }; -class QgsGlobeLayerPropertiesFactory : public QObject, public QgsMapLayerPropertiesFactory +class QgsGlobeLayerPropertiesFactory : public QObject, public QgsMapLayerConfigWidgetFactory { Q_OBJECT public: explicit QgsGlobeLayerPropertiesFactory( QObject* parent = 0 ); - QgsVectorLayerPropertiesPage* createVectorLayerPropertiesPage( QgsVectorLayer* layer, QWidget* parent ) override; - QListWidgetItem* createVectorLayerPropertiesItem( QgsVectorLayer* layer, QListWidget* view ) override; + QgsMapLayerConfigWidget* createWidget( QgsMapLayer *layer, QgsMapCanvas *canvas, bool dockWidget, QWidget *parent ) const override; + + QIcon icon() const override; + + QString title() const override; + + bool supportLayerPropertiesDialog() const override { return true; } + + bool supportsLayer( QgsMapLayer *layer ) const override; signals: void layerSettingsChanged( QgsMapLayer* layer ); diff --git a/src/plugins/globe/qgsglobevectorlayerpropertiespage.ui b/src/plugins/globe/qgsglobevectorlayerpropertiespage.ui index 26b30a98285..1bde68b9cbb 100644 --- a/src/plugins/globe/qgsglobevectorlayerpropertiespage.ui +++ b/src/plugins/globe/qgsglobevectorlayerpropertiespage.ui @@ -1,7 +1,7 @@ QgsGlobeVectorLayerPropertiesPage - + 0 @@ -17,7 +17,7 @@ - 1 + 0 @@ -261,9 +261,9 @@ - QgsVectorLayerPropertiesPage + QgsMapLayerConfigWidget QWidget -
qgsvectorlayerpropertiespage.h
+
qgsmaplayerconfigwidget.h
1
diff --git a/src/ui/qgsmapstylingwidgetbase.ui b/src/ui/qgsmapstylingwidgetbase.ui index c03449e34aa..b86a1a4a03f 100644 --- a/src/ui/qgsmapstylingwidgetbase.ui +++ b/src/ui/qgsmapstylingwidgetbase.ui @@ -14,7 +14,16 @@ Form
- + + 3 + + + 3 + + + 3 + + 3 @@ -35,12 +44,21 @@
+ + 0 + + + 0 + + + 0 + + + 0 + 3 - - 0 - @@ -204,7 +222,7 @@ QgsPanelWidgetStack QWidget -
qgspanelwidget.h
+
qgspanelwidgetstack.h
1