3
* Copyright (C) 2002 Karol Szwed <gallium@kde.org>
4
* Copyright (C) 2002 Daniel Molkentin <molkentin@kde.org>
5
* Copyright (C) 2007 Urs Wolfer <uwolfer @ kde.org>
6
* Copyright (C) 2009 by Davide Bettio <davide.bettio@kdemail.net>
8
* Portions Copyright (C) 2007 Paolo Capriotti <p.capriotti@gmail.com>
9
* Portions Copyright (C) 2007 Ivan Cukic <ivan.cukic+kde@gmail.com>
10
* Portions Copyright (C) 2008 by Petri Damsten <damu@iki.fi>
11
* Portions Copyright (C) 2000 TrollTech AS.
13
* This program is free software; you can redistribute it and/or
14
* modify it under the terms of the GNU General Public
15
* License version 2 as published by the Free Software Foundation.
17
* This program is distributed in the hope that it will be useful,
18
* but WITHOUT ANY WARRANTY; without even the implied warranty of
19
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20
* General Public License for more details.
22
* You should have received a copy of the GNU General Public License
23
* along with this program; see the file COPYING. If not, write to
24
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
25
* Boston, MA 02110-1301, USA.
28
#include "kcmdesktoptheme.h"
30
#include "thememodel.h"
33
#include <kaboutdata.h>
34
#include <kautostart.h>
35
#include <KStandardDirs>
36
#include <knewstuff3/downloaddialog.h>
38
#include <Plasma/Theme>
40
/**** DLL Interface for kcontrol ****/
42
#include <kpluginfactory.h>
43
#include <kpluginloader.h>
45
K_PLUGIN_FACTORY(KCMDesktopThemeFactory, registerPlugin<KCMDesktopTheme>();)
46
K_EXPORT_PLUGIN(KCMDesktopThemeFactory("kcmdesktoptheme","kcm_desktopthemedetails"))
49
KCMDesktopTheme::KCMDesktopTheme( QWidget* parent, const QVariantList& )
50
: KCModule( KCMDesktopThemeFactory::componentData(), parent )
52
setQuickHelp( i18n("<h1>Desktop Theme</h1>"
53
"This module allows you to modify the visual appearance "
58
m_bDesktopThemeDirty = false;
59
m_bDetailsDirty = false;
61
KAutostart plasmaNetbookAutoStart("plasma-netbook");
62
m_isNetbook = plasmaNetbookAutoStart.autostarts();
64
KGlobal::dirs()->addResourceType("themes", "data", "kstyle/themes");
67
new KAboutData( I18N_NOOP("KCMDesktopTheme"), 0,
68
ki18n("KDE Desktop Theme Module"),
69
0, KLocalizedString(), KAboutData::License_GPL,
70
ki18n("(c) 2002 Karol Szwed, Daniel Molkentin"));
72
about->addAuthor(ki18n("Karol Szwed"), KLocalizedString(), "gallium@kde.org");
73
about->addAuthor(ki18n("Daniel Molkentin"), KLocalizedString(), "molkentin@kde.org");
74
about->addAuthor(ki18n("Ralf Nolden"), KLocalizedString(), "nolden@kde.org");
75
setAboutData( about );
77
m_newThemeButton->setIcon(KIcon("get-hot-new-stuff"));
79
m_themeModel = new ThemeModel(this);
80
m_theme->setModel(m_themeModel);
81
m_theme->setItemDelegate(new ThemeDelegate(m_theme));
82
m_theme->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
84
connect(m_detailsWidget, SIGNAL(changed()), this, SLOT(detailChanged()));
86
connect(m_theme->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)),
87
this, SLOT(setDesktopThemeDirty()));
88
connect(m_newThemeButton, SIGNAL(clicked()), this, SLOT(getNewThemes()));
92
KCMDesktopTheme::~KCMDesktopTheme()
96
void KCMDesktopTheme::load()
98
KConfig config( "kdeglobals", KConfig::FullConfig );
102
m_bDesktopThemeDirty = false;
103
m_bDetailsDirty = false;
105
emit changed( false );
109
void KCMDesktopTheme::save()
111
// Don't do anything if we don't need to.
112
if ( !( m_bDesktopThemeDirty) && !(m_bDetailsDirty) )
116
if ( m_bDesktopThemeDirty )
118
QString theme = m_themeModel->data(m_theme->currentIndex(), ThemeModel::PackageNameRole).toString();
120
KConfigGroup cg(KSharedConfig::openConfig("plasmarc"), "Theme-plasma-netbook");
121
cg.writeEntry("name", theme);
123
Plasma::Theme::defaultTheme()->setThemeName(theme);
129
m_detailsWidget->save();
133
m_bDesktopThemeDirty = false;
134
m_bDetailsDirty = false;
135
emit changed( false );
138
void KCMDesktopTheme::defaults()
140
// TODO: reset back to default theme?
143
void KCMDesktopTheme::setDesktopThemeDirty()
145
m_bDesktopThemeDirty = true;
149
void KCMDesktopTheme::getNewThemes()
151
KNS3::DownloadDialog dialog("plasma-themes.knsrc", this);
153
KNS3::Entry::List entries = dialog.changedEntries();
155
if (entries.size() > 0) {
160
void KCMDesktopTheme::loadDesktopTheme()
162
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
163
m_themeModel->reload();
166
KConfigGroup cg(KSharedConfig::openConfig("plasmarc"), "Theme-plasma-netbook");
167
themeName = cg.readEntry("name", "air-netbook");
169
themeName = Plasma::Theme::defaultTheme()->themeName();
171
m_theme->setCurrentIndex(m_themeModel->indexOf(themeName));
172
QApplication::restoreOverrideCursor();
175
void KCMDesktopTheme::detailChanged()
177
m_bDetailsDirty = true;
181
#include "kcmdesktoptheme.moc"
183
// vim: set noet ts=4: