Skip to content

Commit 324a174

Browse files
committed
Merge #406 [stable-4.0] [master] 2003-Account_Settings_Dialog
2 parents 791927e + 862325f commit 324a174

File tree

7 files changed

+279
-9
lines changed

7 files changed

+279
-9
lines changed

src/gui/accountsettings.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,7 +1172,6 @@ void AccountSettings::showConnectionLabel(const QString &message, QStringList er
11721172
_ui->connectLabel->setToolTip({});
11731173
_ui->connectLabel->setStyleSheet(errStyle);
11741174
}
1175-
_ui->accountStatus->setVisible(!message.isEmpty());
11761175
}
11771176

11781177
void AccountSettings::slotEnableCurrentFolder(bool terminate)
@@ -1268,9 +1267,10 @@ void AccountSettings::slotUpdateQuota(qint64 total, qint64 used)
12681267
const auto totalStr = Utility::octetsToString(total);
12691268
const auto percentStr = Utility::compactFormatDouble(percent, 1);
12701269
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);
1271-
_ui->quotaInfoLabel->setText(tr("%1 of %2 in use").arg(usedStr, totalStr));
1270+
_ui->quotaInfoLabel->setText(QCoreApplication::translate("", "%1_OF_%2").arg(usedStr, totalStr));
12721271
_ui->quotaInfoLabel->setToolTip(toolTip);
12731272
_ui->quotaProgressBar->setToolTip(toolTip);
1273+
_ui->quotaInfoText->setText(QCoreApplication::translate("", "USED_STORAGE_%1").arg(percentStr));
12741274
} else {
12751275
_ui->quotaProgressBar->setVisible(false);
12761276
_ui->quotaInfoLabel->setToolTip({});
@@ -1282,6 +1282,7 @@ void AccountSettings::slotUpdateQuota(qint64 total, qint64 used)
12821282
const auto usedStr = Utility::octetsToString(used);
12831283
_ui->quotaInfoLabel->setText(tr("%1 in use").arg(usedStr));
12841284
}
1285+
_ui->quotaInfoText->setText(QCoreApplication::translate("", "USED_STORAGE_%1").arg(QString::number(0)));
12851286
}
12861287
}
12871288

src/gui/accountsettings.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ protected slots:
108108
const QVector<int> &roles);
109109
void slotPossiblyUnblacklistE2EeFoldersAndRestartSync();
110110

111+
void checkClientSideEncryptionState();
111112
void slotE2eEncryptionCertificateNeedMigration();
112113

113114
private slots:
@@ -124,9 +125,14 @@ private slots:
124125

125126
void setupE2eEncryption();
126127
void forgetE2eEncryption();
127-
void checkClientSideEncryptionState();
128128
void removeActionFromEncryptionMessage(const QString &actionId);
129129

130+
protected:
131+
Ui::AccountSettings *getUi() const
132+
{
133+
return _ui;
134+
}
135+
130136
private:
131137
bool event(QEvent *) override;
132138
QAction *addActionToEncryptionMessage(const QString &actionTitle, const QString &actionId);

src/gui/accountsettings.ui

