KTextAddons

grammalecteconfigdialog.cpp
1/*
2 SPDX-FileCopyrightText: 2019-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#include "grammalecteconfigdialog.h"
8#include "grammalecteconfigwidget.h"
9#include <KConfigGroup>
10#include <KLocalizedString>
11#include <KSharedConfig>
12#include <KWindowConfig>
13#include <QDialogButtonBox>
14#include <QVBoxLayout>
15#include <QWindow>
16namespace
17{
18static const char myConfigGrammalecteConfigDialog[] = "GrammalecteConfigDialog";
19}
20using namespace TextGrammarCheck;
21GrammalecteConfigDialog::GrammalecteConfigDialog(QWidget *parent, bool disableMessageBox)
22 : QDialog(parent)
23 , mConfigWidget(new GrammalecteConfigWidget(this, disableMessageBox))
24{
25 setWindowTitle(i18nc("@title:window", "Configure Grammalecte"));
26 auto mainLayout = new QVBoxLayout(this);
27 mainLayout->setObjectName(QStringLiteral("mainlayout"));
28
29 mConfigWidget->setObjectName(QStringLiteral("configwidget"));
30 mainLayout->addWidget(mConfigWidget);
31
33 box->setObjectName(QStringLiteral("box"));
34 mainLayout->addWidget(box);
35 connect(box, &QDialogButtonBox::accepted, this, &GrammalecteConfigDialog::accept);
36 connect(box, &QDialogButtonBox::rejected, this, &GrammalecteConfigDialog::reject);
37 readConfig();
38}
39
40GrammalecteConfigDialog::~GrammalecteConfigDialog()
41{
42 writeConfig();
43}
44
45void GrammalecteConfigDialog::writeConfig()
46{
47 KConfigGroup group(KSharedConfig::openStateConfig(), QLatin1StringView(myConfigGrammalecteConfigDialog));
49}
50
51void GrammalecteConfigDialog::readConfig()
52{
53 create(); // ensure a window is created
54 windowHandle()->resize(QSize(500, 300));
55 KConfigGroup group(KSharedConfig::openStateConfig(), QLatin1StringView(myConfigGrammalecteConfigDialog));
57 resize(windowHandle()->size()); // workaround for QTBUG-40584
58}
59
60#include "moc_grammalecteconfigdialog.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 Mon Nov 4 2024 16:29:59 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.