Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/gui/application.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/*
* SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2014 ownCloud GmbH
Expand Down Expand Up @@ -125,7 +125,7 @@
{
ConfigFile configFile;
const auto shouldTryToMigrate = configFile.shouldTryToMigrate();
if (!shouldTryToMigrate) {

Check warning on line 128 in src/gui/application.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use the init-statement to declare "shouldTryToMigrate" inside the if statement.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ8clfaQGT3uPLl7RN-S&open=AZ8clfaQGT3uPLl7RN-S&pullRequest=10277
qCInfo(lcApplication) << "This is not an upgrade/downgrade/migration. Proceed to read current application config file.";
configFile.setMigrationPhase(ConfigFile::MigrationPhase::Done);
return false;
Expand Down Expand Up @@ -310,7 +310,7 @@
qCDebug(lcApplication) << "Failed to move the old config directory to its new location (" << legacyDir << "to" << confDir << ")";

// Try to move the files one by one
if (QFileInfo(confDir).isDir() || QDir().mkdir(confDir)) {

Check failure on line 313 in src/gui/application.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this TOCTOU race condition window when accessing files

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ8clfaQGT3uPLl7RN-U&open=AZ8clfaQGT3uPLl7RN-U&pullRequest=10277
const QStringList filesList = QDir(legacyDir).entryList(QDir::Files);
qCDebug(lcApplication) << "Will move the individual files" << filesList;
for (const auto &name : filesList) {
Expand All @@ -322,7 +322,7 @@
} else {
#ifndef Q_OS_WIN
// Create a symbolic link so a downgrade of the client would still find the config.
QFile::link(confDir, legacyDir);

Check failure on line 325 in src/gui/application.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this TOCTOU race condition window when accessing files

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ8clfaQGT3uPLl7RN-T&open=AZ8clfaQGT3uPLl7RN-T&pullRequest=10277
#endif
}
}
Expand All @@ -330,7 +330,7 @@
setupConfigFile();
}

if (_theme->doNotUseProxy()) {

Check warning on line 333 in src/gui/application.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace "->" with "::" for access to "Theme::doNotUseProxy".

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ8clfaQGT3uPLl7RN-V&open=AZ8clfaQGT3uPLl7RN-V&pullRequest=10277
ConfigFile().setProxyType(QNetworkProxy::NoProxy);
const auto &allAccounts = AccountManager::instance()->accounts();
for (const auto &accountState : allAccounts) {
Expand Down Expand Up @@ -430,7 +430,7 @@
_gui->setupCloudProviders();
#endif

if (_theme->doNotUseProxy()) {

Check warning on line 433 in src/gui/application.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace "->" with "::" for access to "Theme::doNotUseProxy".

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ8clfaQGT3uPLl7RN-W&open=AZ8clfaQGT3uPLl7RN-W&pullRequest=10277
ConfigFile().setProxyType(QNetworkProxy::NoProxy);
const auto &allAccounts = AccountManager::instance()->accounts();
for (const auto &accountState : allAccounts) {
Expand Down Expand Up @@ -620,7 +620,7 @@
const auto foldersRestoreMessage = foldersListSize > 1
? tr("%1 folders", "number of folders imported").arg(QString::number(foldersListSize))
: tr("1 folder");
const auto messageBox = new QMessageBox(QMessageBox::Information,

Check failure on line 623 in src/gui/application.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace the use of "new" with an operation that automatically manages the memory.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ8clfaQGT3uPLl7RN-X&open=AZ8clfaQGT3uPLl7RN-X&pullRequest=10277
tr("Legacy import"),
tr("Imported %1 and %2 from a legacy desktop client.\n%3",
"number of accounts and folders imported. list of users.")
Expand Down Expand Up @@ -674,7 +674,7 @@
AccountSetupCommandLineManager::destroy();
}

void Application::setupConfigFile()

Check warning on line 677 in src/gui/application.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This function should be declared "const".

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ8clfaQGT3uPLl7RN-Y&open=AZ8clfaQGT3uPLl7RN-Y&pullRequest=10277
{
// Migrate from version <= 2.4
setApplicationName(_theme->appNameGUI());
Expand Down Expand Up @@ -709,11 +709,11 @@
qCDebug(lcApplication) << "Failed to move the old config directory to its new location (" << oldDir << "to" << confDir << ")";

// Try to move the files one by one
if (QFileInfo(confDir).isDir() || QDir().mkdir(confDir)) {

Check failure on line 712 in src/gui/application.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this TOCTOU race condition window when accessing files

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ8clfaQGT3uPLl7RN-a&open=AZ8clfaQGT3uPLl7RN-a&pullRequest=10277
const QStringList filesList = QDir(oldDir).entryList(QDir::Files);
qCDebug(lcApplication) << "Will move the individual files" << filesList;
for (const auto &name : filesList) {
if (!QFile::rename(oldDir + "/" + name, confDir + "/" + name)) {

Check failure on line 716 in src/gui/application.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor this code to not nest more than 3 if|for|do|while|switch statements.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ8clfaQGT3uPLl7RN-Z&open=AZ8clfaQGT3uPLl7RN-Z&pullRequest=10277
qCDebug(lcApplication) << "Fallback move of " << name << "also failed";
}
}
Expand All @@ -726,9 +726,9 @@
}
}

AccountManager::AccountsRestoreResult Application::restoreLegacyAccount()

Check warning on line 729 in src/gui/application.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This function should be declared "const".

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ8clfaQGT3uPLl7RN-b&open=AZ8clfaQGT3uPLl7RN-b&pullRequest=10277
{
ConfigFile cfg;

Check warning on line 731 in src/gui/application.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "cfg" of type "class OCC::ConfigFile" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ8clfaQGT3uPLl7RN-c&open=AZ8clfaQGT3uPLl7RN-c&pullRequest=10277
const auto tryMigrate = cfg.overrideServerUrl().isEmpty();
auto accountsRestoreResult = AccountManager::AccountsRestoreFailure;
if (accountsRestoreResult = AccountManager::instance()->restore(tryMigrate);
Expand Down Expand Up @@ -805,7 +805,7 @@
// FIXME: This is not ideal yet since a ConnectionValidator might already be running and is in
// progress of timing out in some seconds.
// Maybe we need 2 validators, one triggered by timer, one by network configuration changes?
void Application::slotSystemOnlineConfigurationChanged()

Check warning on line 808 in src/gui/application.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this identifier to be shorter or equal to 31 characters.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ8clfaQGT3uPLl7RN-d&open=AZ8clfaQGT3uPLl7RN-d&pullRequest=10277

Check warning on line 808 in src/gui/application.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This function should be declared "const".

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ8clfaQGT3uPLl7RN-e&open=AZ8clfaQGT3uPLl7RN-e&pullRequest=10277
{
if (QNetworkInformation::instance()->reachability() == QNetworkInformation::Reachability::Site ||
QNetworkInformation::instance()->reachability() == QNetworkInformation::Reachability::Online) {
Expand Down Expand Up @@ -881,7 +881,8 @@
<< "locale:" << QLocale::system().name()
<< "ui_lang:" << property("ui_lang")
<< "version:" << _theme->version()
<< "os:" << Utility::platformName();
<< "os:" << Utility::platformName()
<< "platform:" << QApplication::platformName();
qCInfo(lcApplication) << "Arguments:" << qApp->arguments();
}

Expand Down Expand Up @@ -982,7 +983,7 @@
}
} else if (option == QStringLiteral("--overrideserverurl")) {
if (it.hasNext() && !it.peekNext().startsWith(QLatin1String("--"))) {
const auto overrideUrl = it.next();

Check warning on line 986 in src/gui/application.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Avoid this unnecessary copy by using a "const" reference.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ8clfaQGT3uPLl7RN-f&open=AZ8clfaQGT3uPLl7RN-f&pullRequest=10277
const auto isUrlValid = (overrideUrl.startsWith(QStringLiteral("http://")) || overrideUrl.startsWith(QStringLiteral("https://")))
&& QUrl::fromUserInput(overrideUrl).isValid();
if (!isUrlValid) {
Expand Down Expand Up @@ -1135,7 +1136,7 @@
{
const ConfigFile cfg;
const auto configLanguage = cfg.language();
if (!configLanguage.isEmpty()) {

Check warning on line 1139 in src/gui/application.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use the init-statement to declare "configLanguage" inside the if statement.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ8clfaQGT3uPLl7RN-g&open=AZ8clfaQGT3uPLl7RN-g&pullRequest=10277
// always prefer value from configuration
return configLanguage;
}
Expand Down Expand Up @@ -1187,8 +1188,8 @@
const QString qtBaseTrFile = QLatin1String("qtbase_") + choosenLanguage;
if (!qtTranslator->load(qtTrFile, qtTrPath)) {
if (!qtTranslator->load(qtTrFile, trPath)) {
if (!qtTranslator->load(qtBaseTrFile, qtTrPath)) {

Check failure on line 1191 in src/gui/application.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor this code to not nest more than 3 if|for|do|while|switch statements.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ8clfaQGT3uPLl7RN-h&open=AZ8clfaQGT3uPLl7RN-h&pullRequest=10277
if (!qtTranslator->load(qtBaseTrFile, trPath)) {

Check warning on line 1192 in src/gui/application.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Merge this "if" statement with the enclosing one.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ8clfaQGT3uPLl7RN-j&open=AZ8clfaQGT3uPLl7RN-j&pullRequest=10277
qCDebug(lcApplication()) << "impossible to load Qt translation catalog" << qtBaseTrFile;
}
}
Expand All @@ -1196,7 +1197,7 @@
}
const QString qtkeychainTrFile = QLatin1String("qtkeychain_") + choosenLanguage;
if (!qtkeychainTranslator->load(qtkeychainTrFile, qtTrPath)) {
if (!qtkeychainTranslator->load(qtkeychainTrFile, trPath)) {

Check warning on line 1200 in src/gui/application.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Merge this "if" statement with the enclosing one.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ8clfaQGT3uPLl7RN-i&open=AZ8clfaQGT3uPLl7RN-i&pullRequest=10277
qCDebug(lcApplication()) << "impossible to load QtKeychain translation catalog" << qtkeychainTrFile;
}
}
Expand Down Expand Up @@ -1246,7 +1247,7 @@

void Application::openVirtualFile(const QString &filename)
{
QString virtualFileExt = QStringLiteral(APPLICATION_DOTVIRTUALFILE_SUFFIX);

Check warning on line 1250 in src/gui/application.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace the redundant type with "auto".

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ8clfaQGT3uPLl7RN-k&open=AZ8clfaQGT3uPLl7RN-k&pullRequest=10277
if (!filename.endsWith(virtualFileExt)) {
qWarning(lcApplication) << "Can only handle file ending in .owncloud. Unable to open" << filename;
return;
Expand Down
2 changes: 0 additions & 2 deletions src/gui/infosettings.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: GPL-2.0-or-later
*/

