Messagelib

trackingdetailsdialog.cpp
1 /*
2  SPDX-FileCopyrightText: 2017-2021 Laurent Montel <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #include "trackingdetailsdialog.h"
8 #include <KConfigGroup>
9 #include <KLocalizedString>
10 #include <KPIMTextEdit/RichTextEditorWidget>
11 #include <KSharedConfig>
12 #include <QDialogButtonBox>
13 #include <QPushButton>
14 #include <QVBoxLayout>
15 
16 using namespace WebEngineViewer;
17 namespace
18 {
19 static const char myMailTrackingDetailsDialogConfigGroupName[] = "MailTrackingDetailsDialog";
20 }
21 TrackingDetailsDialog::TrackingDetailsDialog(QWidget *parent)
22  : QDialog(parent)
23  , mDetails(new KPIMTextEdit::RichTextEditorWidget(this))
24 {
25  setWindowTitle(i18nc("@title:window", "Details"));
26  setAttribute(Qt::WA_DeleteOnClose);
27  setModal(false);
28 
29  auto mainLayout = new QVBoxLayout(this);
30  mainLayout->setObjectName(QStringLiteral("mainLayout"));
31 
32  auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Close, this);
33  buttonBox->setObjectName(QStringLiteral("buttonbox"));
34  connect(buttonBox, &QDialogButtonBox::rejected, this, &TrackingDetailsDialog::reject);
35  connect(buttonBox->button(QDialogButtonBox::Close), &QPushButton::clicked, this, &TrackingDetailsDialog::close);
36 
37  mDetails->setObjectName(QStringLiteral("detail"));
38  mainLayout->addWidget(mDetails);
39  mainLayout->addWidget(buttonBox);
40  mDetails->setReadOnly(true);
41  readConfig();
42 }
43 
44 TrackingDetailsDialog::~TrackingDetailsDialog()
45 {
46  writeConfig();
47 }
48 
49 void TrackingDetailsDialog::readConfig()
50 {
51  KConfigGroup group(KSharedConfig::openStateConfig(), myMailTrackingDetailsDialogConfigGroupName);
52  const QSize size = group.readEntry("Size", QSize(600, 400));
53  if (size.isValid()) {
54  resize(size);
55  }
56 }
57 
58 void TrackingDetailsDialog::writeConfig()
59 {
60  KConfigGroup group(KSharedConfig::openStateConfig(), myMailTrackingDetailsDialogConfigGroupName);
61  group.writeEntry("Size", size());
62  group.sync();
63 }
64 
65 void TrackingDetailsDialog::setDetails(const QString &details)
66 {
67  mDetails->setHtml(details);
68 }
bool isValid() const const
static KSharedConfig::Ptr openStateConfig(const QString &fileName=QString())
QString i18nc(const char *context, const char *text, const TYPE &arg...)
void clicked(bool checked)
WA_DeleteOnClose
void readConfig()
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue Nov 30 2021 23:05:48 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.