themed colors
svn path=/trunk/KDE/kdebase/runtime/; revision=1170430
This commit is contained in:
parent
3a6168ca60
commit
c9b045fa86
|
@ -29,6 +29,7 @@
|
|||
#include <Plasma/Applet>
|
||||
#include <Plasma/PopupApplet>
|
||||
#include <Plasma/DataEngine>
|
||||
#include <Plasma/Theme>
|
||||
|
||||
#include "simplejavascriptapplet.h"
|
||||
|
||||
|
@ -60,6 +61,7 @@ class AppletInterface : public QObject
|
|||
Q_ENUMS(QtMouseButton)
|
||||
Q_ENUMS(AnimationDirection)
|
||||
Q_ENUMS(IntervalAlignment)
|
||||
Q_ENUMS(ThemeColors)
|
||||
Q_PROPERTY(AspectRatioMode aspectRatioMode READ aspectRatioMode WRITE setAspectRatioMode)
|
||||
Q_PROPERTY(FormFactor formFactor READ formFactor)
|
||||
Q_PROPERTY(Location location READ location)
|
||||
|
@ -172,6 +174,16 @@ enum BackgroundHints {
|
|||
DefaultBackground = Plasma::Applet::DefaultBackground
|
||||
};
|
||||
|
||||
enum ThemeColors {
|
||||
TextColor = Plasma::Theme::TextColor,
|
||||
HighlightColor = Plasma::Theme::HighlightColor,
|
||||
BackgroundColor = Plasma::Theme::BackgroundColor,
|
||||
ButtonTextColor = Plasma::Theme::ButtonTextColor,
|
||||
ButtonBackgroundColor = Plasma::Theme::ButtonBackgroundColor,
|
||||
LinkColor = Plasma::Theme::LinkColor,
|
||||
VisitedLinkColor = Plasma::Theme::VisitedLinkColor
|
||||
};
|
||||
|
||||
enum QtAlignment {
|
||||
QtAlignLeft = 0x0001,
|
||||
QtAlignRight = 0x0002,
|
||||
|
|
|
@ -20,6 +20,9 @@
|
|||
#include <QtScript/QScriptEngine>
|
||||
#include <QtScript/QScriptContext>
|
||||
#include <QtGui/QColor>
|
||||
|
||||
#include <Plasma/Theme>
|
||||
|
||||
#include "backportglobal.h"
|
||||
|
||||
Q_DECLARE_METATYPE(QColor*)
|
||||
|
@ -106,6 +109,22 @@ static QScriptValue valid(QScriptContext *ctx, QScriptEngine *eng)
|
|||
return QScriptValue(eng, self->isValid());
|
||||
}
|
||||
|
||||
static QScriptValue setThemeColor(QScriptContext *ctx, QScriptEngine *)
|
||||
{
|
||||
DECLARE_SELF(QColor, themeColor);
|
||||
|
||||
if (ctx->argumentCount() > 0) {
|
||||
const qint32 arg = ctx->argument(0).toInt32();
|
||||
if (arg >= 0 && arg <= Plasma::Theme::VisitedLinkColor) {
|
||||
kDebug() << "setting to: " << static_cast<Plasma::Theme::ColorRole>(arg);
|
||||
kDebug() << "color is: " << Plasma::Theme::defaultTheme()->color(static_cast<Plasma::Theme::ColorRole>(arg));
|
||||
self->setRgba(Plasma::Theme::defaultTheme()->color(static_cast<Plasma::Theme::ColorRole>(arg)).rgba());
|
||||
}
|
||||
}
|
||||
|
||||
return ctx->thisObject();//.property("themeColor");
|
||||
}
|
||||
|
||||
QScriptValue constructColorClass(QScriptEngine *eng)
|
||||
{
|
||||
QScriptValue proto = qScriptValueFromValue(eng, QColor());
|
||||
|
@ -116,6 +135,7 @@ QScriptValue constructColorClass(QScriptEngine *eng)
|
|||
proto.setProperty("blue", eng->newFunction(blue), getter | setter);
|
||||
proto.setProperty("alpha", eng->newFunction(alpha), getter | setter);
|
||||
proto.setProperty("valid", eng->newFunction(valid), getter);
|
||||
ADD_METHOD(proto, setThemeColor);
|
||||
|
||||
eng->setDefaultPrototype(qMetaTypeId<QColor>(), proto);
|
||||
eng->setDefaultPrototype(qMetaTypeId<QColor*>(), proto);
|
||||
|
|
Loading…
Reference in New Issue
Block a user