20 #include "konq_settings.h"
21 #include "konq_defaults.h"
22 #include "tdeglobalsettings.h"
23 #include <tdeglobal.h>
24 #include <kservicetype.h>
25 #include <kdesktopfile.h>
28 #include <tqfontmetrics.h>
30 struct KonqFMSettingsPrivate
32 KonqFMSettingsPrivate() {
33 showPreviewsInFileTips =
true;
34 m_renameIconDirectly =
false;
37 bool showPreviewsInFileTips;
38 bool m_renameIconDirectly;
39 bool localeAwareCompareIsCaseSensitive;
51 TDEConfig *config = TDEGlobal::config();
52 TDEConfigGroupSaver cgs(config,
"FMSettings");
63 TDEConfig *config = TDEGlobal::config();
64 TDEConfigGroupSaver cgs(config,
"FMSettings");
65 s_pSettings->init( config );
69 KonqFMSettings::KonqFMSettings( TDEConfig * config )
71 d =
new KonqFMSettingsPrivate;
80 void KonqFMSettings::init( TDEConfig * config )
83 m_standardFont = config->readFontEntry(
"StandardFont" );
85 m_normalTextColor = TDEGlobalSettings::textColor();
86 m_normalTextColor = config->readColorEntry(
"NormalTextColor", &m_normalTextColor );
87 m_highlightedTextColor = TDEGlobalSettings::highlightedTextColor();
88 m_highlightedTextColor = config->readColorEntry(
"HighlightedTextColor", &m_highlightedTextColor );
89 m_itemTextBackground = config->readColorEntry(
"ItemTextBackground" );
91 d->m_iconTextWidth = config->readNumEntry(
"TextWidth", DEFAULT_TEXTWIDTH );
92 if ( d->m_iconTextWidth == DEFAULT_TEXTWIDTH )
93 d->m_iconTextWidth = TQFontMetrics(m_standardFont).width(
"0000000000");
95 m_iconTextHeight = config->readNumEntry(
"TextHeight", 0 );
96 if ( m_iconTextHeight == 0 ) {
97 if ( config->readBoolEntry(
"WordWrapText",
true ) )
98 m_iconTextHeight = DEFAULT_TEXTHEIGHT;
100 m_iconTextHeight = 1;
102 m_bWordWrapText = ( m_iconTextHeight > 1 );
104 m_underlineLink = config->readBoolEntry(
"UnderlineLinks", DEFAULT_UNDERLINELINKS );
105 d->m_renameIconDirectly = config->readBoolEntry(
"RenameIconDirectly", DEFAULT_RENAMEICONDIRECTLY );
106 m_fileSizeInBytes = config->readBoolEntry(
"DisplayFileSizeInBytes", DEFAULT_FILESIZEINBYTES );
107 m_iconTransparency = config->readNumEntry(
"TextpreviewIconOpacity", DEFAULT_TEXTPREVIEW_ICONTRANSPARENCY );
108 if ( m_iconTransparency < 0 || m_iconTransparency > 255 )
109 m_iconTransparency = DEFAULT_TEXTPREVIEW_ICONTRANSPARENCY;
112 m_alwaysNewWin = config->readBoolEntry(
"AlwaysNewWin", FALSE );
114 m_homeURL = config->readPathEntry(
"HomeURL",
"~");
116 m_showFileTips = config->readBoolEntry(
"ShowFileTips",
true);
117 d->showPreviewsInFileTips = config->readBoolEntry(
"ShowPreviewsInFileTips",
true);
118 m_numFileTips = config->readNumEntry(
"FileTipsItems", 6);
120 m_embedMap = config->entryMap(
"EmbedSettings" );
123 d->localeAwareCompareIsCaseSensitive = TQString(
"a" ).localeAwareCompare(
"B" ) > 0;
125 m_doubleClickMoveToParent = config->readBoolEntry(
"DoubleClickMoveToParent",
true);
128 bool KonqFMSettings::shouldEmbed(
const TQString & serviceType )
const
132 KServiceType::Ptr serviceTypePtr = KServiceType::serviceType( serviceType );
133 bool hasLocalProtocolRedirect =
false;
134 if ( serviceTypePtr )
136 hasLocalProtocolRedirect = !serviceTypePtr->property(
"X-TDE-LocalProtocol" ).toString().isEmpty();
137 TQVariant autoEmbedProp = serviceTypePtr->property(
"X-TDE-AutoEmbed" );
138 if ( autoEmbedProp.isValid() )
140 bool autoEmbed = autoEmbedProp.toBool();
141 kdDebug(1203) <<
"X-TDE-AutoEmbed set to " << (autoEmbed ?
"true" :
"false") << endl;
144 kdDebug(1203) <<
"No X-TDE-AutoEmbed, looking for group" << endl;
147 TQString serviceTypeGroup = serviceType.left(serviceType.find(
"/"));
148 kdDebug(1203) <<
"KonqFMSettings::shouldEmbed : serviceTypeGroup=" << serviceTypeGroup << endl;
149 if ( serviceTypeGroup ==
"inode" || serviceTypeGroup ==
"Browser" || serviceTypeGroup ==
"Konqueror" )
151 TQMap<TQString, TQString>::ConstIterator it = m_embedMap.find( TQString::fromLatin1(
"embed-")+serviceTypeGroup );
152 if ( it != m_embedMap.end() ) {
153 kdDebug(1203) <<
"KonqFMSettings::shouldEmbed: " << it.data() << endl;
154 return it.data() == TQString::fromLatin1(
"true");
159 if ( serviceTypeGroup ==
"image" || hasLocalProtocolRedirect )
164 bool KonqFMSettings::showPreviewsInFileTips()
const
166 return d->showPreviewsInFileTips;
169 bool KonqFMSettings::renameIconDirectly()
const
171 return d->m_renameIconDirectly;
174 int KonqFMSettings::caseSensitiveCompare(
const TQString& a,
const TQString& b )
const
176 if ( d->localeAwareCompareIsCaseSensitive ) {
177 return a.localeAwareCompare( b );
180 return a.compare( b );
183 int KonqFMSettings::iconTextWidth()
const
185 return d->m_iconTextWidth;
The class KonqFMSettings holds the general settings for the icon/tree views in konqueror/kdesktop.
virtual ~KonqFMSettings()
Destructor.
static void reparseConfiguration()
Reparse the configuration to update the already-created instances.
static KonqFMSettings * settings()
The static instance of KonqFMSettings.