| 1 | /* |
| 2 | This file is part of the KDE libraries |
| 3 | SPDX-FileCopyrightText: 2000 Reginald Stadlbauer <reggie@kde.org> |
| 4 | SPDX-FileCopyrightText: 1997 Stephan Kulow <coolo@kde.org> |
| 5 | SPDX-FileCopyrightText: 1997-2000 Sven Radej <radej@kde.org> |
| 6 | SPDX-FileCopyrightText: 1997-2000 Matthias Ettrich <ettrich@kde.org> |
| 7 | SPDX-FileCopyrightText: 1999 Chris Schlaeger <cs@kde.org> |
| 8 | SPDX-FileCopyrightText: 2002 Joseph Wenninger <jowenn@kde.org> |
| 9 | SPDX-FileCopyrightText: 2005-2006 Hamish Rodda <rodda@kde.org> |
| 10 | |
| 11 | SPDX-License-Identifier: LGPL-2.0-only |
| 12 | */ |
| 13 | |
| 14 | #ifndef KMAINWINDOW_P_H |
| 15 | #define KMAINWINDOW_P_H |
| 16 | |
| 17 | #include <KConfigGroup> |
| 18 | #include <KSharedConfig> |
| 19 | #include <QEventLoopLocker> |
| 20 | #include <QPointer> |
| 21 | |
| 22 | class QObject; |
| 23 | class QSessionManager; |
| 24 | class QTimer; |
| 25 | class ; |
| 26 | class KMainWindow; |
| 27 | |
| 28 | class KMainWindowPrivate |
| 29 | { |
| 30 | public: |
| 31 | virtual ~KMainWindowPrivate() = default; |
| 32 | |
| 33 | bool autoSaveSettings : 1; |
| 34 | bool settingsDirty : 1; |
| 35 | bool autoSaveWindowSize : 1; |
| 36 | bool sizeApplied : 1; |
| 37 | bool suppressCloseEvent : 1; |
| 38 | |
| 39 | KConfigGroup autoSaveGroup; |
| 40 | mutable KConfigGroup m_stateConfigGroup; |
| 41 | inline KConfigGroup &getStateConfig() const |
| 42 | { |
| 43 | if (!m_stateConfigGroup.isValid()) { |
| 44 | // Always use a separate state config here, consumers may override this with a custom/window-specific group |
| 45 | m_stateConfigGroup = KSharedConfig::openStateConfig()->group(QStringLiteral("MainWindow" )); |
| 46 | } |
| 47 | return m_stateConfigGroup; |
| 48 | } |
| 49 | inline void migrateStateDataIfNeeded(KConfigGroup &cg) |
| 50 | { |
| 51 | if (m_stateConfigGroup.isValid()) { |
| 52 | // The window sizes are written in KWindowSystem and RestorePositionForNextInstance is only temporarily written until |
| 53 | // all instances of the app are closed |
| 54 | cg.moveValuesTo(keys: {"State" }, other&: m_stateConfigGroup); |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | QTimer *settingsTimer; |
| 59 | QTimer *sizeTimer; |
| 60 | QRect defaultWindowSize; |
| 61 | KHelpMenu *helpMenu; |
| 62 | KMainWindow *q; |
| 63 | QPointer<QObject> dockResizeListener; |
| 64 | QString dbusName; |
| 65 | bool letDirtySettings; |
| 66 | QEventLoopLocker locker; |
| 67 | |
| 68 | // This slot will be called when the style KCM changes settings that need |
| 69 | // to be set on the already running applications. |
| 70 | void _k_slotSettingsChanged(int category); |
| 71 | void _k_slotSaveAutoSaveSize(); |
| 72 | void _k_slotSaveAutoSavePosition(); |
| 73 | |
| 74 | void init(KMainWindow *_q); |
| 75 | void polish(KMainWindow *q); |
| 76 | enum CallCompression { |
| 77 | NoCompressCalls = 0, |
| 78 | CompressCalls, |
| 79 | }; |
| 80 | void setSettingsDirty(CallCompression callCompression = NoCompressCalls); |
| 81 | void setSizeDirty(); |
| 82 | }; |
| 83 | |
| 84 | class KMWSessionManager : public QObject |
| 85 | { |
| 86 | Q_OBJECT |
| 87 | public: |
| 88 | KMWSessionManager(); |
| 89 | ~KMWSessionManager() override; |
| 90 | |
| 91 | private: |
| 92 | void saveState(QSessionManager &); |
| 93 | void commitData(QSessionManager &); |
| 94 | }; |
| 95 | |
| 96 | #endif |
| 97 | |