Applets
devicenotifier.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 #ifndef DEVICENOTIFIER_H
00021 #define DEVICENOTIFIER_H
00022
00023 #include <solid/solidnamespace.h>
00024 #include <plasma/applet.h>
00025 #include <plasma/dataengine.h>
00026 #include <plasma/animator.h>
00027 #include <plasma/dialog.h>
00028 #include <KIcon>
00029 #include <QModelIndex>
00030 #include <QGraphicsProxyWidget>
00031 #include <QGraphicsGridLayout>
00032 #include <QTimer>
00033 #include <QListView>
00034
00035 #include "ui_deviceNotifierConfig.h"
00036
00037 class QStandardItemModel;
00038 class QGraphicsLinearLayout;
00039
00040 namespace Notifier
00041 {
00042 class NotifierView;
00043 }
00044
00045
00046 namespace Plasma
00047 {
00048 class Icon;
00049 }
00050
00051 class DeviceNotifier : public Plasma::Applet
00052 {
00053 Q_OBJECT
00054
00055 public:
00056 struct ItemType
00057 {
00058 Plasma::Icon *icon;
00059 QStringList predicateFiles;
00060 QString text;
00061 QString udi;
00062 };
00063
00064 enum SpecificRoles {
00065 SolidUdiRole = Qt::UserRole + 1,
00066 PredicateFilesRole = Qt::UserRole + 2,
00067 ActionRole = Qt::UserRole + 3,
00068 IconNameRole = Qt::UserRole + 4,
00069 ScopeRole = Qt::UserRole + 5,
00070 SubTitleMandatoryRole = Qt::UserRole + 6
00071 };
00072
00073 DeviceNotifier(QObject *parent, const QVariantList &args);
00074 ~DeviceNotifier();
00075
00076 void init();
00077 void paintInterface(QPainter *p, const QStyleOptionGraphicsItem *option, const QRect &rect);
00078 void constraintsEvent(Plasma::Constraints constraints);
00079 public slots:
00080 void onSourceAdded(const QString &name);
00081 void onSourceRemoved(const QString &name);
00082 void dataUpdated(const QString &source, Plasma::DataEngine::Data data);
00083 void configAccepted();
00084 void slotOnItemClicked(const QModelIndex &);
00085 void onTimerExpired();
00086 void onClickNotifier();
00087
00088 protected:
00089 void createConfigurationInterface(KConfigDialog *parent);
00090
00091 private slots:
00092 void storageEjectDone(Solid::ErrorType error, QVariant errorData);
00093 void storageTeardownDone(Solid::ErrorType error, QVariant errorData);
00094 void resetIcon();
00095 void updateColors();
00096
00097 private:
00098 QModelIndex indexForUdi(const QString &udi) const;
00099 void initSysTray();
00100
00101 Plasma::DataEngine *m_solidEngine;
00102 Plasma::DataEngine *m_solidDeviceEngine;
00103 QStandardItemModel *m_hotplugModel;
00104
00105 Plasma::Dialog *m_widget;
00106 Plasma::Icon *m_icon;
00107 QLabel *m_label;
00108 QGraphicsProxyWidget * m_proxy;
00109 int m_displayTime;
00110 int m_numberItems;
00111 int m_itemsValidity;
00112 Notifier::NotifierView *m_notifierView;
00113 QTimer *m_timer;
00114 bool isNotificationEnabled;
00115 QGraphicsLinearLayout *m_layout;
00116
00118 Ui::solidNotifierConfig ui;
00119
00120 };
00121
00122 K_EXPORT_PLASMA_APPLET(devicenotifier, DeviceNotifier)
00123
00124 #endif