2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2009-12-08 17:37:40 +01: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
|
2009-12-08 17:37:40 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2009-12-08 17:37:40 +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.
|
2009-12-08 17:37:40 +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
|
|
|
****************************************************************************/
|
2009-12-08 17:37:40 +01:00
|
|
|
|
|
|
|
|
#include "behaviorsettings.h"
|
|
|
|
|
|
2011-02-01 14:13:54 +01:00
|
|
|
#include <utils/settingsutils.h>
|
|
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QSettings>
|
|
|
|
|
#include <QString>
|
2009-12-08 17:37:40 +01:00
|
|
|
|
2014-02-10 13:23:59 +01:00
|
|
|
static const char mouseHidingKey[] = "MouseHiding";
|
2011-05-10 15:19:38 +02:00
|
|
|
static const char mouseNavigationKey[] = "MouseNavigation";
|
|
|
|
|
static const char scrollWheelZoomingKey[] = "ScrollWheelZooming";
|
2011-07-20 13:40:24 +02:00
|
|
|
static const char constrainTooltips[] = "ConstrainTooltips";
|
2011-09-19 19:00:53 +02:00
|
|
|
static const char camelCaseNavigationKey[] = "CamelCaseNavigation";
|
2011-12-08 13:23:41 +01:00
|
|
|
static const char keyboardTooltips[] = "KeyboardTooltips";
|
2011-05-10 15:19:38 +02:00
|
|
|
static const char groupPostfix[] = "BehaviorSettings";
|
2009-12-08 17:37:40 +01:00
|
|
|
|
|
|
|
|
namespace TextEditor {
|
|
|
|
|
|
|
|
|
|
BehaviorSettings::BehaviorSettings() :
|
2014-02-10 13:23:59 +01:00
|
|
|
m_mouseHiding(true),
|
2009-12-09 16:27:34 +01:00
|
|
|
m_mouseNavigation(true),
|
2011-07-20 13:40:24 +02:00
|
|
|
m_scrollWheelZooming(true),
|
2011-12-08 13:23:41 +01:00
|
|
|
m_constrainHoverTooltips(false),
|
|
|
|
|
m_camelCaseNavigation(true),
|
|
|
|
|
m_keyboardTooltips(false)
|
2009-12-08 17:37:40 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BehaviorSettings::toSettings(const QString &category, QSettings *s) const
|
|
|
|
|
{
|
2011-02-01 14:13:54 +01:00
|
|
|
Utils::toSettings(QLatin1String(groupPostfix), category, s, this);
|
2009-12-08 17:37:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BehaviorSettings::fromSettings(const QString &category, const QSettings *s)
|
|
|
|
|
{
|
2011-02-01 14:13:54 +01:00
|
|
|
*this = BehaviorSettings();
|
|
|
|
|
Utils::fromSettings(QLatin1String(groupPostfix), category, s, this);
|
|
|
|
|
}
|
2009-12-08 17:37:40 +01:00
|
|
|
|
2011-02-01 14:13:54 +01:00
|
|
|
void BehaviorSettings::toMap(const QString &prefix, QVariantMap *map) const
|
|
|
|
|
{
|
2014-02-10 13:23:59 +01:00
|
|
|
map->insert(prefix + QLatin1String(mouseHidingKey), m_mouseHiding);
|
2011-02-01 14:13:54 +01:00
|
|
|
map->insert(prefix + QLatin1String(mouseNavigationKey), m_mouseNavigation);
|
|
|
|
|
map->insert(prefix + QLatin1String(scrollWheelZoomingKey), m_scrollWheelZooming);
|
2011-12-08 13:23:41 +01:00
|
|
|
map->insert(prefix + QLatin1String(constrainTooltips), m_constrainHoverTooltips);
|
2011-09-19 19:00:53 +02:00
|
|
|
map->insert(prefix + QLatin1String(camelCaseNavigationKey), m_camelCaseNavigation);
|
2011-12-08 13:23:41 +01:00
|
|
|
map->insert(prefix + QLatin1String(keyboardTooltips), m_keyboardTooltips);
|
2011-02-01 14:13:54 +01:00
|
|
|
}
|
2009-12-08 17:37:40 +01:00
|
|
|
|
2011-02-01 14:13:54 +01:00
|
|
|
void BehaviorSettings::fromMap(const QString &prefix, const QVariantMap &map)
|
|
|
|
|
{
|
2014-02-10 13:23:59 +01:00
|
|
|
m_mouseHiding =
|
|
|
|
|
map.value(prefix + QLatin1String(mouseHidingKey), m_mouseHiding).toBool();
|
2011-02-01 14:13:54 +01:00
|
|
|
m_mouseNavigation =
|
|
|
|
|
map.value(prefix + QLatin1String(mouseNavigationKey), m_mouseNavigation).toBool();
|
|
|
|
|
m_scrollWheelZooming =
|
|
|
|
|
map.value(prefix + QLatin1String(scrollWheelZoomingKey), m_scrollWheelZooming).toBool();
|
2011-12-08 13:23:41 +01:00
|
|
|
m_constrainHoverTooltips =
|
|
|
|
|
map.value(prefix + QLatin1String(constrainTooltips), m_constrainHoverTooltips).toBool();
|
2011-09-19 19:00:53 +02:00
|
|
|
m_camelCaseNavigation =
|
|
|
|
|
map.value(prefix + QLatin1String(camelCaseNavigationKey), m_camelCaseNavigation).toBool();
|
2011-12-08 13:23:41 +01:00
|
|
|
m_keyboardTooltips =
|
|
|
|
|
map.value(prefix + QLatin1String(keyboardTooltips), m_keyboardTooltips).toBool();
|
2009-12-08 17:37:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool BehaviorSettings::equals(const BehaviorSettings &ds) const
|
|
|
|
|
{
|
2014-02-10 13:23:59 +01:00
|
|
|
return m_mouseHiding == ds.m_mouseHiding
|
|
|
|
|
&& m_mouseNavigation == ds.m_mouseNavigation
|
2009-12-09 16:27:34 +01:00
|
|
|
&& m_scrollWheelZooming == ds.m_scrollWheelZooming
|
2011-12-08 13:23:41 +01:00
|
|
|
&& m_constrainHoverTooltips == ds.m_constrainHoverTooltips
|
2011-09-19 19:00:53 +02:00
|
|
|
&& m_camelCaseNavigation == ds.m_camelCaseNavigation
|
2011-12-08 13:23:41 +01:00
|
|
|
&& m_keyboardTooltips == ds.m_keyboardTooltips
|
2009-12-08 17:37:40 +01:00
|
|
|
;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace TextEditor
|
|
|
|
|
|