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

#NMC customization: needed to find the ui file in a different location than the header file
set(CMAKE_AUTOUIC_SEARCH_PATHS "${CMAKE_SOURCE_DIR}/src/gui")

set(client_UI_SRCS
accountsettings.ui
conflictdialog.ui
Expand Down Expand Up @@ -259,6 +262,10 @@ set(client_SRCS
integration/fileactionsmodel.cpp
)

file(GLOB NMC_FILES "nmcgui/*")
set(NMC_SRCS ${NMC_FILES})
list(APPEND client_SRCS ${NMC_SRCS})

if (NOT DISABLE_ACCOUNT_MIGRATION)
list(APPEND client_SRCS
legacyaccountselectiondialog.h
Expand Down
9 changes: 7 additions & 2 deletions src/gui/accountsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1277,7 +1277,6 @@ void AccountSettings::showConnectionLabel(const QString &message, QStringList er
_ui->connectLabel->setToolTip({});
_ui->connectLabel->setStyleSheet(errStyle);
}
_ui->accountStatus->setVisible(!message.isEmpty());
}

void AccountSettings::slotEnableCurrentFolder(bool terminate)
Expand Down Expand Up @@ -1372,7 +1371,12 @@ void AccountSettings::slotUpdateQuota(qint64 total, qint64 used)
if (total > 0) {
const auto usedStr = Utility::octetsToString(used);
const auto totalStr = Utility::octetsToString(total);
_spaceUsageText = tr("%1 of %2 in use").arg(usedStr, totalStr);
const auto percentStr = Utility::compactFormatDouble(percent, 1);
const auto toolTip = tr("%1 (%3%) of %2 in use. Some folders, including network mounted or shared folders, might have different limits.").arg(usedStr, totalStr, percentStr);
_ui->quotaInfoLabel->setText(QCoreApplication::translate("", "%1_OF_%2").arg(usedStr, totalStr));
_ui->quotaInfoLabel->setToolTip(toolTip);
_ui->quotaProgressBar->setToolTip(toolTip);
_ui->quotaInfoText->setText(QCoreApplication::translate("", "USED_STORAGE_%1").arg(percentStr));
} else {
/* -1 means not computed; -2 means unknown; -3 means unlimited (#owncloud/client/issues/3940)*/
if (total == 0 || total == -1) {
Expand All @@ -1381,6 +1385,7 @@ void AccountSettings::slotUpdateQuota(qint64 total, qint64 used)
const auto usedStr = Utility::octetsToString(used);
_spaceUsageText = tr("%1 in use").arg(usedStr);
}
_ui->quotaInfoText->setText(QCoreApplication::translate("", "USED_STORAGE_%1").arg(QString::number(0)));
}

slotAccountStateChanged();
Expand Down
8 changes: 7 additions & 1 deletion src/gui/accountsettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ protected slots:
const QVector<int> &roles);
void slotPossiblyUnblacklistE2EeFoldersAndRestartSync();

void checkClientSideEncryptionState();
void slotE2eEncryptionCertificateNeedMigration();

private slots:
Expand All @@ -135,9 +136,14 @@ private slots:

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

protected:
Ui::AccountSettings *getUi() const
{
return _ui;
}

