2014-05-27 23:22:50 +02:00
class QgsGroupBoxCollapseButton : QToolButton
{
public:
2015-02-18 17:00:36 +11:00
QgsGroupBoxCollapseButton( QWidget *parent /TransferThis/ = 0 );
2014-05-27 23:22:50 +02:00
~QgsGroupBoxCollapseButton();
bool altDown() const;
void setAltDown( bool updown );
bool shiftDown() const;
void setShiftDown( bool shiftdown );
protected:
void mouseReleaseEvent( QMouseEvent *event );
};
2013-02-11 13:36:20 -07:00
/** \ingroup gui
* \class QgsCollapsibleGroupBoxBasic
* A groupbox that collapses/expands when toggled.
* Basic class QgsCollapsibleGroupBoxBasic does not auto-save collapsed or checked state
2013-02-12 14:43:05 -07:00
* Holding Alt modifier key when toggling collapsed state will synchronize the toggling across other collapsible group boxes with the same syncGroup QString value
2013-02-26 14:10:09 -07:00
* Holding Shift modifier key when attempting to toggle collapsed state will expand current group box, then collapse any others with the same syncGroup QString value
2013-02-11 13:36:20 -07:00
* @note To add Collapsible properties in promoted QtDesigner widgets, you can add the following "Dynamic properties" by clicking on the green + in the propreties palette:
2015-11-08 19:18:00 +00:00
* bool collapsed, QString syncGroup, bool scrollOnExpand
2013-02-11 13:36:20 -07:00
*/
class QgsCollapsibleGroupBoxBasic : QGroupBox
{
%TypeHeaderCode
#include <qgscollapsiblegroupbox.h>
%End
public:
2015-02-18 17:00:36 +11:00
QgsCollapsibleGroupBoxBasic( QWidget *parent /TransferThis/ = 0 );
QgsCollapsibleGroupBoxBasic( const QString &title, QWidget *parent /TransferThis/ = 0 );
2013-02-11 13:36:20 -07:00
~QgsCollapsibleGroupBoxBasic();
2015-11-08 19:18:00 +00:00
/**
* Returns the current collapsed state of this group box
*/
2013-02-11 13:36:20 -07:00
bool isCollapsed() const;
2015-11-08 19:18:00 +00:00
/**
* Collapse or uncollapse this groupbox
*
* @param collapse Will collapse on true and uncollapse on false
*/
2013-02-11 13:36:20 -07:00
void setCollapsed( bool collapse );
2015-11-08 19:18:00 +00:00
/**
* Named group which synchronizes collapsing action when triangle is clicked while holding alt modifier key
*/
2013-02-12 14:43:05 -07:00
QString syncGroup() const;
2015-11-08 19:18:00 +00:00
/**
* Named group which synchronizes collapsing action when triangle is clicked while holding alt modifier key
*/
2015-10-07 11:55:34 +11:00
void setSyncGroup( const QString& grp );
2013-02-12 14:43:05 -07:00
2015-11-08 19:18:00 +00:00
//! Set this to false to not automatically scroll parent QScrollArea to this widget's contents when expanded
2013-02-11 13:36:20 -07:00
void setScrollOnExpand( bool scroll );
2014-05-27 23:22:50 +02:00
2015-11-08 19:18:00 +00:00
//! If this is set to false the parent QScrollArea will not be automatically scrolled to this widget's contents when expanded
2014-05-20 10:13:48 +02:00
bool scrollOnExpand();
2013-02-11 13:36:20 -07:00
signals:
/** Signal emitted when groupbox collapsed/expanded state is changed, and when first shown */
void collapsedStateChanged( bool collapsed );
public slots:
void checkToggled( bool ckd );
2013-04-13 19:12:18 -06:00
void checkClicked( bool ckd );
2013-02-11 13:36:20 -07:00
void toggleCollapsed();
protected:
void init();
2014-01-27 09:22:24 +01:00
/** Visual fixes for when group box is collapsed/expanded */
void collapseExpandFixes();
2013-02-11 13:36:20 -07:00
void showEvent( QShowEvent *event );
2014-01-27 09:22:24 +01:00
void mousePressEvent( QMouseEvent *event );
2013-02-11 13:36:20 -07:00
void mouseReleaseEvent( QMouseEvent *event );
void changeEvent( QEvent *event );
void updateStyle();
QRect titleRect() const;
2014-01-27 09:22:24 +01:00
void clearModifiers();
2013-02-11 13:36:20 -07:00
};
/** \ingroup gui
* \class QgsCollapsibleGroupBox
* A groupbox that collapses/expands when toggled and can save its collapsed and checked states.
* By default, it auto-saves only its collapsed state to the global settings based on the widget and it's parent names.
2013-02-12 14:43:05 -07:00
* Holding Alt modifier key when toggling collapsed state will synchronize the toggling across other collapsible group boxes with the same syncGroup QString value
2013-02-26 14:10:09 -07:00
* Holding Shift modifier key when attempting to toggle collapsed state will expand current group box, then collapse any others with the same syncGroup QString value
2013-02-11 13:36:20 -07:00
* @see basic class QgsCollapsibleGroupBoxBasic which does not auto-save states
* @note To add Collapsible properties in promoted QtDesigner widgets, you can add the following "Dynamic properties" by clicking on the green + in the propreties palette:
2013-02-12 14:43:05 -07:00
* bool collapsed, bool saveCollapsedState, bool saveCheckedState, QString syncGroup
2013-02-11 13:36:20 -07:00
*/
class QgsCollapsibleGroupBox : QgsCollapsibleGroupBoxBasic
2012-09-24 02:28:15 +02:00
{
%TypeHeaderCode
#include <qgscollapsiblegroupbox.h>
%End
public:
2015-02-18 17:00:36 +11:00
QgsCollapsibleGroupBox( QWidget *parent /TransferThis/ = 0, QSettings* settings = 0 );
QgsCollapsibleGroupBox( const QString &title, QWidget *parent /TransferThis/ = 0, QSettings* settings = 0 );
2012-09-24 02:28:15 +02:00
~QgsCollapsibleGroupBox();
2013-01-24 11:47:26 -07:00
// set custom QSettings pointer if group box was already created from QtDesigner promotion
void setSettings( QSettings* settings );
2012-09-25 18:18:11 -03:00
//! set this to false to not save/restore collapsed state
void setSaveCollapsedState( bool save );
2015-07-29 11:52:14 +02:00
/** Set this to true to save/restore checked state
2012-09-25 18:18:11 -03:00
* @note only turn on mSaveCheckedState for groupboxes NOT used
2012-09-24 02:28:15 +02:00
* in multiple places or used as options for different parent objects */
void setSaveCheckedState( bool save );
2012-09-25 18:18:11 -03:00
bool saveCollapsedState();
2012-09-24 02:28:15 +02:00
bool saveCheckedState();
2012-09-25 18:18:11 -03:00
2016-02-14 03:50:23 +01:00
//! Set this to a defined string to share save/restore states across different parent dialogs
2012-09-24 02:28:15 +02:00
void setSettingGroup( const QString &group );
2016-02-14 03:50:23 +01:00
//! Returns the name of the setting group in which the collapsed state will be saved
2012-09-24 02:28:15 +02:00
QString settingGroup() const;
2012-09-25 18:18:11 -03:00
2012-09-24 02:28:15 +02:00
protected slots:
2016-02-14 03:50:23 +01:00
/**
* Will load the collapsed and checked state
*
* The configuration path from which it is loaded is defined by
* * The object name
* * The settingGroup
*/
2012-09-24 02:28:15 +02:00
void loadState();
2016-02-14 03:50:23 +01:00
/**
* Will save the collapsed and checked state
*
* The configuration path to which it is saved is defined by
* * The object name
* * The settingGroup
*/
2012-09-24 02:28:15 +02:00
void saveState();
protected:
void init();
void showEvent( QShowEvent *event );
QString saveKey() const;
};