karamba.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef _KARAMBA_H_
00025 #define _KARAMBA_H_
00026
00027 #ifdef HAVE_CONFIG_H
00028 #include <config.h>
00029 #endif
00030
00031 #include <qwidget.h>
00032 #include <kapplication.h>
00033
00034 #include <kwinmodule.h>
00035 #include <kwin.h>
00036
00037 #include <qfile.h>
00038 #include <kfile.h>
00039 #include <qfileinfo.h>
00040 #include <kaction.h>
00041 #include <qtimer.h>
00042 #include <qpixmap.h>
00043 #include <qpainter.h>
00044
00045
00046
00047 #include <qregexp.h>
00048 #include <qlabel.h>
00049 #include <qobjectlist.h>
00050 #include <qstring.h>
00051 #include <qstringlist.h>
00052 #include <ksharedpixmap.h>
00053 #include <qvaluestack.h>
00054 #include <dcopclient.h>
00055 #include <kpopupmenu.h>
00056 #include <qcursor.h>
00057 #include <netwm.h>
00058 #include <kiconloader.h>
00059 #include <kfiledialog.h>
00060 #include <qmap.h>
00061 #include <kurl.h>
00062 #include <krun.h>
00063 #include <qdatetime.h>
00064 #include <qbitmap.h>
00065 #include <kconfig.h>
00066 #include <kprocess.h>
00067 #include <qdragobject.h>
00068
00069 #include "karambarootpixmap.h"
00070
00071 #include "bar.h"
00072 #include "textlabel.h"
00073 #include "imagelabel.h"
00074 #include "graph.h"
00075 #include "input.h"
00076
00077 #include "clickarea.h"
00078
00079 #include "sensorparams.h"
00080 #include "memsensor.h"
00081 #include "datesensor.h"
00082 #include "uptimesensor.h"
00083 #include "memsensor.h"
00084 #include "cpusensor.h"
00085 #include "networksensor.h"
00086 #include "xmmssensor.h"
00087 #include "noatunsensor.h"
00088 #include "programsensor.h"
00089 #include "disksensor.h"
00090 #include "sensorsensor.h"
00091 #include "textfilesensor.h"
00092
00093 #include "clickmap.h"
00094 #include "rsssensor.h"
00095
00096 #include "taskmanager.h"
00097 #include "showdesktop.h"
00098 #include "systemtray.h"
00099 #include "themefile.h"
00100
00109 class KarambaPython;
00110 class LineParser;
00111
00112 class karamba : public QWidget
00113 {
00114 Q_OBJECT
00115
00116 public:
00117 karamba(QString fn, QString name, bool reloading = false,
00118 int instance = -1, bool sub_theme = false);
00119 QObjectList *menuList;
00120
00121 virtual ~karamba();
00122 const ThemeFile& theme() const { return m_theme; };
00123
00124 QObjectList *meterList;
00125 QObjectList *imageList;
00126 QObjectList *clickList;
00127 void setSensor(const LineParser& lineParser, Meter* meter);
00128 QString getSensor(Meter* meter);
00129 QString findSensorFromMap(Sensor* sensor);
00130 void deleteMeterFromSensors(Meter* meter);
00131 Sensor* findSensorFromList(Meter* meter);
00132 KPopupMenu* keditpop;
00133 KPopupMenu *kpop;
00134 QBitmap* widgetMask;
00135 KarambaRootPixmap *kroot;
00136 TaskManager taskManager;
00137 Systemtray* systray;
00138 KProcess* currProcess;
00139 bool useSmoothTransforms();
00140
00141 void changeInterval(int interval);
00142 void setWidgetUpdate(bool wu) { widgetUpdate = wu; };
00143 bool getWidgetUpdate() { return widgetUpdate; };
00144 bool hasMeter(Meter* meter) { return meterList->containsRef(meter) > 0; };
00145 char getTempUnit() { return tempUnit; };
00146 void addMenuConfigOption(QString key, QString name);
00147 bool setMenuConfigOption(QString key, bool value);
00148 bool readMenuConfigOption(QString key);
00149 void writeConfigData();
00150 TextField* getDefaultTextProps() { return defaultTextField; };
00151 int instance() const { return m_instance; };
00152 void setInstance(int instance) { m_instance = instance; };
00153 void closeTheme(bool reloading = false);
00154 void keyPressed(const QString& s, const Meter* meter);
00155
00156 int numberOfConfMenuItems;
00157 KConfig* config;
00158 QString prettyName;
00159 bool m_sub_theme;
00160 bool isSubTheme() { return m_sub_theme; }
00161
00162 void toggleWidgetUpdate( bool );
00163
00164 KWinModule* kWinModule;
00165
00166 QString incomingData;
00167 QString getIncomingData() { return incomingData; }
00168 void _setIncomingData(QString data) { incomingData = data; }
00169 void setIncomingData(QString theme, QString data);
00170
00171 void themeNotify(QString theme, QString txt);
00172 void callTheme(QString theme, QString txt);
00173
00174 double getUpdateTime() { return update_time; }
00175 void setUpdateTime(double time) { update_time = time; }
00176
00177 void makeActive();
00178 void makePassive();
00179
00180 void showMenuExtension();
00181 void hideMenuExtension();
00182
00183 protected:
00184 void mousePressEvent( QMouseEvent *);
00185 void wheelEvent( QWheelEvent *);
00186 void mouseReleaseEvent( QMouseEvent *);
00187 void mouseDoubleClickEvent( QMouseEvent *);
00188 void mouseMoveEvent( QMouseEvent *);
00189 void keyPressEvent ( QKeyEvent * e );
00190 void closeEvent ( QCloseEvent *);
00191 void paintEvent ( QPaintEvent *);
00192 void saveProperties(KConfig *);
00193 void readProperties(KConfig *);
00194 void dragEnterEvent(QDragEnterEvent* event);
00195 void dropEvent(QDropEvent* event);
00196
00197 private:
00198 bool widgetUpdate;
00199 bool repaintInProgress;
00200
00201 bool want_right_button;
00202 bool want_meter_wheel_event;
00203
00204 NETWinInfo* info;
00205 bool onTop;
00206 bool managed;
00207 bool fixedPosition;
00208 bool haveUpdated;
00209 char tempUnit;
00210 double update_time;
00211 int m_instance;
00212
00213 bool parseConfig();
00214
00215 void passClick( QMouseEvent* );
00216 void passWheelClick( QWheelEvent* );
00217 void meterClicked(QMouseEvent*, Meter*);
00218
00219 QMap<QString, Sensor*> sensorMap;
00220 QObjectList *sensorList;
00221 QObjectList *timeList;
00222
00223 QTime lowerTimer;
00224
00225 bool foundKaramba;
00226
00227 KPopupMenu* themeConfMenu;
00228 KPopupMenu* toDesktopMenu;
00229 KPopupMenu* kglobal;
00230
00231 DCOPClient *client;
00232 QCString appId;
00233
00234 QPixmap pm;
00235 QPixmap background;
00236 QPainter p;
00237
00238 QPoint clickPos;
00239 KActionCollection* accColl;
00240 KActionCollection* menuAccColl;
00241 KToggleAction *toggleLocked;
00242
00243 KToggleAction *toggleFastTransforms;
00244
00245
00246 KarambaPython* pythonIface;
00247 TextField *defaultTextField;
00248
00249 int desktop;
00250 ThemeFile m_theme;
00251
00252 int trayMenuSeperatorId;
00253 int trayMenuQuitId;
00254 int trayMenuToggleId;
00255 int trayMenuThemeId;
00256 void start();
00257
00258 public slots:
00259 void step();
00260 void externalStep();
00261 void widgetClosed();
00262 void updateSensors();
00263 void currentDesktopChanged(int);
00264 void currentWallpaperChanged(int);
00265 void slotToggleConfigOption(QString key, bool);
00266 void updateBackground(KSharedPixmap*);
00267 void passMenuOptionChanged(QString key, bool);
00268 void passMenuItemClicked(int);
00269 void processExited (KProcess *proc);
00270 void receivedStdout (KProcess *proc, char *buffer, int buflen);
00271 void toDesktop(int desktopid, int menuid);
00272 const char *getPrettyName() { return prettyName.ascii(); }
00273
00274
00275 void systrayUpdated();
00276
00277
00278 void startupAdded(Startup*);
00279 void startupRemoved(Startup*);
00280
00281 void taskAdded(Task*);
00282 void taskRemoved(Task*);
00283 void activeTaskChanged(Task*);
00284 void reloadConfig();
00285
00286 void setAlwaysOnTop(bool stay);
00287
00292 void setWantRightButton(bool yesno) { want_right_button = yesno; }
00293
00294 void setWantMeterWheelEvent(bool yesno) { want_meter_wheel_event = yesno; }
00295
00299 void management_popup( void );
00300
00301 private:
00302 bool m_reloading;
00303 bool themeStarted;
00304 QTimer *m_sysTimer;
00305 int m_interval;
00306
00307 private slots:
00308 void initPythonInterface();
00309 void killWidget();
00310 void editConfig();
00311 void editScript();
00312 void slotToggleLocked();
00313 void slotToggleFastTransforms();
00314 void popupNotify(int);
00315 void slotFileChanged( const QString & );
00316
00317 void slotToggleSystemTray();
00318 void slotQuit();
00319 void slotShowTheme();
00320 };
00321
00322
00323
00324
00325
00326 class DesktopChangeSlot : public QObject
00327 {
00328 Q_OBJECT
00329
00330 public:
00331 DesktopChangeSlot(QObject *parent, int desktop_id);
00332
00333
00334 void setMenuId(int id);
00335 int menuId();
00336
00337 public slots:
00338 void receive();
00339
00340 protected:
00341 int desktopid;
00342 int menuid;
00343 };
00344
00346 class SignalBridge : public QObject
00347 {
00348 Q_OBJECT
00349
00350 public:
00351 SignalBridge(QObject* parent, QString, KActionCollection*);
00352
00353 signals:
00354 void enabled(QString, bool);
00355
00356 public slots:
00357 void receive();
00358
00359 private:
00360 KActionCollection* collection;
00361 };
00362
00363 #endif // _KARAMBA_H_
|