Messagelib

developertooldialog.cpp
1 /*
2  SPDX-FileCopyrightText: 2020-2021 Laurent Montel <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 #include "developertooldialog.h"
7 #include "developertoolwidget.h"
8 #include <KConfigGroup>
9 #include <KSharedConfig>
10 #include <QDialogButtonBox>
11 #include <QVBoxLayout>
12 
13 namespace
14 {
15 static const char myDeveloperToolDialogConfigGroupName[] = "DeveloperToolDialog";
16 }
17 
18 using namespace WebEngineViewer;
19 DeveloperToolDialog::DeveloperToolDialog(QWidget *parent)
20  : QDialog(parent)
21  , mDeveloperToolWidget(new DeveloperToolWidget(this))
22 {
23  auto mainLayout = new QVBoxLayout(this);
24  mainLayout->setObjectName(QStringLiteral("mainLayout"));
25 
26  mDeveloperToolWidget->setObjectName(QStringLiteral("mDeveloperToolWidget"));
27  mainLayout->addWidget(mDeveloperToolWidget);
28 
29  auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Close, this);
30  buttonBox->setObjectName(QStringLiteral("buttonBox"));
31  connect(buttonBox, &QDialogButtonBox::rejected, this, &DeveloperToolDialog::reject);
32  mainLayout->addWidget(buttonBox);
33  readConfig();
34 }
35 
36 DeveloperToolDialog::~DeveloperToolDialog()
37 {
38  writeConfig();
39 }
40 
41 QWebEnginePage *DeveloperToolDialog::enginePage() const
42 {
43  return mDeveloperToolWidget->enginePage();
44 }
45 
46 void DeveloperToolDialog::readConfig()
47 {
48  KConfigGroup group(KSharedConfig::openStateConfig(), myDeveloperToolDialogConfigGroupName);
49  const QSize sizeDialog = group.readEntry("Size", QSize(800, 600));
50  if (sizeDialog.isValid()) {
51  resize(sizeDialog);
52  }
53 }
54 
55 void DeveloperToolDialog::writeConfig()
56 {
57  KConfigGroup group(KSharedConfig::openStateConfig(), myDeveloperToolDialogConfigGroupName);
58  group.writeEntry("Size", size());
59 }
bool isValid() const const
static KSharedConfig::Ptr openStateConfig(const QString &fileName=QString())
void readConfig()
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Fri Nov 26 2021 23:16:41 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.