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
|
|
|
**
|
2011-11-02 15:59:12 +01:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
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-12-17 16:01:08 +01:00
|
|
|
** If you have questions regarding the use of this file, please contact
|
2011-11-02 15:59:12 +01:00
|
|
|
** Nokia at qt-info@nokia.com.
|
2010-02-09 11:09:11 +01:00
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "designersettings.h"
|
|
|
|
|
#include "qmldesignerconstants.h"
|
|
|
|
|
#include "qmldesignerplugin.h"
|
|
|
|
|
#include "settingspage.h"
|
|
|
|
|
|
2011-09-20 16:06:03 +02:00
|
|
|
#include <qmljseditor/qmljseditorconstants.h>
|
|
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QTextStream>
|
|
|
|
|
#include <QCheckBox>
|
2010-02-09 11:09:11 +01:00
|
|
|
|
|
|
|
|
using namespace QmlDesigner;
|
|
|
|
|
using namespace QmlDesigner::Internal;
|
|
|
|
|
|
|
|
|
|
SettingsPageWidget::SettingsPageWidget(QWidget *parent) :
|
|
|
|
|
QWidget(parent)
|
|
|
|
|
{
|
|
|
|
|
m_ui.setupUi(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DesignerSettings SettingsPageWidget::settings() const
|
|
|
|
|
{
|
|
|
|
|
DesignerSettings ds;
|
2010-04-08 16:26:45 +02:00
|
|
|
ds.itemSpacing = m_ui.spinItemSpacing->value();
|
|
|
|
|
ds.snapMargin = m_ui.spinSnapMargin->value();
|
2011-04-05 13:42:00 +02:00
|
|
|
ds.canvasWidth = m_ui.spinCanvasWidth->value();
|
|
|
|
|
ds.canvasHeight = m_ui.spinCanvasHeight->value();
|
2010-02-09 11:09:11 +01:00
|
|
|
return ds;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SettingsPageWidget::setSettings(const DesignerSettings &s)
|
|
|
|
|
{
|
2010-04-08 16:26:45 +02:00
|
|
|
m_ui.spinItemSpacing->setValue(s.itemSpacing);
|
|
|
|
|
m_ui.spinSnapMargin->setValue(s.snapMargin);
|
2011-04-05 13:42:00 +02:00
|
|
|
m_ui.spinCanvasWidth->setValue(s.canvasWidth);
|
|
|
|
|
m_ui.spinCanvasHeight->setValue(s.canvasHeight);
|
2010-02-09 11:09:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString SettingsPageWidget::searchKeywords() const
|
|
|
|
|
{
|
|
|
|
|
QString rc;
|
|
|
|
|
QTextStream(&rc)
|
2010-12-01 14:35:36 +01:00
|
|
|
<< ' ' << m_ui.snapMarginLabel->text()
|
2011-04-05 13:42:00 +02:00
|
|
|
<< ' ' << m_ui.itemSpacingLabel->text()
|
|
|
|
|
<< ' ' << m_ui.canvasWidthLabel->text()
|
|
|
|
|
<< ' ' << m_ui.canvasHeightLabel->text();
|
2010-02-09 11:09:11 +01:00
|
|
|
rc.remove(QLatin1Char('&'));
|
|
|
|
|
return rc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SettingsPage::SettingsPage() :
|
|
|
|
|
m_widget(0)
|
|
|
|
|
{
|
2012-05-22 11:17:13 +02:00
|
|
|
setId(QLatin1String("B.QmlDesigner"));
|
|
|
|
|
setDisplayName(tr("Qt Quick Designer"));
|
|
|
|
|
setCategory(QLatin1String(QmlJSEditor::Constants::SETTINGS_CATEGORY_QML));
|
|
|
|
|
setDisplayCategory(QCoreApplication::translate("QmlJSEditor",
|
|
|
|
|
QmlJSEditor::Constants::SETTINGS_TR_CATEGORY_QML));
|
|
|
|
|
setCategoryIcon(QLatin1String(Constants::SETTINGS_CATEGORY_QML_ICON));
|
2010-03-26 17:34:10 +01:00
|
|
|
}
|
|
|
|
|
|
2010-02-09 11:09:11 +01:00
|
|
|
QWidget *SettingsPage::createPage(QWidget *parent)
|
|
|
|
|
{
|
|
|
|
|
m_widget = new SettingsPageWidget(parent);
|
|
|
|
|
m_widget->setSettings(BauhausPlugin::pluginInstance()->settings());
|
|
|
|
|
if (m_searchKeywords.isEmpty())
|
|
|
|
|
m_searchKeywords = m_widget->searchKeywords();
|
|
|
|
|
return m_widget;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SettingsPage::apply()
|
|
|
|
|
{
|
2010-12-02 18:28:16 +01:00
|
|
|
if (!m_widget) // page was never shown
|
|
|
|
|
return;
|
2010-02-09 11:09:11 +01:00
|
|
|
BauhausPlugin::pluginInstance()->setSettings(m_widget->settings());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool SettingsPage::matches(const QString &s) const
|
|
|
|
|
{
|
|
|
|
|
return m_searchKeywords.contains(s, Qt::CaseInsensitive);
|
|
|
|
|
}
|