Skip to content

Commit

Permalink
[style dock] Refactor API. Move back button outside scrollarea.
Browse files Browse the repository at this point in the history
Clean up API. Remove QgsPanelWidgetPage - no longer needed
QgsPanelWidgetStack widget manages back button and breadcrumb.
QgsPanelWidget manages state of active widget.
  • Loading branch information
NathanW2 committed Jun 20, 2016
1 parent 29df8a9 commit 7a572c4
Show file tree
Hide file tree
Showing 24 changed files with 466 additions and 228 deletions.
97 changes: 70 additions & 27 deletions python/gui/qgspanelwidget.sip
Expand Up @@ -59,16 +59,20 @@ class QgsPanelWidget : public QWidget
bool dockMode();

/**
* Open a panel or dialog depending on dock mode setting
* If dock mode is true this method will emit the showPanel signal
* for connected slots to handle the open event.
*
* If dock mode is false this method will open a dialog
* and block the user.
*
* @param panel The panel widget to open.
* The the auto delete property on the widget. True by default.
* When auto delete is enabeld when a panel is removed from the stack
* it will be deleted.
* @param autoDelete Enable or disable auto delete on the panel.
*/
void openPanel( QgsPanelWidget* panel );
void setAutoDelete( bool autoDelete );

/**
* The the auto delete property on the widget. True by default.
* When auto delete is enabeld when a panel is removed from the stack
* it will be deleted.
* @returns The auto delete value for the widget.
*/
bool autoDelete();

signals:

Expand Down Expand Up @@ -97,6 +101,17 @@ class QgsPanelWidget : public QWidget
void widgetChanged();

public slots:
/**
* Open a panel or dialog depending on dock mode setting
* If dock mode is true this method will emit the showPanel signal
* for connected slots to handle the open event.
*
* If dock mode is false this method will open a dialog
* and block the user.
*
* @param panel The panel widget to open.
*/
void openPanel( QgsPanelWidget* panel );

