Skip to content

Commit e097443

Browse files
committedJul 7, 2016
Fix globe plugin
1 parent 7dd6104 commit e097443

18 files changed

+400
-294
lines changed
 

‎python/gui/gui.sip

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@
136136
%Include qgsorderbydialog.sip
137137
%Include qgsowssourceselect.sip
138138
%Include qgspanelwidget.sip
139+
%Include qgspanelwidgetstack.sip
139140
%Include qgspixmaplabel.sip
140141
%Include qgspluginmanagerinterface.sip
141142
%Include qgsprevieweffect.sip

‎python/gui/qgsmaplayerconfigwidgetfactory.sip

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ class QgsMapLayerConfigWidgetFactory
2929
*/
3030
virtual QString title() const;
3131

32+
virtual bool supportsStyleDock() const;
33+
34+
virtual bool supportLayerPropertiesDialog() const;
35+
3236
/**
3337
* @brief Check if the layer is supported for this widget.
3438
* @return True if this layer is supported for this widget

‎python/gui/qgspanelwidget.sip

Lines changed: 0 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -156,75 +156,3 @@ class QgsPanelWidgetWrapper: public QgsPanelWidget
156156
*/
157157
QWidget* widget();
158158
};
159-
160-
/**
161-
* A stack widget to manage panels in the interface. Handles the open and close events
162-
* for added panels.
163-
* Any widgets that want to have a non blocking panel based interface should use this
164-
* class to manage the panels.
165-
*/
166-
class QgsPanelWidgetStack: public QWidget
167-
{
168-
%TypeHeaderCode
169-
#include "qgspanelwidget.h"
170-
%End
171-
public:
172-
173-
/**
174-
* A stack widget to manage panels in the interface. Handles the open and close events
175-
* for added panels.
176-
* @param parent
177-
*/
178-
QgsPanelWidgetStack( QWidget* parent = nullptr );
179-
180-
/**
181-
* Adds the main widget to the stack and selects it for the user
182-
* The main widget can not be closed and only the showPanel signal is attached
183-
* to handle children widget opening panels.
184-
* @param panel The panel to set as the first widget in the stack.
185-
*/
186-
void addMainPanel( QgsPanelWidget* panel );
187-
188-
/**
189-
* The main widget that is set in the stack. The main widget can not be closed
190-
* and doesn't display a back button.
191-
* @return The main QgsPanelWidget that is active in the stack.
192-
*/
193-
QgsPanelWidget* mainWidget();
194-
195-
/**
196-
* Removes the main widget from the stack and transfers ownsership to the
197-
* caller.
198-
* @return The main widget that is set in the stack.
199-
*/
200-
QgsPanelWidget* takeMainWidget();
201-
202-
/**
203-
* Clear the stack of all widgets. Unless the panels autoDelete is set to false
204-
* the widget will be deleted.
205-
*/
206-
void clear();
207-
208-
209-
public slots:
210-
/**
211-
* Accept the current active widget in the stack.
212-
*
213-
* Calls the panelAccepeted signal on the active widget.
214-
*/
215-
void acceptCurrentPanel();
216-
217-
/**
218-
* Show a panel in the stack widget. Will connect to the panels showPanel event to handle
219-
* nested panels. Auto switches the the given panel for the user.
220-
* @param panel The panel to show.
221-
*/
222-
void showPanel( QgsPanelWidget* panel );
223-
224-
/**
225-
* Closes the panel in the widget. Will also delete the widget.
226-
* This slot is normally auto connected to panelAccepted when a panel is shown.
227-
* @param panel The panel to close.
228-
*/
229-
void closePanel( QgsPanelWidget* panel );
230-
};

