2010-10-12 21:51:57 +02:00
|
|
|
/***************************************************************************
|
|
|
|
* Copyright 2010 Marco Martin <mart@kde.org> *
|
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* 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 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 THEME_PROXY_P
|
|
|
|
#define THEME_PROXY_P
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
|
2011-04-26 21:46:14 +02:00
|
|
|
#include <KUrl>
|
2011-04-26 15:11:43 +02:00
|
|
|
#include <QFont>
|
2010-10-12 21:51:57 +02:00
|
|
|
#include <QColor>
|
|
|
|
|
2011-10-13 17:54:26 +02:00
|
|
|
#include <Plasma/Theme>
|
|
|
|
|
2012-11-26 11:24:09 +01:00
|
|
|
class QDeclarativePropertyMap;
|
|
|
|
|
2011-10-13 15:19:37 +02:00
|
|
|
class FontProxy : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2011-12-23 16:29:28 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* true if the font is bold
|
|
|
|
*/
|
2011-10-13 15:19:37 +02:00
|
|
|
Q_PROPERTY(bool bold READ bold NOTIFY boldChanged)
|
2011-12-23 16:29:28 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* One of
|
|
|
|
* MixedCase: The text is not changed
|
|
|
|
* AllUppercase: the text becomes UPPERCASE
|
|
|
|
* AllLowercase: the text becomes all lowercase
|
|
|
|
* SmallCaps: the lowercase characters becomes smaller uppercase ones
|
|
|
|
* Capitalize: the first letter of all words are uppercase
|
|
|
|
*/
|
2011-10-13 15:19:37 +02:00
|
|
|
Q_PROPERTY(Capitalization capitalization READ capitalization NOTIFY capitalizationChanged )
|
2011-12-23 16:29:28 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* name of the font family
|
|
|
|
*/
|
2011-10-13 15:19:37 +02:00
|
|
|
Q_PROPERTY(QString family READ family NOTIFY familyChanged )
|
2011-12-23 16:29:28 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* true if the font is italic
|
|
|
|
*/
|
2011-10-13 15:19:37 +02:00
|
|
|
Q_PROPERTY(bool italic READ italic NOTIFY italicChanged )
|
2011-12-23 16:29:28 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* horizontal space between letters
|
|
|
|
*/
|
2011-10-13 15:19:37 +02:00
|
|
|
Q_PROPERTY(qreal letterSpacing READ letterSpacing NOTIFY letterSpacingChanged )
|
2011-12-23 16:29:28 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Size of the font in pixels: settings this is strongly discouraged.
|
|
|
|
* @see pointSize
|
|
|
|
*/
|
2011-10-13 15:19:37 +02:00
|
|
|
Q_PROPERTY(int pixelSize READ pixelSize NOTIFY pixelSizeChanged )
|
2011-12-23 16:29:28 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Size of the font in points
|
|
|
|
*/
|
2011-10-13 15:19:37 +02:00
|
|
|
Q_PROPERTY(qreal pointSize READ pointSize NOTIFY pointSizeChanged )
|
2011-12-23 16:29:28 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* True if the text is striked out with an horizontal line
|
|
|
|
*/
|
2011-10-27 21:24:40 +02:00
|
|
|
Q_PROPERTY(bool strikeout READ strikeout NOTIFY strikeoutChanged )
|
2011-12-23 16:29:28 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* True if all the text will be underlined
|
|
|
|
*/
|
2011-10-13 15:19:37 +02:00
|
|
|
Q_PROPERTY(bool underline READ underline NOTIFY underlineChanged )
|
2011-12-23 16:29:28 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* One of:
|
|
|
|
* Light
|
|
|
|
* Normal
|
|
|
|
* DemiBold
|
|
|
|
* Bold
|
|
|
|
* Black
|
|
|
|
*/
|
2011-10-13 15:19:37 +02:00
|
|
|
Q_PROPERTY(Weight weight READ weight NOTIFY weightChanged )
|
2011-12-23 16:29:28 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Horizontal space between words
|
|
|
|
*/
|
2011-10-13 15:19:37 +02:00
|
|
|
Q_PROPERTY(qreal wordSpacing READ wordSpacing NOTIFY wordSpacingChanged )
|
2011-12-23 16:29:28 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Size in pixels of an uppercase "M" letter
|
|
|
|
*/
|
2011-11-02 21:38:44 +01:00
|
|
|
Q_PROPERTY(QSize mSize READ mSize NOTIFY mSizeChanged )
|
2011-10-13 15:19:37 +02:00
|
|
|
|
|
|
|
Q_ENUMS(Capitalization)
|
|
|
|
Q_ENUMS(Weight)
|
|
|
|
|
|
|
|
public:
|
|
|
|
enum Capitalization {
|
|
|
|
MixedCase = 0,
|
|
|
|
AllUppercase = 1,
|
|
|
|
AllLowercase = 2,
|
|
|
|
SmallCaps = 3,
|
|
|
|
Capitalize = 4
|
|
|
|
};
|
|
|
|
|
|
|
|
enum Weight {
|
|
|
|
Light = 25,
|
|
|
|
Normal = 50,
|
|
|
|
DemiBold = 63,
|
|
|
|
Bold = 75,
|
|
|
|
Black = 87
|
|
|
|
};
|
|
|
|
|
2011-10-13 17:54:26 +02:00
|
|
|
FontProxy(Plasma::Theme::FontRole role, QObject *parent = 0);
|
2011-10-13 15:19:37 +02:00
|
|
|
~FontProxy();
|
2011-10-13 17:54:26 +02:00
|
|
|
static FontProxy *defaultFont();
|
|
|
|
static FontProxy *desktopFont();
|
|
|
|
static FontProxy *smallestFont();
|
2011-10-13 15:19:37 +02:00
|
|
|
|
|
|
|
bool bold() const;
|
|
|
|
Capitalization capitalization() const;
|
|
|
|
QString family() const;
|
|
|
|
bool italic() const;
|
|
|
|
qreal letterSpacing() const;
|
|
|
|
int pixelSize() const;
|
|
|
|
qreal pointSize() const;
|
2011-10-27 21:24:40 +02:00
|
|
|
bool strikeout() const;
|
2011-10-13 15:19:37 +02:00
|
|
|
bool underline() const;
|
|
|
|
Weight weight() const;
|
|
|
|
qreal wordSpacing() const;
|
|
|
|
|
2011-11-02 21:38:44 +01:00
|
|
|
/**
|
|
|
|
* @return The size of an uppercase M in this font
|
|
|
|
*/
|
|
|
|
QSize mSize() const;
|
|
|
|
|
2011-10-13 15:19:37 +02:00
|
|
|
Q_SIGNALS:
|
|
|
|
void boldChanged();
|
|
|
|
void capitalizationChanged();
|
|
|
|
void familyChanged();
|
|
|
|
void italicChanged();
|
|
|
|
void letterSpacingChanged();
|
|
|
|
void pixelSizeChanged();
|
|
|
|
void pointSizeChanged();
|
2011-10-27 21:24:40 +02:00
|
|
|
void strikeoutChanged();
|
2011-10-13 15:19:37 +02:00
|
|
|
void underlineChanged();
|
|
|
|
void weightChanged();
|
|
|
|
void wordSpacingChanged();
|
2011-11-02 21:38:44 +01:00
|
|
|
void mSizeChanged();
|
2011-10-13 17:54:26 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
Plasma::Theme::FontRole m_fontRole;
|
2011-10-13 15:19:37 +02:00
|
|
|
};
|
|
|
|
|
2012-12-14 16:14:31 +01:00
|
|
|
/**
|
|
|
|
* QML wrapper for kdelibs Plasma::Theme
|
|
|
|
*
|
|
|
|
* Exposed as `Theme` in QML.
|
|
|
|
*/
|
2010-10-12 21:51:57 +02:00
|
|
|
class ThemeProxy : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
2011-04-26 21:46:14 +02:00
|
|
|
Q_PROPERTY(QString themeName READ themeName NOTIFY themeChanged)
|
|
|
|
Q_PROPERTY(bool windowTranslucentEnabled READ windowTranslucencyEnabled NOTIFY themeChanged)
|
|
|
|
Q_PROPERTY(KUrl homepage READ homepage NOTIFY themeChanged)
|
|
|
|
Q_PROPERTY(bool useGlobalSettings READ useGlobalSettings NOTIFY themeChanged)
|
|
|
|
Q_PROPERTY(QString wallpaperPath READ wallpaperPath NOTIFY themeChanged)
|
2011-04-26 15:11:43 +02:00
|
|
|
|
2011-10-13 15:19:37 +02:00
|
|
|
//fonts
|
2011-10-13 17:54:26 +02:00
|
|
|
Q_PROPERTY(QObject *defaultFont READ defaultFont CONSTANT)
|
|
|
|
Q_PROPERTY(QObject *desktopFont READ desktopFont CONSTANT)
|
|
|
|
Q_PROPERTY(QObject *smallestFont READ smallestFont CONSTANT)
|
2011-10-13 15:19:37 +02:00
|
|
|
|
2011-04-26 15:11:43 +02:00
|
|
|
// colors
|
2010-10-12 21:51:57 +02:00
|
|
|
Q_PROPERTY(QColor textColor READ textColor NOTIFY themeChanged)
|
|
|
|
Q_PROPERTY(QColor highlightColor READ highlightColor NOTIFY themeChanged)
|
|
|
|
Q_PROPERTY(QColor backgroundColor READ backgroundColor NOTIFY themeChanged)
|
|
|
|
Q_PROPERTY(QColor buttonTextColor READ buttonTextColor NOTIFY themeChanged)
|
|
|
|
Q_PROPERTY(QColor buttonBackgroundColor READ buttonBackgroundColor NOTIFY themeChanged)
|
|
|
|
Q_PROPERTY(QColor linkColor READ linkColor NOTIFY themeChanged)
|
|
|
|
Q_PROPERTY(QColor visitedLinkColor READ visitedLinkColor NOTIFY themeChanged)
|
2010-12-01 23:43:52 +01:00
|
|
|
Q_PROPERTY(QColor visitedLinkColor READ visitedLinkColor NOTIFY themeChanged)
|
|
|
|
Q_PROPERTY(QColor buttonHoverColor READ buttonHoverColor NOTIFY themeChanged)
|
|
|
|
Q_PROPERTY(QColor buttonFocusColor READ buttonFocusColor NOTIFY themeChanged)
|
|
|
|
Q_PROPERTY(QColor viewTextColor READ viewTextColor NOTIFY themeChanged)
|
|
|
|
Q_PROPERTY(QColor viewBackgroundColor READ viewBackgroundColor NOTIFY themeChanged)
|
|
|
|
Q_PROPERTY(QColor viewHoverColor READ viewHoverColor NOTIFY themeChanged)
|
|
|
|
Q_PROPERTY(QColor viewFocusColor READ viewFocusColor NOTIFY themeChanged)
|
2011-04-24 04:04:01 +02:00
|
|
|
Q_PROPERTY(QString styleSheet READ styleSheet NOTIFY themeChanged)
|
2010-10-12 21:51:57 +02:00
|
|
|
|
2011-10-30 19:07:58 +01:00
|
|
|
// icon sizes
|
|
|
|
Q_PROPERTY(int smallIconSize READ smallIconSize CONSTANT)
|
|
|
|
Q_PROPERTY(int smallMediumIconSize READ smallMediumIconSize CONSTANT)
|
|
|
|
Q_PROPERTY(int mediumIconSize READ mediumIconSize CONSTANT)
|
|
|
|
Q_PROPERTY(int largeIconSize READ largeIconSize CONSTANT)
|
|
|
|
Q_PROPERTY(int hugeIconSize READ hugeIconSize CONSTANT)
|
|
|
|
Q_PROPERTY(int enormousIconSize READ enormousIconSize CONSTANT)
|
2012-02-20 15:09:26 +01:00
|
|
|
Q_PROPERTY(int defaultIconSize READ defaultIconSize NOTIFY defaultIconSizeChanged)
|
2011-10-30 19:07:58 +01:00
|
|
|
|
2012-11-26 11:24:09 +01:00
|
|
|
/**
|
|
|
|
* icon sizes depending from the context: use those if possible
|
|
|
|
* Access with theme.iconSizes.desktop theme.iconSizes.small etc.
|
|
|
|
* available keys are:
|
|
|
|
* * desktop
|
|
|
|
* * toolbar
|
|
|
|
* * small
|
|
|
|
* * dialog
|
|
|
|
*/
|
|
|
|
Q_PROPERTY(QDeclarativePropertyMap *iconSizes READ iconSizes NOTIFY iconSizesChanged)
|
|
|
|
|
2010-10-12 21:51:57 +02:00
|
|
|
public:
|
|
|
|
ThemeProxy(QObject *parent = 0);
|
|
|
|
~ThemeProxy();
|
|
|
|
|
2011-04-26 21:46:14 +02:00
|
|
|
QString themeName() const;
|
2011-10-13 17:54:26 +02:00
|
|
|
QObject *defaultFont() const;
|
|
|
|
QObject *desktopFont() const;
|
|
|
|
QObject *smallestFont() const;
|
2011-04-26 15:11:43 +02:00
|
|
|
bool windowTranslucencyEnabled() const;
|
2011-04-26 21:46:14 +02:00
|
|
|
KUrl homepage() const;
|
|
|
|
bool useGlobalSettings() const;
|
|
|
|
QString wallpaperPath() const;
|
2011-10-09 16:12:00 +02:00
|
|
|
Q_INVOKABLE QString wallpaperPathForSize(int width=-1, int height=-1) const;
|
2011-04-26 15:11:43 +02:00
|
|
|
|
2010-10-12 21:51:57 +02:00
|
|
|
QColor textColor() const;
|
|
|
|
QColor highlightColor() const;
|
|
|
|
QColor backgroundColor() const;
|
|
|
|
QColor buttonTextColor() const;
|
|
|
|
QColor buttonBackgroundColor() const;
|
|
|
|
QColor linkColor() const;
|
|
|
|
QColor visitedLinkColor() const;
|
2010-12-01 23:43:52 +01:00
|
|
|
QColor buttonHoverColor() const;
|
|
|
|
QColor buttonFocusColor() const;
|
|
|
|
QColor viewTextColor() const;
|
|
|
|
QColor viewBackgroundColor() const;
|
|
|
|
QColor viewHoverColor() const;
|
|
|
|
QColor viewFocusColor() const;
|
2011-04-24 04:04:01 +02:00
|
|
|
QString styleSheet() const;
|
2010-10-12 21:51:57 +02:00
|
|
|
|
2011-10-30 19:07:58 +01:00
|
|
|
int smallIconSize() const;
|
|
|
|
int smallMediumIconSize() const;
|
|
|
|
int mediumIconSize() const;
|
|
|
|
int largeIconSize() const;
|
|
|
|
int hugeIconSize() const;
|
|
|
|
int enormousIconSize() const;
|
2012-02-20 15:09:26 +01:00
|
|
|
int defaultIconSize() const;
|
2012-11-26 11:24:09 +01:00
|
|
|
QDeclarativePropertyMap *iconSizes() const;
|
2012-02-20 15:09:26 +01:00
|
|
|
|
|
|
|
private Q_SLOTS:
|
|
|
|
void iconLoaderSettingsChanged();
|
2011-10-30 19:07:58 +01:00
|
|
|
|
2010-10-12 21:51:57 +02:00
|
|
|
Q_SIGNALS:
|
|
|
|
void themeChanged();
|
2012-02-20 15:09:26 +01:00
|
|
|
void defaultIconSizeChanged();
|
2012-11-26 11:24:09 +01:00
|
|
|
void iconSizesChanged();
|
2012-02-20 15:09:26 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
int m_defaultIconSize;
|
2012-11-26 11:24:09 +01:00
|
|
|
QDeclarativePropertyMap *m_iconSizes;
|
2010-10-12 21:51:57 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|