Skip to content

Commit 927be9a

Browse files
author
Uwe Kindler
committed
Improved detection of dock widget dragging - uses a distance now (half the height of dock area title bar)
1 parent ada3d6b commit 927be9a

File tree

7 files changed

+26
-7
lines changed

7 files changed

+26
-7
lines changed

src/DockAreaTabBar.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,9 @@ void CDockAreaTabBar::mouseMoveEvent(QMouseEvent* ev)
186186
return;
187187
}
188188

189-
if (!this->geometry().contains(ev->pos()))
189+
int DragDistanceY = qAbs(d->DragStartMousePos.y() - ev->pos().y());
190+
int MinDragDistanceY = this->height() / 2;
191+
if (DragDistanceY >= MinDragDistanceY)
190192
{
191193
qDebug() << "CTabsScrollArea::startFloating";
192194
startFloating(d->DragStartMousePos);

src/DockAreaTabBar.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ public slots:
163163
void currentChanged(int Index);
164164

165165
/**
166-
* This signal is emitted when user clicks on a tab at an index.
166+
* This signal is emitted when user clicks on a tab
167167
*/
168168
void tabBarClicked(int index);
169169

src/DockAreaTitleBar.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ void DockAreaTitleBarPrivate::createButtons()
8484
_this->connect(TabsMenu, SIGNAL(aboutToShow()), SLOT(onTabsMenuAboutToShow()));
8585
TabsMenuButton->setMenu(TabsMenu);
8686
TopLayout->addWidget(TabsMenuButton, 0);
87-
TabsMenuButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
87+
TabsMenuButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
8888
_this->connect(TabsMenuButton->menu(), SIGNAL(triggered(QAction*)),
8989
SLOT(onTabsMenuActionTriggered(QAction*)));
9090

@@ -93,7 +93,7 @@ void DockAreaTitleBarPrivate::createButtons()
9393
CloseButton->setFlat(true);
9494
CloseButton->setIcon(_this->style()->standardIcon(QStyle::SP_TitleBarCloseButton));
9595
CloseButton->setToolTip(QObject::tr("Close"));
96-
CloseButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
96+
CloseButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
9797
TopLayout->addWidget(CloseButton, 0);
9898
_this->connect(CloseButton, SIGNAL(clicked()), SLOT(onCloseButtonClicked()));
9999
}
@@ -110,6 +110,7 @@ void DockAreaTitleBarPrivate::createTabBar()
110110
_this->connect(TabBar, SIGNAL(removingTab(int)), SLOT(markTabsMenuOutdated()));
111111
_this->connect(TabBar, SIGNAL(tabMoved(int, int)), SLOT(markTabsMenuOutdated()));
112112
_this->connect(TabBar, SIGNAL(currentChanged(int)), SLOT(onCurrentTabChanged(int)));
113+
_this->connect(TabBar, SIGNAL(tabBarClicked(int)), SIGNAL(tabBarClicked(int)));
113114
}
114115

115116

@@ -192,6 +193,7 @@ void CDockAreaTitleBar::onTabsMenuActionTriggered(QAction* Action)
192193
{
193194
int Index = Action->data().toInt();
194195
d->TabBar->setCurrentIndex(Index);
196+
emit tabBarClicked(Index);
195197
}
196198

197199

src/DockAreaTitleBar.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@ private slots:
7171
* Returns the pointer to the tabBar()
7272
*/
7373
CDockAreaTabBar* tabBar() const;
74+
75+
signals:
76+
/**
77+
* This signal is emitted if a tab in the tab bar is clicked by the user
78+
* or if the user clicks on a tab item in the title bar tab menu.
79+
*/
80+
void tabBarClicked(int index);
7481
}; // class name
7582
}
7683
// namespace ads

src/DockAreaWidget.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ void DockAreaWidgetPrivate::createTitleBar()
289289
Layout->addWidget(TitleBar);
290290
_this->connect(tabBar(), SIGNAL(tabCloseRequested(int)),
291291
SLOT(onTabCloseRequested(int)));
292-
_this->connect(tabBar(), SIGNAL(tabBarClicked(int)),
292+
_this->connect(TitleBar, SIGNAL(tabBarClicked(int)),
293293
SLOT(setCurrentIndex(int)));
294294
_this->connect(tabBar(), SIGNAL(tabMoved(int, int)),
295295
SLOT(reorderDockWidget(int, int)));

src/DockManager.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,12 @@ bool DockManagerPrivate::restoreState(const QByteArray &state, int version)
225225
return false;
226226
}
227227

228+
// Hide updates of floatingf widgets from use
229+
for (auto FloatingWidget : FloatingWidgets)
230+
{
231+
FloatingWidget->hide();
232+
}
233+
228234
for (auto DockWidget : DockWidgetsMap)
229235
{
230236
DockWidget->setProperty("dirty", true);

src/DockWidgetTab.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,10 @@ void CDockWidgetTab::mouseMoveEvent(QMouseEvent* ev)
279279
d->moveTab(ev);
280280
}
281281

282-
bool MouseInsideTitleArea = d->titleAreaGeometryContains(ev->globalPos());
283-
if (!MouseInsideTitleArea)
282+
// Maybe a fixed drag distance is better here ?
283+
int DragDistanceY = qAbs(d->DragStartMousePosition.y() - ev->pos().y());
284+
int MinDragDistanceY = d->DockArea->titleBarGeometry().height() / 2;
285+
if (DragDistanceY >= MinDragDistanceY)
284286
{
285287
// If this is the last dock area in a dock container with only
286288
// one single dock widget it does not make sense to move it to a new

0 commit comments

Comments
 (0)