summaryrefslogtreecommitdiffstats
path: root/src/kooldock.h
blob: a129a6ff8ab0d958260e2190f253683a3028df6b (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
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
/***************************************************************************
                          kooldock.h  -  description
                             -------------------
    begin                : Tue Jun 10 22:18:34 BST 2003
    copyright            : (C) 2003 by KoolDock team
    email                : 
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef KOOLDOCK_H
#define KOOLDOCK_H

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

#include <kapp.h>
#include <kpopupmenu.h>
#include <kwinmodule.h>
#include <kaboutdialog.h>
#include <krootpixmap.h>
#include <kpixmap.h>
#include <kurifilter.h> 

#include <qwidget.h>
#include <qptrlist.h>
#include <qtimer.h>
#include <qcolor.h>

#include <netwm.h>

#include <qdatetime.h>

#include "item.h"
#include "xosd.h"
#include "clip.h"
#include "setupdialogprg.h"
#include "dinfo.h"

const int MAX_ICONS = 150; // max number of icons
const int UPDATE_DIST = 1; // update when x - last_x <= UPDATE_DIST
const int DEF_SMALL_SIZE = 32; // default small icon size
const int DEF_BIG_SIZE = 90; // default big icon size
const int DEF_DOCK_OPACITY = 50; // default dock opacity
const int DEF_PRIORITY = 5;
const int DEF_HIDDEN = 1; // default hidden priority
const int ANIM_TOTAL_STEP = 6; // not in use yet

const int SPACE_W = 1; // space between quick launchers and tasks (the seperator)

const int ON_CHANGE_ANIM_INTERVAL = 50; // animation's interval

/** KoolDock is the base class of the project */
class KoolDock : public QWidget
{
   Q_OBJECT
   public:
   /** construtor */
   KoolDock(QWidget* parent=0, const char *name=0);
   /** destructor */
   ~KoolDock();
    
   //static bool writeIgnoreList(QString text);
   void setMainPath(const QString& path);
   void setArgs(const QString& param);
   clip *clipw;
    
   private:
      QTime *perf;
      // configuration variables
      int fShowTaskbar; // show-taskbar flag
      int fMinimizedOnly; // show only minimized icons flag
      int fShowNotification; // show-notification flag
      int fShowBorders; // show-borders flag
      int fShowKMenu;	// show the K menu
      int fUseKBFX;
      int fPriority;	// "nice" priority
      int fMouseTimer;	// Mouse timer interval
      int fClipping;	//window area clippig
      int fClipIcons;	//icon area clipping 
      long int fzoomSpeed, zoomStep, zoomStepB, zoomStepS, zoomVal;	//speed of show/hide animation
      int zoomTicksB, zoomTicksS; //counts timer ticks
      int neededTicksB,neededTicksS; //sets how many ticks is necessary to calculate new speed
      bool fSpeed;
      QColor borderColor;
      int fHidden;	// hidden dockbar
      int fStayBelow;
      int fOrientation;	//bottom/left/top/right
      int fHideOnClick;
      int fSteppy;
      int fShowFrames;	// frames to show the dock "growing from bottom"
      int fGrowFrames;	// frames to grow the icon when the mouse is over it.
      int fHighLightTime;
      bool fFirstRun;
      bool fShowShot;
      bool fGrouping;
      int fRepaintInterval;
      int xinerama; //whether we want xinerama
      int hideTimer; //user define time to show dock
      int Solid; //whether using backgroung Image or not (for preference controls)
      int fShowNav; //whether we want the navigation menu (clock + desktop chooser) in kooldocks main menu
      int numSystray; //for systray control
      int fSystray; //whether we want the systray or not
      int fCurrent; //whether to only show windows on current desktop
      int oldDesktop; //number of previous desktop
      bool firstTime; //to control certain things
      QString curTheme; //for the background theme (to preserve changes)
      int leftRes; //Left monitor resolution
      int XinDesiredHeight;
      int XinPreviousWidth;
      int fpercentPos;

      bool noSet;
      bool firstInit;
      bool reloadIcons;
      bool initialization;
      int ptPart;

      bool mouseOnLauncher;
      QStringList lstDrop;
      bool useList;

      Atom net_system_tray_selection;
      Atom net_system_tray_opcode;

      QString fLeftImg;
      QString fRightImg;
      QString fCenterImg;
      bool fNWideBg;
      bool scaleMax;

      QPixmap LeftImg;
      QPixmap RightImg;
      QPixmap CenterImg;
      QPixmap TempScaledCenter; 
      QPixmap TestPix;
      QImage TestIm;

      unsigned int oLeft, oRight;

      int iwSmall;
      int iwBig;
      int iwBig2;

      int firstX, tmpw;
      int oldfirstX, oldtmpw;
      int lastX;

      int dockOpacity;
      QColor bgColor;

      QColor sepColor; // separator bar's color

      int Ybase;

      // normal variables

      QString progPath;
      QString menuPath;
      QString confFile;
      QString iFilename;  // right clicked item filename
      QString mainPath;
      QString args;

      QStringList ignoreList;


      NETWinInfo *info;
      KWinModule *wm;
      SetupDialog *setupdlg;

      int Offset; 
      int numLaunchers; // number of quick launcher items
      int x, y, w, h, h0, h1, w0, x0, w1, x1;
      int rx, ry, rw, rh, uw; //current position
      int ix, iy, iDist, iSpace;
      int dw, dh, rdh;
      int funcW, funcH;
      int ii_first, ii_last;
      int soffset, eoffset; //used in icon positioning
      int sx, sw;
      int adjust;
      int fAmount;
      int last_mx;
      int last_ncx;

      QPtrList<Item> items;//currently visible items
      QPtrList<Item> witems;//all windows on all desktops
      int iSize[MAX_ICONS + 1];//icon sizes
      int cx[MAX_ICONS + 1];//positions of small icons
      int cur_cx[MAX_ICONS + 1];//positions of visible icons
      QPixmap offscr;//drawing buffer

      KRootPixmap *rootpix;
      KPixmap bottomBg;
      KPixmap bottomBgf;
      QPixmap topBg;

      KAboutDialog *aboutDlg;
      QTimer *mkbigTimer; //zoom animation timers
      QTimer *mksmallTimer;
      QTimer *mTimer; //mouse move emulator (can't use normal event instead)
      QTimer *onChangeTimer; // used when a window has changed and we need to notify user
      QTimer *trackTimer; //checks whether mouse touches screen edge

      int animStep; // animation step, not in use yet
      int iOnClick; // index of the quick launcher being clicked
      WId cId;  // id of the application (used in the right click menu over the taskbar)
      QString cClass;
      WId CurrentFocus;
      int onChangeAnimStep;
      KPopupMenu *deskpopup;
      KPopupMenu *appMenu;
      KPopupMenu *godesk;
      KPopupMenu *tasklist;
      KPopupMenu *popup;
      KPopupMenu *advMenu;
      int menuCount, currMenu;
      bool allApps;
      QPtrList<KPopupMenu> popups;
      bool iGroup;
      int dIndex, nDesks;
      QPtrList<dInfo> desks;

      bool fExpanded;
      bool track2active;
       /*Xosd Section */
      QString nom;
      QString aux;
      //xosd *osd;
      int xosd_st;
      int showNames;
      int fCleaner;
      int xosdShadowOffset;
      QString xosdFont;
      QString xosdColor;
      QString xosdShadowColor;
      bool xosdBold;
      bool xosdItalic;
      int xosdSize;
      KURIFilterData *_filterData;
      xosd *xosdw;
      int animValue;
      int animState;

      void run(const QString& cmd);
      int func(int x);
      int func2(int x);
      void doUpdateGeometry();
      bool addTask(WId id, int iFound=-1);
      bool rmTask(WId id, int iFound=-1);
      void rmwTask(int iFound);
      bool addwTask(WId id);
      void movetoback(WId id);
      void loadConf();
      void loadIgnore();
      void saveConf();
      void loadMenu();
      void addWindows();
      int itemFromPoint(int x);
      int xFromIndex(int i);
      void createMenu(KPopupMenu* tmpMenu, KWin::WindowInfo* info);
      void updTaskList();
      void addToTaskList(WId id);
      void rmFromTaskList(WId id);
      bool doRepaint;
      int currXPos;
      int lastXPos;
      int lastYPos;
      void init1();
      void init2();

   protected:
      void paintEvent(QPaintEvent *);
      void mousePressEvent( QMouseEvent * );
      void mMoveEvent( int ex, int ey);
      void mPress( int mx, int my, ButtonState srcButton);
      void wheelEvent(QWheelEvent *);
      void enterEvent(QEvent*);
      void onleaveEvent(QEvent*);
      void mksmallTimerstop();
      void dragMoveEvent(QDragMoveEvent* event);
      void dropEvent(QDropEvent* event);

   public slots:
      void edit();
      void editPref();
      void about();
      void windowAdded(WId id);
      void windowRemoved(WId id);
      void windowChanged(WId id, unsigned int properties);
      void activeWindowChanged(WId id);
      void workAreaChanged();
      void currentDesktopChanged(int);
      void onChangeTimerTicked();
      void updateBackground(const QPixmap&);
      void moveApp();
      void resizeApp();
      void minApp();
      void maxApp();
      void restApp();
      void minAllApps();
      void maxAllApps();
      void restAllApps();
      void closeAllApps();
      void shadeApp();
      void activateApp();
      void closeApp();
      void editItem();
      void removeItem();
      void sendToDesktop(int);
      void goToDesktop(int);
      void goToWindow(int);
      /* Systray support */
      void systemTrayWindowAdded(WId id);
      void systemTrayWindowRemoved(WId id);
      void aboutToShow();
      void aboutToHide();
      
      void toggleAlwaysOnTop();
      void toggleKeptBelowOthers();
      void toggleFullScreen();
      
      static void addFile(const QString& filename,
                          const QString& iconname,
                          const QString& execname,
                          const QString& name,
                          bool notify = true,
                          bool terminal = false,
                          bool tclose = false,
                          bool cuser = false,
                          QString = "na");
      bool ignored(const QString& appname);

      #ifdef _ENABLE_DEBUG
      static void debug(QString message);
      #endif
      #ifndef _ENABLE_DEBUG
      static void debug(QString);
      #endif
      void mkbigTimerDo();
      void mksmallTimerDo();
      void endProg();
      void mTimerEnd();
      void trackTimerEnd();
      void trackTimer2End();
      void restart();
      void reload();
      void chkRestart();
      void refreshBackground();
      void unhighlight();
      void move2(int nx, int ny);
      void resize2(int nw, int nh);
      void getBottomBG();
      void getTopBG();
      void setDesktopIconsArea(int, int, int, int);
      void setDockAbove();
      void setDockBelow();
      void menuX(int num);
      void menuShow();
      void pTest();
};

#endif