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 QtQuick 2.10
import de.skycoder42.qtmvvm.quick 1.0 import de.skycoder42.QtMvvm.Quick 1.0
App {
QtMvvmApp {
title: qsTr("%{ProjectName}")
} }

48
ProjectTemplate/app.cpp

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

13
ProjectTemplate/app.h

@ -1,11 +1,9 @@
#ifndef %{AppGuard} #ifndef %{AppGuard}
#define %{AppGuard} #define %{AppGuard}
#include <coreapp.h> #include <QtMvvmCore/CoreApp>
#include "%{ControlHdrName}" class %{AppCn} : public QtMvvm::CoreApp
class %{AppCn} : public CoreApp
{ {
Q_OBJECT Q_OBJECT
@ -13,14 +11,11 @@ public:
explicit %{AppCn}(QObject *parent = nullptr); explicit %{AppCn}(QObject *parent = nullptr);
protected: protected:
void setupParser(QCommandLineParser &parser, bool &allowInvalid) const override; void performRegistrations() override;
bool startApp(const QCommandLineParser &parser) override; int startApp(const QStringList &arguments) override;
protected slots: protected slots:
void aboutToQuit() override; void aboutToQuit() override;
private:
%{ControlCn} *mainControl;
}; };
#undef coreApp #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 TEMPLATE = lib
QT += core gui QT += mvvmcore
CONFIG += c++11 staticlib #important because dlls are problematic # 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} TARGET = %{CoreName}
@ -9,11 +10,11 @@ DEFINES += QT_DEPRECATED_WARNINGS
HEADERS += \\ HEADERS += \\
%{AppHdrName} \\ %{AppHdrName} \\
%{ControlHdrName} %{VmHdrName}
SOURCES += \\ SOURCES += \\
%{AppSrcName} \\ %{AppSrcName} \\
%{ControlSrcName} %{VmSrcName}
@if '%{UseSettings}' @if '%{UseSettings}'
RESOURCES += \\ RESOURCES += \\
@ -23,11 +24,10 @@ RESOURCES += \\
TRANSLATIONS += %{ProjectLowerName}_core_de.ts \\ TRANSLATIONS += %{ProjectLowerName}_core_de.ts \\
%{ProjectLowerName}_core_template.ts %{ProjectLowerName}_core_template.ts
DISTFILES += $$TRANSLATIONS
@if '%{UseSettings}' @if '%{UseSettings}'
QTMVVM_SETTINGS_FILES = settings.xml QTMVVM_TS_SETTINGS = settings.xml
never_true_lupdate_only: SOURCES += .qtmvvm_settings_xml_ts.cppdummy _never_true_condition: SOURCES += $$files($$PWD/.ts-dummy/*)
CONFIG += no_settings_ts_warn # Uncomment the following line to automatically generated and update settings translations when building
#PRE_TARGETDEPS += qtmvvm-tsgen
@endif @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 TEMPLATE = app
QT += core gui qml quick quickcontrols2 QT += quick mvvmquick
CONFIG += c++11 CONFIG += c++14
TARGET = %{QuickName} 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 DEFINES += QT_DEPRECATED_WARNINGS
SOURCES += main.cpp SOURCES += main.cpp
@ -21,11 +15,6 @@ RESOURCES += \\
TRANSLATIONS += %{ProjectLowerName}_quick_de.ts \\ TRANSLATIONS += %{ProjectLowerName}_quick_de.ts \\
%{ProjectLowerName}_quick_template.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 # Link with core project
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../%{CoreName}/release/ -l%{CoreName} 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} 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: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 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.) # Additional import path used to resolve QML modules in Qt Creator's code model
else: include($$OUT_PWD/qpmx_generated.pri) 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> <RCC>
<qresource prefix="/qml"> <qresource prefix="/">
<file>App.qml</file> <file>App.qml</file>
</qresource> </qresource>
<qresource prefix="/qml/views"> <qresource prefix="/qtmvvm/views">
<file>%{QuickQmlName}</file> <file>%{QuickQmlName}</file>
</qresource> </qresource>
</RCC> </RCC>

17
ProjectTemplate/quick_main.cpp

@ -1,18 +1,21 @@
#include <QGuiApplication> #include <QtGui/QGuiApplication>
#include <QQmlApplicationEngine> #include <QtQml/QQmlApplicationEngine>
#include <quickpresenter.h>
#include <%{AppHdrName}> #include <%{AppHdrName}>
REGISTER_CORE_APP(%{AppCn}) QTMVVM_REGISTER_CORE_APP(%{AppCn})
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); 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); QGuiApplication app(argc, argv);
qmlRegisterUncreatableType<%{ControlCn}>("com.example.%{ProjectLowerName}", 1, 0, "%{ControlCn}", "Controls cannot be created!"); qmlRegisterUncreatableType<%{VmCn}>("com.example.%{ProjectLowerName}", 1, 0, "%{VmCn}", "ViewModels cannot be created!");
QuickPresenter::createAppEngine(QUrl(QLatin1String("qrc:/qml/App.qml"))); QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/App.qml")));
if (engine.rootObjects().isEmpty())
return -1;
return app.exec(); return app.exec();
} }

50
ProjectTemplate/view.qml

@ -1,28 +1,34 @@
import QtQuick 2.8 import QtQuick 2.10
import QtQuick.Controls 2.1 import QtQuick.Vms 2.3
import QtQuick.Layouts 1.3 import QtQuick.Layouts 1.3
import de.skycoder42.quickextras 2.0 import de.skycoder42.QtMvvm.Core 1.0
import de.skycoder42.qtmvvm.quick 1.0 import de.skycoder42.QtMvvm.Quick 1.0
import com.example.%{ProjectLowerName} 1.0 import com.example.%{ProjectLowerName} 1.0
Page { Page {
id: mainView id: mainView
property %{ControlCn} control: null property %{VmCn} viewModel: null
header: ActionBar { header: ContrastToolBar {
id: toolbar RowLayout {
title: qsTr("%{ControlClassName}") anchors.fill: parent
showMenuButton: false spacing: 0
ToolBarLabel {
text: qsTr("%{VmClassName}")
Layout.fillWidth: true
}
@if '%{UseSettings}' @if '%{UseSettings}'
moreMenu: Menu { MenuButton {
MenuItem { MenuItem {
id: settings id: settings
text: qsTr("Settings") text: qsTr("Settings")
onClicked: control.showSettings() onClicked: viewModel.showSettings()
}
} }
}
@endif @endif
}
} }
PresenterProgress {} PresenterProgress {}
@ -37,9 +43,9 @@ Page {
id: textEdit id: textEdit
Layout.fillWidth: true Layout.fillWidth: true
QtMvvmBinding { MvvmBinding {
control: mainView.control viewModel: mainView.viewModel
controlProperty: "text" viewModelProperty: "text"
view: textEdit view: textEdit
viewProperty: "text" viewProperty: "text"
} }
@ -49,12 +55,12 @@ Page {
id: textLabel id: textLabel
Layout.fillWidth: true Layout.fillWidth: true
QtMvvmBinding { MvvmBinding {
control: mainView.control viewModel: mainView.viewModel
controlProperty: "text" viewModelProperty: "text"
view: textLabel view: textLabel
viewProperty: "text" 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 TEMPLATE = app
QT += core gui widgets QT += widgets mvvmwidgets
CONFIG += c++11 CONFIG += c++14
TARGET = %{WidgetsName} 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(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: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 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 <QtWidgets/QApplication>
#include <widgetpresenter.h> #include <QtMvvmWidgets/WidgetsPresenter>
#include <%{AppHdrName}> #include <%{AppHdrName}>
@if '%{UseSettings}'
#include <settingsdialog.h>
@endif
#include "%{WindowHdrName}" #include "%{WindowHdrName}"
//register the core app to be used // Register the core app
REGISTER_CORE_APP(%{AppCn}) QTMVVM_REGISTER_CORE_APP(%{AppCn})
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
QApplication a(argc, argv); QApplication a(argc, argv);
// automatically sets "WidgetPresenter" as presenter and registers the %{WindowName} class as a widget // 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 // The viewmodel this widget belongs to is detected automatically via naming conventions
WidgetPresenter::registerWidget<%{WindowCn}>(); QtMvvm::WidgetsPresenter::registerView<%{WindowCn}>();
@if '%{UseSettings}'
WidgetPresenter::registerWidget<SettingsDialog>();
@endif
return a.exec(); return a.exec();
} }

24
ProjectTemplate/window.cpp

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

11
ProjectTemplate/window.h

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

5
ProjectTemplate/window.ui

@ -10,6 +10,9 @@
<height>300</height> <height>300</height>
</rect> </rect>
</property> </property>
<property name="windowTitle">
<string>%{ProjectName}</string>
</property>
<widget class="QWidget" name="centralWidget"> <widget class="QWidget" name="centralWidget">
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
@ -66,7 +69,7 @@
<action name="actionSettings"> <action name="actionSettings">
<property name="icon"> <property name="icon">
<iconset theme="configure"> <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>
<property name="text"> <property name="text">
<string>Settings</string> <string>Settings</string>

50
ProjectTemplate/wizard.json

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

3
deploy.json

@ -16,5 +16,8 @@
"license": { "license": {
"name": "BSD-3-Clause", "name": "BSD-3-Clause",
"path": "LICENSE" "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); qputenv("QML2_IMPORT_PATH", QML_PATH);
#endif #endif
QIcon::setThemeSearchPaths({});
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication app(argc, argv); QApplication app(argc, argv);
qDebug() << QQuickStyle::availableStyles() << QQuickStyle::name(); qDebug() << QQuickStyle::availableStyles() << QQuickStyle::name();

Loading…
Cancel
Save