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
12 changes: 10 additions & 2 deletions src/gui/accountsettings.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 @@ -60,6 +60,14 @@

using namespace Qt::StringLiterals;

#ifdef Q_OS_WIN
// "light" looks too bright on dark mode on Windows only
#define BACKGROUND_PALETTE "alternate-base"
#else
// ...and "alternate-base" looks too bright on macOS only. On Linux/Plasma either one looked fine ...
#define BACKGROUND_PALETTE "light"

Check warning on line 68 in src/gui/accountsettings.cpp

View workflow job for this annotation

GitHub Actions / build

src/gui/accountsettings.cpp:68:13 [cppcoreguidelines-macro-usage]

macro 'BACKGROUND_PALETTE' used to declare a constant; consider using a 'constexpr' constant

Check failure on line 68 in src/gui/accountsettings.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this macro by "const", "constexpr" or an "enum".

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ0piJd-7ASJbBRNzPi7&open=AZ0piJd-7ASJbBRNzPi7&pullRequest=9703
#endif

#ifdef BUILD_FILE_PROVIDER_MODULE
#include "macOS/fileprovider.h"
#endif
Expand All @@ -79,7 +87,7 @@
constexpr auto e2EeUiActionSetupEncryptionId = "setup_encryption";
constexpr auto e2EeUiActionForgetEncryptionId = "forget_encryption";
constexpr auto e2EeUiActionDisplayMnemonicId = "display_mnemonic";
constexpr auto e2EeUiActionMigrateCertificateId = "migrate_certificate";

Check warning on line 90 in src/gui/accountsettings.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=AZ0piJd-7ASJbBRNzPi-&open=AZ0piJd-7ASJbBRNzPi-&pullRequest=9703
}

