not quite so much needs to be delayed to the init() function
[personal-kdebase.git] / workspace / plasma / applets / devicenotifier / devicenotifier.h
blob16d62977747f41d395e61ec0a73652ef91d872b2
1 /***************************************************************************
2 * Copyright (C) 2007 by Alexis Ménard <darktears31@gmail.com> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
18 ***************************************************************************/
20 #ifndef DEVICENOTIFIER_H
21 #define DEVICENOTIFIER_H
23 //Solid
24 #include <solid/solidnamespace.h>
26 //Plasma
27 #include <Plasma/PopupApplet>
28 #include <Plasma/DataEngine>
29 #include <Plasma/ToolTipManager>
31 class QStandardItemModel;
32 class QGraphicsLinearLayout;
33 class QGraphicsProxyWidget;
34 class QTimer;
36 class KIcon;
38 namespace Notifier
40 class NotifierDialog;
43 //desktop view
44 namespace Plasma
46 class IconWidget;
49 /**
50 * @short Applet used to display hot plug devices
53 class DeviceNotifier : public Plasma::PopupApplet
55 Q_OBJECT
57 public:
58 /**
59 * Constructor of the applet
60 * @param parent the parent of this object
61 **/
62 DeviceNotifier(QObject *parent, const QVariantList &args);
64 /**
65 * Default destructor
66 **/
67 ~DeviceNotifier();
69 /**
70 * initialize the applet (called by plasma automatically)
71 **/
72 void init();
74 /**
75 * allow to change the icon of the notifier if this applet is in icon mode
76 **/
77 void changeNotifierIcon(const QString& name = QString());
79 /**
80 * The widget that displays the list of devices.
82 QWidget *widget();
84 protected:
85 void popupEvent(bool show);
87 public slots:
88 /**
89 * @internal Sets the tooltip content properly before showing.
91 void toolTipAboutToShow();
93 /**
94 * @internal Clears memory when needed.
96 void toolTipHidden();
98 protected slots:
99 /**
100 * slot called when a source/device is added in the hotplug engine
101 * @param name the name of the new source
103 void onSourceAdded(const QString &name);
106 * @internal slot called when a source/device is removed in the hotplug engine
107 * @param name the name of the removed source
109 void onSourceRemoved(const QString &name);
112 * slot called when a source of the hotplug engine is updated
113 * @param source the name of the source
114 * @param data the data of the source
116 void dataUpdated(const QString &source, Plasma::DataEngine::Data data);
118 private:
120 * @internal Used to fill the notifier from previous plugged devices
122 void fillPreviousDevices();
125 * @internal Used to popup the device view.
127 void notifyDevice(const QString &name);
130 * @internal Used to remove the last device notification.
132 void removeLastDeviceNotification(const QString &name);
134 ///the engine used to get hot plug devices
135 Plasma::DataEngine *m_solidEngine;
137 ///The engine used to manage devices in the applet (unmount,...)
138 Plasma::DataEngine *m_solidDeviceEngine;
140 ///the icon used when the applet is in the taskbar
141 Plasma::IconWidget *m_icon;
143 ///default icon of the notifier
144 QString m_iconName;
146 ///The dialog where devices are displayed
147 Notifier::NotifierDialog * m_dialog;
149 ///the time durin when the dialog will be show
150 int m_displayTime;
152 ///the number of items displayed in the dialog
153 int m_numberItems;
155 ///the time during when the item will be displayed
156 int m_itemsValidity;
158 ///the timer for different use cases
159 QTimer *m_timer;
161 ///bool to know if notifications are enabled
162 bool isNotificationEnabled;
164 ///last plugged udi
165 QList<QString> m_lastPlugged;
167 ///true if fillPreviousDevices is running
168 bool m_fillingPreviousDevices;
171 #endif