Skip to content

Commit 6390de0

Browse files
committed
Merge #391 [master] 2003-E2EE_Settings_Dialog
2 parents 9873061 + 6f3c5c1 commit 6390de0

File tree

5 files changed

+2305
-2009
lines changed

5 files changed

+2305
-2009
lines changed

src/3rdparty/kmessagewidget/kmessagewidget.cpp

Lines changed: 85 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ class KMessageWidgetPrivate
3131
QFrame *content = nullptr;
3232
QLabel *iconLabel = nullptr;
3333
QLabel *textLabel = nullptr;
34+
QLabel *titleLabel = nullptr;
35+
QLabel *titelIcon = nullptr;
3436
QToolButton *closeButton = nullptr;
3537
QTimeLine *timeLine = nullptr;
3638
QIcon icon;
@@ -49,6 +51,9 @@ class KMessageWidgetPrivate
4951
void slotTimeLineFinished();
5052

5153
[[nodiscard]] int bestContentHeight() const;
54+
55+
private:
56+
void applyNMCStylesheets() const;
5257
};
5358

5459
void KMessageWidgetPrivate::init(KMessageWidget *q_ptr)
@@ -73,11 +78,24 @@ void KMessageWidgetPrivate::init(KMessageWidget *q_ptr)
7378
iconLabel->hide();
7479

7580
textLabel = new QLabel(content);
76-
textLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
81+
textLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
82+
textLabel->setFixedWidth(500);
7783
textLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
7884
QObject::connect(textLabel, &QLabel::linkActivated, q, &KMessageWidget::linkActivated);
7985
QObject::connect(textLabel, &QLabel::linkHovered, q, &KMessageWidget::linkHovered);
8086

87+
// Titel-Label konfigurieren
88+
titleLabel = new QLabel(content);
89+
titleLabel->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
90+
titleLabel->setText(QCoreApplication::translate("", "E2E_ENCRYPTION"));
91+
titleLabel->setStyleSheet("font-size: 13px; font-weight: 600;");
92+
93+
// Icon-Label konfigurieren
94+
titelIcon = new QLabel(content);
95+
titelIcon->setFixedSize(24, 24);
96+
titelIcon->setPixmap(QIcon(QStringLiteral(":/client/theme/NMCIcons/cloud-security.svg")).pixmap(24, 24));
97+
titelIcon->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
98+
8199
auto *closeAction = new QAction(q);
82100
closeAction->setText(KMessageWidget::tr("&Close"));
83101
closeAction->setToolTip(KMessageWidget::tr("Close message"));
@@ -86,8 +104,6 @@ void KMessageWidgetPrivate::init(KMessageWidget *q_ptr)
86104
QObject::connect(closeAction, &QAction::triggered, q, &KMessageWidget::animatedHide);
87105

88106
closeButton = new QToolButton(content);
89-
closeButton->setAutoRaise(true);
90-
closeButton->setDefaultAction(closeAction);
91107

92108
q->setMessageType(KMessageWidget::Information);
93109
}
@@ -104,37 +120,53 @@ void KMessageWidgetPrivate::createLayout()
104120
Q_FOREACH (QAction *action, q->actions()) {
105121
auto *button = new QToolButton(content);
106122
button->setDefaultAction(action);
107-
button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
123+
button->setToolButtonStyle(Qt::ToolButtonTextOnly);
108124
buttons.append(button);
109125
}
110126

111127
// AutoRaise reduces visual clutter, but we don't want to turn it on if
112128
// there are other buttons, otherwise the close button will look different
113129
// from the others.
114-
closeButton->setAutoRaise(buttons.isEmpty());
130+
// closeButton->setAutoRaise(buttons.isEmpty());
115131