private:
bool event(QEvent *) override;
QAction *addActionToEncryptionMessage(const QString &actionTitle, const QString &actionId);
Expand Down
147 changes: 147 additions & 0 deletions src/gui/nmcgui/nmcaccountsettings.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
/*
* Copyright (C) by Eugen Fischer
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/

#include "nmcgui/nmcaccountsettings.h"
#include "ui_accountsettings.h"
#include "../common/utility.h"
#include "guiutility.h"

#include <QDesktopServices>
#include <QUrl>
#include <QPushButton>
#include <QLabel>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QSpacerItem>
#include <QSizePolicy>

namespace OCC {

NMCAccountSettings::NMCAccountSettings(AccountState *accountState, QWidget *parent)
: AccountSettings(accountState, parent)
, m_liveAccountButton(new CustomButton(QCoreApplication::translate("", "ADD_LIVE_BACKUP"), QIcon(QLatin1String(":/client/theme/NMCIcons/action-add.svg")).pixmap(24,24)))

Check failure on line 33 in src/gui/nmcgui/nmcaccountsettings.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=nextmcloud_desktop&issues=AZ3UYxInXqq687UlPYmk&open=AZ3UYxInXqq687UlPYmk&pullRequest=390
, m_liveTitle(new QLabel(QCoreApplication::translate("", "LIVE_BACKUPS")))

Check failure on line 34 in src/gui/nmcgui/nmcaccountsettings.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=nextmcloud_desktop&issues=AZ3UYxInXqq687UlPYml&open=AZ3UYxInXqq687UlPYml&pullRequest=390
, m_liveDescription(new QLabel(QCoreApplication::translate("", "LIVE_DESCRIPTION")))

Check failure on line 35 in src/gui/nmcgui/nmcaccountsettings.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=nextmcloud_desktop&issues=AZ3UYxInXqq687UlPYmm&open=AZ3UYxInXqq687UlPYmm&pullRequest=390
, m_folderSync(new QLabel(QCoreApplication::translate("", "YOUR_FOLDER_SYNC")))

Check failure on line 36 in src/gui/nmcgui/nmcaccountsettings.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=nextmcloud_desktop&issues=AZ3UYxInXqq687UlPYmn&open=AZ3UYxInXqq687UlPYmn&pullRequest=390
{
setDefaultSettings();
setLayout();
connect(m_liveAccountButton, &CustomButton::clicked, this, &NMCAccountSettings::slotAddFolder);
}

void NMCAccountSettings::setDefaultSettings()
{
getUi()->encryptionMessage->setCloseButtonVisible(true);
getUi()->selectiveSyncStatus->setVisible(false);
getUi()->selectiveSyncNotification->setVisible(false);
getUi()->accountStatus->setVisible(false);
getUi()->bigFolderUi->setVisible(false);
getUi()->gridLayout->setSpacing(8);
}

void NMCAccountSettings::setLayout()
{
// Entferne alte Quota-Widgets
getUi()->storageGroupBox->removeWidget(getUi()->quotaInfoLabel);
getUi()->storageGroupBox->removeWidget(getUi()->quotaProgressBar);
getUi()->storageGroupBox->removeWidget(getUi()->quotaInfoText);

getUi()->gridLayout->removeWidget(getUi()->encryptionMessage);
getUi()->gridLayout->addWidget(getUi()->encryptionMessage, 0, 0);

// Titel für Folder Sync
m_folderSync->setStyleSheet("font-size: 15px; font-weight: 600; padding: 8px;");
m_folderSync->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
getUi()->gridLayout->addWidget(m_folderSync, 1, 0);

// Live-Backup-Bereich
auto *liveHLayout = new QHBoxLayout();

Check failure on line 69 in src/gui/nmcgui/nmcaccountsettings.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=nextmcloud_desktop&issues=AZ3UYxInXqq687UlPYmp&open=AZ3UYxInXqq687UlPYmp&pullRequest=390
liveHLayout->setContentsMargins(8, 8, 8, 8);

auto *liveVLayout = new QVBoxLayout();

Check failure on line 72 in src/gui/nmcgui/nmcaccountsettings.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=nextmcloud_desktop&issues=AZ3UYxInXqq687UlPYmq&open=AZ3UYxInXqq687UlPYmq&pullRequest=390
auto *liveWidget = new QWidget(this);
liveWidget->setStyleSheet("QWidget {border-radius: 4px;}");
liveWidget->setLayout(liveHLayout);

liveHLayout->addLayout(liveVLayout);
liveHLayout->addStretch();

const QString styleSheet = QStringLiteral(

Check warning on line 80 in src/gui/nmcgui/nmcaccountsettings.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=nextmcloud_desktop&issues=AZ3UYxInXqq687UlPYmo&open=AZ3UYxInXqq687UlPYmo&pullRequest=390
"QPushButton { font-size: %5px; border: %1px solid; border-color: black; "
"border-radius: 4px; background-color: %2; color: %3; } "
"QPushButton:hover { background-color: %4; }");

m_liveAccountButton->setStyleSheet(styleSheet.arg("0", "#E20074", "white", "#c00063", "13"));
m_liveAccountButton->setFixedSize(180, 32);
m_liveAccountButton->setLeftIconMargin(4);

liveHLayout->addWidget(m_liveAccountButton);

liveVLayout->addWidget(m_liveTitle);
m_liveTitle->setStyleSheet("font-size: 15px; font-weight: 600;");

liveVLayout->addWidget(m_liveDescription);
m_liveDescription->setStyleSheet("font-size: 13px;");
m_liveDescription->setText(QCoreApplication::translate("", "LIVE_BACKUPS_DESCRIPTION"));
m_liveDescription->setWordWrap(true);
m_liveDescription->setFixedWidth(450);

getUi()->gridLayout->addWidget(liveWidget, 4, 0);

// Speicherbereich
auto *magentaHLayout = new QHBoxLayout();

Check failure on line 103 in src/gui/nmcgui/nmcaccountsettings.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=nextmcloud_desktop&issues=AZ3UYxInXqq687UlPYmr&open=AZ3UYxInXqq687UlPYmr&pullRequest=390
magentaHLayout->setSpacing(32);

auto *quotaVLayout = new QVBoxLayout();

Check failure on line 106 in src/gui/nmcgui/nmcaccountsettings.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=nextmcloud_desktop&issues=AZ3UYxInXqq687UlPYms&open=AZ3UYxInXqq687UlPYms&pullRequest=390
quotaVLayout->setSpacing(4);
quotaVLayout->addSpacing(12);

quotaVLayout->addWidget(getUi()->quotaInfoLabel);
getUi()->quotaInfoLabel->setStyleSheet("QLabel { font-size: 18px; padding: 8px; font-weight: 500; }");

quotaVLayout->addWidget(getUi()->quotaProgressBar);
getUi()->quotaProgressBar->setStyleSheet(
"QProgressBar { background-color: #e5e5e5; color: black; border: 1px solid black; border-radius: 4px; margin-left: 8px; } "
"QProgressBar::chunk { background-color: #E20074; }");
getUi()->quotaProgressBar->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);

quotaVLayout->addWidget(getUi()->quotaInfoText);
getUi()->quotaInfoText->setStyleSheet("QLabel { font-size: 13px; padding: 8px; }");

quotaVLayout->addSpacing(20);
magentaHLayout->addLayout(quotaVLayout);

auto *storageLinkButton = new QPushButton(QCoreApplication::translate("", "STORAGE_EXTENSION"), this);
storageLinkButton->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
storageLinkButton->setStyleSheet(
"QPushButton { height: 32px; width: 180px; border: 1px solid black; background-color: #ededed; "
"color: black; font-size: 13px; border-radius: 4px; } "
"QPushButton::hover { background-color: white; }");

connect(storageLinkButton, &QPushButton::clicked, this, []() {
QDesktopServices::openUrl(QUrl(QStringLiteral("https://cloud.telekom-dienste.de/tarife")));
});

magentaHLayout->addWidget(storageLinkButton);
magentaHLayout->addSpacing(8);

getUi()->gridLayout->addLayout(magentaHLayout, 5, 0);

// Sichtbarkeit initial ausblenden
getUi()->encryptionMessage->hide();
checkClientSideEncryptionState();
}

} // namespace OCC

85 changes: 85 additions & 0 deletions src/gui/nmcgui/nmcaccountsettings.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*
* Copyright (C) by Eugen Fischer
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/

#ifndef MIRALL_ACCOUNTSETTINGSMAGENTA_H
#define MIRALL_ACCOUNTSETTINGSMAGENTA_H

#include <QPushButton>
#include <QIcon>
#include <QPainter>
#include <QLabel>

#include <accountsettings.h>

namespace OCC {

/**
* @brief A QPushButton with a custom left icon margin.
*/
class CustomButton : public QPushButton {
Q_OBJECT

public:
explicit CustomButton(const QString &text, const QIcon &icon, QWidget *parent = nullptr)
: QPushButton(text, parent)
, m_icon(icon)
{
setIconSize(QSize(24, 24));
}

void setLeftIconMargin(int margin) { m_leftMargin = margin; }

protected:
void paintEvent(QPaintEvent *event) override {

Check warning on line 44 in src/gui/nmcgui/nmcaccountsettings.h

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this method "paintEvent" to simply inherit it.

See more on https://sonarcloud.io/project/issues?id=nextmcloud_desktop&issues=AZ3UYxGzXqq687UlPYmi&open=AZ3UYxGzXqq687UlPYmi&pullRequest=390
QPushButton::paintEvent(event);
// Optional icon rendering (currently disabled)
// if (!m_icon.isNull()) {
// QRect iconRect(m_leftMargin,
// (height() - iconSize().height()) / 2,
// iconSize().width(),
// iconSize().height());
// QPainter painter(this);
// painter.drawPixmap(iconRect, m_icon.pixmap(iconSize()));
// }

Check warning on line 54 in src/gui/nmcgui/nmcaccountsettings.h

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove the commented out code.

See more on https://sonarcloud.io/project/issues?id=nextmcloud_desktop&issues=AZ3UYxGzXqq687UlPYmj&open=AZ3UYxGzXqq687UlPYmj&pullRequest=390
}

private:
QIcon m_icon;
int m_leftMargin = 4;
};

