[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [konsole] src: Use QApplication::startDragTime() for tab movement
From:       Kurt Hindenburg <kurt.hindenburg () gmail ! com>
Date:       2015-11-26 13:49:39
Message-ID: E1a1wvb-0000pF-Vl () scm ! kde ! org
[Download RAW message or body]

Git commit 818a0ad6a3ec6cd181503efcdf3974500e81bff4 by Kurt Hindenburg.
Committed on 26/11/2015 at 13:49.
Pushed by hindenburg into branch 'master'.

Use QApplication::startDragTime() for tab movement

Currently there is no delay for dragging tabs.  This patch uses the
> > startDragTime() to delay the tab movement.

REVIEW: 126067
BUG: 355248

M  +11   -1    src/ViewContainerTabBar.cpp
M  +3    -0    src/ViewContainerTabBar.h

http://commits.kde.org/konsole/818a0ad6a3ec6cd181503efcdf3974500e81bff4

diff --git a/src/ViewContainerTabBar.cpp b/src/ViewContainerTabBar.cpp
index e5ade24..6e3ea6d 100644
--- a/src/ViewContainerTabBar.cpp
+++ b/src/ViewContainerTabBar.cpp
@@ -54,13 +54,22 @@ ViewContainerTabBar::ViewContainerTabBar(QWidget* \
parent, TabbedViewContainer* c  setAcceptDrops(true);
     setMouseTracking(true);
 
+    _mousePressTimer = new QElapsedTimer();
+
     setWhatsThis(xi18nc("@info:whatsthis",
                        "<title>Tab Bar</title>"
                        "<para>The tab bar allows you to switch and move \
tabs. You can double-click a tab to change its name.</para>"));  }
 
+ViewContainerTabBar::~ViewContainerTabBar()
+{
+    delete _mousePressTimer;
+}
+
 void ViewContainerTabBar::mousePressEvent(QMouseEvent* event)
 {
+    _mousePressTimer->start();
+
     if (event->buttons() == Qt::LeftButton) {
         _dragStart = event->pos();
     }
@@ -71,7 +80,8 @@ void ViewContainerTabBar::mouseMoveEvent(QMouseEvent* \
event)  {
     if (event->buttons() == Qt::LeftButton) {
         QPoint dragPos = _dragStart - event->pos();
-        if (dragPos.manhattanLength() > QApplication::startDragDistance()) \
{ +        if (dragPos.manhattanLength() > \
QApplication::startDragDistance() +            && \
_mousePressTimer->elapsed() > QApplication::startDragTime()) {  int tab = \
tabAt(_dragStart);  if (tab != -1) {
                 emit initiateDrag(tab);
diff --git a/src/ViewContainerTabBar.h b/src/ViewContainerTabBar.h
index fd55a25..c937b2b 100644
--- a/src/ViewContainerTabBar.h
+++ b/src/ViewContainerTabBar.h
@@ -22,6 +22,7 @@
 #ifndef VIEWCONTAINERTABBAR_H
 #define VIEWCONTAINERTABBAR_H
 
+#include <QElapsedTimer>
 #include <QTabBar>
 
 class QLabel;
@@ -36,6 +37,7 @@ class ViewContainerTabBar : public QTabBar
 
 public:
     ViewContainerTabBar(QWidget* parent, TabbedViewContainer* container);
+    ~ViewContainerTabBar();
 
     // returns a pixmap image of a tab for use with QDrag
     QPixmap dragDropPixmap(int tab);
@@ -78,6 +80,7 @@ private:
     QString _supportedMimeType;
     TabbedViewContainer* _connectedContainer;
     QPoint _dragStart;
+    QElapsedTimer* _mousePressTimer;
 
 };
 }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic