Skip to content
Permalink
Browse files

[style dock] Refactor API. Move back button outside scrollarea.

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 19, 2016
1 parent 29df8a9 commit 7a572c4ff8c56cb7710389b7a3009c2c63ccca84
@@ -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:

@@ -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.
@@ -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"
@@ -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
@@ -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.
@@ -1,4 +1,4 @@
class QgsRasterHistogramWidget : QWidget
class QgsRasterHistogramWidget : QgsPanelWidget
{
%TypeHeaderCode
#include <qgsrasterhistogramwidget.h>
@@ -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 );
@@ -1,7 +1,7 @@
/**
* @brief Widget to control a layers transparency and related options
*/
class QgsRasterTransparencyWidget: QWidget
class QgsRasterTransparencyWidget: QgsPanelWidgetStack
{
%TypeHeaderCode
#include <qgsrastertransparencywidget.h>
@@ -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.
@@ -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();
@@ -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
@@ -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 )
@@ -21,6 +21,8 @@
#include <qgspallabeling.h>
#include "qgsvectorlayerlabeling.h"

#include "qgsmapstylepanel.h"

class QgsLabelingGui;
class QgsMapCanvas;
class QgsRuleBasedLabelingWidget;
@@ -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:

0 comments on commit 7a572c4

Please sign in to comment.
You can’t perform that action at this time.