2010-02-09 11:09:11 +01:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2012-01-26 18:33:46 +01:00
|
|
|
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
2010-02-09 11:09:11 +01:00
|
|
|
**
|
2012-07-19 12:26:56 +02:00
|
|
|
** Contact: http://www.qt-project.org/
|
2010-02-09 11:09:11 +01:00
|
|
|
**
|
|
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** 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.
|
2010-02-09 11:09:11 +01:00
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2011-04-13 08:42:33 +02:00
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Other Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used in accordance with the terms and
|
|
|
|
|
** conditions contained in a signed written agreement between you and Nokia.
|
|
|
|
|
**
|
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),
|
|
|
|
|
canvasHeight(10000)
|
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(
|
|
|
|
|
QLatin1String(QmlDesigner::Constants::QML_ITEMSPACING_KEY), QVariant(0)).toInt();
|
|
|
|
|
snapMargin = settings->value(
|
|
|
|
|
QLatin1String(QmlDesigner::Constants::QML_SNAPMARGIN_KEY), QVariant(0)).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();
|
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);
|
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
|
|
|
|
|
&& canvasHeight == other.canvasHeight;
|
2010-02-09 11:09:11 +01:00
|
|
|
}
|