116-
if (wordWrap) {
132+
// NMC customization: make sure we always enter the first case
133+
if (true) {
117134
auto *layout = new QGridLayout(content);
118-
// Set alignment to make sure icon does not move down if text wraps
119-
layout->addWidget(iconLabel, 0, 0, 1, 1, Qt::AlignHCenter | Qt::AlignTop);
120-
layout->addWidget(textLabel, 0, 1);
135+
layout->setContentsMargins(8, 4, 8, 4);
136+
layout->setSpacing(0);
137+
content->setFixedHeight(84);
138+
139+
auto *titleLayout = new QHBoxLayout();
140+
titleLayout->setSpacing(8);
141+
titleLayout->setContentsMargins(0, 0, 0, 0);
142+
titleLayout->addWidget(titleLabel);
143+
titleLayout->addWidget(titelIcon);
144+
145+
layout->addLayout(titleLayout, 0, 0, 1, 1, Qt::AlignLeft | Qt::AlignVCenter);
146+
147+
textLabel->setWordWrap(true);
148+
layout->addWidget(textLabel, 1, 0);
149+
150+
auto *spacerItem = new QSpacerItem(1, 1, QSizePolicy::Fixed, QSizePolicy::Expanding);
151+
layout->addItem(spacerItem, 2, 0);
121152

122153
if (buttons.isEmpty()) {
123154
// Use top-vertical alignment like the icon does.
124-
layout->addWidget(closeButton, 0, 2, 1, 1, Qt::AlignHCenter | Qt::AlignTop);
155+
// layout->addWidget(closeButton, 0, 2, 1, 1, Qt::AlignHCenter | Qt::AlignTop);
125156
} else {
126157
// Use an additional layout in row 1 for the buttons.
127-
auto *buttonLayout = new QHBoxLayout;
128-
buttonLayout->addStretch();
158+
auto *buttonLayout = new QVBoxLayout;
159+
buttonLayout->setContentsMargins(0, 0, 0, 0);
160+
buttonLayout->setSpacing(4);
129161
Q_FOREACH (QToolButton *button, buttons) {
130162
// For some reason, calling show() is necessary if wordwrap is true,
131163
// otherwise the buttons do not show up. It is not needed if
132164
// wordwrap is false.
133165
button->show();
134166
buttonLayout->addWidget(button);
135167
}
136-
buttonLayout->addWidget(closeButton);
137-
layout->addItem(buttonLayout, 1, 0, 1, 2);
168+
layout->addItem(buttonLayout, 0, 1, 3, 1, Qt::AlignRight);
169+
applyNMCStylesheets();
138170
}
139171
} else {
140172
auto *layout = new QHBoxLayout(content);
@@ -144,8 +176,6 @@ void KMessageWidgetPrivate::createLayout()
144176
for (QToolButton *button : std::as_const(buttons)) {
145177
layout->addWidget(button);
146178
}
147-
148-
layout->addWidget(closeButton);
149179
};
150180

151181
if (q->isVisible()) {
@@ -163,10 +193,10 @@ void KMessageWidgetPrivate::applyStyleSheet()
163193
// The following RGB color values come from the "default" scheme in kcolorscheme.cpp
164194
switch (messageType) {
165195
case KMessageWidget::Positive:
166-
bgBaseColor.setRgb(39, 174, 96); // Window: ForegroundPositive
196+
bgBaseColor.setRgb(204, 250, 225); // Window: ForegroundPositive
167197
break;
168198
case KMessageWidget::Information:
169-
bgBaseColor.setRgb(61, 174, 233); // Window: ForegroundActive
199+
bgBaseColor.setRgb(211, 215, 249); // Window: ForegroundActive
170200
break;
171201
case KMessageWidget::Warning:
172202
bgBaseColor.setRgb(246, 116, 0); // Window: ForegroundNeutral
@@ -175,13 +205,11 @@ void KMessageWidgetPrivate::applyStyleSheet()
175205
bgBaseColor.setRgb(218, 68, 83); // Window: ForegroundNegative
176206
break;
177207
}
178-
const qreal bgBaseColorAlpha = 0.2;
208+
const qreal bgBaseColorAlpha = 1.0;
179209
bgBaseColor.setAlphaF(bgBaseColorAlpha);
180210

181211
const QPalette palette = QGuiApplication::palette();
182212
const QColor windowColor = palette.window().color();
183-
const QColor textColor = palette.text().color();
184-
const QColor border = bgBaseColor;
185213

186214
// Generate a final background color from overlaying bgBaseColor over windowColor
187215
const int newRed = qRound(bgBaseColor.red() * bgBaseColorAlpha) + qRound(windowColor.red() * (1 - bgBaseColorAlpha));
@@ -197,14 +225,15 @@ void KMessageWidgetPrivate::applyStyleSheet()
197225
"border: 2px solid %2;"
198226
"margin: %3px;"
199227
"}"
200-
".QLabel { color: %4; }"
228+
".QLabel { color: black; }"
201229
)
202230
.arg(bgFinalColor.name())
203-
.arg(border.name())
231+
.arg(bgFinalColor.name())
204232
// DefaultFrameWidth returns the size of the external margin + border width. We know our border is 1px, so we subtract this from the frame normal QStyle FrameWidth to get our margin
205233
.arg(q->style()->pixelMetric(QStyle::PM_DefaultFrameWidth, nullptr, q) - 1)
206-
.arg(textColor.name())
207234
);
235+
236+
applyNMCStylesheets();
208237
}
209238

210239
void KMessageWidgetPrivate::updateLayout()
@@ -258,6 +287,36 @@ int KMessageWidgetPrivate::bestContentHeight() const
258287
return height;
259288
}
260289

