~ubuntu-branches/ubuntu/trusty/kdeplasma-addons/trusty

« back to all changes in this revision

Viewing changes to applets/lancelot/app/src/LancelotWindow.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Thomas
  • Date: 2010-05-25 09:50:14 UTC
  • mfrom: (1.1.28 upstream)
  • Revision ID: james.westby@ubuntu.com-20100525095014-6mlrm9z9bkws0zkt
Tags: 4:4.4.80-0ubuntu1
* New upstream beta release:
  - Bump kde-sc-dev-latest build-dep version to 4.4.80
  - Refresh kubuntu_04_kimpanel_disable_scim.diff
  - Update various .install files
  - Drop liblancelot0a and liblancelot-dev packages; Upstream has broken ABI
    without an .so version bump, and after discussion with Debian it was
    decided it was not worth it to ship an unstable library.
  - Add liblancelot files to plasma-widget-lancelot, adding appropriate
    Replaces: entries
* Switch to source format 3.0 (quilt):
  - Bump debhelper build-depend version to 7.3.16 or greater

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 *   Copyright (C) 2007 Ivan Cukic <ivan.cukic(at)kde.org>
3
 
 *
4
 
 *   This program is free software; you can redistribute it and/or modify
5
 
 *   it under the terms of the GNU General Public License version 2,
6
 
 *   or (at your option) any later version, as published by the Free
7
 
 *   Software Foundation
8
 
 *
9
 
 *   This program is distributed in the hope that it will be useful,
10
 
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 
 *   GNU General Public License for more details
13
 
 *
14
 
 *   You should have received a copy of the GNU General Public
15
 
 *   License along with this program; if not, write to the
16
 
 *   Free Software Foundation, Inc.,
17
 
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18
 
 */
19
 
 
20
 
#ifndef LANCELOTWINDOW_H
21
 
#define LANCELOTWINDOW_H
22
 
 
23
 
#include <QEvent>
24
 
#include <QSignalMapper>
25
 
#include <QTimer>
26
 
 
27
 
#include <KConfig>
28
 
#include <KConfigGroup>
29
 
#include <KIcon>
30
 
 
31
 
#include <plasma/svg.h>
32
 
#include <plasma/plasma.h>
33
 
#include <plasma/corona.h>
34
 
 
35
 
#include <lancelot/widgets/PopupList.h>
36
 
#include <lancelot/widgets/PopupMenu.h>
37
 
 
38
 
#include "LancelotConfig.h"
39
 
#include "ui_LancelotWindowBase.h"
40
 
 
41
 
namespace Lancelot {
42
 
    class ActionListModel;
43
 
    class ResizeBordersPanel;
44
 
}
45
 
 
46
 
namespace Plasma
47
 
{
48
 
    class LineEdit;
49
 
}
50
 
 
51
 
class LancelotWindow: public QGraphicsView, public Ui::LancelotWindowBase
52
 
