UpdateStateRow::UpdateStateRow(QWidget *parent) : RpWidget(parent) , _check(this, lang(lng_settings_check_now)) , _restart(this, lang(lng_settings_update_now)) { connect(_check, SIGNAL(clicked()), this, SLOT(onCheck())); connect(_restart, SIGNAL(clicked()), this, SIGNAL(restart())); _versionText = lng_settings_current_version_label(lt_version, currentVersionText()); Core::UpdateChecker checker; checker.checking() | rpl::start_with_next([=] { onChecking(); }, lifetime()); checker.isLatest() | rpl::start_with_next([=] { onLatest(); }, lifetime()); checker.progress( ) | rpl::start_with_next([=](Core::UpdateChecker::Progress progress) { onDownloading(progress.already, progress.size); }, lifetime()); checker.failed() | rpl::start_with_next([=] { onFailed(); }, lifetime()); checker.ready() | rpl::start_with_next([=] { onReady(); }, lifetime()); switch (checker.state()) { case Core::UpdateChecker::State::Download: setState(State::Download, true); setDownloadProgress(checker.already(), checker.size()); break; case Core::UpdateChecker::State::Ready: setState(State::Ready, true); break; default: setState(State::None, true); break; } }
UpdateStateRow::UpdateStateRow(QWidget *parent) : TWidget(parent) , _check(this, lang(lng_settings_check_now)) , _restart(this, lang(lng_settings_update_now)) { connect(_check, SIGNAL(clicked()), this, SLOT(onCheck())); connect(_restart, SIGNAL(clicked()), this, SIGNAL(restart())); Sandbox::connect(SIGNAL(updateChecking()), this, SLOT(onChecking())); Sandbox::connect(SIGNAL(updateLatest()), this, SLOT(onLatest())); Sandbox::connect(SIGNAL(updateProgress(qint64, qint64)), this, SLOT(onDownloading(qint64, qint64))); Sandbox::connect(SIGNAL(updateFailed()), this, SLOT(onFailed())); Sandbox::connect(SIGNAL(updateReady()), this, SLOT(onReady())); _versionText = lng_settings_current_version_label(lt_version, currentVersionText()); switch (Sandbox::updatingState()) { case Application::UpdatingDownload: setState(State::Download, true); setDownloadProgress(Sandbox::updatingReady(), Sandbox::updatingSize()); break; case Application::UpdatingReady: setState(State::Ready, true); break; default: setState(State::None, true); break; } }