Browse Source

fixed project template

pull/2/head
Skycoder42 7 years ago
parent
commit
47ce6a0689
  1. 8
      ProjectTemplate/App.qml
  2. 48
      ProjectTemplate/app.cpp
  3. 13
      ProjectTemplate/app.h
  4. 44
      ProjectTemplate/control.cpp
  5. 34
      ProjectTemplate/control.h
  6. 20
      ProjectTemplate/core.pro
  7. BIN
      ProjectTemplate/guiapplication.png
  8. 27
      ProjectTemplate/qpmx_core.json
  9. 28
      ProjectTemplate/qpmx_quick.json
  10. 28
      ProjectTemplate/qpmx_widgets.json
  11. 22
      ProjectTemplate/quick.pro
  12. 4
      ProjectTemplate/quick.qrc
  13. 17
      ProjectTemplate/quick_main.cpp
  14. 50
      ProjectTemplate/view.qml
  15. 31
      ProjectTemplate/viewmodel.cpp
  16. 31
      ProjectTemplate/viewmodel.h
  17. 7
      ProjectTemplate/widgets.pro
  18. 20
      ProjectTemplate/widgets_main.cpp
  19. 24
      ProjectTemplate/window.cpp
  20. 11
      ProjectTemplate/window.h
  21. 5
      ProjectTemplate/window.ui
  22. 50
      ProjectTemplate/wizard.json
  23. 2
      README.md
  24. 3
      deploy.json
  25. 1
      examples/mvvmquick/SampleQuick/main.cpp

8
ProjectTemplate/App.qml

