2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2010-02-09 11:09:11 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2010-02-09 11:09:11 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2010-02-09 11:09:11 +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:57:40 +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.
|
2010-02-09 11:09:11 +01:00
|
|
|
**
|
2015-09-18 11:34:48 +02:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
2016-01-15 14:57:40 +01:00
|
|
|
** 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
|
|
|
****************************************************************************/
|
2010-02-09 11:09:11 +01:00
|
|
|
|
|
|
|
|
#include "designersettings.h"
|
|
|
|
|
|
2017-01-19 13:46:37 +01:00
|
|
|
#include <qmldesignerplugin.h>
|
|
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QSettings>
|
2010-02-09 11:09:11 +01:00
|
|
|
|
2016-01-13 14:48:40 +01:00
|
|
|
namespace QmlDesigner {
|
|
|
|
|
|
|
|
|
|
namespace DesignerSettingsGroupKey {
|
|
|
|
|
const char QML_SETTINGS_GROUP[] = "QML";
|
|
|
|
|
const char QML_DESIGNER_SETTINGS_GROUP[] = "Designer";
|
|
|
|
|
}
|
2010-02-09 11:09:11 +01:00
|
|
|
|
2018-07-24 23:56:45 +02:00
|
|
|
DesignerSettings::DesignerSettings() = default;
|
2016-01-13 14:48:40 +01:00
|
|
|
|
|
|
|
|
void DesignerSettings::restoreValue(QSettings *settings, const QByteArray &key, const QVariant &defaultValue)
|
|
|
|
|
{
|
|
|
|
|
insert(key, settings->value(QString::fromLatin1(key), defaultValue));
|
|
|
|
|
}
|
2010-06-11 13:40:32 +10:00
|
|
|
|
2010-02-09 11:09:11 +01:00
|
|
|
void DesignerSettings::fromSettings(QSettings *settings)
|
|
|
|
|
{
|
2016-01-13 14:48:40 +01:00
|
|
|
settings->beginGroup(QLatin1String(DesignerSettingsGroupKey::QML_SETTINGS_GROUP));
|
|
|
|
|
settings->beginGroup(QLatin1String(DesignerSettingsGroupKey::QML_DESIGNER_SETTINGS_GROUP));
|
2015-07-16 11:49:50 +02:00
|
|
|
|
2016-01-13 14:48:40 +01:00
|
|
|
restoreValue(settings, DesignerSettingsKey::ITEMSPACING, 6);
|
|
|
|
|
restoreValue(settings, DesignerSettingsKey::CONTAINERPADDING, 8);
|
2020-11-25 08:22:33 +01:00
|
|
|
restoreValue(settings, DesignerSettingsKey::CANVASWIDTH, 40000);
|
|
|
|
|
restoreValue(settings, DesignerSettingsKey::CANVASHEIGHT, 40000);
|
2017-04-26 16:31:36 +02:00
|
|
|
restoreValue(settings, DesignerSettingsKey::ROOT_ELEMENT_INIT_WIDTH, 640);
|
|
|
|
|
restoreValue(settings, DesignerSettingsKey::ROOT_ELEMENT_INIT_HEIGHT, 480);
|
2016-01-13 14:48:40 +01:00
|
|
|
restoreValue(settings, DesignerSettingsKey::WARNING_FOR_FEATURES_IN_DESIGNER, true);
|
2016-06-23 15:09:32 +02:00
|
|
|
restoreValue(settings, DesignerSettingsKey::WARNING_FOR_QML_FILES_INSTEAD_OF_UIQML_FILES, true);
|
2016-01-13 14:48:40 +01:00
|
|
|
restoreValue(settings, DesignerSettingsKey::WARNING_FOR_DESIGNER_FEATURES_IN_EDITOR, false);
|
|
|
|
|
restoreValue(settings, DesignerSettingsKey::SHOW_DEBUGVIEW, false);
|
|
|
|
|
restoreValue(settings, DesignerSettingsKey::ENABLE_DEBUGVIEW, false);
|
2020-09-07 13:35:55 +03:00
|
|
|
restoreValue(settings, DesignerSettingsKey::ALWAYS_SAVE_IN_CRUMBLEBAR, false);
|
2018-10-24 13:40:59 +02:00
|
|
|
restoreValue(settings, DesignerSettingsKey::USE_DEFAULT_PUPPET, true);
|
2017-02-10 15:49:35 +01:00
|
|
|
restoreValue(settings, DesignerSettingsKey::TYPE_OF_QSTR_FUNCTION, 0);
|
2018-10-24 13:40:59 +02:00
|
|
|
restoreValue(settings, DesignerSettingsKey::PUPPET_DEFAULT_DIRECTORY);
|
2016-01-13 14:48:40 +01:00
|
|
|
restoreValue(settings, DesignerSettingsKey::PUPPET_TOPLEVEL_BUILD_DIRECTORY);
|
|
|
|
|
restoreValue(settings, DesignerSettingsKey::CONTROLS_STYLE);
|
2016-01-19 15:05:40 +01:00
|
|
|
restoreValue(settings, DesignerSettingsKey::SHOW_PROPERTYEDITOR_WARNINGS, false);
|
|
|
|
|
restoreValue(settings, DesignerSettingsKey::ENABLE_MODEL_EXCEPTION_OUTPUT, false);
|
2019-12-17 10:44:13 +01:00
|
|
|
restoreValue(settings, DesignerSettingsKey::PUPPET_KILL_TIMEOUT, 30000); // this has no ui at the moment
|
2016-01-19 15:05:40 +01:00
|
|
|
restoreValue(settings, DesignerSettingsKey::DEBUG_PUPPET, QString());
|
|
|
|
|
restoreValue(settings, DesignerSettingsKey::FORWARD_PUPPET_OUTPUT, QString());
|
2016-10-07 12:15:33 +02:00
|
|
|
restoreValue(settings, DesignerSettingsKey::REFORMAT_UI_QML_FILES, true);
|
2017-03-10 10:39:18 +01:00
|
|
|
restoreValue(settings, DesignerSettingsKey::IGNORE_DEVICE_PIXEL_RATIO, false);
|
2017-09-26 12:38:38 +02:00
|
|
|
restoreValue(settings, DesignerSettingsKey::NAVIGATOR_SHOW_ONLY_VISIBLE_ITEMS, true);
|
2020-09-17 14:44:21 +02:00
|
|
|
restoreValue(settings, DesignerSettingsKey::NAVIGATOR_REVERSE_ITEM_ORDER, false);
|
2021-03-09 16:56:25 +01:00
|
|
|
restoreValue(settings, DesignerSettingsKey::ENABLE_TIMELINEVIEW, true);
|
2021-06-21 16:48:19 +02:00
|
|
|
restoreValue(settings, DesignerSettingsKey::COLOR_PALETTE_RECENT, QStringList());
|
|
|
|
|
restoreValue(settings, DesignerSettingsKey::COLOR_PALETTE_FAVORITE, QStringList());
|
2019-10-30 12:16:25 +01:00
|
|
|
restoreValue(settings, DesignerSettingsKey::ALWAYS_DESIGN_MODE, true);
|
2021-09-07 11:23:57 +03:00
|
|
|
restoreValue(settings, DesignerSettingsKey::DISABLE_ITEM_LIBRARY_UPDATE_TIMER, false);
|
2021-07-02 15:10:40 +03:00
|
|
|
restoreValue(settings, DesignerSettingsKey::ASK_BEFORE_DELETING_ASSET, true);
|
2012-10-26 13:57:58 +02:00
|
|
|
|
2010-02-09 11:09:11 +01:00
|
|
|
settings->endGroup();
|
|
|
|
|
settings->endGroup();
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-13 14:48:40 +01:00
|
|
|
void DesignerSettings::storeValue(QSettings *settings, const QByteArray &key, const QVariant &value) const
|
|
|
|
|
{
|
|
|
|
|
if (key.isEmpty())
|
|
|
|
|
return;
|
|
|
|
|
settings->setValue(QString::fromLatin1(key), value);
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-09 11:09:11 +01:00
|
|
|
void DesignerSettings::toSettings(QSettings *settings) const
|
|
|
|
|
{
|
2016-01-13 14:48:40 +01:00
|
|
|
settings->beginGroup(QLatin1String(DesignerSettingsGroupKey::QML_SETTINGS_GROUP));
|
|
|
|
|
settings->beginGroup(QLatin1String(DesignerSettingsGroupKey::QML_DESIGNER_SETTINGS_GROUP));
|
|
|
|
|
|
|
|
|
|
QHash<QByteArray, QVariant>::const_iterator i = constBegin();
|
|
|
|
|
while (i != constEnd()) {
|
|
|
|
|
storeValue(settings, i.key(), i.value());
|
|
|
|
|
++i;
|
|
|
|
|
}
|
2012-10-26 13:57:58 +02:00
|
|
|
|
2010-02-09 11:09:11 +01:00
|
|
|
settings->endGroup();
|
|
|
|
|
settings->endGroup();
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-19 13:46:37 +01:00
|
|
|
QVariant DesignerSettings::getValue(const QByteArray &key)
|
|
|
|
|
{
|
|
|
|
|
DesignerSettings settings = QmlDesignerPlugin::instance()->settings();
|
|
|
|
|
return settings.value(key);
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-17 16:17:02 +01:00
|
|
|
void DesignerSettings::setValue(const QByteArray &key, const QVariant &value)
|
|
|
|
|
{
|
|
|
|
|
DesignerSettings settings = QmlDesignerPlugin::instance()->settings();
|
|
|
|
|
settings.insert(key, value);
|
|
|
|
|
QmlDesignerPlugin::instance()->setSettings(settings);
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-13 14:48:40 +01:00
|
|
|
} // namespace QmlDesigner
|