Browse Source

added quick project skeletons

managed to get the example working...
pull/2/head
Skycoder42 7 years ago
parent
commit
8c7afac64c
  1. 1
      .qmake.conf
  2. 3
      examples/examples.pro
  3. 70
      examples/mvvmquick/SampleQuick/SampleQuick.pro
  4. 22
      examples/mvvmquick/SampleQuick/main.cpp
  5. 6
      examples/mvvmquick/SampleQuick/main.qml
  6. 5
      examples/mvvmquick/SampleQuick/qml.qrc
  7. 5
      examples/mvvmquick/mvvmquick.pro
  8. 1
      examples/mvvmwidgets/mvvmwidgets.pro
  9. 4
      src/imports/imports.pro
  10. 11
      src/imports/mvvmquick/App.qml
  11. 13
      src/imports/mvvmquick/PresenterProgress.qml
  12. 95
      src/imports/mvvmquick/PresentingStackView.qml
  13. 39
      src/imports/mvvmquick/mvvmquick.pro
  14. 19
      src/imports/mvvmquick/plugins.qmltypes
  15. 8
      src/imports/mvvmquick/qmldir
  16. 6
      src/imports/mvvmquick/qqmlquickpresenter.cpp
  17. 18
      src/imports/mvvmquick/qqmlquickpresenter.h
  18. 22
      src/imports/mvvmquick/qtmvvmquick_plugin.cpp
  19. 16
      src/imports/mvvmquick/qtmvvmquick_plugin.h
  20. 38
      src/mvvmcore/translations/qtmvvmcore_de.ts
  21. 38
      src/mvvmcore/translations/qtmvvmcore_template.ts
  22. 6
      src/mvvmquick/builddummy.cpp
  23. 12
      src/mvvmquick/builddummy.h
  24. 4
      src/mvvmquick/mvvmquick.pro
  25. 17
      src/mvvmquick/quickpresenter.cpp
  26. 26
      src/mvvmquick/quickpresenter.h
  27. 13
      src/mvvmwidgets/translations/qtmvvmwidgets_de.ts
  28. 13
      src/mvvmwidgets/translations/qtmvvmwidgets_template.ts
  29. 3
      src/src.pro

1
.qmake.conf

@ -1,6 +1,7 @@
load(qt_build_config)
CONFIG += warning_clean exceptions c++14
CONFIG += samples_in_build
win32:cross_compile: CONFIG += winrt
DEFINES += QT_DEPRECATED_WARNINGS QT_ASCII_CAST_WARNINGS

3
examples/examples.pro

@ -1,6 +1,7 @@
TEMPLATE = subdirs
SUBDIRS = mvvmcore \
mvvmwidgets
mvvmwidgets \
mvvmquick
CONFIG += ordered

70
examples/mvvmquick/SampleQuick/SampleQuick.pro

