2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2016-01-15 14:58:39 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-15 14:58:39 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2016-01-15 14:58:39 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2010-12-17 16:01:08 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2008-12-02 16:19:05 +01:00
|
|
|
|
2016-03-18 07:55:01 +01:00
|
|
|
#pragma once
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2012-08-20 18:52:20 +02:00
|
|
|
#include "fileutils.h"
|
2017-06-14 12:18:10 +02:00
|
|
|
#include "utils_global.h"
|
2012-08-20 18:52:20 +02:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QVariant>
|
2009-09-29 11:39:55 +02:00
|
|
|
|
2011-03-30 15:15:15 +02:00
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
class QWidget;
|
|
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
|
2011-08-16 10:45:23 +02:00
|
|
|
namespace Utils {
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2011-08-16 10:45:23 +02:00
|
|
|
class QTCREATOR_UTILS_EXPORT PersistentSettingsReader
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
PersistentSettingsReader();
|
2014-12-16 15:50:02 +01:00
|
|
|
QVariant restoreValue(const QString &variable, const QVariant &defaultValue = QVariant()) const;
|
2010-01-14 16:28:47 +01:00
|
|
|
QVariantMap restoreValues() const;
|
2012-08-20 18:52:20 +02:00
|
|
|
bool load(const FileName &fileName);
|
2010-01-19 16:57:29 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
private:
|
|
|
|
|
QMap<QString, QVariant> m_valueMap;
|
|
|
|
|
};
|
|
|
|
|
|
2011-08-16 10:45:23 +02:00
|
|
|
class QTCREATOR_UTILS_EXPORT PersistentSettingsWriter
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
public:
|
2012-08-17 13:18:31 +02:00
|
|
|
PersistentSettingsWriter(const FileName &fileName, const QString &docType);
|
2012-09-24 18:20:10 +02:00
|
|
|
~PersistentSettingsWriter();
|
|
|
|
|
|
2017-08-18 14:32:39 +02:00
|
|
|
bool save(const QVariantMap &data, QString *errorString) const;
|
|
|
|
|
#ifdef QT_GUI_LIB
|
2012-08-31 17:01:15 +02:00
|
|
|
bool save(const QVariantMap &data, QWidget *parent) const;
|
2017-08-18 14:32:39 +02:00
|
|
|
#endif
|
2012-08-17 13:18:31 +02:00
|
|
|
|
2014-07-15 23:33:17 +03:00
|
|
|
FileName fileName() const;
|
2010-01-19 16:57:29 +01:00
|
|
|
|
2018-02-27 16:03:33 +01:00
|
|
|
void setContents(const QVariantMap &data);
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
private:
|
2017-08-18 14:32:39 +02:00
|
|
|
bool write(const QVariantMap &data, QString *errorString) const;
|
2012-09-24 18:20:10 +02:00
|
|
|
|
2014-07-15 23:33:17 +03:00
|
|
|
const FileName m_fileName;
|
2012-08-17 13:18:31 +02:00
|
|
|
const QString m_docType;
|
2012-08-31 17:01:15 +02:00
|
|
|
mutable QMap<QString, QVariant> m_savedData;
|
2008-12-02 12:01:29 +01:00
|
|
|
};
|
|
|
|
|
|
2011-08-16 10:45:23 +02:00
|
|
|
} // namespace Utils
|