diff --git a/kdecoration-5.11.3/CMakeLists.txt b/kdecoration-5.11.3/CMakeLists.txt --- a/kdecoration-5.11.3/CMakeLists.txt +++ b/kdecoration-5.11.3/CMakeLists.txt @@ -24,6 +24,7 @@ Core Gui Test + Widgets ) include(KDEInstallDirs) @@ -38,6 +39,7 @@ endif() set(KDECORATION2_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}/KDecoration2") +find_package(KF5I18n CONFIG REQUIRED) # Subdirectories add_subdirectory(src) diff --git a/kdecoration-5.11.3/src/CMakeLists.txt b/kdecoration-5.11.3/src/CMakeLists.txt --- a/kdecoration-5.11.3/src/CMakeLists.txt +++ b/kdecoration-5.11.3/src/CMakeLists.txt @@ -1,3 +1,5 @@ +add_definitions(-DTRANSLATION_DOMAIN="kcmkwindecoration") + add_subdirectory(private) set(libkdecoration2_SRCS @@ -17,8 +19,10 @@ PUBLIC Qt5::Core Qt5::Gui + Qt5::Widgets PRIVATE kdecorations2private + KF5::I18n ) target_include_directories(kdecorations2 INTERFACE "$" ) diff --git a/kdecoration-5.11.3/src/decoration.h b/kdecoration-5.11.3/src/decoration.h --- a/kdecoration-5.11.3/src/decoration.h +++ b/kdecoration-5.11.3/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); diff --git a/kdecoration-5.11.3/src/decoration.cpp b/kdecoration-5.11.3/src/decoration.cpp --- a/kdecoration-5.11.3/src/decoration.cpp +++ b/kdecoration-5.11.3/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); diff --git a/kdecoration-5.11.3/src/decorationbutton.h b/kdecoration-5.11.3/src/decorationbutton.h --- a/kdecoration-5.11.3/src/decorationbutton.h +++ b/kdecoration-5.11.3/src/decorationbutton.h @@ -152,6 +152,11 @@ **/ void update(); + //* show tooltip + void showTooltip(bool); + + QString typeToString( DecorationButtonType type ); + Q_SIGNALS: void clicked(Qt::MouseButton); void pressed(); @@ -159,6 +164,8 @@ void pointerEntered(); void pointerLeft(); void doubleClicked(); + void showtooltip(QString); + void hidetooltip(); void pressedChanged(bool); void hoveredChanged(bool); diff --git a/kdecoration-5.11.3/src/decorationbutton.cpp b/kdecoration-5.11.3/src/decorationbutton.cpp --- a/kdecoration-5.11.3/src/decorationbutton.cpp +++ b/kdecoration-5.11.3/src/decorationbutton.cpp @@ -24,11 +24,15 @@ #include "decoratedclient.h" #include "decorationsettings.h" +#include + +#include #include #include #include #include #include +#include namespace KDecoration2 { @@ -63,6 +67,8 @@ { auto c = decoration->client().data(); auto settings = decoration->settings(); + QObject::connect(q, &DecorationButton::showtooltip, decoration.data(), &Decoration::requestShowToolTip, Qt::QueuedConnection); + QObject::connect(q, &DecorationButton::hidetooltip, decoration.data(), &Decoration::requestHideToolTip, Qt::QueuedConnection); switch (type) { case DecorationButtonType::Menu: QObject::connect(q, &DecorationButton::clicked, decoration.data(), &Decoration::requestShowWindowMenu, Qt::QueuedConnection); @@ -293,6 +299,7 @@ this, static_cast(&DecorationButton::update)); auto updateSlot = static_cast(&DecorationButton::update); connect(this, &DecorationButton::hoveredChanged, this, updateSlot); + connect(this, &DecorationButton::hoveredChanged, this, &DecorationButton::showTooltip); connect(this, &DecorationButton::pressedChanged, this, updateSlot); connect(this, &DecorationButton::checkedChanged, this, updateSlot); connect(this, &DecorationButton::enabledChanged, this, updateSlot); @@ -496,4 +503,60 @@ Q_UNUSED(event) } +void DecorationButton::showTooltip( bool hovered ) +{ + + //TODO: show tooltip if hovered and hide if not + const QString type = typeToString(this->type()); + + //TODO: change offset to something valuable + hovered ? emit showtooltip(type) : hidetooltip(); + +} + +QString DecorationButton::typeToString( DecorationButtonType type ) +{ + + switch (type) { + case DecorationButtonType::Menu: + return i18n("Menu"); + case DecorationButtonType::ApplicationMenu: + return i18n("Application menu"); + case DecorationButtonType::OnAllDesktops: + if ( isChecked() ) + return i18n("On one desktop"); + else + return i18n("On all desktops"); + case DecorationButtonType::Minimize: + return i18n("Minimize"); + case DecorationButtonType::Maximize: + if ( 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 ( isChecked() ) + return i18n("Unshade"); + else + return i18n("Shade"); + case DecorationButtonType::KeepBelow: + if ( isChecked() ) + return i18n("Don't keep below"); + else + return i18n("Keep below"); + case DecorationButtonType::KeepAbove: + if ( isChecked() ) + return i18n("Don't keep above"); + else + return i18n("Keep above"); + default: + return QString(); + } + +} + } diff --git a/kdecoration-5.11.3/src/private/decoratedclientprivate.h b/kdecoration-5.11.3/src/private/decoratedclientprivate.h --- a/kdecoration-5.11.3/src/private/decoratedclientprivate.h +++ b/kdecoration-5.11.3/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;