diff --git a/clients/aurorae/src/aurorae.cpp b/clients/aurorae/src/aurorae.cpp index 76eb527240..886df59591 100644 --- a/clients/aurorae/src/aurorae.cpp +++ b/clients/aurorae/src/aurorae.cpp @@ -422,6 +422,11 @@ void AuroraeClient::themeChanged() m_scene->addItem(m_item); } +int AuroraeClient::doubleClickInterval() const +{ + return QApplication::doubleClickInterval(); +} + } // namespace Aurorae extern "C" diff --git a/clients/aurorae/src/aurorae.h b/clients/aurorae/src/aurorae.h index 8088aaa37f..48211ee770 100644 --- a/clients/aurorae/src/aurorae.h +++ b/clients/aurorae/src/aurorae.h @@ -100,6 +100,7 @@ class AuroraeClient : public KDecorationUnstable Q_PROPERTY(QRect transparentRect READ transparentRect) Q_PROPERTY(int width READ width) Q_PROPERTY(qulonglong windowId READ windowId CONSTANT) + Q_PROPERTY(int doubleClickInterval READ doubleClickInterval) // TODO: window tabs - they suck for dynamic features public: AuroraeClient(KDecorationBridge* bridge, KDecorationFactory* factory); @@ -119,6 +120,7 @@ public: virtual void padding(int &left, int &right, int &top, int &bottom) const; virtual void reset(long unsigned int changed); bool isMaximized() const; + int doubleClickInterval() const; Q_SIGNALS: void activeChanged(); diff --git a/clients/aurorae/src/qml/MenuButton.qml b/clients/aurorae/src/qml/MenuButton.qml index 186df8111e..2f6183c1f0 100644 --- a/clients/aurorae/src/qml/MenuButton.qml +++ b/clients/aurorae/src/qml/MenuButton.qml @@ -23,4 +23,46 @@ DecorationButton { icon: decoration.icon anchors.fill: parent } + Timer { + id: timer + interval: decoration.doubleClickInterval + repeat: false + onTriggered: decoration.menuClicked() + } + MouseArea { + anchors.fill: parent + acceptedButtons: Qt.LeftButton | Qt.RightButton + onPressed: { + parent.pressed = true; + // we need a timer to figure out whether there is a double click in progress or not + // if we have a "normal" click we want to open the context menu. This would eat our + // second click of the double click. To properly get the double click we have to wait + // the double click delay to ensure that it was only a single click. + if (timer.running) { + timer.stop(); + } else { + timer.start(); + } + } + onReleased: { + parent.pressed = false; + } + onExited: { + if (!parent.pressed) { + return; + } + if (timer.running) { + timer.stop(); + } + parent.pressed = false; + } + onClicked: { + // for right clicks we show the menu instantly + if (mouse.button == Qt.RightButton) { + decoration.menuClicked(); + timer.stop(); + } + } + onDoubleClicked: decoration.closeWindow() + } }