Skip to content

Commit 0f0c6a5

Browse files
committed
Merge #369 [stable-3.16] nmc/2025/2003-Account_Settings_Dialog
2 parents b125172 + 53fb79c commit 0f0c6a5

File tree

7 files changed

+273
-7
lines changed

7 files changed

+273
-7
lines changed

src/gui/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ find_package(Qt${QT_MAJOR_VERSION} REQUIRED COMPONENTS Widgets Svg Qml Quick Qui
33
find_package(KF6Archive REQUIRED)
44
find_package(KF6GuiAddons)
55

6+
#NMC customization: needed to find the ui file in a different location than the header file
7+
set(CMAKE_AUTOUIC_SEARCH_PATHS "${CMAKE_SOURCE_DIR}/src/gui")
8+
69
if (NOT TARGET Qt::GuiPrivate)
710
message(FATAL_ERROR "Could not find GuiPrivate component of Qt. It might be shipped as a separate package, please check that.")
811
endif()
@@ -255,6 +258,10 @@ set(client_SRCS
255258
wizard/linklabel.cpp
256259
)
257260

261+
file(GLOB NMC_FILES "nmcgui/*")
262+
set(NMC_SRCS ${NMC_FILES})
263+
list(APPEND client_SRCS ${NMC_SRCS})
264+
258265
if (WITH_WEBENGINE)
259266
list(APPEND client_SRCS
260267
wizard/webviewpage.h

src/gui/accountsettings.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,7 +1162,6 @@ void AccountSettings::showConnectionLabel(const QString &message, QStringList er
11621162
_ui->connectLabel->setToolTip({});
11631163
_ui->connectLabel->setStyleSheet(errStyle);
11641164
}
1165-
_ui->accountStatus->setVisible(!message.isEmpty());
11661165
}
11671166

11681167
void AccountSettings::slotEnableCurrentFolder(bool terminate)
@@ -1258,9 +1257,10 @@ void AccountSettings::slotUpdateQuota(qint64 total, qint64 used)
12581257
const auto totalStr = Utility::octetsToString(total);
12591258
const auto percentStr = Utility::compactFormatDouble(percent, 1);
12601259
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);
1261-
_ui->quotaInfoLabel->setText(tr("%1 of %2 in use").arg(usedStr, totalStr));
1260+
_ui->quotaInfoLabel->setText(QCoreApplication::translate("", "%1_OF_%2").arg(usedStr, totalStr));
12621261
_ui->quotaInfoLabel->setToolTip(toolTip);
12631262
_ui->quotaProgressBar->setToolTip(toolTip);
1263+
_ui->quotaInfoText->setText(QCoreApplication::translate("", "USED_STORAGE_%1").arg(percentStr));
12641264
} else {
12651265
_ui->quotaProgressBar->setVisible(false);
12661266
_ui->quotaInfoLabel->setToolTip({});
@@ -1272,6 +1272,7 @@ void AccountSettings::slotUpdateQuota(qint64 total, qint64 used)
12721272
const auto usedStr = Utility::octetsToString(used);
12731273
_ui->quotaInfoLabel->setText(tr("%1 in use").arg(usedStr));
12741274
}
1275+
_ui->quotaInfoText->setText(QCoreApplication::translate("", "USED_STORAGE_%1").arg(QString::number(0)));
12751276
}
12761277
}
12771278

src/gui/accountsettings.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ protected slots:
115115
void slotSelectiveSyncChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight,
116116
const QVector<int> &roles);
117117
void slotPossiblyUnblacklistE2EeFoldersAndRestartSync();
118-
118+
void checkClientSideEncryptionState(); // NMC customization
119119
void slotE2eEncryptionCertificateNeedMigration();
120120

121121
private slots:
@@ -132,9 +132,14 @@ private slots:
132132

133133
void initializeE2eEncryption();
134134
void resetE2eEncryption();
135-
void checkClientSideEncryptionState();
136135
void removeActionFromEncryptionMessage(const QString &actionId);
137136