@ -1,6 +1,6 @@
import QtQuick 2.8
import de.skycoder42.qtmvvm.quick 1.0
App {
import QtQuick 2.10
import de.skycoder42.QtMvvm.Quick 1.0
QtMvvmApp {
title: qsTr("%{ProjectName}")
}

48
ProjectTemplate/app.cpp

@ -1,11 +1,18 @@
#include "%{AppHdrName}"
#include "%{VmHdrName}"
#include <QtCore/QCommandLineParser>
%{AppCn}::%{AppCn}(QObject *parent) :
CoreApp(parent),
mainControl(nullptr)
CoreApp(parent)
{
//register metatypes etc here, just like you would do in your main before call QCoreApplication::exec
QCoreApplication::setApplicationName(QStringLiteral("%{ProjectName}"));
QCoreApplication::setApplicationVersion(QStringLiteral("1.0.0"));
QCoreApplication::setOrganizationName(QStringLiteral("Example Organization"));
}
void %{AppCn}::performRegistrations()
{
//if you are using a qt resource (e.g. "%{AppQrcFile}"), initialize it here
@if '%{UseSettings}'
Q_INIT_RESOURCE(%{AppQrcName});
@ -14,28 +21,19 @@
@endif
}
void %{AppCn}::setupParser(QCommandLineParser &parser, bool &allowInvalid) const
{
CoreApp::setupParser(parser, allowInvalid);
//add additional command line arguments etc here
}
bool %{AppCn}::startApp(const QCommandLineParser &parser)
int %{AppCn}::startApp(const QStringList &arguments)
{
QCommandLineParser parser;
parser.addVersionOption();
parser.addHelpOption();
//add more options
//shows help or version automatically
if(autoShowHelpOrVersion(parser))
return true;
//use this method to create services, controls, etc
//create and show the inital control
mainControl = new %{ControlCn}(this);
showControl(mainControl);
return true;
}
void %{AppCn}::aboutToQuit()
{
//if you need to perform any cleanups, do it here
if(!autoParse(parser, arguments))
return EXIT_SUCCESS;
//show a viewmodel to complete the startup
show<%{VmCn}>();
return EXIT_SUCCESS;
}

13
ProjectTemplate/app.h

@ -1,11 +1,9 @@
#ifndef %{AppGuard}
#define %{AppGuard}
#include <coreapp.h>
#include <QtMvvmCore/CoreApp>
#include "%{ControlHdrName}"
class %{AppCn} : public CoreApp
class %{AppCn} : public QtMvvm::CoreApp
{
Q_OBJECT
@ -13,14 +11,11 @@ public:
explicit %{AppCn}(QObject *parent = nullptr);
protected:
void setupParser(QCommandLineParser &parser, bool &allowInvalid) const override;
bool startApp(const QCommandLineParser &parser) override;
void performRegistrations() override;
int startApp(const QStringList &arguments) override;
protected slots:
void aboutToQuit() override;
private:
%{ControlCn} *mainControl;
};
#undef coreApp

44
ProjectTemplate/control.cpp

@ -1,44 +0,0 @@
#include "%{ControlHdrName}"
@if '%{UseSettings}'
#include <settingscontrol.h>
@endif
%{ControlCn}::%{ControlCn}(QObject *parent) :
Control(parent),
_text(QStringLiteral("hello world"))
{}
QString %{ControlCn}::text() const
{
return _text;
}
@if '%{UseSettings}'
void %{ControlCn}::showSettings()
{
auto settings = new SettingsControl(this);
settings->setDeleteOnClose(true);
settings->show();
}
@endif
void %{ControlCn}::setText(QString text)
{
if (_text == text)
return;
_text = text;
emit textChanged(_text);
}
void %{ControlCn}::onShow()
{
qDebug("%{ControlName} gui is now visible");
//logic to execute when the gui is shown
}
void %{ControlCn}::onClose()
{
qDebug("%{ControlName} gui is now closed");
//logic to execute when the gui was closed
}

34
ProjectTemplate/control.h

@ -1,34 +0,0 @@
#ifndef %{ControlGuard}
#define %{ControlGuard}
#include <control.h>
class %{ControlCn} : public Control
{
Q_OBJECT
Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
public:
explicit %{ControlCn}(QObject *parent = nullptr);
void onShow() override;
void onClose() override;
QString text() const;
public slots:
@if '%{UseSettings}'
void showSettings();
@endif
void setText(QString text);
signals:
void textChanged(QString text);
private:
QString _text;
};
#endif // %{ControlGuard}

20
ProjectTemplate/core.pro

@ -1,7 +1,8 @@
TEMPLATE = lib
QT += core gui
CONFIG += c++11 staticlib #important because dlls are problematic
QT += mvvmcore
# Creating a static library is typically more efficient. You can still create a shared library if you want to
CONFIG += c++14 static
TARGET = %{CoreName}
@ -9,11 +10,11 @@ DEFINES += QT_DEPRECATED_WARNINGS
HEADERS += \\
%{AppHdrName} \\
%{ControlHdrName}
%{VmHdrName}
SOURCES += \\
%{AppSrcName} \\
%{ControlSrcName}
%{VmSrcName}
@if '%{UseSettings}'
RESOURCES += \\
@ -23,11 +24,10 @@ RESOURCES += \\
TRANSLATIONS += %{ProjectLowerName}_core_de.ts \\
%{ProjectLowerName}_core_template.ts
DISTFILES += $$TRANSLATIONS
@if '%{UseSettings}'
QTMVVM_SETTINGS_FILES = settings.xml
never_true_lupdate_only: SOURCES += .qtmvvm_settings_xml_ts.cppdummy
CONFIG += no_settings_ts_warn
QTMVVM_TS_SETTINGS = settings.xml
_never_true_condition: SOURCES += $$files($$PWD/.ts-dummy/*)
# Uncomment the following line to automatically generated and update settings translations when building
#PRE_TARGETDEPS += qtmvvm-tsgen
@endif
!ReleaseBuild:!DebugBuild:!system(qpmx -d $$shell_quote($$_PRO_FILE_PWD_) --qmake-run init $$QPMX_EXTRA_OPTIONS $$shell_quote($$QMAKE_QMAKE) $$shell_quote($$OUT_PWD)): error(qpmx initialization failed. Check the compilation log for details.)
else: include($$OUT_PWD/qpmx_generated.pri)

BIN
ProjectTemplate/guiapplication.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 831 B

27
ProjectTemplate/qpmx_core.json

@ -1,27 +0,0 @@
{
"dependencies": [
@if '%{UseSettings}'
{
"package": "de.skycoder42.qtmvvm.settings.core",
"provider": "qpm",
"version": "1.1.2"
},
@endif
{
"package": "de.skycoder42.qtmvvm.core",
"provider": "qpm",
"version": "1.1.1"
}
],
"license": {
"file": "",
"name": ""
},
"prcFile": "",
"priFile": "",
"priIncludes": [
],
"publishers": {
},
"source": false
}

28
ProjectTemplate/qpmx_quick.json

@ -1,28 +0,0 @@
{
"dependencies": [
@if '%{UseSettings}'
{
"package": "de.skycoder42.qtmvvm.settings.quick",
"provider": "qpm",
"version": "1.1.2"
},
@endif
{
"package": "de.skycoder42.qtmvvm.quick",
"provider": "qpm",
"version": "1.1.2"
}
],
"license": {
"file": "",
"name": ""
},
"prcFile": "",
"priFile": "",
"priIncludes": [
"../%{CoreName}"
],
"publishers": {
},
"source": false
}

28
ProjectTemplate/qpmx_widgets.json

@ -1,28 +0,0 @@
{
"dependencies": [
@if '%{UseSettings}'
{
"package": "de.skycoder42.qtmvvm.settings.widgets",
"provider": "qpm",
"version": "1.1.3"
},
@endif
{
"package": "de.skycoder42.qtmvvm.widgets",
"provider": "qpm",
"version": "1.1.2"
}
],
"license": {
"file": "",
"name": ""
},
"prcFile": "",
"priFile": "",
"priIncludes": [
"../%{CoreName}"
],
"publishers": {
},
"source": false
}

22
ProjectTemplate/quick.pro

@ -1,16 +1,10 @@
TEMPLATE = app
QT += core gui qml quick quickcontrols2
CONFIG += c++11
QT += quick mvvmquick
CONFIG += c++14
TARGET = %{QuickName}
# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH =
# Additional import path used to resolve QML modules just for Qt Quick Designer
QML_DESIGNER_IMPORT_PATH =
DEFINES += QT_DEPRECATED_WARNINGS
SOURCES += main.cpp
@ -21,11 +15,6 @@ RESOURCES += \\
TRANSLATIONS += %{ProjectLowerName}_quick_de.ts \\
%{ProjectLowerName}_quick_template.ts
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
# Link with core project
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../%{CoreName}/release/ -l%{CoreName}
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../%{CoreName}/debug/ -l%{CoreName}
@ -40,5 +29,8 @@ else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$OUT_PW
else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../%{CoreName}/debug/%{CoreName}.lib
else:unix: PRE_TARGETDEPS += $$OUT_PWD/../%{CoreName}/lib%{CoreName}.a
!ReleaseBuild:!DebugBuild:!system(qpmx -d $$shell_quote($$_PRO_FILE_PWD_) --qmake-run init $$QPMX_EXTRA_OPTIONS $$shell_quote($$QMAKE_QMAKE) $$shell_quote($$OUT_PWD)): error(qpmx initialization failed. Check the compilation log for details.)
else: include($$OUT_PWD/qpmx_generated.pri)
# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH =
# Additional import path used to resolve QML modules just for Qt Quick Designer
QML_DESIGNER_IMPORT_PATH =

4
ProjectTemplate/quick.qrc

@ -1,8 +1,8 @@
<RCC>
<qresource prefix="/qml">
<qresource prefix="/">
<file>App.qml</file>
</qresource>
<qresource prefix="/qml/views">
<qresource prefix="/qtmvvm/views">
<file>%{QuickQmlName}</file>
</qresource>
</RCC>

17
ProjectTemplate/quick_main.cpp

@ -1,18 +1,21 @@
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <quickpresenter.h>
#include <QtGui/QGuiApplication>
#include <QtQml/QQmlApplicationEngine>
#include <%{AppHdrName}>
REGISTER_CORE_APP(%{AppCn})
QTMVVM_REGISTER_CORE_APP(%{AppCn})
int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
// If you want to support file dialogs on platforms other then android, use a QApplication instead (and add QT += widgets to the pro file)
QGuiApplication app(argc, argv);
qmlRegisterUncreatableType<%{ControlCn}>("com.example.%{ProjectLowerName}", 1, 0, "%{ControlCn}", "Controls cannot be created!");
QuickPresenter::createAppEngine(QUrl(QLatin1String("qrc:/qml/App.qml")));
qmlRegisterUncreatableType<%{VmCn}>("com.example.%{ProjectLowerName}", 1, 0, "%{VmCn}", "ViewModels cannot be created!");
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/App.qml")));
if (engine.rootObjects().isEmpty())
return -1;
return app.exec();
}

50
ProjectTemplate/view.qml

@ -1,28 +1,34 @@
import QtQuick 2.8
import QtQuick.Controls 2.1
import QtQuick 2.10
import QtQuick.Vms 2.3
import QtQuick.Layouts 1.3
import de.skycoder42.quickextras 2.0
import de.skycoder42.qtmvvm.quick 1.0
import de.skycoder42.QtMvvm.Core 1.0
import de.skycoder42.QtMvvm.Quick 1.0
import com.example.%{ProjectLowerName} 1.0
Page {
id: mainView
property %{ControlCn} control: null
property %{VmCn} viewModel: null
header: ActionBar {
id: toolbar
title: qsTr("%{ControlClassName}")
showMenuButton: false
header: ContrastToolBar {
RowLayout {
anchors.fill: parent
spacing: 0
ToolBarLabel {
text: qsTr("%{VmClassName}")
Layout.fillWidth: true
}
@if '%{UseSettings}'
moreMenu: Menu {
MenuItem {
id: settings
text: qsTr("Settings")
onClicked: control.showSettings()
MenuButton {
MenuItem {
id: settings
text: qsTr("Settings")
onClicked: viewModel.showSettings()
}
}
}
@endif
}
}
PresenterProgress {}
@ -37,9 +43,9 @@ Page {
id: textEdit
Layout.fillWidth: true
QtMvvmBinding {
control: mainView.control
controlProperty: "text"
MvvmBinding {
viewModel: mainView.viewModel
viewModelProperty: "text"
view: textEdit
viewProperty: "text"
}
@ -49,12 +55,12 @@ Page {
id: textLabel
Layout.fillWidth: true
QtMvvmBinding {
control: mainView.control
controlProperty: "text"
MvvmBinding {
viewModel: mainView.viewModel
viewModelProperty: "text"
view: textLabel
viewProperty: "text"
type: QtMvvmBinding.OneWayFromControl
type: MvvmBinding.OneWayToView
}
}

31
ProjectTemplate/viewmodel.cpp

@ -0,0 +1,31 @@
#include "%{VmHdrName}"
@if '%{UseSettings}'
#include <QtMvvmCore/SettingsViewModel>
@endif
%{VmCn}::%{VmCn}(QObject *parent) :
ViewModel(parent),
_text(QStringLiteral("hello world"))
{}
QString %{VmCn}::text() const
{
return _text;
}
@if '%{UseSettings}'
void %{VmCn}::showSettings()
{
show<QtMvvm::SettingsViewModel>();
}
@endif
void %{VmCn}::setText(const QString &text)
{
if (_text == text)
return;
_text = text;
emit textChanged(_text);
}

31
ProjectTemplate/viewmodel.h

@ -0,0 +1,31 @@
#ifndef %{VmGuard}
#define %{VmGuard}
#include <QtMvvmCore/ViewModel>
class %{VmCn} : public QtMvvm::ViewModel
{
Q_OBJECT
Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
public:
Q_INVOKABLE explicit %{VmCn}(QObject *parent = nullptr);
QString text() const;
public Q_SLOTS:
@if '%{UseSettings}'
void showSettings();
@endif
void setText(const QString &text);
Q_SIGNALS:
void textChanged(const QString &text);
private:
QString _text;
};
#endif // %{VmGuard}

7
ProjectTemplate/widgets.pro

@ -1,7 +1,7 @@
TEMPLATE = app
QT += core gui widgets
CONFIG += c++11
QT += widgets mvvmwidgets
CONFIG += c++14
TARGET = %{WidgetsName}
@ -30,6 +30,3 @@ else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../%{Co
else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../%{CoreName}/release/%{CoreName}.lib
else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../%{CoreName}/debug/%{CoreName}.lib
else:unix: PRE_TARGETDEPS += $$OUT_PWD/../%{CoreName}/lib%{CoreName}.a
!ReleaseBuild:!DebugBuild:!system(qpmx -d $$shell_quote($$_PRO_FILE_PWD_) --qmake-run init $$QPMX_EXTRA_OPTIONS $$shell_quote($$QMAKE_QMAKE) $$shell_quote($$OUT_PWD)): error(qpmx initialization failed. Check the compilation log for details.)
else: include($$OUT_PWD/qpmx_generated.pri)

20
ProjectTemplate/widgets_main.cpp

@ -1,25 +1,19 @@
#include <QApplication>
#include <widgetpresenter.h>
#include <QtWidgets/QApplication>
#include <QtMvvmWidgets/WidgetsPresenter>
#include <%{AppHdrName}>
@if '%{UseSettings}'
#include <settingsdialog.h>
@endif
#include "%{WindowHdrName}"
//register the core app to be used
REGISTER_CORE_APP(%{AppCn})
// Register the core app
QTMVVM_REGISTER_CORE_APP(%{AppCn})
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
// automatically sets "WidgetPresenter" as presenter and registers the %{WindowName} class as a widget
// the control this widget belongs to is detected automatically via naming conventions
WidgetPresenter::registerWidget<%{WindowCn}>();
@if '%{UseSettings}'
WidgetPresenter::registerWidget<SettingsDialog>();
@endif
// Automatically sets "WidgetPresenter" as presenter and registers the %{WindowName} class as a widget
// The viewmodel this widget belongs to is detected automatically via naming conventions
QtMvvm::WidgetsPresenter::registerView<%{WindowCn}>();
return a.exec();
}

24
ProjectTemplate/window.cpp

@ -1,24 +1,28 @@
#include "%{WindowHdrName}"
#include "ui_%{WindowHdrName}"
#include <qtmvvmbinding.h>
%{WindowCn}::%{WindowCn}(Control *mControl, QWidget *parent) :
#include <QtMvvmCore/Binding>
%{WindowCn}::%{WindowCn}(QtMvvm::ViewModel *viewModel, QWidget *parent) :
QMainWindow(parent),
control(static_cast<%{ControlCn}*>(mControl)),
ui(new Ui::%{WindowCn})
_viewModel(static_cast<%{VmCn}*>(viewModel)),
_ui(new Ui::%{WindowCn})
{
ui->setupUi(this);
_ui->setupUi(this);
@if '%{UseSettings}'
connect(ui->actionSettings, &QAction::triggered,
control, &%{ControlCn}::showSettings);
connect(_ui->actionSettings, &QAction::triggered,
_viewModel, &%{VmCn}::showSettings);
@endif
QtMvvmBinding::bind(control, "text", ui->lineEdit, "text");
QtMvvmBinding::bind(control, "text", ui->label, "text", QtMvvmBinding::OneWayFromControl);
QtMvvm::bind(_viewModel, "text",
_ui->lineEdit, "text");
QtMvvm::bind(_viewModel, "text",
_ui->label, "text",
QtMvvm::Binding::OneWayToView);
}
%{WindowCn}::~%{WindowCn}()
{
delete ui;
delete _ui;
}

11
ProjectTemplate/window.h

@ -1,8 +1,9 @@
#ifndef %{WindowGuard}
#define %{WindowGuard}
#include <QMainWindow>
#include <%{ControlHdrName}>
#include <QtWidgets/QMainWindow>
#include <%{VmHdrName}>
namespace Ui {
class %{WindowCn};
@ -13,12 +14,12 @@ class %{WindowCn} : public QMainWindow
Q_OBJECT
public:
Q_INVOKABLE %{WindowCn}(Control *mControl, QWidget *parent = nullptr);
Q_INVOKABLE %{WindowCn}(QtMvvm::ViewModel *viewModel, QWidget *parent = nullptr);
~%{WindowCn}();
private:
%{ControlCn} *control;
Ui::%{WindowCn} *ui;
%{VmCn} *_viewModel;
Ui::%{WindowCn} *_ui;
};
#endif // %{WindowGuard}

5
ProjectTemplate/window.ui

@ -10,6 +10,9 @@
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>%{ProjectName}</string>
</property>
<widget class="QWidget" name="centralWidget">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
@ -66,7 +69,7 @@
<action name="actionSettings">
<property name="icon">
<iconset theme="configure">
<normaloff>:/qtmvvm/icons/settings.ico</normaloff>:/qtmvvm/icons/settings.ico</iconset>
<normaloff>:/de/skycoder42/qtmvvm/icons/settings.ico</normaloff>:/de/skycoder42/qtmvvm/icons/settings.ico</iconset>
</property>
<property name="text">
<string>Settings</string>

50
ProjectTemplate/wizard.json

@ -6,7 +6,7 @@
"trDescription": "Creates a QtMvvm project skeleton, for easy creation of new QtMvvm projects.",
"trDisplayName": "QtMvvm Application Project",
"trDisplayCategory": "Application",
"icon": "guiapplication.png",
"icon": "../../global/guiapplication.png",
"featuresRequired": [ "QtSupport.Wizards.FeatureQt" ],
"enabled": "%{JS: [ %{Plugins} ].indexOf('QmakeProjectManager') >= 0}",
"options":
@ -32,10 +32,10 @@
{ "key": "AppCn", "value": "%{JS: Cpp.className('%{AppName}')}" },
{ "key": "AppGuard", "value": "%{JS: Cpp.headerGuard('%{AppHdrName}')}" },
{ "key": "ControlHdrName", "value": "%{JS: Cpp.classToFileName('%{ControlClassName}', '%{JS: Util.preferredSuffix('text/x-c++hdr')}')}" },
{ "key": "ControlSrcName", "value": "%{JS: Cpp.classToFileName('%{ControlClassName}', '%{JS: Util.preferredSuffix('text/x-c++src')}')}" },
{ "key": "ControlCn", "value": "%{JS: Cpp.className('%{ControlClassName}')}" },
{ "key": "ControlGuard", "value": "%{JS: Cpp.headerGuard('%{ControlHdrName}')}" },
{ "key": "VmHdrName", "value": "%{JS: Cpp.classToFileName('%{VmClassName}', '%{JS: Util.preferredSuffix('text/x-c++hdr')}')}" },
{ "key": "VmSrcName", "value": "%{JS: Cpp.classToFileName('%{VmClassName}', '%{JS: Util.preferredSuffix('text/x-c++src')}')}" },
{ "key": "VmCn", "value": "%{JS: Cpp.className('%{VmClassName}')}" },
{ "key": "VmGuard", "value": "%{JS: Cpp.headerGuard('%{VmHdrName}')}" },
{ "key": "AppQrcName", "value": "%{JS: '%{CoreName}'.toLowerCase()}" },
{ "key": "AppQrcFile", "value": "%{JS: Util.fileName('%{AppQrcName}', 'qrc')}" },
@ -100,14 +100,14 @@
]
},
{
"trDisplayName": "Define Initial Control",
"trShortTitle": "Control",
"trDisplayName": "Define Initial ViewModel",
"trShortTitle": "ViewModel",
"typeId": "Fields",
"data" :
[
{
"name": "ControlName",
"trDisplayName": "Control base name:",
"name": "VmName",
"trDisplayName": "ViewModel base name:",
"mandatory": true,
"type": "LineEdit",
"data":
@ -122,13 +122,13 @@
"data": { "factor": 2 }
},
{
"name": "ControlClassName",
"name": "VmClassName",
"type": "LineEdit",
"trDisplayName": "Control class name:",
"trDisplayName": "ViewModel class name:",
"mandatory": true,
"data":
{
"trText": "%{ControlName}Control",
"trText": "%{VmName}ViewModel",
"validator": "(?:(?:[a-zA-Z_][a-zA-Z_0-9]*::)*[a-zA-Z_][a-zA-Z_0-9]*|)"
}
},
@ -139,7 +139,7 @@
"mandatory": true,
"data":
{
"trText": "%{ControlName}Window",
"trText": "%{VmName}Window",
"validator": "(?:(?:[a-zA-Z_][a-zA-Z_0-9]*::)*[a-zA-Z_][a-zA-Z_0-9]*|)"
}
},
@ -150,7 +150,7 @@
"mandatory": true,
"data":
{
"trText": "%{ControlName}View",
"trText": "%{VmName}View",
"validator": "(?:(?:[a-zA-Z_][a-zA-Z_0-9]*::)*[a-zA-Z_][a-zA-Z_0-9]*|)"
}
}
@ -184,10 +184,6 @@
"source": "core.pro",
"target": "%{CoreProName}"
},
{
"source": "qpmx_core.json",
"target": "%{CoreDirectory}/qpmx.json"
},
{
"source": "app.h",
"target": "%{CoreDirectory}/%{AppHdrName}"
@ -197,12 +193,12 @@
"target": "%{CoreDirectory}/%{AppSrcName}"
},
{
"source": "control.h",
"target": "%{CoreDirectory}/%{ControlHdrName}"
"source": "viewmodel.h",
"target": "%{CoreDirectory}/%{VmHdrName}"
},
{
"source": "control.cpp",
"target": "%{CoreDirectory}/%{ControlSrcName}"
"source": "viewmodel.cpp",
"target": "%{CoreDirectory}/%{VmSrcName}"
},
{
"source": "core.qrc",
@ -219,11 +215,6 @@
"target": "%{WidgetsProName}",
"condition": "%{JS: '%{CreateWidgets}' !== ''}"
},
{
"source": "qpmx_widgets.json",
"target": "%{WidgetsDirectory}/qpmx.json",
"condition": "%{JS: '%{CreateWidgets}' !== ''}"
},
{
"source": "widgets_main.cpp",
"target": "%{WidgetsDirectory}/main.cpp",
@ -249,11 +240,6 @@
"target": "%{QuickProName}",
"condition": "%{JS: '%{CreateQuick}' !== ''}"
},
{
"source": "qpmx_quick.json",
"target": "%{QuickDirectory}/qpmx.json",
"condition": "%{JS: '%{CreateQuick}' !== ''}"
},
{
"source": "quick_main.cpp",
"target": "%{QuickDirectory}/main.cpp",

2
README.md

@ -40,7 +40,7 @@ If you don't know the Mvvm pattern already, you can read up on the links below.
of logic (the models), presentation logic (the viewmodels) and the actual GUI (the views) that is very useful when
creating applications that need to support different uis for the same data.
![[The MVVM Pattern](https://msdn.microsoft.com/en-us/library/hh848246.aspx)](https://i-msdn.sec.s-msft.com/dynimg/IC564167.png)
[![The MVVM Pattern](https://i-msdn.sec.s-msft.com/dynimg/IC564167.png)](https://msdn.microsoft.com/en-us/library/hh848246.aspx)
Good links to get started:

3
deploy.json

@ -16,5 +16,8 @@
"license": {
"name": "BSD-3-Clause",
"path": "LICENSE"
},
"installs": {
"ProjectTemplate": "Tools/QtCreator/share/qtcreator/templates/wizards/projects/qtmvvm"
}
}

1
examples/mvvmquick/SampleQuick/main.cpp

@ -23,7 +23,6 @@ int main(int argc, char *argv[])
qputenv("QML2_IMPORT_PATH", QML_PATH);
#endif
QIcon::setThemeSearchPaths({});
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication app(argc, argv);
qDebug() << QQuickStyle::availableStyles() << QQuickStyle::name();

Loading…
Cancel
Save