superkaramba
karamba.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef KARAMBA_H
00027 #define KARAMBA_H
00028
00029 #include <QGraphicsItemGroup>
00030 #include <QTimeLine>
00031 #include <QGraphicsItemAnimation>
00032
00033 #include <KUrl>
00034 #include <netwm.h>
00035
00036 #include "themefile.h"
00037 #include "taskmanager.h"
00038 #include "superkaramba_export.h"
00039
00040 class QGraphicsView;
00041 class QGraphicsScene;
00042
00043 class KMenu;
00044 class KConfig;
00045 class K3Process;
00046
00047 class Meter;
00048 class Sensor;
00049 class Systemtray;
00050 class TextField;
00051
00052 class SUPERKARAMBA_EXPORT Karamba : public QObject, public QGraphicsItemGroup
00053 {
00054 Q_OBJECT
00055
00056 public:
00057 explicit Karamba(const KUrl &themeFile, QGraphicsView *view = 0,
00058 int instance = -1, bool subTheme = false,
00059 const QPoint &startPos = QPoint(), bool reload = false);
00060
00061 virtual ~Karamba();
00062
00063 QRectF boundingRect() const;
00064
00065 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
00066 QWidget *widget);
00067
00068 QGraphicsScene* getScene() const;
00069 QGraphicsView* getView() const;
00070
00071 void keyPressed(const QString& s, const Meter* meter);
00072
00073 const ThemeFile& theme() const;
00074
00075 bool hasMeter(const Meter* meter) const;
00076 bool removeMeter(Meter *meter);
00077 QString getSensor(const Meter* meter) const;
00078 void setSensor(const LineParser& lineParser, Meter* meter);
00079 void deleteMeterFromSensors(Meter* meter);
00080 TextField* getDefaultTextProps();
00081 void setFixedSize(u_int w, u_int h);
00082 bool readMenuConfigOption(const QString &key) const;
00083 KConfig* getConfig() const;
00084
00085 bool popupMenuExisting(const KMenu *menu) const;
00086 void setPrettyName(const QString &prettyThemeName);
00087 QString prettyName() const;
00088 int getNumberOfDesktops() const;
00089 double getUpdateTime() const;
00090 void setUpdateTime(double newTime);
00091 void setWantRightButton(bool enable);
00092 void changeInterval(u_int newInterval);
00093 void addMenuConfigOption(const QString &key, const QString &name);
00094 bool setMenuConfigOption(const QString &key, bool value);
00095 KMenu* addPopupMenu();
00096 QAction* addMenuItem(KMenu *menu, const QString &text,
00097 const QString &icon);
00098 void popupMenu(KMenu *menu, const QPoint &pos) const;
00099 void deletePopupMenu(KMenu *menu);
00100 void deleteMenuItem(QAction *action);
00101 void scaleImageLabel(Meter *meter, int width,
00102 int height) const;
00103 void moveMeter(Meter *meter, int x, int y) const;
00104 void writeConfigData();
00105
00106 void setMenuExtension(KMenu*);
00107 void removeMenuExtension();
00108 bool hasMenuExtension() const;
00109
00110 int instance();
00111 void setInstance(int instance);
00112
00113 void resizeTo(int width, int height);
00114 QPoint getPosition() const;
00115
00116 void setIncomingData(const QString &data);
00117 void notifyTheme(const QString &sender, const QString &data);
00118 bool sendDataToTheme(const QString &prettyThemeName, const QString &data);
00119 QString retrieveReceivedData() const;
00120 bool sendData(const QString &prettyThemeName, const QString &data);
00121
00122 void setOnTop(bool stayOnTop);
00123 bool isSubTheme() const;
00124
00125 void redrawWidget();
00126
00127 void makeActive();
00128 void makePassive();
00129
00130 void setProcess(K3Process *process);
00131 K3Process* process() const;
00132
00133 void setSystemTray(Systemtray*);
00134 Systemtray* systemTray();
00135
00136 QObject* getPlasmaSensor(const QString& engine, const QString& source = QString());
00137
00138 public Q_SLOTS:
00139 void updateSensors();
00140 void closeWidget();
00141 void reloadConfig();
00142 void processExited(K3Process *proc);
00143 void receivedStdout(K3Process *proc, char *buffer, int buflen);
00144 void startupAdded(Startup::StartupPtr);
00145 void startupRemoved(Startup::StartupPtr);
00146 void taskAdded(Task::TaskPtr);
00147 void taskRemoved(Task::TaskPtr);
00148 void activeTaskChanged(Task::TaskPtr);
00149 void passMenuItemClicked(QAction* action);
00150 void slotFileChanged(const QString &file);
00151 void popupGlobalMenu() const;
00152 void moveToPos(QPoint pos);
00153
00154 private Q_SLOTS:
00155 void startKaramba();
00156 void slotToggleLocked();
00157 void currentDesktopChanged(int i);
00158 void slotToggleConfigOption(QObject*);
00159 void slotDesktopChanged(int desktop);
00160 void currentWallpaperChanged(int desktop);
00161
00162 void step();
00163
00164 protected:
00165 void mousePressEvent(QGraphicsSceneMouseEvent *event);
00166 void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
00167 void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
00168 void wheelEvent(QGraphicsSceneWheelEvent *event);
00169 void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
00170 void dragEnterEvent(QGraphicsSceneDragDropEvent *event);
00171 void dropEvent(QGraphicsSceneDragDropEvent *event);
00172 void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
00173 void timerEvent(QTimerEvent *event);
00174 void keyPressEvent(QKeyEvent *event);
00175
00176 private:
00177 class Private;
00178 Private* const d;
00179
00180 bool parseConfig();
00181 Sensor *findSensorFromList(const Meter *meter) const;
00182 QString findSensorFromMap(const Sensor *sensor) const;
00183
00184 void preparePopupMenu();
00185 int passEvent(QEvent *event);
00186 };
00187
00188 #endif // KARAMBA_H