diff --git a/.gitignore b/.gitignore index f147edf..6ad6e26 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,8 @@ *.so.* *.dll *.dylib +*/build/* +DistributionKit # Qt-es object_script.*.Release diff --git a/CMake/ProjectOut.cmake b/CMake/ProjectOut.cmake new file mode 100644 index 0000000..994e7b1 --- /dev/null +++ b/CMake/ProjectOut.cmake @@ -0,0 +1,32 @@ +# +# Copyright (C) 2018-2020 QuasarApp. +# Distributed under the MIT software license, see the accompanying +# Everyone is permitted to copy and distribute verbatim copies +# of this license document, but changing it is not allowed. +# + +if(DEFINED PROJECT_OUT_SUPPORT) + return() +else() + set(PROJECT_OUT_SUPPORT 1) +endif() + +IF(NOT CMAKE_BUILD_TYPE) + SET(CMAKE_BUILD_TYPE Release) +ENDIF(NOT CMAKE_BUILD_TYPE) + +SET(LIB_OUTPUT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/build/${CMAKE_BUILD_TYPE}) + +message("${} LIB_OUTPUT_DIR = ${LIB_OUTPUT_DIR}") + + +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIB_OUTPUT_DIR}/lib) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIB_OUTPUT_DIR}/lib) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LIB_OUTPUT_DIR}/bin) + +message(STATUS "buid type " ${CMAKE_BUILD_TYPE}) +message(STATUS "Project " ${PROJECT_NAME}) +message(STATUS "c compiler " ${CMAKE_C_COMPILER}) +message(STATUS "cxx compiler " ${CMAKE_CXX_COMPILER}) +message(STATUS "build shared " ${BUILD_SHARED_LIBS}) +message(STATUS "qmake exec " ${QT_QMAKE_EXECUTABLE}) diff --git a/CQtDeployer.json b/CQtDeployer.json new file mode 100644 index 0000000..08dd2fd --- /dev/null +++ b/CQtDeployer.json @@ -0,0 +1,11 @@ +{ + "binDir": "./example/build/Release/bin", + "clear": true, + "libDir": "./", + "recursiveDepth": "5", + "qif": true, + "qifStyle": "quasar", + "qifLogo": "./res/logo2.png", + "icon": "./res/logo2.png", + "qmlDir": "./" +} diff --git a/LoginView/CMakeLists.txt b/LoginView/CMakeLists.txt index 16b7582..2090923 100644 --- a/LoginView/CMakeLists.txt +++ b/LoginView/CMakeLists.txt @@ -16,6 +16,8 @@ set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(LOGIN_VIEW_LIBRARY ON) +include(${CMAKE_CURRENT_SOURCE_DIR}/../CMake/ProjectOut.cmake) + find_package(Qt5 COMPONENTS Core Quick Xml REQUIRED) file(GLOB SOURCE_CPP "src/*.cpp" "src/*.qrc") diff --git a/LoginView/src/mainmodel.cpp b/LoginView/src/lvmainmodel.cpp similarity index 83% rename from LoginView/src/mainmodel.cpp rename to LoginView/src/lvmainmodel.cpp index 227f955..a78a257 100644 --- a/LoginView/src/mainmodel.cpp +++ b/LoginView/src/lvmainmodel.cpp @@ -6,7 +6,7 @@ //# #include "countrysparser.h" -#include "mainmodel.h" +#include "lvmainmodel.h" #include <QXmlStreamReader> #include <QQmlApplicationEngine> #include <QQmlContext> @@ -15,7 +15,7 @@ namespace LoginView { -MainModel::MainModel(const QString modelName, QObject *parent) +LVMainModel::LVMainModel(const QString modelName, QObject *parent) : QObject(parent) { m_modelName = modelName; m_validLvl = static_cast<PasswordValidationLvl>( @@ -24,13 +24,13 @@ MainModel::MainModel(const QString modelName, QObject *parent) PasswordValidationLvl::LatinLargeChars); } -MainModel::~MainModel() { +LVMainModel::~LVMainModel() { if (m_countrysParser) { delete m_countrysParser; } } -bool MainModel::setCounrySource(const QString &path) { +bool LVMainModel::setCounrySource(const QString &path) { if (!m_countrysParser) { m_countrysParser = new CountrysParser(); @@ -43,7 +43,7 @@ bool MainModel::setCounrySource(const QString &path) { return true; } -bool MainModel::init( QQmlApplicationEngine *engine) { +bool LVMainModel::init( QQmlApplicationEngine *engine) { if (!engine) return false; @@ -65,27 +65,27 @@ bool MainModel::init( QQmlApplicationEngine *engine) { return true; } -int MainModel::country() const { +int LVMainModel::country() const { return m_country; } -QStringList MainModel::countryList() const { +QStringList LVMainModel::countryList() const { return m_countryList.values(); } -UserData MainModel::data() const { +UserData LVMainModel::data() const { return m_data; } -UserViewValidationData MainModel::validData() const { +UserViewValidationData LVMainModel::validData() const { return m_validationData; } -QString MainModel::passwordError() const { +QString LVMainModel::passwordError() const { return m_passwordError; } -void MainModel::setCountry(int country) { +void LVMainModel::setCountry(int country) { if (m_country == country) return; @@ -93,7 +93,7 @@ void MainModel::setCountry(int country) { emit countryListChanged(); } -void MainModel::setData(UserData data) { +void LVMainModel::setData(UserData data) { if (m_data == data) return; @@ -102,7 +102,7 @@ void MainModel::setData(UserData data) { emit dataChanged(m_data); } -void MainModel::setPasswordError(QString passwordError) { +void LVMainModel::setPasswordError(QString passwordError) { if (m_passwordError == passwordError) return; @@ -110,7 +110,7 @@ void MainModel::setPasswordError(QString passwordError) { emit passwordErrorChanged(m_passwordError); } -void MainModel::setValidData(UserViewValidationData validationData) { +void LVMainModel::setValidData(UserViewValidationData validationData) { if (m_validationData == validationData) return; @@ -142,7 +142,7 @@ void MainModel::setValidData(UserViewValidationData validationData) { emit validDataChanged(m_validationData); } -void MainModel::checkValid(const UserData& data) { +void LVMainModel::checkValid(const UserData& data) { UserViewValidationData result; @@ -183,29 +183,29 @@ void MainModel::checkValid(const UserData& data) { setValidData(result); } -QList<int> LoginView::MainModel::countryCodeList() const { +QList<int> LoginView::LVMainModel::countryCodeList() const { return m_countryList.keys(); } -void MainModel::loginRequest() { +void LVMainModel::loginRequest() { if (!m_validationData.email()) { emit sigLoginRequest(m_data); } } -void MainModel::rememberPasswordRequest() { +void LVMainModel::rememberPasswordRequest() { if (!m_validationData.email()) { emit sigForgotPasswordRequest(m_data); } } -void MainModel::registerRequest() { +void LVMainModel::registerRequest() { if (m_validationData.noError()) { emit sigRegisterRequest(m_data); } } -void MainModel::showTermOfUseRequest() { +void LVMainModel::showTermOfUseRequest() { emit sigShowTermOfUseRequest(); } diff --git a/LoginView/src/mainmodel.h b/LoginView/src/lvmainmodel.h similarity index 96% rename from LoginView/src/mainmodel.h rename to LoginView/src/lvmainmodel.h index 6557af4..bd37076 100644 --- a/LoginView/src/mainmodel.h +++ b/LoginView/src/lvmainmodel.h @@ -34,7 +34,7 @@ enum PasswordValidationLvl { ExtraChars = 0x10 }; -class LOGINVIEW_EXPORT MainModel : public QObject +class LOGINVIEW_EXPORT LVMainModel : public QObject { Q_OBJECT @@ -47,9 +47,9 @@ class LOGINVIEW_EXPORT MainModel : public QObject Q_PROPERTY(QString passwordError READ passwordError WRITE setPasswordError NOTIFY passwordErrorChanged) public: - explicit MainModel(const QString modelName, + explicit LVMainModel(const QString modelName, QObject *parent = nullptr); - ~MainModel(); + ~LVMainModel(); /** * @brief setCounrySource - sets path to xml source file and extract list of countrys * @param path diff --git a/README.md b/README.md index 401afcc..f3cefe2 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,126 @@ # QMLLoginView -test work +test work for Logic Way Solutions + +## Introdaction + +This is a simple login window library for qml projects. The project is built with the help of the сmake build system and is very easily includet to existing projects. + + +## Main features + +1. cmake support +2. support all qt qml [styles](https://doc.qt.io/qt-5/qtquickcontrols2-styles.html) +3. support login users +4. support register new users +5. support custom country list +6. support cqtdeployer deploy system + +### Screenshots + +#### Login View + + +#### Register View + + + +## Incuding into exits project + + * cd yourRepo + * git submodule add https://github.com/EndrII/QMLLoginView # add the repository of QMLLoginView into your repo like submodule + * git submodule update --init --recursive + * Include in your CMakeLists.txt file the main CMakeLists.txt file of QMLLoginView library + ``` cmake + include(QMLLoginView) + ``` + * Rebuild yuor project + + +## Using + +``` cpp +#include <lvmainmodel.h> + + LoginView::LVMainModel loginModel("exampleLogin"); // create nodel for login dialog + loginModel.init(&QMLEngine) // init login dialog. QMLEngine - this is object of QQmlApplicationEngine. + loginModel.setCounrySource("path/to/countries.xml") // set country list/ Example of counrys xml see example/example.xml + +``` + +``` qml + LoginView { + lognViewModel: exampleLogin // exampleLogin - this is inited model in main.cpp + anchors.fill: parent + } +``` + +``` xml country example +<?xml version="1.0" encoding="UTF-8"?> +<countries> + <country> + <code>375</code> + <name>Belarus</name> + </country> + <country> + <code>33</code> + <name>France</name> + </country> +</countries> + +``` + +### LoginView::LVMainModel Methods +``` cpp + /** + * @brief setCounrySource - sets path to xml source file and extract list of countrys + * @param path + * @return true if the function finished successful + */ + Q_INVOKABLE bool setCounrySource(const QString &path); + + /** + * @brief init - prepare all items for use on qml. + * @param engine - current qml engine of application + * @return true if the function finished successful + */ + bool init(QQmlApplicationEngine *engine); + + +``` + +#### LoginView::LVMainModel Signals +``` cpp + + /** + * @brief sigLoginRequest + * emited when user try login + */ + void sigLoginRequest(UserData); + + /** + * @brief sigRegisterRequest + * emited when user try create new accaunt + */ + void sigRegisterRequest(UserData); + + /** + * @brief sigForgotPasswordRequest + * emited when user forgot own password + */ + void sigForgotPasswordRequest(UserData); + + /** + * @brief sigShowTermOfUseRequest + * emited when user click on "Show term of use" button + */ + void sigShowTermOfUseRequest(); +``` + +#### UserData properties +``` cpp + Q_PROPERTY(int country READ country WRITE setCountry) + Q_PROPERTY(QString firstName READ firstName WRITE setFirstName) + Q_PROPERTY(QString lastName READ lastName WRITE setLastName) + Q_PROPERTY(QString rawPassword READ rawPassword WRITE setRawPassword) + Q_PROPERTY(QString email READ email WRITE setEmail) +``` diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index e6d32d6..5be9605 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -7,7 +7,7 @@ cmake_minimum_required(VERSION 3.5) -project(example LANGUAGES CXX) +project(ExampleLoginView LANGUAGES CXX) set(CMAKE_INCLUDE_CURRENT_DIR ON) @@ -18,6 +18,7 @@ set(CMAKE_AUTORCC ON) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) +include(${CMAKE_CURRENT_SOURCE_DIR}/../CMake/ProjectOut.cmake) find_package(Qt5 COMPONENTS Core QuickControls2 REQUIRED) diff --git a/example/main.cpp b/example/main.cpp index cf61853..b09bcc8 100644 --- a/example/main.cpp +++ b/example/main.cpp @@ -6,7 +6,7 @@ //# #include <QGuiApplication> #include <QQmlApplicationEngine> -#include <mainmodel.h> +#include <lvmainmodel.h> #include <QQuickStyle> int main(int argc, char *argv[]) @@ -22,7 +22,7 @@ int main(int argc, char *argv[]) const QUrl url(QStringLiteral("qrc:/main.qml")); QQuickStyle::setStyle("Material"); - LoginView::MainModel loginModel("exampleLogin"); + LoginView::LVMainModel loginModel("exampleLogin"); if (!loginModel.init(&engine)) { return -1; } diff --git a/res/Screenshot register.png b/res/Screenshot register.png new file mode 100644 index 0000000..587766f Binary files /dev/null and b/res/Screenshot register.png differ diff --git a/res/logo.png b/res/logo.png new file mode 100644 index 0000000..87aae70 Binary files /dev/null and b/res/logo.png differ diff --git a/res/logo2.png b/res/logo2.png new file mode 100644 index 0000000..f5e38c0 Binary files /dev/null and b/res/logo2.png differ diff --git a/res/scrinshot Login.png b/res/scrinshot Login.png new file mode 100644 index 0000000..141e567 Binary files /dev/null and b/res/scrinshot Login.png differ