From 965909f7fa60ee9b8a0e06112c79b0b105ccc73e Mon Sep 17 00:00:00 2001 From: Kevin Ottens Date: Wed, 27 May 2020 20:23:36 +0200 Subject: [PATCH] Add missing auto opportunities Somehow forgot to run it on the updater code Signed-off-by: Kevin Ottens --- .clang-tidy | 1 + src/gui/application.cpp | 2 +- src/gui/generalsettings.cpp | 4 ++-- src/gui/updater/ocupdater.cpp | 20 ++++++++++---------- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 039e5d385..071f522fd 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -4,6 +4,7 @@ Checks: '-*, modernize-redundant-void-arg, modernize-replace-*, modernize-shrink-to-fit, + modernize-use-auto, modernize-use-bool-literals, modernize-use-emplace, modernize-use-noexcept, diff --git a/src/gui/application.cpp b/src/gui/application.cpp index 9083924fc..be5c098fe 100644 --- a/src/gui/application.cpp +++ b/src/gui/application.cpp @@ -261,7 +261,7 @@ Application::Application(int &argc, char **argv) #if defined(BUILD_UPDATER) // Update checks - UpdaterScheduler *updaterScheduler = new UpdaterScheduler(this); + auto *updaterScheduler = new UpdaterScheduler(this); connect(updaterScheduler, &UpdaterScheduler::updaterAnnouncement, _gui.data(), &ownCloudGui::slotShowTrayMessage); connect(updaterScheduler, &UpdaterScheduler::requestRestart, diff --git a/src/gui/generalsettings.cpp b/src/gui/generalsettings.cpp index 40362cc64..34672aae7 100644 --- a/src/gui/generalsettings.cpp +++ b/src/gui/generalsettings.cpp @@ -163,7 +163,7 @@ void GeneralSettings::loadMiscSettings() void GeneralSettings::slotUpdateInfo() { // Note: the sparkle-updater is not an OCUpdater - OCUpdater *updater = qobject_cast(Updater::instance()); + auto *updater = qobject_cast(Updater::instance()); if (ConfigFile().skipUpdateCheck()) { updater = nullptr; // don't show update info if updates are disabled } @@ -194,7 +194,7 @@ void GeneralSettings::slotUpdateInfo() void GeneralSettings::slotUpdateCheckNow() { - OCUpdater *updater = qobject_cast(Updater::instance()); + auto *updater = qobject_cast(Updater::instance()); if (ConfigFile().skipUpdateCheck()) { updater = nullptr; // don't show update info if updates are disabled } diff --git a/src/gui/updater/ocupdater.cpp b/src/gui/updater/ocupdater.cpp index 18ef64e20..4d3a0d3de 100644 --- a/src/gui/updater/ocupdater.cpp +++ b/src/gui/updater/ocupdater.cpp @@ -43,7 +43,7 @@ UpdaterScheduler::UpdaterScheduler(QObject *parent) this, &UpdaterScheduler::slotTimerFired); // Note: the sparkle-updater is not an OCUpdater - if (OCUpdater *updater = qobject_cast(Updater::instance())) { + if (auto *updater = qobject_cast(Updater::instance())) { connect(updater, &OCUpdater::newUpdateAvailable, this, &UpdaterScheduler::updaterAnnouncement); connect(updater, &OCUpdater::requestRestart, this, &UpdaterScheduler::requestRestart); @@ -219,7 +219,7 @@ bool OCUpdater::updateSucceeded() const void OCUpdater::slotVersionInfoArrived() { _timeoutWatchdog->stop(); - QNetworkReply *reply = qobject_cast(sender()); + auto *reply = qobject_cast(sender()); reply->deleteLater(); if (reply->error() != QNetworkReply::NoError) { qCWarning(lcUpdater) << "Failed to reach version check url: " << reply->errorString(); @@ -254,7 +254,7 @@ NSISUpdater::NSISUpdater(const QUrl &url) void NSISUpdater::slotWriteFile() { - QNetworkReply *reply = qobject_cast(sender()); + auto *reply = qobject_cast(sender()); if (_file->isOpen()) { _file->write(reply->readAll()); } @@ -262,7 +262,7 @@ void NSISUpdater::slotWriteFile() void NSISUpdater::slotDownloadFinished() { - QNetworkReply *reply = qobject_cast(sender()); + auto *reply = qobject_cast(sender()); reply->deleteLater(); if (reply->error() != QNetworkReply::NoError) { setDownloadState(DownloadFailed); @@ -319,7 +319,7 @@ void NSISUpdater::versionInfoArrived(const UpdateInfo &info) void NSISUpdater::showDialog(const UpdateInfo &info) { // if the version tag is set, there is a newer version. - QDialog *msgBox = new QDialog; + auto *msgBox = new QDialog; msgBox->setAttribute(Qt::WA_DeleteOnClose); QIcon infoIcon = msgBox->style()->standardIcon(QStyle::SP_MessageBoxInformation, nullptr, nullptr); @@ -327,16 +327,16 @@ void NSISUpdater::showDialog(const UpdateInfo &info) msgBox->setWindowIcon(infoIcon); - QVBoxLayout *layout = new QVBoxLayout(msgBox); - QHBoxLayout *hlayout = new QHBoxLayout; + auto *layout = new QVBoxLayout(msgBox); + auto *hlayout = new QHBoxLayout; layout->addLayout(hlayout); msgBox->setWindowTitle(tr("New Version Available")); - QLabel *ico = new QLabel; + auto *ico = new QLabel; ico->setFixedSize(iconSize, iconSize); ico->setPixmap(infoIcon.pixmap(iconSize)); - QLabel *lbl = new QLabel; + auto *lbl = new QLabel; QString txt = tr("

A new version of the %1 Client is available.

" "

%2 is available for download. The installed version is %3.

") .arg(Utility::escape(Theme::instance()->appNameGUI()), @@ -349,7 +349,7 @@ void NSISUpdater::showDialog(const UpdateInfo &info) hlayout->addWidget(ico); hlayout->addWidget(lbl); - QDialogButtonBox *bb = new QDialogButtonBox; + auto *bb = new QDialogButtonBox; bb->setWindowFlags(bb->windowFlags() & ~Qt::WindowContextHelpButtonHint); QPushButton *skip = bb->addButton(tr("Skip this version"), QDialogButtonBox::ResetRole); QPushButton *reject = bb->addButton(tr("Skip this time"), QDialogButtonBox::AcceptRole);