diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2013-12-27 19:29:38 -0600 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2013-12-27 19:29:38 -0600 |
commit | b876907e650eaf996aa3c2bcfac9a526cf900c5b (patch) | |
tree | 513671ea3db58c11b28de8ee74f51ff35be6b9c8 /tdeioslave/media/medianotifier/medianotifier.cpp | |
parent | ee68bc1fd3d2e5edc1527bdfcacfb330b7670a86 (diff) | |
download | tdebase-b876907e650eaf996aa3c2bcfac9a526cf900c5b.tar.gz tdebase-b876907e650eaf996aa3c2bcfac9a526cf900c5b.zip |
Fix free space overlay not disappearing on unmount
Fix devices disappearing on unmount
Automatically close notification popup on associated media device removal
Diffstat (limited to 'tdeioslave/media/medianotifier/medianotifier.cpp')
-rw-r--r-- | tdeioslave/media/medianotifier/medianotifier.cpp | 45 |
1 files changed, 36 insertions, 9 deletions
diff --git a/tdeioslave/media/medianotifier/medianotifier.cpp b/tdeioslave/media/medianotifier/medianotifier.cpp index bb8948db8..2db917b25 100644 --- a/tdeioslave/media/medianotifier/medianotifier.cpp +++ b/tdeioslave/media/medianotifier/medianotifier.cpp @@ -51,10 +51,14 @@ MediaNotifier::MediaNotifier(const TQCString &name) : KDEDModule(name) connectDCOPSignal( "kded", "mediamanager", "mediumChanged(TQString, bool)", "onMediumChange(TQString, bool)", true ); - m_freeTimer = new TQTimer( this ); - connect( m_freeTimer, TQT_SIGNAL( timeout() ), TQT_SLOT( checkFreeDiskSpace() ) ); - m_freeTimer->start( 1000*6*2 /* 20 minutes */ ); - m_freeDialog = 0; + connectDCOPSignal( "kded", "mediamanager", "mediumRemoved(TQString, bool)", + "onMediumRemove(TQString, bool)", true ); + + m_notificationDialogList.setAutoDelete(FALSE); + m_freeTimer = new TQTimer( this ); + connect( m_freeTimer, TQT_SIGNAL( timeout() ), TQT_SLOT( checkFreeDiskSpace() ) ); + m_freeTimer->start( 1000*6*2 /* 20 minutes */ ); + m_freeDialog = 0; } MediaNotifier::~MediaNotifier() @@ -64,6 +68,24 @@ MediaNotifier::~MediaNotifier() disconnectDCOPSignal( "kded", "mediamanager", "mediumChanged(TQString, bool)", "onMediumChange(TQString, bool)" ); + + disconnectDCOPSignal( "kded", "mediamanager", "mediumRemoved(TQString, bool)", + "onMediumRemove(TQString, bool)" ); +} + +void MediaNotifier::onMediumRemove( const TQString &name, bool allowNotification ) +{ + kdDebug() << "MediaNotifier::onMediumRemove( " << name << ", " + << allowNotification << ")" << endl; + + KURL url( "system:/media/"+name ); + + NotificationDialog* dialog; + for (dialog = m_notificationDialogList.first(); dialog; dialog = m_notificationDialogList.next()) { + if (dialog->medium().url() == url) { + dialog->close(); + } + } } void MediaNotifier::onMediumChange( const TQString &name, bool allowNotification ) @@ -305,16 +327,16 @@ void MediaNotifier::notify( KFileItem &medium ) if ( settings->autoActionForMimetype( medium.mimetype() )==0L ) { - TQValueList<NotifierAction*> actions - = settings->actionsForMimetype( medium.mimetype() ); + TQValueList<NotifierAction*> actions = settings->actionsForMimetype( medium.mimetype() ); // If only one action remains, it's the "do nothing" action // no need to popup in this case. if ( actions.size()>1 ) { - NotificationDialog *dialog - = new NotificationDialog( medium, settings ); - dialog->show(); + NotificationDialog* notifier = new NotificationDialog( medium, settings ); + connect(notifier, TQT_SIGNAL(destroyed(TQObject*)), this, TQT_SLOT(notificationDialogDestroyed(TQObject*))); + m_notificationDialogList.append(notifier); + notifier->show(); } } else @@ -325,6 +347,11 @@ void MediaNotifier::notify( KFileItem &medium ) } } +void MediaNotifier::notificationDialogDestroyed(TQObject* object) +{ + m_notificationDialogList.remove(static_cast<NotificationDialog*>(object)); +} + extern "C" { KDE_EXPORT KDEDModule *create_medianotifier(const TQCString &name) |