SimpleQmlNotify
Loading...
Searching...
No Matches
SimpleQmlNotify

Simple Qml notification service for qml applications.

Include

For cmake projects

The cmake build do not required Qt libraries.

  • cd yourRepo
  • git submodule add https://github.com/QuasarApp/SimpleQmlNotify.git # add the repository of QSimpleQmlNotify into your repo like submodule
  • git submodule update –init –recursive
  • Include in your CMakeLists.txt file the main CMakeLists.txt file of QSimpleQmlNotify library
    include(QmlNotyfyService)
  • Rebuild yuor project

For other build system

  • cd yourRepo
  • git submodule add https://github.com/QuasarApp/SimpleQmlNotify.git # add the repository of QSimpleQmlNotify into your repo like submodule
  • git submodule update –init –recursive
  • Add the rule for build QmlNotyfyService
  • Add INCLUDEPATH and LIBS for your build system
  • Rebuild yuor project

Using

Notification

CPP

int main() {
service->setNotify("title", "text", "UrlOfImage", NotificationData::Normal);
}
static NotificationService * getService()
getService This method return instance to notify service.
bool init(QQmlApplicationEngine *engine)

QML

import NotifyModule 1.0
NotificationServiceView {
anchors.fill: parent;
}

Questions

CPP

int main() {
QmlNotificationService::Listner listner = [] (bool accepted) {
// your action here.
};
service->setQuestion(listner, "title", "some text");
}
std::function< void(bool accept)> Listner
Listner This is listner lyambda function of user ansver. This function has next signature: void(bool ...

QML

import NotifyModule 1.0
NotificationServiceView {
anchors.fill: parent;
}
Item {
notificationService.setQuestion(this, "onQuestionCompleted", qsTr("Remove %0 user").arg(userModel.userId),
qsTr("All saved data and records will be delete, Do you want continuee?"));
function onQuestionCompleted(accepted) {
// your action here.
}
}

Include translations

For include translations into your projects you need to use the QuasarAppUtils::Locales class. See oficiald documentation

if(!QuasarAppUtils::Locales::init(locale, {":/qmlNotify_languages/"})) {
QuasarAppUtils::Params::log("Error load language : " , QuasarAppUtils::Error);
}

Or you can manually load needed qm file. All qm files located in qmlNotify_languages folder.