diff --git a/useractions.h b/useractions.h --- a/useractions.h +++ b/useractions.h @@ -26,6 +26,7 @@ // Qt #include #include +#include class QAction; class QRect; @@ -98,7 +99,7 @@ * @param pos The position where the menu should be shown. * @param client The Client for which the Menu has to be shown. */ - void show(const QRect &pos, const QWeakPointer &client); + void show(const QRect &pos, AbstractClient *client); public Q_SLOTS: /** @@ -219,7 +220,7 @@ * @param message The message type to be shown * @param c The Client for which the dialog should be shown. */ - void helperDialog(const QString &message, const QWeakPointer &c); + void helperDialog(const QString &message, AbstractClient *c); /** * The actual main context menu which is show when the UserActionsMenu is invoked. */ @@ -274,7 +275,7 @@ /** * The Client for which the menu is shown. */ - QWeakPointer m_client; + QPointer m_client; QAction *m_rulesOperation = nullptr; QAction *m_applicationRulesOperation = nullptr; }; diff --git a/useractions.cpp b/useractions.cpp --- a/useractions.cpp +++ b/useractions.cpp @@ -96,7 +96,6 @@ , m_closeOperation(NULL) , m_removeFromTabGroup(NULL) , m_closeTabGroup(NULL) - , m_client(QWeakPointer()) { } @@ -132,8 +131,9 @@ return c == m_client.data(); } -void UserActionsMenu::show(const QRect &pos, const QWeakPointer &cl) +void UserActionsMenu::show(const QRect &pos, AbstractClient* client) { + QPointer cl(client); if (!KAuthorized::authorizeAction(QStringLiteral("kwin_rmb"))) return; if (cl.isNull()) @@ -189,7 +189,7 @@ m_menu->windowHandle()->setKeyboardGrabEnabled(true); } -void UserActionsMenu::helperDialog(const QString& message, const QWeakPointer &c) +void UserActionsMenu::helperDialog(const QString& message, AbstractClient* client) { QStringList args; QString type; @@ -226,8 +226,8 @@ return; args << QStringLiteral("--dontagain") << QLatin1String("kwin_dialogsrc:") + type; } - if (!c.isNull()) - args << QStringLiteral("--embed") << QString::number(c.data()->windowId()); + if (client) + args << QStringLiteral("--embed") << QString::number(client->windowId()); QtConcurrent::run([args]() { KProcess::startDetached(QStringLiteral("kdialog"), args); }); @@ -835,17 +835,17 @@ return; Options::WindowOperation op = static_cast< Options::WindowOperation >(action->data().toInt()); - QWeakPointer c = (!m_client.isNull()) ? m_client : QWeakPointer(Workspace::self()->activeClient()); + QPointer c = m_client ? m_client : QPointer(Workspace::self()->activeClient()); if (c.isNull()) return; QString type; switch(op) { case Options::FullScreenOp: - if (!c.data()->isFullScreen() && c.data()->userCanSetFullScreen()) + if (!c->isFullScreen() && c->userCanSetFullScreen()) type = QStringLiteral("fullscreenaltf3"); break; case Options::NoBorderOp: - if (!c.data()->noBorder() && c.data()->userCanSetNoBorder()) + if (!c->noBorder() && c->userCanSetNoBorder()) type = QStringLiteral("noborderaltf3"); break; default: @@ -858,7 +858,7 @@ qRegisterMetaType(); QMetaObject::invokeMethod(workspace(), "performWindowOperation", Qt::QueuedConnection, - Q_ARG(KWin::AbstractClient*, c.data()), + Q_ARG(KWin::AbstractClient*, c), Q_ARG(Options::WindowOperation, op)); }