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') 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