From e873efdc994ddce1d0eee6e3d04d6d1f38e24b19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Fri, 2 Dec 2011 10:31:52 +0100 Subject: [PATCH] Adding an accept and reject method to TabBox --- tabbox/tabbox.cpp | 52 +++++++++++++++++++---------------------------- tabbox/tabbox.h | 2 ++ 2 files changed, 23 insertions(+), 31 deletions(-) diff --git a/tabbox/tabbox.cpp b/tabbox/tabbox.cpp index 6f458578c0..5de486ec39 100644 --- a/tabbox/tabbox.cpp +++ b/tabbox/tabbox.cpp @@ -216,21 +216,9 @@ QVector< Window > TabBoxHandlerImpl::outlineWindowIds() const void TabBoxHandlerImpl::activateAndClose() { - Client* c = NULL; - if (TabBoxClientImpl* cl = static_cast< TabBoxClientImpl* >(client(currentIndex()))) { - c = cl->client(); - } - m_tabBox->close(); - if (c) { - Workspace::self()->activateClient(c); - if (c->isShade() && options->shadeHover) - c->setShade(ShadeActivated); - if (c->isDesktop()) - Workspace::self()->setShowingDesktop(!Workspace::self()->showingDesktop()); - } + m_tabBox->accept(); } - /********************************************************* * TabBoxClientImpl *********************************************************/ @@ -695,15 +683,7 @@ void TabBox::grabbedKeyEvent(QKeyEvent* event) } if (m_noModifierGrab) { if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return || event->key() == Qt::Key_Space) { - Client* c = currentClient(); - close(); - if (c) { - Workspace::self()->activateClient(c); - if (c->isShade() && options->shadeHover) - c->setShade(ShadeActivated); - if (c->isDesktop()) - Workspace::self()->setShowingDesktop(!Workspace::self()->showingDesktop()); - } + accept(); } } setCurrentIndex(m_tabBox->grabbedKeyEvent(event)); @@ -1186,6 +1166,24 @@ void TabBox::close(bool abort) m_noModifierGrab = false; } +void TabBox::accept() +{ + Client* c = currentClient(); + close(); + if (c) { + Workspace::self()->activateClient(c); + if (c->isShade() && options->shadeHover) + c->setShade(ShadeActivated); + if (c->isDesktop()) + Workspace::self()->setShowingDesktop(!Workspace::self()->showingDesktop()); + } +} + +void TabBox::reject() +{ + close(true); +} + /*! Handles alt-tab / control-tab releasing */ @@ -1227,16 +1225,8 @@ void TabBox::keyRelease(const XKeyEvent& ev) return; if (m_tabGrab) { bool old_control_grab = m_desktopGrab; - Client* c = currentClient(); - close(); + accept(); m_desktopGrab = old_control_grab; - if (c) { - Workspace::self()->activateClient(c); - if (c->isShade() && options->shadeHover) - c->setShade(ShadeActivated); - if (c->isDesktop()) - Workspace::self()->setShowingDesktop(!Workspace::self()->showingDesktop()); - } } if (m_desktopGrab) { bool old_tab_grab = m_tabGrab; diff --git a/tabbox/tabbox.h b/tabbox/tabbox.h index 716cf7e0cb..184b01c998 100644 --- a/tabbox/tabbox.h +++ b/tabbox/tabbox.h @@ -193,6 +193,8 @@ public slots: **/ Q_SCRIPTABLE void openEmbedded(qulonglong wid, QPoint offset, QSize size, int horizontalAlignment, int verticalAlignment); Q_SCRIPTABLE void close(bool abort = false); + Q_SCRIPTABLE void accept(); + Q_SCRIPTABLE void reject(); void slotWalkThroughDesktops(); void slotWalkBackThroughDesktops(); void slotWalkThroughDesktopList();