1/*
2 * Copyright (C) 2006 Aaron Seigo <aseigo@kde.org>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Library General Public License version 2 as
6 * published by the Free Software Foundation
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details
12 *
13 * You should have received a copy of the GNU Library General Public
14 * License along with this program; if not, write to the
15 * Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 */
18
19#ifndef KRUNNERDIALOG_H
20#define KRUNNERDIALOG_H
21
22#include <KDialog>
23
24namespace Plasma
25{
26 class RunnerManager;
27 class FrameSvg;
28 class Svg;
29}
30
31class KRunnerConfigWidget;
32class PanelShadows;
33class QDesktopWidget;
34
35class KRunnerDialog : public QWidget
36{
37 Q_OBJECT
38
39 public:
40 explicit KRunnerDialog(Plasma::RunnerManager *manager, QWidget *parent = 0,
41 Qt::WindowFlags f = Qt::Dialog | Qt::FramelessWindowHint);
42 virtual ~KRunnerDialog();
43
44 void setFreeFloating(bool floating);
45 bool freeFloating() const;
46
47 enum ResizeMode { NotResizing = 0, VerticalResizing, HorizontalResizing };
48 ResizeMode manualResizing() const;
49 virtual void setConfigWidget(QWidget *w) = 0;
50
51 public Q_SLOTS:
52 virtual void display(const QString &term = QString()) = 0;
53 virtual void clearHistory() = 0;
54
55 protected:
56 void paintEvent(QPaintEvent *event);
57 void resizeEvent(QResizeEvent *event);
58 void mousePressEvent(QMouseEvent *event);
59 void mouseReleaseEvent(QMouseEvent *event);
60 void mouseMoveEvent(QMouseEvent *event);
61 void leaveEvent(QEvent *e);
62 void showEvent(QShowEvent *);
63 void hideEvent(QHideEvent *);
64 void moveEvent(QMoveEvent *);
65
66 void positionOnScreen();
67 virtual void setStaticQueryMode(bool staticQuery);
68
69 protected Q_SLOTS:
70 void toggleConfigDialog();
71 void timerEvent(QTimerEvent *event);
72
73 /**
74 * React to configuration being done
75 */
76 void configCompleted();
77
78 private:
79 void updatePresentation();
80 bool checkBorders(const QRect &screenGeom);
81 bool checkCursor(const QPoint &pos);
82 void updateMask();
83 void paintBackground(QPainter* painter, const QRect &exposedRect);
84
85 private Q_SLOTS:
86 /**
87 * React to theme changes
88 */
89 void themeUpdated();
90
91 /**
92 * React to screen changes
93 */
94 void screenResized(int screen);
95 void screenGeometryChanged(int screenCount);
96 void resetScreenPos();
97
98 void compositingChanged(bool);
99
100 protected:
101 Plasma::Svg *m_iconSvg;
102 Plasma::RunnerManager *m_runnerManager;
103
104 private:
105 KRunnerConfigWidget *m_configWidget;
106 PanelShadows *m_shadows;
107 Plasma::FrameSvg *m_background;
108 QPixmap *m_cachedBackground;
109 QPoint m_lastPressPos;
110 QPoint m_customPos;
111 int m_topBorderHeight;
112 int m_leftBorderWidth;
113 int m_rightBorderWidth;
114 int m_bottomBorderHeight;
115 int m_shownOnScreen;
116 qreal m_offset;
117 bool m_floating : 1;
118 bool m_resizing : 1;
119 bool m_rightResize : 1;
120 bool m_vertResize : 1;
121 bool m_runningTimer : 1;
122 QDesktopWidget *m_desktopWidget;
123 QString m_singleRunnerId;
124};
125
126#endif
127