137+
protected:
138+
Ui::AccountSettings *getUi() const
139+
{
140+
return _ui;
141+
}
142+
138143
private:
139144
bool event(QEvent *) override;
140145
QAction *addActionToEncryptionMessage(const QString &actionTitle, const QString &actionId);

src/gui/accountsettings.ui

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<string notr="true">Form</string>
1515
</property>
1616
<layout class="QGridLayout" name="gridLayout">
17-
<item row="2" column="0">
17+
<item row="3" column="0">
1818
<layout class="QHBoxLayout" name="storageGroupBox">
1919
<item>
2020
<widget class="QLabel" name="quotaInfoLabel">
@@ -66,6 +66,25 @@
6666
</property>
6767
</widget>
6868
</item>
69+
<item>
70+
<widget class="QLabel" name="quotaInfoText">
71+
<property name="sizePolicy">
72+
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
73+
<horstretch>0</horstretch>
74+
<verstretch>0</verstretch>
75+
</sizepolicy>
76+
</property>
77+
<property name="text">
78+
<string>0% of memory used</string>
79+
</property>
80+
<property name="textFormat">
81+
<enum>Qt::PlainText</enum>
82+
</property>
83+
<property name="wordWrap">
84+
<bool>false</bool>
85+
</property>
86+
</widget>
87+
</item>
6988
</layout>
7089
</item>
7190
<item row="4" column="0">
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
/*
2+
* Copyright (C) by Eugen Fischer
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation; either version 2 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful, but
10+
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11+
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* for more details.
13+
*/
14+
15+
#include "nmcgui/nmcaccountsettings.h"
16+
#include "ui_accountsettings.h"
17+
#include "../common/utility.h"
18+
#include "guiutility.h"
19+
20+
#include <QDesktopServices>
21+
#include <QUrl>
22+
#include <QPushButton>
23+
#include <QLabel>
24+
#include <QHBoxLayout>
25+
#include <QVBoxLayout>
26+
#include <QSpacerItem>
27+
#include <QSizePolicy>
28+
29+
namespace OCC {
30+
31+
NMCAccountSettings::NMCAccountSettings(AccountState *accountState, QWidget *parent)
32+
: AccountSettings(accountState, parent)
33+
, m_liveAccountButton(new CustomButton(QCoreApplication::translate("", "ADD_LIVE_BACKUP"), QIcon(QLatin1String(":/client/theme/NMCIcons/action-add.svg")).pixmap(24,24)))
34+
, m_liveTitle(new QLabel(QCoreApplication::translate("", "LIVE_BACKUPS")))
35+
, m_liveDescription(new QLabel(QCoreApplication::translate("", "LIVE_DESCRIPTION")))
36+
, m_folderSync(new QLabel(QCoreApplication::translate("", "YOUR_FOLDER_SYNC")))
37+
{
38+
setDefaultSettings();
39+
setLayout();
40+
connect(m_liveAccountButton, &CustomButton::clicked, this, &NMCAccountSettings::slotAddFolder);
41+
}
42+
43+
void NMCAccountSettings::setDefaultSettings()
44+
{
45+
getUi()->encryptionMessage->setCloseButtonVisible(true);
46+
getUi()->selectiveSyncStatus->setVisible(false);
47+
getUi()->selectiveSyncNotification->setVisible(false);
48+
getUi()->accountStatus->setVisible(false);
49+
getUi()->bigFolderUi->setVisible(false);
50+
getUi()->gridLayout->setSpacing(8);
51+
}
52+
53+
void NMCAccountSettings::setLayout()
54+
{
55+
// Entferne alte Quota-Widgets
56+
getUi()->storageGroupBox->removeWidget(getUi()->quotaInfoLabel);
57+
getUi()->storageGroupBox->removeWidget(getUi()->quotaProgressBar);
58+
getUi()->storageGroupBox->removeWidget(getUi()->quotaInfoText);
59+
60+
getUi()->gridLayout->removeWidget(getUi()->encryptionMessage);
61+
getUi()->gridLayout->addWidget(getUi()->encryptionMessage, 0, 0);
62+
63+
// Titel für Folder Sync
64+
m_folderSync->setStyleSheet("font-size: 15px; font-weight: 600; padding: 8px;");
65+
m_folderSync->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
66+
getUi()->gridLayout->addWidget(m_folderSync, 1, 0);
67+
68+
// Live-Backup-Bereich
69+
auto *liveHLayout = new QHBoxLayout();
70+
liveHLayout->setContentsMargins(8, 8, 8, 8);
71+
72+
auto *liveVLayout = new QVBoxLayout();
73+
auto *liveWidget = new QWidget(this);
74+
liveWidget->setStyleSheet("QWidget {background-color: white; border-radius: 4px;}");
75+
liveWidget->setLayout(liveHLayout);
76+
77+
liveHLayout->addLayout(liveVLayout);
78+
liveHLayout->addStretch();
79+
80+
const QString styleSheet = QStringLiteral(
81+
"QPushButton { font-size: %5px; border: %1px solid; border-color: black; "
82+
"border-radius: 4px; background-color: %2; color: %3; } "
83+
"QPushButton:hover { background-color: %4; }");
84+
85+
m_liveAccountButton->setStyleSheet(styleSheet.arg("0", "#E20074", "white", "#c00063", "13"));
86+
m_liveAccountButton->setFixedSize(180, 32);
87+
m_liveAccountButton->setLeftIconMargin(4);
88+
89+
liveHLayout->addWidget(m_liveAccountButton);
90+
91+
liveVLayout->addWidget(m_liveTitle);
92+
m_liveTitle->setStyleSheet("font-size: 15px; font-weight: 600;");
93+
94+
liveVLayout->addWidget(m_liveDescription);
95+
m_liveDescription->setStyleSheet("font-size: 13px;");
96+
m_liveDescription->setText(QCoreApplication::translate("", "LIVE_BACKUPS_DESCRIPTION"));
97+
m_liveDescription->setWordWrap(true);
98+
m_liveDescription->setFixedWidth(450);
99+
100+
getUi()->gridLayout->addWidget(liveWidget, 4, 0);
101+
102+
// Speicherbereich
103+
auto *magentaHLayout = new QHBoxLayout();
104+
magentaHLayout->setSpacing(32);
105+
106+
auto *quotaVLayout = new QVBoxLayout();
107+
quotaVLayout->setSpacing(4);
108+
quotaVLayout->addSpacing(12);
109+
110+
quotaVLayout->addWidget(getUi()->quotaInfoLabel);
111+
getUi()->quotaInfoLabel->setStyleSheet("QLabel { font-size: 18px; padding: 8px; font-weight: 500; }");
112+
113+
quotaVLayout->addWidget(getUi()->quotaProgressBar);
114+
getUi()->quotaProgressBar->setStyleSheet(
115+
"QProgressBar { background-color: #e5e5e5; color: black; border-width: 1px; "
116+
"border-color: black; border-radius: 4px; } "
117+
"QProgressBar::chunk { background-color: #ea0a8e; }");
118+
getUi()->quotaProgressBar->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
119+
120+
quotaVLayout->addWidget(getUi()->quotaInfoText);
121+
getUi()->quotaInfoText->setStyleSheet("QLabel { font-size: 13px; padding: 8px; }");
122+
123+
quotaVLayout->addSpacing(20);
124+
magentaHLayout->addLayout(quotaVLayout);
125+
126+
auto *storageLinkButton = new QPushButton(QCoreApplication::translate("", "STORAGE_EXTENSION"), this);
127+
storageLinkButton->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
128+
storageLinkButton->setStyleSheet(
129+
"QPushButton { height: 32px; width: 180px; border: 1px solid black; background-color: #ededed; "
130+
"font-size: 13px; border-radius: 4px; } "
131+
"QPushButton::hover { background-color: white; }");
132+
133+
connect(storageLinkButton, &QPushButton::clicked, this, []() {
134+
QDesktopServices::openUrl(QUrl(QStringLiteral("https://cloud.telekom-dienste.de/tarife")));
135+
});
136+
137+
magentaHLayout->addWidget(storageLinkButton);
138+
magentaHLayout->addSpacing(8);
139+
140+
getUi()->gridLayout->addLayout(magentaHLayout, 5, 0);
141+
142+
// Sichtbarkeit initial ausblenden
143+
getUi()->encryptionMessage->hide();
144+
checkClientSideEncryptionState();
145+
}
146+
147+
} // namespace OCC
148+
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
/*
2+
* Copyright (C) by Eugen Fischer
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation; either version 2 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful, but
10+
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11+
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* for more details.
13+
*/
14+
15+
#ifndef MIRALL_ACCOUNTSETTINGSMAGENTA_H
16+
#define MIRALL_ACCOUNTSETTINGSMAGENTA_H
17+
18+
#include <QPushButton>
19+
#include <QIcon>
20+
#include <QPainter>
21+
#include <QLabel>
22+
23+
#include <accountsettings.h>
24+
25+
namespace OCC {
26+
27+
/**
28+
* @brief A QPushButton with a custom left icon margin.
29+
*/
30+
class CustomButton : public QPushButton {
31+
Q_OBJECT
32+
33+
public:
34+
explicit CustomButton(const QString &text, const QIcon &icon, QWidget *parent = nullptr)
35+
: QPushButton(text, parent)
36+
, m_icon(icon)
37+
{
38+
setIconSize(QSize(24, 24));
39+
}
40+
41+
void setLeftIconMargin(int margin) { m_leftMargin = margin; }
42+
43+
protected:
44+
void paintEvent(QPaintEvent *event) override {
45+
QPushButton::paintEvent(event);
46+
// Optional icon rendering (currently disabled)
47+
// if (!m_icon.isNull()) {
48+
// QRect iconRect(m_leftMargin,
49+
// (height() - iconSize().height()) / 2,
50+
// iconSize().width(),
51+
// iconSize().height());
52+
// QPainter painter(this);
53+
// painter.drawPixmap(iconRect, m_icon.pixmap(iconSize()));
54+
// }
55+
}
56+
57+
private:
58+
QIcon m_icon;
59+
int m_leftMargin = 4;
60+
};
61+
62+
/**
63+
* @brief Erweiterte AccountSettings-Ansicht für Magenta.
64+
*/
65+
class NMCAccountSettings : public AccountSettings {
66+
Q_OBJECT
67+
68+
public:
69+
explicit NMCAccountSettings(AccountState *accountState, QWidget *parent = nullptr);
70+
~NMCAccountSettings() override = default;
71+
72+
private:
73+
void setDefaultSettings();
74+
void setLayout();
75+
76+
CustomButton *m_liveAccountButton = nullptr;
77+
QLabel *m_liveTitle = nullptr;
78+
QLabel *m_liveDescription = nullptr;
79+
QLabel *m_folderSync = nullptr;
80+
};
81+
82+
} // namespace OCC
83+
84+
#endif // MIRALL_ACCOUNTSETTINGSMAGENTA_H
85+