‎python/gui/qgspanelwidgetstack.sip

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/**
2+
* A stack widget to manage panels in the interface. Handles the open and close events
3+
* for added panels.
4+
* Any widgets that want to have a non blocking panel based interface should use this
5+
* class to manage the panels.
6+
*/
7+
class QgsPanelWidgetStack: public QWidget
8+
{
9+
%TypeHeaderCode
10+
#include "qgspanelwidgetstack.h"
11+
%End
12+
public:
13+
14+
/**
15+
* A stack widget to manage panels in the interface. Handles the open and close events
16+
* for added panels.
17+
* @param parent
18+
*/
19+
QgsPanelWidgetStack( QWidget* parent = nullptr );
20+
21+
/**
22+
* Adds the main widget to the stack and selects it for the user
23+
* The main widget can not be closed and only the showPanel signal is attached
24+
* to handle children widget opening panels.
25+
* @param panel The panel to set as the first widget in the stack.
26+
*/
27+
void addMainPanel( QgsPanelWidget* panel );
28+
29+
/**
30+
* The main widget that is set in the stack. The main widget can not be closed
31+
* and doesn't display a back button.
32+
* @return The main QgsPanelWidget that is active in the stack.
33+
*/
34+
QgsPanelWidget* mainWidget();
35+
36+
/**
37+
* Removes the main widget from the stack and transfers ownsership to the
38+
* caller.
39+
* @return The main widget that is set in the stack.
40+
*/
41+
QgsPanelWidget* takeMainWidget();
42+
43+
/**
44+
* Clear the stack of all widgets. Unless the panels autoDelete is set to false
45+
* the widget will be deleted.
46+
*/
47+
void clear();
48+
49+
50+
public slots:
51+
/**
52+
* Accept the current active widget in the stack.
53+
*
54+
* Calls the panelAccepeted signal on the active widget.
55+
*/
56+
void acceptCurrentPanel();
57+
58+
/**
59+
* Show a panel in the stack widget. Will connect to the panels showPanel event to handle
60+
* nested panels. Auto switches the the given panel for the user.
61+
* @param panel The panel to show.
62+
*/
63+
void showPanel( QgsPanelWidget* panel );
64+
65+
/**
66+
* Closes the panel in the widget. Will also delete the widget.
67+
* This slot is normally auto connected to panelAccepted when a panel is shown.
68+
* @param panel The panel to close.
69+
*/
70+
void closePanel( QgsPanelWidget* panel );
71+
};

