From 38c61064ff8b13c66253c37a535ed70a0e523bf5 Mon Sep 17 00:00:00 2001 From: Alexandr Akulich Date: Tue, 17 Feb 2015 13:59:38 +0500 Subject: [PATCH 1/2] ui/chat: Some code simplification. --- telegram-blackberry10/assets/chat/NewMessage.qml | 14 +------------- telegram-blackberry10/assets/chat/chat_screen.qml | 6 +----- 2 files changed, 2 insertions(+), 18 deletions(-) diff --git a/telegram-blackberry10/assets/chat/NewMessage.qml b/telegram-blackberry10/assets/chat/NewMessage.qml index 831ff52..503dfed 100644 --- a/telegram-blackberry10/assets/chat/NewMessage.qml +++ b/telegram-blackberry10/assets/chat/NewMessage.qml @@ -1,16 +1,7 @@ import bb.cascades 1.2 Container { - signal enableSendButton() - signal disableSendButton() - function validateInput() { - if (newMessage.text.length > 0) { - enableSendButton() - } - if (newMessage.text.length == 0) { - disableSendButton() - } - } + readonly property bool haveText: newMessage.text.length > 0 preferredHeight: 130 background: Color.create("#282929") layout: StackLayout { @@ -34,9 +25,6 @@ Container { hintText: "Enter a message" leftMargin: 0 rightMargin: 0 - onTextChanging: { - validateInput() - } } Container { verticalAlignment: VerticalAlignment.Center diff --git a/telegram-blackberry10/assets/chat/chat_screen.qml b/telegram-blackberry10/assets/chat/chat_screen.qml index 25fa491..e0e7903 100644 --- a/telegram-blackberry10/assets/chat/chat_screen.qml +++ b/telegram-blackberry10/assets/chat/chat_screen.qml @@ -109,10 +109,6 @@ Page { verticalAlignment: VerticalAlignment.Bottom NewMessage { id: newMessage - onEnableSendButton: { - } - onDisableSendButton: { - } } } } @@ -129,7 +125,7 @@ Page { title: "Send" imageSource: "asset:///images/chat/bar_send.png" ActionBar.placement: ActionBarPlacement.OnBar - enabled: newMessage.body.length > 0 + enabled: newMessage.haveText onTriggered: { dataModel.sendMessage(newMessage.body) newMessage.body = "" From c1f890d4dc2bc24922cd2d373956518030df64b4 Mon Sep 17 00:00:00 2001 From: Alexandr Akulich Date: Thu, 19 Feb 2015 11:22:52 +0500 Subject: [PATCH 2/2] tgApi::initConnection() call moved to ApplicationUI() constructor. initConnection() call removed from Api constructor, because that connection is going to be killed in most cases (in favour of restoreConnection()). --- telegram-blackberry10/src/api/tgApi.cpp | 26 +++++++-------------- telegram-blackberry10/src/applicationui.cpp | 3 +++ 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/telegram-blackberry10/src/api/tgApi.cpp b/telegram-blackberry10/src/api/tgApi.cpp index a06d640..d45ed99 100644 --- a/telegram-blackberry10/src/api/tgApi.cpp +++ b/telegram-blackberry10/src/api/tgApi.cpp @@ -21,12 +21,17 @@ CTelegramCore* tgApi::core = NULL; tgApi::tgApi() { - - bool shouldInit = false; - if (core == NULL) { core = new CTelegramCore(); - shouldInit = true; + + CAppInformation info; + info.setAppId(TG_APP_ID); + info.setAppHash(QLatin1String(TG_API_HASH)); + info.setAppVersion(QLatin1String("0.0.1")); + info.setDeviceInfo(QLatin1String("BlackBerry 10")); + info.setLanguageCode(QLatin1String("en")); + info.setOsInfo(QLatin1String("BlackBerry 10")); + core->setAppInformation(&info); } connect(core, SIGNAL(connected()), SIGNAL(connected())); @@ -69,19 +74,6 @@ tgApi::tgApi() SLOT( messagesHistorySliceReceived(quint32, QVector, QVector, QVector))); connect(core, SIGNAL(authorizationErrorReceived()), SIGNAL(authorizationErrorReceived())); - - if (shouldInit) { - CAppInformation info; - info.setAppId(TG_APP_ID); - info.setAppHash(QLatin1String(TG_API_HASH)); - info.setAppVersion(QLatin1String("0.0.1")); - info.setDeviceInfo(QLatin1String("BlackBerry 10")); - info.setLanguageCode(QLatin1String("en")); - info.setOsInfo(QLatin1String("BlackBerry 10")); - core->setAppInformation(&info); - core->initConnection(QLatin1String(TG_API_IP), TG_API_PORT); - } - } void tgApi::connectionEstablished() diff --git a/telegram-blackberry10/src/applicationui.cpp b/telegram-blackberry10/src/applicationui.cpp index 057e465..430cbbf 100644 --- a/telegram-blackberry10/src/applicationui.cpp +++ b/telegram-blackberry10/src/applicationui.cpp @@ -103,6 +103,9 @@ ApplicationUI::ApplicationUI() : pageAsset = "asset:///main/MainPage.qml"; } else { qDebug() << "No existing session"; + + tgApi api; + api.initConnection(QLatin1String(TG_API_IP), TG_API_PORT); pageAsset = "asset:///intro/IntroWithPane.qml"; } #endif