/*! * * Copyright (c) 2021-2024 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 VSettings.h * \author (last) Behrouz NematiPour * \date (last) 18-Jul-2023 * \author (original) Behrouz NematiPour * \date (original) 29-Mar-2021 * */ #pragma once // Qt #include #include // Project #include "main.h" #include "MSettings.h" #include "VView.h" #include "StorageGlobals.h" #include "GuiController.h" namespace View { class VSettings : public QObject { Q_OBJECT QString _location = QString(Storage::Settings_Category_InstructionsImagesLoc).arg(Storage::Settings_Path()); typedef QList TKeysList; typedef struct { QString location; TKeysList keys ; QVariantList values ; } TInstruction ; QMap _instructionMap; typedef qint16 TID ; typedef qint16 TParamIndex ; typedef struct { QString group ; quint16 keyIndex; quint16 locIndex; quint16 prmIndex; QString prmExtra; quint16 prmRound; } TLocation; typedef QList TLocationList; typedef QMap TReplacements; TReplacements _replacements; TRIGGER ( bool , adjustment , 0 ) // TODO: This view needs modification and it needs to isolate the settings and have its own specific properties, not the complete settings exposed to QML and let QML access it. // Don't use QVariantHash, qml doesn't like it and won't show the values, *** and not even complains/errors ***. CONSTANT(QString , groupFormat , "%1^%2" ) PROPERTY(bool , initialized , false ) PROPERTY(QStringList , categorys , {} ) PROPERTY(QVariantMap , instructions , {} ) PROPERTY(bool , isDefaultServicePassword , false ) SETTINGS(QString , servicePass , "" , Storage::Settings_Category_SettingsSystem , "Service" , "Password" ) SETTINGS(quint8 , alarmVolume , 5 , Storage::Settings_Category_SettingsSystem , "Alarm" , "Volume" ) SETTINGS(bool , roWaterMode , false , Storage::Settings_Category_SettingsSystem , "RoWaterMode" , "RoWaterMode" ) SETTINGS(bool , userMode , false , Storage::Settings_Category_SettingsSystem , "UserMode" , "UserMode" ) TRIGGER (bool , encryptionPass, false ) VIEW_DEC(VSettings, SettingsData) private: void initConnectionsSettings(); TKeysList updateReplacements ( const QString &vGroup, const QStringList &vKeys ); void updateInstructions ( const QString &vGroup, const TKeysList &vKeysList, const QVariantList &vValues ); void updateInstructions ( const QString &vGroup ); QString defaultPassword (); bool isPasswordDefault (); QString hashedPassword (const QString &vPassword, bool vIsService); public slots: bool isPasswordHighStrength (const QString &vPassword) const; bool passwordContainsCharacterLimit (const QString &vPassword) const; bool passwordContainsUpperCase (const QString &vPassword) const; bool passwordContainsLowerCase (const QString &vPassword) const; bool passwordContainsDigit (const QString &vPassword) const; bool passwordContainsSymbol (const QString &vPassword) const; bool isServicePasswordMatch (const QString &vPassword); void updateServicePassword (const QString &vPassword); void checkServicePasswordSet (); private slots: void onActionReceive (GuiActionType vAction, const QVariantList &vData); }; }