Skip to content

QuasarApp/QMLLoginView

Repository files navigation

QMLLoginView

Introdaction

Banner

This is a simple login window library for qml projects. The project is built with the help of the сmake build system and may be easily included into existing projects.

Main features

  1. support all qt qml styles
  2. support logining of users
  3. support registeration of new users
  4. support custom country list
  5. support cqtdeployer deploying system
  6. support cmake build system

Screenshots

Login View

scrinshot Login

Register View

Screenshot register

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
  add_subdirectory(QMLLoginView)
  target_link_libraries(${CURRENT_PROJECT} PRIVATE LoginView)
  • Rebuild yuor project

Using

#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
import LoginViewModule 1.0

    LoginView {
        lognViewModel: exampleLogin // exampleLogin - this is inited model in main.cpp
        anchors.fill: parent
    }
<?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

    /**
     * @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

    /**
     * @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

    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)

Build Example

Prepare

  1. install cqtdeployer
  2. install cqtdeployer (gitHub releases or snap-store))
  3. if you use snap store version of cqtdeployer add all permisions for cqdeployer.

build on Linux

git clone https://github.com/EndrII/QMLLoginView

cd QMLLoginView

cmake -DCMAKE_PREFIX_PATH=/my/Qt/Dir

make -j12

export PATH=$PATH:/my/Qt/Dir/bin # add to path location of qmake

cqtdeployer

cd Distributionkit

chmod +x InstallerExampleLoginView.run

./InstallerExampleLoginView.run

Translations

This library sipprots a next languages:

  • English
  • Russian
  • Ukrainian
  • Japanese
  • Turkish

Include translations

For include translations into your projects you need to use the QuasarAppUtils::Locales class. See oficiald documentation

if(!QuasarAppUtils::Locales::init(locale, {":/lv_languages/"})) {
    QuasarAppUtils::Params::log("Error load language : " , QuasarAppUtils::Error);
}

Or you can manually load needed qm file. All qm files located in lv_languages folder.