1 /***************************************************************************
2 * Copyright (C) 2007 by Alexis Ménard <darktears31@gmail.com> *
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. *
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. *
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
24 #include <solid/solidnamespace.h>
27 #include <Plasma/PopupApplet>
28 #include <Plasma/DataEngine>
29 #include <Plasma/ToolTipManager>
31 class QStandardItemModel
;
32 class QGraphicsLinearLayout
;
33 class QGraphicsProxyWidget
;
50 * @short Applet used to display hot plug devices
53 class DeviceNotifier
: public Plasma::PopupApplet
59 * Constructor of the applet
60 * @param parent the parent of this object
62 DeviceNotifier(QObject
*parent
, const QVariantList
&args
);
70 * initialize the applet (called by plasma automatically)
75 * allow to change the icon of the notifier if this applet is in icon mode
77 void changeNotifierIcon(const QString
& name
= QString());
80 * The widget that displays the list of devices.
85 void popupEvent(bool show
);
89 * @internal Sets the tooltip content properly before showing.
91 void toolTipAboutToShow();
94 * @internal Clears memory when needed.
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
);
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
146 ///The dialog where devices are displayed
147 Notifier::NotifierDialog
* m_dialog
;
149 ///the time durin when the dialog will be show
152 ///the number of items displayed in the dialog
155 ///the time during when the item will be displayed
158 ///the timer for different use cases
161 ///bool to know if notifications are enabled
162 bool isNotificationEnabled
;
165 QList
<QString
> m_lastPlugged
;
167 ///true if fillPreviousDevices is running
168 bool m_fillingPreviousDevices
;