| 1 | // -*- c-basic-offset: 2 -*- |
|---|
| 2 | /* |
|---|
| 3 | * This file is part of Licq, an instant messaging client for UNIX. |
|---|
| 4 | * Copyright (C) 2007 Licq developers |
|---|
| 5 | * |
|---|
| 6 | * Licq is free software; you can redistribute it and/or modify |
|---|
| 7 | * it under the terms of the GNU General Public License as published by |
|---|
| 8 | * the Free Software Foundation; either version 2 of the License, or |
|---|
| 9 | * (at your option) any later version. |
|---|
| 10 | * |
|---|
| 11 | * Licq is distributed in the hope that it will be useful, |
|---|
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 14 | * GNU General Public License for more details. |
|---|
| 15 | * |
|---|
| 16 | * You should have received a copy of the GNU General Public License |
|---|
| 17 | * along with Licq; if not, write to the Free Software |
|---|
| 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
|---|
| 19 | */ |
|---|
| 20 | |
|---|
| 21 | #ifndef DOCKICONWIDGET_H |
|---|
| 22 | #define DOCKICONWIDGET_H |
|---|
| 23 | |
|---|
| 24 | #include <QWidget> |
|---|
| 25 | |
|---|
| 26 | class QMenu; |
|---|
| 27 | |
|---|
| 28 | namespace LicqQtGui |
|---|
| 29 | { |
|---|
| 30 | /** |
|---|
| 31 | * Icon widget used by some dock icons |
|---|
| 32 | */ |
|---|
| 33 | class DockIconWidget : public QWidget |
|---|
| 34 | { |
|---|
| 35 | Q_OBJECT |
|---|
| 36 | |
|---|
| 37 | public: |
|---|
| 38 | /** |
|---|
| 39 | * Constructor |
|---|
| 40 | * |
|---|
| 41 | * @param menu Menu to popup |
|---|
| 42 | */ |
|---|
| 43 | DockIconWidget(QMenu* menu); |
|---|
| 44 | |
|---|
| 45 | /** |
|---|
| 46 | * Destructor |
|---|
| 47 | */ |
|---|
| 48 | virtual ~DockIconWidget(); |
|---|
| 49 | |
|---|
| 50 | /** |
|---|
| 51 | * Set the new face icon |
|---|
| 52 | * |
|---|
| 53 | * @param newFace Icon image |
|---|
| 54 | * @param updateMask Should mask be updated from the @a newFace |
|---|
| 55 | */ |
|---|
| 56 | void setFace(QPixmap* newFace, bool updateMask = true); |
|---|
| 57 | |
|---|
| 58 | /** |
|---|
| 59 | * Returns a copy of the current face |
|---|
| 60 | */ |
|---|
| 61 | QPixmap* face(); |
|---|
| 62 | |
|---|
| 63 | signals: |
|---|
| 64 | /** |
|---|
| 65 | * User has clicked on dock icon |
|---|
| 66 | */ |
|---|
| 67 | void clicked(); |
|---|
| 68 | |
|---|
| 69 | /** |
|---|
| 70 | * User has middle clicked on dock icon |
|---|
| 71 | */ |
|---|
| 72 | void middleClicked(); |
|---|
| 73 | |
|---|
| 74 | private: |
|---|
| 75 | /** |
|---|
| 76 | * Intercept close attempts |
|---|
| 77 | * |
|---|
| 78 | * @param event Close event |
|---|
| 79 | */ |
|---|
| 80 | virtual void closeEvent(QCloseEvent* event); |
|---|
| 81 | |
|---|
| 82 | /** |
|---|
| 83 | * User has clicked on icon |
|---|
| 84 | * |
|---|
| 85 | * @param event Event object |
|---|
| 86 | */ |
|---|
| 87 | virtual void mousePressEvent(QMouseEvent* event); |
|---|
| 88 | |
|---|
| 89 | /** |
|---|
| 90 | * Repaint icon widget |
|---|
| 91 | * |
|---|
| 92 | * @param event Event object |
|---|
| 93 | */ |
|---|
| 94 | virtual void paintEvent(QPaintEvent* event); |
|---|
| 95 | |
|---|
| 96 | QMenu* myMenu; |
|---|
| 97 | QPixmap* myFace; |
|---|
| 98 | WId myHandler; |
|---|
| 99 | }; |
|---|
| 100 | |
|---|
| 101 | } // namespace LicqQtGui |
|---|
| 102 | |
|---|
| 103 | #endif |
|---|