Skip to content
Draft
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
10 changes: 10 additions & 0 deletions src/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ configure_file(${CMAKE_SOURCE_DIR}/theme.qrc.in ${CMAKE_SOURCE_DIR}/theme.qrc)
set(theme_dir ${CMAKE_SOURCE_DIR}/theme)

set(client_UI_SRCS
advancedsettings.ui
accountsettings.ui
conflictdialog.ui
invalidfilenamedialog.ui
Expand All @@ -32,6 +33,7 @@ set(client_UI_SRCS
folderwizardsourcepage.ui
folderwizardtargetpage.ui
generalsettings.ui
infosettings.ui
legalnotice.ui
ignorelisteditor.ui
ignorelisttablewidget.ui
Expand All @@ -58,6 +60,8 @@ qt_add_resources(client_UI_SRCS ../../resources.qrc ${CMAKE_SOURCE_DIR}/theme.qr
set(client_SRCS
accountmanager.h
accountmanager.cpp
advancedsettings.h
advancedsettings.cpp
accountsettings.h
accountsettings.cpp
accountsetupfromcommandlinejob.h
Expand Down Expand Up @@ -104,6 +108,8 @@ set(client_SRCS
folderwizard.cpp
generalsettings.h
generalsettings.cpp
infosettings.h
infosettings.cpp
legalnotice.h
legalnotice.cpp
ignorelisteditor.h
Expand Down Expand Up @@ -136,6 +142,10 @@ set(client_SRCS
selectivesyncdialog.cpp
settingsdialog.h
settingsdialog.cpp
settingspanelstyle.h
settingspanelstyle.cpp
settingsswitch.h
settingsswitch.cpp
sharemanager.h
sharemanager.cpp
profilepagewidget.h
Expand Down
77 changes: 63 additions & 14 deletions src/gui/accountsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include <cmath>

#include <QDesktopServices>
#include <QDialog>
#include <QDialogButtonBox>
#include <QDir>
#include <QListWidgetItem>
Expand All @@ -57,6 +58,7 @@
#include <QPushButton>
#include <QStyle>
#include <QFileDialog>
#include <QFrame>

using namespace Qt::StringLiterals;

Expand Down Expand Up @@ -177,6 +179,31 @@
{
_ui->setupUi(this);

_encryptionPanel = new QFrame(this);
_encryptionPanel->setObjectName(QLatin1String("encryptionPanel"));
_encryptionPanel->setFrameShape(QFrame::NoFrame);
_encryptionPanel->setAttribute(Qt::WA_StyledBackground, true);
auto *encryptionPanelLayout = new QVBoxLayout(_encryptionPanel);

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

View workflow job for this annotation

GitHub Actions / build

src/gui/accountsettings.cpp:186:11 [cppcoreguidelines-init-variables]

variable 'encryptionPanelLayout' is not initialized
encryptionPanelLayout->setContentsMargins(0, 0, 0, 0);
encryptionPanelLayout->setSpacing(0);
_ui->accountStatusLayout->removeWidget(_ui->encryptionMessage);
encryptionPanelLayout->addWidget(_ui->encryptionMessage);

auto *connectionSettingsButton = new QPushButton(tr("Connection settings"), _ui->accountStatus);

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

View workflow job for this annotation

GitHub Actions / build

src/gui/accountsettings.cpp:192:11 [cppcoreguidelines-init-variables]

variable 'connectionSettingsButton' is not initialized
connectionSettingsButton->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed);
_ui->gridLayout_2->addWidget(connectionSettingsButton, 0, 2, Qt::AlignRight | Qt::AlignVCenter);
connect(connectionSettingsButton, &QPushButton::clicked, this, &AccountSettings::showConnectionSettingsDialog);

_ui->verticalLayout_2->removeWidget(_ui->accountStatusPanel);
_ui->verticalLayout_2->removeWidget(_ui->fileProviderPanel);
_ui->verticalLayout_2->removeWidget(_ui->syncFoldersPanel);
_ui->verticalLayout_2->removeWidget(_ui->connectionSettingsPanel);
_ui->connectionSettingsPanel->hide();
_ui->verticalLayout_2->insertWidget(0, _ui->fileProviderPanel);
_ui->verticalLayout_2->insertWidget(1, _ui->syncFoldersPanel);
_ui->verticalLayout_2->insertWidget(2, _encryptionPanel);
_ui->verticalLayout_2->insertWidget(3, _ui->accountStatusPanel);

_model->setAccountState(_accountState);
_model->setParent(this);
const auto delegate = new FolderStatusDelegate;
Expand Down Expand Up @@ -233,17 +260,6 @@
_ui->fileProviderPanel->setVisible(false);
#endif

const auto connectionSettingsPanelContents = _ui->connectionSettingsPanelContents;
const auto connectionSettingsLayout = new QVBoxLayout(connectionSettingsPanelContents);
const auto networkSettings = new NetworkSettings(_accountState->account(), connectionSettingsPanelContents);
if (const auto networkSettingsLayout = networkSettings->layout()) {
networkSettingsLayout->setContentsMargins(0, 0, 0, 0);
}
connectionSettingsLayout->setContentsMargins(0, 0, 0, 0);
connectionSettingsLayout->setSpacing(0);
connectionSettingsLayout->addWidget(networkSettings, 1);
connectionSettingsPanelContents->setLayout(connectionSettingsLayout);

const auto mouseCursorChanger = new MouseCursorChanger(this);
mouseCursorChanger->folderList = _ui->_folderList;
mouseCursorChanger->model = _model;
Expand Down Expand Up @@ -310,6 +326,7 @@
_ui->encryptionMessageLabel->setOpenExternalLinks(true);
_ui->encryptionMessageButtonsLayout->addStretch();
setEncryptionMessageIcon({});
setEncryptionPanelVisible(_ui->encryptionMessage->isVisible());

_ui->connectLabel->setText(tr("No account configured."));

Expand Down Expand Up @@ -347,7 +364,7 @@

_ui->encryptionMessageLabel->setText(tr("Encryption is set-up. Remember to <b>Encrypt</b> a folder to end-to-end encrypt any new files added to it."));
setEncryptionMessageIcon(Theme::createColorAwareIcon(QStringLiteral(":/client/theme/lock.svg")));
_ui->encryptionMessage->show();
setEncryptionPanelVisible(true);
}

void AccountSettings::slotE2eEncryptionGenerateKeys()
Expand Down Expand Up @@ -481,7 +498,7 @@
Q_ASSERT(folder);

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

Check warning on line 501 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=AZ4mqr7A-Svkp3hBDNHW&open=AZ4mqr7A-Svkp3hBDNHW&pullRequest=10031
const auto fileId = folderInfo->_fileId;
const auto encryptFolder = [this, fileId, path, folderAlias] {
const auto folder = FolderMan::instance()->folder(folderAlias);
Expand Down Expand Up @@ -752,7 +769,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 772 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=AZ4mqr7A-Svkp3hBDNHZ&open=AZ4mqr7A-Svkp3hBDNHZ&pullRequest=10031
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 @@ -1218,7 +1235,7 @@
widget.exec();
}

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

Check warning on line 1238 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=AZ4mqr7A-Svkp3hBDNHa&open=AZ4mqr7A-Svkp3hBDNHa&pullRequest=10031
{
QMessageBox dialog;
dialog.setWindowTitle(tr("Forget the end-to-end encryption on this device"));
Expand Down Expand Up @@ -1278,6 +1295,30 @@
_ui->accountStatus->setVisible(!message.isEmpty());
}

void AccountSettings::showConnectionSettingsDialog()

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

View workflow job for this annotation

GitHub Actions / build

src/gui/accountsettings.cpp:1298:23 [readability-convert-member-functions-to-static]

method 'showConnectionSettingsDialog' can be made static
{
auto *dialog = new QDialog(this);

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

View workflow job for this annotation

GitHub Actions / build

src/gui/accountsettings.cpp:1300:11 [cppcoreguidelines-init-variables]

variable 'dialog' is not initialized
dialog->setAttribute(Qt::WA_DeleteOnClose);
dialog->setWindowTitle(tr("Connection settings"));

auto *layout = new QVBoxLayout(dialog);

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

View workflow job for this annotation

GitHub Actions / build

src/gui/accountsettings.cpp:1304:11 [cppcoreguidelines-init-variables]

variable 'layout' is not initialized

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

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

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

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ4mqr7A-Svkp3hBDNHc&open=AZ4mqr7A-Svkp3hBDNHc&pullRequest=10031
layout->setContentsMargins(12, 12, 12, 12);
layout->setSpacing(12);

auto *networkSettings = new NetworkSettings(_accountState->account(), dialog);

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

View workflow job for this annotation

GitHub Actions / build

src/gui/accountsettings.cpp:1308:11 [cppcoreguidelines-init-variables]

variable 'networkSettings' is not initialized
if (auto *networkSettingsLayout = networkSettings->layout()) {
networkSettingsLayout->setContentsMargins(0, 0, 0, 0);
}
layout->addWidget(networkSettings);

auto *buttonBox = new QDialogButtonBox(QDialogButtonBox::Close, dialog);

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

View workflow job for this annotation

GitHub Actions / build

src/gui/accountsettings.cpp:1314:11 [cppcoreguidelines-init-variables]

variable 'buttonBox' is not initialized
connect(buttonBox, &QDialogButtonBox::rejected, dialog, &QDialog::reject);
layout->addWidget(buttonBox);

dialog->resize(networkSettings->sizeHint());
dialog->open();
}

void AccountSettings::slotEnableCurrentFolder(bool terminate)
{
const auto alias = selectedFolderAlias();
Expand Down Expand Up @@ -1496,7 +1537,7 @@
<< "Client Side Encryption" << accountsState()->account()->capabilities().clientSideEncryptionAvailable();

if (_accountState->account()->capabilities().clientSideEncryptionAvailable()) {
_ui->encryptionMessage->show();
setEncryptionPanelVisible(true);
}
}

Expand All @@ -1507,7 +1548,7 @@
const auto li = link.split(QLatin1String("?folder="));
if (li.count() > 1) {
auto myFolder = li[0];
const auto alias = li[1];

Check warning on line 1551 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=AZ4mqr7A-Svkp3hBDNHh&open=AZ4mqr7A-Svkp3hBDNHh&pullRequest=10031
if (myFolder.endsWith(QLatin1Char('/'))) {
myFolder.chop(1);
}
Expand Down Expand Up @@ -1859,12 +1900,20 @@
#endif
_ui->encryptionMessageLabel->setText(encryptionMessage);
setEncryptionMessageIcon(Theme::createColorAwareIcon(QStringLiteral(":/client/theme/info.svg")));
_ui->encryptionMessage->hide();
setEncryptionPanelVisible(false);

auto *const actionSetupE2e = addActionToEncryptionMessage(tr("Set up encryption"), e2EeUiActionSetupEncryptionId);
connect(actionSetupE2e, &QAction::triggered, this, &AccountSettings::slotE2eEncryptionGenerateKeys);
}

void AccountSettings::setEncryptionPanelVisible(bool visible)
{
_ui->encryptionMessage->setVisible(visible);
if (_encryptionPanel) {

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

View workflow job for this annotation

GitHub Actions / build

src/gui/accountsettings.cpp:1912:9 [readability-implicit-bool-conversion]

implicit conversion 'QFrame *' -> bool
_encryptionPanel->setVisible(visible);
}
}

void AccountSettings::setEncryptionMessageIcon(const QIcon &icon)
{
if (icon.isNull()) {
Expand Down Expand Up @@ -1901,7 +1950,7 @@
}

for (QAction *action : actions) {
auto *button = new QPushButton(_ui->encryptionMessage);

Check warning on line 1953 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=AZ4mqr7A-Svkp3hBDNHo&open=AZ4mqr7A-Svkp3hBDNHo&pullRequest=10031
button->setText(action->text());
button->setIcon(action->icon());
button->setEnabled(action->isEnabled());
Expand Down
4 changes: 4 additions & 0 deletions src/gui/accountsettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#ifndef ACCOUNTSETTINGS_H
#define ACCOUNTSETTINGS_H

#include <QWidget>

Check failure on line 10 in src/gui/accountsettings.h

View workflow job for this annotation

GitHub Actions / build

src/gui/accountsettings.h:10:10 [clang-diagnostic-error]

'QWidget' file not found
#include <QUrl>
#include <QPointer>
#include <QHash>
Expand All @@ -29,6 +29,7 @@
class QLabel;
class QPushButton;
class QIcon;
class QFrame;

Check warning on line 32 in src/gui/accountsettings.h

View workflow job for this annotation

GitHub Actions / build

src/gui/accountsettings.h:32:7 [cppcoreguidelines-avoid-non-const-global-variables]

variable 'QFrame' is non-const and globally accessible, consider making it const

namespace OCC {

Expand Down Expand Up @@ -119,7 +120,7 @@
const QVector<int> &roles);
void slotPossiblyUnblacklistE2EeFoldersAndRestartSync();

void slotE2eEncryptionCertificateNeedMigration();

Check warning on line 123 in src/gui/accountsettings.h

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=AZ4mqr0c-Svkp3hBDNHM&open=AZ4mqr0c-Svkp3hBDNHM&pullRequest=10031

private slots:
void updateBlackListAndScheduleFolderSync(const QStringList &blackList, OCC::Folder *folder, const QStringList &foldersToRemoveFromBlacklist) const;
Expand All @@ -127,16 +128,18 @@

private slots:
void displayMnemonic(const QString &mnemonic);
void forgetEncryptionOnDeviceForAccount(const OCC::AccountPtr &account) const;

Check warning on line 131 in src/gui/accountsettings.h

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=AZ4mqr0c-Svkp3hBDNHN&open=AZ4mqr0c-Svkp3hBDNHN&pullRequest=10031
void migrateCertificateForAccount(const OCC::AccountPtr &account);
void showConnectionLabel(const QString &message, QStringList errors = QStringList());
void showConnectionSettingsDialog();
void openIgnoredFilesDialog(const QString & absFolderPath);
void customizeStyle();

void setupE2eEncryption();
void forgetE2eEncryption();
void checkClientSideEncryptionState();
void removeActionFromEncryptionMessage(const QString &actionId);
void setEncryptionPanelVisible(bool visible);

private:
bool event(QEvent *) override;
Expand All @@ -160,6 +163,7 @@
QAction *_addAccountAction = nullptr;

bool _menuShown = false;
QFrame *_encryptionPanel = nullptr;

QHash<QString, QMetaObject::Connection> _folderConnections;
QHash<QAction *, QPushButton *> _encryptionMessageButtons;
Expand Down
Loading
Loading