Fix free space overlay not disappearing on unmount

Fix devices disappearing on unmount
Automatically close notification popup on associated media device removal
pull/2/head
Timothy Pearson 10 years ago
parent ee68bc1fd3
commit b876907e65

@ -151,7 +151,7 @@ KDIconView::KDIconView( TQWidget *parent, const char* name )
m_enableMedia(false),
m_gotIconsArea(false),
m_needDesktopAlign(true),
m_paOutstandingOverlaysTimer( 0L )
m_paOutstandingFreeSpaceOverlaysTimer( 0L )
{
setResizeMode( Fixed );
setIconArea( desktopRect() ); // the default is the whole desktop
@ -1223,8 +1223,14 @@ void KDIconView::slotNewItems( const KFileItemList & entries )
}
KFileItem* fileItem = fileIVI->item();
if ( fileItem->mimetype().startsWith("media/") && fileItem->mimetype().contains("_mounted") && KDesktopSettings::mediaFreeSpaceDisplayEnabled() ) {
showFreeSpaceOverlay(fileIVI);
if ( fileItem->mimetype().startsWith("media/") && KDesktopSettings::mediaFreeSpaceDisplayEnabled() ) {
if (fileItem->mimetype().contains("_mounted")) {
showFreeSpaceOverlay(fileIVI);
}
else {
// If not mounted, hide free space overlay
fileIVI->setShowFreeSpaceOverlay(false);
}
}
}
@ -1281,8 +1287,14 @@ void KDIconView::slotRefreshItems( const KFileItemList & entries )
if ( rit.current()->isMimeTypeKnown() ) {
fileIVI->setMouseOverAnimation( rit.current()->iconName() );
}
if ( rit.current()->mimetype().startsWith("media/") && rit.current()->mimetype().contains("_mounted") && KDesktopSettings::mediaFreeSpaceDisplayEnabled() ) {
showFreeSpaceOverlay(fileIVI);
if ( rit.current()->mimetype().startsWith("media/") && KDesktopSettings::mediaFreeSpaceDisplayEnabled() ) {
if (rit.current()->mimetype().contains("_mounted")) {
showFreeSpaceOverlay(fileIVI);
}
else {
// If not mounted, hide free space overlay
fileIVI->setShowFreeSpaceOverlay(false);
}
}
break;
}
@ -1381,15 +1393,15 @@ void KDIconView::showFreeSpaceOverlay(KFileIVI* item)
KFileItem* fileItem = item->item();
if ( TDEGlobalSettings::showFilePreview( fileItem->url() ) ) {
m_paOutstandingOverlays.append(item);
if (m_paOutstandingOverlays.count() == 1)
m_paOutstandingFreeSpaceOverlays.append(item);
if (m_paOutstandingFreeSpaceOverlays.count() == 1)
{
if (!m_paOutstandingOverlaysTimer)
if (!m_paOutstandingFreeSpaceOverlaysTimer)
{
m_paOutstandingOverlaysTimer = new TQTimer(this);
connect(m_paOutstandingOverlaysTimer, TQT_SIGNAL(timeout()), TQT_SLOT(slotFreeSpaceOverlayStart()));
m_paOutstandingFreeSpaceOverlaysTimer = new TQTimer(this);
connect(m_paOutstandingFreeSpaceOverlaysTimer, TQT_SIGNAL(timeout()), TQT_SLOT(slotFreeSpaceOverlayStart()));
}
m_paOutstandingOverlaysTimer->start(20, true);
m_paOutstandingFreeSpaceOverlaysTimer->start(20, true);
}
}
}
@ -1398,7 +1410,7 @@ void KDIconView::slotFreeSpaceOverlayStart()
{
do
{
KFileIVI* item = m_paOutstandingOverlays.first();
KFileIVI* item = m_paOutstandingFreeSpaceOverlays.first();
if (!item) {
return; // Nothing to do
}
@ -1411,16 +1423,16 @@ void KDIconView::slotFreeSpaceOverlayStart()
overlay->start(); // Watch out, may emit finished() immediately!!
return; // Let it run....
}
m_paOutstandingOverlays.removeFirst();
m_paOutstandingFreeSpaceOverlays.removeFirst();
} while (true);
}
void KDIconView::slotFreeSpaceOverlayFinished()
{
m_paOutstandingOverlays.removeFirst();
m_paOutstandingFreeSpaceOverlays.removeFirst();
if (m_paOutstandingOverlays.count() > 0) {
m_paOutstandingOverlaysTimer->start(0, true); // Don't call directly to prevent deep recursion.
if (m_paOutstandingFreeSpaceOverlays.count() > 0) {
m_paOutstandingFreeSpaceOverlaysTimer->start(0, true); // Don't call directly to prevent deep recursion.
}
}

@ -278,8 +278,8 @@ private:
TQListView *mMediaListView;
TQPtrList<KFileIVI> m_paOutstandingOverlays;
TQTimer *m_paOutstandingOverlaysTimer;
TQPtrList<KFileIVI> m_paOutstandingFreeSpaceOverlays;
TQTimer *m_paOutstandingFreeSpaceOverlaysTimer;
TDEConfig *g_pConfig;
};

