diff options
Diffstat (limited to 'tdeioslave/media')
5 files changed, 49 insertions, 14 deletions
diff --git a/tdeioslave/media/mediamanager/mediamanager.cpp b/tdeioslave/media/mediamanager/mediamanager.cpp index 9a4089ca5..b08c37794 100644 --- a/tdeioslave/media/mediamanager/mediamanager.cpp +++ b/tdeioslave/media/mediamanager/mediamanager.cpp @@ -44,7 +44,6 @@ #include "linuxcdpolling.h" #endif //COMPILE_LINUXCDPOLLING - MediaManager::MediaManager(const TQCString &obj) : KDEDModule(obj), m_dirNotify(m_mediaList) { @@ -401,10 +400,6 @@ void MediaManager::slotMediumChanged(const TQString &/*id*/, const TQString &nam kdDebug(1219) << "MediaManager::slotMediumChanged: " << name << endl; KDirNotify_stub notifier("*", "*"); - if (!mounted) - { - notifier.FilesRemoved( KURL("media:/"+name) ); - } notifier.FilesChanged( KURL("media:/"+name) ); emit mediumChanged(name, allowNotification); 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) 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 <tqmap.h> class KDialogBase; +class NotificationDialog; +typedef TQPtrList<NotificationDialog> 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<TDEIO::Job*,bool> 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 <tqlabel.h> #include <tqcheckbox.h> #include <tqpushbutton.h> +#include <tdehardwaredevices.h> #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(); |