2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 06:35:14 +00:00

Improve autoupdate code, move it from Application.

This commit is contained in:
John Preston
2018-04-26 20:14:21 +04:00
parent 65f968ec1b
commit 993cb987a6
18 changed files with 745 additions and 556 deletions

View File

@@ -26,7 +26,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/labels.h"
#include "ui/wrap/fade_wrap.h"
#include "ui/effects/slide_animation.h"
#include "autoupdater.h"
#include "core/update_checker.h"
#include "window/window_slide_animation.h"
#include "styles/style_boxes.h"
#include "styles/style_intro.h"
@@ -42,7 +42,7 @@ constexpr str_const kDefaultCountry = "US";
} // namespace
Widget::Widget(QWidget *parent) : TWidget(parent)
Widget::Widget(QWidget *parent) : RpWidget(parent)
, _back(this, object_ptr<Ui::IconButton>(this, st::introBackButton))
, _settings(
this,
@@ -82,10 +82,17 @@ Widget::Widget(QWidget *parent) : TWidget(parent)
cSetPasswordRecovered(false);
#ifndef TDESKTOP_DISABLE_AUTOUPDATE
Sandbox::connect(SIGNAL(updateLatest()), this, SLOT(onCheckUpdateStatus()));
Sandbox::connect(SIGNAL(updateFailed()), this, SLOT(onCheckUpdateStatus()));
Sandbox::connect(SIGNAL(updateReady()), this, SLOT(onCheckUpdateStatus()));
Sandbox::startUpdateCheck();
Core::UpdateChecker checker;
checker.isLatest() | rpl::start_with_next([=] {
onCheckUpdateStatus();
}, lifetime());
checker.failed() | rpl::start_with_next([=] {
onCheckUpdateStatus();
}, lifetime());
checker.ready() | rpl::start_with_next([=] {
onCheckUpdateStatus();
}, lifetime());
checker.start();
onCheckUpdateStatus();
#endif // !TDESKTOP_DISABLE_AUTOUPDATE
}
@@ -132,7 +139,7 @@ void Widget::createLanguageLink() {
#ifndef TDESKTOP_DISABLE_AUTOUPDATE
void Widget::onCheckUpdateStatus() {
if (Sandbox::updatingState() == Application::UpdatingReady) {
if (Core::UpdateChecker().state() == Core::UpdateChecker::State::Ready) {
if (_update) return;
_update.create(
this,
@@ -144,7 +151,7 @@ void Widget::onCheckUpdateStatus() {
_update->setVisible(true);
}
_update->entity()->setClickedCallback([] {
checkReadyUpdate();
Core::checkReadyUpdate();
App::restart();
});
} else {

View File

@@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#pragma once
#include "mtproto/sender.h"
#include "ui/rp_widget.h"
namespace Ui {
class IconButton;
@@ -22,7 +23,7 @@ class FadeWrap;
namespace Intro {
class Widget : public TWidget, private MTP::Sender, private base::Subscriber {
class Widget : public Ui::RpWidget, private MTP::Sender, private base::Subscriber {
Q_OBJECT
public: