summaryrefslogtreecommitdiffstats
path: root/starter/menu.h
blob: d11a6512faf2d563a53172d9194e0bc06e88ff9b (plain)
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320

#ifndef STARTMENU_H
#define STARTMENU_H

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <qpoint.h>
#include <qwidget.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qscrollview.h>
#include <qmap.h>
#include <qpixmap.h>
#include <qsortedlist.h>
#include <qptrlist.h>
#include <klineedit.h>
#include <kservicegroup.h>
#include "mykey.h"

class KIconLoader;
class QPaintEvent;
class QMouseEvent;
class QEvent;
class QPixmap;
class QVBoxLayout;
class QComboBox;
class StartMenuButton;
class KConfig;
class LinkConfig;

class Panel : public QWidget//QScrollView
{
   friend class StartMenu;
   friend class StartMenuButton;
Q_OBJECT
      
public:
   Panel(int size = 32, QWidget * parent = 0, const char * name = 0);
   Orientation orientation(){ return _orientation; }
   void setOrientation ( Orientation o );
//    void addItem ( QWidget *w );
   StartMenuButton* addIcon ( QString icon, QString title, QString command, QPoint pt = QPoint(-1,-1) );
   void save(KConfig* config);
   void repositionIcon ( StartMenuButton* bt, QPoint pt );
   void ensureVisible(QRect & rect);
   void reloadIcons(int size);
   void poof();
public slots:
   void updateSize(int);
protected:
   void wheelEvent ( QWheelEvent * );
   void dragEnterEvent ( QDragEnterEvent * );
   void dropEvent ( QDropEvent * );
   void mouseReleaseEvent ( QMouseEvent * e );
   void resizeEvent ( QResizeEvent * );
   LinkConfig *linkConfigDialog;
   int _size;
private:
   int _count;
   Orientation _orientation;
   bool _draggedMe;
   int _poofIndex;
   QPoint iconAddPosition;
   QPixmap *_poofPix;
   QPixmap *_poofAnimPix;
   QWidget *_poof;
private slots:
   void addIcon();
   void runPoof();
signals:
   void message(const QString&);
   void clearStatus();
};

class QTextDrag;

class StartMenuButton : public QWidget
{
   friend class Panel;
   Q_OBJECT

public:
   enum Orientation { Horizontal = 0, Vertical, Status };
   StartMenuButton ( int size, QString icon, QString title, QString command, Orientation orientation, QWidget* parent = 0, const char * name = 0);
   void smartMove(QPoint & pt); // prevents collisions with other childs of parentWidget()
   void smartMove(int x, int y);
   void reloadIcon(int size);
public slots:
   void edit();
protected:
   QString & command(){return m_command;}
   QString & title(){return m_title;}
   QString & icon(){return m_icon;}
   void mouseReleaseEvent ( QMouseEvent * e );
   void mouseMoveEvent ( QMouseEvent * e );
   void enterEvent( QEvent * );
   void leaveEvent( QEvent * );
   bool isMoving() {return _moving;}
private:
   Orientation m_orientation;
   bool _moving;
   QTextDrag *myDrag;
   QString m_command;
   QString m_title;
   QString m_icon;
   QLabel* m_titleLabel;
   QLabel* m_pixmapLabel;
   QPixmap m_pix;
   QPixmap m_hoverPix;
signals:
   void pressed(const QString &);
   void hovered(const QString &);
   void unhovered();
   void updateSize(int);
};

class KService;
class QDate;
class AppList;

class StartMenuEntry : public QWidget
{
   friend class AppList;
   Q_OBJECT
public:
   StartMenuEntry(KService * service, QString relPath, int size = 32, bool neewbie = false, QWidget * parent = 0);
   ~StartMenuEntry();
   void reloadIcon(int size);
   bool display;
   QString title();
   void saveStats();
   int rank;
   bool forNewbie;
   //--- operators to allow use of qHeapSort()
   bool operator==( const StartMenuEntry& se ) const;
   bool operator!=( const StartMenuEntry& se ) const;
   bool operator<( const StartMenuEntry& se ) const;
   bool operator>( const StartMenuEntry& se ) const;
   bool operator==( const double& d ) const;
   bool operator!=( const double& d ) const;
   bool operator<( const double& d ) const;
   bool operator>( const double& d ) const;
protected:
   void focusInEvent ( QFocusEvent * );
   void focusOutEvent ( QFocusEvent * );
   void mouseReleaseEvent ( QMouseEvent * e );
   void mouseMoveEvent ( QMouseEvent * mme );
   void keyPressEvent ( QKeyEvent * e );
   void enterEvent( QEvent * );
   void leaveEvent( QEvent * );
   KService* m_service;
   QString groupPath;
   QDate lastUse;
   uint usage;
private:
   void execute();
   QString exec;
   bool isCurrent;
   QLabel* m_titleLabel;
   QLabel* m_commentLabel;
   QLabel* m_pixmapLabel;
   QPixmap m_pix;
   QPixmap m_hoverPix;
signals:
   void closeMenu();
   void pressed();
   void appDown();
   void appUp();
   void appLeft();
   void hovered(const QString &);
   void sayText(const QString&);
   void unhovered();
   void popup(StartMenuEntry*);
   void executed();
};

