2014-11-22 17:15:47 +01:00
|
|
|
/************************************************************************
|
|
|
|
**
|
|
|
|
** @file vsettings.cpp
|
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
|
|
|
** @date 22 11, 2014
|
|
|
|
**
|
|
|
|
** @brief
|
|
|
|
** @copyright
|
2017-10-05 11:20:01 +02:00
|
|
|
** This source code is part of the Valentina project, a pattern making
|
2014-11-22 17:15:47 +01:00
|
|
|
** program, whose allow create and modeling patterns of clothing.
|
2015-02-27 11:27:48 +01:00
|
|
|
** Copyright (C) 2013-2015 Valentina project
|
2014-11-22 17:15:47 +01:00
|
|
|
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
|
|
|
**
|
|
|
|
** Valentina is free software: you can redistribute it and/or modify
|
|
|
|
** it under the terms of the GNU General Public License as published by
|
|
|
|
** the Free Software Foundation, either version 3 of the License, or
|
|
|
|
** (at your option) any later version.
|
|
|
|
**
|
|
|
|
** Valentina is distributed in the hope that it will be useful,
|
|
|
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
** GNU General Public License for more details.
|
|
|
|
**
|
|
|
|
** You should have received a copy of the GNU General Public License
|
|
|
|
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
**
|
|
|
|
*************************************************************************/
|
|
|
|
|
|
|
|
#include "vsettings.h"
|
|
|
|
|
|
|
|
#include <QDir>
|
2014-11-28 19:33:28 +01:00
|
|
|
#include <QLocale>
|
2016-08-08 13:44:49 +02:00
|
|
|
#include <QMetaType>
|
2015-11-09 12:33:36 +01:00
|
|
|
#include <QPrinter>
|
|
|
|
#include <QSharedPointer>
|
2016-08-08 13:44:49 +02:00
|
|
|
#include <QStaticStringData>
|
|
|
|
#include <QStringData>
|
|
|
|
#include <QStringDataPtr>
|
|
|
|
#include <QVariant>
|
2016-08-22 18:43:22 +02:00
|
|
|
#include <QPrinterInfo>
|
2017-10-10 11:22:59 +02:00
|
|
|
#include <QtDebug>
|
2018-03-14 14:39:15 +01:00
|
|
|
#include <QGlobalStatic>
|
2014-11-22 17:15:47 +01:00
|
|
|
|
2016-08-09 15:55:46 +02:00
|
|
|
#include "../vmisc/def.h"
|
2016-08-16 18:57:32 +02:00
|
|
|
#include "../vmisc/vmath.h"
|
2016-08-08 13:44:49 +02:00
|
|
|
|
2015-11-16 13:07:28 +01:00
|
|
|
Q_DECLARE_METATYPE(QMarginsF)
|
|
|
|
|
2018-05-11 11:42:20 +02:00
|
|
|
const int VSettings::defaultScrollingDuration = 300;
|
|
|
|
const int VSettings::scrollingDurationMin = 100;
|
|
|
|
const int VSettings::scrollingDurationMax = 1000;
|
|
|
|
|
|
|
|
const int VSettings::defaultScrollingUpdateInterval = 30;
|
|
|
|
const int VSettings::scrollingUpdateIntervalMin = 10;
|
|
|
|
const int VSettings::scrollingUpdateIntervalMax = 100;
|
|
|
|
|
|
|
|
const qreal VSettings::defaultSensorMouseScale = 2.0;
|
|
|
|
const qreal VSettings::sensorMouseScaleMin = 1.0;
|
|
|
|
const qreal VSettings::sensorMouseScaleMax = 10.0;
|
|
|
|
|
|
|
|
const qreal VSettings::defaultWheelMouseScale = 45.0;
|
|
|
|
const qreal VSettings::wheelMouseScaleMin = 1.0;
|
|
|
|
const qreal VSettings::wheelMouseScaleMax = 100.0;
|
|
|
|
|
|
|
|
const qreal VSettings::defaultScrollingAcceleration = 1.3;
|
|
|
|
const qreal VSettings::scrollingAccelerationMin = 1.0;
|
|
|
|
const qreal VSettings::scrollingAccelerationMax = 10.0;
|
|
|
|
|
2017-07-01 19:32:54 +02:00
|
|
|
namespace
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationLabelLanguage,
|
|
|
|
(QLatin1String("configuration/label_language")))
|
2017-04-11 10:16:11 +02:00
|
|
|
|
2018-03-14 14:39:15 +01:00
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsPattern, (QLatin1String("paths/pattern")))
|
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsLayout, (QLatin1String("paths/layout")))
|
2017-04-11 10:16:11 +02:00
|
|
|
|
2018-03-14 14:39:15 +01:00
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternGraphicalOutput, (QLatin1String("pattern/graphicalOutput")))
|
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternUseOpenGLRender, (QLatin1String("pattern/useOpenGLRender")))
|
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternKnownMaterials, (QLatin1String("pattern/knownMaterials")))
|
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternRememberMaterials, (QLatin1String("pattern/rememberMaterials")))
|
2017-04-11 10:16:11 +02:00
|
|
|
|
2018-03-14 14:39:15 +01:00
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutWidth, (QLatin1String("layout/width")))
|
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutSorting, (QLatin1String("layout/sorting")))
|
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutPaperHeight, (QLatin1String("layout/paperHeight")))
|
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutPaperWidth, (QLatin1String("layout/paperWidth")))
|
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutShift, (QLatin1String("layout/shift")))
|
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutRotate, (QLatin1String("layout/Rotate")))
|
2018-12-27 14:54:29 +01:00
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutFollowGrainline, (QLatin1String("layout/followGrainline")))
|
2018-03-14 14:39:15 +01:00
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutRotationIncrease, (QLatin1String("layout/rotationIncrease")))
|
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutAutoCrop, (QLatin1String("layout/autoCrop")))
|
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutSaveLength, (QLatin1String("layout/saveLength")))
|
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutUnitePages, (QLatin1String("layout/unitePages")))
|
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingFields, (QLatin1String("layout/fields")))
|
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingIgnoreFields, (QLatin1String("layout/ignoreFields")))
|
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingStripOptimization, (QLatin1String("layout/stripOptimization")))
|
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingMultiplier, (QLatin1String("layout/multiplier")))
|
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingTextAsPaths, (QLatin1String("layout/textAsPaths")))
|
2017-10-10 11:22:59 +02:00
|
|
|
|
2018-03-14 14:39:15 +01:00
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingTiledPDFMargins, (QLatin1String("tiledPDF/margins")))
|
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingTiledPDFPaperHeight, (QLatin1String("tiledPDF/paperHeight")))
|
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingTiledPDFPaperWidth, (QLatin1String("tiledPDF/paperWidth")))
|
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingTiledPDFOrientation, (QLatin1String("tiledPDF/orientation")))
|
2018-05-11 11:42:20 +02:00
|
|
|
|
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingDuration, (QLatin1String("scrolling/duration")))
|
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingUpdateInterval, (QLatin1String("scrolling/updateInterval")))
|
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingSensorMouseScale, (QLatin1String("scrolling/sensorMouseScale")))
|
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingWheelMouseScale, (QLatin1String("scrolling/wheelMouseScale")))
|
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingAcceleration, (QLatin1String("scrolling/acceleration")))
|
|
|
|
|
|
|
|
// Reading settings file is very expensive, cache values to speed up getting a value
|
|
|
|
int scrollingDurationCached = -1;
|
|
|
|
int scrollingUpdateIntervalCached = -1;
|
|
|
|
qreal scrollingSensorMouseScaleCached = -1;
|
|
|
|
qreal scrollingWheelMouseScaleCached = -1;
|
|
|
|
qreal scrollingAccelerationCached = -1;
|
2017-07-01 19:32:54 +02:00
|
|
|
}
|
2015-05-08 16:24:20 +02:00
|
|
|
|
2014-11-22 17:15:47 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
VSettings::VSettings(Format format, Scope scope, const QString &organization, const QString &application,
|
|
|
|
QObject *parent)
|
2015-07-15 09:16:59 +02:00
|
|
|
:VCommonSettings(format, scope, organization, application, parent)
|
2015-11-09 12:33:36 +01:00
|
|
|
{
|
|
|
|
qRegisterMetaTypeStreamOperators<QMarginsF>("QMarginsF");
|
|
|
|
}
|
2014-11-22 17:15:47 +01:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-11-28 19:41:46 +01:00
|
|
|
QString VSettings::GetLabelLanguage() const
|
2014-11-22 17:15:47 +01:00
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
return value(*settingConfigurationLabelLanguage, QLocale().bcp47Name()).toString();
|
2014-11-22 17:15:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VSettings::SetLabelLanguage(const QString &value)
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
setValue(*settingConfigurationLabelLanguage, value);
|
2014-11-22 17:15:47 +01:00
|
|
|
}
|
|
|
|
|
2017-02-17 19:37:49 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QString VSettings::GetDefPathPattern()
|
|
|
|
{
|
|
|
|
return QDir::homePath() + QLatin1String("/valentina/") + tr("patterns");
|
|
|
|
}
|
|
|
|
|
2014-11-22 17:15:47 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-11-28 19:41:46 +01:00
|
|
|
QString VSettings::GetPathPattern() const
|
2014-11-22 17:15:47 +01:00
|
|
|
{
|
2015-10-18 15:17:56 +02:00
|
|
|
QSettings settings(this->format(), this->scope(), this->organizationName(), this->applicationName());
|
2018-03-14 14:39:15 +01:00
|
|
|
return settings.value(*settingPathsPattern, GetDefPathPattern()).toString();
|
2014-11-22 17:15:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VSettings::SetPathPattern(const QString &value)
|
|
|
|
{
|
2015-10-18 15:13:51 +02:00
|
|
|
QSettings settings(this->format(), this->scope(), this->organizationName(), this->applicationName());
|
2018-03-14 14:39:15 +01:00
|
|
|
settings.setValue(*settingPathsPattern, value);
|
2015-10-18 14:38:05 +02:00
|
|
|
settings.sync();
|
2014-11-22 17:15:47 +01:00
|
|
|
}
|
|
|
|
|
2017-02-17 19:37:49 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QString VSettings::GetDefPathLayout()
|
|
|
|
{
|
|
|
|
return QDir::homePath() + QLatin1String("/valentina/") + tr("layouts");
|
|
|
|
}
|
|
|
|
|
2015-01-26 15:08:09 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QString VSettings::GetPathLayout() const
|
|
|
|
{
|
2015-10-18 15:13:51 +02:00
|
|
|
QSettings settings(this->format(), this->scope(), this->organizationName(), this->applicationName());
|
2018-03-14 14:39:15 +01:00
|
|
|
return settings.value(*settingPathsLayout, GetDefPathLayout()).toString();
|
2015-01-26 15:08:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VSettings::SetPathLayout(const QString &value)
|
|
|
|
{
|
2015-10-18 15:13:51 +02:00
|
|
|
QSettings settings(this->format(), this->scope(), this->organizationName(), this->applicationName());
|
2018-03-14 14:39:15 +01:00
|
|
|
settings.setValue(*settingPathsLayout, value);
|
2015-10-18 14:38:05 +02:00
|
|
|
settings.sync();
|
2015-01-26 15:08:09 +01:00
|
|
|
}
|
|
|
|
|
2014-11-22 17:15:47 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-11-28 19:41:46 +01:00
|
|
|
bool VSettings::GetGraphicalOutput() const
|
2014-11-22 17:15:47 +01:00
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
return value(*settingPatternGraphicalOutput, 1).toBool();
|
2014-11-22 17:15:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VSettings::SetGraphicalOutput(const bool &value)
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
setValue(*settingPatternGraphicalOutput, value);
|
2014-11-22 17:15:47 +01:00
|
|
|
}
|
|
|
|
|
2018-03-10 15:39:37 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool VSettings::IsOpenGLRender() const
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
return value(*settingPatternUseOpenGLRender, 0).toBool();
|
2018-03-10 15:39:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VSettings::SetOpenGLRender(bool value)
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
setValue(*settingPatternUseOpenGLRender, value);
|
2018-03-10 15:39:37 +01:00
|
|
|
}
|
|
|
|
|
2015-05-08 16:24:20 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-11-05 12:07:51 +01:00
|
|
|
qreal VSettings::GetLayoutPaperHeight() const
|
2015-05-08 16:24:20 +02:00
|
|
|
{
|
2015-11-05 12:07:51 +01:00
|
|
|
const qreal def = UnitConvertor(1189/*A0*/, Unit::Mm, Unit::Px);
|
2015-05-08 16:24:20 +02:00
|
|
|
bool ok = false;
|
2018-03-14 14:39:15 +01:00
|
|
|
const qreal height = value(*settingLayoutPaperHeight, def).toDouble(&ok);
|
2015-05-08 16:24:20 +02:00
|
|
|
if (ok)
|
|
|
|
{
|
|
|
|
return height;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return def;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-11-05 12:07:51 +01:00
|
|
|
void VSettings::SetLayoutPaperHeight(qreal value)
|
2015-05-08 16:24:20 +02:00
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
setValue(*settingLayoutPaperHeight, value);
|
2015-05-08 16:24:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-11-05 12:07:51 +01:00
|
|
|
qreal VSettings::GetLayoutPaperWidth() const
|
2015-05-08 16:24:20 +02:00
|
|
|
{
|
2015-11-05 12:07:51 +01:00
|
|
|
const qreal def = UnitConvertor(841/*A0*/, Unit::Mm, Unit::Px);
|
2015-05-08 16:24:20 +02:00
|
|
|
bool ok = false;
|
2018-03-14 14:39:15 +01:00
|
|
|
const qreal width = value(*settingLayoutPaperWidth, def).toDouble(&ok);
|
2015-05-08 16:24:20 +02:00
|
|
|
if (ok)
|
|
|
|
{
|
|
|
|
return width;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return def;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-11-05 12:07:51 +01:00
|
|
|
void VSettings::SetLayoutPaperWidth(qreal value)
|
2015-05-08 16:24:20 +02:00
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
setValue(*settingLayoutPaperWidth, value);
|
2015-05-08 16:24:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-11-05 13:32:47 +01:00
|
|
|
qreal VSettings::GetLayoutShift() const
|
2015-05-08 16:24:20 +02:00
|
|
|
{
|
2015-11-05 13:32:47 +01:00
|
|
|
const qreal def = GetDefLayoutShift();
|
2015-05-08 16:24:20 +02:00
|
|
|
bool ok = false;
|
2018-03-14 14:39:15 +01:00
|
|
|
const qreal shift = value(*settingLayoutShift, def).toDouble(&ok);
|
2015-05-08 16:24:20 +02:00
|
|
|
if (ok)
|
|
|
|
{
|
|
|
|
return shift;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return def;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-11-05 12:07:51 +01:00
|
|
|
qreal VSettings::GetDefLayoutShift()
|
2015-05-08 16:24:20 +02:00
|
|
|
{
|
2016-03-28 16:19:29 +02:00
|
|
|
return 0;
|
2015-05-08 16:24:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-11-05 13:32:47 +01:00
|
|
|
void VSettings::SetLayoutShift(qreal value)
|
2015-05-08 16:24:20 +02:00
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
setValue(*settingLayoutShift, value);
|
2015-05-08 16:24:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-11-05 13:32:47 +01:00
|
|
|
qreal VSettings::GetLayoutWidth() const
|
2015-05-08 16:24:20 +02:00
|
|
|
{
|
2015-11-05 13:32:47 +01:00
|
|
|
const qreal def = GetDefLayoutWidth();
|
2015-05-08 16:24:20 +02:00
|
|
|
bool ok = false;
|
2018-03-14 14:39:15 +01:00
|
|
|
const qreal lWidth = value(*settingLayoutWidth, def).toDouble(&ok);
|
2015-05-08 16:24:20 +02:00
|
|
|
if (ok)
|
|
|
|
{
|
|
|
|
return lWidth;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return def;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-11-05 12:07:51 +01:00
|
|
|
qreal VSettings::GetDefLayoutWidth()
|
2015-05-08 16:24:20 +02:00
|
|
|
{
|
2015-11-05 12:07:51 +01:00
|
|
|
return UnitConvertor(2.5, Unit::Mm, Unit::Px);
|
2015-05-08 16:24:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-11-05 13:32:47 +01:00
|
|
|
void VSettings::SetLayoutWidth(qreal value)
|
2015-05-08 16:24:20 +02:00
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
setValue(*settingLayoutWidth, value);
|
2015-05-08 16:24:20 +02:00
|
|
|
}
|
|
|
|
|
2015-11-09 12:33:36 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2016-09-30 18:33:10 +02:00
|
|
|
QMarginsF VSettings::GetFields(const QMarginsF &def) const
|
2015-11-09 12:33:36 +01:00
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
const QVariant val = value(*settingFields, QVariant::fromValue(def));
|
2015-11-09 12:33:36 +01:00
|
|
|
if (val.canConvert<QMarginsF>())
|
|
|
|
{
|
|
|
|
return val.value<QMarginsF>();
|
|
|
|
}
|
|
|
|
return def;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VSettings::SetFields(const QMarginsF &value)
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
setValue(*settingFields, QVariant::fromValue(value));
|
2015-11-09 12:33:36 +01:00
|
|
|
}
|
|
|
|
|
2015-05-08 16:24:20 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
Cases VSettings::GetLayoutGroup() const
|
|
|
|
{
|
|
|
|
const Cases def = GetDefLayoutGroup();
|
|
|
|
bool ok = false;
|
2018-03-14 14:39:15 +01:00
|
|
|
const int g = value(*settingLayoutSorting, static_cast<int>(def)).toInt(&ok);
|
2015-05-08 16:24:20 +02:00
|
|
|
if (ok)
|
|
|
|
{
|
|
|
|
if (g >= static_cast<int>(Cases::UnknownCase))
|
|
|
|
{
|
|
|
|
return def;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return static_cast<Cases>(g);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return def;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
Cases VSettings::GetDefLayoutGroup()
|
|
|
|
{
|
|
|
|
return Cases::CaseDesc;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VSettings::SetLayoutGroup(const Cases &value)
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
setValue(*settingLayoutSorting, static_cast<int>(value));
|
2015-05-08 16:24:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool VSettings::GetLayoutRotate() const
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
return value(*settingLayoutRotate, GetDefLayoutRotate()).toBool();
|
2015-05-08 16:24:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool VSettings::GetDefLayoutRotate()
|
|
|
|
{
|
2016-03-28 16:19:29 +02:00
|
|
|
return false;
|
2015-05-08 16:24:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VSettings::SetLayoutRotate(bool value)
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
setValue(*settingLayoutRotate, value);
|
2015-05-08 16:24:20 +02:00
|
|
|
}
|
|
|
|
|
2018-12-27 14:54:29 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool VSettings::GetLayoutFollowGrainline() const
|
|
|
|
{
|
|
|
|
return value(*settingLayoutFollowGrainline, GetDefLayoutFollowGrainline()).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool VSettings::GetDefLayoutFollowGrainline()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VSettings::SetLayoutFollowGrainline(bool value)
|
|
|
|
{
|
|
|
|
setValue(*settingLayoutFollowGrainline, value);
|
|
|
|
}
|
|
|
|
|
2015-05-08 16:24:20 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
int VSettings::GetLayoutRotationIncrease() const
|
|
|
|
{
|
|
|
|
const int def = GetDefLayoutRotationIncrease();
|
|
|
|
bool ok = false;
|
2018-03-14 14:39:15 +01:00
|
|
|
const int r = value(*settingLayoutRotationIncrease, def).toInt(&ok);
|
2015-05-08 16:24:20 +02:00
|
|
|
if (ok)
|
|
|
|
{
|
|
|
|
if (not (r >= 1 && r <= 180 && 360 % r == 0))
|
|
|
|
{
|
|
|
|
return def;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return def;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
int VSettings::GetDefLayoutRotationIncrease()
|
|
|
|
{
|
|
|
|
return 180;/*degree*/
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VSettings::SetLayoutRotationIncrease(int value)
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
setValue(*settingLayoutRotationIncrease, value);
|
2015-05-08 16:24:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool VSettings::GetLayoutAutoCrop() const
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
return value(*settingLayoutAutoCrop, GetDefLayoutAutoCrop()).toBool();
|
2015-11-09 12:33:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool VSettings::GetDefLayoutAutoCrop()
|
|
|
|
{
|
|
|
|
return false;
|
2015-05-08 16:24:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VSettings::SetLayoutAutoCrop(bool value)
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
setValue(*settingLayoutAutoCrop, value);
|
2015-05-08 16:24:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool VSettings::GetLayoutSaveLength() const
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
return value(*settingLayoutSaveLength, GetDefLayoutSaveLength()).toBool();
|
2015-11-09 12:33:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool VSettings::GetDefLayoutSaveLength()
|
|
|
|
{
|
|
|
|
return false;
|
2015-05-08 16:24:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VSettings::SetLayoutSaveLength(bool value)
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
setValue(*settingLayoutSaveLength, value);
|
2015-05-08 16:24:20 +02:00
|
|
|
}
|
|
|
|
|
2015-05-18 13:26:37 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool VSettings::GetLayoutUnitePages() const
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
return value(*settingLayoutUnitePages, GetDefLayoutUnitePages()).toBool();
|
2015-11-09 12:33:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool VSettings::GetDefLayoutUnitePages()
|
|
|
|
{
|
|
|
|
return false;
|
2015-05-18 13:26:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VSettings::SetLayoutUnitePages(bool value)
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
setValue(*settingLayoutUnitePages, value);
|
2015-05-18 13:26:37 +02:00
|
|
|
}
|
|
|
|
|
2015-11-09 12:33:36 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool VSettings::GetIgnoreAllFields() const
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
return value(*settingIgnoreFields, GetDefIgnoreAllFields()).toBool();
|
2015-11-09 12:33:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool VSettings::GetDefIgnoreAllFields()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VSettings::SetIgnoreAllFields(bool value)
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
setValue(*settingIgnoreFields, value);
|
2015-11-09 12:33:36 +01:00
|
|
|
}
|
2016-02-23 13:13:10 +01:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool VSettings::GetStripOptimization() const
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
return value(*settingStripOptimization, GetDefStripOptimization()).toBool();
|
2016-02-23 13:13:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool VSettings::GetDefStripOptimization()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VSettings::SetStripOptimization(bool value)
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
setValue(*settingStripOptimization, value);
|
2016-02-23 13:13:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
quint8 VSettings::GetMultiplier() const
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
return static_cast<quint8>(value(*settingMultiplier, GetDefMultiplier()).toUInt());
|
2016-02-23 13:13:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
quint8 VSettings::GetDefMultiplier()
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VSettings::SetMultiplier(quint8 value)
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
setValue(*settingMultiplier, value);
|
2016-02-23 13:13:10 +01:00
|
|
|
}
|
2016-08-12 01:22:23 +02:00
|
|
|
|
2017-07-01 19:32:54 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool VSettings::GetTextAsPaths() const
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
return value(*settingTextAsPaths, GetDefTextAsPaths()).toBool();
|
2017-07-01 19:32:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool VSettings::GetDefTextAsPaths()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VSettings::SetTextAsPaths(bool value)
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
setValue(*settingTextAsPaths, value);
|
2017-07-01 19:32:54 +02:00
|
|
|
}
|
|
|
|
|
2017-08-28 15:03:19 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QStringList VSettings::GetKnownMaterials() const
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
return value(*settingPatternKnownMaterials, QStringList()).toStringList();
|
2017-08-28 15:03:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VSettings::SetKnownMaterials(const QStringList &list)
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
setValue(*settingPatternKnownMaterials, list);
|
2017-08-28 15:03:19 +02:00
|
|
|
}
|
2017-08-30 06:26:18 +02:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool VSettings::IsRememberPatternMaterials() const
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
return value(*settingPatternRememberMaterials, true).toBool();
|
2017-08-30 06:26:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VSettings::SetRememberPatternMaterials(bool value)
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
setValue(*settingPatternRememberMaterials, value);
|
2017-08-30 06:26:18 +02:00
|
|
|
}
|
2017-10-10 11:22:59 +02:00
|
|
|
|
|
|
|
// settings for the tiled PDFs
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
/**
|
|
|
|
* @brief GetTiledPDFMargins returns the tiled pdf margins in the given unit. When the setting is
|
|
|
|
* called for the first time, the 4 default margins are 10mm.
|
2017-10-12 09:35:22 +02:00
|
|
|
* @param unit the unit in which are the value. Necessary because we save the values
|
|
|
|
* internaly as mm so there is conversion beeing made.
|
|
|
|
* @return tiled pdf margins
|
2017-10-10 11:22:59 +02:00
|
|
|
*/
|
|
|
|
QMarginsF VSettings::GetTiledPDFMargins(const Unit &unit) const
|
|
|
|
{
|
|
|
|
// default value is 10mm. We save the margins in mm in the setting.
|
|
|
|
const QMarginsF def = QMarginsF(10, 10, 10, 10);
|
|
|
|
|
2018-03-14 14:39:15 +01:00
|
|
|
const QVariant val = value(*settingTiledPDFMargins, QVariant::fromValue(def));
|
2017-10-10 11:22:59 +02:00
|
|
|
|
|
|
|
if (val.canConvert<QMarginsF>())
|
|
|
|
{
|
|
|
|
return UnitConvertor(val.value<QMarginsF>(), Unit::Mm, unit);
|
|
|
|
}
|
|
|
|
return UnitConvertor(def, Unit::Mm, unit);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
/**
|
|
|
|
* @brief SetTiledPDFMargins sets the setting tiled pdf margins to the given value.
|
|
|
|
* @param value the margins to save
|
|
|
|
* @param unit the unit in which are the value. Necessary because we save the values
|
|
|
|
* internaly as mm so there is conversion beeing made.
|
|
|
|
*/
|
|
|
|
void VSettings::SetTiledPDFMargins(const QMarginsF &value, const Unit &unit)
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
setValue(*settingTiledPDFMargins, QVariant::fromValue(UnitConvertor(value, unit, Unit::Mm)));
|
2017-10-10 11:22:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
/**
|
|
|
|
* @brief GetTiledPDFPaperHeight returns the paper height of tiled pdf in the desired unit.
|
2017-10-12 09:35:22 +02:00
|
|
|
* @param unit the unit in which are the value. Necessary because we save the values
|
|
|
|
* internaly as mm so there is conversion beeing made.
|
|
|
|
* @return tiled pdf paper height
|
2017-10-10 11:22:59 +02:00
|
|
|
*/
|
|
|
|
qreal VSettings::GetTiledPDFPaperHeight(const Unit &unit) const
|
|
|
|
{
|
|
|
|
const qreal def = 297 /*A4*/;
|
|
|
|
bool ok = false;
|
2018-03-14 14:39:15 +01:00
|
|
|
const qreal height = value(*settingTiledPDFPaperHeight, def).toDouble(&ok);
|
2017-10-10 11:22:59 +02:00
|
|
|
if (ok)
|
|
|
|
{
|
|
|
|
return UnitConvertor(height, Unit::Mm, unit);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return UnitConvertor(def, Unit::Mm, unit);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
/**
|
|
|
|
* @brief SetTiledPDFPaperHeight sets the tiled pdf paper height
|
2017-10-12 09:35:22 +02:00
|
|
|
* @param value in mm
|
2017-10-10 11:22:59 +02:00
|
|
|
* @param unit unit of the given value
|
|
|
|
*/
|
|
|
|
void VSettings::SetTiledPDFPaperHeight(qreal value, const Unit &unit)
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
setValue(*settingTiledPDFPaperHeight, UnitConvertor(value, unit, Unit::Mm));
|
2017-10-10 11:22:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
/**
|
|
|
|
* @brief GetTiledPDFPaperWidth returns the paper height of tiled pdf in the desired unit.
|
2017-10-12 09:35:22 +02:00
|
|
|
* @param unit the unit in which are the value. Necessary because we save the values
|
|
|
|
* internaly as mm so there is conversion beeing made.
|
|
|
|
* @return tiled pdf paper width
|
2017-10-10 11:22:59 +02:00
|
|
|
*/
|
|
|
|
qreal VSettings::GetTiledPDFPaperWidth(const Unit &unit) const
|
|
|
|
{
|
|
|
|
|
|
|
|
const qreal def = 210 /*A4*/;
|
|
|
|
bool ok = false;
|
2018-03-14 14:39:15 +01:00
|
|
|
const qreal width = value(*settingTiledPDFPaperWidth, def).toDouble(&ok);
|
2017-10-10 11:22:59 +02:00
|
|
|
if (ok)
|
|
|
|
{
|
|
|
|
return UnitConvertor(width, Unit::Mm, unit);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return UnitConvertor(def, Unit::Mm, unit);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
/**
|
|
|
|
* @brief SetTiledPDFPaperWidth sets the tiled pdf paper width
|
|
|
|
* @param unit unit of the given value
|
2017-10-12 09:35:22 +02:00
|
|
|
* @param value in mm
|
2017-10-10 11:22:59 +02:00
|
|
|
*/
|
|
|
|
void VSettings::SetTiledPDFPaperWidth(qreal value, const Unit &unit)
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
setValue(*settingTiledPDFPaperWidth, UnitConvertor(value,unit, Unit::Mm));
|
2017-10-10 11:22:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
PageOrientation VSettings::GetTiledPDFOrientation() const
|
|
|
|
{
|
|
|
|
bool defaultValue = static_cast<bool>(PageOrientation::Portrait);
|
2018-03-14 14:39:15 +01:00
|
|
|
bool result = value(*settingTiledPDFOrientation, defaultValue).toBool();
|
2017-10-10 11:22:59 +02:00
|
|
|
return static_cast<PageOrientation>(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VSettings::SetTiledPDFOrientation(PageOrientation value)
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
setValue(*settingTiledPDFOrientation, static_cast<bool> (value));
|
2017-10-10 11:22:59 +02:00
|
|
|
}
|
|
|
|
|
2018-05-11 11:42:20 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
int VSettings::GetScrollingDuration() const
|
|
|
|
{
|
|
|
|
return GetCachedValue(scrollingDurationCached, *settingScrollingDuration, defaultScrollingDuration,
|
|
|
|
scrollingDurationMin, scrollingDurationMax);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VSettings::SetScrollingDuration(int duration)
|
|
|
|
{
|
|
|
|
scrollingDurationCached = qBound(scrollingDurationMin, duration, scrollingDurationMax);
|
|
|
|
setValue(*settingScrollingDuration, scrollingDurationCached);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
int VSettings::GetScrollingUpdateInterval() const
|
|
|
|
{
|
|
|
|
return GetCachedValue(scrollingUpdateIntervalCached, *settingScrollingUpdateInterval,
|
|
|
|
defaultScrollingUpdateInterval, scrollingUpdateIntervalMin, scrollingUpdateIntervalMax);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VSettings::SetScrollingUpdateInterval(int updateInterval)
|
|
|
|
{
|
|
|
|
scrollingUpdateIntervalCached = qBound(scrollingUpdateIntervalMin, updateInterval, scrollingUpdateIntervalMax);
|
|
|
|
setValue(*settingScrollingUpdateInterval, scrollingUpdateIntervalCached);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
qreal VSettings::GetSensorMouseScale() const
|
|
|
|
{
|
|
|
|
return GetCachedValue(scrollingSensorMouseScaleCached, *settingScrollingSensorMouseScale, defaultSensorMouseScale,
|
|
|
|
sensorMouseScaleMin, sensorMouseScaleMax);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VSettings::SetSensorMouseScale(qreal scale)
|
|
|
|
{
|
|
|
|
scrollingSensorMouseScaleCached = qBound(sensorMouseScaleMin, scale, sensorMouseScaleMax);
|
|
|
|
setValue(*settingScrollingSensorMouseScale, scrollingSensorMouseScaleCached);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
qreal VSettings::GetWheelMouseScale() const
|
|
|
|
{
|
|
|
|
return GetCachedValue(scrollingWheelMouseScaleCached, *settingScrollingWheelMouseScale, defaultWheelMouseScale,
|
|
|
|
wheelMouseScaleMin, wheelMouseScaleMax);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VSettings::SetWheelMouseScale(qreal scale)
|
|
|
|
{
|
|
|
|
scrollingWheelMouseScaleCached = qBound(wheelMouseScaleMin, scale, wheelMouseScaleMax);
|
|
|
|
setValue(*settingScrollingWheelMouseScale, scrollingWheelMouseScaleCached);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
qreal VSettings::GetScrollingAcceleration() const
|
|
|
|
{
|
|
|
|
return GetCachedValue(scrollingAccelerationCached, *settingScrollingAcceleration, defaultScrollingAcceleration,
|
|
|
|
scrollingAccelerationMin, scrollingAccelerationMax);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VSettings::SetScrollingAcceleration(qreal acceleration)
|
|
|
|
{
|
|
|
|
scrollingAccelerationCached = qBound(scrollingAccelerationMin, acceleration, scrollingAccelerationMax);
|
|
|
|
setValue(*settingScrollingAcceleration, scrollingAccelerationCached);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
template<typename T>
|
|
|
|
T VSettings::GetCachedValue(T &cache, const QString &setting, T defValue, T valueMin, T valueMax) const
|
|
|
|
{
|
|
|
|
if (cache < 0)
|
|
|
|
{
|
|
|
|
const QVariant val = value(setting, defValue);
|
|
|
|
cache = val.canConvert<T>() ? qBound(valueMin, val.value<T>(), valueMax) : defValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
return cache;
|
|
|
|
}
|