Lines changed: 22 additions & 3 deletions
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="4" column="0">
1818
<layout class="QHBoxLayout" name="storageGroupBox">
1919
<item>
2020
<widget class="QLabel" name="quotaInfoLabel">
@@ -66,9 +66,28 @@
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>
71-
<item row="4" column="0">
90+
<item row="3" column="0">
7291
<widget class="QWidget" name="selectiveSyncStatus" native="true">
7392
<layout class="QHBoxLayout" name="horizontalLayout_3">
7493
<item>
@@ -257,7 +276,7 @@
257276
</layout>
258277
</widget>
259278
</item>
260-
<item row="3" column="0">
279+
<item row="2" column="0">
261280
<widget class="QTabWidget" name="tabWidget">
262281
<property name="tabShape">
263282
<enum>QTabWidget::Rounded</enum>
Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
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+
{
37+
setDefaultSettings();
38+
setLayout();
39+
connect(m_liveAccountButton, &CustomButton::clicked, this, &NMCAccountSettings::slotAddFolder);
40+
}
41+
42+
void NMCAccountSettings::setDefaultSettings()
43+
{
44+
getUi()->encryptionMessage->setCloseButtonVisible(true);
45+
getUi()->selectiveSyncStatus->setVisible(false);
46+
getUi()->selectiveSyncNotification->setVisible(false);
47+
getUi()->accountStatus->setVisible(false);
48+
getUi()->bigFolderUi->setVisible(false);
49+
getUi()->gridLayout->setSpacing(8);
50+
}
51+
52+
void NMCAccountSettings::setLayout()
53+
{
54+
// Entferne alte Quota-Widgets
55+
getUi()->storageGroupBox->removeWidget(getUi()->quotaInfoLabel);
56+
getUi()->storageGroupBox->removeWidget(getUi()->quotaProgressBar);
57+
getUi()->storageGroupBox->removeWidget(getUi()->quotaInfoText);
58+
59+
getUi()->gridLayout->removeWidget(getUi()->encryptionMessage);
60+
getUi()->gridLayout->addWidget(getUi()->encryptionMessage, 0, 0);
61+
62+
// --- Live-Backup-Bereich ---
63+
auto *liveHLayout = new QHBoxLayout();
64+
liveHLayout->setContentsMargins(8, 8, 8, 8);
65+
66+
auto *liveVLayout = new QVBoxLayout();
67+
m_liveWidget = new QWidget(this); // Membervariable statt lokale Variable
68+
m_liveWidget->setStyleSheet("QWidget { border-radius: 4px; }");
69+
m_liveWidget->setLayout(liveHLayout);
70+
71+
liveHLayout->addLayout(liveVLayout);
72+
liveHLayout->addStretch();
73+
74+
const QString styleSheet = QStringLiteral(
75+
"QPushButton { font-size: %5px; border: %1px solid; border-color: black; "
76+
"border-radius: 4px; background-color: %2; color: %3; } "
77+
"QPushButton:hover { background-color: %4; }");
78+
79+
m_liveAccountButton->setStyleSheet(styleSheet.arg("0", "#E20074", "white", "#c00063", "13"));
80+
m_liveAccountButton->setFixedSize(180, 32);
81+
m_liveAccountButton->setLeftIconMargin(4);
82+
83+
liveHLayout->addWidget(m_liveAccountButton);
84+
85+
liveVLayout->addWidget(m_liveTitle);
86+
m_liveTitle->setStyleSheet("font-size: 15px; font-weight: 600;");
87+
88+
liveVLayout->addWidget(m_liveDescription);
89+
m_liveDescription->setStyleSheet("font-size: 13px;");
90+
m_liveDescription->setText(QCoreApplication::translate("", "LIVE_BACKUPS_DESCRIPTION"));
91+
m_liveDescription->setWordWrap(true);
92+
m_liveDescription->setFixedWidth(450);
93+
94+
getUi()->gridLayout->addWidget(m_liveWidget, 4, 0);
95+
96+
// --- Speicherbereich (Quota) ---
97+
auto *magentaHLayout = new QHBoxLayout();
98+
magentaHLayout->setSpacing(32);
99+
100+
auto *quotaVLayout = new QVBoxLayout();
101+
quotaVLayout->setSpacing(4);
102+
quotaVLayout->addSpacing(12);
103+
104+
quotaVLayout->addWidget(getUi()->quotaInfoLabel);
105+
getUi()->quotaInfoLabel->setStyleSheet("QLabel { font-size: 18px; padding: 8px; font-weight: 500; }");
106+
107+
quotaVLayout->addWidget(getUi()->quotaProgressBar);
108+
getUi()->quotaProgressBar->setStyleSheet(
109+
"QProgressBar { background-color: #e5e5e5; color: black; border: 1px solid black; border-radius: 4px; margin-left: 8px; } "
110+
"QProgressBar::chunk { background-color: #E20074; }");
111+
getUi()->quotaProgressBar->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
112+
113+
quotaVLayout->addWidget(getUi()->quotaInfoText);
114+
getUi()->quotaInfoText->setStyleSheet("QLabel { font-size: 13px; padding: 8px; }");
115+
116+
quotaVLayout->addSpacing(20);
117+
magentaHLayout->addLayout(quotaVLayout);
118+
119+
auto *storageLinkButton = new QPushButton(QCoreApplication::translate("", "STORAGE_EXTENSION"), this);
120+
storageLinkButton->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
121+
storageLinkButton->setStyleSheet(
122+
"QPushButton { height: 32px; width: 180px; border: 1px solid black; background-color: #ededed; "
123+
"color: black; font-size: 13px; border-radius: 4px; } "
124+
"QPushButton:hover { background-color: white; }");
125+
126+
connect(storageLinkButton, &QPushButton::clicked, this, []() {
127+
QDesktopServices::openUrl(QUrl(QStringLiteral("https://cloud.telekom-dienste.de/tarife")));
128+
});
129+
130+
magentaHLayout->addWidget(storageLinkButton);
131+
magentaHLayout->addSpacing(8);
132+
133+
getUi()->gridLayout->addLayout(magentaHLayout, 5, 0);
134+
135+
// --- Sichtbarkeit initial ausblenden ---
136+
getUi()->encryptionMessage->hide();
137+
checkClientSideEncryptionState();
138+
139+
// --- Sichtbarkeit des Live-Backup-Bereichs je nach Tab ---
140+
auto *tabWidget = getUi()->tabWidget;
141+
auto *connectionSettingsTab = getUi()->connectionSettingsTab;
142+
143+
if (tabWidget && connectionSettingsTab) {
144+
connect(tabWidget, &QTabWidget::currentChanged, this,
145+
[this, tabWidget, connectionSettingsTab](int index) {
146+
QWidget *currentTab = tabWidget->widget(index);
147+
bool hideLiveBackup = (currentTab == connectionSettingsTab);
148+
m_liveWidget->setVisible(!hideLiveBackup);
149+
});
150+
151+
// Initialzustand
152+
QWidget *currentTab = tabWidget->currentWidget();
153+
bool hideLiveBackup = (currentTab == connectionSettingsTab);
154+
m_liveWidget->setVisible(!hideLiveBackup);
155+
}
156+
}
157+
158+
} // namespace OCC
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+
QWidget *m_liveWidget = 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
@@ -14,6 +14,7 @@
1414
#include "nmcgui/nmcgeneralsettings.h"
1515
#include "networksettings.h"
1616
#include "accountsettings.h"
17+
#include "nmcgui/nmcaccountsettings.h"
1718
#include "configfile.h"
1819
#include "progressdispatcher.h"
1920
#include "owncloudgui.h"
@@ -246,7 +247,7 @@ void SettingsDialog::accountAdded(AccountState *s)
246247
}
247248

