File indexing completed on 2024-10-13 06:40:00
0001 /* 0002 This file is part of the KDE libraries 0003 SPDX-FileCopyrightText: 2000 Reginald Stadlbauer <reggie@kde.org> 0004 SPDX-FileCopyrightText: 1997 Stephan Kulow <coolo@kde.org> 0005 SPDX-FileCopyrightText: 1997-2000 Sven Radej <radej@kde.org> 0006 SPDX-FileCopyrightText: 1997-2000 Matthias Ettrich <ettrich@kde.org> 0007 SPDX-FileCopyrightText: 1999 Chris Schlaeger <cs@kde.org> 0008 SPDX-FileCopyrightText: 2002 Joseph Wenninger <jowenn@kde.org> 0009 SPDX-FileCopyrightText: 2005-2006 Hamish Rodda <rodda@kde.org> 0010 0011 SPDX-License-Identifier: LGPL-2.0-only 0012 */ 0013 0014 #ifndef KMAINWINDOW_P_H 0015 #define KMAINWINDOW_P_H 0016 0017 #include <KConfigGroup> 0018 #include <KSharedConfig> 0019 #include <QEventLoopLocker> 0020 #include <QPointer> 0021 0022 class QObject; 0023 class QSessionManager; 0024 class QTimer; 0025 class KHelpMenu; 0026 class KMainWindow; 0027 0028 class KMainWindowPrivate 0029 { 0030 public: 0031 virtual ~KMainWindowPrivate() = default; 0032 0033 bool autoSaveSettings : 1; 0034 bool settingsDirty : 1; 0035 bool autoSaveWindowSize : 1; 0036 bool sizeApplied : 1; 0037 bool suppressCloseEvent : 1; 0038 0039 KConfigGroup autoSaveGroup; 0040 mutable KConfigGroup m_stateConfigGroup; 0041 inline KConfigGroup &getStateConfig() const 0042 { 0043 if (!m_stateConfigGroup.isValid()) { 0044 // Always use a separate state config here, consumers may override this with a custom/window-specific group 0045 m_stateConfigGroup = KSharedConfig::openStateConfig()->group(QStringLiteral("MainWindow")); 0046 } 0047 return m_stateConfigGroup; 0048 } 0049 inline void migrateStateDataIfNeeded(KConfigGroup &cg) 0050 { 0051 if (m_stateConfigGroup.isValid()) { 0052 // The window sizes are written in KWindowSystem and RestorePositionForNextInstance is only temporarily written until 0053 // all instances of the app are closed 0054 cg.moveValuesTo({"State"}, m_stateConfigGroup); 0055 } 0056 } 0057 0058 QTimer *settingsTimer; 0059 QTimer *sizeTimer; 0060 QRect defaultWindowSize; 0061 KHelpMenu *helpMenu; 0062 KMainWindow *q; 0063 QPointer<QObject> dockResizeListener; 0064 QString dbusName; 0065 bool letDirtySettings; 0066 QEventLoopLocker locker; 0067 0068 // This slot will be called when the style KCM changes settings that need 0069 // to be set on the already running applications. 0070 void _k_slotSettingsChanged(int category); 0071 void _k_slotSaveAutoSaveSize(); 0072 void _k_slotSaveAutoSavePosition(); 0073 0074 void init(KMainWindow *_q); 0075 void polish(KMainWindow *q); 0076 enum CallCompression { 0077 NoCompressCalls = 0, 0078 CompressCalls, 0079 }; 0080 void setSettingsDirty(CallCompression callCompression = NoCompressCalls); 0081 void setSizeDirty(); 0082 }; 0083 0084 class KMWSessionManager : public QObject 0085 { 0086 Q_OBJECT 0087 public: 0088 KMWSessionManager(); 0089 ~KMWSessionManager() override; 0090 0091 private: 0092 void saveState(QSessionManager &); 0093 void commitData(QSessionManager &); 0094 }; 0095 0096 #endif