diff --git a/Linphone/core/App.cpp b/Linphone/core/App.cpp index 9931ec51d..357f6afd8 100644 --- a/Linphone/core/App.cpp +++ b/Linphone/core/App.cpp @@ -2,11 +2,17 @@ #include +#include "tool/Constants.hpp" +#include "view/Page/LoginPage.hpp" + App::App(QObject * parent) : QObject(parent) { init(); } +//----------------------------------------------------------- +// Initializations +//----------------------------------------------------------- void App::init() { // Core @@ -16,11 +22,19 @@ void App::init() { mEngine = new QQmlApplicationEngine(this); mEngine->addImportPath(":/"); - const QUrl url(u"qrc:/Linphone/view/qml/App/Main.qml"_qs); + initCppInterfaces(); + + const QUrl url(u"qrc:/Linphone/view/App/Main.qml"_qs); QObject::connect(mEngine, &QQmlApplicationEngine::objectCreated, this, [url](QObject *obj, const QUrl &objUrl) { if (!obj && url == objUrl) QCoreApplication::exit(-1); }, Qt::QueuedConnection); mEngine->load(url); +} + +void App::initCppInterfaces() { + qmlRegisterSingletonType(Constants::MainQmlUri, 1, 0, "LoginPageCpp", [](QQmlEngine *engine, QJSEngine *) -> QObject *{ + return new LoginPage(engine); + }); } \ No newline at end of file diff --git a/Linphone/core/App.hpp b/Linphone/core/App.hpp index badd6e9d0..5a1603d02 100644 --- a/Linphone/core/App.hpp +++ b/Linphone/core/App.hpp @@ -9,6 +9,7 @@ public: App(QObject * parent = nullptr); void init(); + void initCppInterfaces(); QQmlApplicationEngine * mEngine = nullptr; QSharedPointer mCoreModel; diff --git a/Linphone/view/qml/App/Main.qml b/Linphone/view/App/Main.qml similarity index 94% rename from Linphone/view/qml/App/Main.qml rename to Linphone/view/App/Main.qml index 240b38bad..579743baa 100644 --- a/Linphone/view/qml/App/Main.qml +++ b/Linphone/view/App/Main.qml @@ -12,7 +12,7 @@ Window { ColumnLayout{ anchors.fill: parent - Login{ + LoginPage{ height: 100 width: 640 } diff --git a/Linphone/view/CMakeLists.txt b/Linphone/view/CMakeLists.txt index 7278dbc2c..8a0d116d6 100644 --- a/Linphone/view/CMakeLists.txt +++ b/Linphone/view/CMakeLists.txt @@ -1,10 +1,15 @@ list(APPEND _LINPHONEAPP_QML_FILES - view/qml/App/Main.qml + view/App/Main.qml - view/qml/Item/Button.qml + view/Item/Button.qml - view/qml/Page/Login.qml + view/Page/LoginPage.qml +) + +list(APPEND _LINPHONEAPP_SOURCES + view/Page/LoginPage.cpp ) set(_LINPHONEAPP_QML_FILES ${_LINPHONEAPP_QML_FILES} PARENT_SCOPE) +set(_LINPHONEAPP_SOURCES ${_LINPHONEAPP_SOURCES} PARENT_SCOPE) diff --git a/Linphone/view/qml/Item/Button.qml b/Linphone/view/Item/Button.qml similarity index 98% rename from Linphone/view/qml/Item/Button.qml rename to Linphone/view/Item/Button.qml index 4d773b34d..7a320a051 100644 --- a/Linphone/view/qml/Item/Button.qml +++ b/Linphone/view/Item/Button.qml @@ -27,10 +27,10 @@ Control.Button { } hoverEnabled: true - + /* MouseArea { id: mouseArea anchors.fill: parent onPressed: mouse.accepted = false - } + }*/ } \ No newline at end of file diff --git a/Linphone/view/Page/LoginPage.cpp b/Linphone/view/Page/LoginPage.cpp new file mode 100644 index 000000000..ae3d75207 --- /dev/null +++ b/Linphone/view/Page/LoginPage.cpp @@ -0,0 +1,16 @@ +#include "LoginPage.hpp" +#include + + +LoginPage::LoginPage(QObject * parent) : QObject(parent){ + +} + +bool LoginPage::isLogged() { + static bool testLog = false; + QTimer::singleShot(2000, [&]() mutable{ + testLog = true; + emit isLoggedChanged(); + }); + return testLog; +} \ No newline at end of file diff --git a/Linphone/view/Page/LoginPage.hpp b/Linphone/view/Page/LoginPage.hpp new file mode 100644 index 000000000..e1238b368 --- /dev/null +++ b/Linphone/view/Page/LoginPage.hpp @@ -0,0 +1,17 @@ + + +#include + +class LoginPage : public QObject{ +Q_OBJECT + +public: + LoginPage(QObject * parent = nullptr); + + Q_PROPERTY(bool isLogged READ isLogged NOTIFY isLoggedChanged) + + bool isLogged(); + +signals: + void isLoggedChanged(); +}; \ No newline at end of file diff --git a/Linphone/view/Page/LoginPage.qml b/Linphone/view/Page/LoginPage.qml new file mode 100644 index 000000000..08b85cb35 --- /dev/null +++ b/Linphone/view/Page/LoginPage.qml @@ -0,0 +1,25 @@ +import QtQuick 2.15 +import QtQuick.Layouts 1.0 +import Linphone + +Item{ + id: mainItem + ColumnLayout{ + anchors.fill: parent + Text{ + Layout.fillWidth: true + text: LoginPageCpp.isLogged ? "Online" : "Offline" + } + RowLayout{ + Button{ + text: 'Sign In' + onClicked: console.log("Click!") + } + Button{ + text: 'Sign Out' + onClicked: console.log("Click!") + } + } + } +} + \ No newline at end of file diff --git a/Linphone/view/qml/Page/Login.qml b/Linphone/view/qml/Page/Login.qml deleted file mode 100644 index 67338c655..000000000 --- a/Linphone/view/qml/Page/Login.qml +++ /dev/null @@ -1,19 +0,0 @@ -import QtQuick 2.15 -import QtQuick.Layouts 1.0 -import Linphone - -Item{ - id: mainItem - - - RowLayout{ - Button{ - text: 'Sign In' - } - Button{ - text: 'Sign Out' - } - } - -} - \ No newline at end of file diff --git a/README.md b/README.md index b8d1dae35..43b289669 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ Qt6 application. export PATH=$PATH:~/Qt/6.5.2/gcc_64/bin + optional: export Qt6_DIR=~/Qt/6.5.2/gcc_64/lib/cmake/Qt6 mkdir build diff --git a/external/linphone-sdk b/external/linphone-sdk index 0eb3d223a..521a001ab 160000 --- a/external/linphone-sdk +++ b/external/linphone-sdk @@ -1 +1 @@ -Subproject commit 0eb3d223aaee01b28d3f3d8c7dee4d0395782836 +Subproject commit 521a001ab21f1127682333efce8d4a292099203c