Commit 7ce7d640 authored by Denis Kuplyakov's avatar Denis Kuplyakov
Browse files

Now code doesn't need kdelibs patch

Added old implementation of ColorScheme and fixed PopupItem for it.
parent 035f73be
......@@ -20,106 +20,30 @@
* Boston, MA 02110-1301, USA.
*
********************************************************************/
#include <colorscheme.h>
#include "colorscheme.h"
ColorScheme::ColorScheme(QDeclarativeItem *parent) :
QDeclarativeItem(parent)
QDeclarativeItem(parent)
{
}
QPalette::ColorGroup ColorScheme::getColorGroup() const
{
return m_colorGroup;
}
void ColorScheme::setColorGroup(QPalette::ColorGroup colorGroup)
{
m_colorGroup = colorGroup;
emit onBackgroundChange();
emit onDecorationChange();
emit onForegroundChange();
emit onShadeChange();
}
KColorScheme::ColorSet ColorScheme::getColorSet() const
{
return m_colorSet;
}
void ColorScheme::setColorSet(KColorScheme::ColorSet colorSet)
{
m_colorSet = colorSet;
emit onBackgroundChange();
emit onForegroundChange();
emit onDecorationChange();
}
KColorScheme::BackgroundRole ColorScheme::getBackgroundRole() const
{
return m_backgroundRole;
}
void ColorScheme::setBackgroundRole(KColorScheme::BackgroundRole role)
{
m_backgroundRole = role;
emit onBackgroundChange();
}
KColorScheme::ForegroundRole ColorScheme::getForegroundRole() const
{
return m_foregroundRole;
}
void ColorScheme::setForegroundRole(KColorScheme::ForegroundRole role)
{
m_foregroundRole = role;
emit onForegroundChange();
}
KColorScheme::DecorationRole ColorScheme::getDecorationRole() const
{
return m_decorationRole;
}
void ColorScheme::setDecorationRole(KColorScheme::DecorationRole role)
{
m_decorationRole = role;
emit onDecorationChange();
}
KColorScheme::ShadeRole ColorScheme::getShadeRole() const
{
return m_shadeRole;
}
void ColorScheme::setShadeRole(KColorScheme::ShadeRole role)
{
m_shadeRole = role;
emit onShadeChange();
}
QColor ColorScheme::background() const
{
return KStatefulBrush(m_colorSet,
m_backgroundRole)
.brush(m_colorGroup).color();
return KStatefulBrush(KColorScheme::Tooltip,
KColorScheme::NormalBackground)
.brush(QPalette::Active).color();
}
QColor ColorScheme::foreground() const
{
return KStatefulBrush(m_colorSet,
m_foregroundRole)
.brush(m_colorGroup).color();
}
QColor ColorScheme::decoration() const
{
return KStatefulBrush(m_colorSet,
m_decorationRole)
.brush(m_colorGroup).color();
return KStatefulBrush(KColorScheme::Tooltip,
KColorScheme::NormalText)
.brush(QPalette::Active).color();
}
QColor ColorScheme::shade() const
QColor ColorScheme::border() const
{
return KColorScheme(m_colorGroup).shade(m_shadeRole);
return KStatefulBrush(KColorScheme::View,
KColorScheme::NormalText)
.brush(QPalette::Active).color();
}
......@@ -25,143 +25,25 @@
#define COLORSCHEME_H
#include <QDeclarativeItem>
#include <QColor>
#include <KColorScheme>
#include <QColor>
/**
* Wrapper to access KColorScheme color methods from QML code.
*
* Used to access KDE's current color theme's colors from QML code.
* To use it you must register KColorScheme and QPalette classes with
* qmlRegisterUncreatableType, as their enums are used to access KColorScheme
* methods.
*
* Example usage of class:
* \code{.qml}
Rectangle {
color: backgroundTokken.background
ColorScheme {
id: backgroundTokken
colorSet: KColorScheme.Tooltip
backgroundRole: KColorScheme.NormalBackground
}
}
\endcode
*
* @see KColorScheme
*/
class ColorScheme : public QDeclarativeItem
{
Q_OBJECT
Q_PROPERTY(QPalette::ColorGroup colorGroup
READ getColorGroup WRITE setColorGroup)
Q_PROPERTY(KColorScheme::ColorSet colorSet
READ getColorSet WRITE setColorSet)
Q_PROPERTY(KColorScheme::BackgroundRole backgroundRole
READ getBackgroundRole WRITE setBackgroundRole)
Q_PROPERTY(KColorScheme::ForegroundRole foregroundRole
READ getForegroundRole WRITE setForegroundRole)
Q_PROPERTY(KColorScheme::DecorationRole decorationRole
READ getDecorationRole WRITE setDecorationRole)
Q_PROPERTY(KColorScheme::ShadeRole shadeRole
READ getShadeRole WRITE setShadeRole)
Q_PROPERTY(QColor background READ background NOTIFY onBackgroundChange)
Q_PROPERTY(QColor foreground READ foreground NOTIFY onForegroundChange)
Q_PROPERTY(QColor decoration READ decoration NOTIFY onDecorationChange)
Q_PROPERTY(QColor shade READ shade NOTIFY onShadeChange)
Q_PROPERTY(QColor background READ background NOTIFY placeHolder)
Q_PROPERTY(QColor foreground READ foreground NOTIFY placeHolder)
Q_PROPERTY(QColor border READ border NOTIFY placeHolder)
public:
explicit ColorScheme(QDeclarativeItem *parent = 0);
/**
* @return current QPalette::ColorGroup parameter value
*/
QPalette::ColorGroup getColorGroup() const;
/**
* Sets QPalette::ColorGroup parameter value to @p colorGroup
*/
void setColorGroup(QPalette::ColorGroup colorGroup);
/**
* @return current KColorScheme::ColorSet parameter value
*/
KColorScheme::ColorSet getColorSet() const;
/**
* Sets KColorScheme::ColorSet parameter value to @p colorSet
*/
void setColorSet(KColorScheme::ColorSet colorSet);
/**
* @return current KColorScheme::BackgroundRole parameter value
*/
KColorScheme::BackgroundRole getBackgroundRole() const;
/**
* Sets KColorScheme::BackgroundRole parameter value to @p role
*/
void setBackgroundRole(KColorScheme::BackgroundRole role);
/**
* @return current KColorScheme::ForegroundRole parameter value
*/
KColorScheme::ForegroundRole getForegroundRole() const;
/**
* Sets KColorScheme::ForegroundRole parameter value to @p role
*/
void setForegroundRole(KColorScheme::ForegroundRole role);
/**
* @return current KColorScheme::DecorationRole parameter value
*/
KColorScheme::DecorationRole getDecorationRole() const;
/**
* Sets KColorScheme::DecorationRole parameter value to @p role
*/
void setDecorationRole(KColorScheme::DecorationRole role);
/**
* @return current KColorScheme::ShadeRole parameter value
*/
KColorScheme::ShadeRole getShadeRole() const;
/**
* Sets KColorScheme::ShadeRole parameter value to @p role
*/
void setShadeRole(KColorScheme::ShadeRole role);
ColorScheme(QDeclarativeItem *parent = 0);
QColor background() const;
QColor foreground() const;
QColor decoration() const;
QColor shade() const;
QColor border() const;
signals:
/**
* Emitted when one of parameters that affects background has been changed.
* @see colorSet backgroundRole
*/
void onBackgroundChange();
/**
* Emitted when one of parameters that affects foreground has been changed.
* @see colorSet foregroundRole
*/
void onForegroundChange();
/**
* Emitted when one of parameters that affects decoration has been changed.
* @see colorSet decorationRole
*/
void onDecorationChange();
/**
* Emitted when one of parameters that affects shade has been changed.
* @see shadeRole
*/
void onShadeChange();
private:
QPalette::ColorGroup m_colorGroup;
KColorScheme::ColorSet m_colorSet;
KColorScheme::BackgroundRole m_backgroundRole;
KColorScheme::ForegroundRole m_foregroundRole;
KColorScheme::DecorationRole m_decorationRole;
KColorScheme::ShadeRole m_shadeRole;
void placeHolder();
};
#endif // COLORSCHEME_H
......@@ -32,8 +32,6 @@ KReversiView::KReversiView(KReversiGame* game, QWidget *parent, KgThemeProvider
m_provider->setDeclarativeEngine("themeProvider", engine());
qmlRegisterType<ColorScheme>("ColorScheme", 1, 0, "ColorScheme");
qmlRegisterUncreatableType<KColorScheme>("KColorScheme", 1, 0, "KColorScheme",
"KColorScheme class is uncreatable. Use for enums only");
QString path =
KStandardDirs::locate("appdata", QLatin1String("qml/Table.qml"));
......
......@@ -19,7 +19,6 @@
import QtQuick 1.1
import ColorScheme 1.0
import KColorScheme 1.0
/**
* Popup
......@@ -109,8 +108,8 @@ Rectangle {
height: row.height + 2 * marginOnSides
width: row.width + 2 * marginOnSides
color: backgroundTokken.background
border.color: useCustomBorderColor ? borderColor : borderTokken.foreground
color: colorScheme.background
border.color: useCustomBorderColor ? borderColor : colorScheme.border
border.width: borderWidth
function show(message, showing_state) {
......@@ -120,23 +119,9 @@ Rectangle {
state = showing_state
}
}
ColorScheme {
id: borderTokken
colorSet: KColorScheme.View
foregroundRole: KColorScheme.NormalText
}
ColorScheme {
id: backgroundTokken
colorSet: KColorScheme.Tooltip
backgroundRole: KColorScheme.NormalBackground
}
ColorScheme {
id: textColorTokken
colorSet: KColorScheme.Tooltip
foregroundRole: KColorScheme.NormalText
id: colorScheme
}
Timer {
......@@ -169,7 +154,7 @@ Rectangle {
Text {
id: text
anchors.verticalCenter: parent.verticalCenter
color: textColorTokken.foreground
color: colorScheme.foreground
wrapMode: Text.WordWrap
onLinkActivated: popup.linkActivated(link);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment