mirror of
https://github.com/qgis/QGIS.git
synced 2025-06-18 00:04:02 -04:00
Fix globe plugin
This commit is contained in:
parent
7dd6104982
commit
e097443771
@ -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
|
||||
|
@ -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
|
||||
|
@ -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 );
|
||||
};
|
||||
|
71
python/gui/qgspanelwidgetstack.sip
Normal file
71
python/gui/qgspanelwidgetstack.sip
Normal file
@ -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 );
|
||||
};
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @brief Widget to control a layers transparency and related options
|
||||
*/
|
||||
class QgsRasterTransparencyWidget: QgsPanelWidgetStack
|
||||
class QgsRasterTransparencyWidget: QgsMapLayerConfigWidget
|
||||
{
|
||||
%TypeHeaderCode
|
||||
#include <qgsrastertransparencywidget.h>
|
||||
|
@ -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 );
|
||||
|
@ -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()
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include <QPushButton>
|
||||
#include <QDialog>
|
||||
#include <QSettings>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#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<QgsPanelWidget*>( mStackedWidget->widget( 0 ) );
|
||||
}
|
||||
|
||||
QgsPanelWidget *QgsPanelWidgetStack::takeMainWidget()
|
||||
{
|
||||
QWidget* widget = mStackedWidget->widget( 0 );
|
||||
mStackedWidget->removeWidget( widget );
|
||||
return qobject_cast<QgsPanelWidget*>( widget );
|
||||
}
|
||||
|
||||
void QgsPanelWidgetStack::clear()
|
||||
{
|
||||
for ( int i = mStackedWidget->count(); i >= 0; i-- )
|
||||
{
|
||||
if ( QgsPanelWidget* panelWidget = qobject_cast<QgsPanelWidget*>( 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<QgsPanelWidget*>( 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 )
|
||||
|
@ -17,12 +17,8 @@
|
||||
|
||||
#include <QWidget>
|
||||
#include <QKeyEvent>
|
||||
#include <QStackedWidget>
|
||||
#include <QStack>
|
||||
|
||||
#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<QString> mTitles;
|
||||
};
|
||||
|
||||
|
||||
#endif // QGSPANELWIDGET_H
|
||||
|
135
src/gui/qgspanelwidgetstack.cpp
Normal file
135
src/gui/qgspanelwidgetstack.cpp
Normal file
@ -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 <QDialogButtonBox>
|
||||
#include <QPushButton>
|
||||
#include <QDialog>
|
||||
#include <QSettings>
|
||||
|
||||
#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<QgsPanelWidget*>( mStackedWidget->widget( 0 ) );
|
||||
}
|
||||
|
||||
QgsPanelWidget *QgsPanelWidgetStack::takeMainWidget()
|
||||
{
|
||||
QWidget* widget = mStackedWidget->widget( 0 );
|
||||
mStackedWidget->removeWidget( widget );
|
||||
return qobject_cast<QgsPanelWidget*>( widget );
|
||||
}
|
||||
|
||||
void QgsPanelWidgetStack::clear()
|
||||
{
|
||||
for ( int i = mStackedWidget->count(); i >= 0; i-- )
|
||||
{
|
||||
if ( QgsPanelWidget* panelWidget = qobject_cast<QgsPanelWidget*>( 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<QgsPanelWidget*>( 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 );
|
||||
}
|
101
src/gui/qgspanelwidgetstack.h
Normal file
101
src/gui/qgspanelwidgetstack.h
Normal file
@ -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 <QWidget>
|
||||
#include <QKeyEvent>
|
||||
#include <QStackedWidget>
|
||||
#include <QStack>
|
||||
|
||||
#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<QString> mTitles;
|
||||
};
|
||||
|
||||
|
||||
#endif // QGSPANELWIDGETSTACK_H
|
@ -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;
|
||||
|
@ -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<QgsVectorLayer*>( 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 )
|
||||
|
@ -16,8 +16,11 @@
|
||||
#ifndef QGSGLOBEVECTORLAYERPROPERTIES_H
|
||||
#define QGSGLOBEVECTORLAYERPROPERTIES_H
|
||||
|
||||
#include <QIcon>
|
||||
|
||||
#include "ui_qgsglobevectorlayerpropertiespage.h"
|
||||
#include <qgsmaplayerpropertiesfactory.h>
|
||||
#include <qgsmaplayerconfigwidget.h>
|
||||
#include <qgsmaplayerconfigwidgetfactory.h>
|
||||
#include <osgEarthSymbology/AltitudeSymbol>
|
||||
|
||||
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 );
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>QgsGlobeVectorLayerPropertiesPage</class>
|
||||
<widget class="QgsVectorLayerPropertiesPage" name="QgsGlobeVectorLayerPropertiesPage">
|
||||
<widget class="QgsMapLayerConfigWidget" name="QgsGlobeVectorLayerPropertiesPage">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
@ -17,7 +17,7 @@
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QStackedWidget" name="stackedWidgetRenderingMode">
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="pageRasterized">
|
||||
<layout class="QVBoxLayout" name="verticalLayout"/>
|
||||
@ -261,9 +261,9 @@
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>QgsVectorLayerPropertiesPage</class>
|
||||
<class>QgsMapLayerConfigWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>qgsvectorlayerpropertiespage.h</header>
|
||||
<header>qgsmaplayerconfigwidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
|
@ -14,7 +14,16 @@
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<property name="margin">
|
||||
<property name="leftMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
@ -35,12 +44,21 @@
|
||||
</widget>
|
||||
<widget class="QWidget" name="page_2">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="horizontalSpacing">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="2" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<property name="spacing">
|
||||
@ -204,7 +222,7 @@
|
||||
<customwidget>
|
||||
<class>QgsPanelWidgetStack</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>qgspanelwidget.h</header>
|
||||
<header>qgspanelwidgetstack.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
|
Loading…
x
Reference in New Issue
Block a user