summaryrefslogtreecommitdiffstats
path: root/starter/menu.h
blob: c858a078c583f3fb94cc977d5d38c31da7910772 (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 <tqpoint.h>
#include <tqwidget.h>
#include <tqlabel.h>
#include <tqlayout.h>
#include <tqscrollview.h>
#include <tqmap.h>
#include <tqpixmap.h>
#include <tqsortedlist.h>
#include <tqptrlist.h>
#include <klineedit.h>
#include <kservicegroup.h>
#include "mykey.h"

class KIconLoader;
class TQPaintEvent;
class TQMouseEvent;
class TQEvent;
class TQPixmap;
class TQVBoxLayout;
class TQComboBox;
class StartMenuButton;
class KConfig;
class LinkConfig;

class Panel : public TQWidget//TQScrollView
{
   friend class StartMenu;
   friend class StartMenuButton;
Q_OBJECT
      
public:
   Panel(int size = 32, TQWidget * parent = 0, const char * name = 0);
   Orientation orientation(){ return _orientation; }
   void setOrientation ( Orientation o );
//    void addItem ( TQWidget *w );
   StartMenuButton* addIcon ( TQString icon, TQString title, TQString command, TQPoint pt = TQPoint(-1,-1) );
   void save(KConfig* config);
   void repositionIcon ( StartMenuButton* bt, TQPoint pt );
   void ensureVisible(TQRect & rect);
   void reloadIcons(int size);
   void poof();
public slots:
   void updateSize(int);
protected:
   void wheelEvent ( TQWheelEvent * );
   void dragEnterEvent ( TQDragEnterEvent * );
   void dropEvent ( TQDropEvent * );
   void mouseReleaseEvent ( TQMouseEvent * e );
   void resizeEvent ( TQResizeEvent * );
   LinkConfig *linkConfigDialog;
   int _size;
private:
   int _count;
   Orientation _orientation;
   bool _draggedMe;
   int _poofIndex;
   TQPoint iconAddPosition;
   TQPixmap *_poofPix;
   TQPixmap *_poofAnimPix;
   TQWidget *_poof;
private slots:
   void addIcon();
   void runPoof();
signals:
   void message(const TQString&);
   void clearStatus();
};

class TQTextDrag;

class StartMenuButton : public TQWidget
{
   friend class Panel;
   Q_OBJECT

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

class KService;
class TQDate;
class AppList;

class StartMenuEntry : public TQWidget
{
   friend class AppList;
   Q_OBJECT
public:
   StartMenuEntry(KService * service, TQString relPath, int size = 32, bool neewbie = false, TQWidget * parent = 0);
   ~StartMenuEntry();
   void reloadIcon(int size);
   bool display;
   TQString 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 ( TQFocusEvent * );
   void focusOutEvent ( TQFocusEvent * );
   void mouseReleaseEvent ( TQMouseEvent * e );
   void mouseMoveEvent ( TQMouseEvent * mme );
   void keyPressEvent ( TQKeyEvent * e );
   void enterEvent( TQEvent * );
   void leaveEvent( TQEvent * );
   KService* m_service;
   TQString groupPath;
   TQDate lastUse;
   uint usage;
private:
   void execute();
   TQString exec;
   bool isCurrent;
   TQLabel* m_titleLabel;
   TQLabel* m_commentLabel;
   TQLabel* m_pixmapLabel;
   TQPixmap m_pix;
   TQPixmap m_hoverPix;
signals:
   void closeMenu();
   void pressed();
   void appDown();
   void appUp();
   void appLeft();
   void hovered(const TQString &);
   void sayText(const TQString&);
   void unhovered();
   void popup(StartMenuEntry*);
   void executed();
};

class KPopupMenu;
class ConfigDialog;
class HelpDialog;

class AppList : public TQScrollView
{
   friend class StartMenu;
Q_OBJECT

public:
   AppList(int size = 32, TQWidget * parent = 0);
   StartMenuEntry* addApp(KService * service, TQStringList & captions, TQString relPath);
   void finish();
   StartMenuEntry* handledEntry; // for rightclick menu action
   void writeEntry(TQString 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 TQString & string);
   void appDown();
   void appUp();
   void appLeft();
   void sort();
   void showCategory(const TQString & string);
   void unblockPopup(){popupBlocked_ = false;}
protected:
   TQStringList categories;
   int favItemAmount;
   void save(KConfig* config);
   void mouseReleaseEvent ( TQMouseEvent * e );
   void windowActivationChange ( bool oldActive );
private:
   void init();
   void insertGroup(KServiceGroup *g, TQStringList & captions, TQStringList & paths);
   KServiceGroup::Ptr m_root;
   KIconLoader *m_iconLoader;
   TQLabel *infoLabel;
   TQVBoxLayout * infoLayout;
   TQVBoxLayout * m_VLayout;
   TQFrame * m_widget;
   bool newbie;
   TQStringList neewbieApps;
   KPopupMenu *m_popup;
   bool popupBlocked_;
   int _size;
   typedef TQSortedList<StartMenuEntry> StartMenuEntryList;
   typedef TQMap<TQString,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 TQString&);
   void sayText(const TQString&);
   void clearStatus();
};

class TQStringList;

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

class KURIFilterData;
class StarterConfig;
class TQSignalMapper;
class KSqueezedTextLabel;

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

#endif