mirror of
https://github.com/QuasarApp/QMLLoginView.git
synced 2025-04-26 01:34:38 +00:00
added README
This commit is contained in:
parent
bbbd4fcce9
commit
bbce074628
2
.gitignore
vendored
2
.gitignore
vendored
@ -9,6 +9,8 @@
|
||||
*.so.*
|
||||
*.dll
|
||||
*.dylib
|
||||
*/build/*
|
||||
DistributionKit
|
||||
|
||||
# Qt-es
|
||||
object_script.*.Release
|
||||
|
32
CMake/ProjectOut.cmake
Normal file
32
CMake/ProjectOut.cmake
Normal file
@ -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})
|
11
CQtDeployer.json
Normal file
11
CQtDeployer.json
Normal file
@ -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": "./"
|
||||
}
|
@ -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")
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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
|
126
README.md
126
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)
|
||||
```
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
BIN
res/Screenshot register.png
Normal file
BIN
res/Screenshot register.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 68 KiB |
BIN
res/logo.png
Normal file
BIN
res/logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 17 KiB |
BIN
res/logo2.png
Normal file
BIN
res/logo2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.7 KiB |
BIN
res/scrinshot Login.png
Normal file
BIN
res/scrinshot Login.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 41 KiB |
Loading…
x
Reference in New Issue
Block a user