diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,6 +38,7 @@ endif() set(KDECORATION2_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}/KDecoration2") +find_package(KF5I18n CONFIG REQUIRED) # Subdirectories add_subdirectory(src) diff --git a/autotests/mockclient.h b/autotests/mockclient.h --- a/autotests/mockclient.h +++ b/autotests/mockclient.h @@ -65,6 +65,8 @@ void requestToggleKeepBelow() override; void requestToggleOnAllDesktops() override; void requestToggleShade() override; + void requestShowToolTip(const QString &text) override; + void requestHideToolTip() override; int width() const override; WId windowId() const override; diff --git a/autotests/mockclient.cpp b/autotests/mockclient.cpp --- a/autotests/mockclient.cpp +++ b/autotests/mockclient.cpp @@ -232,6 +232,16 @@ emit client()->shadedChanged(m_shaded); } +void MockClient::requestShowToolTip(const QString &text) +{ + Q_UNUSED(text); +} + +void MockClient::requestHideToolTip() +{ + +} + int MockClient::width() const { return m_width; diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -19,6 +19,7 @@ Qt5::Gui PRIVATE kdecorations2private + KF5::I18n ) target_include_directories(kdecorations2 INTERFACE "$" ) diff --git a/src/decoration.h b/src/decoration.h --- a/src/decoration.h +++ b/src/decoration.h @@ -176,6 +176,8 @@ void requestToggleKeepAbove(); void requestToggleKeepBelow(); void requestShowWindowMenu(); + void requestShowToolTip(const QString &text); + void requestHideToolTip(); void showApplicationMenu(int actionId); void requestShowApplicationMenu(const QRect &rect, int actionId); diff --git a/src/decoration.cpp b/src/decoration.cpp --- a/src/decoration.cpp +++ b/src/decoration.cpp @@ -180,6 +180,16 @@ #undef DELEGATE +void Decoration::requestShowToolTip(const QString &text) +{ + d->client->d->requestShowToolTip(text); +} + +void Decoration::requestHideToolTip() +{ + d->client->d->requestHideToolTip(); +} + void Decoration::requestToggleMaximization(Qt::MouseButtons buttons) { d->client->d->requestToggleMaximization(buttons); diff --git a/src/decorationbutton.cpp b/src/decorationbutton.cpp --- a/src/decorationbutton.cpp +++ b/src/decorationbutton.cpp @@ -24,6 +24,9 @@ #include "decoratedclient.h" #include "decorationsettings.h" +#include + +#include #include #include #include @@ -284,6 +287,49 @@ } } +QString DecorationButton::Private::typeToString(DecorationButtonType type) +{ + switch (type) { + case DecorationButtonType::Menu: + return i18n("Menu"); + case DecorationButtonType::ApplicationMenu: + return i18n("Application menu"); + case DecorationButtonType::OnAllDesktops: + if ( this->q->isChecked() ) + return i18n("On one desktop"); + else + return i18n("On all desktops"); + case DecorationButtonType::Minimize: + return i18n("Minimize"); + case DecorationButtonType::Maximize: + if ( this->q->isChecked() ) + return i18n("Restore"); + else + return i18n("Maximize"); + case DecorationButtonType::Close: + return i18n("Close"); + case DecorationButtonType::ContextHelp: + return i18n("Context help"); + case DecorationButtonType::Shade: + if ( this->q->isChecked() ) + return i18n("Unshade"); + else + return i18n("Shade"); + case DecorationButtonType::KeepBelow: + if ( this->q->isChecked() ) + return i18n("Don't keep below"); + else + return i18n("Keep below"); + case DecorationButtonType::KeepAbove: + if ( this->q->isChecked() ) + return i18n("Don't keep above"); + else + return i18n("Keep above"); + default: + return QString(); + } +} + DecorationButton::DecorationButton(DecorationButtonType type, const QPointer &decoration, QObject *parent) : QObject(parent) , d(new Private(type, decoration, this)) @@ -293,6 +339,17 @@ this, static_cast(&DecorationButton::update)); auto updateSlot = static_cast(&DecorationButton::update); connect(this, &DecorationButton::hoveredChanged, this, updateSlot); + connect(this, &DecorationButton::hoveredChanged, this, + [this](bool hovered) { + if (hovered) { + //TODO: show tooltip if hovered and hide if not + const QString type = this->d->typeToString(this->type()); + this->decoration()->requestShowToolTip(type); + } else { + this->decoration()->requestHideToolTip(); + } + } + ); connect(this, &DecorationButton::pressedChanged, this, updateSlot); connect(this, &DecorationButton::checkedChanged, this, updateSlot); connect(this, &DecorationButton::enabledChanged, this, updateSlot); diff --git a/src/decorationbutton_p.h b/src/decorationbutton_p.h --- a/src/decorationbutton_p.h +++ b/src/decorationbutton_p.h @@ -66,6 +66,8 @@ void startPressAndHold(); void stopPressAndHold(); + QString typeToString(DecorationButtonType type); + QPointer decoration; DecorationButtonType type; QRectF geometry; diff --git a/src/private/CMakeLists.txt b/src/private/CMakeLists.txt --- a/src/private/CMakeLists.txt +++ b/src/private/CMakeLists.txt @@ -25,7 +25,7 @@ target_include_directories(kdecorations2private INTERFACE "$" ) set_target_properties(kdecorations2private PROPERTIES VERSION ${KDECORATION2_VERSION_STRING} - SOVERSION ${KDECORATION2_SOVERSION} + SOVERSION 6 EXPORT_NAME KDecoration2Private ) diff --git a/src/private/decoratedclientprivate.h b/src/private/decoratedclientprivate.h --- a/src/private/decoratedclientprivate.h +++ b/src/private/decoratedclientprivate.h @@ -76,6 +76,8 @@ virtual QPalette palette() const = 0; virtual Qt::Edges adjacentScreenEdges() const = 0; + virtual void requestShowToolTip(const QString &text) = 0; + virtual void requestHideToolTip() = 0; virtual void requestClose() = 0; virtual void requestToggleMaximization(Qt::MouseButtons buttons) = 0; virtual void requestMinimize() = 0;