[SCM] ktp-text-ui packaging branch, master, updated. debian/15.12.1-1-1918-gdf4b0ec
Maximiliano Curia
maxy at moszumanska.debian.org
Sat May 28 00:25:14 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-text-ui.git;a=commitdiff;h=c34cba2
The following commit has been merged in the master branch:
commit c34cba28679714b34ee0065692f249347e13e72c
Author: Martin Klapetek <mklapetek at kde.org>
Date: Tue Feb 10 17:09:30 2015 +0100
[app] Handle middle mouse button clicks on the tab widget
With porting from KTabWidget to QTabWidget we've lost the ability to get
handle middle mouse clicks on the tabs and as of Qt 5.4 there's no way
to get middle mouse click events other than reimplementing
mouseReleaseEvent.
Now it closes the tab again.
---
app/chat-window.cpp | 40 ++++++++++++++++++++++++++++++++++++++--
app/chat-window.h | 3 ++-
2 files changed, 40 insertions(+), 3 deletions(-)
diff --git a/app/chat-window.cpp b/app/chat-window.cpp
index 7bb87c0..de07445 100644
--- a/app/chat-window.cpp
+++ b/app/chat-window.cpp
@@ -53,6 +53,7 @@
#include <QWidgetAction>
#include <QLabel>
#include <QLineEdit>
+#include <QMouseEvent>
#include <TelepathyQt/Account>
#include <TelepathyQt/ContactCapabilities>
@@ -77,6 +78,39 @@
#define PREFERRED_RFB_HANDLER "org.freedesktop.Telepathy.Client.krfb_rfb_handler"
+// FIXME
+// As of Qt 5.4 there's no way to get middle mouse click
+// event other than reimplementing mouseReleaseEvent
+// Remove this class once Qt has something for this
+class MiddleMouseButtonHandler : public QTabWidget
+{
+ Q_OBJECT
+public:
+ MiddleMouseButtonHandler(QWidget *parent);
+
+Q_SIGNALS:
+ void mouseMiddleClick(int index);
+
+protected:
+ virtual void mouseReleaseEvent(QMouseEvent *event);
+};
+
+MiddleMouseButtonHandler::MiddleMouseButtonHandler(QWidget *parent)
+ : QTabWidget(parent)
+{
+}
+
+void MiddleMouseButtonHandler::mouseReleaseEvent(QMouseEvent *event)
+{
+ if (event->button() == Qt::MiddleButton) {
+ Q_EMIT mouseMiddleClick(tabBar()->tabAt(event->pos()));
+ }
+
+ QTabWidget::mouseReleaseEvent(event);
+}
+
+//------------------------------------------------------------------------------
+
Q_GLOBAL_STATIC_WITH_ARGS(KTp::ServiceAvailabilityChecker, s_krfbAvailableChecker,
(QLatin1String(PREFERRED_RFB_HANDLER)));
@@ -123,7 +157,7 @@ ChatWindow::ChatWindow()
connect(m_keyboardLayoutInterface, SIGNAL(currentLayoutChanged(QString)), this, SLOT(onKeyboardLayoutChange(QString)));
// set up m_tabWidget
- m_tabWidget = new QTabWidget(this);
+ m_tabWidget = new MiddleMouseButtonHandler(this);
//clicking on the close button can result in the tab bar getting focus, this works round that
m_tabWidget->setFocusPolicy(Qt::TabFocus);
m_tabWidget->setMovable(true);
@@ -136,7 +170,7 @@ ChatWindow::ChatWindow()
connect(m_tabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(destroyTab(int)));
connect(m_tabWidget, SIGNAL(currentChanged(int)), this, SLOT(onCurrentIndexChanged(int)));
- connect(qobject_cast<QTabBar*>(m_tabWidget->tabBar()), SIGNAL(mouseMiddleClick(int)), this, SLOT(onTabMiddleClicked(int)));
+ connect(m_tabWidget, SIGNAL(mouseMiddleClick(int)), this, SLOT(onTabMiddleClicked(int)));
connect(qobject_cast<QTabBar*>(m_tabWidget->tabBar()), SIGNAL(customContextMenuRequested(QPoint)), SLOT(tabBarContextMenu(QPoint)));
setCentralWidget(m_tabWidget);
@@ -1329,3 +1363,5 @@ void ChatWindow::onLeaveChannelTriggered()
tab->textChannel()->requestLeave();
closeCurrentTab();
}
+
+#include "chat-window.moc"
diff --git a/app/chat-window.h b/app/chat-window.h
index 25eceb7..0d1e0bb 100644
--- a/app/chat-window.h
+++ b/app/chat-window.h
@@ -38,6 +38,7 @@ namespace Sonnet {
class ChatTab;
class QLabel;
class QDBusPendingCallWatcher;
+class MiddleMouseButtonHandler;
class ChatWindow : public KXmlGuiWindow
{
@@ -216,7 +217,7 @@ private:
QAction *m_sendMessage;
- QTabWidget *m_tabWidget;
+ MiddleMouseButtonHandler *m_tabWidget;
QDBusInterface *m_keyboardLayoutInterface;
Sonnet::DictionaryComboBox *m_spellDictCombo;
--
ktp-text-ui packaging
More information about the pkg-kde-commits
mailing list