File indexing completed on 2024-05-19 05:19:22
0001 /* 0002 SPDX-FileCopyrightText: 2008 Volker Krause <vkrause@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #ifndef UISTATESAVER_H 0008 #define UISTATESAVER_H 0009 0010 class QWidget; 0011 class KConfigGroup; 0012 0013 namespace KJots { 0014 /** 0015 * @short Methods to save and restore the UI state of an application. 0016 * 0017 * This namespace provides methods that automatically save and restore 0018 * the state of various UI elements to/from a configuration group. 0019 * 0020 * The following widgets are supported so far: 0021 * - QSplitter 0022 * - QTabWidget 0023 * - QTreeView 0024 * - QComboBox 0025 * 0026 * @note The widgets need to have set an objectName, otherwise they are ignored 0027 * on processing. 0028 * 0029 * @author Volker Krause <vkrause@kde.org> 0030 * @since 4.5 0031 */ 0032 namespace UiStateSaver { 0033 /** 0034 * Saves the state of @p widget and all its sub-widgets to @p config. 0035 * @param widget The top-level widget which state should be saved. 0036 * @param config The config group the settings should be written to. 0037 */ 0038 void saveState(QWidget *widget, KConfigGroup &config); 0039 0040 /** 0041 * Restores the UI state of @p widget and all its sub-widgets from @p config. 0042 * @param widget The top-level widget which state should be restored. 0043 * @param config The config gorup the settings should be read from. 0044 */ 0045 void restoreState(QWidget *widget, const KConfigGroup &config); 0046 } 0047 } 0048 0049 #endif