2006-12-17 00:04:44 +01:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2006 Aaron Seigo <aseigo@kde.org>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Library General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this program; if not, write to the
|
|
|
|
* Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
2007-05-21 16:28:03 +02:00
|
|
|
#include "theme.h"
|
|
|
|
|
2006-12-17 00:04:44 +01:00
|
|
|
#include <KSharedConfig>
|
|
|
|
#include <KStandardDirs>
|
2007-01-29 18:14:20 +01:00
|
|
|
#include <kconfiggroup.h>
|
2006-12-17 00:04:44 +01:00
|
|
|
|
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
|
|
|
|
class Theme::Private
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Private()
|
2007-03-03 02:41:27 +01:00
|
|
|
: themeName( "default" )
|
2006-12-17 00:04:44 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-03-08 00:27:37 +01:00
|
|
|
QString themeName;
|
2006-12-17 00:04:44 +01:00
|
|
|
};
|
|
|
|
|
2007-03-08 00:27:37 +01:00
|
|
|
class ThemeSingleton
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Theme self;
|
|
|
|
};
|
|
|
|
|
|
|
|
K_GLOBAL_STATIC( ThemeSingleton, privateSelf )
|
|
|
|
|
|
|
|
Theme* Theme::self()
|
|
|
|
{
|
|
|
|
return &privateSelf->self;
|
|
|
|
}
|
|
|
|
|
2006-12-17 00:04:44 +01:00
|
|
|
Theme::Theme(QObject* parent)
|
|
|
|
: QObject(parent),
|
|
|
|
d(new Private)
|
|
|
|
{
|
2007-03-03 02:41:27 +01:00
|
|
|
KConfig config( "plasmarc" );
|
|
|
|
KConfigGroup group( &config, "Theme" );
|
|
|
|
d->themeName = group.readEntry( "name", d->themeName );
|
2006-12-17 00:04:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Theme::~Theme()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
QString Theme::themeName() const
|
|
|
|
{
|
|
|
|
return d->themeName;
|
|
|
|
}
|
|
|
|
|
2007-03-05 01:07:21 +01:00
|
|
|
QString Theme::image( const QString& name ) const
|
2006-12-17 00:04:44 +01:00
|
|
|
{
|
2007-05-13 19:47:20 +02:00
|
|
|
QString search = "desktoptheme/" + d->themeName + '/' + name + ".svg";
|
2007-03-08 00:27:37 +01:00
|
|
|
QString path = KStandardDirs::locate( "data", search );
|
|
|
|
|
|
|
|
if ( path.isEmpty() ) {
|
|
|
|
kDebug() << "Theme says: bad image path " << name
|
|
|
|
<< "; looked in: " << search
|
|
|
|
<< endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
return path;
|
2006-12-17 00:04:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#include <theme.moc>
|