23 #include <QToolButton> 24 #include <QMouseEvent> 25 #include <QPushButton> 26 #include <QStyleOptionGroupBox> 28 #include <QScrollArea> 109 QgsDebugMsg(
"did not find a QScrollArea parent" );
137 if ( event->
modifiers() & ( Qt::AltModifier | Qt::ControlModifier | Qt::ShiftModifier )
151 mAltDown = (
event->modifiers() & ( Qt::AltModifier | Qt::ControlModifier ) );
152 mShiftDown = (
event->modifiers() & Qt::ShiftModifier );
187 tipTxt =
tr(
"Ctrl (or Alt)-click to toggle all" ) +
'\n' +
tr(
"Shift-click to expand, then collapse others" );
197 QStyle::SC_GroupBoxLabel,
this );
240 QgsDebugMsg(
"Alt or Shift key down, syncing group" );
308 bool usingQgsStyle = settings.
value(
"qgis/stylesheet/groupBoxCustom",
QVariant(
false ) ).
toBool();
313 QStyle::SC_GroupBoxFrame,
this );
321 int topBuffer = ( usingQgsStyle ? 3 : 1 ) + offsetStyle;
322 int offsetTop = topBuffer;
323 int offsetTopTri = topBuffer;
342 QStyle::SC_GroupBoxFrame,
this );
344 QStyle::SC_GroupBoxCheckBox,
this );
345 if ( rectFrame.
left() <= 0 )
346 offsetLeft = 6 + rectFrame.
left();
347 if ( rectFrame.
top() <= 0 )
352 offsetTop = ( rectCheckBox.
height() / 2 ) -
354 offsetTopTri = offsetTop + 1;
358 offsetTop = 6 + rectFrame.
top();
359 offsetTopTri = offsetTop;
371 ss +=
"QgsCollapsibleGroupBoxBasic, QgsCollapsibleGroupBox {";
372 ss +=
QString(
" margin-top: %1px;" ).
arg( topBuffer + ( usingQgsStyle ? rectTitle.
height() + 5 : rectFrame.
top() ) );
375 ss +=
"QgsCollapsibleGroupBoxBasic::title, QgsCollapsibleGroupBox::title {";
376 ss +=
" subcontrol-origin: margin;";
377 ss +=
" subcontrol-position: top left;";
378 ss +=
QString(
" margin-left: %1px;" ).
arg( marginLeft );
379 ss +=
QString(
" margin-right: %1px;" ).
arg( marginRight );
380 ss +=
QString(
" left: %1px;" ).
arg( offsetLeft );
381 ss +=
QString(
" top: %1px;" ).
arg( offsetTop );
384 ss +=
" background-color: rgba(0,0,0,0)";
392 ssd +=
" background-color: rgba(255, 255, 255, 0); border: none;";
393 ssd +=
QString(
"} QgsCollapsibleGroupBoxBasic > QToolButton#%1:focus, QgsCollapsibleGroupBox > QToolButton#%1:focus { border: 1px solid palette(highlight); }" ).
arg(
mCollapseButton->
objectName() );
395 if ( offsetLeft != 0 || offsetTopTri != 0 )
446 const char* hideKey =
"CollGrpBxHide";
479 , mSettings( settings )
562 saveKey =
'/' + setgrp +
saveKey;
563 saveKey =
"QgsCollapsibleGroupBox" +
saveKey;
581 val =
mSettings->value( key +
"/checked" );
587 val =
mSettings->value( key +
"/collapsed" );
QObject * child(const char *objName, const char *inheritsClass, bool recursiveSearch) const
void clicked(bool checked)
QString syncGroup
An optional group to be collapsed and uncollapsed in sync with this group box if the Alt-modifier is ...
static QIcon getThemeIcon(const QString &theName)
Helper to get a theme icon.
const QObjectList & children() const
void collapsedStateChanged(bool collapsed)
Signal emitted when groupbox collapsed/expanded state is changed, and when first shown.
QScrollArea * mParentScrollArea
~QgsCollapsibleGroupBoxBasic()
virtual QRect subControlRect(ComplexControl control, const QStyleOptionComplex *option, SubControl subControl, const QWidget *widget) const=0
void saveState() const
Will save the collapsed and checked state.
void setCollapsed(bool collapse)
Collapse or uncollapse this groupbox.
void changeEvent(QEvent *event) override
void showEvent(QShowEvent *event) override
QgsCollapsibleGroupBox(QWidget *parent=nullptr, QSettings *settings=nullptr)
QString tr(const char *sourceText, const char *disambiguation, int n)
bool isCollapsed() const
Returns the current collapsed state of this group box.
QgsGroupBoxCollapseButton * mCollapseButton
~QgsCollapsibleGroupBox()
QList< T > findChildren(const QString &name) const
QString syncGroup() const
Named group which synchronizes collapsing action when triangle is clicked while holding alt modifier ...
void checkClicked(bool ckd)
void processEvents(QFlags< QEventLoop::ProcessEventsFlag > flags)
void setChecked(bool checked)
QVariant property(const char *name) const
A groupbox that collapses/expands when toggled.
virtual void mouseReleaseEvent(QMouseEvent *event)
void setObjectName(const QString &name)
void setSyncGroup(const QString &grp)
Named group which synchronizes collapsing action when triangle is clicked while holding alt modifier ...
void mouseReleaseEvent(QMouseEvent *event) override
bool contains(const QPoint &point, bool proper) const
void setSettings(QSettings *settings)
void mousePressEvent(QMouseEvent *event) override
QVariant value(const QString &key, const QVariant &defaultValue) const
QgsCollapsibleGroupBoxBasic(QWidget *parent=nullptr)
virtual void changeEvent(QEvent *ev)
void showEvent(QShowEvent *event) override
void initStyleOption(QStyleOptionGroupBox *option) const
void loadState()
Will load the collapsed and checked state.
void checkToggled(bool ckd)
bool setProperty(const char *name, const QVariant &value)
virtual void mousePressEvent(QMouseEvent *event)
const QPoint & pos() const
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
virtual bool event(QEvent *e)
QPointer< QSettings > mSettings
void collapseExpandFixes()
Visual fixes for when group box is collapsed/expanded.