From ea1da8a9284df94e318f74c41ce3b0505cf6c705 Mon Sep 17 00:00:00 2001 From: EndrII <EndrIIMail@gmail.com> Date: Tue, 18 Jan 2022 17:25:02 +0300 Subject: [PATCH] add new readme file --- CMakeLists.txt | 6 +- README.md | 154 ++++++++++++++++++-- src/Example/Main.qml | 2 +- src/Example/main.cpp | 2 +- src/Library/DoctorPillGui/doctormodel.h | 2 +- src/Library/DoctorPillModule/DoctorView.qml | 2 +- src/Library/languages/de.ts | 8 +- src/Library/languages/en.ts | 8 +- src/Library/languages/es.ts | 8 +- src/Library/languages/fr.ts | 8 +- src/Library/languages/ja.ts | 8 +- src/Library/languages/pl.ts | 8 +- src/Library/languages/ru.ts | 8 +- src/Library/languages/tr.ts | 8 +- src/Library/languages/uk.ts | 8 +- src/Library/languages/zh.ts | 8 +- 16 files changed, 189 insertions(+), 59 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 53dc23c..5ecc724 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,9 +40,9 @@ file(MAKE_DIRECTORY ${TARGET_DIR}) if (DEFINED TARGET_PLATFORM_TOOLCHAIN) if (${TARGET_PLATFORM_TOOLCHAIN} STREQUAL "wasm32") - set(DOCTOR_PILL_TESTS OFF) - set(DOCTOR_PILL_EXAMPLE OFF) - message("Disable DOCTOR_PILL_TESTS and DOCTOR_PILL_EXAMPLE for wasm paltform because wasm not support tests and an example.") + message("This library depend of the qt concurent library, but The concurent is not available in qt wasm") + initAll() + return() endif() endif() diff --git a/README.md b/README.md index dd0285c..7578084 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,145 @@ -# CMakeProject -Template repository for cmake project -Fork me and replase DoctorPill to Name of your new project. +# Doctor Pill +The Doctor pill is simple qt / qml library for fast develop fixes for applications that already released and working in production. -1. Clone this repository -2. Run ./init.sh NewProjectName +The library has c++ interface DP::iPill and QML view for diagnostic gui applications. -# This template supports next build targets: +For Disable the gui part of the library use the DOCTOR_PILL_GUI option. -| Command or make target | Description | -|------|------| -| **make test** | The run tests for a project (dependet of Qt Tests, so you need to add Qt in Cmake using CMAKE_PREFIX_PATH) | -| **make doc** | The generate a documentation for a project (dependet of doxygen) | -| **make deploy** | The generate distribution for a project (dependet of CQtDeployer) | -| **make release** | The prepare Qt Installer framework repository for a project, generate a snap package and APK file for android (dependet of CQtDeployer, snapcraft, AndroidDeployer). | +## BUILD OPTIONS + +``` cmake +option(DOCTOR_PILL_GUI "Enable gui qml model for build" ON) +option(DOCTOR_PILL_TESTS "Enable tests of this library" ON) +option(DOCTOR_PILL_EXAMPLE "Enable example app of this library" ON) +``` + + +## Include to cmake project + +1. add as a submodule this repo + +``` bash + git submodule add https://github.com/QuasarApp/DoctorPill.git +``` + +2. Add to build the DoctorPill as a subdirectory + +``` cmake +set(DOCTOR_PILL_GUI ON) # you may change it if you need. +set(DOCTOR_PILL_TESTS OFF) you may change it if you need. +set(DOCTOR_PILL_EXAMPLE OFF) you may change it if you need. + +add_subdirectory(DoctorPill) +``` + +## Using + +### Wihout GUI + + +#### Create a new pill object. + +```cpp +#include <doctorpill.h> + +class MyPill: DP::iPill { + QString name() const override { + return "My pill"; + }; + + QString description() const override { + return "Description of my pill"; + }; + +protected: + bool diagnostic() const override { + // some code for search bug + }; + + bool fix() const override { + // some code for fix found bug + }; +}; +``` + +#### Use your self created pills + + +```cpp +#include <doctorpill.h> + +// ... + +DP::Doctor _doctor; +if (_doctor.fix({QSharedPointer<MyPill>::create()})) { + // app fixed successfull +} else { + // fail to fix app +} + +// ... +``` + + + +### Use GUI QML wrapper + +For working with gui wrapper you need to initialize this library before include gui module in to your qml file. + + +#### initialize the library (main.cpp) + +``` cpp + +int main(int argc, char *argv[]) { + QCoreApplication::setOrganizationName("QuasarApp"); + QCoreApplication::setApplicationName("DoctorPillExample"); + + QGuiApplication app(argc, argv); + QQmlApplicationEngine engine; + + if (!DP::init(&engine)) { + return -1; + } + + DP::DoctorModel model({QSharedPointer<SomePill>::create()}); + + // see next code view + engine.load("qrc:/Main.qml"); + if (engine.rootObjects().isEmpty()) + return -2; + + // Add new doctor pill model to view + QQmlContext* rootContext = engine.rootContext(); + if (rootContext) + rootContext->setContextProperty("doctorPillModel", &model); + + return app.exec(); +} + + +``` + + +#### Using qml view (main.qml) + + +```qml +import QtQuick 2.15 +import QtQuick.Controls 2.15 +import QtQuick.Controls.Material 2.15 +import DoctorPillModule 1.0 + +ApplicationWindow { + width: 800 + height: 600 + visible: true + + DoctorView { + anchors.fill: parent + // use added model in qml file. + model: (doctorPillModel)? doctorPillModel: null + } +} + +``` diff --git a/src/Example/Main.qml b/src/Example/Main.qml index 308a5a9..d0b4aa4 100644 --- a/src/Example/Main.qml +++ b/src/Example/Main.qml @@ -10,6 +10,6 @@ ApplicationWindow { DoctorView { anchors.fill: parent - model: (doctorPillMpdel)? doctorPillMpdel: null + model: (doctorPillModel)? doctorPillModel: null } } diff --git a/src/Example/main.cpp b/src/Example/main.cpp index a6007a6..148d05d 100644 --- a/src/Example/main.cpp +++ b/src/Example/main.cpp @@ -133,7 +133,7 @@ int main(int argc, char *argv[]) { QQmlContext* rootContext = engine.rootContext(); if (rootContext) - rootContext->setContextProperty("doctorPillMpdel", &model); + rootContext->setContextProperty("doctorPillModel", &model); return app.exec(); } diff --git a/src/Library/DoctorPillGui/doctormodel.h b/src/Library/DoctorPillGui/doctormodel.h index c1ed03c..3fd734b 100644 --- a/src/Library/DoctorPillGui/doctormodel.h +++ b/src/Library/DoctorPillGui/doctormodel.h @@ -16,7 +16,7 @@ namespace DP { /** * @brief The PillsModel class This is gui model of available pills. */ -class DoctorModel: public QAbstractListModel +class DOCTOR_PILL_EXPORT DoctorModel: public QAbstractListModel { Q_OBJECT diff --git a/src/Library/DoctorPillModule/DoctorView.qml b/src/Library/DoctorPillModule/DoctorView.qml index 2798dc5..1c60982 100644 --- a/src/Library/DoctorPillModule/DoctorView.qml +++ b/src/Library/DoctorPillModule/DoctorView.qml @@ -179,7 +179,7 @@ Page { } Button { - text: qsTr("Repair"); + text: qsTr("Fix"); visible: issueStatus === 0 onClicked: { if (root.model) { diff --git a/src/Library/languages/de.ts b/src/Library/languages/de.ts index a21e6f7..36d4d04 100644 --- a/src/Library/languages/de.ts +++ b/src/Library/languages/de.ts @@ -19,10 +19,6 @@ <source>Diagnostic</source> <translation type="unfinished"></translation> </message> - <message> - <source>Repair</source> - <translation type="unfinished"></translation> - </message> <message> <source><b>Attention</b>: Please use this page only if you knows what you do. If your application works correctly then please - do nothing.</source> <translation type="unfinished"></translation> @@ -47,5 +43,9 @@ <source>I know what I'm doing</source> <translation type="unfinished"></translation> </message> + <message> + <source>Fix</source> + <translation type="unfinished"></translation> + </message> </context> </TS> diff --git a/src/Library/languages/en.ts b/src/Library/languages/en.ts index a21e6f7..36d4d04 100644 --- a/src/Library/languages/en.ts +++ b/src/Library/languages/en.ts @@ -19,10 +19,6 @@ <source>Diagnostic</source> <translation type="unfinished"></translation> </message> - <message> - <source>Repair</source> - <translation type="unfinished"></translation> - </message> <message> <source><b>Attention</b>: Please use this page only if you knows what you do. If your application works correctly then please - do nothing.</source> <translation type="unfinished"></translation> @@ -47,5 +43,9 @@ <source>I know what I'm doing</source> <translation type="unfinished"></translation> </message> + <message> + <source>Fix</source> + <translation type="unfinished"></translation> + </message> </context> </TS> diff --git a/src/Library/languages/es.ts b/src/Library/languages/es.ts index a21e6f7..36d4d04 100644 --- a/src/Library/languages/es.ts +++ b/src/Library/languages/es.ts @@ -19,10 +19,6 @@ <source>Diagnostic</source> <translation type="unfinished"></translation> </message> - <message> - <source>Repair</source> - <translation type="unfinished"></translation> - </message> <message> <source><b>Attention</b>: Please use this page only if you knows what you do. If your application works correctly then please - do nothing.</source> <translation type="unfinished"></translation> @@ -47,5 +43,9 @@ <source>I know what I'm doing</source> <translation type="unfinished"></translation> </message> + <message> + <source>Fix</source> + <translation type="unfinished"></translation> + </message> </context> </TS> diff --git a/src/Library/languages/fr.ts b/src/Library/languages/fr.ts index a21e6f7..36d4d04 100644 --- a/src/Library/languages/fr.ts +++ b/src/Library/languages/fr.ts @@ -19,10 +19,6 @@ <source>Diagnostic</source> <translation type="unfinished"></translation> </message> - <message> - <source>Repair</source> - <translation type="unfinished"></translation> - </message> <message> <source><b>Attention</b>: Please use this page only if you knows what you do. If your application works correctly then please - do nothing.</source> <translation type="unfinished"></translation> @@ -47,5 +43,9 @@ <source>I know what I'm doing</source> <translation type="unfinished"></translation> </message> + <message> + <source>Fix</source> + <translation type="unfinished"></translation> + </message> </context> </TS> diff --git a/src/Library/languages/ja.ts b/src/Library/languages/ja.ts index a21e6f7..36d4d04 100644 --- a/src/Library/languages/ja.ts +++ b/src/Library/languages/ja.ts @@ -19,10 +19,6 @@ <source>Diagnostic</source> <translation type="unfinished"></translation> </message> - <message> - <source>Repair</source> - <translation type="unfinished"></translation> - </message> <message> <source><b>Attention</b>: Please use this page only if you knows what you do. If your application works correctly then please - do nothing.</source> <translation type="unfinished"></translation> @@ -47,5 +43,9 @@ <source>I know what I'm doing</source> <translation type="unfinished"></translation> </message> + <message> + <source>Fix</source> + <translation type="unfinished"></translation> + </message> </context> </TS> diff --git a/src/Library/languages/pl.ts b/src/Library/languages/pl.ts index a21e6f7..36d4d04 100644 --- a/src/Library/languages/pl.ts +++ b/src/Library/languages/pl.ts @@ -19,10 +19,6 @@ <source>Diagnostic</source> <translation type="unfinished"></translation> </message> - <message> - <source>Repair</source> - <translation type="unfinished"></translation> - </message> <message> <source><b>Attention</b>: Please use this page only if you knows what you do. If your application works correctly then please - do nothing.</source> <translation type="unfinished"></translation> @@ -47,5 +43,9 @@ <source>I know what I'm doing</source> <translation type="unfinished"></translation> </message> + <message> + <source>Fix</source> + <translation type="unfinished"></translation> + </message> </context> </TS> diff --git a/src/Library/languages/ru.ts b/src/Library/languages/ru.ts index a21e6f7..36d4d04 100644 --- a/src/Library/languages/ru.ts +++ b/src/Library/languages/ru.ts @@ -19,10 +19,6 @@ <source>Diagnostic</source> <translation type="unfinished"></translation> </message> - <message> - <source>Repair</source> - <translation type="unfinished"></translation> - </message> <message> <source><b>Attention</b>: Please use this page only if you knows what you do. If your application works correctly then please - do nothing.</source> <translation type="unfinished"></translation> @@ -47,5 +43,9 @@ <source>I know what I'm doing</source> <translation type="unfinished"></translation> </message> + <message> + <source>Fix</source> + <translation type="unfinished"></translation> + </message> </context> </TS> diff --git a/src/Library/languages/tr.ts b/src/Library/languages/tr.ts index a21e6f7..36d4d04 100644 --- a/src/Library/languages/tr.ts +++ b/src/Library/languages/tr.ts @@ -19,10 +19,6 @@ <source>Diagnostic</source> <translation type="unfinished"></translation> </message> - <message> - <source>Repair</source> - <translation type="unfinished"></translation> - </message> <message> <source><b>Attention</b>: Please use this page only if you knows what you do. If your application works correctly then please - do nothing.</source> <translation type="unfinished"></translation> @@ -47,5 +43,9 @@ <source>I know what I'm doing</source> <translation type="unfinished"></translation> </message> + <message> + <source>Fix</source> + <translation type="unfinished"></translation> + </message> </context> </TS> diff --git a/src/Library/languages/uk.ts b/src/Library/languages/uk.ts index a21e6f7..36d4d04 100644 --- a/src/Library/languages/uk.ts +++ b/src/Library/languages/uk.ts @@ -19,10 +19,6 @@ <source>Diagnostic</source> <translation type="unfinished"></translation> </message> - <message> - <source>Repair</source> - <translation type="unfinished"></translation> - </message> <message> <source><b>Attention</b>: Please use this page only if you knows what you do. If your application works correctly then please - do nothing.</source> <translation type="unfinished"></translation> @@ -47,5 +43,9 @@ <source>I know what I'm doing</source> <translation type="unfinished"></translation> </message> + <message> + <source>Fix</source> + <translation type="unfinished"></translation> + </message> </context> </TS> diff --git a/src/Library/languages/zh.ts b/src/Library/languages/zh.ts index a21e6f7..36d4d04 100644 --- a/src/Library/languages/zh.ts +++ b/src/Library/languages/zh.ts @@ -19,10 +19,6 @@ <source>Diagnostic</source> <translation type="unfinished"></translation> </message> - <message> - <source>Repair</source> - <translation type="unfinished"></translation> - </message> <message> <source><b>Attention</b>: Please use this page only if you knows what you do. If your application works correctly then please - do nothing.</source> <translation type="unfinished"></translation> @@ -47,5 +43,9 @@ <source>I know what I'm doing</source> <translation type="unfinished"></translation> </message> + <message> + <source>Fix</source> + <translation type="unfinished"></translation> + </message> </context> </TS>