@@ -54,13 +54,10 @@ namespace ads
54
54
struct DockAreaTabBarPrivate
55
55
{
56
56
CDockAreaTabBar* _this;
57
- QPoint DragStartMousePos;
58
57
CDockAreaWidget* DockArea;
59
- IFloatingWidget* FloatingWidget = nullptr ;
60
58
QWidget* TabsContainerWidget;
61
59
QBoxLayout* TabsLayout;
62
60
int CurrentIndex = -1 ;
63
- eDragState DragState = DraggingInactive;
64
61
65
62
/* *
66
63
* Private data constructor
@@ -72,14 +69,6 @@ struct DockAreaTabBarPrivate
72
69
* The function reassigns the stylesheet to update the tabs
73
70
*/
74
71
void updateTabs ();
75
-
76
- /* *
77
- * Test function for current drag state
78
- */
79
- bool isDraggingState (eDragState dragState) const
80
- {
81
- return this ->DragState == dragState;
82
- }
83
72
};
84
73
// struct DockAreaTabBarPrivate
85
74
@@ -164,149 +153,6 @@ void CDockAreaTabBar::wheelEvent(QWheelEvent* Event)
164
153
}
165
154
166
155
167
- // ============================================================================
168
- void CDockAreaTabBar::mousePressEvent (QMouseEvent* ev)
169
- {
170
- if (ev->button () == Qt::LeftButton)
171
- {
172
- ev->accept ();
173
- d->DragStartMousePos = ev->pos ();
174
- d->DragState = DraggingMousePressed;
175
- return ;
176
- }
177
- Super::mousePressEvent (ev);
178
- }
179
-
180
-
181
- // ============================================================================
182
- void CDockAreaTabBar::mouseReleaseEvent (QMouseEvent* ev)
183
- {
184
- if (ev->button () == Qt::LeftButton)
185
- {
186
- ADS_PRINT (" CDockAreaTabBar::mouseReleaseEvent" );
187
- ev->accept ();
188
- auto CurrentDragState = d->DragState ;
189
- d->DragStartMousePos = QPoint ();
190
- d->DragState = DraggingInactive;
191
- if (DraggingFloatingWidget == CurrentDragState)
192
- {
193
- d->FloatingWidget ->finishDragging ();
194
- }
195
- return ;
196
- }
197
- Super::mouseReleaseEvent (ev);
198
- }
199
-
200
-
201
- // ============================================================================
202
- void CDockAreaTabBar::mouseMoveEvent (QMouseEvent* ev)
203
- {
204
- Super::mouseMoveEvent (ev);
205
- if (!(ev->buttons () & Qt::LeftButton) || d->isDraggingState (DraggingInactive))
206
- {
207
- d->DragState = DraggingInactive;
208
- return ;
209
- }
210
-
211
- // move floating window
212
- if (d->isDraggingState (DraggingFloatingWidget))
213
- {
214
- d->FloatingWidget ->moveFloating ();
215
- return ;
216
- }
217
-
218
- // If this is the last dock area in a dock container it does not make
219
- // sense to move it to a new floating widget and leave this one
220
- // empty
221
- if (d->DockArea ->dockContainer ()->isFloating ()
222
- && d->DockArea ->dockContainer ()->visibleDockAreaCount () == 1 )
223
- {
224
- return ;
225
- }
226
-
227
- // If one single dock widget in this area is not floatable then the whole
228
- // area is not floatable
229
- if (!d->DockArea ->features ().testFlag (CDockWidget::DockWidgetFloatable))
230
- {
231
- return ;
232
- }
233
-
234
- int DragDistance = (d->DragStartMousePos - ev->pos ()).manhattanLength ();
235
- if (DragDistance >= CDockManager::startDragDistance ())
236
- {
237
- ADS_PRINT (" CTabsScrollArea::startFloating" );
238
- startFloating (d->DragStartMousePos );
239
- auto Overlay = d->DockArea ->dockManager ()->containerOverlay ();
240
- Overlay->setAllowedAreas (OuterDockAreas);
241
- }
242
-
243
- return ;
244
- }
245
-
246
-
247
- // ============================================================================
248
- void CDockAreaTabBar::mouseDoubleClickEvent (QMouseEvent *event)
249
- {
250
- // If this is the last dock area in a dock container it does not make
251
- // sense to move it to a new floating widget and leave this one
252
- // empty
253
- if (d->DockArea ->dockContainer ()->isFloating () && d->DockArea ->dockContainer ()->dockAreaCount () == 1 )
254
- {
255
- return ;
256
- }
257
-
258
- if (!d->DockArea ->features ().testFlag (CDockWidget::DockWidgetFloatable))
259
- {
260
- return ;
261
- }
262
- makeAreaFloating (event->pos (), DraggingInactive);
263
- }
264
-
265
-
266
- // ============================================================================
267
- IFloatingWidget* CDockAreaTabBar::makeAreaFloating (const QPoint& Offset, eDragState DragState)
268
- {
269
- QSize Size = d->DockArea ->size ();
270
- d->DragState = DragState;
271
- bool OpaqueUndocking = CDockManager::configFlags ().testFlag (CDockManager::OpaqueUndocking) ||
272
- (DraggingFloatingWidget != DragState);
273
- CFloatingDockContainer* FloatingDockContainer = nullptr ;
274
- IFloatingWidget* FloatingWidget;
275
- if (OpaqueUndocking)
276
- {
277
- FloatingWidget = FloatingDockContainer = new CFloatingDockContainer (d->DockArea );
278
- }
279
- else
280
- {
281
- auto w = new CFloatingDragPreview (d->DockArea );
282
- connect (w, &CFloatingDragPreview::draggingCanceled, [=]()
283
- {
284
- d->DragState = DraggingInactive;
285
- });
286
- FloatingWidget = w;
287
- }
288
-
289
- FloatingWidget->startFloating (Offset, Size, DragState, nullptr );
290
- if (FloatingDockContainer)
291
- {
292
- auto TopLevelDockWidget = FloatingDockContainer->topLevelDockWidget ();
293
- if (TopLevelDockWidget)
294
- {
295
- TopLevelDockWidget->emitTopLevelChanged (true );
296
- }
297
- }
298
-
299
- return FloatingWidget;
300
- }
301
-
302
-
303
- // ============================================================================
304
- void CDockAreaTabBar::startFloating (const QPoint& Offset)
305
- {
306
- d->FloatingWidget = makeAreaFloating (Offset, DraggingFloatingWidget);
307
- }
308
-
309
-
310
156
// ============================================================================
311
157
void CDockAreaTabBar::setCurrentIndex (int index)
312
158
{
@@ -625,7 +471,6 @@ bool CDockAreaTabBar::isTabOpen(int Index) const
625
471
QSize CDockAreaTabBar::minimumSizeHint () const
626
472
{
627
473
QSize Size = sizeHint ();
628
- // Size.setWidth(Super::minimumSizeHint().width());// this defines the minimum width of a dock area
629
474
Size.setWidth (10 );
630
475
return Size;
631
476
}
@@ -637,13 +482,6 @@ QSize CDockAreaTabBar::sizeHint() const
637
482
return d->TabsContainerWidget ->sizeHint ();
638
483
}
639
484
640
-
641
- // ===========================================================================
642
- eDragState CDockAreaTabBar::dragState () const
643
- {
644
- return d->DragState ;
645
- }
646
-
647
485
} // namespace ads
648
486
649
487
0 commit comments