• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • libkonq
 

libkonq

  • libkonq
konq_settings.cpp
1 /* This file is part of the KDE project
2  Copyright (C) 1999 David Faure <faure@kde.org>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License as published by the Free Software Foundation; either
7  version 2 of the License, or (at your option) any later version.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Library General Public License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to
16  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  Boston, MA 02110-1301, USA.
18 */
19 
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>
26 #include <kdebug.h>
27 #include <assert.h>
28 #include <tqfontmetrics.h>
29 
30 struct KonqFMSettingsPrivate
31 {
32  KonqFMSettingsPrivate() {
33  showPreviewsInFileTips = true;
34  m_renameIconDirectly = false;
35  }
36 
37  bool showPreviewsInFileTips;
38  bool m_renameIconDirectly;
39  bool localeAwareCompareIsCaseSensitive;
40  int m_iconTextWidth;
41 };
42 
43 //static
44 KonqFMSettings * KonqFMSettings::s_pSettings = 0L;
45 
46 //static
47 KonqFMSettings * KonqFMSettings::settings()
48 {
49  if (!s_pSettings)
50  {
51  TDEConfig *config = TDEGlobal::config();
52  TDEConfigGroupSaver cgs(config, "FMSettings");
53  s_pSettings = new KonqFMSettings(config);
54  }
55  return s_pSettings;
56 }
57 
58 //static
59 void KonqFMSettings::reparseConfiguration()
60 {
61  if (s_pSettings)
62  {
63  TDEConfig *config = TDEGlobal::config();
64  TDEConfigGroupSaver cgs(config, "FMSettings");
65  s_pSettings->init( config );
66  }
67 }
68 
69 KonqFMSettings::KonqFMSettings( TDEConfig * config )
70 {
71  d = new KonqFMSettingsPrivate;
72  init( config );
73 }
74 
75 KonqFMSettings::~KonqFMSettings()
76 {
77  delete d;
78 }
79 
80 void KonqFMSettings::init( TDEConfig * config )
81 {
82  // Fonts and colors
83  m_standardFont = config->readFontEntry( "StandardFont" );
84 
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" );
90 
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");
94 
95  m_iconTextHeight = config->readNumEntry( "TextHeight", 0 );
96  if ( m_iconTextHeight == 0 ) {
97  if ( config->readBoolEntry( "WordWrapText", true ) )
98  m_iconTextHeight = DEFAULT_TEXTHEIGHT;
99  else
100  m_iconTextHeight = 1;
101  }
102  m_bWordWrapText = ( m_iconTextHeight > 1 );
103 
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;
110 
111  // Behaviour
112  m_alwaysNewWin = config->readBoolEntry( "AlwaysNewWin", false );
113 
114  m_homeURL = config->readPathEntry("HomeURL", "~");
115 
116  m_showFileTips = config->readBoolEntry("ShowFileTips", true);
117  d->showPreviewsInFileTips = config->readBoolEntry("ShowPreviewsInFileTips", true);
118  m_numFileTips = config->readNumEntry("FileTipsItems", 6);
119 
120  m_embedMap = config->entryMap( "EmbedSettings" );
121 
123  d->localeAwareCompareIsCaseSensitive = TQString( "a" ).localeAwareCompare( "B" ) > 0; // see #40131
124 
125  m_doubleClickMoveToParent = config->readBoolEntry("DoubleClickMoveToParent", true);
126 }
127 
128 bool KonqFMSettings::shouldEmbed( const TQString & serviceType ) const
129 {
130  // First check in user's settings whether to embed or not
131  // 1 - in the mimetype file itself
132  KServiceType::Ptr serviceTypePtr = KServiceType::serviceType( serviceType );
133  bool hasLocalProtocolRedirect = false;
134  if ( serviceTypePtr )
135  {
136  hasLocalProtocolRedirect = !serviceTypePtr->property( "X-TDE-LocalProtocol" ).toString().isEmpty();
137  TQVariant autoEmbedProp = serviceTypePtr->property( "X-TDE-AutoEmbed" );
138  if ( autoEmbedProp.isValid() )
139  {
140  bool autoEmbed = autoEmbedProp.toBool();
141  kdDebug(1203) << "X-TDE-AutoEmbed set to " << (autoEmbed ? "true" : "false") << endl;
142  return autoEmbed;
143  } else
144  kdDebug(1203) << "No X-TDE-AutoEmbed, looking for group" << endl;
145  }
146  // 2 - in the configuration for the group if nothing was found in the mimetype
147  TQString serviceTypeGroup = serviceType.left(serviceType.find("/"));
148  kdDebug(1203) << "KonqFMSettings::shouldEmbed : serviceTypeGroup=" << serviceTypeGroup << endl;
149  if ( serviceTypeGroup == "inode" || serviceTypeGroup == "Browser" || serviceTypeGroup == "Konqueror" )
150  return true; //always embed mimetype inode/*, Browser/* and 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");
155  }
156  // 3 - if no config found, use default.
157  // Note: if you change those defaults, also change kcontrol/filetypes/typeslistitem.cpp !
158  // Embedding is false by default except for image/* and for zip, tar etc.
159  if ( serviceTypeGroup == "image" || hasLocalProtocolRedirect )
160  return true;
161  return false;
162 }
163 
164 bool KonqFMSettings::showPreviewsInFileTips() const
165 {
166  return d->showPreviewsInFileTips;
167 }
168 
169 bool KonqFMSettings::renameIconDirectly() const
170 {
171  return d->m_renameIconDirectly;
172 }
173 
174 int KonqFMSettings::caseSensitiveCompare( const TQString& a, const TQString& b ) const
175 {
176  if ( d->localeAwareCompareIsCaseSensitive ) {
177  return a.localeAwareCompare( b );
178  }
179  else // can't use localeAwareCompare, have to fallback to normal TQString compare
180  return a.compare( b );
181 }
182 
183 int KonqFMSettings::iconTextWidth() const
184 {
185  return d->m_iconTextWidth;
186 }
KonqFMSettings::reparseConfiguration
static void reparseConfiguration()
Reparse the configuration to update the already-created instances.
Definition: konq_settings.cpp:59
KonqFMSettings::settings
static KonqFMSettings * settings()
The static instance of KonqFMSettings.
Definition: konq_settings.cpp:47
KonqFMSettings::~KonqFMSettings
virtual ~KonqFMSettings()
Destructor.
Definition: konq_settings.cpp:75
KonqFMSettings
The class KonqFMSettings holds the general settings for the icon/tree views in konqueror/kdesktop.
Definition: konq_settings.h:44

libkonq

Skip menu "libkonq"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

libkonq

Skip menu "libkonq"
  • kate
  • libkonq
  • twin
  •   lib
Generated for libkonq by doxygen 1.8.13
This website is maintained by Timothy Pearson.