Index: denali.pro =================================================================== diff -u -r96b249bba7de97afe17cfbdaf02250dbded38f4b -r50199c98f47d614c1e3132963f68d3a81692e9e1 --- denali.pro (.../denali.pro) (revision 96b249bba7de97afe17cfbdaf02250dbded38f4b) +++ denali.pro (.../denali.pro) (revision 50199c98f47d614c1e3132963f68d3a81692e9e1) @@ -162,6 +162,7 @@ sources/view/VVitals.h \ sources/view/VNetworkModel.h \ sources/view/VDateTime.h \ + sources/view/VServiceMode.h \ \ # ---------- Views - Alarm sources/view/hd/alarm/VAlarmStatus.h \ \ # ---------- Views - HD - Adjustment @@ -317,6 +318,7 @@ sources/view/VVitals.cpp \ sources/view/VNetworkModel.cpp \ sources/view/VDateTime.cpp \ + sources/view/VServiceMode.cpp \ \ # ---------- Views - Alarm sources/view/hd/alarm/VAlarmStatus.cpp \ \ # ---------- Views - HD - Adjustment Index: denali.pro.user =================================================================== diff -u -r0f0a1ba80bba810155cfde30c054d94e7ac3fe0e -r50199c98f47d614c1e3132963f68d3a81692e9e1 --- denali.pro.user (.../denali.pro.user) (revision 0f0a1ba80bba810155cfde30c054d94e7ac3fe0e) +++ denali.pro.user (.../denali.pro.user) (revision 50199c98f47d614c1e3132963f68d3a81692e9e1) @@ -1,6 +1,6 @@ - + EnvironmentId Index: denali.qrc =================================================================== diff -u -r96b249bba7de97afe17cfbdaf02250dbded38f4b -r50199c98f47d614c1e3132963f68d3a81692e9e1 --- denali.qrc (.../denali.qrc) (revision 96b249bba7de97afe17cfbdaf02250dbded38f4b) +++ denali.qrc (.../denali.qrc) (revision 50199c98f47d614c1e3132963f68d3a81692e9e1) @@ -17,6 +17,7 @@ sources/gui/qml/dialogs/Alert.qml sources/gui/qml/dialogs/VitalsEntry.qml sources/gui/qml/dialogs/WifiJoinDisconnect.qml + sources/gui/qml/dialogs/ServiceLogin.qml sources/gui/qml/dialogs/DisconnectNetwork.qml Index: sources/gui/GuiGlobals.cpp =================================================================== diff -u -r96b249bba7de97afe17cfbdaf02250dbded38f4b -r50199c98f47d614c1e3132963f68d3a81692e9e1 --- sources/gui/GuiGlobals.cpp (.../GuiGlobals.cpp) (revision 96b249bba7de97afe17cfbdaf02250dbded38f4b) +++ sources/gui/GuiGlobals.cpp (.../GuiGlobals.cpp) (revision 50199c98f47d614c1e3132963f68d3a81692e9e1) @@ -77,6 +77,7 @@ #include "VTreatmentAdjustmentPressuresLimits.h" #include "VTreatmentAdjustmentVersions.h" #include "VDateTime.h" +#include "VServiceMode.h" namespace Gui { MainView *_viewer = nullptr; Index: sources/gui/qml/dialogs/ServiceLogin.qml =================================================================== diff -u --- sources/gui/qml/dialogs/ServiceLogin.qml (revision 0) +++ sources/gui/qml/dialogs/ServiceLogin.qml (revision 50199c98f47d614c1e3132963f68d3a81692e9e1) @@ -0,0 +1,97 @@ +/*! + * + * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. + * \copyright + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN + * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * \file Alert.qml + * \author (last) Peter Lucia + * \date (last) 30-Nov-2020 + * \author (original) Peter Lucia + * \date (original) 30-Nov-2019 + * + */ + +// Qt +import QtQuick 2.12 + +// Project +// Qml imports +import "qrc:/globals" +import "qrc:/components" + +/*! + * \brief Contains the Service Login Implementation + */ +ModalDialog { id: _root + property string ssid : "" + property string macAddress : "" + objectName : "ServiceLogin" // SquishQt testability + contentItem.objectName : "ServiceLoginContent" + modal : false + + onVisibleChanged: { + if (!visible) { + _password.textInput.focus = false + } + } + + Item { id: _titleBar + height: _root.height / 4 + width: _root.width + + Text { id: _titleBarText + color: Colors.textMain + font.pixelSize: Fonts.fontPixelTitle + text: qsTr("Service Mode Login") + anchors.centerIn: _titleBar + } + } + + TextEntry { id: _password + textInput.width: Variables.settingsInputWidth + line.width: Variables.settingsInputWidth + label.width: Variables.settingsInputWidth + anchors { + horizontalCenter: parent.horizontalCenter + top: _titleBar.bottom + topMargin: Variables.settingsMargin + } + textInput.inputMethodHints: Qt.ImhNone + textInput.echoMode: TextInput.Password + labelText: qsTr("Password: ") + onEnterPressed: { + _keyboard.setVisible(false) + textInput.focus = false + } + } + + Row { id: _buttons + spacing: Variables.buttonSpacing + anchors { + horizontalCenter: parent.horizontalCenter + bottom: parent.bottom + bottomMargin: Variables.dialogMargin / 2 + } + + TouchRect { id: _confirm + objectName: "_serviceModeLoginConfirm" + width: _root.width / 3 + text.text: qsTr("CONFIRM") + button.onPressed: { + vServiceMode.doLogin(_password.textInput.text) + close() + } + } + + TouchRect { id: _cancel + objectName: "_serviceModeLoginCancel" + width: _root.width / 3 + text.text: qsTr("CANCEL") + button.onPressed: { + close() + } + } + } +} Index: sources/gui/qml/main.qml =================================================================== diff -u -r96b249bba7de97afe17cfbdaf02250dbded38f4b -r50199c98f47d614c1e3132963f68d3a81692e9e1 --- sources/gui/qml/main.qml (.../main.qml) (revision 96b249bba7de97afe17cfbdaf02250dbded38f4b) +++ sources/gui/qml/main.qml (.../main.qml) (revision 50199c98f47d614c1e3132963f68d3a81692e9e1) @@ -72,6 +72,7 @@ import VAlert 0.1; import VNetworkModel 0.1; import VDateTime 0.1; +import VServiceMode 0.1; // Qml imports import "qrc:/globals" @@ -140,6 +141,7 @@ VAlert { id: vAlert } VNetworkModel { id: vNetworkModel } VDateTime { id: vDateTime } + VServiceMode { id: vServiceMode } VHDTreatmentStates { id: vHDTreatmentStates } @@ -174,6 +176,7 @@ _managerStack .visible = vIndex == 1; _settingsStack .visible = vIndex == 2; } + visible: !vServiceMode.isServiceMode } // 4 - Modals @@ -301,9 +304,11 @@ visible: true // ! _GuiView.sdIsReady || _GuiView.sdIsReadOnly } + // dialogs Alert { id: _alert } VitalsEntry { id: _vitalsEntry } WifiJoinDisconnect { id: _wifiJoinDisconnect } + ServiceLogin { id: _serviceLogin } Keyboard { id: _keyboard } Connections { target: vPowerOff Index: sources/gui/qml/pages/SettingsHome.qml =================================================================== diff -u -r96b249bba7de97afe17cfbdaf02250dbded38f4b -r50199c98f47d614c1e3132963f68d3a81692e9e1 --- sources/gui/qml/pages/SettingsHome.qml (.../SettingsHome.qml) (revision 96b249bba7de97afe17cfbdaf02250dbded38f4b) +++ sources/gui/qml/pages/SettingsHome.qml (.../SettingsHome.qml) (revision 50199c98f47d614c1e3132963f68d3a81692e9e1) @@ -103,7 +103,7 @@ color: Colors.textMain font.italic: true font.pixelSize: Fonts.fontPixelDialogText - visible: true // TODO: set visible if in service mode + visible: vServiceMode.isServiceMode } /* @@ -157,11 +157,9 @@ SettingsItem { id: _item_serviceMode title : qsTr("Service Mode") onClicked: { - // TODO: Ask for service password before setting service mode to true - // TODO: Hide main menu and enable shutdown button - console.debug("Clicked login to service mode"); + _serviceLogin.visible = true } - visible: true // TODO: set to false if already in service mode + visible: !vServiceMode.isServiceMode } SettingsItem { id: _itemDateTimeSet title : qsTr("Set Date and Time") @@ -171,6 +169,21 @@ } } } -} - + TouchRect { id: _scan + anchors { + bottom: _root.bottom + bottomMargin: Variables.settingsMargin + horizontalCenter: _root.horizontalCenter + } + visible: vServiceMode.isServiceMode + backgroundColor: Colors.backgroundButtonNormal + textColor: Colors.textMain + height: Variables.settingsButtonHeight + width: Variables.settingsButtonWidth + text.text: qsTr("Shutdown") + onClicked: { + _powerOffDialog.open() + } + } +} Index: sources/view/VServiceMode.cpp =================================================================== diff -u --- sources/view/VServiceMode.cpp (revision 0) +++ sources/view/VServiceMode.cpp (revision 50199c98f47d614c1e3132963f68d3a81692e9e1) @@ -0,0 +1,32 @@ + +// Qt + +// Project +#include "VServiceMode.h" +#include "Logger.h" + +using namespace View; +using namespace Gui; + +VIEW_DEF_CLASS(VServiceMode) + +/*! + * \brief VDateTime::initConnections + * Makes the necessary connections. Called inside VIEW_DEF_CLASS + */ +void VServiceMode::initConnections() {} + + +/*! + * \brief VServiceMode::doLogin + * Called when user logs in to service mode + * \param vPassword - (QString) the provided password + */ +void VServiceMode::doLogin(const QString &vPassword) +{ + if (vPassword == _password) { + isServiceMode(true); + } else { + emit didLoginFailed(); + } +} Index: sources/view/VServiceMode.h =================================================================== diff -u --- sources/view/VServiceMode.h (revision 0) +++ sources/view/VServiceMode.h (revision 50199c98f47d614c1e3132963f68d3a81692e9e1) @@ -0,0 +1,39 @@ + +#pragma once + +// Qt +#include + +// Project +#include "VView.h" +#include "main.h" +#include "GuiController.h" + +// forward declarations +class tst_views; + +namespace View { + +/*! + * \brief The VServiceMode class + * \details View for handling service mode + * + */ +class VServiceMode : public QObject +{ + Q_OBJECT + const QString _password = "1234"; + + // friends + friend class ::tst_views; + +VIEW_DEC_CLASS(VServiceMode) + +protected: + PROPERTY(bool, isServiceMode, false) +signals: + void didLoginFailed(); +public slots: + void doLogin(const QString &vPassword); +}; +} Index: sources/view/VView.h =================================================================== diff -u -rb5a7852d2637f7969680fbd3d2c821a6a74a8ccd -r50199c98f47d614c1e3132963f68d3a81692e9e1 --- sources/view/VView.h (.../VView.h) (revision b5a7852d2637f7969680fbd3d2c821a6a74a8ccd) +++ sources/view/VView.h (.../VView.h) (revision 50199c98f47d614c1e3132963f68d3a81692e9e1) @@ -152,6 +152,7 @@ REGISTER_TYPE( VVitals ) \ REGISTER_TYPE( VAlert ) \ REGISTER_TYPE( VNetworkModel ) \ - REGISTER_TYPE( VDateTime ) + REGISTER_TYPE( VDateTime ) \ + REGISTER_TYPE( VServiceMode ) //--------------------------------------------------------------------------------//