1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
16 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 ** In addition, as a special exception, Nokia gives you certain additional
26 ** rights. These rights are described in the Nokia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
32 **************************************************************************/
34 #include <qmldesigner/qmldesignerconstants.h>
35 #include "quicktoolbarsettingspage.h"
37 #include <coreplugin/icore.h>
39 #include <QtCore/QSettings>
40 #include <QtCore/QTextStream>
41 #include <QtGui/QCheckBox>
44 using namespace QmlJSEditor;
45 using namespace QmlJSEditor::Internal;
47 QuickToolBarSettings::QuickToolBarSettings()
48 : enableContextPane(false),
52 void QuickToolBarSettings::set()
55 if (QSettings *settings = Core::ICore::instance()->settings())
60 void QuickToolBarSettings::fromSettings(QSettings *settings)
62 settings->beginGroup(QLatin1String(QmlDesigner::Constants::QML_SETTINGS_GROUP));
63 settings->beginGroup(QLatin1String(QmlDesigner::Constants::QML_DESIGNER_SETTINGS_GROUP));
64 enableContextPane = settings->value(
65 QLatin1String(QmlDesigner::Constants::QML_CONTEXTPANE_KEY), QVariant(false)).toBool();
66 pinContextPane = settings->value(
67 QLatin1String(QmlDesigner::Constants::QML_CONTEXTPANEPIN_KEY), QVariant(false)).toBool();
72 void QuickToolBarSettings::toSettings(QSettings *settings) const
74 settings->beginGroup(QLatin1String(QmlDesigner::Constants::QML_SETTINGS_GROUP));
75 settings->beginGroup(QLatin1String(QmlDesigner::Constants::QML_DESIGNER_SETTINGS_GROUP));
76 settings->setValue(QLatin1String(QmlDesigner::Constants::QML_CONTEXTPANE_KEY), enableContextPane);
77 settings->setValue(QLatin1String(QmlDesigner::Constants::QML_CONTEXTPANEPIN_KEY), pinContextPane);
82 bool QuickToolBarSettings::equals(const QuickToolBarSettings &other) const
84 return enableContextPane == other.enableContextPane
85 && pinContextPane == other.pinContextPane;
89 QuickToolBarSettingsPageWidget::QuickToolBarSettingsPageWidget(QWidget *parent) :
95 QuickToolBarSettings QuickToolBarSettingsPageWidget::settings() const
97 QuickToolBarSettings ds;
98 ds.enableContextPane = m_ui.textEditHelperCheckBox->isChecked();
99 ds.pinContextPane = m_ui.textEditHelperCheckBoxPin->isChecked();
103 void QuickToolBarSettingsPageWidget::setSettings(const QuickToolBarSettings &s)
105 m_ui.textEditHelperCheckBox->setChecked(s.enableContextPane);
106 m_ui.textEditHelperCheckBoxPin->setChecked(s.pinContextPane);
109 QString QuickToolBarSettingsPageWidget::searchKeywords() const
113 << ' ' << m_ui.textEditHelperCheckBox->text()
114 << ' ' << m_ui.textEditHelperCheckBoxPin->text();
115 rc.remove(QLatin1Char('&'));
119 QuickToolBarSettings QuickToolBarSettings::get()
121 Core::ICore *core = Core::ICore::instance();
122 QuickToolBarSettings settings;
123 settings.fromSettings(core->settings());
127 QuickToolBarSettingsPage::QuickToolBarSettingsPage() :
132 QString QuickToolBarSettingsPage::id() const
134 return QLatin1String("QmlToolbar");
137 QString QuickToolBarSettingsPage::displayName() const
139 return tr("Qt Quick ToolBar");
142 QString QuickToolBarSettingsPage::category() const
144 return QLatin1String("Qt Quick");
147 QString QuickToolBarSettingsPage::displayCategory() const
149 return QCoreApplication::translate("Qt Quick", "Qt Quick");
152 QIcon QuickToolBarSettingsPage::categoryIcon() const
154 return QIcon(QLatin1String(QmlDesigner::Constants::SETTINGS_CATEGORY_QML_ICON));
157 QWidget *QuickToolBarSettingsPage::createPage(QWidget *parent)
159 m_widget = new QuickToolBarSettingsPageWidget(parent);
160 m_widget->setSettings(QuickToolBarSettings::get());
161 if (m_searchKeywords.isEmpty())
162 m_searchKeywords = m_widget->searchKeywords();
166 void QuickToolBarSettingsPage::apply()
168 if (!m_widget) // page was never shown
170 m_widget->settings().set();
173 bool QuickToolBarSettingsPage::matches(const QString &s) const
175 return m_searchKeywords.contains(s, Qt::CaseInsensitive);