~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/*
 *   Copyright (C) 2006 Aaron Seigo <aseigo@kde.org>
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU Library General Public License version 2 as
 *   published by the Free Software Foundation
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details
 *
 *   You should have received a copy of the GNU Library General Public
 *   License along with this program; if not, write to the
 *   Free Software Foundation, Inc.,
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

#ifndef KRUNNERDIALOG_H
#define KRUNNERDIALOG_H

#include <KDialog>

namespace Plasma
{
    class RunnerManager;
    class FrameSvg;
    class Svg;
}

class KRunnerConfigWidget;
class PanelShadows;
class QDesktopWidget;

class KRunnerDialog : public QWidget
{
    Q_OBJECT

    public:
        explicit KRunnerDialog(Plasma::RunnerManager *manager, QWidget *parent = 0,
                               Qt::WindowFlags f =  Qt::Dialog | Qt::FramelessWindowHint);
        virtual ~KRunnerDialog();

        void setFreeFloating(bool floating);
        bool freeFloating() const;

        enum ResizeMode { NotResizing = 0, VerticalResizing, HorizontalResizing };
        ResizeMode manualResizing() const;
        virtual void setConfigWidget(QWidget *w) = 0;

    public Q_SLOTS:
        virtual void display(const QString &term = QString()) = 0;
        virtual void clearHistory() = 0;

    protected:
        void paintEvent(QPaintEvent *event);
        void resizeEvent(QResizeEvent *event);
        void mousePressEvent(QMouseEvent *event);
        void mouseReleaseEvent(QMouseEvent *event);
        void mouseMoveEvent(QMouseEvent *event);
        void leaveEvent(QEvent *e);
        void showEvent(QShowEvent *);
        void hideEvent(QHideEvent *);
        void moveEvent(QMoveEvent *);

        void positionOnScreen();
        virtual void setStaticQueryMode(bool staticQuery);

    protected Q_SLOTS:
        void toggleConfigDialog();
        void timerEvent(QTimerEvent *event);

        /**
         * React to configuration being done
         */
        void configCompleted();

    private:
        void updatePresentation();
        bool checkBorders(const QRect &screenGeom);
        bool checkCursor(const QPoint &pos);
        void updateMask();
        void paintBackground(QPainter* painter, const QRect &exposedRect);

    private Q_SLOTS:
        /**
         * React to theme changes
         */
        void themeUpdated();

        /**
         * React to screen changes
         */
        void screenResized(int screen);
        void screenGeometryChanged(int screenCount);
        void resetScreenPos();

        void compositingChanged(bool);

    protected:
        Plasma::Svg *m_iconSvg;
        Plasma::RunnerManager *m_runnerManager;

    private:
        KRunnerConfigWidget *m_configWidget;
        PanelShadows *m_shadows;
        Plasma::FrameSvg *m_background;
        QPixmap *m_cachedBackground;
        QPoint m_lastPressPos;
        QPoint m_customPos;
        int m_topBorderHeight;
        int m_leftBorderWidth;
        int m_rightBorderWidth;
        int m_bottomBorderHeight;
        int m_shownOnScreen;
        qreal m_offset;
        bool m_floating : 1;
        bool m_resizing : 1;
        bool m_rightResize : 1;
        bool m_vertResize : 1;
        bool m_runningTimer : 1;
        QDesktopWidget *m_desktopWidget;
        QString m_singleRunnerId;
};

#endif