Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 1 addition & 13 deletions telegram-blackberry10/assets/chat/NewMessage.qml
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -34,9 +25,6 @@ Container {
hintText: "Enter a message"
leftMargin: 0
rightMargin: 0
onTextChanging: {
validateInput()
}
}
Container {
verticalAlignment: VerticalAlignment.Center
Expand Down
6 changes: 1 addition & 5 deletions telegram-blackberry10/assets/chat/chat_screen.qml
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,6 @@ Page {
verticalAlignment: VerticalAlignment.Bottom
NewMessage {
id: newMessage
onEnableSendButton: {
}
onDisableSendButton: {
}
}
}
}
Expand All @@ -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 = ""
Expand Down
26 changes: 9 additions & 17 deletions telegram-blackberry10/src/api/tgApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand Down Expand Up @@ -69,19 +74,6 @@ tgApi::tgApi()
SLOT(
messagesHistorySliceReceived(quint32, QVector<TLMessage>, QVector<TLChat>, QVector<TLUser>)));
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()
Expand Down
3 changes: 3 additions & 0 deletions telegram-blackberry10/src/applicationui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down