konq_settings.cc
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "konq_settings.h"
00021 #include "konq_defaults.h"
00022 #include "kglobalsettings.h"
00023 #include <kglobal.h>
00024 #include <kservicetype.h>
00025 #include <kdesktopfile.h>
00026 #include <kdebug.h>
00027 #include <assert.h>
00028
00029 struct KonqFMSettingsPrivate
00030 {
00031 KonqFMSettingsPrivate() {
00032 showPreviewsInFileTips = true;
00033 m_renameIconDirectly = false;
00034 }
00035
00036 bool showPreviewsInFileTips;
00037 bool m_renameIconDirectly;
00038 bool localeAwareCompareIsCaseSensitive;
00039 };
00040
00041
00042 KonqFMSettings * KonqFMSettings::s_pSettings = 0L;
00043
00044
00045 KonqFMSettings * KonqFMSettings::settings()
00046 {
00047 if (!s_pSettings)
00048 {
00049 KConfig *config = KGlobal::config();
00050 KConfigGroupSaver cgs(config, "FMSettings");
00051 s_pSettings = new KonqFMSettings(config);
00052 }
00053 return s_pSettings;
00054 }
00055
00056
00057 void KonqFMSettings::reparseConfiguration()
00058 {
00059 if (s_pSettings)
00060 {
00061 KConfig *config = KGlobal::config();
00062 KConfigGroupSaver cgs(config, "FMSettings");
00063 s_pSettings->init( config );
00064 }
00065 }
00066
00067 KonqFMSettings::KonqFMSettings( KConfig * config )
00068 {
00069 d = new KonqFMSettingsPrivate;
00070 init( config );
00071 }
00072
00073 KonqFMSettings::~KonqFMSettings()
00074 {
00075 delete d;
00076 }
00077
00078 void KonqFMSettings::init( KConfig * config )
00079 {
00080
00081 m_standardFont = config->readFontEntry( "StandardFont" );
00082
00083 m_normalTextColor = KGlobalSettings::textColor();
00084 m_normalTextColor = config->readColorEntry( "NormalTextColor", &m_normalTextColor );
00085 m_highlightedTextColor = KGlobalSettings::highlightedTextColor();
00086 m_highlightedTextColor = config->readColorEntry( "HighlightedTextColor", &m_highlightedTextColor );
00087 m_itemTextBackground = config->readColorEntry( "ItemTextBackground" );
00088 m_bWordWrapText = config->readBoolEntry( "WordWrapText", DEFAULT_WORDWRAPTEXT );
00089 m_underlineLink = config->readBoolEntry( "UnderlineLinks", DEFAULT_UNDERLINELINKS );
00090 d->m_renameIconDirectly = config->readBoolEntry( "RenameIconDirectly", DEFAULT_RENAMEICONDIRECTLY );
00091 m_fileSizeInBytes = config->readBoolEntry( "DisplayFileSizeInBytes", DEFAULT_FILESIZEINBYTES );
00092 m_iconTransparency = config->readNumEntry( "TextpreviewIconOpacity", DEFAULT_TEXTPREVIEW_ICONTRANSPARENCY );
00093 if ( m_iconTransparency < 0 || m_iconTransparency > 255 )
00094 m_iconTransparency = DEFAULT_TEXTPREVIEW_ICONTRANSPARENCY;
00095
00096
00097 m_alwaysNewWin = config->readBoolEntry( "AlwaysNewWin", FALSE );
00098
00099 m_homeURL = config->readPathEntry("HomeURL", "~");
00100
00101 m_showFileTips = config->readBoolEntry("ShowFileTips", true);
00102 d->showPreviewsInFileTips = config->readBoolEntry("ShowPreviewsInFileTips", true);
00103 m_numFileTips = config->readNumEntry("FileTipsItems", 6);
00104
00105 m_embedMap = config->entryMap( "EmbedSettings" );
00106
00108 d->localeAwareCompareIsCaseSensitive = QString( "a" ).localeAwareCompare( "B" ) > 0;
00109 }
00110
00111 bool KonqFMSettings::shouldEmbed( const QString & serviceType ) const
00112 {
00113
00114
00115 KServiceType::Ptr serviceTypePtr = KServiceType::serviceType( serviceType );
00116
00117 if ( serviceTypePtr )
00118 {
00119 kdDebug(1203) << serviceTypePtr->desktopEntryPath() << endl;
00120 KDesktopFile deFile( serviceTypePtr->desktopEntryPath(),
00121 true , "mime");
00122 if ( deFile.hasKey( "X-KDE-AutoEmbed" ) )
00123 {
00124 bool autoEmbed = deFile.readBoolEntry( "X-KDE-AutoEmbed" );
00125 kdDebug(1203) << "X-KDE-AutoEmbed set to " << (autoEmbed ? "true" : "false") << endl;
00126 return autoEmbed;
00127 } else
00128 kdDebug(1203) << "No X-KDE-AutoEmbed, looking for group" << endl;
00129 }
00130
00131 QString serviceTypeGroup = serviceType.left(serviceType.find("/"));
00132 kdDebug(1203) << "KonqFMSettings::shouldEmbed : serviceTypeGroup=" << serviceTypeGroup << endl;
00133 if ( serviceTypeGroup == "inode" || serviceTypeGroup == "Browser" || serviceTypeGroup == "Konqueror" )
00134 return true;
00135 QMap<QString, QString>::ConstIterator it = m_embedMap.find( QString::fromLatin1("embed-")+serviceTypeGroup );
00136 if ( it == m_embedMap.end() )
00137 return (serviceTypeGroup=="image");
00138
00139 kdDebug(1203) << "KonqFMSettings::shouldEmbed: " << it.data() << endl;
00140 return it.data() == QString::fromLatin1("true");
00141 }
00142
00143 bool KonqFMSettings::showPreviewsInFileTips() const
00144 {
00145 return d->showPreviewsInFileTips;
00146 }
00147
00148 bool KonqFMSettings::renameIconDirectly() const
00149 {
00150 return d->m_renameIconDirectly;
00151 }
00152
00153 int KonqFMSettings::caseSensitiveCompare( const QString& a, const QString& b ) const
00154 {
00155 if ( d->localeAwareCompareIsCaseSensitive ) {
00156 return a.localeAwareCompare( b );
00157 }
00158 else
00159 return a.compare( b );
00160 }
This file is part of the documentation for libkonq Library Version 3.2.2.