diff --git a/qml/pages/AboutPage.qml b/qml/pages/AboutPage.qml index ed4e7fd..72c150f 100644 --- a/qml/pages/AboutPage.qml +++ b/qml/pages/AboutPage.qml @@ -121,7 +121,20 @@ Page { Label { x: Theme.horizontalPageMargin width: parent.width - ( 2 * Theme.horizontalPageMargin ) - text: qsTr("This product uses the Telegram API but is not endorsed or certified by Telegram") + horizontalAlignment: Text.AlignHCenter + text: qsTr("This product uses the Telegram API but is not endorsed or certified by Telegram.") + font.pixelSize: Theme.fontSizeSmall + wrapMode: Text.Wrap + anchors { + horizontalCenter: parent.horizontalCenter + } + } + + Label { + x: Theme.horizontalPageMargin + width: parent.width - ( 2 * Theme.horizontalPageMargin ) + horizontalAlignment: Text.AlignHCenter + text: qsTr("TDLib version %1").arg(tdLibWrapper.getVersion()) font.pixelSize: Theme.fontSizeSmall wrapMode: Text.Wrap anchors { @@ -147,7 +160,7 @@ Page { horizontalCenter: parent.horizontalCenter } onClicked: { - Qt.openUrlExternally("https://telegram.orgprivacy") + Qt.openUrlExternally("https://telegram.org/privacy") } } diff --git a/src/tdlibreceiver.cpp b/src/tdlibreceiver.cpp index 0c64a17..01c032f 100644 --- a/src/tdlibreceiver.cpp +++ b/src/tdlibreceiver.cpp @@ -8,7 +8,11 @@ TDLibReceiver::TDLibReceiver(void *tdLibClient, QObject *parent) : QThread(paren void TDLibReceiver::setActive(const bool &active) { - qDebug() << "[TDLibReceiver] setActive " << active; + if (active) { + qDebug() << "[TDLibReceiver] Activating receiver loop..."; + } else { + qDebug() << "[TDLibReceiver] Deactivating receiver loop, this may take a while..."; + } this->isActive = active; } @@ -21,27 +25,27 @@ void TDLibReceiver::receiverLoop() if (result) { QJsonDocument receivedJsonDocument = QJsonDocument::fromJson(QByteArray(result)); qDebug().noquote() << "[TDLibReceiver] Raw result: " << receivedJsonDocument.toJson(QJsonDocument::Indented); - handleReceivedDocument(receivedJsonDocument); + processReceivedDocument(receivedJsonDocument); } } qDebug() << "[TDLibReceiver] Stopping receiver loop"; } -void TDLibReceiver::handleReceivedDocument(const QJsonDocument &receivedJsonDocument) +void TDLibReceiver::processReceivedDocument(const QJsonDocument &receivedJsonDocument) { QVariantMap receivedInformation = receivedJsonDocument.object().toVariantMap(); QString objectTypeName = receivedInformation.value("@type").toString(); if (objectTypeName == "updateOption") { - this->handleUpdateOption(receivedInformation); + this->processUpdateOption(receivedInformation); } if (objectTypeName == "updateAuthorizationState") { - this->handleUpdateAuthorizationState(receivedInformation); + this->processUpdateAuthorizationState(receivedInformation); } } -void TDLibReceiver::handleUpdateOption(const QVariantMap &receivedInformation) +void TDLibReceiver::processUpdateOption(const QVariantMap &receivedInformation) { QString currentOption = receivedInformation.value("name").toString(); if (currentOption == "version") { @@ -51,7 +55,7 @@ void TDLibReceiver::handleUpdateOption(const QVariantMap &receivedInformation) } } -void TDLibReceiver::handleUpdateAuthorizationState(const QVariantMap &receivedInformation) +void TDLibReceiver::processUpdateAuthorizationState(const QVariantMap &receivedInformation) { QString authorizationState = receivedInformation.value("authorization_state").toMap().value("@type").toString(); qDebug() << "[TDLibReceiver] Authorization state changed: " << authorizationState; diff --git a/src/tdlibreceiver.h b/src/tdlibreceiver.h index ff28b90..3a628e1 100644 --- a/src/tdlibreceiver.h +++ b/src/tdlibreceiver.h @@ -26,9 +26,9 @@ private: bool isActive; void receiverLoop(); - void handleReceivedDocument(const QJsonDocument &receivedJsonDocument); - void handleUpdateOption(const QVariantMap &receivedInformation); - void handleUpdateAuthorizationState(const QVariantMap &receivedInformation); + void processReceivedDocument(const QJsonDocument &receivedJsonDocument); + void processUpdateOption(const QVariantMap &receivedInformation); + void processUpdateAuthorizationState(const QVariantMap &receivedInformation); }; #endif // TDLIBRECEIVER_H diff --git a/src/tdlibwrapper.cpp b/src/tdlibwrapper.cpp index 84788b4..f8f99c6 100644 --- a/src/tdlibwrapper.cpp +++ b/src/tdlibwrapper.cpp @@ -24,6 +24,10 @@ TDLibWrapper::TDLibWrapper(QObject *parent) : QObject(parent) qDebug() << "[TDLibWrapper] Initializing TD Lib..."; this->tdLibClient = td_json_client_create(); this->tdLibReceiver = new TDLibReceiver(this->tdLibClient, this); + + connect(this->tdLibReceiver, SIGNAL(versionDetected(QString)), this, SLOT(handleVersionDetected(QString))); + connect(this->tdLibReceiver, SIGNAL(authorizationStateChanged(QString)), this, SLOT(handleAuthorizationStateChanged(QString))); + this->tdLibReceiver->start(); } @@ -37,3 +41,25 @@ TDLibWrapper::~TDLibWrapper() td_json_client_destroy(this->tdLibClient); } +QString TDLibWrapper::getVersion() +{ + return this->version; +} + +QString TDLibWrapper::getAuthorizationState() +{ + return this->authorizationState; +} + +void TDLibWrapper::handleVersionDetected(const QString &version) +{ + this->version = version; + emit versionDetected(version); +} + +void TDLibWrapper::handleAuthorizationStateChanged(const QString &authorizationState) +{ + this->authorizationState = authorizationState; + emit authorizationStateChanged(authorizationState); +} + diff --git a/src/tdlibwrapper.h b/src/tdlibwrapper.h index 9b8160a..aba7a3b 100644 --- a/src/tdlibwrapper.h +++ b/src/tdlibwrapper.h @@ -14,15 +14,24 @@ public: explicit TDLibWrapper(QObject *parent = nullptr); ~TDLibWrapper(); + Q_INVOKABLE QString getVersion(); + Q_INVOKABLE QString getAuthorizationState(); + signals: + void versionDetected(const QString &version); + void authorizationStateChanged(const QString &authorizationState); public slots: - + void handleVersionDetected(const QString &version); + void handleAuthorizationStateChanged(const QString &authorizationState); private: void *tdLibClient; TDLibReceiver *tdLibReceiver; + QString version; + QString authorizationState; + }; #endif // TDLIBWRAPPER_H diff --git a/translations/harbour-fernschreiber-de.ts b/translations/harbour-fernschreiber-de.ts index c3d51cb..0ab953f 100644 --- a/translations/harbour-fernschreiber-de.ts +++ b/translations/harbour-fernschreiber-de.ts @@ -27,10 +27,6 @@ Sources on GitHub - - This product uses the Telegram API but is not endorsed or certified by Telegram - - Terms of Service @@ -55,6 +51,14 @@ About Telegram + + This product uses the Telegram API but is not endorsed or certified by Telegram. + + + + TDLib version %1 + + OverviewPage diff --git a/translations/harbour-fernschreiber.ts b/translations/harbour-fernschreiber.ts index c3d51cb..0ab953f 100644 --- a/translations/harbour-fernschreiber.ts +++ b/translations/harbour-fernschreiber.ts @@ -27,10 +27,6 @@ Sources on GitHub - - This product uses the Telegram API but is not endorsed or certified by Telegram - - Terms of Service @@ -55,6 +51,14 @@ About Telegram + + This product uses the Telegram API but is not endorsed or certified by Telegram. + + + + TDLib version %1 + + OverviewPage