Index: CMakeLists.txt =================================================================== --- CMakeLists.txt +++ CMakeLists.txt @@ -38,6 +38,7 @@ endif() set(KDECORATION2_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}/KDecoration2") +find_package(KF5I18n CONFIG REQUIRED) # Subdirectories add_subdirectory(src) Index: src/CMakeLists.txt =================================================================== --- src/CMakeLists.txt +++ src/CMakeLists.txt @@ -19,6 +19,7 @@ Qt5::Gui PRIVATE kdecorations2private + KF5::I18n ) target_include_directories(kdecorations2 INTERFACE "$" ) Index: src/decoration.h =================================================================== --- src/decoration.h +++ src/decoration.h @@ -176,6 +176,8 @@ void requestToggleKeepAbove(); void requestToggleKeepBelow(); void requestShowWindowMenu(); + void requestShowToolTip(QString text); + void requestHideToolTip(); void showApplicationMenu(int actionId); void requestShowApplicationMenu(const QRect &rect, int actionId); Index: src/decoration.cpp =================================================================== --- src/decoration.cpp +++ src/decoration.cpp @@ -180,6 +180,17 @@ #undef DELEGATE +void Decoration::requestShowToolTip(QString text) +{ + QString &textref = text; + d->client->d->requestShowToolTip(textref); +} + +void Decoration::requestHideToolTip() +{ + d->client->d->requestHideToolTip(); +} + void Decoration::requestToggleMaximization(Qt::MouseButtons buttons) { d->client->d->requestToggleMaximization(buttons); Index: src/decorationbutton.cpp =================================================================== --- src/decorationbutton.cpp +++ src/decorationbutton.cpp @@ -24,6 +24,9 @@ #include "decoratedclient.h" #include "decorationsettings.h" +#include + +#include #include #include #include @@ -284,6 +287,51 @@ } } +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 +341,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); Index: src/decorationbutton_p.h =================================================================== --- src/decorationbutton_p.h +++ src/decorationbutton_p.h @@ -66,6 +66,8 @@ void startPressAndHold(); void stopPressAndHold(); + QString typeToString( DecorationButtonType type ); + QPointer decoration; DecorationButtonType type; QRectF geometry; Index: src/private/CMakeLists.txt =================================================================== --- src/private/CMakeLists.txt +++ 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 ) Index: src/private/decoratedclientprivate.h =================================================================== --- src/private/decoratedclientprivate.h +++ src/private/decoratedclientprivate.h @@ -76,6 +76,8 @@ virtual QPalette palette() const = 0; virtual Qt::Edges adjacentScreenEdges() const = 0; + virtual void requestShowToolTip(QString &text) = 0; + virtual void requestHideToolTip() = 0; virtual void requestClose() = 0; virtual void requestToggleMaximization(Qt::MouseButtons buttons) = 0; virtual void requestMinimize() = 0;