{
53
 
    Q_OBJECT
54
 
public:
55
 
    LancelotWindow();
56
 
    virtual ~LancelotWindow();
57
 
    bool eventFilter(QObject * object, QEvent * event);
58
 
 
59
 
public Q_SLOTS:
60
 
    /**
61
 
     * Shows full window centered on the screen.
62
 
     */
63
 
    void lancelotShowCentered();
64
 
 
65
 
    /**
66
 
     * Shows full window.
67
 
     * @param x x coordinate of the mouse
68
 
     * @param y y coordinate of the mouse
69
 
     */
70
 
    void lancelotShow(int x, int y);
71
 
 
72
 
    /**
73
 
     * Shows window with only specified section
74
 
     * @param x x coordinate of the mouse
75
 
     * @param y y coordinate of the mouse
76
 
     * @param name the name of the section to be shown
77
 
     */
78
 
    void lancelotShowItem(int x, int y, const QString & name);
79
 
 
80
 
    /**
81
 
     * Hides window
82
 
     * @param immediate if not set, the window will start \
83
 
     *   the auto-timer for hiding. If true, window will be \
84
 
     *   hidden immediately
85
 
     */
86
 
    void lancelotHide(bool immediate = false);
87
 
 
88
 
    /**
89
 
     * Opens the search section and searches for
90
 
     * the specified string,
91
 
     * @param string search string
92
 
     */
93
 
    void search(const QString & string);
94
 
 
95
 
protected Q_SLOTS:
96
 
    /**
97
 
     * Shows specified section
98
 
     * @param item section to be shown
99
 
     */
100
 
    void sectionActivated(const QString & item);
101
 
 
102
 
private:
103
 
    void nextSection(int increment);
104
 
 
105
 
private Q_SLOTS:
106
 
    void systemButtonClicked();
107
 
 
108
 
    void lancelotContext();
109
 
    void saveConfig();
110
 
    void showAboutDialog();
111
 
 
112
 
    void hideImmediate();
113
 
 
114
 
    void focusChanged(QWidget * old, QWidget * now);
115
 
 
116
 
public:
117
 
    /**
118
 
     * Returns a list of available sections - their IDs
119
 
     */
120
 
    QStringList sectionIDs();
121
 
 
122
 
    /**
123
 
     * Returns a list of available sections - their names
124
 
     */
125
 
    QStringList sectionNames();
126
 
 
127
 
    /**
128
 
     * Returns a list of available sections - their icons
129
 
     */
130
 
    QStringList sectionIcons();
131
 
 
132
 
public Q_SLOTS:
133
 
    /**
134
 
     * Opens the configure shortcuts dialog
135
 
     */
136
 
    void configureShortcuts();
137
 
 
138
 
    /**
139
 
     * Opens the configure menu dialog
140
 
     */
141
 
    void configureMenu();
142
 
 
143
 
    /**
144
 
     * Call this when an external application changes
145
 
     * the configuration
146
 
     */
147
 
    void configurationChanged();
148
 
 
149
 
    /**
150
 
     * Starts the menu editor
151
 
     */
152
 
    void showMenuEditor();
153
 
 
154
 
protected:
155
 
    /**
156
 
     * Resizes window and relayouts everything.
157
 
     */
158
 
    void resizeWindow();
159
 
 
160
 
    /**
161
 
     * Shows window
162
 
     * @param x x coordinate of position to show at
163
 
     * @param y y coordinate of position to show at
164
 
     * @param centered override x and y and show window centered
165
 
     */
166
 
    void showWindow(int x, int y, bool centered = false);
167
 
 
168
 
    /**
169
 
     * Creates and sets up data models
170
 
     */
171
 
    void setupModels();
172
 
 
173
 
    /**
174
 
     * Loads configuration options
175
 
     */
176
 
    void loadConfig();
177
 
 
178
 
    /**
179
 
     * Sets up the actions
180
 
     */
181
 
    void setupActions();
182
 
 
183
 
    // void paintEvent(QPaintEvent * event);
184
 
    void drawBackground(QPainter * painter, const QRectF & rect);
185
 
 
186
 
private:
187
 
    Lancelot::ResizeBordersPanel * m_root;
188
 
    Plasma::Corona      * m_corona;
189
 
 
190
 
    Plasma::LineEdit    * editSearch;
191
 
 
192
 
    QHash < Lancelot::ExtenderButton *, QString > systemButtonActions;
193
 
 
194
 
    QTimer                m_hideTimer;
195
 
    QString               m_searchString;
196
 
 
197
 
    bool                  m_hovered;
198
 
    bool                  m_showingFull;
199
 
 
200
 
    QSignalMapper       * m_sectionsSignalMapper;
201
 
    KActionCollection   * m_actionCollection;
202
 
 
203
 
    QMap < QString, Lancelot::ActionListModel * > m_models;
204
 
    QMap < QString, Lancelot::ActionListModel * > m_modelGroups;
205
 
 
206
 
    KConfig               m_config;
207
 
    KConfigGroup          m_mainConfig;
208
 
    QString               m_activeSection;
209
 
 
210
 
    LancelotConfig m_configUi;
211
 
    QWidget * m_configWidget;
212
 
 
213
 
// Resize related code
214
 
protected:
215
 
    void mousePressEvent   (QMouseEvent * event);
216
 
    void mouseReleaseEvent (QMouseEvent * event);
217
 
    void mouseMoveEvent    (QMouseEvent * event);
218
 
    void resizeEvent       (QResizeEvent * event);
219
 
 
220
 
    void sendKeyEvent      (QKeyEvent * event);
221
 
 
222
 
private:
223
 
    enum BaseDirection {
224
 
        None = 0,
225
 
        Up   = 1, Down  = 2,
226
 
        Left = 4, Right = 8
227
 
    };
228
 
 
229
 
    Q_DECLARE_FLAGS(ResizeDirection, BaseDirection)
230
 
 
231
 
    ResizeDirection m_resizeDirection;
232
 
    QPoint          m_originalMousePosition;
233
 
    QPoint          m_originalWindowPosition;
234
 
    QSize           m_originalMainSize;
235
 
    QSize           m_mainSize;
236
 
 
237
 
    QList < QGraphicsWidget * > m_focusList;
238
 
    int m_focusIndex;
239
 
    bool m_skipEvent;
240
 
 
241
 
    // Additional widgets
242
 
    Lancelot::PopupList * menuSystemButton;
243
 
    Lancelot::PopupMenu * menuLancelotContext;
244
 
};
245
 
 
246
 
#endif /*LANCELOTWINDOW_H*/