summaryrefslogtreecommitdiffstats
path: root/kdesktop/kdiconview.cc
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-09-24 01:59:23 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-09-24 01:59:23 +0000
commit6ade341229a0ce755b3e606d974b37c7d1609c8a (patch)
tree07389116d19da9923d611a79f85d2c200f23e511 /kdesktop/kdiconview.cc
parentd1839212f86747491106bd28e4401d9f96c723dd (diff)
downloadtdebase-6ade341229a0ce755b3e606d974b37c7d1609c8a.tar.gz
tdebase-6ade341229a0ce755b3e606d974b37c7d1609c8a.zip
* Allow XDG launcher to directly rewrite the XDG configuration file instead of going through a third party application
* Fix desktop icon builtin detection * Desktop icon removal is now more intuitive git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1178835 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kdesktop/kdiconview.cc')
-rw-r--r--kdesktop/kdiconview.cc103
1 files changed, 84 insertions, 19 deletions
diff --git a/kdesktop/kdiconview.cc b/kdesktop/kdiconview.cc
index fa7a9d7d0..ed0500e1c 100644
--- a/kdesktop/kdiconview.cc
+++ b/kdesktop/kdiconview.cc
@@ -190,6 +190,8 @@ KDIconView::KDIconView( TQWidget *parent, const char* name )
setAcceptDrops(false);
viewport()->setAcceptDrops(false);
}
+
+ g_pConfig = new KConfig("kdesktoprc");
}
KDIconView::~KDIconView()
@@ -719,6 +721,74 @@ void KDIconView::slotPopupPasteTo()
paste( m_popupURL );
}
+// These two functions and the following class are all lifted from desktopbehavior_impl.cpp to handle the media icons
+class DesktopBehaviorMediaItem : public QCheckListItem
+{
+public:
+ DesktopBehaviorMediaItem(TQListView *parent, const TQString name, const TQString mimetype, bool on)
+ : TQCheckListItem(parent, name, CheckBox),
+ m_mimeType(mimetype){setOn(on);}
+
+ const TQString &mimeType() const { return m_mimeType; }
+
+private:
+ TQString m_mimeType;
+};
+
+void KDIconView::fillMediaListView()
+{
+ if (!mMediaListView)
+ mMediaListView = new TQListView();
+ mMediaListView->hide();
+ mMediaListView->clear();
+ KMimeType::List mimetypes = KMimeType::allMimeTypes();
+ TQValueListIterator<KMimeType::Ptr> it2(mimetypes.begin());
+ g_pConfig->setGroup( "Media" );
+ TQString excludedMedia=g_pConfig->readEntry("exclude","media/hdd_mounted,media/hdd_unmounted,media/floppy_unmounted,media/cdrom_unmounted,media/floppy5_unmounted");
+ for (; it2 != mimetypes.end(); ++it2) {
+ if ( ((*it2)->name().startsWith("media/")) )
+ {
+ bool ok=excludedMedia.contains((*it2)->name())==0;
+ new DesktopBehaviorMediaItem (mMediaListView, (*it2)->comment(), (*it2)->name(),ok);
+ }
+ }
+}
+
+void KDIconView::saveMediaListView()
+{
+ g_pConfig->setGroup( "Media" );
+ TQStringList exclude;
+ for (DesktopBehaviorMediaItem *it=static_cast<DesktopBehaviorMediaItem *>(mMediaListView->firstChild());
+ it; it=static_cast<DesktopBehaviorMediaItem *>(it->nextSibling()))
+ {
+ if (!it->isOn()) exclude << it->mimeType();
+ }
+ g_pConfig->writeEntry("exclude",exclude);
+ g_pConfig->sync();
+
+ // Reload kdesktop configuration to apply changes
+ TQByteArray data;
+ int konq_screen_number = KApplication::desktop()->primaryScreen();
+ TQCString appname;
+ if (konq_screen_number == 0)
+ appname = "kdesktop";
+ else
+ appname.sprintf("kdesktop-screen-%d", konq_screen_number);
+ kapp->dcopClient()->send( appname, "KDesktopIface", "configure()", data );
+}
+
+void KDIconView::removeBuiltinIcon(TQString iconName)
+{
+ DesktopBehaviorMediaItem *changeItem;
+ fillMediaListView();
+ changeItem = static_cast<DesktopBehaviorMediaItem *>(mMediaListView->findItem(iconName, 0));
+ if (changeItem != 0) {
+ changeItem->setOn(false);
+ }
+ saveMediaListView();
+ KMessageBox::information(0, i18n("You have chosen to remove a system icon") + TQString(".\n") + i18n("You can restore this icon in the future through the") + TQString(" \"") + ("Device Icons") + TQString("\" ") + i18n("tab in the") + TQString(" \"") + i18n("Behavior") + TQString("\" ") + i18n("pane of the Desktop Settings control module."), "System Icon Removed", "sysiconremovedwarning");
+}
+
/**
* The files on the desktop come from a variety of sources.
* If an attempt is made to delete a .desktop file that does
@@ -762,49 +832,44 @@ bool KDIconView::deleteGlobalDesktopFiles()
// Ignore these special files
// Name URL Type OnlyShowIn
- // My Documents $HOME/Documents Link KDE;
+ // My Documents kxdglauncher --xdgname DOCUMENTS Application KDE;
// My Computer media:/ Link KDE;
// My Network Places remote:/ Link KDE;
// Printers [exec] kjobviewer --all --show %i %m Application KDE;
// Trash trash:/ Link KDE;
- // Web Browser <dont care> Application KDE;
+ // Web Browser kfmclient openBrowser %u Application KDE;
if ( isDesktopFile(fItem) ) {
KSimpleConfig cfg( fItem->url().path(), true );
cfg.setDesktopGroup();
- if ( cfg.readEntry( "Type" ) == "Link" &&
- cfg.readEntry( "URL" ) == "$HOME/Documents" &&
- cfg.readEntry( "OnlyShowIn" ) == "KDE;" &&
+ if ( cfg.readEntry( "X-Trinity-BuiltIn" ) == "true" &&
cfg.readEntry( "Name" ) == "My Documents" ) {
+ removeBuiltinIcon("My Documents");
continue;
}
- if ( cfg.readEntry( "Type" ) == "Link" &&
- cfg.readEntry( "URL" ) == "media:/" &&
- cfg.readEntry( "OnlyShowIn" ) == "KDE;" &&
+ if ( cfg.readEntry( "X-Trinity-BuiltIn" ) == "true" &&
cfg.readEntry( "Name" ) == "My Computer" ) {
+ removeBuiltinIcon("My Computer");
continue;
}
- if ( cfg.readEntry( "Type" ) == "Link" &&
- cfg.readEntry( "URL" ) == "remote:/" &&
- cfg.readEntry( "OnlyShowIn" ) == "KDE;" &&
+ if ( cfg.readEntry( "X-Trinity-BuiltIn" ) == "true" &&
cfg.readEntry( "Name" ) == "My Network Places" ) {
+ removeBuiltinIcon("My Network Places");
continue;
}
- if ( cfg.readEntry( "Type" ) == "Application" &&
- cfg.readEntry( "Exec" ) == "kjobviewer --all --show %i %m" &&
- cfg.readEntry( "OnlyShowIn" ) == "KDE;" &&
+ if ( cfg.readEntry( "X-Trinity-BuiltIn" ) == "true" &&
cfg.readEntry( "Name" ) == "Printers" ) {
+ removeBuiltinIcon("Printers");
continue;
}
- if ( cfg.readEntry( "Type" ) == "Link" &&
- cfg.readEntry( "URL" ) == "trash:/" &&
- cfg.readEntry( "OnlyShowIn" ) == "KDE;" &&
+ if ( cfg.readEntry( "X-Trinity-BuiltIn" ) == "true" &&
cfg.readEntry( "Name" ) == "Trash" ) {
+ removeBuiltinIcon("Trash");
continue;
}
- if ( cfg.readEntry( "Type" ) == "Application" &&
- cfg.readEntry( "OnlyShowIn" ) == "KDE;" &&
+ if ( cfg.readEntry( "X-Trinity-BuiltIn" ) == "true" &&
cfg.readEntry( "Name" ) == "Web Browser" ) {
+ removeBuiltinIcon("Web Browser");
continue;
}
}