Messagelib

trackingdetailsdialog.cpp
1/*
2 SPDX-FileCopyrightText: 2017-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "trackingdetailsdialog.h"
8#include <KConfigGroup>
9#include <KLocalizedString>
10#include <KSharedConfig>
11#include <KWindowConfig>
12#include <QDialogButtonBox>
13#include <QPushButton>
14#include <QVBoxLayout>
15#include <QWindow>
16#include <TextCustomEditor/RichTextEditorWidget>
17
18using namespace WebEngineViewer;
19namespace
20{
21static const char myMailTrackingDetailsDialogConfigGroupName[] = "MailTrackingDetailsDialog";
22}
23TrackingDetailsDialog::TrackingDetailsDialog(QWidget *parent)
24 : QDialog(parent)
25 , mDetails(new TextCustomEditor::RichTextEditorWidget(this))
26{
27 setWindowTitle(i18nc("@title:window", "Details"));
28 setAttribute(Qt::WA_DeleteOnClose);
29 setModal(false);
30
31 auto mainLayout = new QVBoxLayout(this);
32 mainLayout->setObjectName(QLatin1StringView("mainLayout"));
33
34 auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Close, this);
35 buttonBox->setObjectName(QLatin1StringView("buttonbox"));
36 connect(buttonBox, &QDialogButtonBox::rejected, this, &TrackingDetailsDialog::reject);
37 connect(buttonBox->button(QDialogButtonBox::Close), &QPushButton::clicked, this, &TrackingDetailsDialog::close);
38
39 mDetails->setObjectName(QLatin1StringView("detail"));
40 mainLayout->addWidget(mDetails);
41 mainLayout->addWidget(buttonBox);
42 mDetails->setReadOnly(true);
43 readConfig();
44}
45
46TrackingDetailsDialog::~TrackingDetailsDialog()
47{
48 writeConfig();
49}
50
51void TrackingDetailsDialog::readConfig()
52{
53 create(); // ensure a window is created
54 windowHandle()->resize(QSize(600, 400));
55 KConfigGroup group(KSharedConfig::openStateConfig(), QLatin1StringView(myMailTrackingDetailsDialogConfigGroupName));
57 resize(windowHandle()->size()); // workaround for QTBUG-40584
58}
59
60void TrackingDetailsDialog::writeConfig()
61{
62 KConfigGroup group(KSharedConfig::openStateConfig(), QLatin1StringView(myMailTrackingDetailsDialogConfigGroupName));
64}
65
66void TrackingDetailsDialog::setDetails(const QString &details)
67{
68 mDetails->setHtml(details);
69}
70
71#include "moc_trackingdetailsdialog.cpp"
static KSharedConfig::Ptr openStateConfig(const QString &fileName=QString())
QString i18nc(const char *context, const char *text, const TYPE &arg...)
KCONFIGGUI_EXPORT void saveWindowSize(const QWindow *window, KConfigGroup &config, KConfigGroup::WriteConfigFlags options=KConfigGroup::Normal)
KCONFIGGUI_EXPORT void restoreWindowSize(QWindow *window, const KConfigGroup &config)
void clicked(bool checked)
WA_DeleteOnClose
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
void create(WId window, bool initializeWindow, bool destroyOldWindow)
void resize(const QSize &)
QWindow * windowHandle() const const
void resize(const QSize &newSize)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:33:26 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.