add more spacing
[personal-kdebase.git] / workspace / kcontrol / krdb / krdb_clearlibrarypath.cpp
blob53e240bbae41b0b6244d2b81dcb10ca9824d65a5
1 /* This file is part of the KDE project
2 Copyright (C) 2008 Matthias Kretz <kretz@kde.org>
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) version 3, or any
8 later version accepted by the membership of KDE e.V. (or its
9 successor approved by the membership of KDE e.V.), Trolltech ASA
10 (or its successors, if any) and the KDE Free Qt Foundation, which shall
11 act as a proxy defined in Section 6 of version 3 of the license.
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
18 You should have received a copy of the GNU Lesser General Public
19 License along with this library. If not, see <http://www.gnu.org/licenses/>.
23 #include <QtCore/QCoreApplication>
24 #include <QtCore/QDir>
25 #include <QtCore/QSettings>
26 #include <QtCore/QStringList>
27 #include <kcomponentdata.h>
28 #include <kglobal.h>
29 #include <kstandarddirs.h>
31 int main(int argc, char **argv)
33 QCoreApplication app(argc, argv);
34 QSettings settings(QLatin1String("Trolltech"));
35 QString qversion = qVersion();
36 if (qversion.count('.') > 1) {
37 qversion.truncate(qversion.lastIndexOf('.'));
39 if (qversion.contains('-')) {
40 qversion.truncate(qversion.lastIndexOf('-'));
42 const QString &libPathKey = QString("/qt/%1/libraryPath").arg(qversion);
44 QStringList kdeAdded;
45 KComponentData kcd("krdb libraryPath fix");
46 const QStringList &plugins = KGlobal::dirs()->resourceDirs("qtplugins");
47 foreach (const QString &_path, plugins) {
48 QString path = QDir(_path).canonicalPath();
49 if (path.isEmpty() || kdeAdded.contains(path)) {
50 continue;
52 kdeAdded.prepend(path);
53 if (path.contains("/lib64/")) {
54 path.replace("/lib64/", "/lib/");
55 if (!kdeAdded.contains(path)) {
56 kdeAdded.prepend(path);
60 QStringList libraryPath;
61 foreach (const QString &path, const_cast<const QStringList &>(kdeAdded)) {
62 libraryPath.append(path);
65 // Write the list out..
66 settings.setValue("/qt/KDE/kdeAddedLibraryPaths", kdeAdded);
67 settings.setValue(libPathKey, libraryPath.join(QLatin1String(":")));
69 return 0;