class KPopupMenu;
class ConfigDialog;
class HelpDialog;

class AppList : public QScrollView
{
   friend class StartMenu;
Q_OBJECT

public:
   AppList(int size = 32, QWidget * parent = 0);
   StartMenuEntry* addApp(KService * service, QStringList & captions, QString relPath);
   void finish();
   StartMenuEntry* handledEntry; // for rightclick menu action
   void writeEntry(QString path, bool hidden = false); // for add/edit
   void reloadIcons(int size);
public slots:
   void addEntry();
   void addDialog();
   void removeEntry();
   void editEntry();
   void editDialog();
   void clear();
   void reset();
   void search(const QString & string);
   void appDown();
   void appUp();
   void appLeft();
   void sort();
   void showCategory(const QString & string);
   void unblockPopup(){popupBlocked_ = false;}
protected:
   QStringList categories;
   int favItemAmount;
   void save(KConfig* config);
   void mouseReleaseEvent ( QMouseEvent * e );
   void windowActivationChange ( bool oldActive );
private:
   void init();
   void insertGroup(KServiceGroup *g, QStringList & captions, QStringList & paths);
   KServiceGroup::Ptr m_root;
   KIconLoader *m_iconLoader;
   QLabel *infoLabel;
   QVBoxLayout * infoLayout;
   QVBoxLayout * m_VLayout;
   QFrame * m_widget;
   bool newbie;
   QStringList neewbieApps;
   KPopupMenu *m_popup;
   bool popupBlocked_;
   int _size;
   typedef QSortedList<StartMenuEntry> StartMenuEntryList;
   typedef QMap<QString,StartMenuEntryList> KeyWordList;
   StartMenuEntryList entryList;
   KeyWordList m_keywordList;
   KeyWordList m_groupList;
   ConfigDialog* configDialog_;
   HelpDialog* helpDialog_;
private slots:
   void popup(StartMenuEntry*);
signals:
   void looseKey();
   void message(const QString&);
   void sayText(const QString&);
   void clearStatus();
};

class QStringList;

class SearchLine : public KLineEdit
{
   Q_OBJECT
public:
   SearchLine( QWidget * parent );
   bool blocked;
protected slots:
   void makeCompletion (const QString &);
   void block(){blocked = true;}
signals:
   void typedTextChanged(const QString & string);
};

class KURIFilterData;
class StarterConfig;
class QSignalMapper;
class KSqueezedTextLabel;

class StartMenu : public QWidget
{
   friend class starter; // to allow setting the shortcutlis directly
   Q_OBJECT
public:
   enum PanelPosition { North = 0, South, West, East, Nowhere };
   StartMenu ( int size = 32, QWidget * parent = 0, WFlags f = 0 );
   ~StartMenu();
   void show();
   void hide();
   void reloadIcons(int size);
   QStringList & categories(){return appList->categories;};
   typedef QMap<MyKey,QString> ShortcutList;
   void updateShortcuts(ShortcutList &);
   void setFavItemAmount(int i) {if (appList) appList->favItemAmount = i;}
   void setPanelPosition(PanelPosition p);
public slots:
   void sayText(const QString &text);
   void toggleKTTS(bool);
   void setCategory(const QString & category);
   void save();
protected:
   bool eventFilter ( QObject * o, QEvent * e );
   ShortcutList shortcutList;
private slots:
   void message(const QString &text);
   void centerMessage(const QString &text);
   void clearStatus();
   void execute(const QString & command);
   void search(const QString & string);
   void endHistory();
//    void slotLock();
private:
   bool inMove;
   uint m_spokenText;
   int _size;
   QWidget *header;
   QPoint movePoint;
   KURIFilterData *_filterData;
   AppList *appList;
   QComboBox *categoryCombo;
   SearchLine *searchLine;
   KSqueezedTextLabel *statusBar;
   Panel *m_panel;
   QStringList history;
   QStringList::Iterator currentHistoryItem;
   PanelPosition m_panelPos;
   StartMenuButton *userButton;
   QGridLayout *panelLayout;
   
signals:
   void aboutToHide();
};

#endif