Page Menu
Home
GnuPG
Search
Configure Global Search
Log In
Files
F37926948
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Size
6 KB
Subscribers
None
View Options
diff --git a/client/emailviewer.cpp b/client/emailviewer.cpp
index de82616..0e7f9b5 100644
--- a/client/emailviewer.cpp
+++ b/client/emailviewer.cpp
@@ -1,147 +1,159 @@
// SPDX-FileCopyrightText: 2024 g10 code GmbH
// SPDX-Contributor: Carl Schwan <carl.schwan@gnupg.com>
// SPDX-License-Identifier: GPL-2.0-or-later
#include "emailviewer.h"
#include "editor/composerwindow.h"
#include "editor/composerwindowfactory.h"
#include "setupdialogs.h"
#include "websocketclient.h"
#include <Libkleo/Compliance>
#include <KColorScheme>
#include <KLocalizedString>
#include <KMessageDialog>
+#include <MimeTreeParserCore/UrlHandler>
#include <mimetreeparser_widgets_version.h>
#include <QApplication>
#include <QLabel>
#include <QMenuBar>
#include <QStatusBar>
#include <QToolBar>
#include <QToolButton>
#include <QToolTip>
#include <QVBoxLayout>
using namespace Qt::Literals::StringLiterals;
static KMime::Message::Ptr toMessage(const QString &content)
{
KMime::Message::Ptr message(new KMime::Message());
message->setContent(KMime::CRLFtoLF(content.toUtf8()));
message->parse();
return message;
}
EmailViewer::EmailViewer(const QString &content, const QString &accountEmail, const QString &displayName)
: MimeTreeParser::Widgets::MessageViewerWindow()
, m_email(accountEmail)
, m_displayName(displayName)
, m_secLevelButton(nullptr)
{
setMessages({toMessage(content)});
auto message = messages().at(0);
toolBar()->show();
auto messageMenu = menuBar()->findChild<QMenu *>("messageMenu");
Q_ASSERT(messageMenu);
messageMenu->addSeparator();
m_secLevelButton = new QToolButton();
connect(m_secLevelButton, &QToolButton::clicked, this, [this]() {
- KMessageDialog dialog(KMessageDialog::Information, m_secLevelInfo.details(), m_secLevelButton);
- dialog.setWindowTitle(m_secLevelInfo.shortText());
- dialog.setIcon(m_secLevelInfo.icon());
- dialog.exec();
+ // We need custom handling of links (to key info) in the dialog label, so cannot use KMessageDialog or similar
+ auto dialog = new QDialog(this);
+ auto vbox = new QVBoxLayout(dialog);
+ auto label = new QLabel(m_secLevelInfo.details());
+ connect(label, &QLabel::linkActivated, dialog, [dialog](const QString &link) {
+ UrlHandler().handleClick(QUrl(link), dialog->windowHandle());
+ dialog->accept();
+ });
+ vbox->addWidget(label);
+ auto buttonbox = new QDialogButtonBox(QDialogButtonBox::Ok);
+ connect(buttonbox, &QDialogButtonBox::accepted, dialog, &QDialog::accept);
+ vbox->addWidget(buttonbox);
+
+ dialog->setAttribute(Qt::WA_DeleteOnClose);
+ dialog->exec();
});
updateSecLevel();
toolBar()->insertWidget(toolBar()->actions().value(0), m_secLevelButton);
// spacer
QWidget *spacer = new QWidget();
spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
toolBar()->addWidget(spacer);
// reply
auto replyAction = new QAction(QIcon::fromTheme(u"mail-reply-sender-symbolic"_s), i18nc("@action:button", "Reply"), toolBar());
connect(replyAction, &QAction::triggered, this, [this](bool) {
auto dialog = ComposerWindowFactory::self().create(m_email, m_displayName);
dialog->reply(messages().at(0));
DialogController::strongActivateWindow(dialog);
});
toolBar()->addAction(replyAction);
messageMenu->addAction(replyAction);
auto widget = qobject_cast<QToolButton *>(toolBar()->widgetForAction(replyAction));
widget->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
// forward
auto forwardAction = new QAction(QIcon::fromTheme(u"mail-forward-symbolic"_s), i18nc("@action:button", "Forward"), toolBar());
connect(forwardAction, &QAction::triggered, this, [this](bool) {
auto dialog = ComposerWindowFactory::self().create(m_email, m_displayName);
dialog->reply(messages().at(0));
DialogController::strongActivateWindow(dialog);
});
toolBar()->addAction(forwardAction);
messageMenu->addAction(forwardAction);
widget = qobject_cast<QToolButton *>(toolBar()->widgetForAction(forwardAction));
widget->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
#if MIMETREEPARSER_WIDGETS_VERSION >= QT_VERSION_CHECK(6, 5, 0)
if (Kleo::DeVSCompliance::isActive()) {
auto statusBar = new QStatusBar(this);
auto statusLbl = std::make_unique<QLabel>(Kleo::DeVSCompliance::name());
{
auto statusPalette = qApp->palette();
KColorScheme::adjustForeground(statusPalette,
Kleo::DeVSCompliance::isCompliant() ? KColorScheme::NormalText : KColorScheme::NegativeText,
statusLbl->foregroundRole(),
KColorScheme::View);
statusLbl->setAutoFillBackground(true);
KColorScheme::adjustBackground(statusPalette,
Kleo::DeVSCompliance::isCompliant() ? KColorScheme::PositiveBackground : KColorScheme::NegativeBackground,
QPalette::Window,
KColorScheme::View);
statusLbl->setPalette(statusPalette);
}
statusBar->addPermanentWidget(statusLbl.release());
setStatusBar(statusBar);
}
#endif
}
void EmailViewer::closeEvent(QCloseEvent *event)
{
MimeTreeParser::Widgets::MessageViewerWindow::closeEvent(event);
WebsocketClient::self().sendStatusUpdate(true);
}
void EmailViewer::showEvent(QShowEvent *event)
{
MimeTreeParser::Widgets::MessageViewerWindow::showEvent(event);
WebsocketClient::self().sendStatusUpdate();
}
void EmailViewer::view(const QString &content, const QString &accountEmail, const QString &displayName)
{
m_email = accountEmail;
m_displayName = displayName;
setMessages({toMessage(content)});
updateSecLevel();
toolBar()->show();
}
void EmailViewer::updateSecLevel()
{
m_secLevelInfo = SecurityLevelInfo(messages().at(0));
m_secLevelButton->setText(m_secLevelInfo.shortText());
m_secLevelButton->setIcon(m_secLevelInfo.icon());
m_secLevelButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
m_secLevelButton->setToolTip(m_secLevelInfo.details());
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Thu, Mar 19, 5:35 AM (1 d, 10 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
2b/62/7f8dea4462df036e54d5b3c96910
Attached To
rOJ GpgOL.js
Event Timeline
Log In to Comment