File indexing completed on 2024-05-12 16:02:28
0001 /* 0002 * SPDX-FileCopyrightText: 2019 Boudewijn Rempt <boud@kde.org> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 #ifndef KISDIALOGSTATESAVER_H 0007 #define KISDIALOGSTATESAVER_H 0008 0009 #include "kritawidgetutils_export.h" 0010 0011 #include <QWidget> 0012 #include <QString> 0013 #include <QMap> 0014 #include <QVariant> 0015 0016 /** 0017 * @brief The KisDialogStateSaver class saves state for the specified 0018 * widget in the kritarc file and restores it. Simply call saveState 0019 * in your dialog's destructor, and use restoreState in the constructor. 0020 */ 0021 namespace KisDialogStateSaver 0022 { 0023 /** 0024 * @brief saveState saves the state for the specified widgets 0025 * @param parent the parent at the top of the QObject hierarchy that contains the child widgets 0026 * @param dialogName the name for the section under which we will save the state 0027 * @return true if all the widgets could be saved, false if there was a problem 0028 */ 0029 KRITAWIDGETUTILS_EXPORT void saveState(QWidget *parent, const QString &dialogName); 0030 0031 /** 0032 * @brief restoreState restores the state of the dialog 0033 * @param parent the parent at the top of the QObject hierarchy that contains the child widgets 0034 * @param dialogName the name for the section under which we will restore the state 0035 * @param defaults: contains default values for widgets. This overrides what is stored in the config 0036 * file. If there is no value in the config file, and no default specified, the value set for 0037 * the widget (for instance in the ui file) will be used. 0038 * @return true if all the widgets could be restored, false if there was a problem 0039 */ 0040 KRITAWIDGETUTILS_EXPORT void restoreState(QWidget *parent, const QString &dialogName, const QMap<QString, QVariant> &defaults = QMap<QString, QVariant>()); 0041 }; 0042 0043 #endif // KISDIALOGSTATESAVER_H