/**
* @brief Erweiterte AccountSettings-Ansicht für Magenta.
*/
class NMCAccountSettings : public AccountSettings {
Q_OBJECT

public:
explicit NMCAccountSettings(AccountState *accountState, QWidget *parent = nullptr);
~NMCAccountSettings() override = default;

private:
void setDefaultSettings();
void setLayout();

CustomButton *m_liveAccountButton = nullptr;
QLabel *m_liveTitle = nullptr;
QLabel *m_liveDescription = nullptr;
QLabel *m_folderSync = nullptr;
};

} // namespace OCC

#endif // MIRALL_ACCOUNTSETTINGSMAGENTA_H

7 changes: 4 additions & 3 deletions src/gui/settingsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "generalsettings.h"
#include "networksettings.h"
#include "accountsettings.h"
#include "nmcgui/nmcaccountsettings.h"
#include "configfile.h"
#include "progressdispatcher.h"
#include "owncloudgui.h"
Expand Down Expand Up @@ -342,8 +343,8 @@ void SettingsDialog::accountAdded(AccountState *s)
accountAction->setIconText(shortDisplayNameForSettings(s->account().data(), static_cast<int>(height * buttonSizeRatio)));
}

_toolBar->addAction(accountAction);
auto accountSettings = new AccountSettings(s, this);
_toolBar->insertAction(_toolBar->actions().at(0), accountAction);
auto accountSettings = new NMCAccountSettings(s, this);
QString objectName = QLatin1String("accountSettings_");
objectName += s->account()->displayName();
accountSettings->setObjectName(objectName);
Expand Down Expand Up @@ -417,7 +418,7 @@ void SettingsDialog::slotAccountDisplayNameChanged()
void SettingsDialog::accountRemoved(AccountState *s)
{
for (auto it = _actionGroupWidgets.begin(); it != _actionGroupWidgets.end(); ++it) {
auto as = qobject_cast<AccountSettings *>(*it);
auto as = qobject_cast<NMCAccountSettings *>(*it);
if (!as) {
continue;
}
Expand Down
Loading