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 --- 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 ++++++++++++++++++++++++++ 6 files changed, 179 insertions(+) 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 (limited to 'framework/theme') 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 From 181b39ddd0b3c027341b228ab51482ce4413d3bb Mon Sep 17 00:00:00 2001 From: Michael Bohlender Date: Thu, 10 Mar 2016 13:54:07 +0100 Subject: add scaling unit to the theme plugin and use it instaed of the main.qml unit item --- framework/theme/CMakeLists.txt | 1 + framework/theme/themeplugin.cpp | 14 ++++++++++++-- framework/theme/unit.cpp | 29 +++++++++++++++++++++++++++++ framework/theme/unit.h | 38 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 framework/theme/unit.cpp create mode 100644 framework/theme/unit.h (limited to 'framework/theme') diff --git a/framework/theme/CMakeLists.txt b/framework/theme/CMakeLists.txt index 4314f662..319e3d39 100644 --- a/framework/theme/CMakeLists.txt +++ b/framework/theme/CMakeLists.txt @@ -1,6 +1,7 @@ set(themeplugin_SRCS themeplugin.cpp colorpalette.cpp + unit.cpp ) add_library(themeplugin SHARED ${themeplugin_SRCS}) diff --git a/framework/theme/themeplugin.cpp b/framework/theme/themeplugin.cpp index 919205cf..ad9d0e1b 100644 --- a/framework/theme/themeplugin.cpp +++ b/framework/theme/themeplugin.cpp @@ -18,11 +18,12 @@ #include "themeplugin.h" -#include "colorpalette.h" - #include #include +#include "colorpalette.h" +#include "unit.h" + static QObject *colorpaletteInstace(QQmlEngine *engine, QJSEngine *scriptEngine) { Q_UNUSED(engine); @@ -31,10 +32,19 @@ static QObject *colorpaletteInstace(QQmlEngine *engine, QJSEngine *scriptEngine) return new ColorPalette; } +static QObject *unitInstace(QQmlEngine *engine, QJSEngine *scriptEngine) +{ + Q_UNUSED(engine); + Q_UNUSED(scriptEngine); + + return new Unit; +} + void ThemePlugin::registerTypes (const char *uri) { Q_ASSERT(uri == QLatin1String("org.kube.framework.theme")); qmlRegisterSingletonType(uri, 1, 0, "ColorPalette", colorpaletteInstace); + qmlRegisterSingletonType(uri, 1, 0, "Unit", unitInstace); } diff --git a/framework/theme/unit.cpp b/framework/theme/unit.cpp new file mode 100644 index 00000000..1f3803cb --- /dev/null +++ b/framework/theme/unit.cpp @@ -0,0 +1,29 @@ +/* + 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 "unit.h" + +Unit::Unit(QObject *parent) : QObject(parent), m_size(5) +{ + +} + +int Unit::size() const +{ + return m_size; +} \ No newline at end of file diff --git a/framework/theme/unit.h b/framework/theme/unit.h new file mode 100644 index 00000000..bd9b58f0 --- /dev/null +++ b/framework/theme/unit.h @@ -0,0 +1,38 @@ +/* + 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 + + +class Unit : public QObject +{ + Q_OBJECT + Q_PROPERTY (int size READ size NOTIFY unitChanged) + + +public: + explicit Unit(QObject *parent = Q_NULLPTR); + + int size() const; + +signals: + void unitChanged(); + +private: + int m_size; +}; -- cgit v1.2.3