diff --git a/qml/harbour-fernschreiber.qml b/qml/harbour-fernschreiber.qml index 2845f2c..1cf695d 100644 --- a/qml/harbour-fernschreiber.qml +++ b/qml/harbour-fernschreiber.qml @@ -24,12 +24,7 @@ ApplicationWindow { id: appWindow - Component { - id: overviewPage - OverviewPage {} - } - - initialPage: overviewPage + initialPage: Qt.resolvedUrl("pages/OverviewPage.qml") cover: Qt.resolvedUrl("pages/CoverPage.qml") allowedOrientations: defaultAllowedOrientations } diff --git a/qml/pages/CoverPage.qml b/qml/pages/CoverPage.qml index d1f6cba..00e583e 100644 --- a/qml/pages/CoverPage.qml +++ b/qml/pages/CoverPage.qml @@ -72,16 +72,12 @@ CoverBackground { Connections { target: tdLibWrapper onUnreadMessageCountUpdated: { - if (messageCountInformation.chat_list_type === "chatListMain") { - coverPage.unreadMessages = messageCountInformation.unread_count; - setUnreadInfoText(); - } + coverPage.unreadMessages = messageCountInformation.unread_count; + setUnreadInfoText(); } onUnreadChatCountUpdated: { - if (chatCountInformation.chat_list_type === "chatListMain") { - coverPage.unreadChats = chatCountInformation.unread_count; - setUnreadInfoText(); - } + coverPage.unreadChats = chatCountInformation.unread_count; + setUnreadInfoText(); } onAuthorizationStateChanged: { coverPage.authenticated = (authorizationState === TelegramAPI.AuthorizationReady); @@ -137,7 +133,7 @@ CoverBackground { Row { width: parent.width spacing: Theme.paddingMedium - visible: coverPage.authenticated && coverPage.unreadChats > 0 + visible: coverPage.authenticated && coverPage.unreadMessages > 1 Text { id: inText font.pixelSize: Theme.fontSizeSmall diff --git a/qml/pages/InitializationPage.qml b/qml/pages/InitializationPage.qml index d0f68d5..45ec32f 100644 --- a/qml/pages/InitializationPage.qml +++ b/qml/pages/InitializationPage.qml @@ -23,6 +23,7 @@ import WerkWolf.Fernschreiber 1.0 Page { id: initializationPage allowedOrientations: Orientation.All + backNavigation: false property bool loading: true property int authorizationState: TelegramAPI.Closed @@ -50,9 +51,8 @@ Page { enterPinColumn.visible = true; break; case TelegramAPI.AuthorizationReady: - overviewPage.loading = false; - pageStack.clear(); - pageStack.push(Qt.resolvedUrl("../pages/OverviewPage.qml")); + initializationPage.loading = false; + pageStack.pop(); break; default: // Nothing ;) @@ -206,15 +206,15 @@ Page { SilicaFlickable { id: welcomeFlickable - anchors.fill: parent contentHeight: welcomeColumn.height Behavior on opacity { NumberAnimation {} } + anchors.fill: parent opacity: visible ? 1 : 0 Column { id: welcomeColumn width: parent.width - spacing: Theme.paddingLarge + spacing: Theme.paddingSmall PageHeader { title: qsTr("Welcome to Fernschreiber!") @@ -232,6 +232,7 @@ Page { } Label { + id: enterPhoneNumberLabel wrapMode: Text.Wrap x: Theme.horizontalPageMargin width: parent.width - ( 2 * Theme.horizontalPageMargin ) @@ -252,6 +253,7 @@ Page { } Button { + id: continueWithPhoneNumberButton text: qsTr("Continue") anchors { horizontalCenter: parent.horizontalCenter @@ -264,18 +266,8 @@ Page { } } - Label { - id: separatorLabelPhoneNumber - x: Theme.horizontalPageMargin - width: parent.width - ( 2 * Theme.horizontalPageMargin ) - font.pixelSize: Theme.fontSizeExtraSmall - anchors { - horizontalCenter: parent.horizontalCenter - } - } - } - } + } diff --git a/qml/pages/OverviewPage.qml b/qml/pages/OverviewPage.qml index e8ef5ce..cbcaa0a 100644 --- a/qml/pages/OverviewPage.qml +++ b/qml/pages/OverviewPage.qml @@ -64,6 +64,17 @@ Page { function updateContent() { tdLibWrapper.getChats(); + + } + + function initializePage() { + overviewPage.authorizationState = tdLibWrapper.getAuthorizationState(); + if (overviewPage.authorizationState === TelegramAPI.AuthorizationReady) { + overviewPage.loading = false; + overviewPage.updateContent(); + } + overviewPage.connectionState = tdLibWrapper.getConnectionState(); + overviewPage.setPageStatus(); } Connections { @@ -72,12 +83,10 @@ Page { switch (authorizationState) { case TelegramAPI.WaitPhoneNumber: overviewPage.loading = false; - pageStack.clear(); pageStack.push(Qt.resolvedUrl("../pages/InitializationPage.qml")); break; case TelegramAPI.WaitCode: overviewPage.loading = false; - pageStack.clear(); pageStack.push(Qt.resolvedUrl("../pages/InitializationPage.qml")); break; case TelegramAPI.AuthorizationReady: @@ -97,14 +106,7 @@ Page { } Component.onCompleted: { - overviewPage.authorizationState = tdLibWrapper.getAuthorizationState(); - if (overviewPage.authorizationState === TelegramAPI.AuthorizationReady) { - overviewPage.loading = false; - overviewPage.updateContent(); - } - - overviewPage.connectionState = tdLibWrapper.getConnectionState(); - overviewPage.setPageStatus(); + initializePage(); } SilicaFlickable { diff --git a/src/tdlibwrapper.cpp b/src/tdlibwrapper.cpp index 1912cfe..601b02b 100644 --- a/src/tdlibwrapper.cpp +++ b/src/tdlibwrapper.cpp @@ -259,14 +259,18 @@ void TDLibWrapper::handleNewChatDiscovered(const QVariantMap &chatInformation) void TDLibWrapper::handleUnreadMessageCountUpdated(const QVariantMap &messageCountInformation) { - this->unreadMessageInformation = messageCountInformation; - emit unreadMessageCountUpdated(messageCountInformation); + if (messageCountInformation.value("chat_list_type").toString() == "chatListMain") { + this->unreadMessageInformation = messageCountInformation; + emit unreadMessageCountUpdated(messageCountInformation); + } } void TDLibWrapper::handleUnreadChatCountUpdated(const QVariantMap &chatCountInformation) { - this->unreadChatInformation = chatCountInformation; - emit unreadChatCountUpdated(chatCountInformation); + if (chatCountInformation.value("chat_list_type").toString() == "chatListMain") { + this->unreadChatInformation = chatCountInformation; + emit unreadChatCountUpdated(chatCountInformation); + } } void TDLibWrapper::setInitialParameters()