summaryrefslogtreecommitdiffstats
path: root/konqueror
diff options
context:
space:
mode:
authorTimothy Pearson <[email protected]>2013-04-13 22:41:07 -0500
committerTimothy Pearson <[email protected]>2013-04-13 22:41:07 -0500
commit9e4aad6b3bc3c1b4781a3c1cef6968640d4f6e67 (patch)
tree93678c9bd7fd986e44911b920bc066c591274dae /konqueror
parent3df12cd87674fdfbc2afa21584e1f3e558fa873b (diff)
downloadtdebase-9e4aad6b3bc3c1b4781a3c1cef6968640d4f6e67.tar.gz
tdebase-9e4aad6b3bc3c1b4781a3c1cef6968640d4f6e67.zip
Add initial media device free space overlay to Konqueror icon view
Diffstat (limited to 'konqueror')
-rw-r--r--konqueror/iconview/konq_iconview.cc76
-rw-r--r--konqueror/iconview/konq_iconview.h5
-rw-r--r--konqueror/iconview/konq_iconview.rc1
3 files changed, 82 insertions, 0 deletions
diff --git a/konqueror/iconview/konq_iconview.cc b/konqueror/iconview/konq_iconview.cc
index a7bb5a812..1ac7b2eb5 100644
--- a/konqueror/iconview/konq_iconview.cc
+++ b/konqueror/iconview/konq_iconview.cc
@@ -40,6 +40,7 @@
#include <ktrader.h>
#include <tdelocale.h>
#include <kivdirectoryoverlay.h>
+#include <kivfreespaceoverlay.h>
#include <tdemessagebox.h>
#include <kstaticdeleter.h>
@@ -217,6 +218,9 @@ KonqKfmIconView::KonqKfmIconView( TQWidget *parentWidget, TQObject *parent, cons
m_paDirectoryOverlays = new TDEToggleAction( i18n( "&Folder Icons Reflect Contents" ), 0, this, TQT_SLOT( slotShowDirectoryOverlays() ),
actionCollection(), "show_directory_overlays" );
+ m_paFreeSpaceOverlays = new TDEToggleAction( i18n( "&Media Icons Reflect Free Space" ), 0, this, TQT_SLOT( slotShowFreeSpaceOverlays() ),
+ actionCollection(), "show_free_space_overlays" );
+
m_pamPreview = new TDEActionMenu( i18n( "&Preview" ), actionCollection(), "iconview_preview" );
m_paEnablePreviews = new TDEToggleAction( i18n("Enable Previews"), 0, actionCollection(), "iconview_preview_all" );
@@ -517,6 +521,27 @@ void KonqKfmIconView::slotShowDirectoryOverlays()
m_pIconView->updateContents();
}
+void KonqKfmIconView::slotShowFreeSpaceOverlays()
+{
+ bool show = !m_pProps->isShowingFreeSpaceOverlays();
+
+ m_pProps->setShowingFreeSpaceOverlays( show );
+
+ for ( TQIconViewItem *item = m_pIconView->firstItem(); item; item = item->nextItem() )
+ {
+ KFileIVI* kItem = static_cast<KFileIVI*>(item);
+ if ( !kItem->item()->isDir() ) continue;
+
+ if (show) {
+ showFreeSpaceOverlay(kItem);
+ } else {
+ kItem -> setShowFreeSpaceOverlay(false);
+ }
+ }
+
+ m_pIconView->updateContents();
+}
+
void KonqKfmIconView::slotSelect()
{
bool ok;
@@ -978,6 +1003,9 @@ void KonqKfmIconView::slotNewItems( const KFileItemList& entries )
if ( fileItem->isDir() && m_pProps->isShowingDirectoryOverlays() ) {
showDirectoryOverlay(item);
}
+ if ( fileItem->mimetype().startsWith("media/") && m_pProps->isShowingFreeSpaceOverlays() ) {
+ showFreeSpaceOverlay(item);
+ }
TQString key;
@@ -1074,6 +1102,25 @@ void KonqKfmIconView::showDirectoryOverlay(KFileIVI* item)
}
}
+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);
+ }
+ }
+}
+
void KonqKfmIconView::slotDirectoryOverlayStart()
{
do
@@ -1094,6 +1141,26 @@ void KonqKfmIconView::slotDirectoryOverlayStart()
} while (true);
}
+void KonqKfmIconView::slotFreeSpaceOverlayStart()
+{
+ do
+ {
+ KFileIVI* item = m_paOutstandingOverlays.first();
+ if (!item)
+ return; // Nothing to do
+
+ KIVFreeSpaceOverlay* overlay = item->setShowFreeSpaceOverlay( true );
+
+ if (overlay)
+ {
+ connect( overlay, TQT_SIGNAL( finished() ), this, TQT_SLOT( slotFreeSpaceOverlayFinished() ) );
+ overlay->start(); // Watch out, may emit finished() immediately!!
+ return; // Let it run....
+ }
+ m_paOutstandingOverlays.removeFirst();
+ } while (true);
+}
+
void KonqKfmIconView::slotDirectoryOverlayFinished()
{
m_paOutstandingOverlays.removeFirst();
@@ -1102,6 +1169,14 @@ void KonqKfmIconView::slotDirectoryOverlayFinished()
m_paOutstandingOverlaysTimer->start(0, true); // Don't call directly to prevent deep recursion.
}
+void KonqKfmIconView::slotFreeSpaceOverlayFinished()
+{
+ m_paOutstandingOverlays.removeFirst();
+
+ if (m_paOutstandingOverlays.count() > 0)
+ m_paOutstandingOverlaysTimer->start(0, true); // Don't call directly to prevent deep recursion.
+}
+
// see also KDesktop::slotRefreshItems
void KonqKfmIconView::slotRefreshItems( const KFileItemList& entries )
{
@@ -1302,6 +1377,7 @@ bool KonqKfmIconView::doOpenURL( const KURL & url )
{
m_paDotFiles->setChecked( m_pProps->isShowingDotFiles() );
m_paDirectoryOverlays->setChecked( m_pProps->isShowingDirectoryOverlays() );
+ m_paFreeSpaceOverlays->setChecked( m_pProps->isShowingFreeSpaceOverlays() );
m_paEnablePreviews->setChecked( m_pProps->isShowingPreview() );
for ( m_paPreviewPlugins.first(); m_paPreviewPlugins.current(); m_paPreviewPlugins.next() )
{
diff --git a/konqueror/iconview/konq_iconview.h b/konqueror/iconview/konq_iconview.h
index c05362b9d..d66cc4cc8 100644
--- a/konqueror/iconview/konq_iconview.h
+++ b/konqueror/iconview/konq_iconview.h
@@ -76,6 +76,7 @@ public:
public slots:
void slotPreview( bool toggle );
void slotShowDirectoryOverlays();
+ void slotShowFreeSpaceOverlays();
void slotShowDot();
void slotSelect();
void slotUnselect();
@@ -120,7 +121,9 @@ protected slots:
virtual void slotClear();
virtual void slotRedirection( const KURL & );
virtual void slotDirectoryOverlayStart();
+ virtual void slotFreeSpaceOverlayStart();
virtual void slotDirectoryOverlayFinished();
+ virtual void slotFreeSpaceOverlayFinished();
/**
* This is the 'real' finished slot, where we emit the completed() signal
@@ -196,6 +199,7 @@ protected:
TDEToggleAction *m_paDotFiles;
TDEToggleAction *m_paDirectoryOverlays;
+ TDEToggleAction *m_paFreeSpaceOverlays;
TDEToggleAction *m_paEnablePreviews;
TQPtrList<KFileIVI> m_paOutstandingOverlays;
TQTimer *m_paOutstandingOverlaysTimer;
@@ -226,6 +230,7 @@ protected:
private:
void showDirectoryOverlay(KFileIVI* item);
+ void showFreeSpaceOverlay(KFileIVI* item);
};
class IconViewBrowserExtension : public KonqDirPartBrowserExtension
diff --git a/konqueror/iconview/konq_iconview.rc b/konqueror/iconview/konq_iconview.rc
index 20551e0a7..4c0f95c99 100644
--- a/konqueror/iconview/konq_iconview.rc
+++ b/konqueror/iconview/konq_iconview.rc
@@ -36,6 +36,7 @@
<Action name="iconview_preview" />
<Action name="show_dot"/>
<Action name="show_directory_overlays"/>
+ <Action name="show_free_space_overlays"/>
<Separator/>
<Action name="bgsettings"/>
</Menu>