File indexing completed on 2024-12-01 07:38:56
0001 /* This file is part of the KDE project 0002 0003 Copyright (C) 2002 Patrick Charbonnier <pch@freeshell.org> 0004 Based On Caitoo v.0.7.3 (c) 1998 - 2000, Matej Koss 0005 0006 This program is free software; you can redistribute it and/or 0007 modify it under the terms of the GNU General Public 0008 License as published by the Free Software Foundation; either 0009 version 2 of the License, or (at your option) any later version. 0010 */ 0011 0012 #ifndef DROPTARGET_H 0013 #define DROPTARGET_H 0014 0015 #include <QCloseEvent> 0016 #include <QDragEnterEvent> 0017 #include <QDropEvent> 0018 #include <QMouseEvent> 0019 #include <QWidget> 0020 0021 #include "core/transfer.h" 0022 0023 class QAction; 0024 class QTimer; 0025 class QMenu; 0026 0027 class MainWindow; 0028 0029 class DropTarget : public QWidget 0030 { 0031 Q_OBJECT 0032 0033 public: 0034 DropTarget(MainWindow *parent); 0035 ~DropTarget() override; 0036 0037 void playAnimationShow(); 0038 void playAnimationHide(); 0039 void playAnimationSync(); 0040 void setDropTargetVisible(bool shown, bool internal = true); 0041 0042 protected: 0043 // drag and drop 0044 void dragEnterEvent(QDragEnterEvent *) override; 0045 void dropEvent(QDropEvent *) override; 0046 0047 // handle quit events as hide events 0048 void closeEvent(QCloseEvent *) override; 0049 0050 void mousePressEvent(QMouseEvent *e) override; 0051 void mouseReleaseEvent(QMouseEvent *e) override; 0052 void mouseDoubleClickEvent(QMouseEvent *e) override; 0053 void mouseMoveEvent(QMouseEvent *e) override; 0054 void enterEvent(QEnterEvent *event) override; 0055 void leaveEvent(QEvent *event) override; 0056 0057 // paint the drop target 0058 void paintEvent(QPaintEvent *) override; 0059 0060 private Q_SLOTS: 0061 void toggleSticky(); 0062 void toggleMinimizeRestore(); 0063 void slotStartStopToggled(bool); 0064 void slotAnimateShow(); 0065 void slotAnimateHide(); 0066 void slotAnimateSync(); 0067 void slotToolTipUpdate(); 0068 void slotToolTipTimer(); 0069 void slotClose(); 0070 0071 private: 0072 QMenu *popupMenu = nullptr; 0073 MainWindow *parentWidget = nullptr; 0074 QTimer *animTimer = nullptr; 0075 QTimer *popupTimer = nullptr; 0076 QPixmap cachedPixmap; 0077 0078 QAction *pop_sticky = nullptr; 0079 QAction *pop_show = nullptr; 0080 0081 QPoint position; 0082 0083 QString tooltipText; 0084 0085 int dx; 0086 int dy; 0087 bool isdragging; 0088 bool showInformation; 0089 0090 float ani_y, ani_vy; 0091 }; 0092 0093 #endif // _DROPTARGET_H