Messagelib

developertooldialog.cpp
1/*
2 SPDX-FileCopyrightText: 2020-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6#include "developertooldialog.h"
7#include "developertoolwidget.h"
8#include <KConfigGroup>
9#include <KLocalizedString>
10#include <KSharedConfig>
11#include <KWindowConfig>
12#include <QDialogButtonBox>
13#include <QVBoxLayout>
14#include <QWindow>
15
16namespace
17{
18static const char myDeveloperToolDialogConfigGroupName[] = "DeveloperToolDialog";
19}
20
21using namespace WebEngineViewer;
22DeveloperToolDialog::DeveloperToolDialog(QWidget *parent)
23 : QDialog(parent)
24 , mDeveloperToolWidget(new DeveloperToolWidget(this))
25{
26 setWindowTitle(i18nc("@title:window", "Developer Tool"));
27 auto mainLayout = new QVBoxLayout(this);
28 mainLayout->setObjectName(QLatin1StringView("mainLayout"));
29
30 mDeveloperToolWidget->setObjectName(QLatin1StringView("mDeveloperToolWidget"));
31 mainLayout->addWidget(mDeveloperToolWidget);
32
33 auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Close, this);
34 buttonBox->setObjectName(QLatin1StringView("buttonBox"));
35 connect(buttonBox, &QDialogButtonBox::rejected, this, &DeveloperToolDialog::reject);
36 connect(mDeveloperToolWidget, &DeveloperToolWidget::closeRequested, this, &DeveloperToolDialog::reject);
37 mainLayout->addWidget(buttonBox);
38 readConfig();
39}
40
41DeveloperToolDialog::~DeveloperToolDialog()
42{
43 writeConfig();
44}
45
46QWebEnginePage *DeveloperToolDialog::enginePage() const
47{
48 return mDeveloperToolWidget->enginePage();
49}
50
51void DeveloperToolDialog::readConfig()
52{
53 create(); // ensure a window is created
54 windowHandle()->resize(QSize(800, 600));
55 KConfigGroup group(KSharedConfig::openStateConfig(), QLatin1StringView(myDeveloperToolDialogConfigGroupName));
57 resize(windowHandle()->size()); // workaround for QTBUG-40584
58}
59
60void DeveloperToolDialog::writeConfig()
61{
62 KConfigGroup group(KSharedConfig::openStateConfig(), QLatin1StringView(myDeveloperToolDialogConfigGroupName));
64}
65
66#include "moc_developertooldialog.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)
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 Fri Oct 4 2024 11:53:55 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.