2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2009-03-26 18:02:43 +01:00
|
|
|
**
|
2016-01-15 14:58:39 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2009-03-26 18:02:43 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2009-03-26 18:02:43 +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.
|
2009-03-26 18:02:43 +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
|
|
|
****************************************************************************/
|
2009-03-26 18:02:43 +01:00
|
|
|
|
2016-03-18 07:55:01 +01:00
|
|
|
#pragma once
|
2009-03-26 18:02:43 +01:00
|
|
|
|
|
|
|
|
#include "utils_global.h"
|
|
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QAction>
|
2009-03-26 18:02:43 +01:00
|
|
|
|
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
class QSettings;
|
|
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
|
|
|
|
|
namespace Utils {
|
|
|
|
|
|
|
|
|
|
enum ApplyMode { ImmediateApply, DeferedApply };
|
|
|
|
|
|
2009-05-08 12:09:21 +02:00
|
|
|
class QTCREATOR_UTILS_EXPORT SavedAction : public QAction
|
2009-03-26 18:02:43 +01:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
SavedAction(QObject *parent = 0);
|
|
|
|
|
|
2015-02-27 18:26:31 +01:00
|
|
|
QVariant value() const;
|
2015-05-29 11:55:16 +02:00
|
|
|
void setValue(const QVariant &value, bool doemit = true);
|
2009-03-26 18:02:43 +01:00
|
|
|
|
2015-02-27 18:26:31 +01:00
|
|
|
QVariant defaultValue() const;
|
2015-05-29 11:55:16 +02:00
|
|
|
void setDefaultValue(const QVariant &value);
|
2009-03-26 18:02:43 +01:00
|
|
|
|
2015-05-29 11:55:16 +02:00
|
|
|
void trigger(const QVariant &data);
|
2009-03-26 18:02:43 +01:00
|
|
|
|
|
|
|
|
// used for persistency
|
2015-02-27 18:26:31 +01:00
|
|
|
QString settingsKey() const;
|
2015-05-29 11:55:16 +02:00
|
|
|
void setSettingsKey(const QString &key);
|
|
|
|
|
void setSettingsKey(const QString &group, const QString &key);
|
2009-03-26 18:02:43 +01:00
|
|
|
|
2015-02-27 18:26:31 +01:00
|
|
|
QString settingsGroup() const;
|
2015-05-29 11:55:16 +02:00
|
|
|
void setSettingsGroup(const QString &group);
|
2009-03-26 18:02:43 +01:00
|
|
|
|
2009-11-24 15:05:02 +01:00
|
|
|
virtual void readSettings(const QSettings *settings);
|
2015-05-29 11:55:16 +02:00
|
|
|
virtual void writeSettings(QSettings *settings);
|
2010-01-29 21:33:57 +01:00
|
|
|
|
2015-02-27 18:26:31 +01:00
|
|
|
void connectWidget(QWidget *widget, ApplyMode applyMode = DeferedApply);
|
|
|
|
|
void disconnectWidget();
|
2015-05-29 11:55:16 +02:00
|
|
|
void apply(QSettings *settings);
|
2009-03-26 18:02:43 +01:00
|
|
|
|
|
|
|
|
QString toString() const;
|
|
|
|
|
|
2015-05-29 11:06:10 +02:00
|
|
|
QString dialogText() const;
|
|
|
|
|
void setDialogText(const QString &dialogText);
|
|
|
|
|
|
2009-03-26 18:02:43 +01:00
|
|
|
signals:
|
|
|
|
|
void valueChanged(const QVariant &newValue);
|
|
|
|
|
|
|
|
|
|
private:
|
2015-02-27 18:26:31 +01:00
|
|
|
void actionTriggered(bool);
|
2009-03-26 18:02:43 +01:00
|
|
|
|
|
|
|
|
QVariant m_value;
|
|
|
|
|
QVariant m_defaultValue;
|
|
|
|
|
QString m_settingsKey;
|
|
|
|
|
QString m_settingsGroup;
|
2015-05-29 11:06:10 +02:00
|
|
|
QString m_dialogText;
|
2009-03-26 18:02:43 +01:00
|
|
|
QWidget *m_widget;
|
|
|
|
|
};
|
|
|
|
|
|
2009-05-08 12:09:21 +02:00
|
|
|
class QTCREATOR_UTILS_EXPORT SavedActionSet
|
2009-03-26 18:02:43 +01:00
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
SavedActionSet() {}
|
|
|
|
|
~SavedActionSet() {}
|
|
|
|
|
|
|
|
|
|
void insert(SavedAction *action, QWidget *widget);
|
|
|
|
|
void apply(QSettings *settings);
|
|
|
|
|
void finish();
|
|
|
|
|
void clear() { m_list.clear(); }
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
QList<SavedAction *> m_list;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Utils
|