mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-17 03:18:07 +00:00
Add an example of Cpp model for views.
Remove qml folder. Update SDK
This commit is contained in:
parent
4f86e1362a
commit
23c0b9bd42
11 changed files with 87 additions and 27 deletions
|
|
@ -2,11 +2,17 @@
|
|||
|
||||
#include <QCoreApplication>
|
||||
|
||||
#include "tool/Constants.hpp"
|
||||
#include "view/Page/LoginPage.hpp"
|
||||
|
||||
|
||||
App::App(QObject * parent) : QObject(parent) {
|
||||
init();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Initializations
|
||||
//-----------------------------------------------------------
|
||||
|
||||
void App::init() {
|
||||
// Core
|
||||
|
|
@ -16,7 +22,9 @@ 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)
|
||||
|
|
@ -24,3 +32,9 @@ void App::init() {
|
|||
}, Qt::QueuedConnection);
|
||||
mEngine->load(url);
|
||||
}
|
||||
|
||||
void App::initCppInterfaces() {
|
||||
qmlRegisterSingletonType<LoginPage>(Constants::MainQmlUri, 1, 0, "LoginPageCpp", [](QQmlEngine *engine, QJSEngine *) -> QObject *{
|
||||
return new LoginPage(engine);
|
||||
});
|
||||
}
|
||||
|
|
@ -9,6 +9,7 @@ public:
|
|||
App(QObject * parent = nullptr);
|
||||
|
||||
void init();
|
||||
void initCppInterfaces();
|
||||
|
||||
QQmlApplicationEngine * mEngine = nullptr;
|
||||
QSharedPointer<CoreModel> mCoreModel;
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ Window {
|
|||
ColumnLayout{
|
||||
anchors.fill: parent
|
||||
|
||||
Login{
|
||||
LoginPage{
|
||||
height: 100
|
||||
width: 640
|
||||
}
|
||||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -27,10 +27,10 @@ Control.Button {
|
|||
}
|
||||
|
||||
hoverEnabled: true
|
||||
|
||||
/*
|
||||
MouseArea {
|
||||
id: mouseArea
|
||||
anchors.fill: parent
|
||||
onPressed: mouse.accepted = false
|
||||
}
|
||||
}*/
|
||||
}
|
||||
16
Linphone/view/Page/LoginPage.cpp
Normal file
16
Linphone/view/Page/LoginPage.cpp
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
#include "LoginPage.hpp"
|
||||
#include <QTimer>
|
||||
|
||||
|
||||
LoginPage::LoginPage(QObject * parent) : QObject(parent){
|
||||
|
||||
}
|
||||
|
||||
bool LoginPage::isLogged() {
|
||||
static bool testLog = false;
|
||||
QTimer::singleShot(2000, [&]() mutable{
|
||||
testLog = true;
|
||||
emit isLoggedChanged();
|
||||
});
|
||||
return testLog;
|
||||
}
|
||||
17
Linphone/view/Page/LoginPage.hpp
Normal file
17
Linphone/view/Page/LoginPage.hpp
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class LoginPage : public QObject{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
LoginPage(QObject * parent = nullptr);
|
||||
|
||||
Q_PROPERTY(bool isLogged READ isLogged NOTIFY isLoggedChanged)
|
||||
|
||||
bool isLogged();
|
||||
|
||||
signals:
|
||||
void isLoggedChanged();
|
||||
};
|
||||
25
Linphone/view/Page/LoginPage.qml
Normal file
25
Linphone/view/Page/LoginPage.qml
Normal file
|
|
@ -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!")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -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'
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -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
|
||||
|
|
|
|||
2
external/linphone-sdk
vendored
2
external/linphone-sdk
vendored
|
|
@ -1 +1 @@
|
|||
Subproject commit 0eb3d223aaee01b28d3f3d8c7dee4d0395782836
|
||||
Subproject commit 521a001ab21f1127682333efce8d4a292099203c
|
||||
Loading…
Add table
Reference in a new issue