Check warning on line 4 in src/gui/infosettings.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Edit this comment to use the C++ format, i.e. "//".

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ8iTJHtF48o4O_dRizf&open=AZ8iTJHtF48o4O_dRizf&pullRequest=10277

#include "infosettings.h"
#include "ui_infosettings.h"
Expand All @@ -27,7 +27,6 @@
#include <QLabel>
#include <QMessageBox>
#include <QPushButton>
#include <QRegularExpression>
#include <QSizePolicy>
#include <QUrl>

Expand All @@ -38,14 +37,13 @@
{
auto aboutText = Theme::instance()->about();
Theme::replaceLinkColorStringBackgroundAware(aboutText);
aboutText.replace(QRegularExpression(QStringLiteral(R"( \(([^()]*)\)$)")), QStringLiteral("<br>(\\1)"));
return aboutText;
}
}

InfoSettings::InfoSettings(QWidget *parent)

Check warning on line 44 in src/gui/infosettings.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "parent" of type "class QWidget *" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ8iTJHtF48o4O_dRizh&open=AZ8iTJHtF48o4O_dRizh&pullRequest=10277
: QWidget(parent)
, _ui(new Ui::InfoSettings)

Check failure on line 46 in src/gui/infosettings.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace the use of "new" with an operation that automatically manages the memory.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ8iTJHtF48o4O_dRizi&open=AZ8iTJHtF48o4O_dRizi&pullRequest=10277
{
_ui->setupUi(this);

Expand Down Expand Up @@ -76,7 +74,7 @@

InfoSettings::~InfoSettings()
{
delete _ui;

Check failure on line 77 in src/gui/infosettings.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rewrite the code so that you no longer need this "delete".

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ8iTJHtF48o4O_dRizj&open=AZ8iTJHtF48o4O_dRizj&pullRequest=10277
}

QSize InfoSettings::sizeHint() const
Expand All @@ -89,7 +87,7 @@

#if defined(BUILD_UPDATER)
void InfoSettings::loadUpdateChannelsList() {
ConfigFile cfgFile;

Check warning on line 90 in src/gui/infosettings.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "cfgFile" of type "class OCC::ConfigFile" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ8iTJHtF48o4O_dRizk&open=AZ8iTJHtF48o4O_dRizk&pullRequest=10277
if (cfgFile.serverHasValidSubscription()) {
_ui->updateChannel->hide();
_ui->updateChannelLabel->hide();
Expand All @@ -104,7 +102,7 @@
_ui->updateChannel->clear();
_ui->updateChannel->addItems(_currentUpdateChannelList);
const auto currentUpdateChannelIndex = _currentUpdateChannelList.indexOf(currentUpdateChannel);
_ui->updateChannel->setCurrentIndex(currentUpdateChannelIndex != -1 ? currentUpdateChannelIndex : 0);

Check warning on line 105 in src/gui/infosettings.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

implicit conversion loses integer precision: 'const qsizetype' (aka 'const long long') to 'int'

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ8iTJHtF48o4O_dRizg&open=AZ8iTJHtF48o4O_dRizg&pullRequest=10277
connect(_ui->updateChannel, &QComboBox::currentTextChanged, this, &InfoSettings::slotUpdateChannelChanged);
}

Expand All @@ -116,7 +114,7 @@

void InfoSettings::slotUpdateInfo()
{
ConfigFile config;

Check warning on line 117 in src/gui/infosettings.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "config" of type "class OCC::ConfigFile" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ8iTJHtF48o4O_dRizl&open=AZ8iTJHtF48o4O_dRizl&pullRequest=10277
const auto updater = Updater::instance();
if (config.skipUpdateCheck() || !updater) {
_ui->updatesContainer->setVisible(false);
Expand Down Expand Up @@ -190,9 +188,9 @@
#endif
}

void InfoSettings::setAndCheckNewUpdateChannel(const QString &newChannel) {

Check warning on line 191 in src/gui/infosettings.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This function should be declared "const".

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ8iTJHtF48o4O_dRizm&open=AZ8iTJHtF48o4O_dRizm&pullRequest=10277
ConfigFile().setUpdateChannel(newChannel);
if (auto updater = qobject_cast<OCUpdater *>(Updater::instance())) {

Check warning on line 193 in src/gui/infosettings.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "updater" of type "class OCC::OCUpdater *" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ8iTJHtF48o4O_dRizn&open=AZ8iTJHtF48o4O_dRizn&pullRequest=10277
updater->setUpdateUrl(Updater::updateUrl());
updater->checkForUpdate();
}
Expand Down Expand Up @@ -240,7 +238,7 @@
}
};

ConfigFile configFile;

Check warning on line 241 in src/gui/infosettings.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "configFile" of type "class OCC::ConfigFile" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ8iTJHtF48o4O_dRizo&open=AZ8iTJHtF48o4O_dRizo&pullRequest=10277
const auto newChannel = updateChannelFromLocalized(_ui->updateChannel->currentIndex());
const auto currentUpdateChannel = configFile.currentUpdateChannel();
if (newChannel == currentUpdateChannel) {
Expand All @@ -264,15 +262,15 @@
"Downgrading versions is not possible immediately: changing from stable to enterprise means waiting for the new enterprise version.",
"list of available update channels to enterprise users and downgrading warning");

auto msgBox = new QMessageBox(
QMessageBox::Warning,
tr("Changing update channel?"),
tr("The channel determines which upgrades will be offered to install:\n"
"- stable: contains tested versions considered reliable\n",
"starts list of available update channels, stable is always available")
.append(configFile.validUpdateChannels().contains("enterprise") ? enterpriseOptions : nonEnterpriseOptions),
QMessageBox::NoButton,
this);

Check warning on line 273 in src/gui/infosettings.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "msgBox" of type "class QMessageBox *" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ8iTJHtF48o4O_dRizp&open=AZ8iTJHtF48o4O_dRizp&pullRequest=10277
const auto acceptButton = msgBox->addButton(tr("Change update channel"), QMessageBox::AcceptRole);
msgBox->addButton(tr("Cancel"), QMessageBox::RejectRole);
connect(msgBox, &QMessageBox::finished, msgBox, [this, newChannel, currentUpdateChannel, msgBox, acceptButton] {
Expand Down Expand Up @@ -303,7 +301,7 @@
}
}

void InfoSettings::slotToggleAutoUpdateCheck()

Check warning on line 304 in src/gui/infosettings.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This function should be declared "const".

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ8iTJHtF48o4O_dRizq&open=AZ8iTJHtF48o4O_dRizq&pullRequest=10277
{
ConfigFile().setAutoUpdateCheck(_ui->autoCheckForUpdatesCheckBox->isChecked(), QString());
}
Expand All @@ -324,7 +322,7 @@

void InfoSettings::slotShowLegalNotice()
{
auto notice = new LegalNotice(this);

Check warning on line 325 in src/gui/infosettings.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "notice" of type "class OCC::LegalNotice *" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ8iTJHtF48o4O_dRizr&open=AZ8iTJHtF48o4O_dRizr&pullRequest=10277
notice->setAttribute(Qt::WA_DeleteOnClose);
notice->open();
}
Expand Down
9 changes: 2 additions & 7 deletions src/libsync/theme.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/*
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2012 ownCloud GmbH
Expand Down Expand Up @@ -215,9 +215,9 @@
return imagePathToUrl(themeImagePath("state-offline"));
}

/*
* neutral icons for in-app status
*/

Check warning on line 220 in src/libsync/theme.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Edit this comment to use the C++ format, i.e. "//".

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ8ic7pAikeny8Xk02DP&open=AZ8ic7pAikeny8Xk02DP&pullRequest=10277

QUrl Theme::offline() const
{
Expand Down Expand Up @@ -385,7 +385,7 @@
// try to find a 2x version


const int dotIndex = fileName.lastIndexOf(QLatin1Char('.'));

Check warning on line 388 in src/libsync/theme.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

implicit conversion loses integer precision: 'qsizetype' (aka 'long long') to 'const int'

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ8ic7pAikeny8Xk02DR&open=AZ8ic7pAikeny8Xk02DR&pullRequest=10277
if (dotIndex != -1) {
QString at2xfileName = fileName;
at2xfileName.insert(dotIndex, QStringLiteral("@2x"));
Expand Down Expand Up @@ -459,13 +459,8 @@

QString Theme::developerStringInfo() const
{
// Shorten Qt's OS name: "macOS Mojave (10.14)" -> "macOS"
const auto osStringList = Utility::platformName().split(QLatin1Char(' '));
const auto osName = osStringList.at(0);

const auto devString = QString(tr("%1 Desktop Client Version %2 (%3 running on %4)", "%1 is application name. %2 is the human version string. %3 is the operating system name. %4 is the platform name (wayland, x11, …)"))
.arg(APPLICATION_NAME, QString::fromLatin1(MIRALL_HUMAN_VERSION_STRING), osName, qGuiApp->platformName());

const auto devString = QString(tr("%1 Desktop Client Version %2", "%1 is application name. %2 is the human version string."))
.arg(APPLICATION_NAME, QString::fromLatin1(MIRALL_HUMAN_VERSION_STRING));
return devString;
}

Expand Down Expand Up @@ -744,9 +739,9 @@

// Neutral icons for the classic sync folder list

QIcon Theme::folderStateIcon(SyncResult::Status status) const

Check warning on line 742 in src/libsync/theme.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "status" of type "enum OCC::SyncResult::Status" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ8ic7pAikeny8Xk02DS&open=AZ8ic7pAikeny8Xk02DS&pullRequest=10277
{
// FIXME: Mind the size!

Check warning on line 744 in src/libsync/theme.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Take the required action to fix the issue indicated by this "FIXME" comment.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ8ic7pAikeny8Xk02DQ&open=AZ8ic7pAikeny8Xk02DQ&pullRequest=10277
QString statusIcon;

switch (status) {
Expand All @@ -772,7 +767,7 @@
case SyncResult::SetupError:
statusIcon = QLatin1String("offline");
break;
case SyncResult::Error:

Check warning on line 770 in src/libsync/theme.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this redundant "case" clause.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ8ic7pAikeny8Xk02DT&open=AZ8ic7pAikeny8Xk02DT&pullRequest=10277
default:
statusIcon = QLatin1String("error");
}
Expand Down Expand Up @@ -1051,13 +1046,13 @@
void Theme::connectToPaletteSignal() const
{
if (const auto ptr = qobject_cast<QGuiApplication*>(qApp)) {
connect(ptr->styleHints(), &QStyleHints::colorSchemeChanged, this, &Theme::darkModeChanged, Qt::UniqueConnection);

Check warning on line 1049 in src/libsync/theme.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace "->" with "::" for access to "QGuiApplication::styleHints".

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ8ic7pAikeny8Xk02DU&open=AZ8ic7pAikeny8Xk02DU&pullRequest=10277
}
}

QVariantMap Theme::systemPalette() const
{
auto systemPalette = QGuiApplication::palette();

Check warning on line 1055 in src/libsync/theme.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "systemPalette" of type "class QPalette" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ8ic7pAikeny8Xk02DV&open=AZ8ic7pAikeny8Xk02DV&pullRequest=10277
#if defined(Q_OS_WIN)
if (darkMode() && !isWindows11OrGreater()) {
systemPalette = reserveDarkPalette;
Expand Down Expand Up @@ -1095,7 +1090,7 @@
{
connectToPaletteSignal();
const auto isDarkFromStyle = [] {
switch (qGuiApp->styleHints()->colorScheme())

Check warning on line 1093 in src/libsync/theme.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace "->" with "::" for access to "QGuiApplication::styleHints".

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ8ic7pAikeny8Xk02DX&open=AZ8ic7pAikeny8Xk02DX&pullRequest=10277

Check failure on line 1093 in src/libsync/theme.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add a "default" case to this switch statement.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ8ic7pAikeny8Xk02DW&open=AZ8ic7pAikeny8Xk02DW&pullRequest=10277
{
case Qt::ColorScheme::Dark:
return true;
Expand Down Expand Up @@ -1170,7 +1165,7 @@
}
}

void Theme::systemPaletteHasChanged()

Check warning on line 1168 in src/libsync/theme.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This function should be declared "const".

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ8ic7pAikeny8Xk02DY&open=AZ8ic7pAikeny8Xk02DY&pullRequest=10277
{
qCInfo(lcTheme()) << "system palette changed";
#ifdef Q_OS_WIN
Expand Down
Loading