2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2010-02-09 11:09:11 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
|
|
|
|
|
** 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"
|
|
|
|
|
#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();
|
2012-10-26 13:57:58 +02:00
|
|
|
ds.warningsInDesigner = m_ui.designerWarningsCheckBox->isChecked();
|
|
|
|
|
ds.designerWarningsInEditor = m_ui.designerWarningsInEditorCheckBox->isChecked();
|
|
|
|
|
|
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);
|
2012-10-26 13:57:58 +02:00
|
|
|
m_ui.designerWarningsCheckBox->setChecked(s.warningsInDesigner);
|
|
|
|
|
m_ui.designerWarningsInEditorCheckBox->setChecked(s.designerWarningsInEditor);
|
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)
|
|
|
|
|
{
|
2013-01-16 15:22:58 +01:00
|
|
|
setId("B.QmlDesigner");
|
2012-05-22 11:17:13 +02:00
|
|
|
setDisplayName(tr("Qt Quick Designer"));
|
2012-12-29 03:37:27 +01:00
|
|
|
setCategory(QmlJSEditor::Constants::SETTINGS_CATEGORY_QML);
|
2012-05-22 11:17:13 +02:00
|
|
|
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);
|
|
|
|
|
}
|