Make a branch to make krunner Good Enough For Aaron™.
[kdebase/uwolfer.git] / apps / konqueror / src / konqsettings.cpp
blob792cd12e14ae3191d95351c98ed842390cf98824
1 /* This file is part of the KDE project
2 Copyright (C) 1999, 2007 David Faure <faure@kde.org>
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.
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.
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.
20 #include "konqsettings.h"
21 #include "konq_defaults.h"
22 #include "kglobalsettings.h"
23 #include <ksharedconfig.h>
24 #include <kglobal.h>
25 #include <kmimetype.h>
26 #include <kdesktopfile.h>
27 #include <kdebug.h>
28 #include <assert.h>
29 #include <kconfiggroup.h>
31 //static
32 KonqFMSettings * KonqFMSettings::s_pSettings = 0L;
34 //static
35 KonqFMSettings * KonqFMSettings::settings()
37 if (!s_pSettings)
39 KSharedConfig::Ptr config = KGlobal::config();
40 KConfigGroup cgs(config, "FMSettings");
41 s_pSettings = new KonqFMSettings(cgs);
43 return s_pSettings;
46 //static
47 void KonqFMSettings::reparseConfiguration()
49 if (s_pSettings)
51 KSharedConfig::Ptr config = KGlobal::config();
52 KConfigGroup cgs(config, "FMSettings");
53 s_pSettings->init(cgs);
57 KonqFMSettings::KonqFMSettings(const KConfigGroup &config)
59 init(config);
62 KonqFMSettings::~KonqFMSettings()
66 void KonqFMSettings::init(const KConfigGroup &config)
68 m_homeURL = config.readPathEntry("HomeURL", "~");
69 const KSharedConfig::Ptr fileTypesConfig = KSharedConfig::openConfig("filetypesrc", KConfig::NoGlobals);
70 m_embedMap = fileTypesConfig->entryMap("EmbedSettings");
73 bool KonqFMSettings::shouldEmbed( const QString & mimeType ) const
75 // First check in user's settings whether to embed or not
76 // 1 - in the filetypesrc config file (written by the configuration module)
77 bool hasLocalProtocolRedirect = false;
78 // TODO
79 //hasLocalProtocolRedirect = !mimeTypePtr->property( "X-KDE-LocalProtocol" ).toString().isEmpty();
80 QMap<QString, QString>::const_iterator it = m_embedMap.find( QString::fromLatin1("embed-")+mimeType );
81 if ( it != m_embedMap.end() ) {
82 kDebug(1202) << mimeType << it.value();
83 return it.value() == QLatin1String("true");
85 // 2 - in the configuration for the group if nothing was found in the mimetype
86 QString mimeTypeGroup = mimeType.left(mimeType.indexOf('/'));
87 if ( mimeTypeGroup == "inode" || mimeTypeGroup == "Browser" || mimeTypeGroup == "Konqueror" )
88 return true; //always embed mimetype inode/*, Browser/* and Konqueror/*
89 it = m_embedMap.find( QString::fromLatin1("embed-")+mimeTypeGroup );
90 if ( it != m_embedMap.end() ) {
91 kDebug(1202) << mimeType << "group setting:" << it.value();
92 return it.value() == QLatin1String("true");
94 // 3 - if no config found, use default.
95 // Note: if you change those defaults, also change kcontrol/filetypes/mimetypedata.cpp !
96 // Embedding is false by default except for image/* and for zip, tar etc.
97 if ( mimeTypeGroup == "image" || hasLocalProtocolRedirect )
98 return true;
99 return false;
102 QString KonqFMSettings::homeUrl() const
104 return m_homeURL;