diff --git a/qml/pages/AboutPage.qml b/qml/pages/AboutPage.qml index b613c80..2317826 100644 --- a/qml/pages/AboutPage.qml +++ b/qml/pages/AboutPage.qml @@ -18,6 +18,7 @@ */ import QtQuick 2.6 import Sailfish.Silica 1.0 +import WerkWolf.Fernschreiber 1.0 import "../components" import "../js/twemoji.js" as Emoji @@ -25,8 +26,7 @@ Page { id: aboutPage allowedOrientations: Orientation.All - property bool isLoggedIn : false - property var userInformation : tdLibWrapper.getUserInformation(); + readonly property var userInformation : tdLibWrapper.userInformation SilicaFlickable { id: aboutContainer @@ -158,7 +158,7 @@ Page { Loader { id: userInformationLoader - active: isLoggedIn + active: tdLibWrapper.authorizationState === TelegramAPI.AuthorizationReady width: parent.width sourceComponent: Component { Column { @@ -227,18 +227,18 @@ Page { } } } - } - } - } - Button { - id: activeSessionsButton - text: qsTr("Active Sessions") - anchors { - horizontalCenter: parent.horizontalCenter - } - onClicked: { - pageStack.push(Qt.resolvedUrl("ActiveSessionsPage.qml")); + Button { + id: activeSessionsButton + text: qsTr("Active Sessions") + anchors { + horizontalCenter: parent.horizontalCenter + } + onClicked: { + pageStack.push(Qt.resolvedUrl("ActiveSessionsPage.qml")); + } + } + } } } diff --git a/qml/pages/CoverPage.qml b/qml/pages/CoverPage.qml index e3ed8f4..aa9e2a5 100644 --- a/qml/pages/CoverPage.qml +++ b/qml/pages/CoverPage.qml @@ -28,7 +28,7 @@ CoverBackground { property int unreadMessages: 0 property int unreadChats: 0 - property bool authenticated: false + readonly property bool authenticated: tdLibWrapper.authorizationState === TelegramAPI.AuthorizationReady property int connectionState: TelegramAPI.WaitingForNetwork function setUnreadInfoText() { @@ -56,7 +56,6 @@ CoverBackground { } Component.onCompleted: { - coverPage.authenticated = (tdLibWrapper.getAuthorizationState() === TelegramAPI.AuthorizationReady); coverPage.connectionState = tdLibWrapper.getConnectionState(); coverPage.unreadMessages = tdLibWrapper.getUnreadMessageInformation().unread_count || 0; coverPage.unreadChats = tdLibWrapper.getUnreadChatInformation().unread_count || 0; @@ -74,7 +73,6 @@ CoverBackground { setUnreadInfoText(); } onAuthorizationStateChanged: { - coverPage.authenticated = (authorizationState === TelegramAPI.AuthorizationReady); setUnreadInfoText(); } onConnectionStateChanged: { diff --git a/qml/pages/InitializationPage.qml b/qml/pages/InitializationPage.qml index 5648151..0778c99 100644 --- a/qml/pages/InitializationPage.qml +++ b/qml/pages/InitializationPage.qml @@ -26,15 +26,13 @@ Page { backNavigation: false property bool loading: true - property int authorizationState: TelegramAPI.Closed property var authorizationStateData: null Component.onCompleted: { - initializationPage.authorizationState = tdLibWrapper.getAuthorizationState(); initializationPage.authorizationStateData = tdLibWrapper.getAuthorizationStateData(); initializationPage.loading = false; - switch (authorizationState) { + switch (tdLibWrapper.authorizationState) { case TelegramAPI.WaitCode: initializationPage.loading = false; welcomeColumn.visible = false; @@ -66,7 +64,7 @@ Page { Connections { target: tdLibWrapper onAuthorizationStateChanged: { - switch (authorizationState) { + switch (tdLibWrapper.authorizationState) { case TelegramAPI.WaitCode: initializationPage.loading = false; enterPinColumn.visible = true; diff --git a/qml/pages/OverviewPage.qml b/qml/pages/OverviewPage.qml index 7a55c39..7ff9cc0 100644 --- a/qml/pages/OverviewPage.qml +++ b/qml/pages/OverviewPage.qml @@ -32,7 +32,6 @@ Page { property bool initializationCompleted: false; property bool loading: true; property bool logoutLoading: false; - property int authorizationState: TelegramAPI.Closed property int connectionState: TelegramAPI.WaitingForNetwork property int ownUserId; property bool chatListCreated: false; @@ -146,14 +145,13 @@ Page { } function initializePage() { - overviewPage.authorizationState = tdLibWrapper.getAuthorizationState(); overviewPage.handleAuthorizationState(true); overviewPage.connectionState = tdLibWrapper.getConnectionState(); overviewPage.setPageStatus(); } function handleAuthorizationState(isOnInitialization) { - switch (overviewPage.authorizationState) { + switch (tdLibWrapper.authorizationState) { case TelegramAPI.WaitPhoneNumber: case TelegramAPI.WaitCode: case TelegramAPI.WaitPassword: @@ -204,8 +202,7 @@ Page { Connections { target: tdLibWrapper onAuthorizationStateChanged: { - overviewPage.authorizationState = authorizationState; - handleAuthorizationState(); + handleAuthorizationState(false); } onConnectionStateChanged: { overviewPage.connectionState = connectionState; @@ -278,7 +275,7 @@ Page { } MenuItem { text: qsTr("About Fernschreiber") - onClicked: pageStack.push(Qt.resolvedUrl("../pages/AboutPage.qml"), {isLoggedIn : (overviewPage.authorizationState == TelegramAPI.AuthorizationReady)}) + onClicked: pageStack.push(Qt.resolvedUrl("../pages/AboutPage.qml")) } MenuItem { text: qsTr("Settings") diff --git a/src/tdlibwrapper.h b/src/tdlibwrapper.h index b69c7ec..9dac049 100644 --- a/src/tdlibwrapper.h +++ b/src/tdlibwrapper.h @@ -31,6 +31,9 @@ class TDLibWrapper : public QObject { Q_OBJECT + Q_PROPERTY(AuthorizationState authorizationState READ getAuthorizationState NOTIFY authorizationStateChanged) + Q_PROPERTY(QVariantMap userInformation READ getUserInformation NOTIFY ownUserUpdated) + public: explicit TDLibWrapper(AppSettings *appSettings, MceInterface *mceInterface, QObject *parent = nullptr); ~TDLibWrapper();