From b876907e650eaf996aa3c2bcfac9a526cf900c5b Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Fri, 27 Dec 2013 19:29:38 -0600 Subject: Fix free space overlay not disappearing on unmount Fix devices disappearing on unmount Automatically close notification popup on associated media device removal --- tdeioslave/media/medianotifier/medianotifier.cpp | 45 +++++++++++++++++----- tdeioslave/media/medianotifier/medianotifier.h | 5 +++ .../media/medianotifier/notificationdialog.cpp | 6 +++ .../media/medianotifier/notificationdialog.h | 2 + 4 files changed, 49 insertions(+), 9 deletions(-) (limited to 'tdeioslave/media/medianotifier') 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 actions - = settings->actionsForMimetype( medium.mimetype() ); + TQValueList 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(object)); +} + extern "C" { KDE_EXPORT KDEDModule *create_medianotifier(const TQCString &name) diff --git a/tdeioslave/media/medianotifier/medianotifier.h b/tdeioslave/media/medianotifier/medianotifier.h index 3e30d12b1..84eee525c 100644 --- a/tdeioslave/media/medianotifier/medianotifier.h +++ b/tdeioslave/media/medianotifier/medianotifier.h @@ -29,6 +29,8 @@ #include class KDialogBase; +class NotificationDialog; +typedef TQPtrList NotificationDialogList; class MediaNotifier: public KDEDModule { @@ -41,6 +43,7 @@ public: k_dcop: void onMediumChange( const TQString &name, bool allowNotification ); + void onMediumRemove( const TQString &name, bool allowNotification ); private slots: void slotStatResult( TDEIO::Job *job ); @@ -48,6 +51,7 @@ private slots: void slotFreeFinished( KMessageBox::ButtonCode ); void slotFreeContinue(); void slotFreeCancel(); + void notificationDialogDestroyed( TQObject* ); private: bool autostart( const KFileItem &medium ); @@ -61,6 +65,7 @@ private: TQMap m_allowNotificationMap; TQTimer * m_freeTimer; KDialogBase * m_freeDialog; + NotificationDialogList m_notificationDialogList; }; #endif diff --git a/tdeioslave/media/medianotifier/notificationdialog.cpp b/tdeioslave/media/medianotifier/notificationdialog.cpp index 981d48e6a..c9a920f99 100644 --- a/tdeioslave/media/medianotifier/notificationdialog.cpp +++ b/tdeioslave/media/medianotifier/notificationdialog.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include "actionlistboxitem.h" #include "notificationdialogview.h" @@ -86,6 +87,11 @@ NotificationDialog::~NotificationDialog() delete m_settings; } +KFileItem NotificationDialog::medium() +{ + return m_medium; +} + void NotificationDialog::updateActionsListBox() { m_view->actionsList->clear(); diff --git a/tdeioslave/media/medianotifier/notificationdialog.h b/tdeioslave/media/medianotifier/notificationdialog.h index d50baa492..16bedb842 100644 --- a/tdeioslave/media/medianotifier/notificationdialog.h +++ b/tdeioslave/media/medianotifier/notificationdialog.h @@ -38,6 +38,8 @@ public: TQWidget* parent = 0, const char* name = 0 ); ~NotificationDialog(); + KFileItem medium(); + private slots: void slotOk(); void slotConfigure(); -- cgit v1.2.1