SimpleQmlNotify/README.md

113 lines
2.6 KiB
Markdown
Raw Permalink Normal View History

2019-11-19 13:28:02 +03:00
# SimpleQmlNotify
Simple Qml notification service for qml applications.
2019-11-19 15:20:38 +03:00
2020-03-30 15:56:56 +03:00
## 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
2021-05-27 10:12:43 +03:00
```cmake
2020-03-30 16:01:45 +03:00
include(QmlNotyfyService)
```
2020-03-30 15:56:56 +03:00
* Rebuild yuor project
2020-03-30 16:01:45 +03:00
2020-03-30 15:56:56 +03:00
### 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
2019-11-19 15:20:38 +03:00
2021-04-16 10:05:32 +03:00
#### CPP
2021-05-27 10:12:43 +03:00
```cpp
2019-11-19 15:20:38 +03:00
#include <qmlnotifyservice.h>
int main() {
QmlNotificationService::init();
auto service = QmlNotificationService::NotificationService::getService();
service->setNotify("title", "text", "UrlOfImage", NotificationData::Normal);
}
```
2021-04-16 10:05:32 +03:00
#### QML
2019-11-19 15:20:38 +03:00
2021-05-27 10:12:43 +03:00
```qml
2021-05-27 16:43:56 +03:00
import NotifyModule 1.0
2019-11-19 15:20:38 +03:00
NotificationServiceView {
anchors.fill: parent;
}
```
### Questions
2021-04-16 10:05:32 +03:00
#### CPP
2021-05-27 10:12:43 +03:00
```cpp
#include <qmlnotifyservice.h>
int main() {
QmlNotificationService::init();
auto service = QmlNotificationService::NotificationService::getService();
2021-10-21 18:46:18 +03:00
QmlNotificationService::Listner listner = [] (bool accepted) {
// your action here.
};
service->setQuestion(listner, "title", "some text");
}
```
2021-04-16 10:05:32 +03:00
#### QML
2021-05-27 10:12:43 +03:00
```qml
2021-05-27 16:43:56 +03:00
import NotifyModule 1.0
NotificationServiceView {
anchors.fill: parent;
}
2021-10-21 18:46:18 +03:00
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.
}
}
```
2021-05-05 17:46:04 +03:00
### Include translations
For include translations into your projects you need to use the QuasarAppUtils::Locales class. See oficiald [documentation](https://quasarapp.ddns.net:3031/docs/QuasarApp/QuasarAppLib/latest/classQuasarAppUtils_1_1Locales.html)
```cpp
if(!QuasarAppUtils::Locales::init(locale, {":/qmlNotify_languages/"})) {
QuasarAppUtils::Params::log("Error load language : " , QuasarAppUtils::Error);
}
```
Or you can manually load needed qm file.
2021-05-27 10:12:43 +03:00
All qm files located in qmlNotify_languages folder.