248249
_toolBar->insertAction(_toolBar->actions().at(0), accountAction);
249-
auto accountSettings = new AccountSettings(s, this);
250+
auto accountSettings = new NMCAccountSettings(s, this);
250251
QString objectName = QLatin1String("accountSettings_");
251252
objectName += s->account()->displayName();
252253
accountSettings->setObjectName(objectName);
@@ -309,7 +310,7 @@ void SettingsDialog::slotAccountDisplayNameChanged()
309310
void SettingsDialog::accountRemoved(AccountState *s)
310311
{
311312
for (auto it = _actionGroupWidgets.begin(); it != _actionGroupWidgets.end(); ++it) {
312-
auto as = qobject_cast<AccountSettings *>(*it);
313+
auto as = qobject_cast<NMCAccountSettings *>(*it);
313314
if (!as) {
314315
continue;
315316
}

translations/client_de.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ Soll das Konto importiert werden?</translation>
737737
<message>
738738
<location filename="../src/gui/accountsettings.ui" line="270"/>
739739
<source>Standard file sync</source>
740-
<translation>Standard Dateisynchronisierung</translation>
740+
<translation>Ihre Ordner in Synchronisation</translation>
741741
</message>
742742
<message>
743743
<location filename="../src/gui/accountsettings.ui" line="314"/>

0 commit comments

Comments
 (0)