Pimcommon

whatsnewdialog.cpp
1/*
2 SPDX-FileCopyrightText: 2023-2024 Laurent Montel <montel.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "whatsnewdialog.h"
8#include "whatsnewwidget.h"
9
10#include <KConfigGroup>
11#include <KLocalizedString>
12#include <KSharedConfig>
13#include <KWindowConfig>
14#include <QCoreApplication>
15#include <QDialogButtonBox>
16#include <QVBoxLayout>
17#include <QWindow>
18namespace
19{
20const char myWhatsNewDialogGroupName[] = "WhatsNewDialog";
21}
22using namespace PimCommon;
23WhatsNewDialog::WhatsNewDialog(const QList<PimCommon::WhatsNewInfo> &infos, QWidget *parent)
24 : QDialog(parent)
25 , mWhatsNewWidget(new WhatsNewWidget(infos, this))
26{
27 setWindowTitle(i18nc("@title:window", "What's new in %1", QCoreApplication::applicationName()));
28 auto mainLayout = new QVBoxLayout(this);
29 mainLayout->setObjectName(QStringLiteral("mainLayout"));
30
31 mWhatsNewWidget->setObjectName(QStringLiteral("mWhatsNewWidget"));
32 mainLayout->addWidget(mWhatsNewWidget);
33
34 auto button = new QDialogButtonBox(QDialogButtonBox::Close, this);
35 button->setObjectName(QStringLiteral("button"));
36 mainLayout->addWidget(button);
37 connect(button, &QDialogButtonBox::rejected, this, &WhatsNewDialog::reject);
38 readConfig();
39}
40
41WhatsNewDialog::~WhatsNewDialog()
42{
43 writeConfig();
44}
45
46void WhatsNewDialog::readConfig()
47{
48 create(); // ensure a window is created
49 windowHandle()->resize(QSize(400, 300));
50 KConfigGroup group(KSharedConfig::openStateConfig(), QLatin1StringView(myWhatsNewDialogGroupName));
52 resize(windowHandle()->size()); // workaround for QTBUG-40584
53}
54
55void WhatsNewDialog::writeConfig()
56{
57 KConfigGroup group(KSharedConfig::openStateConfig(), QLatin1StringView(myWhatsNewDialogGroupName));
59}
60
61void WhatsNewDialog::updateInformations()
62{
63 mWhatsNewWidget->updateInformations();
64}
65
66#include "moc_whatsnewdialog.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)
folderdialogacltab.h
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 18 2024 12:14:35 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.