Sisyphus repositório
Última atualização: 1 outubro 2023 | SRPMs: 18631 | Visitas: 37518958
en ru br
ALT Linux repositórios
S:5.27.8-alt1

Group :: Sistema/Bibliotecas
RPM: plasma5-kdecoration

 Main   Changelog   Spec   Patches   Sources   Download   Gear   Bugs e FR  Repocop 

Patch: alt-kdecoration-tooltips.patch
Download


diff --git a/CMakeLists.txt b/CMakeLists.txt
index 01471c3..cbd3a58 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -24,6 +24,7 @@ find_package(Qt5 ${REQUIRED_QT_VERSION} CONFIG REQUIRED COMPONENTS
     Core
     Gui
     Test
+    Widgets
 )
 
 include(KDEInstallDirs)
@@ -38,6 +39,7 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
 endif()
 
 set(KDECORATION2_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}/KDecoration2")
+find_package(KF5I18n CONFIG REQUIRED)
 
 # Subdirectories
 add_subdirectory(src)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 309a784..86eb6d1 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,3 +1,5 @@
+add_definitions(-DTRANSLATION_DOMAIN="kcmkwindecoration")
+
 add_subdirectory(private)
 
 set(libkdecoration2_SRCS
@@ -17,8 +19,10 @@ target_link_libraries(kdecorations2
     PUBLIC
         Qt5::Core
         Qt5::Gui
+        Qt5::Widgets
     PRIVATE
         kdecorations2private
+        KF5::I18n
 )
 
 target_include_directories(kdecorations2 INTERFACE "$<INSTALL_INTERFACE:${KDECORATION2_INCLUDEDIR}>" )
diff --git a/src/decorationbutton.cpp b/src/decorationbutton.cpp
index 5d3c2f9..d04e90e 100644
--- a/src/decorationbutton.cpp
+++ b/src/decorationbutton.cpp
@@ -24,11 +24,15 @@
 #include "decoratedclient.h"
 #include "decorationsettings.h"
 
+#include <KLocalizedString>
+
+#include <QDebug>
 #include <QElapsedTimer>
 #include <QHoverEvent>
 #include <QGuiApplication>
 #include <QStyleHints>
 #include <QTimer>
+#include <QToolTip>
 
 namespace KDecoration2
 {
@@ -293,6 +297,7 @@ DecorationButton::DecorationButton(DecorationButtonType type, const QPointer<Dec
             this, static_cast<void (DecorationButton::*)(const QRectF&)>(&DecorationButton::update));
     auto updateSlot = static_cast<void (DecorationButton::*)()>(&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 +501,65 @@ void DecorationButton::wheelEvent(QWheelEvent *event)
     Q_UNUSED(event)
 }
 
+void DecorationButton::showTooltip( bool hovered )
+{
+
+    //TODO: show tooltip if hovered and hide if not
+    if ( hovered ){
+        const QString& type = typeToString(this->type());
+        const QPoint& position = QCursor::pos();
+
+        //TODO: change offset to something valuable
+        QToolTip::showText(position, type);
+    } else {
+        QToolTip::hideText();
+    }
+
+}
+
+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/src/decorationbutton.h b/src/decorationbutton.h
index 912b150..643accd 100644
--- a/src/decorationbutton.h
+++ b/src/decorationbutton.h
@@ -152,6 +152,11 @@ public Q_SLOTS:
      **/
     void update();
 
+    //* show tooltip
+    void showTooltip(bool);
+
+    QString typeToString( DecorationButtonType type );
+
 Q_SIGNALS:
     void clicked(Qt::MouseButton);
     void pressed();
 
projeto & código: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
mantenedor atual: Michael Shigorin
mantenedor da tradução: Fernando Martini aka fmartini © 2009