‎python/gui/raster/qgsrastertransparencywidget.sip

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @brief Widget to control a layers transparency and related options
33
*/
4-
class QgsRasterTransparencyWidget: QgsPanelWidgetStack
4+
class QgsRasterTransparencyWidget: QgsMapLayerConfigWidget
55
{
66
%TypeHeaderCode
77
#include <qgsrastertransparencywidget.h>

‎src/app/qgslayerstylingwidget.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ void QgsLayerStylingWidget::setLayer( QgsMapLayer *layer )
173173

174174
Q_FOREACH ( QgsMapLayerConfigWidgetFactory* factory, mPageFactories )
175175
{
176-
if ( factory->supportsLayer( layer ) )
176+
if ( factory->supportsStyleDock() && factory->supportsLayer( layer ) )
177177
{
178178
QListWidgetItem* item = new QListWidgetItem( factory->icon(), QString() );
179179
mOptionsListWidget->addItem( item );

‎src/app/qgsvectorlayerproperties.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -329,19 +329,21 @@ void QgsVectorLayerProperties::setLabelCheckBox()
329329

330330
void QgsVectorLayerProperties::addPropertiesPageFactory( QgsMapLayerConfigWidgetFactory* factory )
331331
{
332+
if ( !factory->supportLayerPropertiesDialog() )
333+
{
334+
return;
335+
}
336+
332337
QListWidgetItem* item = new QListWidgetItem();
333338
item->setIcon( factory->icon() );
334339
item->setText( factory->title() );
335340
item->setToolTip( factory->title() );
336341

337-
if ( item )
338-
{
339-
mOptionsListWidget->addItem( item );
342+
mOptionsListWidget->addItem( item );
340343

341-
QgsMapLayerConfigWidget* page = factory->createWidget( mLayer, nullptr, false, this );
342-
mLayerPropertiesPages << page;
343-
mOptionsStackedWidget->addWidget( page );
344-
}
344+
QgsMapLayerConfigWidget* page = factory->createWidget( mLayer, nullptr, false, this );
345+
mLayerPropertiesPages << page;
346+
mOptionsStackedWidget->addWidget( page );
345347
}
346348

347349
void QgsVectorLayerProperties::insertField()

‎src/gui/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ SET(QGIS_GUI_SRCS
275275
qgsowssourceselect.cpp
276276
qgssourceselectdialog.cpp
277277
qgspanelwidget.cpp
278+
qgspanelwidgetstack.cpp
278279
qgspixmaplabel.cpp
279280
qgspluginmanagerinterface.cpp
280281
qgsprevieweffect.cpp
@@ -425,6 +426,7 @@ SET(QGIS_GUI_MOC_HDRS
425426
qgsowssourceselect.h
426427
qgssourceselectdialog.h
427428
qgspanelwidget.h
429+
qgspanelwidgetstack.h
428430
qgspixmaplabel.h
429431
qgspluginmanagerinterface.h
430432
qgsprevieweffect.h

‎src/gui/qgsmaplayerconfigwidgetfactory.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,18 @@ class GUI_EXPORT QgsMapLayerConfigWidgetFactory
4747
*/
4848
virtual QString title() const { return QString(); }
4949

50+
/**
51+
* Flag if widget is supported for use in style dock.
52+
* @return True if supported
53+
*/
54+
virtual bool supportsStyleDock() const { return false; }
55+
56+
/**
57+
* Flag if widget is supported for use in layer properties dialog.
58+
* @return True if supported
59+
*/
60+
virtual bool supportLayerPropertiesDialog() const { return false; }
61+
5062
/**
5163
* @brief Check if the layer is supported for this widget.
5264
* @return True if this layer is supported for this widget

‎src/gui/qgspanelwidget.cpp

Lines changed: 1 addition & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <QPushButton>
1717
#include <QDialog>
1818
#include <QSettings>
19+
#include <QVBoxLayout>
1920

2021
#include "qgspanelwidget.h"
2122
#include "qgslogger.h"
@@ -84,117 +85,6 @@ void QgsPanelWidget::keyPressEvent( QKeyEvent *event )
8485
}
8586
}
8687

87-
QgsPanelWidgetStack::QgsPanelWidgetStack( QWidget *parent )
88-
: QWidget( parent )
89-
{
90-
setupUi( this );
91-
clear();
92-
93-
connect( mBackButton, SIGNAL( pressed() ), this, SLOT( acceptCurrentPanel() ) );
94-
}
95-
96-
void QgsPanelWidgetStack::addMainPanel( QgsPanelWidget *panel )
97-
{
98-
// TODO Don't allow adding another main widget or else that would be strange for the user.
99-
connect( panel, SIGNAL( showPanel( QgsPanelWidget* ) ), this, SLOT( showPanel( QgsPanelWidget* ) ),
100-
// using unique connection because addMainPanel() may be called multiple times
101-
// for a panel, so showPanel() slot could be invoked more times from one signal
102-
Qt::UniqueConnection );
103-
mStackedWidget->insertWidget( 0, panel );
104-
mStackedWidget->setCurrentIndex( 0 );
105-
}
106-
107-
QgsPanelWidget *QgsPanelWidgetStack::mainWidget()
108-
{
109-
return qobject_cast<QgsPanelWidget*>( mStackedWidget->widget( 0 ) );
110-
}
111-
112-
QgsPanelWidget *QgsPanelWidgetStack::takeMainWidget()
113-
{
114-
QWidget* widget = mStackedWidget->widget( 0 );
115-
mStackedWidget->removeWidget( widget );
116-
return qobject_cast<QgsPanelWidget*>( widget );
117-
}
118-
119-
void QgsPanelWidgetStack::clear()
120-
{
121-
for ( int i = mStackedWidget->count(); i >= 0; i-- )
122-
{
123-
if ( QgsPanelWidget* panelWidget = qobject_cast<QgsPanelWidget*>( mStackedWidget->widget( i ) ) )
124-
{
125-
mStackedWidget->removeWidget( panelWidget );
126-
if ( panelWidget->autoDelete() )
127-
{
128-
panelWidget->deleteLater();
129-
}
130-
}
131-
else if ( QWidget* widget = mStackedWidget->widget( i ) )
132-
{
133-
mStackedWidget->removeWidget( widget );
134-
widget->deleteLater();
135-
}
136-
}
137-
mTitles.clear();
138-
mTitleText->hide();
139-
mBackButton->hide();
140-
this->updateBreadcrumb();
141-
}
142-
143-
void QgsPanelWidgetStack::acceptCurrentPanel()
144-
{
145-
// You can't accept the main panel.
146-
if ( mStackedWidget->currentIndex() == 0 )
147-
return;
148-
149-
QgsPanelWidget* widget = qobject_cast<QgsPanelWidget*>( mStackedWidget->currentWidget() );
150-
widget->acceptPanel();
151-
}
152-
153-
void QgsPanelWidgetStack::showPanel( QgsPanelWidget *panel )
154-
{
155-
mTitles.push( panel->panelTitle() );
156-
157-
connect( panel, SIGNAL( panelAccepted( QgsPanelWidget* ) ), this, SLOT( closePanel( QgsPanelWidget* ) ) );
158-
connect( panel, SIGNAL( showPanel( QgsPanelWidget* ) ), this, SLOT( showPanel( QgsPanelWidget* ) ) );
159-
160-
int index = mStackedWidget->addWidget( panel );
161-
mStackedWidget->setCurrentIndex( index );
162-
mBackButton->show();
163-
mTitleText->show();
164-
165-
this->updateBreadcrumb();
166-
}
167-
168-
void QgsPanelWidgetStack::closePanel( QgsPanelWidget *panel )
169-
{
170-
mTitles.pop();
171-
mStackedWidget->setCurrentIndex( mStackedWidget->currentIndex() - 1 );
172-
mStackedWidget->removeWidget( panel );
173-
if ( panel->autoDelete() )
174-
{
175-
panel->deleteLater();
176-
}
177-
178-
if ( mStackedWidget->currentIndex() == 0 )
179-
{
180-
mBackButton->hide();
181-
mTitleText->hide();
182-
}
183-
this->updateBreadcrumb();
184-
}
185-
186-
void QgsPanelWidgetStack::updateBreadcrumb()
187-
{
188-
QString breadcrumb;
189-
Q_FOREACH ( QString title, mTitles )
190-
{
191-
breadcrumb += QString( " %1 >" ).arg( title );
192-
}
193-
// Remove the last
194-
breadcrumb.chop( 1 );
195-
mTitleText->setText( breadcrumb );
196-
}
197-
19888
QgsPanelWidgetWrapper::QgsPanelWidgetWrapper( QWidget *widget, QWidget *parent )
19989
: QgsPanelWidget( parent )
20090
, mWidget( widget )

‎src/gui/qgspanelwidget.h

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,8 @@
1717

1818
#include <QWidget>
1919
#include <QKeyEvent>
20-
#include <QStackedWidget>
2120
#include <QStack>
2221

23-
#include "ui_qgsrenderercontainerbase.h"
24-
25-
2622
/** \ingroup gui
2723
* @brief Base class for any widget that can be shown as a inline panel
2824
*/
@@ -188,78 +184,4 @@ class GUI_EXPORT QgsPanelWidgetWrapper: public QgsPanelWidget
188184

189185
};
190186

191-
192-
/** \ingroup gui
193-
* A stack widget to manage panels in the interface. Handles the open and close events
194-
* for added panels.
195-
* Any widgets that want to have a non blocking panel based interface should use this
196-
* class to manage the panels.
197-
*/
198-
class GUI_EXPORT QgsPanelWidgetStack : public QWidget, private Ui::QgsRendererWidgetContainerBase
199-
{
200-
Q_OBJECT
201-
public:
202-
203-
/**
204-
* A stack widget to manage panels in the interface. Handles the open and close events
205-
* for added panels.
206-
* @param parent
207-
*/
208-
QgsPanelWidgetStack( QWidget* parent = nullptr );
209-
210-
/**
211-
* Adds the main widget to the stack and selects it for the user
212-
* The main widget can not be closed and only the showPanel signal is attached
213-
* to handle children widget opening panels.
214-
* @param panel The panel to set as the first widget in the stack.
215-
*/
216-
void addMainPanel( QgsPanelWidget* panel );
217-
218-
/**
219-
* The main widget that is set in the stack. The main widget can not be closed
220-
* and doesn't display a back button.
221-
* @return The main QgsPanelWidget that is active in the stack.
222-
*/
223-
QgsPanelWidget* mainWidget();
224-
225-
/**
226-
* Removes the main widget from the stack and transfers ownsership to the
227-
* caller.
228-
* @return The main widget that is set in the stack.
229-
*/
230-
QgsPanelWidget* takeMainWidget();
231-
232-
/**
233-
* Clear the stack of all widgets. Unless the panels autoDelete is set to false
234-
* the widget will be deleted.
235-
*/
236-
void clear();
237-
238-
public slots:
239-
/**
240-
* Accept the current active widget in the stack.
241-
*
242-
* Calls the panelAccepeted signal on the active widget.
243-
*/
244-
void acceptCurrentPanel();
245-
246-
/**
247-
* Show a panel in the stack widget. Will connect to the panels showPanel event to handle
248-
* nested panels. Auto switches the the given panel for the user.
249-
* @param panel The panel to show.
250-
*/
251-
void showPanel( QgsPanelWidget* panel );
252-
253-
/**
254-
* Closes the panel in the widget. Will also delete the widget.
255-
* This slot is normally auto connected to panelAccepted when a panel is shown.
256-
* @param panel The panel to close.
257-
*/
258-
void closePanel( QgsPanelWidget* panel );
259-
private:
260-
void updateBreadcrumb();
261-
QStack<QString> mTitles;
262-
};
263-
264-
265187
#endif // QGSPANELWIDGET_H

‎src/gui/qgspanelwidgetstack.cpp

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
/***************************************************************************
2+
qgspanelwidget.cpp
3+
---------------------
4+
begin : June 2016
5+
copyright : (C) 2016 by Nathan Woodrow
6+
email :
7+
***************************************************************************
8+
* *
9+
* This program is free software; you can redistribute it and/or modify *
10+
* it under the terms of the GNU General Public License as published by *
11+
* the Free Software Foundation; either version 2 of the License, or *
12+
* (at your option) any later version. *
13+
* *
14+
***************************************************************************/
15+
#include <QDialogButtonBox>
16+
#include <QPushButton>
17+
#include <QDialog>
18+
#include <QSettings>
19+
20+
#include "qgslogger.h"
21+
22+
#include "qgspanelwidgetstack.h"
23+
24+
#include "qgspanelwidget.h"
25+
26+
QgsPanelWidgetStack::QgsPanelWidgetStack( QWidget *parent )
27+
: QWidget( parent )
28+
{
29+
setupUi( this );
30+
clear();
31+
32+
connect( mBackButton, SIGNAL( pressed() ), this, SLOT( acceptCurrentPanel() ) );
33+
}
34+
35+
void QgsPanelWidgetStack::addMainPanel( QgsPanelWidget *panel )
36+
{
37+
// TODO Don't allow adding another main widget or else that would be strange for the user.
38+
connect( panel, SIGNAL( showPanel( QgsPanelWidget* ) ), this, SLOT( showPanel( QgsPanelWidget* ) ),
39+
// using unique connection because addMainPanel() may be called multiple times
40+
// for a panel, so showPanel() slot could be invoked more times from one signal
41+
Qt::UniqueConnection );
42+
mStackedWidget->insertWidget( 0, panel );
43+
mStackedWidget->setCurrentIndex( 0 );
44+
}
45+
46+
QgsPanelWidget *QgsPanelWidgetStack::mainWidget()
47+
{
48+
return qobject_cast<QgsPanelWidget*>( mStackedWidget->widget( 0 ) );
49+
}
50+
51+
QgsPanelWidget *QgsPanelWidgetStack::takeMainWidget()
52+
{
53+
QWidget* widget = mStackedWidget->widget( 0 );
54+
mStackedWidget->removeWidget( widget );
55+
return qobject_cast<QgsPanelWidget*>( widget );
56+
}
57+
58+
void QgsPanelWidgetStack::clear()
59+
{
60+
for ( int i = mStackedWidget->count(); i >= 0; i-- )
61+
{
62+
if ( QgsPanelWidget* panelWidget = qobject_cast<QgsPanelWidget*>( mStackedWidget->widget( i ) ) )
63+
{
64+
mStackedWidget->removeWidget( panelWidget );
65+
if ( panelWidget->autoDelete() )
66+
{
67+
panelWidget->deleteLater();
68+
}
69+
}
70+
else if ( QWidget* widget = mStackedWidget->widget( i ) )
71+
{
72+
mStackedWidget->removeWidget( widget );
73+
widget->deleteLater();
74+
}
75+
}
76+
mTitles.clear();
77+
mTitleText->hide();
78+
mBackButton->hide();
79+
this->updateBreadcrumb();
80+
}
81+
82+
void QgsPanelWidgetStack::acceptCurrentPanel()
83+
{
84+
// You can't accept the main panel.
85+
if ( mStackedWidget->currentIndex() == 0 )
86+
return;
87+
88+
QgsPanelWidget* widget = qobject_cast<QgsPanelWidget*>( mStackedWidget->currentWidget() );
89+
widget->acceptPanel();
90+
}
91+
92+
void QgsPanelWidgetStack::showPanel( QgsPanelWidget *panel )
93+
{
94+
mTitles.push( panel->panelTitle() );
95+
96+
connect( panel, SIGNAL( panelAccepted( QgsPanelWidget* ) ), this, SLOT( closePanel( QgsPanelWidget* ) ) );
97+
connect( panel, SIGNAL( showPanel( QgsPanelWidget* ) ), this, SLOT( showPanel( QgsPanelWidget* ) ) );
98+
99+
int index = mStackedWidget->addWidget( panel );
100+
mStackedWidget->setCurrentIndex( index );
101+
mBackButton->show();
102+
mTitleText->show();
103+
104+
this->updateBreadcrumb();
105+
}
106+
107+
void QgsPanelWidgetStack::closePanel( QgsPanelWidget *panel )
108+
{
109+
mTitles.pop();
110+
mStackedWidget->setCurrentIndex( mStackedWidget->currentIndex() - 1 );
111+
mStackedWidget->removeWidget( panel );
112+
if ( panel->autoDelete() )
113+
{
114+
panel->deleteLater();
115+
}
116+
117+
if ( mStackedWidget->currentIndex() == 0 )
118+
{
119+
mBackButton->hide();
120+
mTitleText->hide();
121+
}
122+
this->updateBreadcrumb();
123+
}
124+
125+
void QgsPanelWidgetStack::updateBreadcrumb()
126+
{
127+
QString breadcrumb;
128+
Q_FOREACH ( QString title, mTitles )
129+
{
130+
breadcrumb += QString( " %1 >" ).arg( title );
131+
}
132+
// Remove the last
133+
breadcrumb.chop( 1 );
134+
mTitleText->setText( breadcrumb );
135+
}

‎src/gui/qgspanelwidgetstack.h

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
/***************************************************************************
2+
qgspanelwidgetstack.h
3+
---------------------
4+
begin : June 2016
5+
copyright : (C) 2016 by Nathan Woodrow
6+
email :
7+
***************************************************************************
8+
* *
9+
* This program is free software; you can redistribute it and/or modify *
10+
* it under the terms of the GNU General Public License as published by *
11+
* the Free Software Foundation; either version 2 of the License, or *
12+
* (at your option) any later version. *
13+
* *
14+
***************************************************************************/
15+
#ifndef QGSPANELWIDGETSTACK_H
16+
#define QGSPANELWIDGETSTACK_H
17+
18+
#include <QWidget>
19+
#include <QKeyEvent>
20+
#include <QStackedWidget>
21+
#include <QStack>
22+
23+
#include "qgspanelwidget.h"
24+
25+
#include "ui_qgsrenderercontainerbase.h"
26+
27+
28+
/** \ingroup gui
29+
* A stack widget to manage panels in the interface. Handles the open and close events
30+
* for added panels.
31+
* Any widgets that want to have a non blocking panel based interface should use this
32+
* class to manage the panels.
33+
*/
34+
class GUI_EXPORT QgsPanelWidgetStack : public QWidget, private Ui::QgsRendererWidgetContainerBase
35+
{
36+
Q_OBJECT
37+
public:
38+
39+
/**
40+
* A stack widget to manage panels in the interface. Handles the open and close events
41+
* for added panels.
42+
* @param parent
43+
*/
44+
QgsPanelWidgetStack( QWidget* parent = nullptr );
45+
46+
/**
47+
* Adds the main widget to the stack and selects it for the user
48+
* The main widget can not be closed and only the showPanel signal is attached
49+
* to handle children widget opening panels.
50+
* @param panel The panel to set as the first widget in the stack.
51+
*/
52+
void addMainPanel( QgsPanelWidget* panel );
53+
54+
/**
55+
* The main widget that is set in the stack. The main widget can not be closed
56+
* and doesn't display a back button.
57+
* @return The main QgsPanelWidget that is active in the stack.
58+
*/
59+
QgsPanelWidget* mainWidget();
60+
61+
/**
62+
* Removes the main widget from the stack and transfers ownsership to the
63+
* caller.
64+
* @return The main widget that is set in the stack.
65+
*/
66+
QgsPanelWidget* takeMainWidget();
67+
68+
/**
69+
* Clear the stack of all widgets. Unless the panels autoDelete is set to false
70+
* the widget will be deleted.
71+
*/
72+
void clear();
73+
74+
public slots:
75+
/**
76+
* Accept the current active widget in the stack.
77+
*
78+
* Calls the panelAccepeted signal on the active widget.
79+
*/
80+
void acceptCurrentPanel();
81+
82+
/**
83+
* Show a panel in the stack widget. Will connect to the panels showPanel event to handle
84+
* nested panels. Auto switches the the given panel for the user.
85+
* @param panel The panel to show.
86+
*/
87+
void showPanel( QgsPanelWidget* panel );
88+
89+
/**
90+
* Closes the panel in the widget. Will also delete the widget.
91+
* This slot is normally auto connected to panelAccepted when a panel is shown.
92+
* @param panel The panel to close.
93+
*/
94+
void closePanel( QgsPanelWidget* panel );
95+
private:
96+
void updateBreadcrumb();
97+
QStack<QString> mTitles;
98+
};
99+
100+
101+
#endif // QGSPANELWIDGETSTACK_H

‎src/plugins/globe/globe_plugin.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ void GlobePlugin::initGui()
272272
mQGisIface->addPluginToMenu( tr( "&Globe" ), mActionToggleGlobe );
273273

274274
mLayerPropertiesFactory = new QgsGlobeLayerPropertiesFactory( this );
275-
mQGisIface->registerMapLayerPropertiesFactory( mLayerPropertiesFactory );
275+
mQGisIface->registerMapLayerConfigWidgetFactory( mLayerPropertiesFactory );
276276

277277
connect( mActionToggleGlobe, SIGNAL( triggered( bool ) ), this, SLOT( setGlobeEnabled( bool ) ) );
278278
connect( mLayerPropertiesFactory, SIGNAL( layerSettingsChanged( QgsMapLayer* ) ), this, SLOT( layerChanged( QgsMapLayer* ) ) );
@@ -1090,7 +1090,7 @@ void GlobePlugin::unload()
10901090
}
10911091
mQGisIface->removePluginMenu( tr( "&Globe" ), mActionToggleGlobe );
10921092
mQGisIface->removeToolBarIcon( mActionToggleGlobe );
1093-
mQGisIface->unregisterMapLayerPropertiesFactory( mLayerPropertiesFactory );
1093+
mQGisIface->unregisterMapLayerConfigWidgetFactory( mLayerPropertiesFactory );
10941094
delete mLayerPropertiesFactory;
10951095
mLayerPropertiesFactory = 0;
10961096
delete mSettingsDialog;

‎src/plugins/globe/qgsglobevectorlayerproperties.cpp

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ QgsGlobeVectorLayerConfig* QgsGlobeVectorLayerConfig::getConfig( QgsVectorLayer*
3434

3535
///////////////////////////////////////////////////////////////////////////////
3636

37-
QgsGlobeVectorLayerPropertiesPage::QgsGlobeVectorLayerPropertiesPage( QgsVectorLayer* layer, QWidget *parent )
38-
: QgsVectorLayerPropertiesPage( parent )
37+
QgsGlobeVectorLayerPropertiesPage::QgsGlobeVectorLayerPropertiesPage( QgsVectorLayer* layer, QgsMapCanvas *canvas, QWidget *parent )
38+
: QgsMapLayerConfigWidget( layer, canvas, parent )
3939
, mLayer( layer )
4040
{
4141
setupUi( this );
@@ -190,17 +190,27 @@ QgsGlobeLayerPropertiesFactory::QgsGlobeLayerPropertiesFactory( QObject *parent
190190
connect( QgsProject::instance(), SIGNAL( writeMapLayer( QgsMapLayer*, QDomElement&, QDomDocument& ) ), this, SLOT( writeGlobeVectorLayerConfig( QgsMapLayer*, QDomElement&, QDomDocument& ) ) );
191191
}
192192

193-
QgsVectorLayerPropertiesPage* QgsGlobeLayerPropertiesFactory::createVectorLayerPropertiesPage( QgsVectorLayer* layer, QWidget* parent )
193+
QgsMapLayerConfigWidget *QgsGlobeLayerPropertiesFactory::createWidget( QgsMapLayer *layer, QgsMapCanvas *canvas, bool dockWidget, QWidget *parent ) const
194194
{
195-
QgsGlobeVectorLayerPropertiesPage* propsPage = new QgsGlobeVectorLayerPropertiesPage( layer, parent );
195+
Q_UNUSED( dockWidget );
196+
QgsGlobeVectorLayerPropertiesPage* propsPage = new QgsGlobeVectorLayerPropertiesPage( qobject_cast<QgsVectorLayer*>( layer ), canvas, parent );
196197
connect( propsPage, SIGNAL( layerSettingsChanged( QgsMapLayer* ) ), this, SIGNAL( layerSettingsChanged( QgsMapLayer* ) ) );
197198
return propsPage;
198199
}
199200

200-
QListWidgetItem* QgsGlobeLayerPropertiesFactory::createVectorLayerPropertiesItem( QgsVectorLayer* layer, QListWidget* view )
201+
QIcon QgsGlobeLayerPropertiesFactory::icon() const
201202
{
202-
Q_UNUSED( layer );
203-
return new QListWidgetItem( QIcon( ":/globe/icon.svg" ), tr( "Globe" ), view );
203+
return QIcon( ":/globe/icon.svg" );
204+
}
205+
206+
QString QgsGlobeLayerPropertiesFactory::title() const
207+
{
208+
return tr( "Globe" );
209+
}
210+
211+
bool QgsGlobeLayerPropertiesFactory::supportsLayer( QgsMapLayer *layer ) const
212+
{
213+
return layer->type() == QgsMapLayer::VectorLayer;
204214
}
205215

206216
void QgsGlobeLayerPropertiesFactory::readGlobeVectorLayerConfig( QgsMapLayer* mapLayer, const QDomElement& elem )

‎src/plugins/globe/qgsglobevectorlayerproperties.h

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@
1616
#ifndef QGSGLOBEVECTORLAYERPROPERTIES_H
1717
#define QGSGLOBEVECTORLAYERPROPERTIES_H
1818

19+
#include <QIcon>
20+
1921
#include "ui_qgsglobevectorlayerpropertiespage.h"
20-
#include <qgsmaplayerpropertiesfactory.h>
22+
#include <qgsmaplayerconfigwidget.h>
23+
#include <qgsmaplayerconfigwidgetfactory.h>
2124
#include <osgEarthSymbology/AltitudeSymbol>
2225

2326
class QgsGlobeVectorLayerConfig;
@@ -79,12 +82,12 @@ class QgsGlobeVectorLayerConfig : public QObject
7982
};
8083

8184

82-
class QgsGlobeVectorLayerPropertiesPage : public QgsVectorLayerPropertiesPage, private Ui::QgsGlobeVectorLayerPropertiesPage
85+
class QgsGlobeVectorLayerPropertiesPage : public QgsMapLayerConfigWidget, private Ui::QgsGlobeVectorLayerPropertiesPage
8386
{
8487
Q_OBJECT
8588

8689
public:
87-
explicit QgsGlobeVectorLayerPropertiesPage( QgsVectorLayer* layer, QWidget *parent = 0 );
90+
explicit QgsGlobeVectorLayerPropertiesPage( QgsVectorLayer* layer, QgsMapCanvas* canvas, QWidget *parent = 0 );
8891

8992
public slots:
9093
virtual void apply();
@@ -102,13 +105,20 @@ class QgsGlobeVectorLayerPropertiesPage : public QgsVectorLayerPropertiesPage, p
102105
};
103106

104107

105-
class QgsGlobeLayerPropertiesFactory : public QObject, public QgsMapLayerPropertiesFactory
108+
class QgsGlobeLayerPropertiesFactory : public QObject, public QgsMapLayerConfigWidgetFactory
106109
{
107110
Q_OBJECT
108111
public:
109112
explicit QgsGlobeLayerPropertiesFactory( QObject* parent = 0 );
110-
QgsVectorLayerPropertiesPage* createVectorLayerPropertiesPage( QgsVectorLayer* layer, QWidget* parent ) override;
111-
QListWidgetItem* createVectorLayerPropertiesItem( QgsVectorLayer* layer, QListWidget* view ) override;
113+
QgsMapLayerConfigWidget* createWidget( QgsMapLayer *layer, QgsMapCanvas *canvas, bool dockWidget, QWidget *parent ) const override;
114+
115+
QIcon icon() const override;
116+
117+
QString title() const override;
118+
119+
bool supportLayerPropertiesDialog() const override { return true; }
120+
121+
bool supportsLayer( QgsMapLayer *layer ) const override;
112122

113123
signals:
114124
void layerSettingsChanged( QgsMapLayer* layer );

‎src/plugins/globe/qgsglobevectorlayerpropertiespage.ui

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<ui version="4.0">
33
<class>QgsGlobeVectorLayerPropertiesPage</class>
4-
<widget class="QgsVectorLayerPropertiesPage" name="QgsGlobeVectorLayerPropertiesPage">
4+
<widget class="QgsMapLayerConfigWidget" name="QgsGlobeVectorLayerPropertiesPage">
55
<property name="geometry">
66
<rect>
77
<x>0</x>
@@ -17,7 +17,7 @@
1717
<item row="1" column="0" colspan="2">
1818
<widget class="QStackedWidget" name="stackedWidgetRenderingMode">
1919
<property name="currentIndex">
20-
<number>1</number>
20+
<number>0</number>
2121
</property>
2222
<widget class="QWidget" name="pageRasterized">
2323
<layout class="QVBoxLayout" name="verticalLayout"/>
@@ -261,9 +261,9 @@
261261
</widget>
262262
<customwidgets>
263263
<customwidget>
264-
<class>QgsVectorLayerPropertiesPage</class>
264+
<class>QgsMapLayerConfigWidget</class>
265265
<extends>QWidget</extends>
266-
<header>qgsvectorlayerpropertiespage.h</header>
266+
<header>qgsmaplayerconfigwidget.h</header>
267267
<container>1</container>
268268
</customwidget>
269269
</customwidgets>

‎src/ui/qgsmapstylingwidgetbase.ui

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,16 @@
1414
<string>Form</string>
1515
</property>
1616
<layout class="QGridLayout" name="gridLayout_2">
17-
<property name="margin">
17+
<property name="leftMargin">
18+
<number>3</number>
19+
</property>
20+
<property name="topMargin">
21+
<number>3</number>
22+
</property>
23+
<property name="rightMargin">
24+
<number>3</number>
25+
</property>
26+
<property name="bottomMargin">
1827
<number>3</number>
1928
</property>
2029
<item row="0" column="0">
@@ -35,12 +44,21 @@
3544
</widget>
3645
<widget class="QWidget" name="page_2">
3746
<layout class="QGridLayout" name="gridLayout">
38-
<property name="horizontalSpacing">
39-
<number>3</number>
47+
<property name="leftMargin">
48+
<number>0</number>
49+
</property>
50+
<property name="topMargin">
51+
<number>0</number>
52+
</property>
53+
<property name="rightMargin">
54+
<number>0</number>
4055
</property>
41-
<property name="margin">
56+
<property name="bottomMargin">
4257
<number>0</number>
4358
</property>
59+
<property name="horizontalSpacing">
60+
<number>3</number>
61+
</property>
4462
<item row="2" column="1">
4563
<layout class="QHBoxLayout" name="horizontalLayout_2">
4664
<property name="spacing">
@@ -204,7 +222,7 @@
204222
<customwidget>
205223
<class>QgsPanelWidgetStack</class>
206224
<extends>QWidget</extends>
207-
<header>qgspanelwidget.h</header>
225+
<header>qgspanelwidgetstack.h</header>
208226
<container>1</container>
209227
</customwidget>
210228
</customwidgets>

1 commit comments

Comments
 (1)

m-kuhn commented on Jul 7, 2016

@m-kuhn
Member

Nice, thanks a lot for all this!!!

Please sign in to comment.