OSDN Git Service

kdeplasma-addons: do not register the showdesktop applet icon as drag handle
authorIvailo Monev <xakepa10@gmail.com>
Fri, 15 Sep 2023 03:00:50 +0000 (06:00 +0300)
committerIvailo Monev <xakepa10@gmail.com>
Fri, 15 Sep 2023 03:00:50 +0000 (06:00 +0300)
the feature to minimize on drag can be implemented by sub-classing
Plasma::IconWidget but I dont need that kind of feature and it was borked

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
kdeplasma-addons/applets/showdesktop/showdesktop.cpp
kdeplasma-addons/applets/showdesktop/showdesktop.h

index 4a5a97d..1403336 100644 (file)
@@ -37,8 +37,6 @@ ShowDesktop::ShowDesktop(QObject *parent, const QVariantList &args)
     setAspectRatioMode(Plasma::ConstrainedSquare);
     int iconSize = IconSize(KIconLoader::Desktop);
     resize(iconSize * 2, iconSize * 2);
-    setAcceptDrops(true);
-    connect(&m_timer, SIGNAL(timeout()), this, SLOT(minimizeAll()));
 }
 
 void ShowDesktop::init()
@@ -49,14 +47,16 @@ void ShowDesktop::init()
     layout->setContentsMargins(0, 0, 0, 0);
     layout->setSpacing(0);
 
-    Plasma::IconWidget *icon = new Plasma::IconWidget(KIcon("user-desktop"), QString(), this);
+    Plasma::IconWidget *icon = new Plasma::IconWidget(this);
+    icon->setIcon(KIcon("user-desktop"));
     layout->addItem(icon);
-    registerAsDragHandle(icon);
     connect(icon, SIGNAL(clicked()), this, SLOT(minimizeAll()));
 
-    Plasma::ToolTipContent toolTipData(i18n("Show the Desktop"),
-                                       i18n("Minimize all open windows and show the Desktop"),
-                                       icon->icon().pixmap(IconSize(KIconLoader::Desktop)));
+    Plasma::ToolTipContent toolTipData(
+        i18n("Show the Desktop"),
+        i18n("Minimize all open windows and show the Desktop"),
+        icon->icon().pixmap(IconSize(KIconLoader::Desktop))
+    );
     Plasma::ToolTipManager::self()->setContent(this, toolTipData);
 
     NETRootInfo info(QX11Info::display(), NET::Supported);
@@ -79,7 +79,6 @@ void ShowDesktop::init()
 
 void ShowDesktop::minimizeAll()
 {
-    m_timer.stop();
     if (m_wm2ShowingDesktop) {
         NETRootInfo info(QX11Info::display(), 0);
 #ifndef MINIMIZE_ONLY
@@ -94,17 +93,6 @@ void ShowDesktop::minimizeAll()
     }
 }
 
-void ShowDesktop::dragEnterEvent(QGraphicsSceneDragDropEvent *event)
-{
-    m_timer.start(750);
-    event->accept();
-}
-
-void ShowDesktop::dragLeaveEvent(QGraphicsSceneDragDropEvent *event)
-{
-    m_timer.stop();
-}
-
 #ifndef MINIMIZE_ONLY
 void ShowDesktop::delay()
 {
index 7f94569..72798f4 100644 (file)
@@ -21,8 +21,6 @@
 //#define MINIMIZE_ONLY
 
 #include <Plasma/Applet>
-#include <QTimer>
-#include <QtGui/qgraphicssceneevent.h>
 
 class ShowDesktop : public Plasma::Applet
 {
@@ -40,8 +38,6 @@ public slots:
 #endif
 
 protected:
-    void dragEnterEvent(QGraphicsSceneDragDropEvent *event);
-    void dragLeaveEvent(QGraphicsSceneDragDropEvent *event);
     QSizeF sizeHint(Qt::SizeHint which, const QSizeF & constraint = QSizeF()) const;
     
 private slots:
@@ -53,7 +49,6 @@ private:
     bool m_down;
     bool m_goingDown;
 #endif
-    QTimer m_timer;
 };
 
 K_EXPORT_PLASMA_APPLET(showdesktop, ShowDesktop)