Display connecting to proxy state with a link.

This commit is contained in:
John Preston 2017-06-27 22:24:59 +03:00
parent 8c04bed572
commit 1968ca07de
2 changed files with 13 additions and 4 deletions

View File

@ -88,6 +88,8 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
"lng_continue" = "Continue";
"lng_close" = "Close";
"lng_connecting" = "Connecting...";
"lng_connecting_to_proxy" = "Connecting to proxy...";
"lng_connecting_settings" = "Settings";
"lng_reconnecting#one" = "Reconnect in {count} s...";
"lng_reconnecting#other" = "Reconnect in {count} s...";
"lng_reconnecting_try_now" = "Try now";

View File

@ -41,6 +41,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
#include "boxes/confirm_box.h"
#include "boxes/contacts_box.h"
#include "boxes/add_contact_box.h"
#include "boxes/connection_box.h"
#include "observer_peer.h"
#include "autoupdater.h"
#include "mediaview.h"
@ -113,7 +114,12 @@ void ConnectingWidget::paintEvent(QPaintEvent *e) {
}
void ConnectingWidget::onReconnect() {
MTP::restart();
auto throughProxy = (Global::ConnectionType() != dbictAuto);
if (throughProxy) {
Ui::show(Box<ConnectionBox>());
} else {
MTP::restart();
}
}
MainWindow::MainWindow() {
@ -371,13 +377,14 @@ void MainWindow::mtpStateChanged(int32 dc, int32 state) {
}
void MainWindow::updateConnectingStatus() {
int32 state = MTP::dcstate();
auto state = MTP::dcstate();
auto throughProxy = (Global::ConnectionType() != dbictAuto);
if (state == MTP::ConnectingState || state == MTP::DisconnectedState || (state < 0 && state > -600)) {
if (_main || getms() > 5000 || _connecting) {
showConnecting(lang(lng_connecting));
showConnecting(lang(throughProxy ? lng_connecting_to_proxy : lng_connecting), throughProxy ? lang(lng_connecting_settings) : QString());
}
} else if (state < 0) {
showConnecting(lng_reconnecting(lt_count, ((-state) / 1000) + 1), lang(lng_reconnecting_try_now));
showConnecting(lng_reconnecting(lt_count, ((-state) / 1000) + 1), lang(throughProxy ? lng_connecting_settings : lng_reconnecting_try_now));
QTimer::singleShot((-state) % 1000, this, SLOT(updateConnectingStatus()));
} else {
hideConnecting();