Qt: simplify current_build in update manager

This commit is contained in:
Megamouse 2020-03-22 15:09:37 +01:00
parent 7f8d802bd5
commit da09badd8d
2 changed files with 10 additions and 8 deletions

View File

@ -526,7 +526,7 @@ void main_window::HandlePackageInstallation(QStringList file_paths)
// Update progress window
double pval = progress;
pval < 0 ? pval += 1. : pval;
if (pval < 0) pval += 1.;
pdlg.SetValue(static_cast<int>(pval * pdlg.maximum()));
QCoreApplication::processEvents();
}
@ -660,8 +660,8 @@ void main_window::HandlePupInstallation(QString file_path)
updatefilenames.end());
std::string version_string = pup.get_file(0x100).to_string();
size_t version_pos = version_string.find('\n');
if (version_pos != umax)
if (const size_t version_pos = version_string.find('\n'); version_pos != umax)
{
version_string.erase(version_pos);
}
@ -824,7 +824,7 @@ void main_window::RepaintThumbnailIcons()
{
const QColor new_color = gui::utils::get_label_color("thumbnail_icon_color");
auto icon = [&new_color](const QString& path)
const auto icon = [&new_color](const QString& path)
{
return gui::utils::get_colorized_icon(QPixmap::fromImage(gui::utils::get_opaque_image_area(path)), Qt::black, new_color);
};
@ -847,7 +847,7 @@ void main_window::RepaintToolBarIcons()
{
const QColor new_color = gui::utils::get_label_color("toolbar_icon_color");
auto icon = [&new_color](const QString& path)
const auto icon = [&new_color](const QString& path)
{
return gui::utils::get_colorized_icon(QIcon(path), Qt::black, new_color);
};

View File

@ -179,7 +179,9 @@ bool update_manager::handle_json(bool automatic)
}
}
const auto& current = json_data["current_build"];
const auto& latest = json_data["latest_build"];
if (!latest.isObject())
{
update_log.error("JSON doesn't contain latest_build section");
@ -200,7 +202,7 @@ bool update_manager::handle_json(bool automatic)
// Check that every bit of info we need is there
if (!latest[os].isObject() || !latest[os]["download"].isString() || !latest[os]["size"].isDouble() || !latest[os]["checksum"].isString() || !latest["version"].isString() ||
!latest["datetime"].isString() ||
(hash_found && (!json_data["current_build"].isObject() || !json_data["current_build"]["version"].isString() || !json_data["current_build"]["datetime"].isString())))
(hash_found && (!current.isObject() || !current["version"].isString() || !current["datetime"].isString())))
{
update_log.error("Some information seems unavailable");
return false;
@ -220,7 +222,7 @@ bool update_manager::handle_json(bool automatic)
// Calculate how old the build is
const QString date_fmt = QStringLiteral("yyyy-MM-dd hh:mm:ss");
const QDateTime cur_date = hash_found ? QDateTime::fromString(json_data["current_build"]["datetime"].toString(), date_fmt) : QDateTime::currentDateTimeUtc();
const QDateTime cur_date = hash_found ? QDateTime::fromString(current["datetime"].toString(), date_fmt) : QDateTime::currentDateTimeUtc();
const QDateTime lts_date = QDateTime::fromString(latest["datetime"].toString(), date_fmt);
const QString cur_str = cur_date.toString(date_fmt);
@ -237,7 +239,7 @@ bool update_manager::handle_json(bool automatic)
if (hash_found)
{
message = tr("A new version of RPCS3 is available!\n\nCurrent version: %0 (%1)\nLatest version: %2 (%3)\nYour version is %4 old.\n\nDo you want to update?")
.arg(json_data["current_build"]["version"].toString())
.arg(current["version"].toString())
.arg(cur_str)
.arg(latest["version"].toString())
.arg(lts_str)