mirror of
https://github.com/QuasarApp/Snake.git
synced 2025-05-09 07:59:48 +00:00
Merge pull request #26 from QuasarApp/notificationService
added notify service
This commit is contained in:
commit
120303a0e3
SnakeClient/SnakeApp
SnakeApp.pro
back-end
ProfileViewItems
mainclient.cppmainclient.hmainmenumodel.hnotificationdata.cppnotificationdata.hnotificationservice.cppnotificationservice.h
clientapp.cppcontroller.cppcontroller.hfront-end
BasePopUp.qmlLoginView.qmlNotificationForm.qmlNotificationServiceView.qmlPagePopUp.qmlScene.qmlmain.qml
qml.qrc@ -16,6 +16,7 @@ SOURCES += \
|
||||
back-end/ProfileViewItems/mainclient.cpp \
|
||||
back-end/ProfileViewItems/mainmenumodel.cpp \
|
||||
back-end/ProfileViewItems/networkclient.cpp \
|
||||
back-end/ProfileViewItems/notificationdata.cpp \
|
||||
back-end/ProfileViewItems/notificationservice.cpp \
|
||||
back-end/ProfileViewItems/playerclientdata.cpp \
|
||||
back-end/ProfileViewItems/settingsviewmodel.cpp \
|
||||
@ -92,6 +93,7 @@ HEADERS += \
|
||||
back-end/ProfileViewItems/mainclient.h \
|
||||
back-end/ProfileViewItems/mainmenumodel.h \
|
||||
back-end/ProfileViewItems/networkclient.h \
|
||||
back-end/ProfileViewItems/notificationdata.h \
|
||||
back-end/ProfileViewItems/notificationservice.h \
|
||||
back-end/ProfileViewItems/playerclientdata.h \
|
||||
back-end/ProfileViewItems/settingsviewmodel.h \
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "mainclient.h"
|
||||
#include "notificationservice.h"
|
||||
#include "playerclientdata.h"
|
||||
|
||||
#include <QSharedPointer>
|
||||
@ -12,6 +13,8 @@ void MainClient::setOnlineStatus(OnlineStatus onlineStatus) {
|
||||
return;
|
||||
|
||||
emit sigOnlineStatusChanged(_onlineStatus = onlineStatus);
|
||||
pushNotify(onlineStatus);
|
||||
|
||||
}
|
||||
|
||||
void MainClient::clientStatusChanged() {
|
||||
@ -28,6 +31,64 @@ void MainClient::clientStatusChanged() {
|
||||
setOnlineStatus(status);
|
||||
}
|
||||
|
||||
void MainClient::pushNotify(OnlineStatus onlineStatus) {
|
||||
|
||||
|
||||
switch (onlineStatus) {
|
||||
|
||||
case 0: {
|
||||
|
||||
NotificationService::getService()->setNotify(
|
||||
NotificationData(tr("Login status"), tr("Success")));
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// case 1: {
|
||||
|
||||
// NotificationService::getService()->setNotify(
|
||||
// NotificationData(tr("Login status"), tr("Authorization Required")));
|
||||
|
||||
// break;
|
||||
// }
|
||||
|
||||
// case 2: {
|
||||
|
||||
// NotificationService::getService()->setNotify(
|
||||
// NotificationData(tr("Login status"), tr("Wait for answer")));
|
||||
|
||||
// break;
|
||||
// }
|
||||
|
||||
case 3: {
|
||||
|
||||
NotificationService::getService()->setNotify(
|
||||
NotificationData(tr("Login result"), tr("Authorization fail") , "", NotificationData::Error));
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 4: {
|
||||
|
||||
NotificationService::getService()->setNotify(
|
||||
NotificationData(tr("Login result"), tr("Client is offline"), "", NotificationData::Warning));
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 5: {
|
||||
|
||||
NotificationService::getService()->setNotify(
|
||||
NotificationData(tr("Login result"), tr("Offline Mode")));
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default: break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void MainClient::handleReceivePackage(ClientProtocol::Command cmd, const QByteArray &obj) {
|
||||
switch (cmd) {
|
||||
|
||||
@ -45,6 +106,7 @@ void MainClient::handleReceivePackage(ClientProtocol::Command cmd, const QByteAr
|
||||
}
|
||||
|
||||
case ClientProtocol::Command::BadRequest: {
|
||||
|
||||
break;
|
||||
}
|
||||
default: return;
|
||||
|
@ -22,7 +22,7 @@ private:
|
||||
|
||||
void setOnlineStatus(OnlineStatus onlineStatus);
|
||||
void clientStatusChanged();
|
||||
|
||||
void pushNotify(OnlineStatus onlineStatus);
|
||||
|
||||
private slots:
|
||||
void handleReceivePackage(ClientProtocol::Command cmd, const QByteArray& obj);
|
||||
|
@ -17,7 +17,6 @@ class MainMenuModel : public QObject
|
||||
|
||||
Q_PROPERTY(QObject* userViewModel READ userViewModel NOTIFY userViewModelChanged)
|
||||
Q_PROPERTY(QObject* userSettingsModel READ userSettingsModel NOTIFY userSettingsModelChanged)
|
||||
|
||||
Q_PROPERTY(int onlineStatus READ onlineStatus NOTIFY onlineStatusChanged)
|
||||
|
||||
private:
|
||||
@ -36,16 +35,13 @@ public:
|
||||
Q_INVOKABLE void playOffline();
|
||||
Q_INVOKABLE void tryConnect();
|
||||
|
||||
|
||||
public slots:
|
||||
void login(const QString& email, const QString& pass);
|
||||
void registerNewUser(const QString& email, const QString& pass);
|
||||
|
||||
|
||||
signals:
|
||||
void userViewModelChanged(QObject* userViewModel);
|
||||
void newGame();
|
||||
|
||||
void onlinelChanged(bool online);
|
||||
void loginChanged(bool login);
|
||||
void onlineStatusChanged();
|
||||
|
@ -0,0 +1,34 @@
|
||||
#include "notificationdata.h"
|
||||
|
||||
NotificationData::NotificationData(const QString &title,
|
||||
const QString &text,
|
||||
const QString &img, Type type) {
|
||||
|
||||
_text = text;
|
||||
_title = title;
|
||||
_img = img;
|
||||
_type = type;
|
||||
}
|
||||
|
||||
QString NotificationData::text() const {
|
||||
return _text;
|
||||
}
|
||||
|
||||
QString NotificationData::img() const {
|
||||
return _img;
|
||||
}
|
||||
|
||||
QString NotificationData::title() const {
|
||||
return _title;
|
||||
}
|
||||
|
||||
bool NotificationData::operator ==(const NotificationData &righ) {
|
||||
return _title == righ._title &&
|
||||
_text == righ._text &&
|
||||
_img == righ._img &&
|
||||
_type == righ._type;
|
||||
}
|
||||
|
||||
int NotificationData::type() const {
|
||||
return _type;
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
#ifndef NOTIFICATIONDATA_H
|
||||
#define NOTIFICATIONDATA_H
|
||||
#include <QObject>
|
||||
|
||||
class NotificationData
|
||||
{
|
||||
Q_GADGET
|
||||
Q_PROPERTY(QString text READ text)
|
||||
Q_PROPERTY(QString img READ img)
|
||||
Q_PROPERTY(QString title READ title)
|
||||
Q_PROPERTY(int type READ type)
|
||||
|
||||
QString _text;
|
||||
QString _img;
|
||||
QString _title;
|
||||
int _type;
|
||||
|
||||
public:
|
||||
|
||||
enum Type {
|
||||
Normal,
|
||||
Warning = 1,
|
||||
Error = 2,
|
||||
};
|
||||
|
||||
explicit NotificationData(const QString& title = "",
|
||||
const QString& text = "",
|
||||
const QString& img = "",
|
||||
Type type = Type::Normal);
|
||||
|
||||
Q_INVOKABLE QString text() const;
|
||||
Q_INVOKABLE QString img() const;
|
||||
Q_INVOKABLE QString title() const;
|
||||
Q_INVOKABLE int type() const;
|
||||
|
||||
bool operator ==(const NotificationData &righ);
|
||||
};
|
||||
|
||||
#endif // NOTIFICATIONDATA_H
|
@ -1,6 +1,37 @@
|
||||
#include "notificationservice.h"
|
||||
|
||||
NotificationService::NotificationService()
|
||||
{
|
||||
NotificationService::NotificationService(QObject * ptr): QObject (ptr) {
|
||||
qRegisterMetaType<NotificationData>("NotificationData");
|
||||
qRegisterMetaType<QList<NotificationData>> ("QList<NotificationData>");
|
||||
|
||||
}
|
||||
|
||||
NotificationData NotificationService::notify() const {
|
||||
return _notify;
|
||||
}
|
||||
|
||||
void NotificationService::setNotify(const NotificationData& notify) {
|
||||
if (_notify == notify)
|
||||
return;
|
||||
|
||||
_notify = notify;
|
||||
_history.push_back(_notify);
|
||||
|
||||
emit notifyChanged();
|
||||
}
|
||||
|
||||
void NotificationService::setNotify(const QString &title,
|
||||
const QString &text,
|
||||
const QString &img,
|
||||
NotificationData::Type type) {
|
||||
setNotify(NotificationData(title, text, img, type));
|
||||
}
|
||||
|
||||
NotificationService *NotificationService::getService() {
|
||||
static auto service = new NotificationService;
|
||||
return service;
|
||||
}
|
||||
|
||||
const QList<NotificationData> &NotificationService::history() const {
|
||||
return _history;
|
||||
}
|
||||
|
@ -1,12 +1,39 @@
|
||||
#ifndef NOTIFICATIONSERVICE_H
|
||||
#define NOTIFICATIONSERVICE_H
|
||||
|
||||
#include "notificationdata.h"
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class NotificationService
|
||||
class NotificationService: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(NotificationData notify READ notify NOTIFY notifyChanged)
|
||||
Q_PROPERTY(QList<NotificationData> history READ history NOTIFY notifyChanged)
|
||||
|
||||
private:
|
||||
explicit NotificationService(QObject *ptr = nullptr);
|
||||
|
||||
NotificationData _notify;
|
||||
QList<NotificationData> _history;
|
||||
|
||||
public:
|
||||
NotificationService();
|
||||
NotificationData notify() const;
|
||||
void setNotify(const NotificationData ¬ify);
|
||||
Q_INVOKABLE void setNotify(const QString& title = "",
|
||||
const QString& text = "",
|
||||
const QString& img = "",
|
||||
NotificationData::Type type = NotificationData::Normal);
|
||||
|
||||
static NotificationService* getService();
|
||||
|
||||
const QList<NotificationData> & history() const;
|
||||
|
||||
signals:
|
||||
void notifyChanged();
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // NOTIFICATIONSERVICE_H
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <QQmlContext>
|
||||
|
||||
#include <back-end/ProfileViewItems/mainmenumodel.h>
|
||||
#include <back-end/ProfileViewItems/notificationservice.h>
|
||||
|
||||
QByteArray ClientApp::initTheme() {
|
||||
int themeIndex = Settings::get()->getValue(THEME, THEME_DEFAULT).toInt();
|
||||
@ -39,6 +40,7 @@ bool ClientApp::init(QQmlApplicationEngine *engine) {
|
||||
engine->addImageProvider(QLatin1String("userItems"), new ImageProvider());
|
||||
|
||||
root->setContextProperty("contr", &contr);
|
||||
root->setContextProperty("notificationService", NotificationService::getService());
|
||||
|
||||
engine->load(QUrl(QStringLiteral("qrc:/front-end/main.qml")));
|
||||
if (engine->rootObjects().isEmpty())
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "diff.h"
|
||||
#include <lvls.h>
|
||||
#include "ProfileViewItems/mainmenumodel.h"
|
||||
#include <back-end/ProfileViewItems/notificationservice.h>
|
||||
|
||||
Controller::Controller() {
|
||||
srand(static_cast<unsigned int>(time(nullptr)));
|
||||
@ -63,14 +64,29 @@ void Controller::update() {
|
||||
}
|
||||
|
||||
world.render();
|
||||
|
||||
if(world.isDefiat()) {
|
||||
stopTimer();
|
||||
emit finished(false, lvl, world.getCurrentLong());
|
||||
if (!_showMenu) {
|
||||
setShowMenu(true);
|
||||
}
|
||||
handleNewGame();
|
||||
}
|
||||
|
||||
if (world.isEnd()) {
|
||||
stopTimer();
|
||||
emit finished(true, lvl, world.getCurrentLong());
|
||||
|
||||
if (!_showMenu) {
|
||||
|
||||
NotificationData notify(tr(" Next Lvl!!!"),
|
||||
tr(" You anblock next lvl (%0)" ).arg(lvl),
|
||||
"qrc:/texture/up");
|
||||
|
||||
NotificationService::getService()->setNotify(notify);
|
||||
}
|
||||
|
||||
nextLvl();
|
||||
|
||||
}
|
||||
|
||||
long_changed(static_cast<int>(world.getCurrentLong()));
|
||||
@ -124,3 +140,15 @@ void Controller::setPause(bool p){
|
||||
}
|
||||
}
|
||||
|
||||
bool Controller::showMenu() const {
|
||||
return _showMenu;
|
||||
}
|
||||
|
||||
void Controller::setShowMenu(bool showMenu) {
|
||||
if (_showMenu == showMenu)
|
||||
return;
|
||||
|
||||
_showMenu = showMenu;
|
||||
emit showMenuChanged(_showMenu);
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,7 @@ class Controller : public QObject
|
||||
Q_PROPERTY(int long_ READ long_ NOTIFY long_changed)
|
||||
Q_PROPERTY(int generalLong READ generalLong NOTIFY generalLongchanged)
|
||||
Q_PROPERTY(QObject* mainMenuModel READ mainMenuModel NOTIFY mainMenuModelchanged)
|
||||
Q_PROPERTY(bool showMenu READ showMenu WRITE setShowMenu NOTIFY showMenuChanged)
|
||||
|
||||
private:
|
||||
|
||||
@ -27,6 +28,7 @@ private:
|
||||
int lvl = 0;
|
||||
int m_generalLong = 0;
|
||||
bool pause = false;
|
||||
bool _showMenu = true;
|
||||
|
||||
void generateDiff(const QMap<int, GuiObject *> &);
|
||||
|
||||
@ -40,16 +42,14 @@ public:
|
||||
void stopTimer();
|
||||
|
||||
int long_() const;
|
||||
|
||||
int generalLong() const;
|
||||
bool showMenu() const;
|
||||
|
||||
QObject* mainMenuModel() const;
|
||||
|
||||
public slots:
|
||||
void buttonPress();
|
||||
|
||||
void setPause(bool);
|
||||
|
||||
void update();
|
||||
|
||||
/**
|
||||
@ -70,14 +70,9 @@ public slots:
|
||||
*/
|
||||
QObject* getGameObject(int id);
|
||||
|
||||
void setShowMenu(bool showMenu);
|
||||
|
||||
signals:
|
||||
/**
|
||||
* @brief finished - imited when game over or victory
|
||||
* @param victory - flag of vicrory, if it equals false then game over
|
||||
* @param lvl - game over lvl
|
||||
* @param distance - game over distance
|
||||
*/
|
||||
void finished(bool victory, int lvl, double distance);
|
||||
|
||||
/**
|
||||
* @brief gameObjectsChanged
|
||||
@ -87,6 +82,7 @@ signals:
|
||||
void long_changed(int m_long);
|
||||
void generalLongchanged(int generalLong);
|
||||
void mainMenuModelchanged(QObject* mainMenuModel);
|
||||
void showMenuChanged(bool showMenu);
|
||||
};
|
||||
|
||||
#endif // CONTROLLER_H
|
||||
|
@ -2,7 +2,7 @@ import QtQuick 2.11
|
||||
import QtQuick.Controls 2.3
|
||||
import QtQuick.Controls.Material 2.0
|
||||
import QtQuick.Layouts 1.3
|
||||
import QtGraphicalEffects 1.13
|
||||
import QtGraphicalEffects 1.12
|
||||
|
||||
Dialog {
|
||||
id : basePopup
|
||||
|
@ -8,15 +8,6 @@ Item {
|
||||
id: element
|
||||
|
||||
property int loginStatus : 0
|
||||
readonly property var resultLoginEnum: [
|
||||
qsTr("Success"), // 0
|
||||
qsTr("Authorization Required"), // 1
|
||||
qsTr("Wait for answer"), // 2
|
||||
qsTr("Authorization fail"), // 3
|
||||
qsTr("Client is offline "), // 4
|
||||
qsTr("Offline Mode "), // 5
|
||||
|
||||
]
|
||||
|
||||
readonly property int currentView: tabBar.currentIndex
|
||||
readonly property var resultEnum: [
|
||||
@ -231,8 +222,11 @@ Item {
|
||||
sigLogin(loginEmail.text, loginPass.text);
|
||||
}
|
||||
} else {
|
||||
errorMessage.text = resultEnum[messageIndex];
|
||||
errorMessage._show();
|
||||
|
||||
notificationService.notify(qsTr("Error"),
|
||||
resultEnum[messageIndex],
|
||||
"",
|
||||
2);
|
||||
}
|
||||
}
|
||||
|
||||
@ -243,33 +237,11 @@ Item {
|
||||
anchors.right: parent.right
|
||||
}
|
||||
|
||||
BasePopUp {
|
||||
id: errorMessage;
|
||||
property string text: ""
|
||||
Label {
|
||||
id: sourceText;
|
||||
wrapMode: Text.WordWrap
|
||||
text: errorMessage.text
|
||||
anchors.fill: parent
|
||||
}
|
||||
backgroundColor: "#ff4f28"
|
||||
closeInterval: 5000
|
||||
|
||||
height: 2 * metrix.controlPtMaterial;
|
||||
width: 7 * metrix.controlPtMaterial;
|
||||
x: 0;
|
||||
y: 0;
|
||||
}
|
||||
|
||||
onLoginStatusChanged: {
|
||||
if (loginStatus === 2)
|
||||
busy._show();
|
||||
else {
|
||||
busy.close();
|
||||
if (loginStatus > 2) {
|
||||
errorMessage._show();
|
||||
errorMessage.text = resultLoginEnum[loginStatus];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,57 +6,49 @@ import QtQuick.Layouts 1.3
|
||||
BasePopUp {
|
||||
id : popup
|
||||
|
||||
autoClose: true;
|
||||
closeInterval: 5000
|
||||
function show(title_, message_, img_) {
|
||||
title.text = title_;
|
||||
message.text = message_;
|
||||
if (img_) {
|
||||
image.source = img_;
|
||||
} else {
|
||||
image.source = "";
|
||||
property string text: qsTr("Message")
|
||||
property string img: ""
|
||||
property string titleText: qsTr("Message")
|
||||
property int type: 0
|
||||
|
||||
function _getBackGraundColor(type) {
|
||||
switch(type){
|
||||
case 1: return "#FFC107"
|
||||
case 2: return "#FF5722"
|
||||
}
|
||||
|
||||
_show();
|
||||
return Material.background
|
||||
}
|
||||
|
||||
autoClose: true;
|
||||
closeInterval: 5000
|
||||
|
||||
margins: 0
|
||||
margin: 0
|
||||
spacing: 0
|
||||
|
||||
|
||||
backgroundColor: _getBackGraundColor(type);
|
||||
|
||||
Page {
|
||||
id: page
|
||||
title: "Level Up!!!"
|
||||
anchors.fill: parent
|
||||
spacing: 0
|
||||
|
||||
|
||||
Label {
|
||||
id: title
|
||||
x: 0
|
||||
width: 200
|
||||
height: 31
|
||||
text: qsTr("Title Message")
|
||||
font.bold: true
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: 0
|
||||
font.pointSize: 13
|
||||
fontSizeMode: Text.Fit
|
||||
renderType: Text.QtRendering
|
||||
textFormat: Text.AutoText
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
wrapMode: Text.WordWrap
|
||||
background: Rectangle {
|
||||
color: "#00000000"
|
||||
}
|
||||
|
||||
header: Label {
|
||||
text: titleText
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
}
|
||||
|
||||
contentItem:
|
||||
RowLayout {
|
||||
id: rowLayout
|
||||
spacing: 5
|
||||
clip: true
|
||||
anchors.top: title.bottom
|
||||
anchors.topMargin: 1
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: 0
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: 0
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.bottomMargin: 0
|
||||
|
||||
Rectangle {
|
||||
color: "#00000000"
|
||||
@ -69,14 +61,14 @@ BasePopUp {
|
||||
fillMode: Image.PreserveAspectCrop
|
||||
clip: true
|
||||
anchors.fill: parent;
|
||||
source: ""
|
||||
source: img
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Label {
|
||||
id: message
|
||||
text: qsTr("Message")
|
||||
text: popup.text
|
||||
Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
|
||||
Layout.fillHeight: true;
|
||||
Layout.fillWidth: true;
|
||||
|
30
SnakeClient/SnakeApp/front-end/NotificationServiceView.qml
Normal file
30
SnakeClient/SnakeApp/front-end/NotificationServiceView.qml
Normal file
@ -0,0 +1,30 @@
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Controls.Material 2.12
|
||||
import QtQuick.Controls 2.12
|
||||
import QtQuick.Layouts 1.3
|
||||
import QtGraphicalEffects 1.12
|
||||
|
||||
Item {
|
||||
readonly property var model: notificationService;
|
||||
readonly property var msg: model.notify
|
||||
readonly property var history: model.history
|
||||
|
||||
|
||||
NotificationForm {
|
||||
id: notyfyView
|
||||
titleText : msg.title;
|
||||
text: (msg)? msg.text: "";
|
||||
img: (msg)? msg.img: "";
|
||||
type: (msg)? msg.type: 0;
|
||||
|
||||
x: parent.width - width - margin;
|
||||
y: margin;
|
||||
|
||||
width: 6 * metrix.controlPtMaterial;
|
||||
height: width * 0.5
|
||||
}
|
||||
|
||||
onMsgChanged: {
|
||||
notyfyView._show();
|
||||
}
|
||||
}
|
@ -14,6 +14,9 @@ BasePopUp {
|
||||
}
|
||||
|
||||
onSourceChanged: {
|
||||
if (!source)
|
||||
return;
|
||||
|
||||
source.parent = sourceVal;
|
||||
source.anchors.fill = sourceVal;
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ Item {
|
||||
|
||||
property var model: null;
|
||||
property var arrayObjects: []
|
||||
property bool showMenu: true
|
||||
readonly property bool showMenu: (model)? model.showMenu: false
|
||||
property bool isPause: false
|
||||
|
||||
function add (cppObjId) {
|
||||
@ -112,29 +112,6 @@ Item {
|
||||
remove(tempDifRem[i]);
|
||||
}
|
||||
}
|
||||
|
||||
onFinished: {
|
||||
|
||||
var isVictory = victory;
|
||||
var gameLvl = lvl + 1;
|
||||
var dist = distance;
|
||||
updateBackgroundColor(gameLvl);
|
||||
|
||||
if (isVictory ) {
|
||||
|
||||
if (!autoTimer.running)
|
||||
notification.show(qsTr(" Next Lvl!!!"),
|
||||
qsTr(" You anblock next lvl (" + gameLvl + ")" ),
|
||||
"qrc:/texture/up");
|
||||
|
||||
model.nextLvl();
|
||||
} else if (autoTimer.running) {
|
||||
model.handleNewGame();
|
||||
} else {
|
||||
showMenu = true;
|
||||
model.handleNewGame();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
@ -155,19 +132,6 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
NotificationForm {
|
||||
z: -1
|
||||
id: notification;
|
||||
margin: metrix.gamePt;
|
||||
|
||||
x: parent.width - width - margin;
|
||||
y: margin;
|
||||
|
||||
width: 40 * metrix.gamePt;
|
||||
height: width * 0.5
|
||||
|
||||
}
|
||||
|
||||
Button {
|
||||
id: returnToMenu;
|
||||
|
||||
@ -181,7 +145,8 @@ Item {
|
||||
z: 1
|
||||
|
||||
onClicked: {
|
||||
showMenu = true;
|
||||
if (model)
|
||||
model.showMenu = true;
|
||||
}
|
||||
|
||||
visible: !showMenu
|
||||
|
@ -5,8 +5,8 @@ import QtQuick.Controls 2.12
|
||||
ApplicationWindow {
|
||||
id: mainWindow;
|
||||
visible: true;
|
||||
width: 1140;
|
||||
height: 540;
|
||||
width: 640;
|
||||
height: 480;
|
||||
title: qsTr("SnakeOnTheRoad");
|
||||
|
||||
Component.onCompleted: {
|
||||
@ -29,8 +29,12 @@ ApplicationWindow {
|
||||
visible: scane.showMenu;
|
||||
|
||||
onPlayGame: {
|
||||
scane.showMenu = false;
|
||||
contr.showMenu = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
NotificationServiceView {
|
||||
anchors.fill: parent;
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,7 @@
|
||||
<file>front-end/LeftSideBar.qml</file>
|
||||
<file>front-end/LeftBoxSideBar.qml</file>
|
||||
<file>front-end/SettingsView.qml</file>
|
||||
<file>front-end/NotificationServiceView.qml</file>
|
||||
</qresource>
|
||||
<qresource prefix="/texture">
|
||||
<file alias="up">img/up.svg</file>
|
||||
|
Loading…
x
Reference in New Issue
Block a user