2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2010-08-12 15:48:24 +02:00
|
|
|
**
|
2014-01-07 13:27:11 +01:00
|
|
|
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
2012-10-02 09:12:39 +02:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
2010-08-12 15:48:24 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2010-08-12 15:48:24 +02: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-08-12 15:48:24 +02: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-08-12 15:48:24 +02:00
|
|
|
|
|
|
|
|
#include "quicktoolbarsettingspage.h"
|
2011-09-20 16:06:03 +02:00
|
|
|
#include "qmljseditorconstants.h"
|
2010-08-12 15:48:24 +02:00
|
|
|
|
2011-09-20 16:06:03 +02:00
|
|
|
#include <qmldesigner/qmldesignerconstants.h>
|
2014-06-02 16:50:01 +02:00
|
|
|
#include <qmljstools/qmljstoolsconstants.h>
|
2010-08-12 15:48:24 +02:00
|
|
|
#include <coreplugin/icore.h>
|
|
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QSettings>
|
|
|
|
|
#include <QTextStream>
|
|
|
|
|
#include <QCheckBox>
|
2010-08-12 15:48:24 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
using namespace QmlJSEditor;
|
|
|
|
|
using namespace QmlJSEditor::Internal;
|
|
|
|
|
|
|
|
|
|
QuickToolBarSettings::QuickToolBarSettings()
|
|
|
|
|
: enableContextPane(false),
|
|
|
|
|
pinContextPane(false)
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
void QuickToolBarSettings::set()
|
|
|
|
|
{
|
2012-08-09 12:58:51 +03:00
|
|
|
if (get() != *this)
|
|
|
|
|
toSettings(Core::ICore::settings());
|
2010-08-12 15:48:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QuickToolBarSettings::fromSettings(QSettings *settings)
|
|
|
|
|
{
|
|
|
|
|
settings->beginGroup(QLatin1String(QmlDesigner::Constants::QML_SETTINGS_GROUP));
|
|
|
|
|
settings->beginGroup(QLatin1String(QmlDesigner::Constants::QML_DESIGNER_SETTINGS_GROUP));
|
|
|
|
|
enableContextPane = settings->value(
|
|
|
|
|
QLatin1String(QmlDesigner::Constants::QML_CONTEXTPANE_KEY), QVariant(false)).toBool();
|
|
|
|
|
pinContextPane = settings->value(
|
|
|
|
|
QLatin1String(QmlDesigner::Constants::QML_CONTEXTPANEPIN_KEY), QVariant(false)).toBool();
|
|
|
|
|
settings->endGroup();
|
|
|
|
|
settings->endGroup();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QuickToolBarSettings::toSettings(QSettings *settings) const
|
|
|
|
|
{
|
|
|
|
|
settings->beginGroup(QLatin1String(QmlDesigner::Constants::QML_SETTINGS_GROUP));
|
|
|
|
|
settings->beginGroup(QLatin1String(QmlDesigner::Constants::QML_DESIGNER_SETTINGS_GROUP));
|
|
|
|
|
settings->setValue(QLatin1String(QmlDesigner::Constants::QML_CONTEXTPANE_KEY), enableContextPane);
|
|
|
|
|
settings->setValue(QLatin1String(QmlDesigner::Constants::QML_CONTEXTPANEPIN_KEY), pinContextPane);
|
|
|
|
|
settings->endGroup();
|
|
|
|
|
settings->endGroup();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool QuickToolBarSettings::equals(const QuickToolBarSettings &other) const
|
|
|
|
|
{
|
|
|
|
|
return enableContextPane == other.enableContextPane
|
|
|
|
|
&& pinContextPane == other.pinContextPane;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QuickToolBarSettingsPageWidget::QuickToolBarSettingsPageWidget(QWidget *parent) :
|
|
|
|
|
QWidget(parent)
|
|
|
|
|
{
|
|
|
|
|
m_ui.setupUi(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QuickToolBarSettings QuickToolBarSettingsPageWidget::settings() const
|
|
|
|
|
{
|
|
|
|
|
QuickToolBarSettings ds;
|
|
|
|
|
ds.enableContextPane = m_ui.textEditHelperCheckBox->isChecked();
|
|
|
|
|
ds.pinContextPane = m_ui.textEditHelperCheckBoxPin->isChecked();
|
|
|
|
|
return ds;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QuickToolBarSettingsPageWidget::setSettings(const QuickToolBarSettings &s)
|
|
|
|
|
{
|
|
|
|
|
m_ui.textEditHelperCheckBox->setChecked(s.enableContextPane);
|
|
|
|
|
m_ui.textEditHelperCheckBoxPin->setChecked(s.pinContextPane);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QuickToolBarSettings QuickToolBarSettings::get()
|
|
|
|
|
{
|
|
|
|
|
QuickToolBarSettings settings;
|
2012-01-24 15:36:40 +01:00
|
|
|
settings.fromSettings(Core::ICore::settings());
|
2010-08-12 15:48:24 +02:00
|
|
|
return settings;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QuickToolBarSettingsPage::QuickToolBarSettingsPage() :
|
|
|
|
|
m_widget(0)
|
|
|
|
|
{
|
2013-01-16 15:22:58 +01:00
|
|
|
setId("C.QmlToolbar");
|
2012-05-22 11:17:13 +02:00
|
|
|
setDisplayName(tr("Qt Quick ToolBar"));
|
2012-12-29 03:37:27 +01:00
|
|
|
setCategory(Constants::SETTINGS_CATEGORY_QML);
|
2012-05-22 11:17:13 +02:00
|
|
|
setDisplayCategory(QCoreApplication::translate("QmlJSEditor",
|
|
|
|
|
QmlJSEditor::Constants::SETTINGS_TR_CATEGORY_QML));
|
2014-06-02 16:50:01 +02:00
|
|
|
setCategoryIcon(QLatin1String(QmlJSTools::Constants::SETTINGS_CATEGORY_QML_ICON));
|
2010-08-12 15:48:24 +02:00
|
|
|
}
|
|
|
|
|
|
2013-12-03 14:17:03 +01:00
|
|
|
QWidget *QuickToolBarSettingsPage::widget()
|
2010-08-12 15:48:24 +02:00
|
|
|
{
|
2013-12-03 14:17:03 +01:00
|
|
|
if (!m_widget) {
|
|
|
|
|
m_widget = new QuickToolBarSettingsPageWidget;
|
|
|
|
|
m_widget->setSettings(QuickToolBarSettings::get());
|
|
|
|
|
}
|
2010-08-12 15:48:24 +02:00
|
|
|
return m_widget;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QuickToolBarSettingsPage::apply()
|
|
|
|
|
{
|
2010-12-02 18:28:16 +01:00
|
|
|
if (!m_widget) // page was never shown
|
|
|
|
|
return;
|
2010-08-12 15:48:24 +02:00
|
|
|
m_widget->settings().set();
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-03 14:17:03 +01:00
|
|
|
void QuickToolBarSettingsPage::finish()
|
2010-08-12 15:48:24 +02:00
|
|
|
{
|
2013-12-03 14:17:03 +01:00
|
|
|
delete m_widget;
|
2010-08-12 15:48:24 +02:00
|
|
|
}
|