From 7c7a755f2d87d672ee8afc7d5656971297539fe3 Mon Sep 17 00:00:00 2001 From: Michael Bohlender Date: Thu, 10 Mar 2016 12:12:31 +0100 Subject: Theme plugin with colorpalette --- components/package/contents/ui/FocusComposer.qml | 4 +- framework/theme/CMakeLists.txt | 13 +++++++ framework/theme/colorpalette.cpp | 45 +++++++++++++++++++++++ framework/theme/colorpalette.h | 47 ++++++++++++++++++++++++ framework/theme/qmldir | 3 ++ framework/theme/themeplugin.cpp | 40 ++++++++++++++++++++ framework/theme/themeplugin.h | 31 ++++++++++++++++ 7 files changed, 182 insertions(+), 1 deletion(-) create mode 100644 framework/theme/CMakeLists.txt create mode 100644 framework/theme/colorpalette.cpp create mode 100644 framework/theme/colorpalette.h create mode 100644 framework/theme/qmldir create mode 100644 framework/theme/themeplugin.cpp create mode 100644 framework/theme/themeplugin.h diff --git a/components/package/contents/ui/FocusComposer.qml b/components/package/contents/ui/FocusComposer.qml index 8ec01cc9..5c4d88d7 100644 --- a/components/package/contents/ui/FocusComposer.qml +++ b/components/package/contents/ui/FocusComposer.qml @@ -19,13 +19,15 @@ import QtQuick 2.4 import QtQuick.Controls 1.4 import QtQuick.Layouts 1.1 +import org.kube.framework.theme 1.0 + Rectangle { id: root property variant originalMessage visible: false - color: colorPalette.border + color: ColorPalette.border opacity: 0.9 diff --git a/framework/theme/CMakeLists.txt b/framework/theme/CMakeLists.txt new file mode 100644 index 00000000..4314f662 --- /dev/null +++ b/framework/theme/CMakeLists.txt @@ -0,0 +1,13 @@ +set(themeplugin_SRCS + themeplugin.cpp + colorpalette.cpp +) + +add_library(themeplugin SHARED ${themeplugin_SRCS}) + +qt5_use_modules(themeplugin Core Quick Qml) + +target_link_libraries(themeplugin) + +install(TARGETS themeplugin DESTINATION ${QML_INSTALL_DIR}/org/kube/framework/theme) +install(FILES qmldir DESTINATION ${QML_INSTALL_DIR}/org/kube/framework/theme) diff --git a/framework/theme/colorpalette.cpp b/framework/theme/colorpalette.cpp new file mode 100644 index 00000000..a321a292 --- /dev/null +++ b/framework/theme/colorpalette.cpp @@ -0,0 +1,45 @@ +/* + Copyright (C) 2016 Michael Bohlender + + 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. +*/ + +#include "colorpalette.h" + +ColorPalette::ColorPalette(QObject *parent) : QObject(parent), m_background("#fcfcfc"), m_selected("#3daee9"), m_read("#232629"), m_border("#232629") +{ + +} + +QString ColorPalette::background() const +{ + return m_background; +} + +QString ColorPalette::read() const +{ + return m_read; +} + +QString ColorPalette::selected() const +{ + return m_selected; +} + +QString ColorPalette::border() const +{ + return m_border; +} + diff --git a/framework/theme/colorpalette.h b/framework/theme/colorpalette.h new file mode 100644 index 00000000..a06783f3 --- /dev/null +++ b/framework/theme/colorpalette.h @@ -0,0 +1,47 @@ +/* + Copyright (C) 2016 Michael Bohlender + + 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. +*/ + +#include +#include + +class ColorPalette : public QObject +{ + Q_OBJECT + + Q_PROPERTY (QString background READ background NOTIFY themeChanged) + Q_PROPERTY (QString selected READ background NOTIFY themeChanged) + Q_PROPERTY (QString read READ read NOTIFY themeChanged) + Q_PROPERTY (QString border READ border NOTIFY themeChanged) + +public: + explicit ColorPalette(QObject *parent = Q_NULLPTR); + + QString background() const; + QString selected() const; + QString read() const; + QString border() const; + +signals: + void themeChanged(); + +private: + QString m_background; + QString m_selected; + QString m_read; + QString m_border; +}; diff --git a/framework/theme/qmldir b/framework/theme/qmldir new file mode 100644 index 00000000..489a71ca --- /dev/null +++ b/framework/theme/qmldir @@ -0,0 +1,3 @@ +module org.kube.framework.theme + +plugin themeplugin diff --git a/framework/theme/themeplugin.cpp b/framework/theme/themeplugin.cpp new file mode 100644 index 00000000..919205cf --- /dev/null +++ b/framework/theme/themeplugin.cpp @@ -0,0 +1,40 @@ +/* + Copyright (C) 2016 Michael Bohlender + + 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. +*/ + +#include "themeplugin.h" + +#include "colorpalette.h" + +#include +#include + +static QObject *colorpaletteInstace(QQmlEngine *engine, QJSEngine *scriptEngine) +{ + Q_UNUSED(engine); + Q_UNUSED(scriptEngine); + + return new ColorPalette; +} + +void ThemePlugin::registerTypes (const char *uri) +{ + Q_ASSERT(uri == QLatin1String("org.kube.framework.theme")); + + qmlRegisterSingletonType(uri, 1, 0, "ColorPalette", colorpaletteInstace); + +} diff --git a/framework/theme/themeplugin.h b/framework/theme/themeplugin.h new file mode 100644 index 00000000..d8ae43c1 --- /dev/null +++ b/framework/theme/themeplugin.h @@ -0,0 +1,31 @@ +/* + Copyright (C) 2016 Michael Bohlender + + 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. +*/ + +#pragma once + +#include +#include + +class ThemePlugin : public QQmlExtensionPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") + +public: + virtual void registerTypes(const char *uri); +}; \ No newline at end of file -- cgit v1.2.3