290+
void KMessageWidgetPrivate::applyNMCStylesheets() const
291+
{
292+
// Set button color and size
293+
if (!buttons.empty()) {
294+
const QString stylesheet = QStringLiteral(
295+
"QToolButton{width: 180px; height: 32px; border-radius: 4px; font-size: %1px; color: %2; background-color: %3;} "
296+
"QToolButton:hover { background-color: %4;}"
297+
);
298+
299+
switch (messageType) {
300+
case KMessageWidget::Positive:
301+
for (QToolButton *button : buttons) {
302+
button->setStyleSheet(stylesheet.arg("13", "white", "#00b367", "#00a461"));
303+
}
304+
break;
305+
case KMessageWidget::Information:
306+
for (QToolButton *button : buttons) {
307+
button->setStyleSheet(stylesheet.arg("13", "white", "#216bff", "#0819bd"));
308+
}
309+
break;
310+
case KMessageWidget::Warning:
311+
// Optional: Add styling here if needed
312+
break;
313+
case KMessageWidget::Error:
314+
// Optional: Add styling here if needed
315+
break;
316+
}
317+
}
318+
}
319+
261320
//---------------------------------------------------------------------
262321
// KMessageWidget
263322
//---------------------------------------------------------------------
@@ -383,7 +442,8 @@ bool KMessageWidget::isCloseButtonVisible() const
383442

384443
void KMessageWidget::setCloseButtonVisible(bool show)
385444
{
386-
d->closeButton->setVisible(show);
445+
Q_UNUSED(show)
446+
d->closeButton->setVisible(false);
387447
updateGeometry();
388448
}
389449

src/gui/accountsettings.cpp

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -323,8 +323,7 @@ void AccountSettings::slotE2eEncryptionMnemonicReady()
323323
}
324324

325325
_ui->encryptionMessage->setMessageType(KMessageWidget::Positive);
326-
_ui->encryptionMessage->setText(tr("Encryption is set-up. Remember to <b>Encrypt</b> a folder to end-to-end encrypt any new files added to it."));
327-
_ui->encryptionMessage->setIcon(Theme::createColorAwareIcon(QStringLiteral(":/client/theme/lock.svg")));
326+
_ui->encryptionMessage->setText(QCoreApplication::translate("", "E2E_ENCRYPTION_ACTIVE"));
328327
_ui->encryptionMessage->show();
329328
}
330329