namespace OCC {
Expand Down Expand Up @@ -171,7 +179,7 @@
AccountSettings::AccountSettings(AccountState *accountState, QWidget *parent)
: QWidget(parent)
, _ui(new Ui::AccountSettings)
, _model(new FolderStatusModel)

Check warning on line 182 in src/gui/accountsettings.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Do not use the constructor's initializer list for data member "_model". Use the in-class initializer instead.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ0piJd-7ASJbBRNzPi9&open=AZ0piJd-7ASJbBRNzPi9&pullRequest=9703

Check failure on line 182 in src/gui/accountsettings.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=AZ0piJd-7ASJbBRNzPi_&open=AZ0piJd-7ASJbBRNzPi_&pullRequest=9703
, _accountState(accountState)
, _userInfo(accountState, false, true)
{
Expand All @@ -182,7 +190,7 @@
const auto delegate = new FolderStatusDelegate;
delegate->setParent(this);

setStyleSheet("QWidget#syncFoldersPanelContents, QWidget#connectionSettingsPanelContents, QWidget#fileProviderPanelContents { background: palette(alternate-base); }"_L1);
setStyleSheet("QWidget#syncFoldersPanelContents, QWidget#connectionSettingsPanelContents, QWidget#fileProviderPanelContents { background: palette(" BACKGROUND_PALETTE "); }"_L1);
_ui->syncFoldersPanelContents->setAutoFillBackground(true);
_ui->syncFoldersPanelContents->setAttribute(Qt::WA_StyledBackground, true);
_ui->syncFoldersPanelContents->setContentsMargins(0, 0, 0, 0);
Expand All @@ -199,7 +207,7 @@
_ui->_folderList->header()->hide();
_ui->_folderList->setAutoFillBackground(true);
_ui->_folderList->setAttribute(Qt::WA_StyledBackground, true);
_ui->_folderList->setStyleSheet(QStringLiteral("QTreeView { background: palette(alternate-base); }"));
_ui->_folderList->setStyleSheet(QStringLiteral("QTreeView { background: palette(" BACKGROUND_PALETTE "); }"));
_ui->_folderList->setItemDelegate(delegate);
_ui->_folderList->setModel(_model);
_ui->_folderList->setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents);
Expand Down Expand Up @@ -228,8 +236,8 @@
#endif

const auto connectionSettingsPanelContents = _ui->connectionSettingsPanelContents;
const auto connectionSettingsLayout = new QVBoxLayout(connectionSettingsPanelContents);

Check failure on line 239 in src/gui/accountsettings.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=AZ0piJd-7ASJbBRNzPjA&open=AZ0piJd-7ASJbBRNzPjA&pullRequest=9703
const auto networkSettings = new NetworkSettings(_accountState->account(), connectionSettingsPanelContents);

Check failure on line 240 in src/gui/accountsettings.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=AZ0piJd-7ASJbBRNzPjB&open=AZ0piJd-7ASJbBRNzPjB&pullRequest=9703
if (const auto networkSettingsLayout = networkSettings->layout()) {
networkSettingsLayout->setContentsMargins(0, 0, 0, 0);
}
Expand Down Expand Up @@ -475,8 +483,8 @@
Q_ASSERT(folder);

const auto folderAlias = folder->alias();
const auto path = folderInfo->_path;

Check warning on line 486 in src/gui/accountsettings.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=AZ0piJd-7ASJbBRNzPjD&open=AZ0piJd-7ASJbBRNzPjD&pullRequest=9703
const auto fileId = folderInfo->_fileId;

Check warning on line 487 in src/gui/accountsettings.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=AZ0piJd-7ASJbBRNzPjE&open=AZ0piJd-7ASJbBRNzPjE&pullRequest=9703
const auto encryptFolder = [this, fileId, path, folderAlias] {
const auto folder = FolderMan::instance()->folder(folderAlias);
if (!folder) {
Expand All @@ -489,7 +497,7 @@
Q_ASSERT(!path.startsWith('/') && path.endsWith('/'));
// But EncryptFolderJob expects directory path Foo/Bar convention
const auto choppedPath = path.chopped(1);
auto job = new OCC::EncryptFolderJob(accountsState()->account(), folder->journalDb(), choppedPath, choppedPath, folder->remotePath(), fileId);

Check warning on line 500 in src/gui/accountsettings.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "job" of type "class OCC::EncryptFolderJob *" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ0piJd-7ASJbBRNzPjF&open=AZ0piJd-7ASJbBRNzPjF&pullRequest=9703

Check failure on line 500 in src/gui/accountsettings.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=AZ0piJd-7ASJbBRNzPjG&open=AZ0piJd-7ASJbBRNzPjG&pullRequest=9703
job->setParent(this);
job->setProperty(propertyFolder, QVariant::fromValue(folder));
job->setProperty(propertyPath, QVariant::fromValue(path));
Expand Down Expand Up @@ -746,7 +754,7 @@
if (const auto mode = bestAvailableVfsMode();
!Theme::instance()->disableVirtualFilesSyncFolder() &&
Theme::instance()->showVirtualFilesOption() && !folder->virtualFilesEnabled() && Vfs::checkAvailability(folder->path(), mode)) {
if (mode == Vfs::WindowsCfApi || ConfigFile().showExperimentalOptions()) {

Check warning on line 757 in src/gui/accountsettings.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=AZ0piJd-7ASJbBRNzPjH&open=AZ0piJd-7ASJbBRNzPjH&pullRequest=9703
ac = menu->addAction(tr("Enable virtual file support %1 …").arg(mode == Vfs::WindowsCfApi ? QString() : tr("(experimental)")));
// TODO: remove when UX decision is made
ac->setEnabled(!Utility::isPathWindowsDrivePartitionRoot(folder->path()));
Expand Down Expand Up @@ -1212,7 +1220,7 @@
widget.exec();
}

void AccountSettings::forgetEncryptionOnDeviceForAccount(const AccountPtr &account) const

Check warning on line 1223 in src/gui/accountsettings.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=AZ0piJd-7ASJbBRNzPjI&open=AZ0piJd-7ASJbBRNzPjI&pullRequest=9703
{
QMessageBox dialog;
dialog.setWindowTitle(tr("Forget the end-to-end encryption on this device"));
Expand Down Expand Up @@ -1378,7 +1386,7 @@
slotAccountStateChanged();
}

void AccountSettings::slotAccountStateChanged()

Check failure on line 1389 in src/gui/accountsettings.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor this function to reduce its Cognitive Complexity from 26 to the 25 allowed.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ0piJd-7ASJbBRNzPjJ&open=AZ0piJd-7ASJbBRNzPjJ&pullRequest=9703
{
const auto state = _accountState ? _accountState->state() : AccountState::Disconnected;
if (state != AccountState::Disconnected) {
Expand Down Expand Up @@ -1629,7 +1637,7 @@
}
}

void AccountSettings::slotE2eEncryptionCertificateNeedMigration()

Check warning on line 1640 in src/gui/accountsettings.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=AZ0piJd-7ASJbBRNzPjL&open=AZ0piJd-7ASJbBRNzPjL&pullRequest=9703
{
const auto actionMigrateCertificate = addActionToEncryptionMessage(tr("Migrate certificate to a new one"), e2EeUiActionMigrateCertificateId);
connect(actionMigrateCertificate, &QAction::triggered, this, [this] {
Expand Down Expand Up @@ -1816,9 +1824,9 @@

void AccountSettings::removeActionFromEncryptionMessage(const QString &actionId)
{
const auto foundEnableEncryptionActionIt = std::find_if(std::cbegin(_ui->encryptionMessage->actions()), std::cend(_ui->encryptionMessage->actions()), [&actionId](const QAction *action) {
return action->property(e2eUiActionIdKey).toString() == actionId;
});

Check warning on line 1829 in src/gui/accountsettings.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace with the version of "std::ranges::find_if" that takes a range.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ0piJd-7ASJbBRNzPjM&open=AZ0piJd-7ASJbBRNzPjM&pullRequest=9703
if (foundEnableEncryptionActionIt != std::cend(_ui->encryptionMessage->actions())) {
_ui->encryptionMessage->removeAction(*foundEnableEncryptionActionIt);
(*foundEnableEncryptionActionIt)->deleteLater();
Expand Down Expand Up @@ -1855,7 +1863,7 @@
setEncryptionMessageIcon(Theme::createColorAwareIcon(QStringLiteral(":/client/theme/info.svg")));
_ui->encryptionMessage->hide();

auto *const actionSetupE2e = addActionToEncryptionMessage(tr("Set up encryption"), e2EeUiActionSetupEncryptionId);

Check warning on line 1866 in src/gui/accountsettings.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make the type of this variable a pointer-to-const. The current type of "actionSetupE2e" is "class QAction *const".

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ0piJd-7ASJbBRNzPjN&open=AZ0piJd-7ASJbBRNzPjN&pullRequest=9703
connect(actionSetupE2e, &QAction::triggered, this, &AccountSettings::slotE2eEncryptionGenerateKeys);
}

Expand All @@ -1881,7 +1889,7 @@
_encryptionMessageButtons.clear();

const auto actions = _ui->encryptionMessage->actions();
auto *layout = _ui->encryptionMessageButtonsLayout;

Check warning on line 1892 in src/gui/accountsettings.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "layout" of type "class QHBoxLayout *" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ0piJd-7ASJbBRNzPjO&open=AZ0piJd-7ASJbBRNzPjO&pullRequest=9703
int stretchIndex = -1;
for (int i = 0; i < layout->count(); ++i) {
if (layout->itemAt(i)->spacerItem()) {
Expand All @@ -1894,8 +1902,8 @@
stretchIndex = layout->count() - 1;
}

for (QAction *action : actions) {

Check warning on line 1905 in src/gui/accountsettings.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "action" of type "class QAction *" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ0piJd-7ASJbBRNzPjP&open=AZ0piJd-7ASJbBRNzPjP&pullRequest=9703
auto *button = new QPushButton(_ui->encryptionMessage);

Check failure on line 1906 in src/gui/accountsettings.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=AZ0piJd-7ASJbBRNzPjR&open=AZ0piJd-7ASJbBRNzPjR&pullRequest=9703

Check warning on line 1906 in src/gui/accountsettings.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "button" of type "class QPushButton *" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ0piJd-7ASJbBRNzPjQ&open=AZ0piJd-7ASJbBRNzPjQ&pullRequest=9703
button->setText(action->text());
button->setIcon(action->icon());
button->setEnabled(action->isEnabled());
Expand Down
2 changes: 1 addition & 1 deletion src/gui/macOS/ui/FileProviderSettings.qml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Page {
title: qsTr("Virtual files settings")

background: Rectangle {
color: palette.alternateBase
color: palette.light
border.width: root.showBorder ? Style.normalBorderWidth : 0
border.color: palette.mid
}
Expand Down
17 changes: 13 additions & 4 deletions src/gui/networksettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@
#include <QPalette>
#include <type_traits>

constexpr auto BACKGROUND_ROLE =
#ifdef Q_OS_WIN
// "light" looks too bright on dark mode on Windows only
QPalette::AlternateBase;
#else
// ...and "alternate-base" looks too bright on macOS only. On Linux/Plasma either one looked fine ...
QPalette::Light;
#endif

namespace OCC {

NetworkSettings::NetworkSettings(const AccountPtr &account, QWidget *parent)
Expand All @@ -30,19 +39,19 @@
{
_ui->setupUi(this);
setAutoFillBackground(true);
setBackgroundRole(QPalette::AlternateBase);
setBackgroundRole(BACKGROUND_ROLE);
_ui->proxyGroupBox->setAutoFillBackground(true);
_ui->proxyGroupBox->setBackgroundRole(QPalette::AlternateBase);
_ui->proxyGroupBox->setBackgroundRole(BACKGROUND_ROLE);
_ui->downloadBox->setAutoFillBackground(true);
_ui->downloadBox->setBackgroundRole(QPalette::AlternateBase);
_ui->downloadBox->setBackgroundRole(BACKGROUND_ROLE);
_ui->uploadBox->setAutoFillBackground(true);
_ui->uploadBox->setBackgroundRole(QPalette::AlternateBase);
_ui->uploadBox->setBackgroundRole(BACKGROUND_ROLE);

_ui->manualSettings->setVisible(_ui->manualProxyRadioButton->isChecked());

_ui->proxyGroupBox->setVisible(!Theme::instance()->doNotUseProxy());

Check warning on line 52 in src/gui/networksettings.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=AZ0piJe37ASJbBRNzPjT&open=AZ0piJe37ASJbBRNzPjT&pullRequest=9703

if (!Theme::instance()->doNotUseProxy()) {

Check warning on line 54 in src/gui/networksettings.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=AZ0piJe37ASJbBRNzPjU&open=AZ0piJe37ASJbBRNzPjU&pullRequest=9703
_ui->hostLineEdit->setPlaceholderText(tr("Hostname of proxy server"));
_ui->userLineEdit->setPlaceholderText(tr("Username for proxy server"));
_ui->passwordLineEdit->setPlaceholderText(tr("Password for proxy server"));
Expand Down Expand Up @@ -195,7 +204,7 @@
if (_account) { // We must be setting up network proxy for a specific account
_account->setProxySettings(proxyType, host, port, needsAuth, user, password);
const auto accountState = AccountManager::instance()->accountFromUserId(_account->userIdAtHostWithPort());
if (accountState) {

Check warning on line 207 in src/gui/networksettings.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

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

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ0piJe37ASJbBRNzPjV&open=AZ0piJe37ASJbBRNzPjV&pullRequest=9703
accountState->freshConnectionAttempt();
}
AccountManager::instance()->saveAccount(_account);
Expand Down
12 changes: 10 additions & 2 deletions src/gui/settingsdialog.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/*
* SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2013 ownCloud GmbH
Expand Down Expand Up @@ -42,6 +42,14 @@

using namespace Qt::StringLiterals;

#ifdef Q_OS_WIN
// "light" looks too bright on dark mode on Windows only
#define BACKGROUND_PALETTE "alternate-base"
#else
// ...and "alternate-base" looks too bright on macOS only. On Linux/Plasma either one looked fine ...
#define BACKGROUND_PALETTE "light"

Check warning on line 50 in src/gui/settingsdialog.cpp

View workflow job for this annotation

GitHub Actions / build

src/gui/settingsdialog.cpp:50:13 [cppcoreguidelines-macro-usage]

macro 'BACKGROUND_PALETTE' used to declare a constant; consider using a 'constexpr' constant

Check failure on line 50 in src/gui/settingsdialog.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this macro by "const", "constexpr" or an "enum".

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ0piJWi7ASJbBRNzPib&open=AZ0piJWi7ASJbBRNzPib&pullRequest=9703
#endif

namespace {
class CurrentPageSizeStackedWidget : public QStackedWidget
{
Expand All @@ -50,7 +58,7 @@

[[nodiscard]] QSize sizeHint() const override
{
if (const auto *widget = currentWidget()) {

Check warning on line 61 in src/gui/settingsdialog.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

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

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ0piJWi7ASJbBRNzPif&open=AZ0piJWi7ASJbBRNzPif&pullRequest=9703
return widget->sizeHint();
}
return QStackedWidget::sizeHint();
Expand All @@ -58,7 +66,7 @@

[[nodiscard]] QSize minimumSizeHint() const override
{
if (const auto *widget = currentWidget()) {

Check warning on line 69 in src/gui/settingsdialog.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

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

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ0piJWi7ASJbBRNzPig&open=AZ0piJWi7ASJbBRNzPig&pullRequest=9703
return widget->minimumSizeHint();
}
return QStackedWidget::minimumSizeHint();
Expand All @@ -66,15 +74,15 @@

[[nodiscard]] bool hasHeightForWidth() const override
{
if (const auto *widget = currentWidget()) {

Check warning on line 77 in src/gui/settingsdialog.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

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

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ0piJWi7ASJbBRNzPih&open=AZ0piJWi7ASJbBRNzPih&pullRequest=9703
return widget->hasHeightForWidth();
}
return QStackedWidget::hasHeightForWidth();
}

[[nodiscard]] int heightForWidth(int width) const override

Check warning on line 83 in src/gui/settingsdialog.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "width" of type "int" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ0piJWi7ASJbBRNzPii&open=AZ0piJWi7ASJbBRNzPii&pullRequest=9703
{
if (const auto *widget = currentWidget()) {

Check warning on line 85 in src/gui/settingsdialog.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

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

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ0piJWi7ASJbBRNzPij&open=AZ0piJWi7ASJbBRNzPij&pullRequest=9703
return widget->hasHeightForWidth() ? widget->heightForWidth(width) : widget->sizeHint().height();
}
return QStackedWidget::heightForWidth(width);
Expand All @@ -89,7 +97,7 @@
"QToolBar QToolButton:checked { background: palette(highlight); color: palette(highlighted-text); }"
);

const float buttonSizeRatio = 1.618f; // golden ratio

Check warning on line 100 in src/gui/settingsdialog.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace constant with "std::numbers::phi_v<float>".

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


/** display name with two lines that is displayed in the settings
Expand Down Expand Up @@ -123,10 +131,10 @@
using QWidget::QWidget;

protected:
void mousePressEvent(QMouseEvent *event) override

Check warning on line 134 in src/gui/settingsdialog.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "event" of type "class QMouseEvent *" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ0piJWi7ASJbBRNzPil&open=AZ0piJWi7ASJbBRNzPil&pullRequest=9703
{
if (event->button() == Qt::LeftButton) {
if (const auto *window = this->window(); window && window->windowHandle()) {

Check warning on line 137 in src/gui/settingsdialog.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

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

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ0piJWi7ASJbBRNzPim&open=AZ0piJWi7ASJbBRNzPim&pullRequest=9703
window->windowHandle()->startSystemMove();
event->accept();
return;
Expand Down Expand Up @@ -174,7 +182,7 @@
QAction *generalAction = createColorAwareAction(QLatin1String(":/client/theme/settings.svg"), tr("General"));
_actionGroup->addAction(generalAction);
_toolBar->addAction(generalAction);
auto *accountSpacer = new QWidget(this);

Check warning on line 185 in src/gui/settingsdialog.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

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

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

Check failure on line 185 in src/gui/settingsdialog.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=AZ0piJWi7ASJbBRNzPio&open=AZ0piJWi7ASJbBRNzPio&pullRequest=9703
accountSpacer->setFixedHeight(16);
_toolBar->addWidget(accountSpacer);
_toolBar->addSeparator();
Expand Down Expand Up @@ -219,7 +227,7 @@
cfg.restoreGeometry(this);
}

SettingsDialog::~SettingsDialog()

Check failure on line 230 in src/gui/settingsdialog.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use "=default" instead of the default implementation of this special member functions.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ0piJWi7ASJbBRNzPip&open=AZ0piJWi7ASJbBRNzPip&pullRequest=9703
{
}

Expand All @@ -229,7 +237,7 @@
}

// close event is not being called here
void SettingsDialog::resizeEvent(QResizeEvent *event)

Check warning on line 240 in src/gui/settingsdialog.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this method "resizeEvent" to simply inherit it.

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

Check warning on line 240 in src/gui/settingsdialog.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "event" of type "class QResizeEvent *" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ0piJWi7ASJbBRNzPir&open=AZ0piJWi7ASJbBRNzPir&pullRequest=9703
{
QDialog::resizeEvent(event);

Expand Down Expand Up @@ -281,7 +289,7 @@
{
_stack->setCurrentWidget(_actionGroupWidgets.value(action));
_stack->updateGeometry();
if (auto *contentContainer = _stack->parentWidget()) {

Check warning on line 292 in src/gui/settingsdialog.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

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

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ0piJWi7ASJbBRNzPis&open=AZ0piJWi7ASJbBRNzPis&pullRequest=9703
contentContainer->updateGeometry();
}
}
Expand Down Expand Up @@ -350,14 +358,14 @@

void SettingsDialog::slotAccountAvatarChanged()
{
auto *account = dynamic_cast<Account *>(sender());

Check warning on line 361 in src/gui/settingsdialog.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make the type of this variable a pointer-to-const. The current type of "account" is "class OCC::Account *".

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ0piJWi7ASJbBRNzPit&open=AZ0piJWi7ASJbBRNzPit&pullRequest=9703
if (!account) {
return;
}
updateAccountAvatar(account);
}

void SettingsDialog::updateAccountAvatar(const Account *account)

Check warning on line 368 in src/gui/settingsdialog.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "account" of type "const class OCC::Account *" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ0piJWi7ASJbBRNzPiu&open=AZ0piJWi7ASJbBRNzPiu&pullRequest=9703
{
if (!account || !_actionForAccount.contains(account)) {
return;
Expand Down Expand Up @@ -427,22 +435,22 @@
return;
}

const QScopedValueRollback<bool> updatingStyle(_updatingStyle, true);

Check warning on line 438 in src/gui/settingsdialog.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Avoid explicitly specifying the template arguments by relying on the class template argument deduction.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ0piJWi7ASJbBRNzPiv&open=AZ0piJWi7ASJbBRNzPiv&pullRequest=9703
_toolBar->setStyleSheet(TOOLBAR_CSS);

setStyleSheet(QStringLiteral(
"#Settings { background: palette(window); border-radius: 0; }"

/* Navigation */

Check warning on line 444 in src/gui/settingsdialog.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=AZ0piJWi7ASJbBRNzPic&open=AZ0piJWi7ASJbBRNzPic&pullRequest=9703
"#settings_navigation, #settings_navigation_scroll { background: palette(alternate-base); border-radius: 12px; padding: 4px; }"
"#settings_navigation, #settings_navigation_scroll { background: palette(" BACKGROUND_PALETTE "); border-radius: 12px; padding: 4px; }"

/* Content area */

Check warning on line 447 in src/gui/settingsdialog.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=AZ0piJWi7ASJbBRNzPid&open=AZ0piJWi7ASJbBRNzPid&pullRequest=9703
"#settings_content, #settings_content_scroll { background: palette(window); border-radius: 12px; }"

/* Panels */
"#generalGroupBox, #advancedGroupBox, #aboutAndUpdatesGroupBox,"
"#accountStatusPanel, #connectionSettingsPanel, #fileProviderPanel, #syncFoldersPanel {"
" background: palette(alternate-base);"
" background: palette(" BACKGROUND_PALETTE ");"
" border-radius: 10px;"
" margin: 0px;"
" padding: 6px;"
Expand Down Expand Up @@ -515,7 +523,7 @@
setWindowTitle(tr("Settings"));
setGeometry(0, 0, 950, 500);

auto *mainLayout = new QHBoxLayout(this);

Check failure on line 526 in src/gui/settingsdialog.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=AZ0piJWi7ASJbBRNzPix&open=AZ0piJWi7ASJbBRNzPix&pullRequest=9703
mainLayout->setContentsMargins(12, 12, 12, 12);
mainLayout->setSpacing(12);
setLayout(mainLayout);
Expand All @@ -528,17 +536,17 @@
_toolBar->setMinimumWidth(220);
_toolBar->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum);

auto *navigationContainer = new QWidget(this);

Check warning on line 539 in src/gui/settingsdialog.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

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

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ0piJWi7ASJbBRNzPiy&open=AZ0piJWi7ASJbBRNzPiy&pullRequest=9703
navigationContainer->setObjectName("settings_navigation"_L1);
navigationContainer->setAttribute(Qt::WA_StyledBackground);

auto *navigationLayout = new QVBoxLayout(navigationContainer);

Check warning on line 543 in src/gui/settingsdialog.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "navigationLayout" of type "class QVBoxLayout *" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ0piJWi7ASJbBRNzPi0&open=AZ0piJWi7ASJbBRNzPi0&pullRequest=9703
navigationLayout->setContentsMargins(0, 0, 0, 0);
navigationLayout->setSpacing(0);
navigationLayout->addWidget(_toolBar);
navigationLayout->addStretch(1);

auto *navigationScroll = new QScrollArea(this);

Check warning on line 549 in src/gui/settingsdialog.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "navigationScroll" of type "class QScrollArea *" should be const-qualified.

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

Check failure on line 549 in src/gui/settingsdialog.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=AZ0piJWi7ASJbBRNzPi3&open=AZ0piJWi7ASJbBRNzPi3&pullRequest=9703
navigationScroll->setObjectName("settings_navigation_scroll"_L1);
navigationScroll->setWidgetResizable(true);
navigationScroll->setAlignment(Qt::AlignTop | Qt::AlignLeft);
Expand All @@ -548,10 +556,10 @@
navigationScroll->viewport()->setAutoFillBackground(false);
navigationScroll->setWidget(navigationContainer);

_stack = new CurrentPageSizeStackedWidget(this);

Check failure on line 559 in src/gui/settingsdialog.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=AZ0piJWi7ASJbBRNzPi4&open=AZ0piJWi7ASJbBRNzPi4&pullRequest=9703
_stack->setObjectName(u"settings_content"_s);

auto *contentScroll = new QScrollArea(this);

Check failure on line 562 in src/gui/settingsdialog.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=AZ0piJWi7ASJbBRNzPi6&open=AZ0piJWi7ASJbBRNzPi6&pullRequest=9703
contentScroll->setObjectName("settings_content_scroll"_L1);
contentScroll->setWidgetResizable(true);
contentScroll->setAlignment(Qt::AlignTop | Qt::AlignLeft);
Expand Down
Loading