diff --git a/src/decoration.h b/src/decoration.h --- a/src/decoration.h +++ b/src/decoration.h @@ -27,6 +27,7 @@ #include #include #include +#include class QHoverEvent; class QMouseEvent; @@ -113,6 +114,20 @@ **/ QWeakPointer client() const; + /** + * All @link{DecoratedClient}s for this Decoration in case window tabs are used. + * If no window tabs are used, this contains just the DecoratedClient returned by @link client. + * If window tabs are used the returned vector is in order of the tabs. + * + * If the tabs change (order, adding or removing tabs) the signal clientsChanged is emitted. + * + * Ownership of the @link{DecoratedClient}s is with the Decoration objects owning the + * Decoration. + * @since 5.14 + * @see client + **/ + QVector windowTabClients() const; + QMargins borders() const; int borderLeft() const; int borderRight() const; @@ -167,7 +182,18 @@ bool event(QEvent *event) override; public Q_SLOTS: + /** + * Requests to close the window tab group. + * In case no window tabs are used only the DecoratedClient for this Decoration is requested to close. + * @see requestCloseWindowTab + **/ void requestClose(); + /** + * Requests to close the window tab referring to the DecoratedClient @p client. + * @see requestClose + * @since 5.14 + **/ + void requestCloseWindowTab(DecoratedClient *client); void requestToggleMaximization(Qt::MouseButtons buttons); void requestMinimize(); void requestContextHelp(); @@ -178,6 +204,13 @@ void requestShowWindowMenu(); void requestShowToolTip(const QString &text); void requestHideToolTip(); + /** + * Requests to activate the window tab @p client. + * Only a Decoration which contains the active DecoratedClient can request to activate + * another DecoratedClient in it's window tab group. + * @since 5.14 + **/ + void requestActivateWindowTab(DecoratedClient *client); void showApplicationMenu(int actionId); void requestShowApplicationMenu(const QRect &rect, int actionId); @@ -201,6 +234,11 @@ void titleBarChanged(); void opaqueChanged(bool); void shadowChanged(const QSharedPointer &shadow); + /** + * The vector returned by @link{windowTabClients} changed. + * @since 5.14 + **/ + void windowTabClientsChanged(); protected: /** diff --git a/src/decoration.cpp b/src/decoration.cpp --- a/src/decoration.cpp +++ b/src/decoration.cpp @@ -169,7 +169,6 @@ d->client->d->name(); \ } -DELEGATE(requestClose) DELEGATE(requestContextHelp) DELEGATE(requestMinimize) DELEGATE(requestToggleOnAllDesktops) @@ -410,4 +409,33 @@ return d->settings; } +QVector Decoration::windowTabClients() const +{ + if (auto c = dynamic_cast(d->client->d.get())) { + return c->tabGroup(); + } + return {d->client.data()}; +} + +void Decoration::requestClose() +{ + if (auto c = dynamic_cast(d->client->d.get())) { + c->requestCloseWindowTabGroup(); + } else { + d->client->d->requestClose(); + } +} + +void Decoration::requestCloseWindowTab(DecoratedClient *client) +{ + client->d->requestClose(); +} + +void Decoration::requestActivateWindowTab(DecoratedClient *client) +{ + if (auto c = dynamic_cast(client->d.get())) { + return c->requestActivate(); + } +} + } // namespace diff --git a/src/private/decoratedclientprivate.h b/src/private/decoratedclientprivate.h --- a/src/private/decoratedclientprivate.h +++ b/src/private/decoratedclientprivate.h @@ -25,6 +25,7 @@ #include #include +#include // // W A R N I N G @@ -117,6 +118,32 @@ explicit ApplicationMenuEnabledDecoratedClientPrivate(DecoratedClient *client, Decoration *decoration); }; +class KDECORATIONS_PRIVATE_EXPORT WindowTabsEnabledDecoratedClientPrivate : public ApplicationMenuEnabledDecoratedClientPrivate +{ +public: + ~WindowTabsEnabledDecoratedClientPrivate() override; + + /** + * All clients of the window tab group. + * In case there is only this DecoratedClient in the window tab group the returned vector should + * only contain this DecoratedClient. + **/ + virtual QVector tabGroup() const = 0; + + /** + * Requests to activate this DecoratedClient in the window tab group. + **/ + virtual void requestActivate() = 0; + + /** + * Requests to close all clients in the window tab group. + **/ + virtual void requestCloseWindowTabGroup() = 0; + +protected: + explicit WindowTabsEnabledDecoratedClientPrivate(DecoratedClient *client, Decoration *decoration); +}; + } // namespace #endif diff --git a/src/private/decoratedclientprivate.cpp b/src/private/decoratedclientprivate.cpp --- a/src/private/decoratedclientprivate.cpp +++ b/src/private/decoratedclientprivate.cpp @@ -71,9 +71,17 @@ ApplicationMenuEnabledDecoratedClientPrivate::ApplicationMenuEnabledDecoratedClientPrivate(DecoratedClient *client, Decoration *decoration) : DecoratedClientPrivate(client, decoration) { - } ApplicationMenuEnabledDecoratedClientPrivate::~ApplicationMenuEnabledDecoratedClientPrivate() = default; + +WindowTabsEnabledDecoratedClientPrivate::WindowTabsEnabledDecoratedClientPrivate(DecoratedClient *client, Decoration *decoration) + : ApplicationMenuEnabledDecoratedClientPrivate(client, decoration) +{ + +} + +WindowTabsEnabledDecoratedClientPrivate::~WindowTabsEnabledDecoratedClientPrivate() = default; + }