File indexing completed on 2024-04-14 05:39:39

0001 // SPDX-License-Identifier: GPL-3.0-or-later
0002 /*
0003   Copyright 2017 Martin Koller, kollix@aon.at
0004 
0005   This file is part of liquidshell.
0006 
0007   liquidshell is free software: you can redistribute it and/or modify
0008   it under the terms of the GNU General Public License as published by
0009   the Free Software Foundation, either version 3 of the License, or
0010   (at your option) any later version.
0011 
0012   liquidshell is distributed in the hope that it will be useful,
0013   but WITHOUT ANY WARRANTY; without even the implied warranty of
0014   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0015   GNU General Public License for more details.
0016 
0017   You should have received a copy of the GNU General Public License
0018   along with liquidshell.  If not, see <http://www.gnu.org/licenses/>.
0019 */
0020 
0021 #ifndef _TaskBarButton_H_
0022 #define _TaskBarButton_H_
0023 
0024 #include <QPushButton>
0025 #include <QTimer>
0026 class QLabel;
0027 class KSqueezedTextLabel;
0028 
0029 #include <kwindowsystem.h>
0030 
0031 class TaskBarButton : public QPushButton
0032 {
0033   Q_OBJECT
0034 
0035   public:
0036     TaskBarButton(WId wid);
0037 
0038     void setIconSize(int size);
0039 
0040     QSize sizeHint() const override;
0041 
0042   Q_SIGNALS:
0043     void clicked();
0044 
0045   protected:
0046     void mousePressEvent(QMouseEvent *event) override;
0047     void mouseMoveEvent(QMouseEvent *event) override;
0048     void paintEvent(QPaintEvent *event) override;
0049     void dragEnterEvent(QDragEnterEvent *event) override;
0050     void dragLeaveEvent(QDragLeaveEvent *event) override;
0051     void dropEvent(QDropEvent *event) override;
0052     void moveEvent(QMoveEvent *) override { updateWMGeometry(); }
0053     void resizeEvent(QResizeEvent *) override { updateWMGeometry(); }
0054 
0055   private Q_SLOTS:
0056     void fill();
0057     void setBackground();
0058     void windowChanged(WId id, NET::Properties props, NET::Properties2 props2);
0059 
0060   private:
0061     void updateWMGeometry();
0062 
0063   private:
0064     WId wid;
0065     QLabel *iconLabel;
0066     KSqueezedTextLabel *textLabel;
0067     QTimer dragDropTimer;
0068     QPoint dragStartPos;
0069 };
0070 
0071 #endif