2006-12-17 00:04:44 +01:00
|
|
|
/*
|
2007-08-06 13:20:02 +02:00
|
|
|
* Copyright 2006-2007 Aaron Seigo <aseigo@kde.org>
|
2006-12-17 00:04:44 +01:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
2007-09-14 21:06:18 +02:00
|
|
|
* it under the terms of the GNU Library General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2, or
|
|
|
|
* (at your option) any later version.
|
2006-12-17 00:04:44 +01:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef PLASMA_THEME_H
|
|
|
|
#define PLASMA_THEME_H
|
|
|
|
|
|
|
|
#include <QtCore/QObject>
|
2007-12-19 20:56:39 +01:00
|
|
|
#include <QtGui/QFont>
|
|
|
|
#include <QtGui/QFontMetrics>
|
2006-12-17 00:04:44 +01:00
|
|
|
|
2007-11-06 02:23:15 +01:00
|
|
|
#include <KDE/KSharedConfig>
|
2007-11-04 07:57:42 +01:00
|
|
|
|
2007-06-02 19:29:39 +02:00
|
|
|
#include <plasma/plasma_export.h>
|
2008-02-15 11:35:00 +01:00
|
|
|
#include <plasma/packagestructure.h>
|
2007-01-01 05:31:43 +01:00
|
|
|
|
2006-12-17 00:04:44 +01:00
|
|
|
namespace Plasma
|
|
|
|
{
|
2007-05-22 03:30:03 +02:00
|
|
|
/**
|
|
|
|
* @short Interface to the Plasma theme
|
|
|
|
*
|
2008-04-22 23:10:14 +02:00
|
|
|
* Accessed via Plasma::Theme::defaultTheme() e.g:
|
2007-05-22 03:30:03 +02:00
|
|
|
* \code
|
2008-04-22 23:10:14 +02:00
|
|
|
* QString imagePath = Plasma::Theme::defaultTheme()->imagePath("widgets/clock")
|
2007-05-22 03:30:03 +02:00
|
|
|
* \endcode
|
|
|
|
*
|
2007-05-24 20:14:54 +02:00
|
|
|
* Plasma::Theme provides access to a common and standardized set of graphic
|
|
|
|
* elements stored in SVG format. This allows artists to create single packages
|
|
|
|
* of SVGs that will affect the look and feel of all workspace components.
|
|
|
|
*
|
|
|
|
* Plasma::Svg uses Plasma::Theme internally to locate and load the appropriate
|
|
|
|
* SVG data. Alternatively, Plasma::Theme can be used directly to retrieve
|
|
|
|
* file system paths to SVGs by name.
|
2007-05-22 03:30:03 +02:00
|
|
|
*/
|
2007-05-20 22:13:46 +02:00
|
|
|
class PLASMA_EXPORT Theme : public QObject
|
2006-12-17 00:04:44 +01:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
2007-08-04 14:46:29 +02:00
|
|
|
Q_PROPERTY( QString themeName READ themeName )
|
2006-12-17 00:04:44 +01:00
|
|
|
|
|
|
|
public:
|
2007-03-08 00:27:37 +01:00
|
|
|
/**
|
|
|
|
* Singleton pattern accessor
|
|
|
|
**/
|
2008-04-22 23:10:14 +02:00
|
|
|
static Theme* defaultTheme();
|
2007-03-08 00:27:37 +01:00
|
|
|
|
2007-05-29 09:56:58 +02:00
|
|
|
/**
|
|
|
|
* Default constructor. Usually you want to use the singleton instead.
|
|
|
|
*/
|
2007-03-03 02:41:27 +01:00
|
|
|
explicit Theme( QObject* parent = 0 );
|
2006-12-17 00:04:44 +01:00
|
|
|
~Theme();
|
|
|
|
|
2008-02-15 11:35:00 +01:00
|
|
|
/**
|
|
|
|
* @return a package structure representing a Theme
|
|
|
|
*/
|
2008-02-26 05:08:51 +01:00
|
|
|
static PackageStructure::Ptr packageStructure();
|
2008-02-15 11:35:00 +01:00
|
|
|
|
2007-07-17 22:51:12 +02:00
|
|
|
/**
|
|
|
|
* Sets the application the theme setting is associated with. This
|
|
|
|
* allows for individual applications that use libplasma to have the
|
|
|
|
* theme set independantly.
|
|
|
|
*
|
|
|
|
* @param appname name of the application
|
|
|
|
**/
|
|
|
|
void setApplication(const QString &appname);
|
|
|
|
|
2007-05-22 03:30:03 +02:00
|
|
|
/**
|
2007-11-04 04:04:55 +01:00
|
|
|
* Sets the current theme being used.
|
|
|
|
*/
|
|
|
|
void setThemeName(const QString &themeName);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return the name of the theme.
|
2007-05-22 03:30:03 +02:00
|
|
|
*/
|
2006-12-17 00:04:44 +01:00
|
|
|
QString themeName() const;
|
2007-05-24 20:14:54 +02:00
|
|
|
|
2007-05-22 03:30:03 +02:00
|
|
|
/**
|
2007-05-29 09:56:58 +02:00
|
|
|
* Retrieve the path for an SVG image in the current theme.
|
|
|
|
*
|
|
|
|
* @arg name the name of the file in the theme directory (without the
|
|
|
|
* ".svg" part or a leading slash)
|
2008-04-13 15:23:39 +02:00
|
|
|
* @return the full path to the requested file for the current theme
|
2007-05-22 03:30:03 +02:00
|
|
|
*/
|
2008-04-16 17:53:16 +02:00
|
|
|
Q_INVOKABLE QString imagePath( const QString& name ) const;
|
2006-12-17 00:04:44 +01:00
|
|
|
|
2007-11-04 07:57:42 +01:00
|
|
|
/**
|
|
|
|
* Returns the color scheme configurationthat goes along this theme.
|
|
|
|
* This can be used with KStatefulBrush and KColorScheme to determine
|
|
|
|
* the proper colours to use along with the visual elements in this theme.
|
|
|
|
*/
|
2008-04-16 17:53:16 +02:00
|
|
|
Q_INVOKABLE KSharedConfigPtr colorScheme() const;
|
2007-11-04 07:57:42 +01:00
|
|
|
|
2007-11-27 22:56:47 +01:00
|
|
|
/**
|
|
|
|
* Returns the text color to be used by items resting on the background
|
|
|
|
*/
|
|
|
|
Q_INVOKABLE QColor textColor() const;
|
|
|
|
|
2008-01-08 02:43:13 +01:00
|
|
|
/**
|
|
|
|
* Returns the background color to be used by items resting on the background
|
|
|
|
*/
|
|
|
|
Q_INVOKABLE QColor backgroundColor() const;
|
|
|
|
|
2007-12-21 00:44:08 +01:00
|
|
|
/**
|
|
|
|
* Sets the default font to be used with themed items. Defaults to
|
|
|
|
* the application wide default font.
|
|
|
|
*/
|
|
|
|
Q_INVOKABLE void setFont(const QFont &font);
|
|
|
|
|
2007-12-19 20:56:39 +01:00
|
|
|
/**
|
|
|
|
* Returns the font to be used by themed items
|
|
|
|
*/
|
|
|
|
Q_INVOKABLE QFont font() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the font metrics for the font to be used by themed items
|
|
|
|
*/
|
|
|
|
Q_INVOKABLE QFontMetrics fontMetrics() const;
|
|
|
|
|
2008-03-05 22:03:27 +01:00
|
|
|
/**
|
|
|
|
* Returns if the window compositing is active or not
|
|
|
|
*/
|
|
|
|
Q_INVOKABLE bool compositingActive() const;
|
|
|
|
|
2007-04-22 11:35:04 +02:00
|
|
|
Q_SIGNALS:
|
2007-05-29 09:56:58 +02:00
|
|
|
/**
|
|
|
|
* Emitted when the user changes the theme. SVGs should be reloaded at
|
|
|
|
* that point
|
|
|
|
*/
|
2006-12-17 00:04:44 +01:00
|
|
|
void changed();
|
|
|
|
|
2007-07-17 22:51:12 +02:00
|
|
|
public Q_SLOTS:
|
|
|
|
/**
|
|
|
|
* Notifies the Theme object that the theme settings have changed
|
|
|
|
* and should be read from the config file
|
|
|
|
**/
|
|
|
|
void settingsChanged();
|
|
|
|
|
2008-02-07 11:54:38 +01:00
|
|
|
private Q_SLOTS:
|
|
|
|
void compositingChanged();
|
2008-02-26 06:08:08 +01:00
|
|
|
void colorsChanged();
|
2008-02-07 11:54:38 +01:00
|
|
|
|
2006-12-17 00:04:44 +01:00
|
|
|
private:
|
2008-04-23 06:50:44 +02:00
|
|
|
friend class ThemeSingleton;
|
2006-12-17 00:04:44 +01:00
|
|
|
class Private;
|
2007-05-21 16:28:03 +02:00
|
|
|
Private* const d;
|
2006-12-17 00:04:44 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
} // Plasma namespace
|
|
|
|
|
|
|
|
#endif // multiple inclusion guard
|
|
|
|
|