src/gui/settingsdialog.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "generalsettings.h"
2121
#include "networksettings.h"
2222
#include "accountsettings.h"
23+
#include "nmcgui/nmcaccountsettings.h"
2324
#include "configfile.h"
2425
#include "progressdispatcher.h"
2526
#include "owncloudgui.h"
@@ -250,7 +251,7 @@ void SettingsDialog::accountAdded(AccountState *s)
250251
}
251252

252253
_toolBar->insertAction(_toolBar->actions().at(0), accountAction);
253-
auto accountSettings = new AccountSettings(s, this);
254+
auto accountSettings = new NMCAccountSettings(s, this);
254255
QString objectName = QLatin1String("accountSettings_");
255256
objectName += s->account()->displayName();
256257
accountSettings->setObjectName(objectName);
@@ -312,7 +313,7 @@ void SettingsDialog::slotAccountDisplayNameChanged()
312313
void SettingsDialog::accountRemoved(AccountState *s)
313314
{
314315
for (auto it = _actionGroupWidgets.begin(); it != _actionGroupWidgets.end(); ++it) {
315-
auto as = qobject_cast<AccountSettings *>(*it);
316+
auto as = qobject_cast<NMCAccountSettings *>(*it);
316317
if (!as) {
317318
continue;
318319
}

0 commit comments

Comments
 (0)