Move Fusion styles palette into QtGui
So that it can be used as the standard palette for QtGui applications instead of the absolutely useless black palette. Change-Id: Ie001439fcd8840a66275009c9f42cbf8bab4864a Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
This commit is contained in:
parent
d42e54c862
commit
3ae271523f
@ -21,6 +21,7 @@ HEADERS += \
|
||||
kernel/qplatformintegrationfactory_p.h \
|
||||
kernel/qplatformintegrationplugin.h \
|
||||
kernel/qplatformtheme.h\
|
||||
kernel/qplatformtheme_p.h \
|
||||
kernel/qplatformthemefactory_p.h \
|
||||
kernel/qplatformthemeplugin.h \
|
||||
kernel/qplatformwindow.h \
|
||||
|
@ -180,7 +180,7 @@ static void initPalette()
|
||||
if (const QPalette *themePalette = QGuiApplicationPrivate::platformTheme()->palette())
|
||||
QGuiApplicationPrivate::app_pal = new QPalette(*themePalette);
|
||||
if (!QGuiApplicationPrivate::app_pal)
|
||||
QGuiApplicationPrivate::app_pal = new QPalette(Qt::black);
|
||||
QGuiApplicationPrivate::app_pal = new QPalette(Qt::gray);
|
||||
}
|
||||
|
||||
static inline void clearPalette()
|
||||
@ -1014,6 +1014,7 @@ void QGuiApplicationPrivate::init()
|
||||
// and QImage conversion functions
|
||||
qInitImageConversions();
|
||||
|
||||
initPalette();
|
||||
QFont::initialize();
|
||||
|
||||
#ifndef QT_NO_CURSOR
|
||||
|
@ -1096,6 +1096,40 @@ void QPalette::setColorGroup(ColorGroup cg, const QBrush &foreground, const QBru
|
||||
setBrush(cg, ToolTipText, toolTipText);
|
||||
}
|
||||
|
||||
Q_GUI_EXPORT QPalette qt_fusionPalette()
|
||||
{
|
||||
QColor backGround(239, 235, 231);
|
||||
QColor light = backGround.lighter(150);
|
||||
QColor mid(backGround.darker(130));
|
||||
QColor midLight = mid.lighter(110);
|
||||
QColor base = Qt::white;
|
||||
QColor disabledBase(backGround);
|
||||
QColor dark = backGround.darker(150);
|
||||
QColor darkDisabled = QColor(209, 200, 191).darker(110);
|
||||
QColor text = Qt::black;
|
||||
QColor hightlightedText = Qt::white;
|
||||
QColor disabledText = QColor(190, 190, 190);
|
||||
QColor button = backGround;
|
||||
QColor shadow = dark.darker(135);
|
||||
QColor disabledShadow = shadow.lighter(150);
|
||||
|
||||
QPalette fusionPalette(Qt::black,backGround,light,dark,mid,text,base);
|
||||
fusionPalette.setBrush(QPalette::Midlight, midLight);
|
||||
fusionPalette.setBrush(QPalette::Button, button);
|
||||
fusionPalette.setBrush(QPalette::Shadow, shadow);
|
||||
fusionPalette.setBrush(QPalette::HighlightedText, hightlightedText);
|
||||
|
||||
fusionPalette.setBrush(QPalette::Disabled, QPalette::Text, disabledText);
|
||||
fusionPalette.setBrush(QPalette::Disabled, QPalette::Base, disabledBase);
|
||||
fusionPalette.setBrush(QPalette::Disabled, QPalette::Dark, darkDisabled);
|
||||
fusionPalette.setBrush(QPalette::Disabled, QPalette::Shadow, disabledShadow);
|
||||
|
||||
fusionPalette.setBrush(QPalette::Active, QPalette::Highlight, QColor(48, 140, 198));
|
||||
fusionPalette.setBrush(QPalette::Inactive, QPalette::Highlight, QColor(145, 141, 126));
|
||||
fusionPalette.setBrush(QPalette::Disabled, QPalette::Highlight, QColor(145, 141, 126));
|
||||
return fusionPalette;
|
||||
}
|
||||
|
||||
#ifndef QT_NO_DEBUG_STREAM
|
||||
QDebug operator<<(QDebug dbg, const QPalette &)
|
||||
{
|
||||
|
@ -41,6 +41,8 @@
|
||||
|
||||
#include "qplatformtheme.h"
|
||||
|
||||
#include "qplatformtheme_p.h"
|
||||
|
||||
#include <QtCore/QVariant>
|
||||
#include <QtCore/QStringList>
|
||||
#include <QtCore/qfileinfo.h>
|
||||
@ -137,6 +139,33 @@ QT_BEGIN_NAMESPACE
|
||||
\sa themeHint(), QStyle::pixelMetric()
|
||||
*/
|
||||
|
||||
QPlatformThemePrivate::QPlatformThemePrivate()
|
||||
: systemPalette(0)
|
||||
{ }
|
||||
|
||||
QPlatformThemePrivate::~QPlatformThemePrivate()
|
||||
{
|
||||
delete systemPalette;
|
||||
}
|
||||
|
||||
Q_GUI_EXPORT QPalette qt_fusionPalette();
|
||||
|
||||
void QPlatformThemePrivate::initializeSystemPalette()
|
||||
{
|
||||
Q_ASSERT(!systemPalette);
|
||||
systemPalette = new QPalette(qt_fusionPalette());
|
||||
}
|
||||
|
||||
QPlatformTheme::QPlatformTheme()
|
||||
: d_ptr(new QPlatformThemePrivate)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QPlatformTheme::QPlatformTheme(QPlatformThemePrivate *priv)
|
||||
: d_ptr(priv)
|
||||
{ }
|
||||
|
||||
QPlatformTheme::~QPlatformTheme()
|
||||
{
|
||||
|
||||
@ -156,7 +185,12 @@ QPlatformDialogHelper *QPlatformTheme::createPlatformDialogHelper(DialogType typ
|
||||
|
||||
const QPalette *QPlatformTheme::palette(Palette type) const
|
||||
{
|
||||
Q_UNUSED(type)
|
||||
Q_D(const QPlatformTheme);
|
||||
if (type == QPlatformTheme::SystemPalette) {
|
||||
if (!d->systemPalette)
|
||||
const_cast<QPlatformTheme *>(this)->d_ptr->initializeSystemPalette();
|
||||
return d->systemPalette;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -52,6 +52,7 @@
|
||||
//
|
||||
|
||||
#include <QtCore/QtGlobal>
|
||||
#include <QtCore/QScopedPointer>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
@ -63,6 +64,7 @@ class QPlatformMenu;
|
||||
class QPlatformMenuBar;
|
||||
class QPlatformDialogHelper;
|
||||
class QPlatformSystemTrayIcon;
|
||||
class QPlatformThemePrivate;
|
||||
class QVariant;
|
||||
class QPalette;
|
||||
class QFont;
|
||||
@ -72,6 +74,7 @@ class QFileInfo;
|
||||
|
||||
class Q_GUI_EXPORT QPlatformTheme
|
||||
{
|
||||
Q_DECLARE_PRIVATE(QPlatformTheme)
|
||||
public:
|
||||
enum ThemeHint {
|
||||
CursorFlashTime,
|
||||
@ -249,6 +252,7 @@ public:
|
||||
AnimateToolBoxUiEffect = 0x40
|
||||
};
|
||||
|
||||
explicit QPlatformTheme();
|
||||
virtual ~QPlatformTheme();
|
||||
|
||||
virtual QPlatformMenuItem* createPlatformMenuItem() const;
|
||||
@ -274,6 +278,12 @@ public:
|
||||
virtual QIconEngine *createIconEngine(const QString &iconName) const;
|
||||
|
||||
static QVariant defaultThemeHint(ThemeHint hint);
|
||||
|
||||
protected:
|
||||
explicit QPlatformTheme(QPlatformThemePrivate *priv);
|
||||
QScopedPointer<QPlatformThemePrivate> d_ptr;
|
||||
private:
|
||||
Q_DISABLE_COPY(QPlatformTheme)
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
74
src/gui/kernel/qplatformtheme_p.h
Normal file
74
src/gui/kernel/qplatformtheme_p.h
Normal file
@ -0,0 +1,74 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3.0 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU General Public License version 3.0 requirements will be
|
||||
** met: http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QPLATFORMTHEME_P_H
|
||||
#define QPLATFORMTHEME_P_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is part of the QPA API and is not meant to be used
|
||||
// in applications. Usage of this API may make your code
|
||||
// source and binary incompatible with future versions of Qt.
|
||||
//
|
||||
|
||||
#include <QtCore/QtGlobal>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QPalette;
|
||||
|
||||
class Q_GUI_EXPORT QPlatformThemePrivate
|
||||
{
|
||||
public:
|
||||
QPlatformThemePrivate();
|
||||
|
||||
virtual ~QPlatformThemePrivate();
|
||||
|
||||
void initializeSystemPalette();
|
||||
|
||||
QPalette *systemPalette;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QPLATFORMTHEME_P_H
|
@ -42,6 +42,8 @@
|
||||
#include "qgenericunixthemes_p.h"
|
||||
#include "../../services/genericunix/qgenericunixservices_p.h"
|
||||
|
||||
#include "qpa/qplatformtheme_p.h"
|
||||
|
||||
#include <QtGui/QPalette>
|
||||
#include <QtGui/QFont>
|
||||
#include <QtGui/QGuiApplication>
|
||||
@ -87,15 +89,27 @@ const char *QGenericUnixTheme::name = "generic";
|
||||
static const char defaultSystemFontNameC[] = "Sans Serif";
|
||||
enum { defaultSystemFontSize = 9 };
|
||||
|
||||
class QGenericUnixThemePrivate : public QPlatformThemePrivate
|
||||
{
|
||||
public:
|
||||
QGenericUnixThemePrivate()
|
||||
: QPlatformThemePrivate()
|
||||
, systemFont(QLatin1String(defaultSystemFontNameC), defaultSystemFontSize)
|
||||
{ }
|
||||
|
||||
const QFont systemFont;
|
||||
};
|
||||
|
||||
QGenericUnixTheme::QGenericUnixTheme()
|
||||
: m_systemFont(QLatin1String(defaultSystemFontNameC), defaultSystemFontSize)
|
||||
: QPlatformTheme(new QGenericUnixThemePrivate())
|
||||
{
|
||||
}
|
||||
|
||||
const QFont *QGenericUnixTheme::font(Font type) const
|
||||
{
|
||||
Q_D(const QGenericUnixTheme);
|
||||
if (type == QPlatformTheme::SystemFont)
|
||||
return &m_systemFont;
|
||||
return &d->systemFont;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -142,6 +156,93 @@ QVariant QGenericUnixTheme::themeHint(ThemeHint hint) const
|
||||
}
|
||||
|
||||
#ifndef QT_NO_SETTINGS
|
||||
class QKdeThemePrivate : public QPlatformThemePrivate
|
||||
{
|
||||
public:
|
||||
QKdeThemePrivate(const QString &kdeHome, int kdeVersion)
|
||||
: kdeHome(kdeHome)
|
||||
, kdeVersion(kdeVersion)
|
||||
, toolButtonStyle(Qt::ToolButtonTextBesideIcon)
|
||||
, toolBarIconSize(0)
|
||||
{ }
|
||||
|
||||
QString globalSettingsFile() const
|
||||
{
|
||||
return kdeHome + QStringLiteral("/share/config/kdeglobals");
|
||||
}
|
||||
|
||||
void refresh();
|
||||
static void readKdeSystemPalette(const QSettings &kdeSettings, QPalette *pal);
|
||||
static QFont *readKdeFontSetting(const QSettings &settings, const QString &key);
|
||||
static QStringList kdeIconThemeSearchPaths(const QString &kdeHome);
|
||||
|
||||
|
||||
const QString kdeHome;
|
||||
const int kdeVersion;
|
||||
|
||||
ResourceHelper resources;
|
||||
QString iconThemeName;
|
||||
QString iconFallbackThemeName;
|
||||
QStringList styleNames;
|
||||
int toolButtonStyle;
|
||||
int toolBarIconSize;
|
||||
};
|
||||
|
||||
void QKdeThemePrivate::refresh()
|
||||
{
|
||||
resources.clear();
|
||||
|
||||
toolButtonStyle = Qt::ToolButtonTextBesideIcon;
|
||||
toolBarIconSize = 0;
|
||||
styleNames.clear();
|
||||
styleNames << QStringLiteral("Oxygen") << QStringLiteral("fusion") << QStringLiteral("windows");
|
||||
iconFallbackThemeName = iconThemeName = QStringLiteral("oxygen");
|
||||
|
||||
// Read settings file.
|
||||
const QString settingsFile = globalSettingsFile();
|
||||
if (!QFileInfo(settingsFile).isReadable())
|
||||
return;
|
||||
|
||||
const QSettings kdeSettings(settingsFile, QSettings::IniFormat);
|
||||
|
||||
QPalette systemPalette = QPalette();
|
||||
readKdeSystemPalette(kdeSettings, &systemPalette);
|
||||
resources.palettes[QPlatformTheme::SystemPalette] = new QPalette(systemPalette);
|
||||
//## TODO tooltip color
|
||||
|
||||
const QVariant styleValue = kdeSettings.value(QStringLiteral("widgetStyle"));
|
||||
if (styleValue.isValid()) {
|
||||
const QString style = styleValue.toString();
|
||||
if (style != styleNames.front())
|
||||
styleNames.push_front(style);
|
||||
}
|
||||
|
||||
const QVariant themeValue = kdeSettings.value(QStringLiteral("Icons/Theme"));
|
||||
if (themeValue.isValid())
|
||||
iconThemeName = themeValue.toString();
|
||||
|
||||
const QVariant toolBarIconSizeValue = kdeSettings.value(QStringLiteral("ToolbarIcons/Size"));
|
||||
if (toolBarIconSizeValue.isValid())
|
||||
toolBarIconSize = toolBarIconSizeValue.toInt();
|
||||
|
||||
const QVariant toolbarStyleValue = kdeSettings.value(QStringLiteral("ToolButtonStyle"));
|
||||
if (toolbarStyleValue.isValid()) {
|
||||
const QString toolBarStyle = toolbarStyleValue.toString();
|
||||
if (toolBarStyle == QStringLiteral("TextBesideIcon"))
|
||||
toolButtonStyle = Qt::ToolButtonTextBesideIcon;
|
||||
else if (toolBarStyle == QStringLiteral("TextOnly"))
|
||||
toolButtonStyle = Qt::ToolButtonTextOnly;
|
||||
else if (toolBarStyle == QStringLiteral("TextUnderIcon"))
|
||||
toolButtonStyle = Qt::ToolButtonTextUnderIcon;
|
||||
}
|
||||
|
||||
// Read system font, ignore 'fixed' 'smallestReadableFont'
|
||||
if (QFont *systemFont = readKdeFontSetting(kdeSettings, QStringLiteral("font"))) {
|
||||
resources.fonts[QPlatformTheme::SystemFont] = systemFont;
|
||||
} else {
|
||||
resources.fonts[QPlatformTheme::SystemFont] = new QFont(QLatin1String(defaultSystemFontNameC), defaultSystemFontSize);
|
||||
}
|
||||
}
|
||||
|
||||
// Reads the color from the KDE configuration, and store it in the
|
||||
// palette with the given color role if found.
|
||||
@ -158,7 +259,7 @@ static inline bool kdeColor(QPalette *pal, QPalette::ColorRole role,
|
||||
return true;
|
||||
}
|
||||
|
||||
static inline void readKdeSystemPalette(const QSettings &kdeSettings, QPalette *pal)
|
||||
void QKdeThemePrivate::readKdeSystemPalette(const QSettings &kdeSettings, QPalette *pal)
|
||||
{
|
||||
kdeColor(pal, QPalette::Button, kdeSettings, QStringLiteral("Colors:Button/BackgroundNormal"));
|
||||
kdeColor(pal, QPalette::Window, kdeSettings, QStringLiteral("Colors:Window/BackgroundNormal"));
|
||||
@ -183,14 +284,13 @@ static inline void readKdeSystemPalette(const QSettings &kdeSettings, QPalette *
|
||||
|
||||
const char *QKdeTheme::name = "kde";
|
||||
|
||||
QKdeTheme::QKdeTheme(const QString &kdeHome, int kdeVersion) :
|
||||
m_kdeHome(kdeHome), m_kdeVersion(kdeVersion),
|
||||
m_toolButtonStyle(Qt::ToolButtonTextBesideIcon), m_toolBarIconSize(0)
|
||||
QKdeTheme::QKdeTheme(const QString &kdeHome, int kdeVersion)
|
||||
: QPlatformTheme(new QKdeThemePrivate(kdeHome,kdeVersion))
|
||||
{
|
||||
refresh();
|
||||
d_func()->refresh();
|
||||
}
|
||||
|
||||
static inline QFont *readKdeFontSetting(const QSettings &settings, const QString &key)
|
||||
QFont *QKdeThemePrivate::readKdeFontSetting(const QSettings &settings, const QString &key)
|
||||
{
|
||||
const QVariant fontValue = settings.value(key);
|
||||
if (fontValue.isValid()) {
|
||||
@ -218,68 +318,8 @@ static inline QFont *readKdeFontSetting(const QSettings &settings, const QString
|
||||
return 0;
|
||||
}
|
||||
|
||||
void QKdeTheme::refresh()
|
||||
{
|
||||
m_resources.clear();
|
||||
|
||||
m_toolButtonStyle = Qt::ToolButtonTextBesideIcon;
|
||||
m_toolBarIconSize = 0;
|
||||
m_styleNames.clear();
|
||||
m_styleNames << QStringLiteral("Oxygen") << QStringLiteral("fusion") << QStringLiteral("windows");
|
||||
m_iconFallbackThemeName = m_iconThemeName = QStringLiteral("oxygen");
|
||||
|
||||
// Read settings file.
|
||||
const QString settingsFile = globalSettingsFile();
|
||||
if (!QFileInfo(settingsFile).isReadable())
|
||||
return;
|
||||
|
||||
const QSettings kdeSettings(settingsFile, QSettings::IniFormat);
|
||||
|
||||
QPalette systemPalette = QPalette();
|
||||
readKdeSystemPalette(kdeSettings, &systemPalette);
|
||||
m_resources.palettes[SystemPalette] = new QPalette(systemPalette);
|
||||
//## TODO tooltip color
|
||||
|
||||
const QVariant styleValue = kdeSettings.value(QStringLiteral("widgetStyle"));
|
||||
if (styleValue.isValid()) {
|
||||
const QString style = styleValue.toString();
|
||||
if (style != m_styleNames.front())
|
||||
m_styleNames.push_front(style);
|
||||
}
|
||||
|
||||
const QVariant themeValue = kdeSettings.value(QStringLiteral("Icons/Theme"));
|
||||
if (themeValue.isValid())
|
||||
m_iconThemeName = themeValue.toString();
|
||||
|
||||
const QVariant toolBarIconSizeValue = kdeSettings.value(QStringLiteral("ToolbarIcons/Size"));
|
||||
if (toolBarIconSizeValue.isValid())
|
||||
m_toolBarIconSize = toolBarIconSizeValue.toInt();
|
||||
|
||||
const QVariant toolbarStyleValue = kdeSettings.value(QStringLiteral("ToolButtonStyle"));
|
||||
if (toolbarStyleValue.isValid()) {
|
||||
const QString toolBarStyle = toolbarStyleValue.toString();
|
||||
if (toolBarStyle == QStringLiteral("TextBesideIcon"))
|
||||
m_toolButtonStyle = Qt::ToolButtonTextBesideIcon;
|
||||
else if (toolBarStyle == QStringLiteral("TextOnly"))
|
||||
m_toolButtonStyle = Qt::ToolButtonTextOnly;
|
||||
else if (toolBarStyle == QStringLiteral("TextUnderIcon"))
|
||||
m_toolButtonStyle = Qt::ToolButtonTextUnderIcon;
|
||||
}
|
||||
|
||||
// Read system font, ignore 'fixed' 'smallestReadableFont'
|
||||
if (QFont *systemFont = readKdeFontSetting(kdeSettings, QStringLiteral("font"))) {
|
||||
m_resources.fonts[SystemFont] = systemFont;
|
||||
} else {
|
||||
m_resources.fonts[SystemFont] = new QFont(QLatin1String(defaultSystemFontNameC), defaultSystemFontSize);
|
||||
}
|
||||
}
|
||||
|
||||
QString QKdeTheme::globalSettingsFile() const
|
||||
{
|
||||
return m_kdeHome + QStringLiteral("/share/config/kdeglobals");
|
||||
}
|
||||
|
||||
static QStringList kdeIconThemeSearchPaths(const QString &kdeHome)
|
||||
QStringList QKdeThemePrivate::kdeIconThemeSearchPaths(const QString &kdeHome)
|
||||
{
|
||||
QStringList candidates = QStringList(kdeHome);
|
||||
const QString kdeDirs = QFile::decodeName(qgetenv("KDEDIRS"));
|
||||
@ -298,6 +338,7 @@ static QStringList kdeIconThemeSearchPaths(const QString &kdeHome)
|
||||
|
||||
QVariant QKdeTheme::themeHint(QPlatformTheme::ThemeHint hint) const
|
||||
{
|
||||
Q_D(const QKdeTheme);
|
||||
switch (hint) {
|
||||
case QPlatformTheme::UseFullScreenForPopupMenu:
|
||||
return QVariant(true);
|
||||
@ -306,17 +347,17 @@ QVariant QKdeTheme::themeHint(QPlatformTheme::ThemeHint hint) const
|
||||
case QPlatformTheme::DialogButtonBoxLayout:
|
||||
return QVariant(2); // QDialogButtonBox::KdeLayout
|
||||
case QPlatformTheme::ToolButtonStyle:
|
||||
return QVariant(m_toolButtonStyle);
|
||||
return QVariant(d->toolButtonStyle);
|
||||
case QPlatformTheme::ToolBarIconSize:
|
||||
return QVariant(m_toolBarIconSize);
|
||||
return QVariant(d->toolBarIconSize);
|
||||
case QPlatformTheme::SystemIconThemeName:
|
||||
return QVariant(m_iconThemeName);
|
||||
return QVariant(d->iconThemeName);
|
||||
case QPlatformTheme::SystemIconFallbackThemeName:
|
||||
return QVariant(m_iconFallbackThemeName);
|
||||
return QVariant(d->iconFallbackThemeName);
|
||||
case QPlatformTheme::IconThemeSearchPaths:
|
||||
return QVariant(kdeIconThemeSearchPaths(m_kdeHome));
|
||||
return QVariant(d->kdeIconThemeSearchPaths(d->kdeHome));
|
||||
case QPlatformTheme::StyleNames:
|
||||
return QVariant(m_styleNames);
|
||||
return QVariant(d->styleNames);
|
||||
case QPlatformTheme::KeyboardScheme:
|
||||
return QVariant(int(KdeKeyboardScheme));
|
||||
default:
|
||||
@ -325,6 +366,18 @@ QVariant QKdeTheme::themeHint(QPlatformTheme::ThemeHint hint) const
|
||||
return QPlatformTheme::themeHint(hint);
|
||||
}
|
||||
|
||||
const QPalette *QKdeTheme::palette(Palette type) const
|
||||
{
|
||||
Q_D(const QKdeTheme);
|
||||
return d->resources.palettes[type];
|
||||
}
|
||||
|
||||
const QFont *QKdeTheme::font(Font type) const
|
||||
{
|
||||
Q_D(const QKdeTheme);
|
||||
return d->resources.fonts[type];
|
||||
}
|
||||
|
||||
QPlatformTheme *QKdeTheme::createKdeTheme()
|
||||
{
|
||||
// Check for version >= 4 and determine home folder from environment,
|
||||
@ -361,8 +414,18 @@ QPlatformTheme *QKdeTheme::createKdeTheme()
|
||||
|
||||
const char *QGnomeTheme::name = "gnome";
|
||||
|
||||
class QGnomeThemePrivate : public QPlatformThemePrivate
|
||||
{
|
||||
public:
|
||||
QGnomeThemePrivate()
|
||||
: systemFont(QLatin1Literal(defaultSystemFontNameC), defaultSystemFontSize)
|
||||
{}
|
||||
|
||||
const QFont systemFont;
|
||||
};
|
||||
|
||||
QGnomeTheme::QGnomeTheme()
|
||||
: m_systemFont(QLatin1String(defaultSystemFontNameC), defaultSystemFontSize)
|
||||
: QPlatformTheme(new QGnomeThemePrivate())
|
||||
{
|
||||
}
|
||||
|
||||
@ -393,8 +456,10 @@ QVariant QGnomeTheme::themeHint(QPlatformTheme::ThemeHint hint) const
|
||||
|
||||
const QFont *QGnomeTheme::font(Font type) const
|
||||
{
|
||||
Q_D(const QGnomeTheme);
|
||||
if (type == QPlatformTheme::SystemFont)
|
||||
return &m_systemFont;
|
||||
return &d->systemFont;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -61,8 +61,11 @@ public:
|
||||
QFont *fonts[QPlatformTheme::NFonts];
|
||||
};
|
||||
|
||||
class QGenericUnixThemePrivate;
|
||||
|
||||
class QGenericUnixTheme : public QPlatformTheme
|
||||
{
|
||||
Q_DECLARE_PRIVATE(QGenericUnixTheme)
|
||||
public:
|
||||
QGenericUnixTheme();
|
||||
|
||||
@ -75,55 +78,39 @@ public:
|
||||
static QStringList xdgIconThemePaths();
|
||||
|
||||
static const char *name;
|
||||
|
||||
private:
|
||||
const QFont m_systemFont;
|
||||
};
|
||||
|
||||
#ifndef QT_NO_SETTINGS
|
||||
class QKdeThemePrivate;
|
||||
|
||||
class QKdeTheme : public QPlatformTheme
|
||||
{
|
||||
Q_DECLARE_PRIVATE(QKdeTheme)
|
||||
QKdeTheme(const QString &kdeHome, int kdeVersion);
|
||||
public:
|
||||
|
||||
static QPlatformTheme *createKdeTheme();
|
||||
virtual QVariant themeHint(ThemeHint hint) const;
|
||||
|
||||
virtual const QPalette *palette(Palette type = SystemPalette) const
|
||||
{ return m_resources.palettes[type]; }
|
||||
virtual const QPalette *palette(Palette type = SystemPalette) const;
|
||||
|
||||
virtual const QFont *font(Font type) const
|
||||
{ return m_resources.fonts[type]; }
|
||||
virtual const QFont *font(Font type) const;
|
||||
|
||||
static const char *name;
|
||||
|
||||
private:
|
||||
QString globalSettingsFile() const;
|
||||
void refresh();
|
||||
|
||||
const QString m_kdeHome;
|
||||
const int m_kdeVersion;
|
||||
|
||||
ResourceHelper m_resources;
|
||||
QString m_iconThemeName;
|
||||
QString m_iconFallbackThemeName;
|
||||
QStringList m_styleNames;
|
||||
int m_toolButtonStyle;
|
||||
int m_toolBarIconSize;
|
||||
};
|
||||
#endif // QT_NO_SETTINGS
|
||||
|
||||
class QGnomeThemePrivate;
|
||||
|
||||
class QGnomeTheme : public QPlatformTheme
|
||||
{
|
||||
Q_DECLARE_PRIVATE(QGnomeTheme)
|
||||
public:
|
||||
QGnomeTheme();
|
||||
virtual QVariant themeHint(ThemeHint hint) const;
|
||||
virtual const QFont *font(Font type) const;
|
||||
|
||||
static const char *name;
|
||||
|
||||
private:
|
||||
const QFont m_systemFont;
|
||||
};
|
||||
|
||||
QPlatformTheme *qt_createUnixTheme();
|
||||
|
@ -1896,50 +1896,14 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio
|
||||
}
|
||||
}
|
||||
|
||||
extern QPalette qt_fusionPalette();
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
QPalette QFusionStyle::standardPalette () const
|
||||
{
|
||||
QPalette palette = QCommonStyle::standardPalette();
|
||||
palette.setBrush(QPalette::Active, QPalette::Highlight, QColor(48, 140, 198));
|
||||
palette.setBrush(QPalette::Inactive, QPalette::Highlight, QColor(145, 141, 126));
|
||||
palette.setBrush(QPalette::Disabled, QPalette::Highlight, QColor(145, 141, 126));
|
||||
|
||||
QColor backGround(239, 235, 231);
|
||||
|
||||
QColor light = backGround.lighter(150);
|
||||
QColor base = Qt::white;
|
||||
QColor dark = QColor(170, 156, 143).darker(110);
|
||||
dark = backGround.darker(150);
|
||||
QColor darkDisabled = QColor(209, 200, 191).darker(110);
|
||||
|
||||
//### Find the correct disabled text color
|
||||
palette.setBrush(QPalette::Disabled, QPalette::Text, QColor(190, 190, 190));
|
||||
|
||||
palette.setBrush(QPalette::Window, backGround);
|
||||
palette.setBrush(QPalette::Mid, backGround.darker(130));
|
||||
palette.setBrush(QPalette::Light, light);
|
||||
|
||||
palette.setBrush(QPalette::Active, QPalette::Base, base);
|
||||
palette.setBrush(QPalette::Inactive, QPalette::Base, base);
|
||||
palette.setBrush(QPalette::Disabled, QPalette::Base, backGround);
|
||||
|
||||
palette.setBrush(QPalette::Midlight, palette.mid().color().lighter(110));
|
||||
|
||||
palette.setBrush(QPalette::All, QPalette::Dark, dark);
|
||||
palette.setBrush(QPalette::Disabled, QPalette::Dark, darkDisabled);
|
||||
|
||||
QColor button = backGround;
|
||||
|
||||
palette.setBrush(QPalette::Button, button);
|
||||
|
||||
QColor shadow = dark.darker(135);
|
||||
palette.setBrush(QPalette::Shadow, shadow);
|
||||
palette.setBrush(QPalette::Disabled, QPalette::Shadow, shadow.lighter(150));
|
||||
palette.setBrush(QPalette::HighlightedText, QColor(QRgb(0xffffffff)));
|
||||
|
||||
return palette;
|
||||
return qt_fusionPalette();
|
||||
}
|
||||
|
||||
/*!
|
||||
|
Loading…
Reference in New Issue
Block a user