Skip to content

This is simple library for create productions fixes for your applications.

License

Notifications You must be signed in to change notification settings

QuasarApp/DoctorPill

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Doctor Pill

The Doctor pill is simple qt / qml library for fast develop fixes for applications that already released and working in production.

The library has c++ interface DP::iPill and QML view for diagnostic gui applications.

For Disable the gui part of the library use the DOCTOR_PILL_GUI option.

2022-01-18 17-50-20

BUILD OPTIONS

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
 git submodule add https://github.com/QuasarApp/DoctorPill.git
  1. Add to build the DoctorPill as a subdirectory
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.

#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

#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)

#include <doctorpillgui.h>

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)

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
    }
}