2009-02-25 09:15:00 +01:00
|
|
|
/**************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2011-01-11 16:28:15 +01:00
|
|
|
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Contact: Nokia Corporation (info@qt.nokia.com)
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** GNU Lesser General Public License Usage
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
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.
|
2008-12-02 14:17:16 +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-05-06 15:05:37 +02:00
|
|
|
** Nokia at info@qt.nokia.com.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
**************************************************************************/
|
2008-12-02 16:19:05 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "displaysettings.h"
|
|
|
|
|
|
|
|
|
|
#include <QtCore/QSettings>
|
|
|
|
|
#include <QtCore/QString>
|
|
|
|
|
|
|
|
|
|
static const char * const displayLineNumbersKey = "DisplayLineNumbers";
|
|
|
|
|
static const char * const textWrappingKey = "TextWrapping";
|
|
|
|
|
static const char * const showWrapColumnKey = "ShowWrapColumn";
|
|
|
|
|
static const char * const wrapColumnKey = "WrapColumn";
|
|
|
|
|
static const char * const visualizeWhitespaceKey = "VisualizeWhitespace";
|
2009-04-28 12:03:06 +02:00
|
|
|
static const char * const displayFoldingMarkersKey = "DisplayFoldingMarkers";
|
2009-12-01 14:47:10 +01:00
|
|
|
static const char * const highlightCurrentLineKey = "HighlightCurrentLine2Key";
|
2009-04-28 12:03:06 +02:00
|
|
|
static const char * const highlightBlocksKey = "HighlightBlocksKey";
|
2009-04-29 12:17:42 +02:00
|
|
|
static const char * const animateMatchingParenthesesKey= "AnimateMatchingParenthesesKey";
|
2009-07-16 11:27:02 +02:00
|
|
|
static const char * const markTextChangesKey = "MarkTextChanges";
|
2010-04-14 11:49:58 +02:00
|
|
|
static const char * const autoFoldFirstCommentKey = "AutoFoldFirstComment";
|
|
|
|
|
static const char * const centerCursorOnScrollKey = "CenterCursorOnScroll";
|
2008-12-02 12:01:29 +01:00
|
|
|
static const char * const groupPostfix = "DisplaySettings";
|
|
|
|
|
|
|
|
|
|
namespace TextEditor {
|
|
|
|
|
|
|
|
|
|
DisplaySettings::DisplaySettings() :
|
|
|
|
|
m_displayLineNumbers(true),
|
|
|
|
|
m_textWrapping(false),
|
|
|
|
|
m_showWrapColumn(false),
|
|
|
|
|
m_wrapColumn(80),
|
|
|
|
|
m_visualizeWhitespace(false),
|
2009-04-28 12:03:06 +02:00
|
|
|
m_displayFoldingMarkers(true),
|
2009-12-01 14:47:10 +01:00
|
|
|
m_highlightCurrentLine(false),
|
2009-04-29 12:17:42 +02:00
|
|
|
m_highlightBlocks(false),
|
2009-05-13 16:05:11 +02:00
|
|
|
m_animateMatchingParentheses(true),
|
2009-12-01 18:08:02 +01:00
|
|
|
m_markTextChanges(true),
|
2010-04-14 11:49:58 +02:00
|
|
|
m_autoFoldFirstComment(true),
|
2010-08-31 13:40:13 +02:00
|
|
|
m_centerCursorOnScroll(false)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DisplaySettings::toSettings(const QString &category, QSettings *s) const
|
|
|
|
|
{
|
|
|
|
|
QString group = QLatin1String(groupPostfix);
|
|
|
|
|
if (!category.isEmpty())
|
|
|
|
|
group.insert(0, category);
|
|
|
|
|
s->beginGroup(group);
|
|
|
|
|
s->setValue(QLatin1String(displayLineNumbersKey), m_displayLineNumbers);
|
|
|
|
|
s->setValue(QLatin1String(textWrappingKey), m_textWrapping);
|
|
|
|
|
s->setValue(QLatin1String(showWrapColumnKey), m_showWrapColumn);
|
|
|
|
|
s->setValue(QLatin1String(wrapColumnKey), m_wrapColumn);
|
|
|
|
|
s->setValue(QLatin1String(visualizeWhitespaceKey), m_visualizeWhitespace);
|
|
|
|
|
s->setValue(QLatin1String(displayFoldingMarkersKey), m_displayFoldingMarkers);
|
|
|
|
|
s->setValue(QLatin1String(highlightCurrentLineKey), m_highlightCurrentLine);
|
2009-04-22 20:04:38 +02:00
|
|
|
s->setValue(QLatin1String(highlightBlocksKey), m_highlightBlocks);
|
2009-04-29 12:17:42 +02:00
|
|
|
s->setValue(QLatin1String(animateMatchingParenthesesKey), m_animateMatchingParentheses);
|
2009-07-16 11:27:02 +02:00
|
|
|
s->setValue(QLatin1String(markTextChangesKey), m_markTextChanges);
|
2009-12-01 18:08:02 +01:00
|
|
|
s->setValue(QLatin1String(autoFoldFirstCommentKey), m_autoFoldFirstComment);
|
2010-04-14 11:49:58 +02:00
|
|
|
s->setValue(QLatin1String(centerCursorOnScrollKey), m_centerCursorOnScroll);
|
2008-12-02 12:01:29 +01:00
|
|
|
s->endGroup();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DisplaySettings::fromSettings(const QString &category, const QSettings *s)
|
|
|
|
|
{
|
|
|
|
|
QString group = QLatin1String(groupPostfix);
|
|
|
|
|
if (!category.isEmpty())
|
|
|
|
|
group.insert(0, category);
|
|
|
|
|
group += QLatin1Char('/');
|
|
|
|
|
|
|
|
|
|
*this = DisplaySettings(); // Assign defaults
|
|
|
|
|
|
|
|
|
|
m_displayLineNumbers = s->value(group + QLatin1String(displayLineNumbersKey), m_displayLineNumbers).toBool();
|
|
|
|
|
m_textWrapping = s->value(group + QLatin1String(textWrappingKey), m_textWrapping).toBool();
|
|
|
|
|
m_showWrapColumn = s->value(group + QLatin1String(showWrapColumnKey), m_showWrapColumn).toBool();
|
|
|
|
|
m_wrapColumn = s->value(group + QLatin1String(wrapColumnKey), m_wrapColumn).toInt();
|
|
|
|
|
m_visualizeWhitespace = s->value(group + QLatin1String(visualizeWhitespaceKey), m_visualizeWhitespace).toBool();
|
|
|
|
|
m_displayFoldingMarkers = s->value(group + QLatin1String(displayFoldingMarkersKey), m_displayFoldingMarkers).toBool();
|
|
|
|
|
m_highlightCurrentLine = s->value(group + QLatin1String(highlightCurrentLineKey), m_highlightCurrentLine).toBool();
|
2009-04-22 20:04:38 +02:00
|
|
|
m_highlightBlocks = s->value(group + QLatin1String(highlightBlocksKey), m_highlightBlocks).toBool();
|
2009-04-29 12:17:42 +02:00
|
|
|
m_animateMatchingParentheses = s->value(group + QLatin1String(animateMatchingParenthesesKey), m_animateMatchingParentheses).toBool();
|
2009-07-16 11:27:02 +02:00
|
|
|
m_markTextChanges = s->value(group + QLatin1String(markTextChangesKey), m_markTextChanges).toBool();
|
2009-12-01 18:08:02 +01:00
|
|
|
m_autoFoldFirstComment = s->value(group + QLatin1String(autoFoldFirstCommentKey), m_autoFoldFirstComment).toBool();
|
2010-04-14 11:49:58 +02:00
|
|
|
m_centerCursorOnScroll = s->value(group + QLatin1String(centerCursorOnScrollKey), m_centerCursorOnScroll).toBool();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool DisplaySettings::equals(const DisplaySettings &ds) const
|
|
|
|
|
{
|
|
|
|
|
return m_displayLineNumbers == ds.m_displayLineNumbers
|
|
|
|
|
&& m_textWrapping == ds.m_textWrapping
|
|
|
|
|
&& m_showWrapColumn == ds.m_showWrapColumn
|
|
|
|
|
&& m_wrapColumn == ds.m_wrapColumn
|
|
|
|
|
&& m_visualizeWhitespace == ds.m_visualizeWhitespace
|
|
|
|
|
&& m_displayFoldingMarkers == ds.m_displayFoldingMarkers
|
|
|
|
|
&& m_highlightCurrentLine == ds.m_highlightCurrentLine
|
2009-04-22 20:04:38 +02:00
|
|
|
&& m_highlightBlocks == ds.m_highlightBlocks
|
2009-04-29 12:17:42 +02:00
|
|
|
&& m_animateMatchingParentheses == ds.m_animateMatchingParentheses
|
2009-07-16 11:27:02 +02:00
|
|
|
&& m_markTextChanges == ds.m_markTextChanges
|
2009-12-01 18:08:02 +01:00
|
|
|
&& m_autoFoldFirstComment== ds.m_autoFoldFirstComment
|
2010-04-14 11:49:58 +02:00
|
|
|
&& m_centerCursorOnScroll == ds.m_centerCursorOnScroll
|
2008-12-02 12:01:29 +01:00
|
|
|
;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace TextEditor
|