~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to plasma/desktop/shell/configupdates/plasma-to-plasma-desktop.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *   Copyright 2006 Aaron Seigo <aseigo@kde.org>
 
3
 *
 
4
 *   This program is free software; you can redistribute it and/or modify
 
5
 *   it under the terms of the GNU Library General Public License version 2 
 
6
 *   published by the Free Software Foundation
 
7
 *
 
8
 *   This program is distributed in the hope that it will be useful,
 
9
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 *   GNU General Public License for more details
 
12
 *
 
13
 *   You should have received a copy of the GNU Library General Public
 
14
 *   License along with this program; if not, write to the
 
15
 *   Free Software Foundation, Inc.,
 
16
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
17
 */
 
18
 
 
19
#include <QApplication>
 
20
#include <QFile>
 
21
 
 
22
#include <KComponentData>
 
23
#include <KConfig>
 
24
#include <KConfigGroup>
 
25
#include <KDebug>
 
26
#include <KStandardDirs>
 
27
 
 
28
#include <KIO/Job>
 
29
 
 
30
void migrateAppletsrc()
 
31
{
 
32
    QString oldRc = KStandardDirs::locateLocal("config", "plasma-appletsrc");
 
33
 
 
34
    if (oldRc.isEmpty() || !QFile::exists(oldRc)) {
 
35
        //kDebug() << oldRc << "doesn't exist!";
 
36
        return;
 
37
    }
 
38
 
 
39
    QString newRc = KStandardDirs::locateLocal("config", "plasma-desktop-appletsrc");
 
40
 
 
41
    if (QFile::exists(newRc)) {
 
42
        //kDebug() << newRc << "exists!";
 
43
        return;
 
44
    }
 
45
 
 
46
    //kDebug() << "move" << oldRc << "to" << newRc;
 
47
    KIO::FileCopyJob *job = KIO::file_move(oldRc, newRc);
 
48
    job->exec();
 
49
}
 
50
 
 
51
void migratePlasmarc()
 
52
{
 
53
    QString oldRc = KStandardDirs::locateLocal("config", "plasmarc");
 
54
 
 
55
    if (oldRc.isEmpty() || !QFile::exists(oldRc)) {
 
56
        //kDebug() << oldRc << "doesn't exist!";
 
57
        return;
 
58
    }
 
59
 
 
60
    QString newRc = KStandardDirs::locateLocal("config", "plasma-desktoprc");
 
61
 
 
62
    if (QFile::exists(newRc)) {
 
63
        //kDebug() << newRc << "exists!";
 
64
        return;
 
65
    }
 
66
 
 
67
    KIO::FileCopyJob *job = KIO::file_copy(oldRc, newRc);
 
68
    job->exec();
 
69
    //kDebug() << "opening up" << oldRc << "for" << newRc;
 
70
    KConfig newConfig("plasma-desktoprc", KConfig::NoGlobals);
 
71
 
 
72
    foreach (const QString &group, newConfig.groupList()) {
 
73
        //kDebug() << group;
 
74
        if (group.startsWith("Theme") || group == "CachePolicies") {
 
75
            KConfigGroup newGroup(&newConfig, group);
 
76
            newGroup.deleteGroup();
 
77
        }
 
78
    }
 
79
}
 
80
 
 
81
int main(int argc, char *argv[])
 
82
{
 
83
    KComponentData cd("plasma-to-plasma-desktop");
 
84
    QApplication app(argc, argv);
 
85
    migratePlasmarc();
 
86
    migrateAppletsrc();
 
87
 
 
88
    return 0;
 
89
}
 
90