Commit 84022a09 authored by Thomas Hartmann's avatar Thomas Hartmann
Browse files

Add cppdemoproject

parent 1b18bd35
# This file is used to ignore files which are generated
# ----------------------------------------------------------------------------
*~
*.autosave
*.a
*.core
*.moc
*.o
*.obj
*.orig
*.rej
*.so
*.so.*
*_pch.h.cpp
*_resource.rc
*.qm
.#*
*.*#
core
!core/
tags
.DS_Store
.directory
*.debug
Makefile*
*.prl
*.app
moc_*.cpp
ui_*.h
qrc_*.cpp
Thumbs.db
*.res
*.rc
/.qmake.cache
/.qmake.stash
# qtcreator generated files
*.pro.user*
# xemacs temporary files
*.flc
# Vim temporary files
.*.swp
# Visual Studio generated files
*.ib_pdb_index
*.idb
*.ilk
*.pdb
*.sln
*.suo
*.vcproj
*vcproj.*.*.user
*.ncb
*.sdf
*.opensdf
*.vcxproj
*vcxproj.*
# MinGW generated files
*.Debug
*.Release
# Python byte code
*.pyc
# Binaries
# --------
*.dll
*.exe
cmake_minimum_required(VERSION 3.14)
project(demoproject LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
list(APPEND QML_IMPORT_PATH "${CMAKE_CURRENT_SOURCE_DIR}/qml/imports")
list(APPEND QML_IMPORT_PATH "${CMAKE_CURRENT_SOURCE_DIR}/qml/cppImports")
set(QML_IMPORT_PATH ${QML_IMPORT_PATH}
CACHE STRING "Qt Creator 4.1 extra qml import paths"
FORCE
)
# QtCreator supports the following variables for Android, which are identical to qmake Android variables.
# Check http://doc.qt.io/qt-5/deployment-android.html for more information.
# They need to be set before the find_package(Qt5 ...) call.
#if(ANDROID)
# set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
# if (ANDROID_ABI STREQUAL "armeabi-v7a")
# set(ANDROID_EXTRA_LIBS
# ${CMAKE_CURRENT_SOURCE_DIR}/path/to/libcrypto.so
# ${CMAKE_CURRENT_SOURCE_DIR}/path/to/libssl.so)
# endif()
#endif()
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core Quick REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Quick REQUIRED)
if(ANDROID)
add_library(demoproject SHARED
main.cpp
cppbackend.cpp
cppbackend.h
qml.qrc
qdsimports.qrc
)
else()
add_executable(demoproject
main.cpp
cppbackend.cpp
cppbackend.h
qml.qrc
qdsimports.qrc
)
endif()
target_compile_definitions(demoproject
PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>)
target_link_libraries(demoproject
PRIVATE Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Quick)
#include "cppbackend.h"
CppBackend::CppBackend(QObject *parent) : QObject(parent) {
m_timer.setInterval(3);
m_timer.setSingleShot(false);
m_timer.start();
connect(&m_timer, &QTimer::timeout, this, [this]() {
if (m_steps >= 1010 || m_steps < 0)
m_direction = m_direction * -1;
m_steps += m_direction;
waterActiveChanged();
percentageChanged();
timeChanged();
});
}
int CppBackend::percentage() const { return m_steps / 10; }
QString CppBackend::time() const {
return "00:" + QString::number(60 - (m_steps / 35));
}
bool CppBackend::waterActive() const { return m_steps > 200 && m_steps < 800; }
#ifndef CPPBACKEND_H
#define CPPBACKEND_H
#include <QObject>
#include <QQmlEngine>
#include <QTimer>
class CppBackend : public QObject
{
Q_OBJECT
Q_PROPERTY(int percentage READ percentage NOTIFY percentageChanged)
Q_PROPERTY(QString time READ time NOTIFY timeChanged)
Q_PROPERTY(bool waterActive READ waterActive NOTIFY waterActiveChanged)
public:
explicit CppBackend(QObject *parent = nullptr);
signals:
void percentageChanged();
void timeChanged();
void waterActiveChanged();
private:
int percentage() const;
QString time() const;
bool waterActive() const;
QTimer m_timer;
int m_steps = 0;
int m_direction = 1;
};
#endif // CPPBACKEND_H
#include <cppbackend.h>
#include <QGuiApplication>
#include <QQmlApplicationEngine>
int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);
qmlRegisterSingletonType<CppBackend>(
"backend", 1, 0, "BackendObject",
[](QQmlEngine *, QJSEngine *) { return new CppBackend; });
QQmlApplicationEngine engine;
const QUrl url(QStringLiteral("qrc:/qml/main.qml"));
QObject::connect(
&engine, &QQmlApplicationEngine::objectCreated, &app,
[url](QObject *obj, const QUrl &objUrl) {
if (!obj && url == objUrl)
QCoreApplication::exit(-1);
},
Qt::QueuedConnection);
engine.addImportPath("qrc:/qml/imports/"); // Adding imports paths
engine.addImportPath("qrc:/qml/cppImports/");
engine.load(url);
return app.exec();
}
<RCC>
<qresource prefix="/">
<file>qml/cppImports/QtQuick/Studio/Components/ArcItem.qml</file>
<file>qml/cppImports/QtQuick/Studio/Components/BorderItem.qml</file>
<file>qml/cppImports/QtQuick/Studio/Components/FlipableItem.qml</file>
<file>qml/cppImports/QtQuick/Studio/Components/GroupItem.qml</file>
<file>qml/cppImports/QtQuick/Studio/Components/IsoItem.qml</file>
<file>qml/cppImports/QtQuick/Studio/Components/PieItem.qml</file>
<file>qml/cppImports/QtQuick/Studio/Components/qmldir</file>
<file>qml/cppImports/QtQuick/Studio/Components/RectangleItem.qml</file>
<file>qml/cppImports/QtQuick/Studio/Components/SvgPathItem.qml</file>
<file>qml/cppImports/QtQuick/Studio/Components/TriangleItem.qml</file>
<file>qml/cppImports/QtQuick/Studio/LogicHelper/AndOperator.qml</file>
<file>qml/cppImports/QtQuick/Studio/LogicHelper/BidirectionalBinding.qml</file>
<file>qml/cppImports/QtQuick/Studio/LogicHelper/MinMaxMapper.qml</file>
<file>qml/cppImports/QtQuick/Studio/LogicHelper/NotOperator.qml</file>
<file>qml/cppImports/QtQuick/Studio/LogicHelper/OrOperator.qml</file>
<file>qml/cppImports/QtQuick/Studio/LogicHelper/qmldir</file>
<file>qml/cppImports/QtQuick/Studio/LogicHelper/RangeMapper.qml</file>
<file>qml/cppImports/QtQuick/Studio/LogicHelper/StringMapper.qml</file>
<file>qml/cppImports/FlowView/DefaultFlowEffect.qml</file>
<file>qml/cppImports/FlowView/FlowActionArea.qml</file>
<file>qml/cppImports/FlowView/FlowDecision.qml</file>
<file>qml/cppImports/FlowView/FlowEffect.qml</file>
<file>qml/cppImports/FlowView/FlowFadeEffect.qml</file>
<file>qml/cppImports/FlowView/FlowItem.qml</file>
<file>qml/cppImports/FlowView/FlowMoveEffect.qml</file>
<file>qml/cppImports/FlowView/FlowPushEffect.qml</file>
<file>qml/cppImports/FlowView/FlowPushLeftEffect.qml</file>
<file>qml/cppImports/FlowView/FlowPushRightEffect.qml</file>
<file>qml/cppImports/FlowView/FlowPushUpEffect.qml</file>
<file>qml/cppImports/FlowView/FlowSlideDownEffect.qml</file>
<file>qml/cppImports/FlowView/FlowSlideLeftEffect.qml</file>
<file>qml/cppImports/FlowView/FlowSlideRightEffect.qml</file>
<file>qml/cppImports/FlowView/FlowSlideUpEffect.qml</file>
<file>qml/cppImports/FlowView/FlowState.qml</file>
<file>qml/cppImports/FlowView/FlowTransition.qml</file>
<file>qml/cppImports/FlowView/FlowTransitionList.qml</file>
<file>qml/cppImports/FlowView/FlowView.qml</file>
<file>qml/cppImports/FlowView/FlowWildcard.qml</file>
<file>qml/cppImports/FlowView/plugins.qmltypes</file>
<file>qml/cppImports/FlowView/qmldir</file>
<file>qml/cppImports/FlowView/SwipeInteraction.qml</file>
<file>qml/cppImports/QtQuick/Studio/Components/ArcArrow.qml</file>
<file>qml/cppImports/QtQuick/Studio/Components/plugins.qmltypes</file>
<file>qml/cppImports/QtQuick/Studio/Components/StraightArrow.qml</file>
<file>qml/cppImports/QtQuick/Studio/Effects/BlendEffect.qml</file>
<file>qml/cppImports/QtQuick/Studio/Effects/BlendItem.qml</file>
<file>qml/cppImports/QtQuick/Studio/Effects/BrightnessContrastEffect.qml</file>
<file>qml/cppImports/QtQuick/Studio/Effects/BrightnessContrastItem.qml</file>
<file>qml/cppImports/QtQuick/Studio/Effects/ColorizeEffect.qml</file>
<file>qml/cppImports/QtQuick/Studio/Effects/ColorizeItem.qml</file>
<file>qml/cppImports/QtQuick/Studio/Effects/ColorOverlayEffect.qml</file>
<file>qml/cppImports/QtQuick/Studio/Effects/ColorOverlayItem.qml</file>
<file>qml/cppImports/QtQuick/Studio/Effects/DesaturationEffect.qml</file>
<file>qml/cppImports/QtQuick/Studio/Effects/DesaturationItem.qml</file>
<file>qml/cppImports/QtQuick/Studio/Effects/DirectionalBlurEffect.qml</file>
<file>qml/cppImports/QtQuick/Studio/Effects/DirectionalBlurItem.qml</file>
<file>qml/cppImports/QtQuick/Studio/Effects/DisplaceEffect.qml</file>
<file>qml/cppImports/QtQuick/Studio/Effects/DisplaceItem.qml</file>
<file>qml/cppImports/QtQuick/Studio/Effects/DropShadowEffect.qml</file>
<file>qml/cppImports/QtQuick/Studio/Effects/DropShadowItem.qml</file>
<file>qml/cppImports/QtQuick/Studio/Effects/FastBlurEffect.qml</file>
<file>qml/cppImports/QtQuick/Studio/Effects/FastBlurItem.qml</file>
<file>qml/cppImports/QtQuick/Studio/Effects/GammaAdjustEffect.qml</file>
<file>qml/cppImports/QtQuick/Studio/Effects/GammaAdjustItem.qml</file>
<file>qml/cppImports/QtQuick/Studio/Effects/GaussianBlurEffect.qml</file>
<file>qml/cppImports/QtQuick/Studio/Effects/GaussianBlurItem.qml</file>
<file>qml/cppImports/QtQuick/Studio/Effects/GlowEffect.qml</file>
<file>qml/cppImports/QtQuick/Studio/Effects/GlowItem.qml</file>
<file>qml/cppImports/QtQuick/Studio/Effects/HueSaturationEffect.qml</file>
<file>qml/cppImports/QtQuick/Studio/Effects/HueSaturationItem.qml</file>
<file>qml/cppImports/QtQuick/Studio/Effects/InnerShadowEffect.qml</file>
<file>qml/cppImports/QtQuick/Studio/Effects/InnerShadowItem.qml</file>
<file>qml/cppImports/QtQuick/Studio/Effects/LevelAdjustEffect.qml</file>
<file>qml/cppImports/QtQuick/Studio/Effects/LevelAdjustItem.qml</file>
<file>qml/cppImports/QtQuick/Studio/Effects/MaskedBlurEffect.qml</file>
<file>qml/cppImports/QtQuick/Studio/Effects/MaskedBlurItem.qml</file>
<file>qml/cppImports/QtQuick/Studio/Effects/MaskItem.qml</file>
<file>qml/cppImports/QtQuick/Studio/Effects/OpacityMaskEffect.qml</file>
<file>qml/cppImports/QtQuick/Studio/Effects/OpacityMaskItem.qml</file>
<file>qml/cppImports/QtQuick/Studio/Effects/plugins.qmltypes</file>
<file>qml/cppImports/QtQuick/Studio/Effects/qmldir</file>
<file>qml/cppImports/QtQuick/Studio/Effects/RadialBlurEffect.qml</file>
<file>qml/cppImports/QtQuick/Studio/Effects/RadialBlurItem.qml</file>
<file>qml/cppImports/QtQuick/Studio/Effects/RecursiveBlurEffect.qml</file>
<file>qml/cppImports/QtQuick/Studio/Effects/RecursiveBlurItem.qml</file>
<file>qml/cppImports/QtQuick/Studio/Effects/RotationItem.qml</file>
<file>qml/cppImports/QtQuick/Studio/Effects/SaturationItem.qml</file>
<file>qml/cppImports/QtQuick/Studio/Effects/ThresholdMaskEffect.qml</file>
<file>qml/cppImports/QtQuick/Studio/Effects/ThresholdMaskItem.qml</file>
<file>qml/cppImports/QtQuick/Studio/Effects/ZoomBlurEffect.qml</file>
<file>qml/cppImports/QtQuick/Studio/Effects/ZoomBlurItem.qml</file>
<file>qml/cppImports/QtQuick/Studio/EventSimulator/EventSimulator.qml</file>
<file>qml/cppImports/QtQuick/Studio/EventSimulator/EventSimulatorDelegate.qml</file>
<file>qml/cppImports/QtQuick/Studio/EventSimulator/plugins.qmltypes</file>
<file>qml/cppImports/QtQuick/Studio/EventSimulator/qmldir</file>
<file>qml/cppImports/QtQuick/Studio/EventSystem/EventListener.qml</file>
<file>qml/cppImports/QtQuick/Studio/EventSystem/EventSystem.qml</file>
<file>qml/cppImports/QtQuick/Studio/EventSystem/plugins.qmltypes</file>
<file>qml/cppImports/QtQuick/Studio/EventSystem/qmldir</file>
<file>qml/cppImports/QtQuick/Studio/LogicHelper/plugins.qmltypes</file>
<file>qml/cppImports/QtQuick/Studio/MultiText/MultiTextElement.qml</file>
<file>qml/cppImports/QtQuick/Studio/MultiText/MultiTextException.qml</file>
<file>qml/cppImports/QtQuick/Studio/MultiText/MultiTextItem.qml</file>
<file>qml/cppImports/QtQuick/Studio/MultiText/plugins.qmltypes</file>
<file>qml/cppImports/QtQuick/Studio/MultiText/qmldir</file>
</qresource>
</RCC>
<RCC>
<qresource prefix="/">
<file>qml/main.qml</file>
<file>qml/imports/qdsproject/Constants.qml</file>
<file>qml/imports/qdsproject/DirectoryFontLoader.qml</file>
<file>qml/imports/qdsproject/EventListModel.qml</file>
<file>qml/imports/qdsproject/EventListSimulator.qml</file>
<file>qml/imports/qdsproject/qmldir</file>
<file>qml/WashingMachineHome/ArcDial.ui.qml</file>
<file>qml/WashingMachineHome/MainFile.ui.qml</file>
<file>qml/WashingMachineHome/SpinIcon.ui.qml</file>
<file>qml/WashingMachineHome/TimerElement.ui.qml</file>
<file>qml/WashingMachineHome/assets/backgroundElipse1.png</file>
<file>qml/WashingMachineHome/assets/mainBackground1.png</file>
<file>qml/WashingMachineHome/assets/outlineElipse1.png</file>
</qresource>
</RCC>
import QtQuick 2.8
import backend 1.0
import QtQuick.Studio.Components 1.0
import QtQuick.Studio.LogicHelper 1.0
import QtQuick.Timeline 1.0
Item {
id: arcDial
width: 400
height: 403
Item {
id: backgroundElipse
x: 0
y: 0
width: 400
height: 400
Image {
id: backgroundElipse1
x: 0
y: 0
source: "assets/backgroundElipse1.png"
}
}
Item {
id: outlineElipse
x: 0
y: 0
width: 400
height: 400
Image {
id: outlineElipse1
x: 0
y: 0
source: "assets/outlineElipse1.png"
ArcItem {
id: arc
x: 16
y: 14
width: 367
height: 369
end: rangeMapper.output
capStyle: 32
begin: -180
strokeWidth: 14
strokeColor: "#e9e755"
fillColor: "#00000000"
}
}
}
TimerElement {
id: timerElement
x: 59
y: 115
width: 282
height: 194
_45Text: BackendObject.time
minutesRemainingText: "TIME REMAINING"
}
RangeMapper {
id: rangeMapper
input: BackendObject.percentage
outputMaximum: 360
}
}
/*##^##
Designer {
D{i:0;height:403;width:400}D{i:2;uuid:"8d9b4f5a-f5a1-55f4-a435-9bd7ad008db2-1"}D{i:1;uuid:"8d9b4f5a-f5a1-55f4-a435-9bd7ad008db2"}
D{i:5}D{i:4;uuid:"cbaf20f4-f684-5d8e-ac5f-aec576c06aed-1"}D{i:3;uuid:"cbaf20f4-f684-5d8e-ac5f-aec576c06aed"}
D{i:6;uuid:"836e273f-ed25-5887-908d-f5a22d06d048"}
}
##^##*/
import QtQuick 2.8
import backend 1.0
Rectangle {
id: mainFile
width: 500
height: 987
color: "transparent"
property alias spinLabelText: spinLabel.text
property alias fabricLabelText: fabricLabel.text
clip: true
Item {
id: mainBackground
x: 0
y: 0
width: 500
height: 987
Image {
id: mainBackground1
x: 0
y: 0
source: "assets/mainBackground1.png"
}
}
ArcDial {
id: arcDial
x: 51
y: 205
width: 400
height: 403
}
Text {
id: spinLabel
x: 0
y: 662
width: 501
height: 42
color: "#34bb27"
text: "SPIN CYCLE"
font.pixelSize: 24
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
wrapMode: Text.Wrap
font.family: "Roboto"
font.weight: Font.Normal
}
Text {
id: fabricLabel
x: 98
y: 54
width: 306
height: 42
color: "#ffffff"
text: "COTTON 30"
font.pixelSize: 30
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
wrapMode: Text.Wrap
font.family: "Roboto"
font.weight: Font.Normal
}
SpinIcon {
id: spinIcon
x: 153
y: 758
width: 197
height: 133
}
}
/*##^##
Designer {
D{i:0;formeditorZoom:0.5;uuid:"0f5c378d-b572-50d7-bcf9-b29189cd8f65"}D{i:2;uuid:"6e1f33f8-a437-59e5-a60e-8f8645218df5-1"}
D{i:1;uuid:"6e1f33f8-a437-59e5-a60e-8f8645218df5"}D{i:3;uuid:"1838a6c9-130c-5572-a4cf-c5a45e7ee7da"}
D{i:4;uuid:"dfca6a4c-8d35-5db4-8a8d-3d74e1ec9eba"}D{i:5;uuid:"5f3bd6d6-c08e-5fba-b908-d992035ecd02"}
D{i:6;uuid:"5b61d918-0486-52b3-90f3-fa32da5aba4b"}
}
##^##*/
import QtQuick 2.15
import QtQuick.Controls 2.15
import qdsproject 1.0
import QtQuick.Studio.Components 1.0
import backend 1.0
import QtQuick.Studio.LogicHelper 1.0
import QtGraphicalEffects 1.0
Rectangle {
id: rectangle
width: Constants.width
height: Constants.height
color: Constants.backgroundColor
Rectangle {
id: rectangle1
x: 480
y: 310
width: 344
height: 200
color: "#047eff"
}
Text {
text: BackendObject.time
anchors.centerIn: parent
}
ArcItem {
x: 490
y: 210
width: 300
height: 300
capStyle: 32
strokeWidth: 20
strokeColor: "#000080"
fillColor: "#00000000"
end: rangeMapper.output
RangeMapper {
id: rangeMapper
outputMinimum: 0
outputMaximum: 360
input: BackendObject.percentage
inputMaximum: 100
inputMinimum: 0
}
}
states: [
State {
name: "no water"
when: !BackendObject.waterActive
PropertyChanges {
target: rectangle1
opacity: 0
}
},
State {
name: "water"
when: BackendObject.waterActive
}
]
}
import QtQuick 2.8
import QtQuick.Studio.Components 1.0
import QtQuick.Timeline 1.0
import backend 1.0
Item {
id: spinIcon
width: 197
height: 133
state: "washing"
SvgPathItem {
id: frame
x: 0
y: 0
width: 197
height: 133
fillColor: "#ffffff"
strokeWidth: 1
strokeColor: "transparent"
path: "M 185.5974587496495 4.7210499561906625 C 186.17714240289519 1.5429677789503073 189.36542052533548 -0.4794481729177819 192.26383879156398 0.09838496629140854 C 195.45209902638058 0.676218105500599 197.4809757706653 3.854299911418146 196.90129211741962 6.743465501371867 L 175.45300688489752 118.55417403061972 C 174.00379775178328 127.22167051756827 167.04758809225893 133 158.64217497823105 133 L 38.64766131174639 133 C 30.242248197718503 133 22.996204519661024 127.2216693859178 21.54699538654678 118.84308892043066 L 0.09870004787220152 7.032382654483732 C -0.4809836053734964 3.854300477243377 1.547909207604934 0.676218105500599 4.73616944242154 0.09838496629140854 C 7.9244296772381455 -0.4794481729177819 11.112689344193681 1.5429677789503073 11.69237299743938 4.7210499561906625 L 33.1406673157386 116.53176074873943 C 33.72035096898429 119.13200975140651 36.03908387838388 121.15442614532557 38.93750214461237 121.15442614532557 L 158.9320294397627 121.15442614532557 C 161.83044770599116 121.15442614532557 164.14918061539078 119.13200975140651 164.72886426863647 116.53176074873943 L 185.5974587496495 4.7210499561906625 Z"
}
Item {
id: mask
width: 200
height: 200