tdefilespeedbar.cpp
00001 /* This file is part of the KDE libraries 00002 Copyright (C) 2002 Carsten Pfeiffer <pfeiffer@kde.org> 00003 00004 library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation, version 2. 00007 00008 This library is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00011 Library General Public License for more details. 00012 00013 You should have received a copy of the GNU Library General Public License 00014 along with this library; see the file COPYING.LIB. If not, write to 00015 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00016 Boston, MA 02110-1301, USA. 00017 */ 00018 00019 #include "tdefilespeedbar.h" 00020 #include "config-tdefile.h" 00021 00022 #include <tqdir.h> 00023 #include <tqfile.h> 00024 #include <tqtextcodec.h> 00025 #include <tqtextstream.h> 00026 00027 #include <tdeconfig.h> 00028 #include <tdeglobal.h> 00029 #include <tdeglobalsettings.h> 00030 #include <tdelocale.h> 00031 #include <kprotocolinfo.h> 00032 #include <kstandarddirs.h> 00033 #include <kurl.h> 00034 00035 KFileSpeedBar::KFileSpeedBar( TQWidget *parent, const char *name ) 00036 : KURLBar( true, parent, name ) 00037 { 00038 TDEConfig *config = TDEGlobal::config(); 00039 TDEConfigGroupSaver cs( config, ConfigGroup ); 00040 m_initializeSpeedbar = config->readBoolEntry( "Set speedbar defaults", 00041 true ); 00042 setIconSize(TDEIcon::SizeSmallMedium); 00043 readConfig( TDEGlobal::config(), "KFileDialog Speedbar" ); 00044 00045 if ( m_initializeSpeedbar ) 00046 { 00047 insertItem(TQDir::homeDirPath(), i18n("Home Folder"), false, "folder_home"); 00048 insertItem(TDEGlobalSettings::desktopPath(), i18n("Desktop"), false, "desktop"); 00049 insertItem(TDEGlobalSettings::documentPath(), i18n("Documents"), false, "folder_wordprocessing"); 00050 insertItem(TDEGlobalSettings::downloadPath(), i18n( "Downloads" ), false, "folder_html"); 00051 insertItem(TDEGlobalSettings::musicPath(), i18n( "Music" ), false, "folder_sound"); 00052 insertItem(TDEGlobalSettings::picturesPath(), i18n( "Pictures" ), false, "folder_image"); 00053 insertItem(TDEGlobalSettings::publicSharePath(), i18n( "Public" ), false, "folder_open"); 00054 insertItem(TDEGlobalSettings::templatesPath(), i18n( "Templates" ), false, "folder_grey"); 00055 insertItem(TDEGlobalSettings::videosPath(), i18n( "Videos" ), false, "folder_video"); 00056 00057 KURL u = "media:/"; 00058 if (KProtocolInfo::isKnownProtocol(u)) 00059 { 00060 insertItem(u, i18n("Storage Media"), false, KProtocolInfo::icon("media")); 00061 } 00062 00063 u = "remote:/"; 00064 if (KProtocolInfo::isKnownProtocol(u)) 00065 { 00066 insertItem(u, i18n("Network Folders"), false, KProtocolInfo::icon("remote")); 00067 } 00068 } 00069 } 00070 00071 KFileSpeedBar::~KFileSpeedBar() 00072 { 00073 } 00074 00075 void KFileSpeedBar::save( TDEConfig *config ) 00076 { 00077 if ( m_initializeSpeedbar && isModified() ) 00078 { 00079 TDEConfigGroup conf( config, ConfigGroup ); 00080 // write to kdeglobals 00081 conf.writeEntry( "Set speedbar defaults", false, true, true ); 00082 } 00083 00084 writeConfig( config, "KFileDialog Speedbar" ); 00085 } 00086 00087 TQSize KFileSpeedBar::sizeHint() const 00088 { 00089 TQSize sizeHint = KURLBar::sizeHint(); 00090 int ems = fontMetrics().width("mmmmmmmmmmmm"); 00091 if (sizeHint.width() < ems) 00092 { 00093 sizeHint.setWidth(ems); 00094 } 00095 return sizeHint; 00096 } 00097 00098 #include "tdefilespeedbar.moc"