1
/* This file is part of the KDE project
2
Copyright (C) 2008 Matthias Kretz <kretz@kde.org>
3
Copyright (C) 2011 David Faure <faure@kde.org>
5
This library is free software; you can redistribute it and/or
6
modify it under the terms of the GNU Lesser General Public
7
License as published by the Free Software Foundation; either
8
version 2.1 of the License, or (at your option) version 3, or any
9
later version accepted by the membership of KDE e.V. (or its
10
successor approved by the membership of KDE e.V.), Trolltech ASA
11
(or its successors, if any) and the KDE Free Qt Foundation, which shall
12
act as a proxy defined in Section 6 of version 3 of the license.
14
This library is distributed in the hope that it will be useful,
15
but WITHOUT ANY WARRANTY; without even the implied warranty of
16
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
Lesser General Public License for more details.
19
You should have received a copy of the GNU Lesser General Public
20
License along with this library. If not, see <http://www.gnu.org/licenses/>.
24
#include <QtCore/QCoreApplication>
25
#include <QtCore/QDir>
26
#include <QtCore/QSettings>
27
#include <QtCore/QStringList>
28
#include <kcomponentdata.h>
30
#include <kstandarddirs.h>
32
int main(int argc, char **argv)
34
QCoreApplication app(argc, argv);
35
QSettings settings(QLatin1String("Trolltech"));
36
QString qversion = qVersion();
37
if (qversion.count('.') > 1) {
38
qversion.truncate(qversion.lastIndexOf('.'));
40
if (qversion.contains('-')) {
41
qversion.truncate(qversion.lastIndexOf('-'));
43
const QString &libPathKey = QString("/qt/%1/libraryPath").arg(qversion);
46
KComponentData kcd("krdb libraryPath fix");
47
const QStringList &plugins = KGlobal::dirs()->resourceDirs("qtplugins");
48
foreach (const QString &_path, plugins) {
49
QString path = QDir(_path).canonicalPath();
50
if (path.isEmpty() || kdeAdded.contains(path)) {
53
kdeAdded.prepend(path);
54
if (path.contains("/lib64/")) {
55
path.replace("/lib64/", "/lib/");
56
if (!kdeAdded.contains(path)) {
57
kdeAdded.prepend(path);
62
// Don't use toStringList! That's a different storage format
63
QStringList libraryPath = settings.value(libPathKey, QString())
64
.toString().split(QLatin1Char(':'), QString::SkipEmptyParts);
66
// Remove all KDE paths, not needed anymore, done by $QT_PLUGIN_PATH
67
foreach (const QString &path, const_cast<const QStringList &>(kdeAdded)) {
68
libraryPath.removeAll(path);
71
settings.remove("/qt/KDE/kdeAddedLibraryPaths");
72
settings.setValue(libPathKey, libraryPath.join(QLatin1String(":")));