@ -0,0 +1,70 @@
TEMPLATE = app
QT += core gui qml quick mvvmquick
TARGET = SampleQuick
SOURCES += main.cpp
RESOURCES += qml.qrc
target.path = $$[QT_INSTALL_EXAMPLES]/mvvmquick/$$TARGET
INSTALLS += target
#not found by linker?
unix:!mac {
LIBS += -L$$OUT_PWD/../../../lib #required to make this the first place to search
LIBS += -L$$[QT_INSTALL_LIBS] -licudata
LIBS += -L$$[QT_INSTALL_LIBS] -licui18n
LIBS += -L$$[QT_INSTALL_LIBS] -licuuc
}
#add lib dir to rpath
mac: QMAKE_LFLAGS += '-Wl,-rpath,\'$$OUT_PWD/../../../lib\''
#link to core lib
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../../mvvmcore/SampleCore/release/ -lSampleCore
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../../mvvmcore/SampleCore/debug/ -lSampleCore
else:unix: LIBS += -L$$OUT_PWD/../../mvvmcore/SampleCore/ -lSampleCore
INCLUDEPATH += $$PWD/../../mvvmcore/SampleCore
DEPENDPATH += $$PWD/../../mvvmcore/SampleCore
win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../../mvvmcore/SampleCore/release/libSampleCore.a
else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../../mvvmcore/SampleCore/debug/libSampleCore.a
else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../../mvvmcore/SampleCore/release/SampleCore.lib
else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../../mvvmcore/SampleCore/debug/SampleCore.lib
else:unix: PRE_TARGETDEPS += $$OUT_PWD/../../mvvmcore/SampleCore/libSampleCore.a
#hacky code to make it possible to use the example from within a shadowed build
samples_in_build {
# first, create a fake qml imports dir
FAKEPATH = qml/de/skycoder42/qtmvvm/quick
ORIGPATH = ../../../../../../../../qml/de/skycoder42/qtmvvm/quick
QMLDEPPATH = $$PWD/../../../src/imports/mvvmquick
system($$QMAKE_MKDIR $$shell_quote($$shell_path($$FAKEPATH)))
# next, symlink all "compiled" files
build_symlink_target.target = create_qml_build_symlinks
build_symlink_target.commands += $$QMAKE_SYMBOLIC_LINK $$shell_path($$ORIGPATH/libdeclarative_mvvmquick.so) $$shell_quote($$shell_path($$FAKEPATH/libdeclarative_mvvmquick.so)) \
$$escape_expand(\n\t)$$QMAKE_SYMBOLIC_LINK $$shell_path($$ORIGPATH/plugins.qmltypes) $$shell_quote($$shell_path($$FAKEPATH/plugins.qmltypes)) \
$$escape_expand(\n\t)$$QMAKE_SYMBOLIC_LINK $$shell_path($$ORIGPATH/qmldir) $$shell_quote($$shell_path($$FAKEPATH/qmldir))
QMAKE_EXTRA_TARGETS += build_symlink_target
# next, prepare compiler to symlink all the qml files
qml_symlink_compiler.name = symlink ${QMAKE_FILE_IN}
qml_symlink_compiler.input = QML_MODULE_DEPFILES
qml_symlink_compiler.variable_out = QML_MODULE_DEPFILES_LINKS
qml_symlink_compiler.output = $$FAKEPATH/${QMAKE_FILE_BASE}.qml
qml_symlink_compiler.commands = $$QMAKE_SYMBOLIC_LINK $$QMLDEPPATH/${QMAKE_FILE_BASE}.qml ${QMAKE_FILE_OUT}
qml_symlink_compiler.depends = create_qml_build_symlinks
qml_symlink_compiler.CONFIG += no_link target_predeps
QMAKE_EXTRA_COMPILERS += qml_symlink_compiler
#finally, add the files to make it work
QML_MODULE_DEPFILES += $$files($$QMLDEPPATH/*.qml)
# also, add it as import path for QtCreator and the src files
QML_IMPORT_PATH = $$OUT_PWD/qml/
DEFINES += QML_PATH=\\\"$$QML_IMPORT_PATH\\\"
}

22
examples/mvvmquick/SampleQuick/main.cpp

@ -0,0 +1,22 @@
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <samplecoreapp.h>
QTMVVM_REGISTER_CORE_APP(SampleCoreApp)
int main(int argc, char *argv[])
{
qputenv("QML2_IMPORT_PATH", QML_PATH);
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
if (engine.rootObjects().isEmpty())
return -1;
return app.exec();
}

6
examples/mvvmquick/SampleQuick/main.qml

@ -0,0 +1,6 @@
import QtQuick 2.10
import de.skycoder42.qtmvvm.quick 1.0
App {
title: qsTr("Hello World")
}

5
examples/mvvmquick/SampleQuick/qml.qrc

@ -0,0 +1,5 @@
<RCC>
<qresource prefix="/">
<file>main.qml</file>
</qresource>
</RCC>

5
examples/mvvmquick/mvvmquick.pro

@ -0,0 +1,5 @@
TEMPLATE = subdirs
QT_FOR_CONFIG += quick
SUBDIRS += \
SampleQuick

1
examples/mvvmwidgets/mvvmwidgets.pro

@ -1,4 +1,5 @@
TEMPLATE = subdirs
QT_FOR_CONFIG += widgets
SUBDIRS += \
SampleWidgets

4
src/imports/imports.pro

@ -0,0 +1,4 @@
TEMPLATE = subdirs
SUBDIRS += \
mvvmquick

11
src/imports/mvvmquick/App.qml

@ -0,0 +1,11 @@
import QtQuick 2.10
import QtQuick.Controls 2.3
ApplicationWindow {
id: _root
visible: true
width: 360
height: 520
PresenterProgress {}
}

13
src/imports/mvvmquick/PresenterProgress.qml

@ -0,0 +1,13 @@
import QtQuick 2.10
import QtQuick.Controls 2.3
import de.skycoder42.qtmvvm.quick 1.0
ProgressBar {
visible: QuickPresenter.viewLoading
value: QuickPresenter.loadingProgress
anchors.left: parent.left
anchors.right: parent.right
anchors.top: parent.top
z: 10
}

95
src/imports/mvvmquick/PresentingStackView.qml

@ -0,0 +1,95 @@
import QtQuick 2.10
import QtQuick.Controls 2.3
import de.skycoder42.qtmvvm.quick 1.0
StackView {
id: mainStack
anchors.fill: parent
readonly property int animDuration: 150
readonly property int opDuration: 75
function presentItem(item) {
if(push(item)) {
QuickPresenter.qmlPresenter.opened(item);
return true;
} else
return false;
}
function withdrawItem(item) {
if(currentItem === item) {
if(pop()) {
QuickPresenter.qmlPresenter.closed(item);
return true;
}
}
return false;
}
function closeAction() {
if(typeof mainStack.currentItem.closeAction != "undefined") {
if(mainStack.currentItem.closeAction())
return true;
}
if(mainStack.depth <= 1)
return false;
else {
var item = mainStack.pop();
if(item) {
QuickPresenter.qmlPresenter.closed(item);
return true;
} else
return false;
}
}
pushEnter: Transition {
PropertyAnimation {
property: "y"
easing.type: Easing.InOutQuad
from: height * 0.3
to: 0
duration: mainStack.animDuration
}
PropertyAnimation {
property: "opacity"
from: 0.0
to: 1.0
duration: mainStack.opDuration
}
}
pushExit: Transition {
PauseAnimation {
duration: mainStack.animDuration
}
}
popEnter: Transition {
PauseAnimation {
duration: mainStack.animDuration
}
}
popExit: Transition {
PropertyAnimation {
property: "y"
easing.type: Easing.InOutQuad
from: 0
to: height * 0.3
duration: mainStack.animDuration
}
SequentialAnimation {
PauseAnimation {
duration: mainStack.animDuration - mainStack.opDuration
}
PropertyAnimation {
id: pp1
property: "opacity"
from: 1.0
to: 0.0
duration: mainStack.opDuration
}
}
}
}

39
src/imports/mvvmquick/mvvmquick.pro

@ -0,0 +1,39 @@
QT += core qml quick mvvmquick
CXX_MODULE = mvvmquick
TARGETPATH = de/skycoder42/qtmvvm/quick
TARGET = declarative_mvvmquick
IMPORT_VERSION = 1.0
HEADERS += \
qtmvvmquick_plugin.h \
qqmlquickpresenter.h
SOURCES += \
qtmvvmquick_plugin.cpp \
qqmlquickpresenter.cpp
QML_FILES += \
App.qml \
PresentingStackView.qml \
PresenterProgress.qml
OTHER_FILES += qmldir
generate_qmltypes {
typeextra1.target = qmltypes
typeextra1.depends += export LD_LIBRARY_PATH := "$$shadowed($$dirname(_QMAKE_CONF_))/lib/:$(LD_LIBRARY_PATH)"
qmltypes.depends += typeextra1
typeextra2.target = qmltypes
typeextra2.depends += export QML2_IMPORT_PATH := "$$shadowed($$dirname(_QMAKE_CONF_))/qml/"
qmltypes.depends += typeextra2
QMAKE_EXTRA_TARGETS += typeextra1 typeextra2
}
load(qml_plugin)
generate_qmltypes {
mfirst.target = all
mfirst.depends += qmltypes
QMAKE_EXTRA_TARGETS += mfirst
}

19
src/imports/mvvmquick/plugins.qmltypes

@ -0,0 +1,19 @@
import QtQuick.tooling 1.2
// This file describes the plugin-supplied types contained in the library.
// It is used for QML tooling purposes only.
//
// This file was auto-generated by:
// 'qmlplugindump -nonrelocatable de.skycoder42.qtmvvm.quick 1.0'
Module {
dependencies: ["QtQuick 2.8"]
Component {
name: "QtMvvm::QQmlQuickPresenter"
prototype: "QObject"
exports: ["de.skycoder42.qtmvvm.quick/QuickPresenter 1.0"]
isCreatable: false
isSingleton: true
exportMetaObjectRevisions: [0]
}
}

8
src/imports/mvvmquick/qmldir

@ -0,0 +1,8 @@
module de.skycoder42.qtmvvm.quick
plugin declarative_mvvmquick
classname QtMvvmQuickDeclarativeModule
typeinfo plugins.qmltypes
App 1.0 App.qml
PresenterProgress 1.0 PresenterProgress.qml
PresentingStackView 1.0 PresentingStackView.qml

6
src/imports/mvvmquick/qqmlquickpresenter.cpp

@ -0,0 +1,6 @@
#include "qqmlquickpresenter.h"
using namespace QtMvvm;
QQmlQuickPresenter::QQmlQuickPresenter(QObject *parent) :
QObject(parent)
{}

18
src/imports/mvvmquick/qqmlquickpresenter.h

@ -0,0 +1,18 @@
#ifndef QTMVVM_QQMLQUICKPRESENTER_H
#define QTMVVM_QQMLQUICKPRESENTER_H
#include <QObject>
namespace QtMvvm {
class QQmlQuickPresenter : public QObject
{
Q_OBJECT
public:
explicit QQmlQuickPresenter(QObject *parent = nullptr);
};
}
#endif // QTMVVM_QQMLQUICKPRESENTER_H

22
src/imports/mvvmquick/qtmvvmquick_plugin.cpp

@ -0,0 +1,22 @@
#include "qtmvvmquick_plugin.h"
#include <QtQml>
#include "qqmlquickpresenter.h"
static QObject *createQuickPresenterQmlSingleton(QQmlEngine *qmlEngine, QJSEngine *jsEngine)
{
Q_UNUSED(jsEngine)
return new QtMvvm::QQmlQuickPresenter(qmlEngine);
}
QtMvvmQuickDeclarativeModule::QtMvvmQuickDeclarativeModule(QObject *parent) :
QQmlExtensionPlugin(parent)
{}
void QtMvvmQuickDeclarativeModule::registerTypes(const char *uri)
{
Q_ASSERT(qstrcmp(uri, "de.skycoder42.qtmvvm.quick") == 0);
qmlRegisterSingletonType<QtMvvm::QQmlQuickPresenter>(uri, 1, 0, "QuickPresenter", createQuickPresenterQmlSingleton);
}

16
src/imports/mvvmquick/qtmvvmquick_plugin.h

@ -0,0 +1,16 @@
#ifndef QTMVVMQUICK_PLUGIN_H
#define QTMVVMQUICK_PLUGIN_H
#include <QQmlExtensionPlugin>
class QtMvvmQuickDeclarativeModule : public QQmlExtensionPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid)
public:
QtMvvmQuickDeclarativeModule(QObject *parent = nullptr);
void registerTypes(const char *uri) override;
};
#endif // QTMVVMQUICK_PLUGIN_H

38
src/mvvmcore/translations/qtmvvmcore_de.ts

@ -1,4 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="de_DE">
<context>
<name>MessageConfig</name>
<message>
<location filename="../message.cpp" line="+372"/>
<source>%1 Version %2</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+14"/>
<source> (Built with %1)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+3"/>
<source>Qt-Version: &lt;a href=&quot;https://www.qt.io/&quot;&gt;%1&lt;/a&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+14"/>
<source>Developed by: %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+3"/>
<source>Project Website: &lt;a href=&quot;%1&quot;&gt;%2&lt;/a&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+6"/>
<source>License: &lt;a href=&quot;%1&quot;&gt;%2&lt;/a&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+4"/>
<source>License: %1</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>

38
src/mvvmcore/translations/qtmvvmcore_template.ts

@ -1,4 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1">
<context>
<name>MessageConfig</name>
<message>
<location filename="../message.cpp" line="+372"/>
<source>%1 Version %2</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+14"/>
<source> (Built with %1)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+3"/>
<source>Qt-Version: &lt;a href=&quot;https://www.qt.io/&quot;&gt;%1&lt;/a&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+14"/>
<source>Developed by: %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+3"/>
<source>Project Website: &lt;a href=&quot;%1&quot;&gt;%2&lt;/a&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+6"/>
<source>License: &lt;a href=&quot;%1&quot;&gt;%2&lt;/a&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+4"/>
<source>License: %1</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>

6
src/mvvmquick/builddummy.cpp

@ -1,6 +0,0 @@
#include "builddummy.h"
builddummy::builddummy()
{
}

12
src/mvvmquick/builddummy.h

@ -1,12 +0,0 @@
#ifndef BUILDDUMMY_H
#define BUILDDUMMY_H
#include "qtmvvmquick_global.h"
class Q_MVVMQUICK_EXPORT builddummy
{
public:
builddummy();
};
#endif // BUILDDUMMY_H

4
src/mvvmquick/mvvmquick.pro

@ -4,10 +4,10 @@ QT = core gui widgets mvvmcore
HEADERS += \
qtmvvmquick_global.h \
builddummy.h
quickpresenter.h
SOURCES += \
builddummy.cpp
quickpresenter.cpp
TRANSLATIONS += \
translations/qtmvvmquick_de.ts \

17
src/mvvmquick/quickpresenter.cpp

@ -0,0 +1,17 @@
#include "quickpresenter.h"
using namespace QtMvvm;
QuickPresenter::QuickPresenter(QObject *parent) :
QObject(parent),
IPresenter()
{}
void QuickPresenter::present(QtMvvm::ViewModel *viewModel, const QVariantHash &params, QPointer<QtMvvm::ViewModel> parent)
{
}
void QuickPresenter::showDialog(const QtMvvm::MessageConfig &config, QtMvvm::MessageResult *result)
{
}

26
src/mvvmquick/quickpresenter.h

@ -0,0 +1,26 @@
#ifndef QTMVVM_QUICKPRESENTER_H
#define QTMVVM_QUICKPRESENTER_H
#include <QtCore/qobject.h>
#include <QtMvvmCore/ipresenter.h>
#include "QtMvvmQuick/qtmvvmquick_global.h"
namespace QtMvvm {
class Q_MVVMQUICK_EXPORT QuickPresenter : public QObject, public IPresenter
{
Q_OBJECT
Q_INTERFACES(QtMvvm::IPresenter)
public:
explicit QuickPresenter(QObject *parent = nullptr);
void present(ViewModel *viewModel, const QVariantHash &params, QPointer<ViewModel> parent) override;
void showDialog(const MessageConfig &config, MessageResult *result) override;
};
}
#endif // QTMVVM_QUICKPRESENTER_H

13
src/mvvmwidgets/translations/qtmvvmwidgets_de.ts

@ -1,4 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="de_DE">
<context>
<name>QtMvvm::WidgetsPresenter</name>
<message>
<location filename="../widgetspresenter.cpp" line="+214"/>
<source>About</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+16"/>
<source>About &amp;Qt</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>

13
src/mvvmwidgets/translations/qtmvvmwidgets_template.ts

@ -1,4 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1">
<context>
<name>QtMvvm::WidgetsPresenter</name>
<message>
<location filename="../widgetspresenter.cpp" line="+214"/>
<source>About</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+16"/>
<source>About &amp;Qt</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>

3
src/src.pro

@ -3,7 +3,8 @@ CONFIG += ordered
SUBDIRS += mvvmcore \
mvvmwidgets \
mvvmquick
mvvmquick \
imports
prepareRecursiveTarget(lrelease)
QMAKE_EXTRA_TARGETS += lrelease

Loading…
Cancel
Save