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 . *
|
|
|
|
***************************************************************************/
|
|
|
|
|
2011-11-01 19:27:55 +01:00
|
|
|
#include "theme.h"
|
2010-10-12 21:51:57 +02:00
|
|
|
|
2011-10-30 19:07:58 +01:00
|
|
|
#include <KIconLoader>
|
|
|
|
|
2011-10-13 15:19:37 +02:00
|
|
|
class FontProxySingleton
|
|
|
|
{
|
|
|
|
public:
|
2011-10-13 17:54:26 +02:00
|
|
|
FontProxySingleton()
|
|
|
|
: defaultFont(Plasma::Theme::DefaultFont),
|
|
|
|
desktopFont(Plasma::Theme::DesktopFont),
|
|
|
|
smallestFont(Plasma::Theme::SmallestFont)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
FontProxy defaultFont;
|
|
|
|
FontProxy desktopFont;
|
|
|
|
FontProxy smallestFont;
|
2011-10-13 15:19:37 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
K_GLOBAL_STATIC(FontProxySingleton, privateFontProxySingleton)
|
|
|
|
|
2011-10-13 17:54:26 +02:00
|
|
|
FontProxy::FontProxy(Plasma::Theme::FontRole role, QObject *parent)
|
|
|
|
: QObject(parent),
|
|
|
|
m_fontRole(role)
|
2011-10-13 15:19:37 +02:00
|
|
|
{
|
|
|
|
connect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()),
|
2011-10-27 21:24:40 +02:00
|
|
|
this, SIGNAL(boldChanged()));
|
2011-10-13 15:19:37 +02:00
|
|
|
connect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()),
|
2011-10-27 21:24:40 +02:00
|
|
|
this, SIGNAL(capitalizationChanged()));
|
2011-10-13 15:19:37 +02:00
|
|
|
connect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()),
|
2011-10-27 21:24:40 +02:00
|
|
|
this, SIGNAL(familyChanged()));
|
2011-10-13 15:19:37 +02:00
|
|
|
connect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()),
|
2011-10-27 21:24:40 +02:00
|
|
|
this, SIGNAL(italicChanged()));
|
2011-10-13 15:19:37 +02:00
|
|
|
connect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()),
|
2011-10-27 21:24:40 +02:00
|
|
|
this, SIGNAL(letterSpacingChanged()));
|
2011-10-13 15:19:37 +02:00
|
|
|
connect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()),
|
2011-10-27 21:24:40 +02:00
|
|
|
this, SIGNAL(pixelSizeChanged()));
|
2011-10-13 15:19:37 +02:00
|
|
|
connect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()),
|
2011-10-27 21:24:40 +02:00
|
|
|
this, SIGNAL(pointSizeChanged()));
|
2011-10-13 15:19:37 +02:00
|
|
|
connect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()),
|
2011-10-27 21:24:40 +02:00
|
|
|
this, SIGNAL(strikeoutChanged()));
|
2011-10-13 15:19:37 +02:00
|
|
|
connect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()),
|
2011-10-27 21:24:40 +02:00
|
|
|
this, SIGNAL(underlineChanged()));
|
2011-10-13 15:19:37 +02:00
|
|
|
connect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()),
|
2011-10-27 21:24:40 +02:00
|
|
|
this, SIGNAL(weightChanged()));
|
2011-10-13 15:19:37 +02:00
|
|
|
connect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()),
|
2011-10-27 21:24:40 +02:00
|
|
|
this, SIGNAL(wordSpacingChanged()));
|
2011-11-02 21:38:44 +01:00
|
|
|
connect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()),
|
|
|
|
this, SIGNAL(mSizeChanged()));
|
2011-10-13 15:19:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
FontProxy::~FontProxy()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-10-13 17:54:26 +02:00
|
|
|
FontProxy *FontProxy::defaultFont()
|
|
|
|
{
|
|
|
|
return &privateFontProxySingleton->defaultFont;
|
|
|
|
}
|
|
|
|
|
|
|
|
FontProxy *FontProxy::desktopFont()
|
|
|
|
{
|
|
|
|
return &privateFontProxySingleton->desktopFont;
|
|
|
|
}
|
|
|
|
|
|
|
|
FontProxy *FontProxy::smallestFont()
|
2011-10-13 15:19:37 +02:00
|
|
|
{
|
2011-10-13 17:54:26 +02:00
|
|
|
return &privateFontProxySingleton->smallestFont;
|
2011-10-13 15:19:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool FontProxy::bold() const
|
|
|
|
{
|
2011-10-13 17:54:26 +02:00
|
|
|
return Plasma::Theme::defaultTheme()->font(m_fontRole).bold();
|
2011-10-13 15:19:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
FontProxy::Capitalization FontProxy::capitalization() const
|
|
|
|
{
|
2011-10-13 17:54:26 +02:00
|
|
|
return (FontProxy::Capitalization)Plasma::Theme::defaultTheme()->font(m_fontRole).capitalization();
|
2011-10-13 15:19:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
QString FontProxy::family() const
|
|
|
|
{
|
2011-10-13 17:54:26 +02:00
|
|
|
return Plasma::Theme::defaultTheme()->font(m_fontRole).family();
|
2011-10-13 15:19:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool FontProxy::italic() const
|
|
|
|
{
|
2011-10-13 17:54:26 +02:00
|
|
|
return Plasma::Theme::defaultTheme()->font(m_fontRole).italic();
|
2011-10-13 15:19:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
qreal FontProxy::letterSpacing() const
|
|
|
|
{
|
2011-10-13 17:54:26 +02:00
|
|
|
return Plasma::Theme::defaultTheme()->font(m_fontRole).letterSpacing();
|
2011-10-13 15:19:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int FontProxy::pixelSize() const
|
|
|
|
{
|
2011-10-13 17:54:26 +02:00
|
|
|
return Plasma::Theme::defaultTheme()->font(m_fontRole).pixelSize();
|
2011-10-13 15:19:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
qreal FontProxy::pointSize() const
|
|
|
|
{
|
2011-10-13 17:54:26 +02:00
|
|
|
return Plasma::Theme::defaultTheme()->font(m_fontRole).pointSize();
|
2011-10-13 15:19:37 +02:00
|
|
|
}
|
|
|
|
|
2011-10-27 21:24:40 +02:00
|
|
|
bool FontProxy::strikeout() const
|
2011-10-13 15:19:37 +02:00
|
|
|
{
|
2011-10-13 17:54:26 +02:00
|
|
|
return Plasma::Theme::defaultTheme()->font(m_fontRole).strikeOut();
|
2011-10-13 15:19:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool FontProxy::underline() const
|
|
|
|
{
|
2011-10-13 17:54:26 +02:00
|
|
|
return Plasma::Theme::defaultTheme()->font(m_fontRole).underline();
|
2011-10-13 15:19:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
FontProxy::Weight FontProxy::weight() const
|
|
|
|
{
|
2011-10-13 17:54:26 +02:00
|
|
|
return (FontProxy::Weight)Plasma::Theme::defaultTheme()->font(m_fontRole).weight();
|
2011-10-13 15:19:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
qreal FontProxy::wordSpacing() const
|
|
|
|
{
|
2011-10-13 17:54:26 +02:00
|
|
|
return Plasma::Theme::defaultTheme()->font(m_fontRole).wordSpacing();
|
2011-10-13 15:19:37 +02:00
|
|
|
}
|
|
|
|
|
2011-11-02 21:38:44 +01:00
|
|
|
QSize FontProxy::mSize() const
|
|
|
|
{
|
|
|
|
return QFontMetrics(Plasma::Theme::defaultTheme()->font(m_fontRole)).boundingRect("M").size();
|
|
|
|
}
|
2011-10-13 15:19:37 +02:00
|
|
|
|
|
|
|
|
|
|
|
//********** Theme *************
|
|
|
|
|
2010-10-12 21:51:57 +02:00
|
|
|
ThemeProxy::ThemeProxy(QObject *parent)
|
|
|
|
: QObject(parent)
|
|
|
|
{
|
|
|
|
connect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()), this, SIGNAL(themeChanged()));
|
|
|
|
}
|
|
|
|
|
|
|
|
ThemeProxy::~ThemeProxy()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-04-26 21:46:14 +02:00
|
|
|
QString ThemeProxy::themeName() const
|
2011-04-26 15:11:43 +02:00
|
|
|
{
|
|
|
|
return Plasma::Theme::defaultTheme()->themeName();
|
|
|
|
}
|
|
|
|
|
2011-10-13 17:54:26 +02:00
|
|
|
QObject *ThemeProxy::defaultFont() const
|
|
|
|
{
|
|
|
|
return FontProxy::defaultFont();
|
|
|
|
}
|
|
|
|
|
|
|
|
QObject *ThemeProxy::desktopFont() const
|
|
|
|
{
|
|
|
|
return FontProxy::desktopFont();
|
|
|
|
}
|
|
|
|
|
|
|
|
QObject *ThemeProxy::smallestFont() const
|
2011-04-26 15:11:43 +02:00
|
|
|
{
|
2011-10-13 17:54:26 +02:00
|
|
|
return FontProxy::smallestFont();
|
2011-04-26 15:11:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ThemeProxy::windowTranslucencyEnabled() const
|
|
|
|
{
|
|
|
|
return Plasma::Theme::defaultTheme()->windowTranslucencyEnabled();
|
|
|
|
}
|
|
|
|
|
2011-04-26 21:46:14 +02:00
|
|
|
KUrl ThemeProxy::homepage() const
|
2011-04-26 15:11:43 +02:00
|
|
|
{
|
|
|
|
return Plasma::Theme::defaultTheme()->homepage();
|
|
|
|
}
|
|
|
|
|
2011-04-26 21:46:14 +02:00
|
|
|
bool ThemeProxy::useGlobalSettings() const
|
|
|
|
{
|
|
|
|
return Plasma::Theme::defaultTheme()->useGlobalSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
QString ThemeProxy::wallpaperPath() const
|
|
|
|
{
|
|
|
|
return Plasma::Theme::defaultTheme()->wallpaperPath();
|
|
|
|
}
|
|
|
|
|
2011-10-09 16:12:00 +02:00
|
|
|
QString ThemeProxy::wallpaperPathForSize(int width, int height) const
|
|
|
|
{
|
|
|
|
return Plasma::Theme::defaultTheme()->wallpaperPath(QSize(width, height));
|
|
|
|
}
|
|
|
|
|
2010-10-12 21:51:57 +02:00
|
|
|
QColor ThemeProxy::textColor() const
|
|
|
|
{
|
|
|
|
return Plasma::Theme::defaultTheme()->color(Plasma::Theme::TextColor);
|
|
|
|
}
|
|
|
|
|
|
|
|
QColor ThemeProxy::highlightColor() const
|
|
|
|
{
|
|
|
|
return Plasma::Theme::defaultTheme()->color(Plasma::Theme::HighlightColor);
|
|
|
|
}
|
|
|
|
|
|
|
|
QColor ThemeProxy::backgroundColor() const
|
|
|
|
{
|
|
|
|
return Plasma::Theme::defaultTheme()->color(Plasma::Theme::BackgroundColor);
|
|
|
|
}
|
|
|
|
|
|
|
|
QColor ThemeProxy::buttonTextColor() const
|
|
|
|
{
|
|
|
|
return Plasma::Theme::defaultTheme()->color(Plasma::Theme::ButtonTextColor);
|
|
|
|
}
|
|
|
|
|
|
|
|
QColor ThemeProxy::buttonBackgroundColor() const
|
|
|
|
{
|
|
|
|
return Plasma::Theme::defaultTheme()->color(Plasma::Theme::ButtonBackgroundColor);
|
|
|
|
}
|
|
|
|
|
|
|
|
QColor ThemeProxy::linkColor() const
|
|
|
|
{
|
|
|
|
return Plasma::Theme::defaultTheme()->color(Plasma::Theme::LinkColor);
|
|
|
|
}
|
|
|
|
|
|
|
|
QColor ThemeProxy::visitedLinkColor() const
|
|
|
|
{
|
|
|
|
return Plasma::Theme::defaultTheme()->color(Plasma::Theme::VisitedLinkColor);
|
|
|
|
}
|
|
|
|
|
2010-12-01 23:43:52 +01:00
|
|
|
QColor ThemeProxy::buttonHoverColor() const
|
|
|
|
{
|
|
|
|
return Plasma::Theme::defaultTheme()->color(Plasma::Theme::ButtonHoverColor);
|
|
|
|
}
|
|
|
|
|
|
|
|
QColor ThemeProxy::buttonFocusColor() const
|
|
|
|
{
|
|
|
|
return Plasma::Theme::defaultTheme()->color(Plasma::Theme::ButtonFocusColor);
|
|
|
|
}
|
|
|
|
|
|
|
|
QColor ThemeProxy::viewTextColor() const
|
|
|
|
{
|
|
|
|
return Plasma::Theme::defaultTheme()->color(Plasma::Theme::ViewTextColor);
|
|
|
|
}
|
|
|
|
|
|
|
|
QColor ThemeProxy::viewBackgroundColor() const
|
|
|
|
{
|
|
|
|
return Plasma::Theme::defaultTheme()->color(Plasma::Theme::ViewBackgroundColor);
|
|
|
|
}
|
|
|
|
|
|
|
|
QColor ThemeProxy::viewHoverColor() const
|
|
|
|
{
|
|
|
|
return Plasma::Theme::defaultTheme()->color(Plasma::Theme::ViewHoverColor);
|
|
|
|
}
|
|
|
|
|
|
|
|
QColor ThemeProxy::viewFocusColor() const
|
|
|
|
{
|
|
|
|
return Plasma::Theme::defaultTheme()->color(Plasma::Theme::ViewFocusColor);
|
|
|
|
}
|
|
|
|
|
2011-04-24 04:04:01 +02:00
|
|
|
QString ThemeProxy::styleSheet() const
|
|
|
|
{
|
|
|
|
return Plasma::Theme::defaultTheme()->styleSheet(QString());
|
|
|
|
}
|
|
|
|
|
2011-10-30 19:07:58 +01:00
|
|
|
int ThemeProxy::smallIconSize() const
|
|
|
|
{
|
|
|
|
return KIconLoader::SizeSmall;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ThemeProxy::smallMediumIconSize() const
|
|
|
|
{
|
|
|
|
return KIconLoader::SizeSmallMedium;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ThemeProxy::mediumIconSize() const
|
|
|
|
{
|
|
|
|
return KIconLoader::SizeMedium;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ThemeProxy::largeIconSize() const
|
|
|
|
{
|
|
|
|
return KIconLoader::SizeLarge;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ThemeProxy::hugeIconSize() const
|
|
|
|
{
|
|
|
|
return KIconLoader::SizeHuge;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ThemeProxy::enormousIconSize() const
|
|
|
|
{
|
|
|
|
return KIconLoader::SizeEnormous;
|
|
|
|
}
|
2010-12-01 23:43:52 +01:00
|
|
|
|
2011-11-01 19:27:55 +01:00
|
|
|
#include "theme.moc"
|
2010-10-12 21:51:57 +02:00
|
|
|
|