KConfig

kwindowstatesaverquick.cpp
1// SPDX-FileCopyrightText: 2024 Joshua Goins <josh@redstrate.com>
2// SPDX-License-Identifier: LGPL-2.0-or-later
3
4#include "kwindowstatesaverquick.h"
5#include "kconfig_qml_log_settings.h"
6
7#include <QQuickItem>
8#include <QQuickWindow>
9
10#include <KWindowStateSaver>
11
12void KWindowStateSaverQuick::classBegin()
13{
14}
15
16void KWindowStateSaverQuick::componentComplete()
17{
18 const auto parentItem = qobject_cast<QQuickItem *>(parent());
19 if (!parentItem) {
20 qCWarning(KCONFIG_QML_LOG) << "WindowStateSaver requires a parent item";
21 return;
22 }
23
24 const auto window = qobject_cast<QWindow *>(parentItem->window());
25 if (!window) {
26 qCWarning(KCONFIG_QML_LOG) << "WindowStateSaver requires the parent to be a type that inherits QWindow";
27 return;
28 }
29
30 new KWindowStateSaver(window, m_configGroupName);
31}
32
33void KWindowStateSaverQuick::setConfigGroupName(const QString &name)
34{
35 if (m_configGroupName != name) {
36 m_configGroupName = name;
37 Q_EMIT configGroupNameChanged();
38 }
39}
40
41QString KWindowStateSaverQuick::configGroupName() const
42{
43 return m_configGroupName;
44}
45
46#include "moc_kwindowstatesaverquick.cpp"
Saves and restores a window size and (when possible) position.
QString name(GameStandardAction id)
QWidget * window(QObject *job)
Q_EMITQ_EMIT
QObject * parent() const const
T qobject_cast(QObject *object)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jul 26 2024 11:52:48 by doxygen 1.11.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.