@ -2391,10 +2391,14 @@ static int run_vkbd = -1;
void LockProcess::showVkbd()
{
if( run_vkbd == - 1 ) {
#ifdef WITH_HAL
int status = system( "hal-find-by-property --key system.formfactor.subtype --string tabletpc" );
// status = 0; // enable for testing
run_vkbd = ( WIFEXITED( status ) && WEXITSTATUS( status ) == 0
&& !TDEStandardDirs::findExe( "xvkbd" ).isEmpty()) ? 1 : 0;
#else // WITH_HAL
run_vkbd = (!TDEStandardDirs::findExe( "xvkbd" ).isEmpty());
#endif // WITH_HAL
}
if( run_vkbd ) {
mVkbdWindows.clear();

@ -170,6 +170,7 @@ KonqKfmIconView::KonqKfmIconView( TQWidget *parentWidget, TQObject *parent, cons
, m_bNeedSetCurrentItem( false )
, m_pEnsureVisible( 0 )
, m_paOutstandingOverlaysTimer( 0 )
, m_paOutstandingFreeSpaceOverlaysTimer( 0 )
, m_pTimeoutRefreshTimer( 0 )
, m_itemDict( 43 )
{
@ -1083,8 +1084,11 @@ void KonqKfmIconView::slotDeleteItem( KFileItem * _fileitem )
m_itemDict.remove( _fileitem );
if (m_paOutstandingOverlays.first() == ivi) // Being processed?
m_paOutstandingOverlaysTimer->start(20, true); // Restart processing...
m_paOutstandingOverlays.remove(ivi);
if (m_paOutstandingFreeSpaceOverlays.first() == ivi) // Being processed?
m_paOutstandingFreeSpaceOverlaysTimer->start(20, true); // Restart processing...
m_paOutstandingFreeSpaceOverlays.remove(ivi);
delete ivi;
}
}
@ -1112,18 +1116,16 @@ void KonqKfmIconView::showFreeSpaceOverlay(KFileIVI* item)
{
KFileItem* fileItem = item->item();
if ( TDEGlobalSettings::showFilePreview( fileItem->url() ) ) {
m_paOutstandingOverlays.append(item);
if (m_paOutstandingOverlays.count() == 1)
{
if (!m_paOutstandingOverlaysTimer)
{
m_paOutstandingOverlaysTimer = new TQTimer(this);
connect(m_paOutstandingOverlaysTimer, TQT_SIGNAL(timeout()),
TQT_SLOT(slotFreeSpaceOverlayStart()));
}
m_paOutstandingOverlaysTimer->start(20, true);
}
m_paOutstandingFreeSpaceOverlays.append(item);
if (m_paOutstandingFreeSpaceOverlays.count() == 1)
{
if (!m_paOutstandingFreeSpaceOverlaysTimer)
{
m_paOutstandingFreeSpaceOverlaysTimer = new TQTimer(this);
connect(m_paOutstandingFreeSpaceOverlaysTimer, TQT_SIGNAL(timeout()),
TQT_SLOT(slotFreeSpaceOverlayStart()));
}
m_paOutstandingFreeSpaceOverlaysTimer->start(20, true);
}
}
@ -1151,7 +1153,7 @@ void KonqKfmIconView::slotFreeSpaceOverlayStart()
{
do
{
KFileIVI* item = m_paOutstandingOverlays.first();
KFileIVI* item = m_paOutstandingFreeSpaceOverlays.first();
if (!item)
return; // Nothing to do
@ -1163,7 +1165,7 @@ void KonqKfmIconView::slotFreeSpaceOverlayStart()
overlay->start(); // Watch out, may emit finished() immediately!!
return; // Let it run....
}
m_paOutstandingOverlays.removeFirst();
m_paOutstandingFreeSpaceOverlays.removeFirst();
} while (true);
}
@ -1177,10 +1179,10 @@ void KonqKfmIconView::slotDirectoryOverlayFinished()
void KonqKfmIconView::slotFreeSpaceOverlayFinished()
{
m_paOutstandingOverlays.removeFirst();
m_paOutstandingFreeSpaceOverlays.removeFirst();
if (m_paOutstandingOverlays.count() > 0)
m_paOutstandingOverlaysTimer->start(0, true); // Don't call directly to prevent deep recursion.
if (m_paOutstandingFreeSpaceOverlays.count() > 0)
m_paOutstandingFreeSpaceOverlaysTimer->start(0, true); // Don't call directly to prevent deep recursion.
}
// see also KDesktop::slotRefreshItems
@ -1211,8 +1213,14 @@ void KonqKfmIconView::slotRefreshItems( const KFileItemList& entries )
if ( !bNeedRepaint && oldSize != ivi->pixmap()->size() ) {
bNeedRepaint = true;
}
if ( (*rit)->mimetype().startsWith("media/") && (*rit)->mimetype().contains("_mounted") && m_pProps->isShowingFreeSpaceOverlays() ) {
showFreeSpaceOverlay(ivi);
if ( (*rit)->mimetype().startsWith("media/") && m_pProps->isShowingFreeSpaceOverlays() ) {
if ((*rit)->mimetype().contains("_mounted")) {
showFreeSpaceOverlay(ivi);
}
else {
// If not mounted, hide free space overlay
ivi->setShowFreeSpaceOverlay(false);
}
}
}
}
@ -1380,6 +1388,7 @@ bool KonqKfmIconView::doOpenURL( const KURL & url )
m_bUpdateContentsPosAfterListing = true;
m_paOutstandingOverlays.clear();
m_paOutstandingFreeSpaceOverlays.clear();
// Start the directory lister !
m_dirLister->openURL( url, false, args.reload );

@ -202,7 +202,9 @@ protected:
TDEToggleAction *m_paFreeSpaceOverlays;
TDEToggleAction *m_paEnablePreviews;
TQPtrList<KFileIVI> m_paOutstandingOverlays;
TQPtrList<KFileIVI> m_paOutstandingFreeSpaceOverlays;
TQTimer *m_paOutstandingOverlaysTimer;
TQTimer *m_paOutstandingFreeSpaceOverlaysTimer;
/* TDEToggleAction *m_paImagePreview;
TDEToggleAction *m_paTextPreview;
TDEToggleAction *m_paHTMLPreview;*/

@ -1422,6 +1422,8 @@ void KonqIconViewWidget::slotSaveIconPositions()
// in tdebase/kdesktop/kdiconview.cc
// WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
printf("WARNING: Strongly deprecated method KonqIconViewWidget::slotSaveIconPositions() called!\n"); fflush(stdout);
if ( m_dotDirectoryPath.isEmpty() )
return;
if ( !m_bDesktop )

@ -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);

@ -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)

@ -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

@ -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();

@ -38,6 +38,8 @@ public:
TQWidget* parent = 0, const char* name = 0 );
~NotificationDialog();
KFileItem medium();
private slots:
void slotOk();
void slotConfigure();

Loading…
Cancel
Save