2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2010-02-09 11:09:11 +01:00
|
|
|
**
|
2013-01-28 17:12:19 +01:00
|
|
|
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
2012-10-02 09:12:39 +02:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
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
|
|
|
|
|
** a written agreement between you and Digia. For licensing terms and
|
|
|
|
|
** conditions see http://qt.digia.com/licensing. For further information
|
|
|
|
|
** use the contact form at http://qt.digia.com/contact-us.
|
2010-02-09 11:09:11 +01:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
|
|
|
** General Public License version 2.1 as published by the Free Software
|
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
|
|
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
|
|
|
**
|
|
|
|
|
** In addition, as a special exception, Digia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2010-02-09 11:09:11 +01:00
|
|
|
|
|
|
|
|
#include "designersettings.h"
|
2010-03-16 16:51:45 +01:00
|
|
|
#include "qmldesignerconstants.h"
|
2010-02-09 11:09:11 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QSettings>
|
2010-02-09 11:09:11 +01:00
|
|
|
|
|
|
|
|
using namespace QmlDesigner;
|
|
|
|
|
|
2010-02-09 16:01:47 +01:00
|
|
|
DesignerSettings::DesignerSettings()
|
2010-06-11 13:40:32 +10:00
|
|
|
: openDesignMode(QmlDesigner::Constants::QML_OPENDESIGNMODE_DEFAULT),
|
|
|
|
|
itemSpacing(0),
|
2011-03-02 16:20:36 +01:00
|
|
|
snapMargin(0),
|
|
|
|
|
canvasWidth(10000),
|
2012-10-26 13:57:58 +02:00
|
|
|
canvasHeight(10000),
|
|
|
|
|
warningsInDesigner(true),
|
2013-03-14 16:02:19 +01:00
|
|
|
designerWarningsInEditor(false),
|
|
|
|
|
showDebugView(false),
|
|
|
|
|
enableDebugView(false)
|
2010-02-09 16:01:47 +01:00
|
|
|
{}
|
2010-06-11 13:40:32 +10:00
|
|
|
|
2010-02-09 11:09:11 +01:00
|
|
|
void DesignerSettings::fromSettings(QSettings *settings)
|
|
|
|
|
{
|
2010-03-16 16:51:45 +01:00
|
|
|
settings->beginGroup(QLatin1String(QmlDesigner::Constants::QML_SETTINGS_GROUP));
|
|
|
|
|
settings->beginGroup(QLatin1String(QmlDesigner::Constants::QML_DESIGNER_SETTINGS_GROUP));
|
|
|
|
|
openDesignMode = settings->value(
|
|
|
|
|
QLatin1String(QmlDesigner::Constants::QML_OPENDESIGNMODE_SETTINGS_KEY),
|
|
|
|
|
bool(QmlDesigner::Constants::QML_OPENDESIGNMODE_DEFAULT)).toBool();
|
2010-04-08 16:26:45 +02:00
|
|
|
itemSpacing = settings->value(
|
2013-05-15 17:16:04 +02:00
|
|
|
QLatin1String(QmlDesigner::Constants::QML_ITEMSPACING_KEY), QVariant(6)).toInt();
|
2010-04-08 16:26:45 +02:00
|
|
|
snapMargin = settings->value(
|
2013-05-15 17:16:04 +02:00
|
|
|
QLatin1String(QmlDesigner::Constants::QML_SNAPMARGIN_KEY), QVariant(4)).toInt();
|
2011-03-02 16:20:36 +01:00
|
|
|
canvasWidth = settings->value(QLatin1String(QmlDesigner::Constants::QML_CANVASWIDTH_KEY), QVariant(10000)).toInt();
|
|
|
|
|
canvasHeight = settings->value(QLatin1String(QmlDesigner::Constants::QML_CANVASHEIGHT_KEY), QVariant(10000)).toInt();
|
2012-10-26 13:57:58 +02:00
|
|
|
warningsInDesigner = settings->value(
|
|
|
|
|
QLatin1String(QmlDesigner::Constants::QML_WARNIN_FOR_FEATURES_IN_DESIGNER_KEY), QVariant(true)).toBool();
|
|
|
|
|
designerWarningsInEditor = settings->value(
|
|
|
|
|
QLatin1String(QmlDesigner::Constants::QML_WARNIN_FOR_DESIGNER_FEATURES_IN_EDITOR_KEY), QVariant(false)).toBool();
|
2013-03-14 16:02:19 +01:00
|
|
|
showDebugView = settings->value(
|
|
|
|
|
QLatin1String(QmlDesigner::Constants::QML_SHOW_DEBUGVIEW), QVariant(false)).toBool();
|
|
|
|
|
enableDebugView = settings->value(
|
|
|
|
|
QLatin1String(QmlDesigner::Constants::QML_ENABLE_DEBUGVIEW), QVariant(false)).toBool();
|
2012-10-26 13:57:58 +02:00
|
|
|
|
2010-02-09 11:09:11 +01:00
|
|
|
settings->endGroup();
|
|
|
|
|
settings->endGroup();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DesignerSettings::toSettings(QSettings *settings) const
|
|
|
|
|
{
|
2010-03-16 16:51:45 +01:00
|
|
|
settings->beginGroup(QLatin1String(QmlDesigner::Constants::QML_SETTINGS_GROUP));
|
|
|
|
|
settings->beginGroup(QLatin1String(QmlDesigner::Constants::QML_DESIGNER_SETTINGS_GROUP));
|
|
|
|
|
settings->setValue(QLatin1String(QmlDesigner::Constants::QML_OPENDESIGNMODE_SETTINGS_KEY), openDesignMode);
|
2010-04-08 16:26:45 +02:00
|
|
|
settings->setValue(QLatin1String(QmlDesigner::Constants::QML_ITEMSPACING_KEY), itemSpacing);
|
|
|
|
|
settings->setValue(QLatin1String(QmlDesigner::Constants::QML_SNAPMARGIN_KEY), snapMargin);
|
2011-03-02 16:20:36 +01:00
|
|
|
settings->setValue(QLatin1String(QmlDesigner::Constants::QML_CANVASWIDTH_KEY), canvasWidth);
|
|
|
|
|
settings->setValue(QLatin1String(QmlDesigner::Constants::QML_CANVASHEIGHT_KEY), canvasHeight);
|
2012-10-26 13:57:58 +02:00
|
|
|
settings->setValue(QLatin1String(QmlDesigner::Constants::QML_WARNIN_FOR_FEATURES_IN_DESIGNER_KEY), warningsInDesigner);
|
|
|
|
|
settings->setValue(QLatin1String(QmlDesigner::Constants::QML_WARNIN_FOR_DESIGNER_FEATURES_IN_EDITOR_KEY), designerWarningsInEditor);
|
2013-03-14 16:02:19 +01:00
|
|
|
settings->setValue(QLatin1String(QmlDesigner::Constants::QML_SHOW_DEBUGVIEW), showDebugView);
|
|
|
|
|
settings->setValue(QLatin1String(QmlDesigner::Constants::QML_ENABLE_DEBUGVIEW), enableDebugView);
|
2012-10-26 13:57:58 +02:00
|
|
|
|
2010-02-09 11:09:11 +01:00
|
|
|
settings->endGroup();
|
|
|
|
|
settings->endGroup();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool DesignerSettings::equals(const DesignerSettings &other) const
|
|
|
|
|
{
|
2010-04-08 16:26:45 +02:00
|
|
|
return openDesignMode == other.openDesignMode
|
|
|
|
|
&& snapMargin == other.snapMargin
|
2011-03-02 16:20:36 +01:00
|
|
|
&& canvasWidth == other.canvasWidth
|
2012-10-26 13:57:58 +02:00
|
|
|
&& canvasHeight == other.canvasHeight
|
|
|
|
|
&& warningsInDesigner == other.warningsInDesigner
|
2013-03-14 16:02:19 +01:00
|
|
|
&& designerWarningsInEditor == other.designerWarningsInEditor
|
|
|
|
|
&& showDebugView == other.showDebugView
|
|
|
|
|
&& enableDebugView == other.enableDebugView;
|
2010-02-09 11:09:11 +01:00
|
|
|
}
|