/**
* Accept the panel. Causes panelAccepted to be emiited.
Expand All @@ -115,36 +130,40 @@ class QgsPanelWidget : public QWidget


/**
* A non model panel page that can get shown to the user. Page will contain a close button and trigger the
* internal widgets acceptPanel() on close.
* @brief Wrapper widget for existing widgets which can't have
* the inheritance tree changed, e.g dialogs.
*
* @note Generally you should use the QgsPanelWidget class if you can
* and only use this wrapper if you can't update your code.
*/
class QgsPanelWidgetPage : public QgsPanelWidget
class QgsPanelWidgetWrapper: public QgsPanelWidget
{
%TypeHeaderCode
#include "qgspanelwidget.h"
%End
public:

/**
* A non model panel page that can get shown to the user.
* @param widget The internal widget to show in the page.
* @param parent THe parent widget.
* @brief Wrapper widget for existing widgets which can't have
* the inheritance tree changed, e.g dialogs.
* @param widget The widget to wrap.
* @param parent The parent widget.
*/
QgsPanelWidgetPage( QgsPanelWidget* widget, QWidget* parent = nullptr );

~QgsPanelWidgetPage();
QgsPanelWidgetWrapper( QWidget* widget, QWidget* parent = nullptr );

void setTitle( QString title );
/**
* Returns the internal widget that is wrapped in this panel.
* @return The internal widget. Can be nullptr.
*/
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 QgsPanelWidgetStackWidget : public QStackedWidget
class QgsPanelWidgetStack: public QWidget
{
%TypeHeaderCode
#include "qgspanelwidget.h"
Expand All @@ -156,11 +175,7 @@ class QgsPanelWidgetStackWidget : public QStackedWidget
* for added panels.
* @param parent
*/
QgsPanelWidgetStackWidget( QWidget* parent = nullptr );

void connectPanels( QList<QgsPanelWidget*> panels );

void connectPanel( QgsPanelWidget* panel );
QgsPanelWidgetStack( QWidget* parent = nullptr );

/**
* Adds the main widget to the stack and selects it for the user
Expand All @@ -170,7 +185,35 @@ class QgsPanelWidgetStackWidget : public QStackedWidget
*/
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.
Expand Down
11 changes: 3 additions & 8 deletions python/gui/raster/qgsrasterhistogramwidget.sip
@@ -1,4 +1,4 @@
class QgsRasterHistogramWidget : QWidget
class QgsRasterHistogramWidget : QgsPanelWidget
{
%TypeHeaderCode
#include <qgsrasterhistogramwidget.h>
Expand All @@ -25,19 +25,14 @@ class QgsRasterHistogramWidget : QWidget
/** Apply a histoActionTriggered() event. */
void setSelectedBand( int index );

signals:
/**
* Emitted when something on the widget has changed.
* All widgets will fire this event to notify of an internal change.
*/
void widgetChanged();

public slots:
/** \brief slot executed when user wishes to refresh raster histogramwidget */
void refreshHistogram();
/** This slot lets you save the histogram as an image to disk */
void on_mSaveAsImageButton_clicked();

void apply();

private slots:
/** Used when the histogram band selector changes, or when tab is loaded. */
void on_cboHistoBand_currentIndexChanged( int );
Expand Down
9 changes: 1 addition & 8 deletions python/gui/raster/qgsrastertransparencywidget.sip
@@ -1,7 +1,7 @@
/**
* @brief Widget to control a layers transparency and related options
*/
class QgsRasterTransparencyWidget: QWidget
class QgsRasterTransparencyWidget: QgsPanelWidgetStack
{
%TypeHeaderCode
#include <qgsrastertransparencywidget.h>
Expand All @@ -13,13 +13,6 @@ class QgsRasterTransparencyWidget: QWidget
QgsRasterTransparencyWidget( QgsRasterLayer* layer, QgsMapCanvas *canvas, QWidget *parent = 0 );
~QgsRasterTransparencyWidget();

signals:
/**
* Emitted when something on the widget has changed.
* All widgets will fire this event to notify of an internal change.
*/
void widgetChanged();

public slots:
/**
* Sync the widget state to the layer set for the widget.
Expand Down
20 changes: 20 additions & 0 deletions python/gui/symbology-ng/qgsrendererv2propertiesdialog.sip
Expand Up @@ -45,6 +45,14 @@ class QgsRendererV2PropertiesDialog : QDialog
*/
void widgetChanged();

/**
* Emit when you require a panel to be show in the interface.
* @param panel The panel widget to show.
* @note If you are connected to this signal you should also connect
* given panels showPanel signal as they can be nested.
*/
void showPanel( QgsPanelWidget* panel );

public slots:
//! called when user changes renderer type
void rendererChanged();
Expand All @@ -55,6 +63,18 @@ class QgsRendererV2PropertiesDialog : QDialog
//! Apply and accept the changes for the dialog.
void onOK();

/**
* Open a panel or dialog depending on dock mode setting
* If dock mode is true this method will emit the showPanel signal
* for connected slots to handle the open event.
*
* If dock mode is false this method will open a dialog
* and block the user.
*
* @param panel The panel widget to open.
*/
void openPanel( QgsPanelWidget* panel );

protected:
/**
* Connect the given slot to the value changed event for the set of widgets
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgslabelingwidget.cpp
Expand Up @@ -25,7 +25,7 @@
#include "qgisapp.h"

QgsLabelingWidget::QgsLabelingWidget( QgsVectorLayer* layer, QgsMapCanvas* canvas, QWidget* parent )
: QWidget( parent )
: QgsMapStylingPanel( layer, canvas, parent )
, mLayer( layer )
, mCanvas( canvas )
, mWidget( nullptr )
Expand Down
4 changes: 3 additions & 1 deletion src/app/qgslabelingwidget.h
Expand Up @@ -21,6 +21,8 @@
#include <qgspallabeling.h>
#include "qgsvectorlayerlabeling.h"

#include "qgsmapstylepanel.h"

class QgsLabelingGui;
class QgsMapCanvas;
class QgsRuleBasedLabelingWidget;
Expand All @@ -30,7 +32,7 @@ class QgsMapLayer;
/**
* Master widget for configuration of labeling of a vector layer
*/
class QgsLabelingWidget : public QWidget, private Ui::QgsLabelingWidget
class QgsLabelingWidget : public QgsMapStylingPanel, private Ui::QgsLabelingWidget
{
Q_OBJECT
public:
Expand Down

0 comments on commit 7a572c4

Please sign in to comment.