3434#include < QMessageBox>
3535
3636namespace {
37- QIcon iconForType (DeviceInfo::DeviceType type)
37+ QString iconNameForType (DeviceInfo::DeviceType type)
3838 {
3939 switch (type)
4040 {
4141 case DeviceInfo::CD :
42- return QIcon::fromTheme ( " media-optical" ) ;
42+ return " media-optical" ;
4343 case DeviceInfo::Flash:
4444 case DeviceInfo::Other:
45- return QIcon::fromTheme ( " media-flash" ) ;
45+ return " media-flash" ;
4646 case DeviceInfo::Floppy:
47- return QIcon::fromTheme ( " media-floppy" ) ;
47+ return " media-floppy" ;
4848 case DeviceInfo::HDD :
49- return QIcon::fromTheme ( " drive-harddisk" ) ;
49+ return " drive-harddisk" ;
5050 }
5151
52- return QIcon ();
52+ return QString ();
5353 }
5454
5555 QString formatFileSize (qulonglong size)
@@ -156,7 +156,7 @@ void TinyMountTray::reloadDevices()
156156 }
157157 else
158158 {
159- icon = iconForType ( d->type );
159+ icon = QIcon::fromTheme ( iconNameForType ( d->type ) );
160160 text.replace (" %mounted%" , " " );
161161 }
162162
@@ -186,7 +186,9 @@ void TinyMountTray::onDeviceAdded(const DeviceInfo &device)
186186 qDebug () << " Device added:" << device.name ;
187187
188188 if (SettingsManager::instance ().getSettings ().deviceNotifications )
189- showNotification (tr (" Device is added" ), tr (" Device %1 is added" ).arg (device.name ));
189+ showNotification (tr (" Device is added" ),
190+ tr (" Device %1 is added" ).arg (device.name ),
191+ iconNameForType (device.type ));
190192
191193 if (SettingsManager::instance ().getSettings ().mountAutomaticaly )
192194 manager->mountDevice (device.udisksPath );
@@ -199,7 +201,9 @@ void TinyMountTray::onDeviceRemoved(const DeviceInfo& device)
199201 qDebug () << " Device removed:" << device.name ;
200202
201203 if (SettingsManager::instance ().getSettings ().deviceNotifications )
202- showNotification (tr (" Device is removed" ), tr (" Device %1 is removed" ).arg (device.name ));
204+ showNotification (tr (" Device is removed" ),
205+ tr (" Device %1 is removed" ).arg (device.name ),
206+ iconNameForType (device.type ));
203207
204208 reloadDevices ();
205209}
@@ -231,11 +235,15 @@ void TinyMountTray::onMountDone(const DeviceInfo &device, const QString &mountPa
231235 if (DiskManager::OK == status)
232236 {
233237 if (SettingsManager::instance ().getSettings ().mountNotifications )
234- showNotification (tr (" Device is mounted" ), tr (" %1 is mounted to %2." ).arg (device.name ).arg (mountPath));
238+ showNotification (tr (" Device is mounted" ),
239+ tr (" %1 is mounted to %2." ).arg (device.name ).arg (mountPath),
240+ iconNameForType (device.type ));
235241 }
236242 else
237243 {
238- showNotification (tr (" Mount failed" ), tr (" %1 mounting error. %2." ).arg (device.name ).arg (errorToString (status)));
244+ showNotification (tr (" Mount failed" ),
245+ tr (" %1 mounting error. %2." ).arg (device.name ).arg (errorToString (status)),
246+ " dialog-error" );
239247 }
240248}
241249
@@ -246,11 +254,15 @@ void TinyMountTray::onUnmountDone(const DeviceInfo &device, int status)
246254 if (DiskManager::OK == status)
247255 {
248256 if (SettingsManager::instance ().getSettings ().mountNotifications )
249- showNotification (tr (" Device is unmounted" ), tr (" %1 is unmounted successfuly." ).arg (device.name ));
257+ showNotification (tr (" Device is unmounted" ),
258+ tr (" %1 is unmounted successfuly." ).arg (device.name ),
259+ iconNameForType (device.type ));
250260 }
251261 else
252262 {
253- showNotification (tr (" Unmount failed" ), tr (" Failed to unmount %1. %2." ).arg (device.name ).arg (errorToString (status)));
263+ showNotification (tr (" Unmount failed" ),
264+ tr (" Failed to unmount %1. %2." ).arg (device.name ).arg (errorToString (status)),
265+ " dialog-error" );
254266 }
255267}
256268
@@ -280,18 +292,19 @@ void TinyMountTray::showSettings()
280292 }
281293}
282294
283- void TinyMountTray::showNotification (const QString& title, const QString &message)
295+ void TinyMountTray::showNotification (const QString& title, const QString &message, const QString& icon )
284296{
285297#ifdef WITH_LIBNOTIFY
286298 if (SettingsManager::instance ().getSettings ().useLibnotify )
287299 {
288- notifier->showNotification (title, message);
300+ notifier->showNotification (title, message, icon );
289301 }
290302 else
291303 {
292304 tray->showMessage (title, message);
293305 }
294306#else
307+ Q_UNUSED (icon);
295308 tray->showMessage (title, message);
296309#endif
297310}
0 commit comments