@@ -60,6 +60,8 @@ void QgsCollapsibleGroupBoxBasic::init()
60
60
mParentScrollArea = 0 ;
61
61
mSyncParent = 0 ;
62
62
mSyncGroup = " " ;
63
+ mAltDown = false ;
64
+ mTitleClicked = false ;
63
65
64
66
// init icons
65
67
if ( mCollapseIcon .isNull () )
@@ -130,17 +132,35 @@ void QgsCollapsibleGroupBoxBasic::showEvent( QShowEvent * event )
130
132
event->accept ();
131
133
}
132
134
135
+ void QgsCollapsibleGroupBoxBasic::mousePressEvent ( QMouseEvent *event )
136
+ {
137
+ // avoid leaving checkbox in pressed state if alt-clicking
138
+ if ( event->modifiers () & Qt::AltModifier
139
+ && titleRect ().contains ( event->pos () )
140
+ && isCheckable () )
141
+ {
142
+ event->ignore ();
143
+ return ;
144
+ }
145
+
146
+ // default behaviour - pass to QGroupBox
147
+ QGroupBox::mousePressEvent ( event );
148
+ }
149
+
133
150
void QgsCollapsibleGroupBoxBasic::mouseReleaseEvent ( QMouseEvent *event )
134
151
{
135
- // catch mouse release over title when non checkable, to collapse/expand
136
- if ( !isCheckable () && event->button () == Qt::LeftButton )
152
+ mAltDown = ( event->modifiers () & Qt::AltModifier );
153
+ mTitleClicked = ( titleRect ().contains ( event->pos () ) );
154
+
155
+ // sync group when title is alt-clicked
156
+ // collapse/expand when title is clicked and non-checkable
157
+ if ( event->button () == Qt::LeftButton && mTitleClicked &&
158
+ ( mAltDown || !isCheckable () ) )
137
159
{
138
- if ( titleRect ().contains ( event->pos () ) )
139
- {
140
- toggleCollapsed ();
141
- return ;
142
- }
160
+ toggleCollapsed ();
161
+ return ;
143
162
}
163
+
144
164
// default behaviour - pass to QGroupBox
145
165
QGroupBox::mouseReleaseEvent ( event );
146
166
}
@@ -183,9 +203,11 @@ void QgsCollapsibleGroupBoxBasic::toggleCollapsed()
183
203
senderCollBtn = ( collBtn && collBtn == mCollapseButton );
184
204
185
205
// find any sync group siblings and toggle them
186
- if ( senderCollBtn && mCollapseButton ->altDown () && !mSyncGroup .isEmpty () )
206
+ if ((( senderCollBtn && mCollapseButton ->altDown () ) || ( mTitleClicked && mAltDown ) )
207
+ && !mSyncGroup .isEmpty () )
187
208
{
188
209
mCollapseButton ->setAltDown ( false );
210
+ mAltDown = false ;
189
211
QgsDebugMsg ( " Alt key down, syncing group" );
190
212
// get pointer to parent or grandparent widget
191
213
if ( parentWidget () )
0 commit comments