@@ -417,8 +416,7 @@ bool AccountSettings::canEncryptOrDecrypt(const FolderStatusModel::SubFolderInfo
417416

418417
if (!_accountState->account()->e2e() || !_accountState->account()->e2e()->isInitialized()) {
419418
QMessageBox msgBox;
420-
msgBox.setText(tr("You cannot encrypt this folder because the end-to-end encryption is not set-up yet on this device.\n"
421-
"Would you like to do this now?"));
419+
msgBox.setText(QCoreApplication::translate("", "E2E_MNEMONIC_TEXT2"));
422420
msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
423421
msgBox.setDefaultButton(QMessageBox::Ok);
424422
const auto ret = msgBox.exec();
@@ -1100,17 +1098,12 @@ void AccountSettings::displayMnemonic(const QString &mnemonic)
11001098
Ui_Dialog ui{};
11011099
ui.setupUi(&widget);
11021100
widget.setWindowTitle(tr("End-to-end encryption mnemonic"));
1103-
ui.label->setText(
1104-
tr("To protect your Cryptographic Identity, we encrypt it with a mnemonic of 12 dictionary words. "
1105-
"Please note it down and keep it safe. "
1106-
"You will need it to set-up the synchronization of encrypted folders on your other devices."));
1107-
QFont monoFont(QStringLiteral("Monospace"));
1108-
monoFont.setStyleHint(QFont::TypeWriter);
1109-
ui.lineEdit->setFont(monoFont);
1101+
widget.setWindowFlags(Qt::WindowTitleHint | Qt::WindowCloseButtonHint);
1102+
ui.label->setText(QCoreApplication::translate("", "E2E_MNEMONIC_TEXT"));
11101103
ui.lineEdit->setText(mnemonic);
11111104
ui.lineEdit->setReadOnly(true);
11121105

1113-
ui.lineEdit->setStyleSheet(QStringLiteral("QLineEdit{ color: black; background: lightgrey; border-style: inset;}"));
1106+
ui.lineEdit->setStyleSheet(QStringLiteral("QLineEdit{ color: black; background: lightgrey; border-style: inset; padding: 5px;}"));
11141107

11151108
ui.lineEdit->focusWidget();
11161109
ui.lineEdit->selectAll();
@@ -1127,10 +1120,7 @@ void AccountSettings::forgetEncryptionOnDeviceForAccount(const AccountPtr &accou
11271120
{
11281121
QMessageBox dialog;
11291122
dialog.setWindowTitle(tr("Forget the end-to-end encryption on this device"));
1130-
dialog.setText(tr("Do you want to forget the end-to-end encryption settings for %1 on this device?").arg(account->davUser()));
1131-
dialog.setInformativeText(tr("Forgetting end-to-end encryption will remove the sensitive data and all the encrypted files from this device."
1132-
"<br>"
1133-
"However, the encrypted files will remain on the server and all your other devices, if configured."));
1123+
dialog.setText(QCoreApplication::translate("", "E2E_MNEMONIC_TEXT4"));
11341124
dialog.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
11351125
dialog.setDefaultButton(QMessageBox::Ok);
11361126
dialog.adjustSize();
@@ -1700,9 +1690,7 @@ void AccountSettings::setupE2eEncryption()
17001690

17011691
connect(_accountState->account()->e2e(), &ClientSideEncryption::initializationFinished, this, [this] {
17021692
if (!_accountState->account()->e2e()->getPublicKey().isNull()) {
1703-
_ui->encryptionMessage->setText(tr("End-to-end encryption has been initialized on this account with another device."
1704-
"<br>"
1705-
"Enter the unique mnemonic to have the encrypted folders synchronize on this device as well."));
1693+
_ui->encryptionMessage->setText(QCoreApplication::translate("", "E2E_ENCRYPTION_START"));
17061694
}
17071695
});
17081696
_accountState->account()->setE2eEncryptionKeysGenerationAllowed(false);
@@ -1759,7 +1747,6 @@ void AccountSettings::setupE2eEncryptionMessage()
17591747
{
17601748
_ui->encryptionMessage->setMessageType(KMessageWidget::Information);
17611749
_ui->encryptionMessage->setText(tr("This account supports end-to-end encryption, but it needs to be set up first."));
1762-
_ui->encryptionMessage->setIcon(Theme::createColorAwareIcon(QStringLiteral(":/client/theme/info.svg")));
17631750
_ui->encryptionMessage->hide();
17641751

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

src/gui/socketapi/socketapi.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -554,20 +554,20 @@ void SocketApi::processEncryptRequest(const QString &localFile)
554554

555555
auto job = new OCC::EncryptFolderJob(account, folder->journalDb(), choppedPath, choppedPath, folder->remotePath(), rec.numericFileId());
556556
job->setParent(this);
557-
connect(job, &OCC::EncryptFolderJob::finished, this, [fileData, job](const int status) {
557+
connect(job, &OCC::EncryptFolderJob::finished, this, [fileData, account](const int status) {
558558
if (status == OCC::EncryptFolderJob::Error) {
559559
const int ret = QMessageBox::critical(
560560
nullptr,
561561
tr("Failed to encrypt folder"),
562-
tr("Could not encrypt the following folder: \"%1\".\n\n"
563-
"Server replied with error: %2").arg(fileData.folderRelativePath, job->errorString()),
562+
QCoreApplication::translate("", "E2E_MNEMONIC_TEXT3").arg(account->prettyName()),
564563
QMessageBox::Ok
565564
);
566565
Q_UNUSED(ret)
567566
} else {
568567
const int ret = QMessageBox::information(nullptr,
569-
tr("Folder encrypted successfully").arg(fileData.folderRelativePath),
570-
tr("The following folder was encrypted successfully: \"%1\"").arg(fileData.folderRelativePath));
568+
tr("Folder encrypted successfully"),
569+
tr("The following folder was encrypted successfully: \"%1\"")
570+
.arg(fileData.folderRelativePath));
571571
Q_UNUSED(ret)
572572
}
573573
});

src/libsync/clientsideencryption.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2272,15 +2272,11 @@ void ClientSideEncryption::decryptPrivateKey(const QByteArray &key) {
22722272
return;
22732273
}
22742274

2275-
QString msg = tr("Please enter your end-to-end encryption passphrase:<br>"
2276-
"<br>"
2277-
"Username: %2<br>"
2278-
"Account: %3<br>")
2279-
.arg(Utility::escape(_account->credentials()->user()),
2280-
Utility::escape(_account->displayName()));
2275+
QString msg = QCoreApplication::translate("", "E2E_MNEMONIC_PASSPHRASE");
22812276

22822277
QInputDialog dialog;
2283-
dialog.setWindowTitle(tr("Enter E2E passphrase"));
2278+
dialog.setWindowTitle(tr(""));
2279+
dialog.setWindowFlags(Qt::WindowTitleHint | Qt::WindowCloseButtonHint);
22842280
dialog.setLabelText(msg);
22852281
dialog.setTextEchoMode(QLineEdit::Normal);
22862282

0 commit comments

Comments
 (0)