Skycoder42
7 years ago
29 changed files with 512 additions and 22 deletions
@ -1,6 +1,7 @@ |
|||
TEMPLATE = subdirs |
|||
|
|||
SUBDIRS = mvvmcore \ |
|||
mvvmwidgets |
|||
mvvmwidgets \ |
|||
mvvmquick |
|||
|
|||
CONFIG += ordered |
|||
|
@ -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\\\" |
|||
} |
@ -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(); |
|||
} |
@ -0,0 +1,6 @@ |
|||
import QtQuick 2.10 |
|||
import de.skycoder42.qtmvvm.quick 1.0 |
|||
|
|||
App { |
|||
title: qsTr("Hello World") |
|||
} |
@ -0,0 +1,5 @@ |
|||
<RCC> |
|||
<qresource prefix="/"> |
|||
<file>main.qml</file> |
|||
</qresource> |
|||
</RCC> |
@ -0,0 +1,5 @@ |
|||
TEMPLATE = subdirs |
|||
QT_FOR_CONFIG += quick |
|||
|
|||
SUBDIRS += \ |
|||
SampleQuick |
@ -1,4 +1,5 @@ |
|||
TEMPLATE = subdirs |
|||
QT_FOR_CONFIG += widgets |
|||
|
|||
SUBDIRS += \ |
|||
SampleWidgets |
|||
|
@ -0,0 +1,4 @@ |
|||
TEMPLATE = subdirs |
|||
|
|||
SUBDIRS += \ |
|||
mvvmquick |
@ -0,0 +1,11 @@ |
|||
import QtQuick 2.10 |
|||
import QtQuick.Controls 2.3 |
|||
|
|||
ApplicationWindow { |
|||
id: _root |
|||
visible: true |
|||
width: 360 |
|||
height: 520 |
|||
|
|||
PresenterProgress {} |
|||
} |
@ -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 |
|||
} |
@ -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 |
|||
} |
|||
} |
|||
} |
|||
} |
@ -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 |
|||
} |
@ -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] |
|||
} |
|||
} |
@ -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 |
@ -0,0 +1,6 @@ |
|||
#include "qqmlquickpresenter.h" |
|||
using namespace QtMvvm; |
|||
|
|||
QQmlQuickPresenter::QQmlQuickPresenter(QObject *parent) : |
|||
QObject(parent) |
|||
{} |
@ -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
|
@ -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); |
|||
} |
@ -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
|
@ -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: <a href="https://www.qt.io/">%1</a></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: <a href="%1">%2</a></source> |
|||
<translation type="unfinished"></translation> |
|||
</message> |
|||
<message> |
|||
<location line="+6"/> |
|||
<source>License: <a href="%1">%2</a></source> |
|||
<translation type="unfinished"></translation> |
|||
</message> |
|||
<message> |
|||
<location line="+4"/> |
|||
<source>License: %1</source> |
|||
<translation type="unfinished"></translation> |
|||
</message> |
|||
</context> |
|||
</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: <a href="https://www.qt.io/">%1</a></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: <a href="%1">%2</a></source> |
|||
<translation type="unfinished"></translation> |
|||
</message> |
|||
<message> |
|||
<location line="+6"/> |
|||
<source>License: <a href="%1">%2</a></source> |
|||
<translation type="unfinished"></translation> |
|||
</message> |
|||
<message> |
|||
<location line="+4"/> |
|||
<source>License: %1</source> |
|||
<translation type="unfinished"></translation> |
|||
</message> |
|||
</context> |
|||
</TS> |
|||
|
@ -1,6 +0,0 @@ |
|||
#include "builddummy.h" |
|||
|
|||
builddummy::builddummy() |
|||
{ |
|||
|
|||
} |
@ -1,12 +0,0 @@ |
|||
#ifndef BUILDDUMMY_H |
|||
#define BUILDDUMMY_H |
|||
|
|||
#include "qtmvvmquick_global.h" |
|||
|
|||
class Q_MVVMQUICK_EXPORT builddummy |
|||
{ |
|||
public: |
|||
builddummy(); |
|||
}; |
|||
|
|||
#endif // BUILDDUMMY_H
|
@ -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 ¶ms, QPointer<QtMvvm::ViewModel> parent) |
|||
{ |
|||
|
|||
} |
|||
|
|||
void QuickPresenter::showDialog(const QtMvvm::MessageConfig &config, QtMvvm::MessageResult *result) |
|||
{ |
|||
|
|||
} |
@ -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 ¶ms, QPointer<ViewModel> parent) override; |
|||
void showDialog(const MessageConfig &config, MessageResult *result) override; |
|||
}; |
|||
|
|||
} |
|||
|
|||
#endif // QTMVVM_QUICKPRESENTER_H
|
@ -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 &Qt</source> |
|||
<translation type="unfinished"></translation> |
|||
</message> |
|||
</context> |
|||
</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 &Qt</source> |
|||
<translation type="unfinished"></translation> |
|||
</message> |
|||
</context> |
|||
</TS> |
|||
|
Loading…
Reference in new issue