Redesign settings.

All apps settings classes moved to binaries. Use common part to get access from static libraries. Fixed issues with VMainGraphicsView class.
This commit is contained in:
Roman Telezhynskyi 2020-05-10 18:32:14 +03:00
parent 02b21d818f
commit 7b1449f11e
38 changed files with 548 additions and 468 deletions

View File

@ -18,6 +18,7 @@ SOURCES += \
$$PWD/vpuzzlemaingraphicsview.cpp \ $$PWD/vpuzzlemaingraphicsview.cpp \
$$PWD/vpuzzlemimedatapiece.cpp \ $$PWD/vpuzzlemimedatapiece.cpp \
$$PWD/vpuzzlepiece.cpp \ $$PWD/vpuzzlepiece.cpp \
$$PWD/vpuzzlesettings.cpp \
$$PWD/xml/layoutliterals.cpp \ $$PWD/xml/layoutliterals.cpp \
$$PWD/xml/vpuzzlelayoutfilewriter.cpp \ $$PWD/xml/vpuzzlelayoutfilewriter.cpp \
$$PWD/xml/vpuzzlelayoutfilereader.cpp \ $$PWD/xml/vpuzzlelayoutfilereader.cpp \
@ -43,6 +44,7 @@ HEADERS += \
$$PWD/vpuzzlemaingraphicsview.h \ $$PWD/vpuzzlemaingraphicsview.h \
$$PWD/vpuzzlemimedatapiece.h \ $$PWD/vpuzzlemimedatapiece.h \
$$PWD/vpuzzlepiece.h \ $$PWD/vpuzzlepiece.h \
$$PWD/vpuzzlesettings.h \
$$PWD/xml/layoutliterals.h \ $$PWD/xml/layoutliterals.h \
$$PWD/xml/vpuzzlelayoutfilewriter.h \ $$PWD/xml/vpuzzlelayoutfilewriter.h \
$$PWD/xml/vpuzzlelayoutfilereader.h \ $$PWD/xml/vpuzzlelayoutfilereader.h \

View File

@ -197,14 +197,14 @@ noRunPath{ # For enable run qmake with CONFIG+=noRunPath
#win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vtools/$${DESTDIR}/vtools.lib #win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vtools/$${DESTDIR}/vtools.lib
#else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vtools/$${DESTDIR}/libvtools.a #else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vtools/$${DESTDIR}/libvtools.a
##VWidgets static library #VWidgets static library
#unix|win32: LIBS += -L$$OUT_PWD/../../libs/vwidgets/$${DESTDIR}/ -lvwidgets unix|win32: LIBS += -L$$OUT_PWD/../../libs/vwidgets/$${DESTDIR}/ -lvwidgets
#INCLUDEPATH += $$PWD/../../libs/vwidgets INCLUDEPATH += $$PWD/../../libs/vwidgets
#DEPENDPATH += $$PWD/../../libs/vwidgets DEPENDPATH += $$PWD/../../libs/vwidgets
#win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vwidgets/$${DESTDIR}/vwidgets.lib win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vwidgets/$${DESTDIR}/vwidgets.lib
#else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vwidgets/$${DESTDIR}/libvwidgets.a else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vwidgets/$${DESTDIR}/libvwidgets.a
## VFormat static library (depend on VPatternDB, IFC) ## VFormat static library (depend on VPatternDB, IFC)
#unix|win32: LIBS += -L$$OUT_PWD/../../libs/vformat/$${DESTDIR}/ -lvformat #unix|win32: LIBS += -L$$OUT_PWD/../../libs/vformat/$${DESTDIR}/ -lvformat
@ -277,13 +277,13 @@ else:unix: LIBS += -L$${OUT_PWD}/../../libs/qmuparser/$${DESTDIR} -lqmuparser
INCLUDEPATH += $${PWD}/../../libs/qmuparser INCLUDEPATH += $${PWD}/../../libs/qmuparser
DEPENDPATH += $${PWD}/../../libs/qmuparser DEPENDPATH += $${PWD}/../../libs/qmuparser
## VPropertyExplorer library # VPropertyExplorer library
#win32:CONFIG(release, debug|release): LIBS += -L$${OUT_PWD}/../../libs/vpropertyexplorer/$${DESTDIR} -lvpropertyexplorer win32:CONFIG(release, debug|release): LIBS += -L$${OUT_PWD}/../../libs/vpropertyexplorer/$${DESTDIR} -lvpropertyexplorer
#else:win32:CONFIG(debug, debug|release): LIBS += -L$${OUT_PWD}/../../libs/vpropertyexplorer/$${DESTDIR} -lvpropertyexplorer else:win32:CONFIG(debug, debug|release): LIBS += -L$${OUT_PWD}/../../libs/vpropertyexplorer/$${DESTDIR} -lvpropertyexplorer
#else:unix: LIBS += -L$${OUT_PWD}/../../libs/vpropertyexplorer/$${DESTDIR} -lvpropertyexplorer else:unix: LIBS += -L$${OUT_PWD}/../../libs/vpropertyexplorer/$${DESTDIR} -lvpropertyexplorer
#INCLUDEPATH += $${PWD}/../../libs/vpropertyexplorer INCLUDEPATH += $${PWD}/../../libs/vpropertyexplorer
#DEPENDPATH += $${PWD}/../../libs/vpropertyexplorer DEPENDPATH += $${PWD}/../../libs/vpropertyexplorer
contains(DEFINES, APPIMAGE) { contains(DEFINES, APPIMAGE) {
unix:!macx: LIBS += -licudata -licui18n -licuuc unix:!macx: LIBS += -licudata -licui18n -licuuc

View File

@ -29,7 +29,7 @@
#define PUZZLEAPPLICATION_H #define PUZZLEAPPLICATION_H
#include "../vmisc/def.h" #include "../vmisc/def.h"
#include "../vmisc/vpuzzlesettings.h" #include "vpuzzlesettings.h"
#include "../vmisc/vabstractapplication.h" #include "../vmisc/vabstractapplication.h"
#include "vpuzzlecommandline.h" #include "vpuzzlecommandline.h"

View File

@ -0,0 +1,81 @@
/************************************************************************
**
** @file vpuzzlesettings.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 16 2, 2020
**
** @brief
** @copyright
** This source code is part of the Valentina project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2020 Valentina project
** <https://gitlab.com/smart-pattern/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 "vpuzzlesettings.h"
namespace
{
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDockWidgetPropertiesActive, (QLatin1String("dockWidget/properties")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDockPropertiesContentsActive, (QLatin1String("dockWidget/contents")))
}
//---------------------------------------------------------------------------------------------------------------------
VPuzzleSettings::VPuzzleSettings(Format format, Scope scope, const QString &organization, const QString &application,
QObject *parent)
: VCommonSettings(format, scope, organization, application, parent)
{}
//---------------------------------------------------------------------------------------------------------------------
VPuzzleSettings::VPuzzleSettings(const QString &fileName, QSettings::Format format, QObject *parent)
: VCommonSettings(fileName, format, parent)
{}
//---------------------------------------------------------------------------------------------------------------------
bool VPuzzleSettings::IsDockWidgetPropertiesActive() const
{
return value(*settingDockWidgetPropertiesActive, GetDefDockWidgetPropertiesActive()).toBool();
}
//---------------------------------------------------------------------------------------------------------------------
bool VPuzzleSettings::GetDefDockWidgetPropertiesActive()
{
return true;
}
//---------------------------------------------------------------------------------------------------------------------
void VPuzzleSettings::SetDockWidgetPropertiesActive(bool value)
{
setValue(*settingDockWidgetPropertiesActive, value);
}
//---------------------------------------------------------------------------------------------------------------------
bool VPuzzleSettings::IsDockWidgetPropertiesContentsActive() const
{
return value(*settingDockWidgetPropertiesActive, GetDefDockWidgetPropertiesActive()).toBool();
}
//---------------------------------------------------------------------------------------------------------------------
bool VPuzzleSettings::GetDefDockWidgetPropertiesContentsActive()
{
return true;
}
//---------------------------------------------------------------------------------------------------------------------
void VPuzzleSettings::SetDockWidgetPropertiesContentsActive(bool value)
{
setValue(*settingDockPropertiesContentsActive, value);
}

View File

@ -38,6 +38,15 @@ class VPuzzleSettings : public VCommonSettings
public: public:
VPuzzleSettings(Format format, Scope scope, const QString &organization, const QString &application = QString(), VPuzzleSettings(Format format, Scope scope, const QString &organization, const QString &application = QString(),
QObject *parent = nullptr); QObject *parent = nullptr);
VPuzzleSettings(const QString &fileName, Format format, QObject *parent = nullptr);
bool IsDockWidgetPropertiesActive() const;
static bool GetDefDockWidgetPropertiesActive();
void SetDockWidgetPropertiesActive(bool value);
bool IsDockWidgetPropertiesContentsActive() const;
static bool GetDefDockWidgetPropertiesContentsActive();
void SetDockWidgetPropertiesContentsActive(bool value);
private: private:
Q_DISABLE_COPY(VPuzzleSettings) Q_DISABLE_COPY(VPuzzleSettings)

View File

@ -29,7 +29,7 @@
#include "tapepreferencesconfigurationpage.h" #include "tapepreferencesconfigurationpage.h"
#include "ui_tapepreferencesconfigurationpage.h" #include "ui_tapepreferencesconfigurationpage.h"
#include "../../mapplication.h" #include "../../mapplication.h"
#include "../vmisc/vtapesettings.h" #include "../../vtapesettings.h"
#include "../vpatterndb/variables/vmeasurement.h" #include "../vpatterndb/variables/vmeasurement.h"
#include "../vpatterndb/pmsystems.h" #include "../vpatterndb/pmsystems.h"

View File

@ -29,7 +29,7 @@
#include "tapepreferencespathpage.h" #include "tapepreferencespathpage.h"
#include "ui_tapepreferencespathpage.h" #include "ui_tapepreferencespathpage.h"
#include "../../mapplication.h" #include "../../mapplication.h"
#include "../vmisc/vtapesettings.h" #include "../../vtapesettings.h"
#include <QDir> #include <QDir>
#include <QFileDialog> #include <QFileDialog>

View File

@ -30,7 +30,7 @@
#include "ui_dialognewmeasurements.h" #include "ui_dialognewmeasurements.h"
#include "../vpatterndb/variables/vmeasurement.h" #include "../vpatterndb/variables/vmeasurement.h"
#include "../vmisc/vtapesettings.h" #include "../vtapesettings.h"
#include "../mapplication.h" #include "../mapplication.h"
#include <QShowEvent> #include <QShowEvent>

View File

@ -31,7 +31,7 @@
#include "../vpatterndb/vtranslatevars.h" #include "../vpatterndb/vtranslatevars.h"
#include "../vmisc/def.h" #include "../vmisc/def.h"
#include "../vmisc/vtapesettings.h" #include "vtapesettings.h"
#include "../vmisc/vabstractapplication.h" #include "../vmisc/vabstractapplication.h"
#include "dialogs/dialogmdatabase.h" #include "dialogs/dialogmdatabase.h"

View File

@ -11,7 +11,8 @@ SOURCES += \
$$PWD/vlitepattern.cpp \ $$PWD/vlitepattern.cpp \
$$PWD/dialogs/dialogtapepreferences.cpp \ $$PWD/dialogs/dialogtapepreferences.cpp \
$$PWD/dialogs/configpages/tapepreferencesconfigurationpage.cpp \ $$PWD/dialogs/configpages/tapepreferencesconfigurationpage.cpp \
$$PWD/dialogs/configpages/tapepreferencespathpage.cpp $$PWD/dialogs/configpages/tapepreferencespathpage.cpp \
$$PWD/vtapesettings.cpp
*msvc*:SOURCES += $$PWD/stable.cpp *msvc*:SOURCES += $$PWD/stable.cpp
@ -26,7 +27,8 @@ HEADERS += \
$$PWD/vlitepattern.h \ $$PWD/vlitepattern.h \
$$PWD/dialogs/dialogtapepreferences.h \ $$PWD/dialogs/dialogtapepreferences.h \
$$PWD/dialogs/configpages/tapepreferencesconfigurationpage.h \ $$PWD/dialogs/configpages/tapepreferencesconfigurationpage.h \
$$PWD/dialogs/configpages/tapepreferencespathpage.h $$PWD/dialogs/configpages/tapepreferencespathpage.h \
$$PWD/vtapesettings.h
FORMS += \ FORMS += \
$$PWD/tmainwindow.ui \ $$PWD/tmainwindow.ui \

View File

@ -6,11 +6,13 @@ HEADERS += \
$$PWD/vformulaproperty.h \ $$PWD/vformulaproperty.h \
$$PWD/vformulapropertyeditor.h \ $$PWD/vformulapropertyeditor.h \
$$PWD/vtooloptionspropertybrowser.h \ $$PWD/vtooloptionspropertybrowser.h \
$$PWD/vcmdexport.h $$PWD/vcmdexport.h \
$$PWD/vvalentinasettings.h
SOURCES += \ SOURCES += \
$$PWD/vapplication.cpp \ $$PWD/vapplication.cpp \
$$PWD/vformulaproperty.cpp \ $$PWD/vformulaproperty.cpp \
$$PWD/vformulapropertyeditor.cpp \ $$PWD/vformulapropertyeditor.cpp \
$$PWD/vtooloptionspropertybrowser.cpp \ $$PWD/vtooloptionspropertybrowser.cpp \
$$PWD/vcmdexport.cpp $$PWD/vcmdexport.cpp \
$$PWD/vvalentinasettings.cpp

View File

@ -447,7 +447,7 @@ bool VApplication::notify(QObject *receiver, QEvent *event)
void VApplication::ActivateDarkMode() void VApplication::ActivateDarkMode()
{ {
VSettings *settings = qApp->ValentinaSettings(); VValentinaSettings *settings = qApp->ValentinaSettings();
if (settings->GetDarkMode()) if (settings->GetDarkMode())
{ {
QFile f(QStringLiteral(":qdarkstyle/style.qss")); QFile f(QStringLiteral(":qdarkstyle/style.qss"));
@ -726,15 +726,15 @@ void VApplication::AboutToQuit()
*/ */
void VApplication::OpenSettings() void VApplication::OpenSettings()
{ {
settings = new VSettings(QSettings::IniFormat, QSettings::UserScope, QCoreApplication::organizationName(), settings = new VValentinaSettings(QSettings::IniFormat, QSettings::UserScope, QCoreApplication::organizationName(),
QCoreApplication::applicationName(), this); QCoreApplication::applicationName(), this);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VSettings *VApplication::ValentinaSettings() VValentinaSettings *VApplication::ValentinaSettings()
{ {
SCASSERT(settings != nullptr) SCASSERT(settings != nullptr)
return qobject_cast<VSettings *>(settings); return qobject_cast<VValentinaSettings *>(settings);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -32,7 +32,7 @@
#include "../vmisc/vabstractapplication.h" #include "../vmisc/vabstractapplication.h"
#include "../vwidgets/vmaingraphicsview.h" #include "../vwidgets/vmaingraphicsview.h"
#include "../vpatterndb/vtranslatevars.h" #include "../vpatterndb/vtranslatevars.h"
#include "vsettings.h" #include "vvalentinasettings.h"
#include "vcmdexport.h" #include "vcmdexport.h"
class VApplication;// use in define class VApplication;// use in define
@ -76,7 +76,7 @@ public:
virtual bool IsPedantic() const override; virtual bool IsPedantic() const override;
virtual void OpenSettings() override; virtual void OpenSettings() override;
VSettings *ValentinaSettings(); VValentinaSettings *ValentinaSettings();
protected: protected:
virtual void InitTrVars() override; virtual void InitTrVars() override;

View File

@ -32,7 +32,7 @@
#include "../ifc/xml/vdomdocument.h" #include "../ifc/xml/vdomdocument.h"
#include "../vformat/vmeasurements.h" #include "../vformat/vmeasurements.h"
#include "../vmisc/commandoptions.h" #include "../vmisc/commandoptions.h"
#include "../vmisc/vsettings.h" #include "vvalentinasettings.h"
#include "../vmisc/dialogs/dialogexporttocsv.h" #include "../vmisc/dialogs/dialogexporttocsv.h"
#include "../vlayout/vlayoutgenerator.h" #include "../vlayout/vlayoutgenerator.h"
#include "../vpatterndb/variables/vmeasurement.h" #include "../vpatterndb/variables/vmeasurement.h"
@ -801,7 +801,7 @@ QStringList VCommandLine::OptionValues(const QString &option) const
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
int VCommandLine::OptNestingTime() const int VCommandLine::OptNestingTime() const
{ {
int time = VSettings::GetDefNestingTime(); int time = VValentinaSettings::GetDefNestingTime();
if (IsOptionSet(LONG_OPTION_NESTING_TIME)) if (IsOptionSet(LONG_OPTION_NESTING_TIME))
{ {
bool ok = false; bool ok = false;
@ -821,7 +821,7 @@ int VCommandLine::OptNestingTime() const
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
qreal VCommandLine::OptEfficiencyCoefficient() const qreal VCommandLine::OptEfficiencyCoefficient() const
{ {
qreal coefficient = VSettings::GetDefEfficiencyCoefficient(); qreal coefficient = VValentinaSettings::GetDefEfficiencyCoefficient();
if (IsOptionSet(LONG_OPTION_EFFICIENCY_COEFFICIENT)) if (IsOptionSet(LONG_OPTION_EFFICIENCY_COEFFICIENT))
{ {
bool ok = false; bool ok = false;

View File

@ -26,7 +26,7 @@
** **
*************************************************************************/ *************************************************************************/
#include "vsettings.h" #include "vvalentinasettings.h"
#include <QDir> #include <QDir>
#include <QLocale> #include <QLocale>
@ -47,26 +47,6 @@
Q_DECLARE_METATYPE(QMarginsF) Q_DECLARE_METATYPE(QMarginsF)
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;
namespace namespace
{ {
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationLabelLanguage, Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationLabelLanguage,
@ -76,8 +56,6 @@ Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingAutoRefreshPatternMessage,
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsLayout, (QLatin1String("paths/layout"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsLayout, (QLatin1String("paths/layout")))
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, settingPatternKnownMaterials, (QLatin1String("pattern/knownMaterials")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternRememberMaterials, (QLatin1String("pattern/rememberMaterials"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternRememberMaterials, (QLatin1String("pattern/rememberMaterials")))
@ -107,13 +85,6 @@ Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingTiledPDFPaperHeight, (QLatin1Str
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingTiledPDFPaperWidth, (QLatin1String("tiledPDF/paperWidth"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingTiledPDFPaperWidth, (QLatin1String("tiledPDF/paperWidth")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingTiledPDFOrientation, (QLatin1String("tiledPDF/orientation"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingTiledPDFOrientation, (QLatin1String("tiledPDF/orientation")))
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")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingdockWidgetGroupsActive, (QLatin1String("dockWidget/groupsActive"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingdockWidgetGroupsActive, (QLatin1String("dockWidget/groupsActive")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDockWidgetToolOptionsActive, Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDockWidgetToolOptionsActive,
(QLatin1String("dockWidget/toolOptionsActive"))) (QLatin1String("dockWidget/toolOptionsActive")))
@ -122,17 +93,10 @@ Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDockWidgetPatternMessagesActive,
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternMessagesFontSize, (QLatin1String("font/patternMessagesSize"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternMessagesFontSize, (QLatin1String("font/patternMessagesSize")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingWatermarkEditorSize, (QLatin1String("watermarkEditorSize"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingWatermarkEditorSize, (QLatin1String("watermarkEditorSize")))
// 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;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VSettings::VSettings(Format format, Scope scope, const QString &organization, const QString &application, VValentinaSettings::VValentinaSettings(Format format, Scope scope, const QString &organization, const QString &application,
QObject *parent) QObject *parent)
:VCommonSettings(format, scope, organization, application, parent) :VCommonSettings(format, scope, organization, application, parent)
{ {
@ -140,63 +104,39 @@ VSettings::VSettings(Format format, Scope scope, const QString &organization, co
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VSettings::VSettings(const QString &fileName, QSettings::Format format, QObject *parent) VValentinaSettings::VValentinaSettings(const QString &fileName, QSettings::Format format, QObject *parent)
:VCommonSettings(fileName, format, parent) :VCommonSettings(fileName, format, parent)
{ {
qRegisterMetaTypeStreamOperators<QMarginsF>("QMarginsF"); qRegisterMetaTypeStreamOperators<QMarginsF>("QMarginsF");
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
template <class T> QString VValentinaSettings::GetLabelLanguage() const
inline T VSettings::ValueOrDef(const QString &setting, const T &defValue) const
{
const QVariant val = value(setting, QVariant::fromValue(defValue));
return val.canConvert<T>() ? val.value<T>() : defValue;
}
//---------------------------------------------------------------------------------------------------------------------
template <>
inline Cases VSettings::ValueOrDef<Cases>(const QString &setting, const Cases &defValue) const
{
const QVariant val = value(setting, QVariant::fromValue(static_cast<int>(defValue)));
const int g = val.canConvert<int>() ? val.value<int>() : static_cast<int>(defValue);
if (g < static_cast<int>(Cases::CaseThreeGroup) || g >= static_cast<int>(Cases::UnknownCase))
{
return defValue;
}
else
{
return static_cast<Cases>(g);
}
}
//---------------------------------------------------------------------------------------------------------------------
QString VSettings::GetLabelLanguage() const
{ {
return value(*settingConfigurationLabelLanguage, QLocale().bcp47Name()).toString(); return value(*settingConfigurationLabelLanguage, QLocale().bcp47Name()).toString();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VSettings::SetLabelLanguage(const QString &value) void VValentinaSettings::SetLabelLanguage(const QString &value)
{ {
setValue(*settingConfigurationLabelLanguage, value); setValue(*settingConfigurationLabelLanguage, value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString VSettings::GetDefPathLayout() QString VValentinaSettings::GetDefPathLayout()
{ {
return QDir::homePath() + QStringLiteral("/valentina/") + tr("layouts"); return QDir::homePath() + QStringLiteral("/valentina/") + tr("layouts");
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString VSettings::GetPathLayout() const QString VValentinaSettings::GetPathLayout() const
{ {
QSettings settings(this->format(), this->scope(), this->organizationName(), this->applicationName()); QSettings settings(this->format(), this->scope(), this->organizationName(), this->applicationName());
return settings.value(*settingPathsLayout, GetDefPathLayout()).toString(); return settings.value(*settingPathsLayout, GetDefPathLayout()).toString();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VSettings::SetPathLayout(const QString &value) void VValentinaSettings::SetPathLayout(const QString &value)
{ {
QSettings settings(this->format(), this->scope(), this->organizationName(), this->applicationName()); QSettings settings(this->format(), this->scope(), this->organizationName(), this->applicationName());
settings.setValue(*settingPathsLayout, value); settings.setValue(*settingPathsLayout, value);
@ -204,358 +144,334 @@ void VSettings::SetPathLayout(const QString &value)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetGraphicalOutput() const qreal VValentinaSettings::GetLayoutPaperHeight() const
{ {
return value(*settingPatternGraphicalOutput, 1).toBool(); return ValueOrDef<qreal>(*this, *settingLayoutPaperHeight, UnitConvertor(1189/*A0*/, Unit::Mm, Unit::Px));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VSettings::SetGraphicalOutput(const bool &value) void VValentinaSettings::SetLayoutPaperHeight(qreal value)
{
setValue(*settingPatternGraphicalOutput, value);
}
//---------------------------------------------------------------------------------------------------------------------
bool VSettings::IsOpenGLRender() const
{
return value(*settingPatternUseOpenGLRender, 0).toBool();
}
//---------------------------------------------------------------------------------------------------------------------
void VSettings::SetOpenGLRender(bool value)
{
setValue(*settingPatternUseOpenGLRender, value);
}
//---------------------------------------------------------------------------------------------------------------------
qreal VSettings::GetLayoutPaperHeight() const
{
return ValueOrDef<qreal>(*settingLayoutPaperHeight, UnitConvertor(1189/*A0*/, Unit::Mm, Unit::Px));
}
//---------------------------------------------------------------------------------------------------------------------
void VSettings::SetLayoutPaperHeight(qreal value)
{ {
setValue(*settingLayoutPaperHeight, value); setValue(*settingLayoutPaperHeight, value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
qreal VSettings::GetLayoutPaperWidth() const qreal VValentinaSettings::GetLayoutPaperWidth() const
{ {
return ValueOrDef<qreal>(*settingLayoutPaperWidth, UnitConvertor(841/*A0*/, Unit::Mm, Unit::Px)); return ValueOrDef<qreal>(*this, *settingLayoutPaperWidth, UnitConvertor(841/*A0*/, Unit::Mm, Unit::Px));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VSettings::SetLayoutPaperWidth(qreal value) void VValentinaSettings::SetLayoutPaperWidth(qreal value)
{ {
setValue(*settingLayoutPaperWidth, value); setValue(*settingLayoutPaperWidth, value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
qreal VSettings::GetLayoutWidth() const qreal VValentinaSettings::GetLayoutWidth() const
{ {
return ValueOrDef<qreal>(*settingLayoutWidth, GetDefLayoutWidth()); return ValueOrDef<qreal>(*this, *settingLayoutWidth, GetDefLayoutWidth());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
qreal VSettings::GetDefLayoutWidth() qreal VValentinaSettings::GetDefLayoutWidth()
{ {
return UnitConvertor(2.5, Unit::Mm, Unit::Px); return UnitConvertor(2.5, Unit::Mm, Unit::Px);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VSettings::SetLayoutWidth(qreal value) void VValentinaSettings::SetLayoutWidth(qreal value)
{ {
setValue(*settingLayoutWidth, value); setValue(*settingLayoutWidth, value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
int VSettings::GetNestingTime() const int VValentinaSettings::GetNestingTime() const
{ {
return ValueOrDef<int>(*settingNestingTime, GetDefNestingTime()); return ValueOrDef<int>(*this, *settingNestingTime, GetDefNestingTime());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VSettings::SetNestingTime(int value) void VValentinaSettings::SetNestingTime(int value)
{ {
setValue(*settingNestingTime, value); setValue(*settingNestingTime, value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
qreal VSettings::GetEfficiencyCoefficient() const qreal VValentinaSettings::GetEfficiencyCoefficient() const
{ {
return ValueOrDef<qreal>(*settingEfficiencyCoefficient, GetDefEfficiencyCoefficient()); return ValueOrDef<qreal>(*this, *settingEfficiencyCoefficient, GetDefEfficiencyCoefficient());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VSettings::SetEfficiencyCoefficient(qreal value) void VValentinaSettings::SetEfficiencyCoefficient(qreal value)
{ {
setValue(*settingEfficiencyCoefficient, value); setValue(*settingEfficiencyCoefficient, value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QMarginsF VSettings::GetFields(const QMarginsF &def) const QMarginsF VValentinaSettings::GetFields(const QMarginsF &def) const
{ {
return ValueOrDef<QMarginsF>(*settingFields, def); return ValueOrDef<QMarginsF>(*this, *settingFields, def);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VSettings::SetFields(const QMarginsF &value) void VValentinaSettings::SetFields(const QMarginsF &value)
{ {
setValue(*settingFields, QVariant::fromValue(value)); setValue(*settingFields, QVariant::fromValue(value));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
Cases VSettings::GetLayoutGroup() const Cases VValentinaSettings::GetLayoutGroup() const
{ {
return ValueOrDef<Cases>(*settingLayoutSorting, GetDefLayoutGroup()); return ValueOrDef<Cases>(*this, *settingLayoutSorting, GetDefLayoutGroup());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
Cases VSettings::GetDefLayoutGroup() Cases VValentinaSettings::GetDefLayoutGroup()
{ {
return Cases::CaseDesc; return Cases::CaseDesc;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VSettings::SetLayoutGroup(const Cases &value) void VValentinaSettings::SetLayoutGroup(const Cases &value)
{ {
setValue(*settingLayoutSorting, static_cast<int>(value)); setValue(*settingLayoutSorting, static_cast<int>(value));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetLayoutFollowGrainline() const bool VValentinaSettings::GetLayoutFollowGrainline() const
{ {
return value(*settingLayoutFollowGrainline, GetDefLayoutFollowGrainline()).toBool(); return value(*settingLayoutFollowGrainline, GetDefLayoutFollowGrainline()).toBool();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetDefLayoutFollowGrainline() bool VValentinaSettings::GetDefLayoutFollowGrainline()
{ {
return false; return false;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VSettings::SetLayoutFollowGrainline(bool value) void VValentinaSettings::SetLayoutFollowGrainline(bool value)
{ {
setValue(*settingLayoutFollowGrainline, value); setValue(*settingLayoutFollowGrainline, value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetLayoutManualPriority() const bool VValentinaSettings::GetLayoutManualPriority() const
{ {
return value(*settingLayoutManualPriority, GetDefLayoutManualPriority()).toBool(); return value(*settingLayoutManualPriority, GetDefLayoutManualPriority()).toBool();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetDefLayoutManualPriority() bool VValentinaSettings::GetDefLayoutManualPriority()
{ {
return false; return false;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VSettings::SetLayoutManualPriority(bool value) void VValentinaSettings::SetLayoutManualPriority(bool value)
{ {
setValue(*settingLayoutManualPriority, value); setValue(*settingLayoutManualPriority, value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetLayoutNestQuantity() const bool VValentinaSettings::GetLayoutNestQuantity() const
{ {
return value(*settingLayoutNestQuantity, GetDefLayoutNestQuantity()).toBool(); return value(*settingLayoutNestQuantity, GetDefLayoutNestQuantity()).toBool();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetDefLayoutNestQuantity() bool VValentinaSettings::GetDefLayoutNestQuantity()
{ {
return false; return false;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VSettings::SetLayoutNestQuantity(bool value) void VValentinaSettings::SetLayoutNestQuantity(bool value)
{ {
setValue(*settingLayoutNestQuantity, value); setValue(*settingLayoutNestQuantity, value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetLayoutAutoCropLength() const bool VValentinaSettings::GetLayoutAutoCropLength() const
{ {
return value(*settingLayoutAutoCropLength, GetDefLayoutAutoCropLength()).toBool(); return value(*settingLayoutAutoCropLength, GetDefLayoutAutoCropLength()).toBool();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetDefLayoutAutoCropLength() bool VValentinaSettings::GetDefLayoutAutoCropLength()
{ {
return false; return false;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VSettings::SetLayoutAutoCropLength(bool value) void VValentinaSettings::SetLayoutAutoCropLength(bool value)
{ {
setValue(*settingLayoutAutoCropLength, value); setValue(*settingLayoutAutoCropLength, value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetLayoutAutoCropWidth() const bool VValentinaSettings::GetLayoutAutoCropWidth() const
{ {
return value(*settingLayoutAutoCropWidth, GetDefLayoutAutoCropWidth()).toBool(); return value(*settingLayoutAutoCropWidth, GetDefLayoutAutoCropWidth()).toBool();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetDefLayoutAutoCropWidth() bool VValentinaSettings::GetDefLayoutAutoCropWidth()
{ {
return false; return false;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VSettings::SetLayoutAutoCropWidth(bool value) void VValentinaSettings::SetLayoutAutoCropWidth(bool value)
{ {
setValue(*settingLayoutAutoCropWidth, value); setValue(*settingLayoutAutoCropWidth, value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetLayoutSaveLength() const bool VValentinaSettings::GetLayoutSaveLength() const
{ {
return value(*settingLayoutSaveLength, GetDefLayoutSaveLength()).toBool(); return value(*settingLayoutSaveLength, GetDefLayoutSaveLength()).toBool();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetDefLayoutSaveLength() bool VValentinaSettings::GetDefLayoutSaveLength()
{ {
return false; return false;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VSettings::SetLayoutSaveLength(bool value) void VValentinaSettings::SetLayoutSaveLength(bool value)
{ {
setValue(*settingLayoutSaveLength, value); setValue(*settingLayoutSaveLength, value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetLayoutPreferOneSheetSolution() const bool VValentinaSettings::GetLayoutPreferOneSheetSolution() const
{ {
return value(*settingLayoutPreferOneSheetSolution, GetDefLayoutPreferOneSheetSolution()).toBool(); return value(*settingLayoutPreferOneSheetSolution, GetDefLayoutPreferOneSheetSolution()).toBool();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetDefLayoutPreferOneSheetSolution() bool VValentinaSettings::GetDefLayoutPreferOneSheetSolution()
{ {
return false; return false;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VSettings::SetLayoutPreferOneSheetSolution(bool value) void VValentinaSettings::SetLayoutPreferOneSheetSolution(bool value)
{ {
setValue(*settingLayoutPreferOneSheetSolution, value); setValue(*settingLayoutPreferOneSheetSolution, value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetLayoutUnitePages() const bool VValentinaSettings::GetLayoutUnitePages() const
{ {
return value(*settingLayoutUnitePages, GetDefLayoutUnitePages()).toBool(); return value(*settingLayoutUnitePages, GetDefLayoutUnitePages()).toBool();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetDefLayoutUnitePages() bool VValentinaSettings::GetDefLayoutUnitePages()
{ {
return false; return false;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VSettings::SetLayoutUnitePages(bool value) void VValentinaSettings::SetLayoutUnitePages(bool value)
{ {
setValue(*settingLayoutUnitePages, value); setValue(*settingLayoutUnitePages, value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetIgnoreAllFields() const bool VValentinaSettings::GetIgnoreAllFields() const
{ {
return value(*settingIgnoreFields, GetDefIgnoreAllFields()).toBool(); return value(*settingIgnoreFields, GetDefIgnoreAllFields()).toBool();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetDefIgnoreAllFields() bool VValentinaSettings::GetDefIgnoreAllFields()
{ {
return false; return false;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VSettings::SetIgnoreAllFields(bool value) void VValentinaSettings::SetIgnoreAllFields(bool value)
{ {
setValue(*settingIgnoreFields, value); setValue(*settingIgnoreFields, value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetStripOptimization() const bool VValentinaSettings::GetStripOptimization() const
{ {
return value(*settingStripOptimization, GetDefStripOptimization()).toBool(); return value(*settingStripOptimization, GetDefStripOptimization()).toBool();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetDefStripOptimization() bool VValentinaSettings::GetDefStripOptimization()
{ {
return false; return false;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VSettings::SetStripOptimization(bool value) void VValentinaSettings::SetStripOptimization(bool value)
{ {
setValue(*settingStripOptimization, value); setValue(*settingStripOptimization, value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
quint8 VSettings::GetMultiplier() const quint8 VValentinaSettings::GetMultiplier() const
{ {
return static_cast<quint8>(value(*settingMultiplier, GetDefMultiplier()).toUInt()); return static_cast<quint8>(value(*settingMultiplier, GetDefMultiplier()).toUInt());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
quint8 VSettings::GetDefMultiplier() quint8 VValentinaSettings::GetDefMultiplier()
{ {
return 1; return 1;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VSettings::SetMultiplier(quint8 value) void VValentinaSettings::SetMultiplier(quint8 value)
{ {
setValue(*settingMultiplier, value); setValue(*settingMultiplier, value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetTextAsPaths() const bool VValentinaSettings::GetTextAsPaths() const
{ {
return value(*settingTextAsPaths, GetDefTextAsPaths()).toBool(); return value(*settingTextAsPaths, GetDefTextAsPaths()).toBool();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetDefTextAsPaths() bool VValentinaSettings::GetDefTextAsPaths()
{ {
return false; return false;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VSettings::SetTextAsPaths(bool value) void VValentinaSettings::SetTextAsPaths(bool value)
{ {
setValue(*settingTextAsPaths, value); setValue(*settingTextAsPaths, value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QStringList VSettings::GetKnownMaterials() const QStringList VValentinaSettings::GetKnownMaterials() const
{ {
return value(*settingPatternKnownMaterials, QStringList()).toStringList(); return value(*settingPatternKnownMaterials, QStringList()).toStringList();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VSettings::SetKnownMaterials(const QStringList &list) void VValentinaSettings::SetKnownMaterials(const QStringList &list)
{ {
setValue(*settingPatternKnownMaterials, list); setValue(*settingPatternKnownMaterials, list);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VSettings::IsRememberPatternMaterials() const bool VValentinaSettings::IsRememberPatternMaterials() const
{ {
return value(*settingPatternRememberMaterials, true).toBool(); return value(*settingPatternRememberMaterials, true).toBool();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VSettings::SetRememberPatternMaterials(bool value) void VValentinaSettings::SetRememberPatternMaterials(bool value)
{ {
setValue(*settingPatternRememberMaterials, value); setValue(*settingPatternRememberMaterials, value);
} }
@ -569,10 +485,11 @@ void VSettings::SetRememberPatternMaterials(bool value)
* internaly as mm so there is conversion beeing made. * internaly as mm so there is conversion beeing made.
* @return tiled pdf margins * @return tiled pdf margins
*/ */
QMarginsF VSettings::GetTiledPDFMargins(const Unit &unit) const QMarginsF VValentinaSettings::GetTiledPDFMargins(const Unit &unit) const
{ {
// default value is 10mm. We save the margins in mm in the setting. // default value is 10mm. We save the margins in mm in the setting.
return UnitConvertor(ValueOrDef<QMarginsF>(*settingTiledPDFMargins, QMarginsF(10, 10, 10, 10)), Unit::Mm, unit); return UnitConvertor(ValueOrDef<QMarginsF>(*this, *settingTiledPDFMargins, QMarginsF(10, 10, 10, 10)), Unit::Mm,
unit);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -582,7 +499,7 @@ QMarginsF VSettings::GetTiledPDFMargins(const Unit &unit) const
* @param unit the unit in which are the value. Necessary because we save the values * @param unit the unit in which are the value. Necessary because we save the values
* internaly as mm so there is conversion beeing made. * internaly as mm so there is conversion beeing made.
*/ */
void VSettings::SetTiledPDFMargins(const QMarginsF &value, const Unit &unit) void VValentinaSettings::SetTiledPDFMargins(const QMarginsF &value, const Unit &unit)
{ {
setValue(*settingTiledPDFMargins, QVariant::fromValue(UnitConvertor(value, unit, Unit::Mm))); setValue(*settingTiledPDFMargins, QVariant::fromValue(UnitConvertor(value, unit, Unit::Mm)));
} }
@ -594,9 +511,9 @@ void VSettings::SetTiledPDFMargins(const QMarginsF &value, const Unit &unit)
* internaly as mm so there is conversion beeing made. * internaly as mm so there is conversion beeing made.
* @return tiled pdf paper height * @return tiled pdf paper height
*/ */
qreal VSettings::GetTiledPDFPaperHeight(const Unit &unit) const qreal VValentinaSettings::GetTiledPDFPaperHeight(const Unit &unit) const
{ {
return UnitConvertor(ValueOrDef<qreal>(*settingTiledPDFPaperHeight, 297 /*A4*/), Unit::Mm, unit); return UnitConvertor(ValueOrDef<qreal>(*this, *settingTiledPDFPaperHeight, 297 /*A4*/), Unit::Mm, unit);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -605,7 +522,7 @@ qreal VSettings::GetTiledPDFPaperHeight(const Unit &unit) const
* @param value in mm * @param value in mm
* @param unit unit of the given value * @param unit unit of the given value
*/ */
void VSettings::SetTiledPDFPaperHeight(qreal value, const Unit &unit) void VValentinaSettings::SetTiledPDFPaperHeight(qreal value, const Unit &unit)
{ {
setValue(*settingTiledPDFPaperHeight, UnitConvertor(value, unit, Unit::Mm)); setValue(*settingTiledPDFPaperHeight, UnitConvertor(value, unit, Unit::Mm));
} }
@ -617,9 +534,9 @@ void VSettings::SetTiledPDFPaperHeight(qreal value, const Unit &unit)
* internaly as mm so there is conversion beeing made. * internaly as mm so there is conversion beeing made.
* @return tiled pdf paper width * @return tiled pdf paper width
*/ */
qreal VSettings::GetTiledPDFPaperWidth(const Unit &unit) const qreal VValentinaSettings::GetTiledPDFPaperWidth(const Unit &unit) const
{ {
return UnitConvertor(ValueOrDef<qreal>(*settingTiledPDFPaperWidth, 210 /*A4*/), Unit::Mm, unit); return UnitConvertor(ValueOrDef<qreal>(*this, *settingTiledPDFPaperWidth, 210 /*A4*/), Unit::Mm, unit);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -628,13 +545,13 @@ qreal VSettings::GetTiledPDFPaperWidth(const Unit &unit) const
* @param unit unit of the given value * @param unit unit of the given value
* @param value in mm * @param value in mm
*/ */
void VSettings::SetTiledPDFPaperWidth(qreal value, const Unit &unit) void VValentinaSettings::SetTiledPDFPaperWidth(qreal value, const Unit &unit)
{ {
setValue(*settingTiledPDFPaperWidth, UnitConvertor(value,unit, Unit::Mm)); setValue(*settingTiledPDFPaperWidth, UnitConvertor(value,unit, Unit::Mm));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
PageOrientation VSettings::GetTiledPDFOrientation() const PageOrientation VValentinaSettings::GetTiledPDFOrientation() const
{ {
bool defaultValue = static_cast<bool>(PageOrientation::Portrait); bool defaultValue = static_cast<bool>(PageOrientation::Portrait);
bool result = value(*settingTiledPDFOrientation, defaultValue).toBool(); bool result = value(*settingTiledPDFOrientation, defaultValue).toBool();
@ -642,137 +559,69 @@ PageOrientation VSettings::GetTiledPDFOrientation() const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VSettings::SetTiledPDFOrientation(PageOrientation value) void VValentinaSettings::SetTiledPDFOrientation(PageOrientation value)
{ {
setValue(*settingTiledPDFOrientation, static_cast<bool> (value)); setValue(*settingTiledPDFOrientation, static_cast<bool> (value));
} }
//---------------------------------------------------------------------------------------------------------------------
int VSettings::GetScrollingDuration() const
{
return GetCachedValue(scrollingDurationCached, *settingScrollingDuration, defaultScrollingDuration,
scrollingDurationMin, scrollingDurationMax);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VSettings::SetScrollingDuration(int duration) bool VValentinaSettings::IsDockWidgetGroupsActive() const
{
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);
}
//---------------------------------------------------------------------------------------------------------------------
bool VSettings::IsDockWidgetGroupsActive() const
{ {
return value(*settingdockWidgetGroupsActive, GetDefDockWidgetGroupsActive()).toBool(); return value(*settingdockWidgetGroupsActive, GetDefDockWidgetGroupsActive()).toBool();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetDefDockWidgetGroupsActive() bool VValentinaSettings::GetDefDockWidgetGroupsActive()
{ {
return true; return true;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VSettings::SetDockWidgetGroupsActive(bool value) void VValentinaSettings::SetDockWidgetGroupsActive(bool value)
{ {
setValue(*settingdockWidgetGroupsActive, value); setValue(*settingdockWidgetGroupsActive, value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VSettings::IsDockWidgetToolOptionsActive() const bool VValentinaSettings::IsDockWidgetToolOptionsActive() const
{ {
return value(*settingDockWidgetToolOptionsActive, GetDefDockWidgetToolOptionsActive()).toBool(); return value(*settingDockWidgetToolOptionsActive, GetDefDockWidgetToolOptionsActive()).toBool();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetDefDockWidgetToolOptionsActive() bool VValentinaSettings::GetDefDockWidgetToolOptionsActive()
{ {
return true; return true;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VSettings::SetDockWidgetToolOptionsActive(bool value) void VValentinaSettings::SetDockWidgetToolOptionsActive(bool value)
{ {
setValue(*settingDockWidgetToolOptionsActive, value); setValue(*settingDockWidgetToolOptionsActive, value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VSettings::IsDockWidgetPatternMessagesActive() const bool VValentinaSettings::IsDockWidgetPatternMessagesActive() const
{ {
return value(*settingDockWidgetPatternMessagesActive, GetDefDockWidgetPatternMessagesActive()).toBool(); return value(*settingDockWidgetPatternMessagesActive, GetDefDockWidgetPatternMessagesActive()).toBool();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetDefDockWidgetPatternMessagesActive() bool VValentinaSettings::GetDefDockWidgetPatternMessagesActive()
{ {
return true; return true;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VSettings::SetDockWidgetPatternMessagesActive(bool value) void VValentinaSettings::SetDockWidgetPatternMessagesActive(bool value)
{ {
setValue(*settingDockWidgetPatternMessagesActive, value); setValue(*settingDockWidgetPatternMessagesActive, value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
int VSettings::GetPatternMessageFontSize(int fontSizeDef) const int VValentinaSettings::GetPatternMessageFontSize(int fontSizeDef) const
{ {
fontSizeDef = qBound(GetDefMinPatternMessageFontSize(), fontSizeDef, GetDefMaxPatternMessageFontSize()); fontSizeDef = qBound(GetDefMinPatternMessageFontSize(), fontSizeDef, GetDefMaxPatternMessageFontSize());
const int fontSize = value(*settingPatternMessagesFontSize, fontSizeDef).toInt(); const int fontSize = value(*settingPatternMessagesFontSize, fontSizeDef).toInt();
@ -780,56 +629,44 @@ int VSettings::GetPatternMessageFontSize(int fontSizeDef) const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
int VSettings::GetDefMinPatternMessageFontSize() int VValentinaSettings::GetDefMinPatternMessageFontSize()
{ {
return 5; return 5;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
int VSettings::GetDefMaxPatternMessageFontSize() int VValentinaSettings::GetDefMaxPatternMessageFontSize()
{ {
return 40; return 40;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VSettings::SetPatternMessageFontSize(int size) void VValentinaSettings::SetPatternMessageFontSize(int size)
{ {
setValue(*settingPatternMessagesFontSize, qBound(GetDefMinPatternMessageFontSize(), size, setValue(*settingPatternMessagesFontSize, qBound(GetDefMinPatternMessageFontSize(), size,
GetDefMaxPatternMessageFontSize())); GetDefMaxPatternMessageFontSize()));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetAutoRefreshPatternMessage() const bool VValentinaSettings::GetAutoRefreshPatternMessage() const
{ {
return value(*settingAutoRefreshPatternMessage, true).toBool(); return value(*settingAutoRefreshPatternMessage, true).toBool();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VSettings::SetAutoRefreshPatternMessage(bool value) void VValentinaSettings::SetAutoRefreshPatternMessage(bool value)
{ {
setValue(*settingAutoRefreshPatternMessage, value); setValue(*settingAutoRefreshPatternMessage, value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QSize VSettings::GetWatermarkEditorSize() const QSize VValentinaSettings::GetWatermarkEditorSize() const
{ {
return value(*settingWatermarkEditorSize, QSize(0, 0)).toSize(); return value(*settingWatermarkEditorSize, QSize(0, 0)).toSize();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VSettings::SetWatermarkEditorSize(const QSize &sz) void VValentinaSettings::SetWatermarkEditorSize(const QSize &sz)
{ {
setValue(*settingWatermarkEditorSize, sz); setValue(*settingWatermarkEditorSize, sz);
} }
//---------------------------------------------------------------------------------------------------------------------
template<typename T>
T VSettings::GetCachedValue(T &cache, const QString &setting, T defValue, T valueMin, T valueMax) const
{
if (cache < 0)
{
cache = qBound(valueMin, ValueOrDef(setting, defValue), valueMax);
}
return cache;
}

View File

@ -26,8 +26,8 @@
** **
*************************************************************************/ *************************************************************************/
#ifndef VSETTINGS_H #ifndef VVALENTINASETTINGS_H
#define VSETTINGS_H #define VVALENTINASETTINGS_H
#include <QMetaObject> #include <QMetaObject>
#include <QObject> #include <QObject>
@ -39,13 +39,13 @@
#include "vcommonsettings.h" #include "vcommonsettings.h"
#include "../vlayout/vbank.h" #include "../vlayout/vbank.h"
class VSettings : public VCommonSettings class VValentinaSettings : public VCommonSettings
{ {
Q_OBJECT Q_OBJECT
public: public:
VSettings(Format format, Scope scope, const QString &organization, const QString &application = QString(), VValentinaSettings(Format format, Scope scope, const QString &organization, const QString &application = QString(),
QObject *parent = nullptr); QObject *parent = nullptr);
VSettings(const QString &fileName, Format format, QObject *parent = nullptr); VValentinaSettings(const QString &fileName, Format format, QObject *parent = nullptr);
QString GetLabelLanguage() const; QString GetLabelLanguage() const;
void SetLabelLanguage(const QString &value); void SetLabelLanguage(const QString &value);
@ -54,12 +54,6 @@ public:
QString GetPathLayout() const; QString GetPathLayout() const;
void SetPathLayout(const QString &value); void SetPathLayout(const QString &value);
bool GetGraphicalOutput() const;
void SetGraphicalOutput(const bool &value);
bool IsOpenGLRender() const;
void SetOpenGLRender(bool value);
// Layout settings // Layout settings
qreal GetLayoutPaperHeight() const; qreal GetLayoutPaperHeight() const;
void SetLayoutPaperHeight(qreal value); void SetLayoutPaperHeight(qreal value);
@ -153,36 +147,6 @@ public:
PageOrientation GetTiledPDFOrientation() const; PageOrientation GetTiledPDFOrientation() const;
void SetTiledPDFOrientation(PageOrientation value); void SetTiledPDFOrientation(PageOrientation value);
static const int defaultScrollingDuration;
static const int scrollingDurationMin;
static const int scrollingDurationMax;
int GetScrollingDuration() const;
void SetScrollingDuration(int duration);
static const int defaultScrollingUpdateInterval;
static const int scrollingUpdateIntervalMin;
static const int scrollingUpdateIntervalMax;
int GetScrollingUpdateInterval() const;
void SetScrollingUpdateInterval(int updateInterval);
static const qreal defaultSensorMouseScale;
static const qreal sensorMouseScaleMin;
static const qreal sensorMouseScaleMax;
qreal GetSensorMouseScale() const;
void SetSensorMouseScale(qreal scale);
static const qreal defaultWheelMouseScale;
static const qreal wheelMouseScaleMin;
static const qreal wheelMouseScaleMax;
qreal GetWheelMouseScale() const;
void SetWheelMouseScale(qreal scale);
static const qreal defaultScrollingAcceleration;
static const qreal scrollingAccelerationMin;
static const qreal scrollingAccelerationMax;
qreal GetScrollingAcceleration() const;
void SetScrollingAcceleration(qreal acceleration);
bool IsDockWidgetGroupsActive() const; bool IsDockWidgetGroupsActive() const;
static bool GetDefDockWidgetGroupsActive(); static bool GetDefDockWidgetGroupsActive();
void SetDockWidgetGroupsActive(bool value); void SetDockWidgetGroupsActive(bool value);
@ -207,13 +171,7 @@ public:
void SetWatermarkEditorSize(const QSize& sz); void SetWatermarkEditorSize(const QSize& sz);
private: private:
Q_DISABLE_COPY(VSettings) Q_DISABLE_COPY(VValentinaSettings)
template <typename T>
T GetCachedValue(T &cache, const QString &setting, T defValue, T valueMin, T valueMax) const;
template <class T>
T ValueOrDef(const QString &setting, const T &defValue) const;
}; };
#endif // VSETTINGS_H #endif // VVALENTINASETTINGS_H

View File

@ -110,13 +110,13 @@ PreferencesConfigurationPage::PreferencesConfigurationPage(QWidget *parent)
//----------------------------- Pattern Editing //----------------------------- Pattern Editing
connect(ui->resetWarningsButton, &QPushButton::released, this, []() connect(ui->resetWarningsButton, &QPushButton::released, this, []()
{ {
VSettings *settings = qApp->ValentinaSettings(); VValentinaSettings *settings = qApp->ValentinaSettings();
settings->SetConfirmItemDelete(true); settings->SetConfirmItemDelete(true);
settings->SetConfirmFormatRewriting(true); settings->SetConfirmFormatRewriting(true);
}); });
VSettings *settings = qApp->ValentinaSettings(); VValentinaSettings *settings = qApp->ValentinaSettings();
ui->checkBoxFreeCurve->setChecked(settings->IsFreeCurveMode()); ui->checkBoxFreeCurve->setChecked(settings->IsFreeCurveMode());
ui->checkBoxZoomFitBestCurrentPP->setChecked(settings->IsDoubleClickZoomFitBestCurrentPP()); ui->checkBoxZoomFitBestCurrentPP->setChecked(settings->IsDoubleClickZoomFitBestCurrentPP());
@ -128,24 +128,24 @@ PreferencesConfigurationPage::PreferencesConfigurationPage(QWidget *parent)
ui->darkModeCheck->setChecked(settings->GetDarkMode()); ui->darkModeCheck->setChecked(settings->GetDarkMode());
// Tab Scrolling // Tab Scrolling
ui->spinBoxDuration->setMinimum(VSettings::scrollingDurationMin); ui->spinBoxDuration->setMinimum(VValentinaSettings::scrollingDurationMin);
ui->spinBoxDuration->setMaximum(VSettings::scrollingDurationMax); ui->spinBoxDuration->setMaximum(VValentinaSettings::scrollingDurationMax);
ui->spinBoxDuration->setValue(settings->GetScrollingDuration()); ui->spinBoxDuration->setValue(settings->GetScrollingDuration());
ui->spinBoxUpdateInterval->setMinimum(VSettings::scrollingUpdateIntervalMin); ui->spinBoxUpdateInterval->setMinimum(VValentinaSettings::scrollingUpdateIntervalMin);
ui->spinBoxUpdateInterval->setMaximum(VSettings::scrollingUpdateIntervalMax); ui->spinBoxUpdateInterval->setMaximum(VValentinaSettings::scrollingUpdateIntervalMax);
ui->spinBoxUpdateInterval->setValue(settings->GetScrollingUpdateInterval()); ui->spinBoxUpdateInterval->setValue(settings->GetScrollingUpdateInterval());
ui->doubleSpinBoxSensor->setMinimum(VSettings::sensorMouseScaleMin); ui->doubleSpinBoxSensor->setMinimum(VValentinaSettings::sensorMouseScaleMin);
ui->doubleSpinBoxSensor->setMaximum(VSettings::sensorMouseScaleMax); ui->doubleSpinBoxSensor->setMaximum(VValentinaSettings::sensorMouseScaleMax);
ui->doubleSpinBoxSensor->setValue(settings->GetSensorMouseScale()); ui->doubleSpinBoxSensor->setValue(settings->GetSensorMouseScale());
ui->doubleSpinBoxWheel->setMinimum(VSettings::wheelMouseScaleMin); ui->doubleSpinBoxWheel->setMinimum(VValentinaSettings::wheelMouseScaleMin);
ui->doubleSpinBoxWheel->setMaximum(VSettings::wheelMouseScaleMax); ui->doubleSpinBoxWheel->setMaximum(VValentinaSettings::wheelMouseScaleMax);
ui->doubleSpinBoxWheel->setValue(settings->GetWheelMouseScale()); ui->doubleSpinBoxWheel->setValue(settings->GetWheelMouseScale());
ui->doubleSpinBoxAcceleration->setMinimum(VSettings::scrollingAccelerationMin); ui->doubleSpinBoxAcceleration->setMinimum(VValentinaSettings::scrollingAccelerationMin);
ui->doubleSpinBoxAcceleration->setMaximum(VSettings::scrollingAccelerationMax); ui->doubleSpinBoxAcceleration->setMaximum(VValentinaSettings::scrollingAccelerationMax);
ui->doubleSpinBoxAcceleration->setValue(settings->GetScrollingAcceleration()); ui->doubleSpinBoxAcceleration->setValue(settings->GetScrollingAcceleration());
} }
@ -160,7 +160,7 @@ QStringList PreferencesConfigurationPage::Apply()
{ {
// Tab General // Tab General
QStringList preferences; QStringList preferences;
VSettings *settings = qApp->ValentinaSettings(); VValentinaSettings *settings = qApp->ValentinaSettings();
settings->SetAutosaveState(ui->autoSaveCheck->isChecked()); settings->SetAutosaveState(ui->autoSaveCheck->isChecked());
settings->SetAutosaveTime(ui->autoTime->value()); settings->SetAutosaveTime(ui->autoTime->value());

View File

@ -28,7 +28,7 @@
#include "preferencespathpage.h" #include "preferencespathpage.h"
#include "ui_preferencespathpage.h" #include "ui_preferencespathpage.h"
#include "../vmisc/vsettings.h" #include "../../core/vvalentinasettings.h"
#include "../../core/vapplication.h" #include "../../core/vapplication.h"
#include <QDir> #include <QDir>
@ -65,7 +65,7 @@ PreferencesPathPage::~PreferencesPathPage()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QStringList PreferencesPathPage::Apply() QStringList PreferencesPathPage::Apply()
{ {
VSettings *settings = qApp->ValentinaSettings(); VValentinaSettings *settings = qApp->ValentinaSettings();
settings->SetPathIndividualMeasurements(ui->pathTable->item(0, 1)->text()); settings->SetPathIndividualMeasurements(ui->pathTable->item(0, 1)->text());
settings->SetPathMultisizeMeasurements(ui->pathTable->item(1, 1)->text()); settings->SetPathMultisizeMeasurements(ui->pathTable->item(1, 1)->text());
settings->SetPathPattern(ui->pathTable->item(2, 1)->text()); settings->SetPathPattern(ui->pathTable->item(2, 1)->text());
@ -105,13 +105,13 @@ void PreferencesPathPage::DefaultPath()
path = VCommonSettings::GetDefPathMultisizeMeasurements(); path = VCommonSettings::GetDefPathMultisizeMeasurements();
break; break;
case 2: // pattern path case 2: // pattern path
path = VSettings::GetDefPathPattern(); path = VValentinaSettings::GetDefPathPattern();
break; break;
case 0: // individual measurements case 0: // individual measurements
path = VCommonSettings::GetDefPathIndividualMeasurements(); path = VCommonSettings::GetDefPathIndividualMeasurements();
break; break;
case 3: // layout path case 3: // layout path
path = VSettings::GetDefPathLayout(); path = VValentinaSettings::GetDefPathLayout();
break; break;
case 4: // templates case 4: // templates
path = VCommonSettings::GetDefPathTemplate(); path = VCommonSettings::GetDefPathTemplate();
@ -206,7 +206,7 @@ void PreferencesPathPage::InitTable()
ui->pathTable->setRowCount(7); ui->pathTable->setRowCount(7);
ui->pathTable->setColumnCount(2); ui->pathTable->setColumnCount(2);
const VSettings *settings = qApp->ValentinaSettings(); const VValentinaSettings *settings = qApp->ValentinaSettings();
{ {
ui->pathTable->setItem(0, 0, new QTableWidgetItem(tr("My Individual Measurements"))); ui->pathTable->setItem(0, 0, new QTableWidgetItem(tr("My Individual Measurements")));

View File

@ -63,7 +63,7 @@ PreferencesPatternPage::PreferencesPatternPage(QWidget *parent)
ui->setupUi(this); ui->setupUi(this);
RetranslateUi(); RetranslateUi();
VSettings *settings = qApp->ValentinaSettings(); VValentinaSettings *settings = qApp->ValentinaSettings();
ui->graphOutputCheck->setChecked(settings->GetGraphicalOutput()); ui->graphOutputCheck->setChecked(settings->GetGraphicalOutput());
ui->checkBoxOpenGLRender->setChecked(settings->IsOpenGLRender()); ui->checkBoxOpenGLRender->setChecked(settings->IsOpenGLRender());
@ -125,7 +125,7 @@ QStringList PreferencesPatternPage::Apply()
{ {
QStringList preferences; QStringList preferences;
VSettings *settings = qApp->ValentinaSettings(); VValentinaSettings *settings = qApp->ValentinaSettings();
// Scene antialiasing // Scene antialiasing
if (settings->GetGraphicalOutput() != ui->graphOutputCheck->isChecked()) if (settings->GetGraphicalOutput() != ui->graphOutputCheck->isChecked())
@ -200,7 +200,7 @@ void PreferencesPatternPage::changeEvent(QEvent *event)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PreferencesPatternPage::EditDateTimeFormats() void PreferencesPatternPage::EditDateTimeFormats()
{ {
VSettings *settings = qApp->ValentinaSettings(); VValentinaSettings *settings = qApp->ValentinaSettings();
QPushButton *button = qobject_cast<QPushButton *>(sender()); QPushButton *button = qobject_cast<QPushButton *>(sender());
if (button == ui->pushButtonEditDateFormats) if (button == ui->pushButtonEditDateFormats)
@ -230,7 +230,7 @@ void PreferencesPatternPage::ManageKnownMaterials()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PreferencesPatternPage::InitLabelDateTimeFormats() void PreferencesPatternPage::InitLabelDateTimeFormats()
{ {
VSettings *settings = qApp->ValentinaSettings(); VValentinaSettings *settings = qApp->ValentinaSettings();
InitComboBoxFormats(ui->comboBoxDateFormats, InitComboBoxFormats(ui->comboBoxDateFormats,
VCommonSettings::PredefinedDateFormats() + settings->GetUserDefinedDateFormats(), VCommonSettings::PredefinedDateFormats() + settings->GetUserDefinedDateFormats(),

View File

@ -28,7 +28,7 @@
#include "dialogfinalmeasurements.h" #include "dialogfinalmeasurements.h"
#include "ui_dialogfinalmeasurements.h" #include "ui_dialogfinalmeasurements.h"
#include "../vmisc/vsettings.h" #include "../core/vvalentinasettings.h"
#include "../vmisc/compatibility.h" #include "../vmisc/compatibility.h"
#include "../qmuparser/qmudef.h" #include "../qmuparser/qmudef.h"
#include "../qmuparser/qmutokenparser.h" #include "../qmuparser/qmutokenparser.h"

View File

@ -29,7 +29,7 @@
#include "dialogincrements.h" #include "dialogincrements.h"
#include "ui_dialogincrements.h" #include "ui_dialogincrements.h"
#include "../vwidgets/vwidgetpopup.h" #include "../vwidgets/vwidgetpopup.h"
#include "../vmisc/vsettings.h" #include "../core/vvalentinasettings.h"
#include "../qmuparser/qmudef.h" #include "../qmuparser/qmudef.h"
#include "../qmuparser/qmutokenparser.h" #include "../qmuparser/qmutokenparser.h"
#include "../vpatterndb/vtranslatevars.h" #include "../vpatterndb/vtranslatevars.h"

View File

@ -29,7 +29,7 @@
#include "dialoglayoutscale.h" #include "dialoglayoutscale.h"
#include "ui_dialoglayoutscale.h" #include "ui_dialoglayoutscale.h"
#include "../core/vapplication.h" #include "../core/vapplication.h"
#include "../vmisc/vsettings.h" #include "../core/vvalentinasettings.h"
#include <QPushButton> #include <QPushButton>
@ -180,7 +180,7 @@ void DialogLayoutScale::VerticalScaleChanged(double d)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogLayoutScale::ReadSettings() void DialogLayoutScale::ReadSettings()
{ {
VSettings *settings = qApp->ValentinaSettings(); VValentinaSettings *settings = qApp->ValentinaSettings();
const Unit unit = qApp->patternUnit(); const Unit unit = qApp->patternUnit();
// read Margins top, right, bottom, left // read Margins top, right, bottom, left
@ -200,7 +200,7 @@ void DialogLayoutScale::ReadSettings()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogLayoutScale::WriteSettings() const void DialogLayoutScale::WriteSettings() const
{ {
VSettings *settings = qApp->ValentinaSettings(); VValentinaSettings *settings = qApp->ValentinaSettings();
const Unit unit = qApp->patternUnit(); const Unit unit = qApp->patternUnit();
// write Margins top, right, bottom, left // write Margins top, right, bottom, left

View File

@ -30,7 +30,7 @@
#include "ui_dialoglayoutsettings.h" #include "ui_dialoglayoutsettings.h"
#include "../core/vapplication.h" #include "../core/vapplication.h"
#include "../ifc/xml/vdomdocument.h" #include "../ifc/xml/vdomdocument.h"
#include "../vmisc/vsettings.h" #include "../core/vvalentinasettings.h"
#include "../vmisc/vmath.h" #include "../vmisc/vmath.h"
#include "../vlayout/vlayoutgenerator.h" #include "../vlayout/vlayoutgenerator.h"
@ -698,17 +698,17 @@ void DialogLayoutSettings::RestoreDefaults()
InitPrinter(); InitPrinter();
ui->comboBoxPrinter->blockSignals(false); ui->comboBoxPrinter->blockSignals(false);
SetLayoutWidth(VSettings::GetDefLayoutWidth()); SetLayoutWidth(VValentinaSettings::GetDefLayoutWidth());
SetGroup(VSettings::GetDefLayoutGroup()); SetGroup(VValentinaSettings::GetDefLayoutGroup());
SetFollowGrainline(VSettings::GetDefLayoutFollowGrainline()); SetFollowGrainline(VValentinaSettings::GetDefLayoutFollowGrainline());
SetManualPriority(VSettings::GetDefLayoutManualPriority()); SetManualPriority(VValentinaSettings::GetDefLayoutManualPriority());
SetFields(GetDefPrinterFields()); SetFields(GetDefPrinterFields());
SetIgnoreAllFields(VSettings::GetDefIgnoreAllFields()); SetIgnoreAllFields(VValentinaSettings::GetDefIgnoreAllFields());
SetMultiplier(VSettings::GetDefMultiplier()); SetMultiplier(VValentinaSettings::GetDefMultiplier());
SetNestingTime(VSettings::GetDefNestingTime()); SetNestingTime(VValentinaSettings::GetDefNestingTime());
SetEfficiencyCoefficient(VSettings::GetDefEfficiencyCoefficient()); SetEfficiencyCoefficient(VValentinaSettings::GetDefEfficiencyCoefficient());
SetNestQuantity(VSettings::GetDefLayoutNestQuantity()); SetNestQuantity(VValentinaSettings::GetDefLayoutNestQuantity());
SetPreferOneSheetSolution(VSettings::GetDefLayoutPreferOneSheetSolution()); SetPreferOneSheetSolution(VValentinaSettings::GetDefLayoutPreferOneSheetSolution());
CorrectMaxFileds(); CorrectMaxFileds();
IgnoreAllFields(ui->checkBoxIgnoreFileds->isChecked()); IgnoreAllFields(ui->checkBoxIgnoreFileds->isChecked());
@ -1019,7 +1019,7 @@ void DialogLayoutSettings::MinimumLayoutSize()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogLayoutSettings::ReadSettings() void DialogLayoutSettings::ReadSettings()
{ {
const VSettings *settings = qApp->ValentinaSettings(); const VValentinaSettings *settings = qApp->ValentinaSettings();
SetLayoutWidth(settings->GetLayoutWidth()); SetLayoutWidth(settings->GetLayoutWidth());
SetNestingTime(settings->GetNestingTime()); SetNestingTime(settings->GetNestingTime());
SetEfficiencyCoefficient(settings->GetEfficiencyCoefficient()); SetEfficiencyCoefficient(settings->GetEfficiencyCoefficient());
@ -1051,7 +1051,7 @@ void DialogLayoutSettings::ReadSettings()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogLayoutSettings::WriteSettings() const void DialogLayoutSettings::WriteSettings() const
{ {
VSettings *settings = qApp->ValentinaSettings(); VValentinaSettings *settings = qApp->ValentinaSettings();
settings->SetLayoutWidth(GetLayoutWidth()); settings->SetLayoutWidth(GetLayoutWidth());
settings->SetLayoutGroup(GetGroup()); settings->SetLayoutGroup(GetGroup());
settings->SetLayoutPaperHeight(GetPaperHeight()); settings->SetLayoutPaperHeight(GetPaperHeight());

View File

@ -29,7 +29,7 @@
#include "dialognewpattern.h" #include "dialognewpattern.h"
#include "ui_dialognewpattern.h" #include "ui_dialognewpattern.h"
#include "../core/vapplication.h" #include "../core/vapplication.h"
#include "../vmisc/vsettings.h" #include "../core/vvalentinasettings.h"
#include "../vpatterndb/vcontainer.h" #include "../vpatterndb/vcontainer.h"
#include <QFileDialog> #include <QFileDialog>

View File

@ -81,7 +81,7 @@ DialogPatternProperties::DialogPatternProperties(VPattern *doc, VContainer *pat
SCASSERT(doc != nullptr) SCASSERT(doc != nullptr)
VSettings *settings = qApp->ValentinaSettings(); VValentinaSettings *settings = qApp->ValentinaSettings();
settings->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c()); settings->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c());
patternMaterials = doc->GetPatternMaterials(); patternMaterials = doc->GetPatternMaterials();
@ -951,7 +951,7 @@ void DialogPatternProperties::EditLabel()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogPatternProperties::ManagePatternMaterials() void DialogPatternProperties::ManagePatternMaterials()
{ {
VSettings *settings = qApp->ValentinaSettings(); VValentinaSettings *settings = qApp->ValentinaSettings();
DialogPatternMaterials editor(patternMaterials, settings->IsRememberPatternMaterials()); DialogPatternMaterials editor(patternMaterials, settings->IsRememberPatternMaterials());

View File

@ -29,7 +29,7 @@
#include "dialogsavelayout.h" #include "dialogsavelayout.h"
#include "ui_dialogsavelayout.h" #include "ui_dialogsavelayout.h"
#include "../core/vapplication.h" #include "../core/vapplication.h"
#include "../vmisc/vsettings.h" #include "../core/vvalentinasettings.h"
#include "../ifc/exception/vexception.h" #include "../ifc/exception/vexception.h"
#include <QDir> #include <QDir>
@ -903,7 +903,7 @@ void DialogSaveLayout::RemoveFormatFromList(LayoutExportFormats format)
*/ */
void DialogSaveLayout::ReadSettings() void DialogSaveLayout::ReadSettings()
{ {
VSettings *settings = qApp->ValentinaSettings(); VValentinaSettings *settings = qApp->ValentinaSettings();
const Unit unit = qApp->patternUnit(); const Unit unit = qApp->patternUnit();
// read Margins top, right, bottom, left // read Margins top, right, bottom, left
@ -957,7 +957,7 @@ void DialogSaveLayout::WriteSettings() const
return; return;
} }
VSettings *settings = qApp->ValentinaSettings(); VValentinaSettings *settings = qApp->ValentinaSettings();
const Unit unit = qApp->patternUnit(); const Unit unit = qApp->patternUnit();
// write Margins top, right, bottom, left // write Margins top, right, bottom, left

View File

@ -37,7 +37,7 @@
#include "version.h" #include "version.h"
#include "core/vapplication.h" #include "core/vapplication.h"
#include "../vmisc/customevents.h" #include "../vmisc/customevents.h"
#include "../vmisc/vsettings.h" #include "core/vvalentinasettings.h"
#include "../vmisc/def.h" #include "../vmisc/def.h"
#include "../vmisc/qxtcsvmodel.h" #include "../vmisc/qxtcsvmodel.h"
#include "../vmisc/vmodifierkey.h" #include "../vmisc/vmodifierkey.h"
@ -301,7 +301,7 @@ MainWindow::MainWindow(QWidget *parent)
connect(ui->toolButtonMessagesZoomInFont, &QToolButton::clicked, this, [this]() connect(ui->toolButtonMessagesZoomInFont, &QToolButton::clicked, this, [this]()
{ {
VSettings *settings = qApp->ValentinaSettings(); VValentinaSettings *settings = qApp->ValentinaSettings();
QFont f = ui->plainTextEditPatternMessages->font(); QFont f = ui->plainTextEditPatternMessages->font();
if (f.pointSize() < settings->GetDefMaxPatternMessageFontSize()) if (f.pointSize() < settings->GetDefMaxPatternMessageFontSize())
{ {
@ -313,7 +313,7 @@ MainWindow::MainWindow(QWidget *parent)
connect(ui->toolButtonMessagesZoomOutFont, &QToolButton::clicked, this, [this]() connect(ui->toolButtonMessagesZoomOutFont, &QToolButton::clicked, this, [this]()
{ {
VSettings *settings = qApp->ValentinaSettings(); VValentinaSettings *settings = qApp->ValentinaSettings();
QFont f = ui->plainTextEditPatternMessages->font(); QFont f = ui->plainTextEditPatternMessages->font();
if (f.pointSize() > settings->GetDefMinPatternMessageFontSize()) if (f.pointSize() > settings->GetDefMinPatternMessageFontSize())
{ {
@ -2195,7 +2195,7 @@ void MainWindow::ToolBarTools()
ui->actionIncreaseLabelFont->setShortcut(QKeySequence(Qt::ShiftModifier + Qt::Key_Plus)); ui->actionIncreaseLabelFont->setShortcut(QKeySequence(Qt::ShiftModifier + Qt::Key_Plus));
connect(ui->actionIncreaseLabelFont, &QAction::triggered, this, [this]() connect(ui->actionIncreaseLabelFont, &QAction::triggered, this, [this]()
{ {
VSettings *settings = qApp->ValentinaSettings(); VValentinaSettings *settings = qApp->ValentinaSettings();
settings->SetLabelFontSize(settings->GetLabelFontSize() + 1); settings->SetLabelFontSize(settings->GetLabelFontSize() + 1);
if (sceneDraw) if (sceneDraw)
{ {
@ -2211,7 +2211,7 @@ void MainWindow::ToolBarTools()
ui->actionDecreaseLabelFont->setShortcut(QKeySequence(Qt::ShiftModifier + Qt::Key_Minus)); ui->actionDecreaseLabelFont->setShortcut(QKeySequence(Qt::ShiftModifier + Qt::Key_Minus));
connect(ui->actionDecreaseLabelFont, &QAction::triggered, this, [this]() connect(ui->actionDecreaseLabelFont, &QAction::triggered, this, [this]()
{ {
VSettings *settings = qApp->ValentinaSettings(); VValentinaSettings *settings = qApp->ValentinaSettings();
settings->SetLabelFontSize(settings->GetLabelFontSize() - 1); settings->SetLabelFontSize(settings->GetLabelFontSize() - 1);
if (sceneDraw) if (sceneDraw)
{ {
@ -2227,7 +2227,7 @@ void MainWindow::ToolBarTools()
ui->actionOriginalLabelFont->setShortcut(QKeySequence(Qt::ShiftModifier + Qt::Key_0)); ui->actionOriginalLabelFont->setShortcut(QKeySequence(Qt::ShiftModifier + Qt::Key_0));
connect(ui->actionOriginalLabelFont, &QAction::triggered, this, [this]() connect(ui->actionOriginalLabelFont, &QAction::triggered, this, [this]()
{ {
VSettings *settings = qApp->ValentinaSettings(); VValentinaSettings *settings = qApp->ValentinaSettings();
settings->SetLabelFontSize(settings->GetDefLabelFontSize()); settings->SetLabelFontSize(settings->GetDefLabelFontSize());
if (sceneDraw) if (sceneDraw)
{ {
@ -4172,7 +4172,7 @@ void MainWindow::setCurrentFile(const QString &fileName)
if (not qApp->GetPatternPath().isEmpty() && VApplication::IsGUIMode()) if (not qApp->GetPatternPath().isEmpty() && VApplication::IsGUIMode())
{ {
qCDebug(vMainWindow, "Updating recent file list."); qCDebug(vMainWindow, "Updating recent file list.");
VSettings *settings = qApp->ValentinaSettings(); VValentinaSettings *settings = qApp->ValentinaSettings();
QStringList files = settings->GetRecentFileList(); QStringList files = settings->GetRecentFileList();
files.removeAll(fileName); files.removeAll(fileName);
files.prepend(fileName); files.prepend(fileName);
@ -4201,7 +4201,7 @@ void MainWindow::setCurrentFile(const QString &fileName)
void MainWindow::ReadSettings() void MainWindow::ReadSettings()
{ {
qCDebug(vMainWindow, "Reading settings."); qCDebug(vMainWindow, "Reading settings.");
const VSettings *settings = qApp->ValentinaSettings(); const VValentinaSettings *settings = qApp->ValentinaSettings();
if (settings->status() == QSettings::NoError) if (settings->status() == QSettings::NoError)
{ {
@ -4243,7 +4243,7 @@ void MainWindow::WriteSettings()
{ {
ActionDraw(true); ActionDraw(true);
VSettings *settings = qApp->ValentinaSettings(); VValentinaSettings *settings = qApp->ValentinaSettings();
settings->SetGeometry(saveGeometry()); settings->SetGeometry(saveGeometry());
settings->SetWindowState(saveState()); settings->SetWindowState(saveState());
settings->SetToolbarsState(saveState(APP_VERSION)); settings->SetToolbarsState(saveState(APP_VERSION));

View File

@ -1820,7 +1820,7 @@ void MainWindowsNoGUI::SetPrinterSettings(QPrinter *printer, const PrintType &pr
} }
else else
{ {
VSettings *settings = qApp->ValentinaSettings(); VValentinaSettings *settings = qApp->ValentinaSettings();
pageMargin = QMarginsF(settings->GetTiledPDFMargins(Unit::Mm)); pageMargin = QMarginsF(settings->GetTiledPDFMargins(Unit::Mm));
orientation = settings->GetTiledPDFOrientation(); orientation = settings->GetTiledPDFOrientation();
} }

View File

@ -40,7 +40,7 @@
#include "../ifc/exception/vexceptionundo.h" #include "../ifc/exception/vexceptionundo.h"
#include "../ifc/xml/vpatternconverter.h" #include "../ifc/xml/vpatternconverter.h"
#include "../vmisc/customevents.h" #include "../vmisc/customevents.h"
#include "../vmisc/vsettings.h" #include "../core/vvalentinasettings.h"
#include "../vmisc/vmath.h" #include "../vmisc/vmath.h"
#include "../vmisc/projectversion.h" #include "../vmisc/projectversion.h"
#include "../vmisc/compatibility.h" #include "../vmisc/compatibility.h"

View File

@ -37,7 +37,17 @@
#endif #endif
#define qApp (static_cast<TestVApplication*>(QCoreApplication::instance())) #define qApp (static_cast<TestVApplication*>(QCoreApplication::instance()))
class VTestSettings; class VTestSettings : public VCommonSettings
{
Q_OBJECT
public:
VTestSettings(Format format, Scope scope, const QString &organization, const QString &application = QString(),
QObject *parent = nullptr)
: VCommonSettings(format, scope, organization, application, parent)
{
qRegisterMetaTypeStreamOperators<QMarginsF>("QMarginsF");
}
};
class TestVApplication : public VAbstractApplication class TestVApplication : public VAbstractApplication
{ {
@ -50,7 +60,7 @@ public:
setApplicationName("ValentinaTest"); setApplicationName("ValentinaTest");
setOrganizationName(VER_COMPANYNAME_STR); setOrganizationName(VER_COMPANYNAME_STR);
OpenSettings(); TestVApplication::OpenSettings();
} }
virtual ~TestVApplication() Q_DECL_EQ_DEFAULT; virtual ~TestVApplication() Q_DECL_EQ_DEFAULT;
@ -62,8 +72,8 @@ public:
virtual void OpenSettings() override virtual void OpenSettings() override
{ {
settings = new VSettings(QSettings::IniFormat, QSettings::UserScope, QCoreApplication::organizationName(), settings = new VTestSettings(QSettings::IniFormat, QSettings::UserScope, QCoreApplication::organizationName(),
QCoreApplication::applicationName(), this); QCoreApplication::applicationName(), this);
} }
virtual bool IsAppInGUIMode() const override virtual bool IsAppInGUIMode() const override
@ -88,16 +98,4 @@ private:
VTranslateVars *m_trVars; VTranslateVars *m_trVars;
}; };
class VTestSettings : public VCommonSettings
{
Q_OBJECT
public:
VTestSettings(Format format, Scope scope, const QString &organization, const QString &application = QString(),
QObject *parent = nullptr)
: VCommonSettings(format, scope, organization, application, parent)
{
qRegisterMetaTypeStreamOperators<QMarginsF>("QMarginsF");
}
};
#endif // TESTVAPPLICATION_H #endif // TESTVAPPLICATION_H

View File

@ -45,7 +45,6 @@
#include "def.h" #include "def.h"
#include "vcommonsettings.h" #include "vcommonsettings.h"
#include "vlockguard.h" #include "vlockguard.h"
#include "vsettings.h"
class QUndoStack; class QUndoStack;
class VAbstractApplication;// use in define class VAbstractApplication;// use in define

View File

@ -47,6 +47,26 @@
#include "../vmisc/compatibility.h" #include "../vmisc/compatibility.h"
#include "../vpatterndb/pmsystems.h" #include "../vpatterndb/pmsystems.h"
const int VCommonSettings::defaultScrollingDuration = 300;
const int VCommonSettings::scrollingDurationMin = 100;
const int VCommonSettings::scrollingDurationMax = 1000;
const int VCommonSettings::defaultScrollingUpdateInterval = 30;
const int VCommonSettings::scrollingUpdateIntervalMin = 10;
const int VCommonSettings::scrollingUpdateIntervalMax = 100;
const qreal VCommonSettings::defaultSensorMouseScale = 2.0;
const qreal VCommonSettings::sensorMouseScaleMin = 1.0;
const qreal VCommonSettings::sensorMouseScaleMax = 10.0;
const qreal VCommonSettings::defaultWheelMouseScale = 45.0;
const qreal VCommonSettings::wheelMouseScaleMin = 1.0;
const qreal VCommonSettings::wheelMouseScaleMax = 100.0;
const qreal VCommonSettings::defaultScrollingAcceleration = 1.3;
const qreal VCommonSettings::scrollingAccelerationMin = 1.0;
const qreal VCommonSettings::scrollingAccelerationMax = 10.0;
namespace namespace
{ {
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsIndividualMeasurements, (QLatin1String("paths/individual_measurements"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsIndividualMeasurements, (QLatin1String("paths/individual_measurements")))
@ -81,6 +101,8 @@ Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternShowCurveDetails, (QLatin
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternPieceShowMainPath, (QLatin1String("pattern/pieceShowMainPath"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternPieceShowMainPath, (QLatin1String("pattern/pieceShowMainPath")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternLabelFontSize, (QLatin1String("pattern/labelFontSize"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternLabelFontSize, (QLatin1String("pattern/labelFontSize")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternHideLabels, (QLatin1String("pattern/hideLabels"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternHideLabels, (QLatin1String("pattern/hideLabels")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternUseOpenGLRender, (QLatin1String("pattern/useOpenGLRender")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternGraphicalOutput, (QLatin1String("pattern/graphicalOutput")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingGeneralRecentFileList, (QLatin1String("recentFileList"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingGeneralRecentFileList, (QLatin1String("recentFileList")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingGeneralRestoreFileList, (QLatin1String("restoreFileList"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingGeneralRestoreFileList, (QLatin1String("restoreFileList")))
@ -105,12 +127,24 @@ Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLabelUserDateFormats, (QLatin1St
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLabelTimeFormat, (QLatin1String("label/timeFormat"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLabelTimeFormat, (QLatin1String("label/timeFormat")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLabelUserTimeFormats, (QLatin1String("label/userTimeFormats"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLabelUserTimeFormats, (QLatin1String("label/userTimeFormats")))
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 curve approximation to speed up getting value // Reading settings file is very expensive, cache curve approximation to speed up getting value
qreal curveApproximationCached = -1; qreal curveApproximationCached = -1;
Q_GLOBAL_STATIC(QString, localeCached) Q_GLOBAL_STATIC(QString, localeCached)
qreal lineWidthCached = 0; qreal lineWidthCached = 0;
int labelFontSizeCached = 0; int labelFontSizeCached = 0;
int pieceShowMainPath = -1; int pieceShowMainPath = -1;
int scrollingDurationCached = -1;
int scrollingUpdateIntervalCached = -1;
qreal scrollingSensorMouseScaleCached = -1;
qreal scrollingWheelMouseScaleCached = -1;
qreal scrollingAccelerationCached = -1;
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QStringList ClearFormats(const QStringList &predefinedFormats, QStringList formats) QStringList ClearFormats(const QStringList &predefinedFormats, QStringList formats)
@ -1219,3 +1253,118 @@ qreal VCommonSettings::WidthHairLine() const
{ {
return WidthMainLine()/3.0; return WidthMainLine()/3.0;
} }
//---------------------------------------------------------------------------------------------------------------------
int VCommonSettings::GetScrollingDuration() const
{
QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename);
return GetCachedValue(settings, scrollingDurationCached, *settingScrollingDuration, defaultScrollingDuration,
scrollingDurationMin, scrollingDurationMax);
}
//---------------------------------------------------------------------------------------------------------------------
void VCommonSettings::SetScrollingDuration(int duration)
{
scrollingDurationCached = qBound(scrollingDurationMin, duration, scrollingDurationMax);
QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename);
settings.setValue(*settingScrollingDuration, scrollingDurationCached);
settings.sync();
}
//---------------------------------------------------------------------------------------------------------------------
int VCommonSettings::GetScrollingUpdateInterval() const
{
QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename);
return GetCachedValue(settings, scrollingUpdateIntervalCached, *settingScrollingUpdateInterval,
defaultScrollingUpdateInterval, scrollingUpdateIntervalMin, scrollingUpdateIntervalMax);
}
//---------------------------------------------------------------------------------------------------------------------
void VCommonSettings::SetScrollingUpdateInterval(int updateInterval)
{
scrollingUpdateIntervalCached = qBound(scrollingUpdateIntervalMin, updateInterval, scrollingUpdateIntervalMax);
QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename);
settings.setValue(*settingScrollingUpdateInterval, scrollingUpdateIntervalCached);
settings.sync();
}
//---------------------------------------------------------------------------------------------------------------------
qreal VCommonSettings::GetSensorMouseScale() const
{
QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename);
return GetCachedValue(settings, scrollingSensorMouseScaleCached, *settingScrollingSensorMouseScale,
defaultSensorMouseScale, sensorMouseScaleMin, sensorMouseScaleMax);
}
//---------------------------------------------------------------------------------------------------------------------
void VCommonSettings::SetSensorMouseScale(qreal scale)
{
scrollingSensorMouseScaleCached = qBound(sensorMouseScaleMin, scale, sensorMouseScaleMax);
QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename);
settings.setValue(*settingScrollingSensorMouseScale, scrollingSensorMouseScaleCached);
settings.sync();
}
//---------------------------------------------------------------------------------------------------------------------
qreal VCommonSettings::GetWheelMouseScale() const
{
QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename);
return GetCachedValue(settings, scrollingWheelMouseScaleCached, *settingScrollingWheelMouseScale,
defaultWheelMouseScale, wheelMouseScaleMin, wheelMouseScaleMax);
}
//---------------------------------------------------------------------------------------------------------------------
void VCommonSettings::SetWheelMouseScale(qreal scale)
{
scrollingWheelMouseScaleCached = qBound(wheelMouseScaleMin, scale, wheelMouseScaleMax);
QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename);
settings.setValue(*settingScrollingWheelMouseScale, scrollingWheelMouseScaleCached);
settings.sync();
}
//---------------------------------------------------------------------------------------------------------------------
qreal VCommonSettings::GetScrollingAcceleration() const
{
QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename);
return GetCachedValue(settings, scrollingAccelerationCached, *settingScrollingAcceleration,
defaultScrollingAcceleration, scrollingAccelerationMin, scrollingAccelerationMax);
}
//---------------------------------------------------------------------------------------------------------------------
void VCommonSettings::SetScrollingAcceleration(qreal acceleration)
{
scrollingAccelerationCached = qBound(scrollingAccelerationMin, acceleration, scrollingAccelerationMax);
QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename);
settings.setValue(*settingScrollingAcceleration, scrollingAccelerationCached);
settings.sync();
}
//---------------------------------------------------------------------------------------------------------------------
bool VCommonSettings::IsOpenGLRender() const
{
QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename);
return settings.value(*settingPatternUseOpenGLRender, 0).toBool();
}
//---------------------------------------------------------------------------------------------------------------------
void VCommonSettings::SetOpenGLRender(bool value)
{
QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename);
settings.setValue(*settingPatternUseOpenGLRender, value);
settings.sync();
}
//---------------------------------------------------------------------------------------------------------------------
bool VCommonSettings::GetGraphicalOutput() const
{
QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename);
return settings.value(*settingPatternGraphicalOutput, 1).toBool();
}
//---------------------------------------------------------------------------------------------------------------------
void VCommonSettings::SetGraphicalOutput(const bool &value)
{
QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename);
settings.setValue(*settingPatternGraphicalOutput, value);
settings.sync();
}

View File

@ -38,6 +38,8 @@
#include <QStringList> #include <QStringList>
#include <QtGlobal> #include <QtGlobal>
#include "../vlayout/vbank.h"
class VCommonSettings : public QSettings class VCommonSettings : public QSettings
{ {
Q_OBJECT Q_OBJECT
@ -225,6 +227,52 @@ public:
void SetLineWidth(qreal width); void SetLineWidth(qreal width);
qreal WidthMainLine() const; qreal WidthMainLine() const;
qreal WidthHairLine() const; qreal WidthHairLine() const;
static const int defaultScrollingDuration;
static const int scrollingDurationMin;
static const int scrollingDurationMax;
int GetScrollingDuration() const;
void SetScrollingDuration(int duration);
static const int defaultScrollingUpdateInterval;
static const int scrollingUpdateIntervalMin;
static const int scrollingUpdateIntervalMax;
int GetScrollingUpdateInterval() const;
void SetScrollingUpdateInterval(int updateInterval);
static const qreal defaultSensorMouseScale;
static const qreal sensorMouseScaleMin;
static const qreal sensorMouseScaleMax;
qreal GetSensorMouseScale() const;
void SetSensorMouseScale(qreal scale);
static const qreal defaultWheelMouseScale;
static const qreal wheelMouseScaleMin;
static const qreal wheelMouseScaleMax;
qreal GetWheelMouseScale() const;
void SetWheelMouseScale(qreal scale);
static const qreal defaultScrollingAcceleration;
static const qreal scrollingAccelerationMin;
static const qreal scrollingAccelerationMax;
qreal GetScrollingAcceleration() const;
void SetScrollingAcceleration(qreal acceleration);
bool IsOpenGLRender() const;
void SetOpenGLRender(bool value);
bool GetGraphicalOutput() const;
void SetGraphicalOutput(const bool &value);
protected:
template <typename T>
static T GetCachedValue(const QSettings &settings, T &cache, const QString &setting, T defValue, T valueMin,
T valueMax);
template <class T>
static T ValueOrDef(const QSettings &settings, const QString &setting, const T &defValue);
private: private:
Q_DISABLE_COPY(VCommonSettings) Q_DISABLE_COPY(VCommonSettings)
}; };
@ -247,4 +295,42 @@ inline qreal VCommonSettings::MaximalLineWidth()
return 5.0; // mm return 5.0; // mm
} }
//---------------------------------------------------------------------------------------------------------------------
template<typename T>
T VCommonSettings::GetCachedValue(const QSettings &settings, T &cache, const QString &setting, T defValue, T valueMin,
T valueMax)
{
if (cache < 0)
{
cache = qBound(valueMin, ValueOrDef(settings, setting, defValue), valueMax);
}
return cache;
}
//---------------------------------------------------------------------------------------------------------------------
template <class T>
inline T VCommonSettings::ValueOrDef(const QSettings &settings, const QString &setting, const T &defValue)
{
const QVariant val = settings.value(setting, QVariant::fromValue(defValue));
return val.canConvert<T>() ? val.value<T>() : defValue;
}
//---------------------------------------------------------------------------------------------------------------------
template <>
inline Cases VCommonSettings::ValueOrDef<Cases>(const QSettings &settings, const QString &setting,
const Cases &defValue)
{
const QVariant val = settings.value(setting, QVariant::fromValue(static_cast<int>(defValue)));
const int g = val.canConvert<int>() ? val.value<int>() : static_cast<int>(defValue);
if (g < static_cast<int>(Cases::CaseThreeGroup) || g >= static_cast<int>(Cases::UnknownCase))
{
return defValue;
}
else
{
return static_cast<Cases>(g);
}
}
#endif // VCOMMONSETTINGS_H #endif // VCOMMONSETTINGS_H

View File

@ -3,18 +3,15 @@
SOURCES += \ SOURCES += \
$$PWD/def.cpp \ $$PWD/def.cpp \
$$PWD/vsettings.cpp \
$$PWD/vabstractapplication.cpp \ $$PWD/vabstractapplication.cpp \
$$PWD/projectversion.cpp \ $$PWD/projectversion.cpp \
$$PWD/vcommonsettings.cpp \ $$PWD/vcommonsettings.cpp \
$$PWD/vtapesettings.cpp \
$$PWD/commandoptions.cpp \ $$PWD/commandoptions.cpp \
$$PWD/qxtcsvmodel.cpp \ $$PWD/qxtcsvmodel.cpp \
$$PWD/vtablesearch.cpp \ $$PWD/vtablesearch.cpp \
$$PWD/dialogs/dialogexporttocsv.cpp \ $$PWD/dialogs/dialogexporttocsv.cpp \
$$PWD/literals.cpp \ $$PWD/literals.cpp \
$$PWD/vmodifierkey.cpp \ $$PWD/vmodifierkey.cpp
$$PWD/vpuzzlesettings.cpp
*msvc*:SOURCES += $$PWD/stable.cpp *msvc*:SOURCES += $$PWD/stable.cpp
@ -29,11 +26,9 @@ HEADERS += \
$$PWD/stable.h \ $$PWD/stable.h \
$$PWD/def.h \ $$PWD/def.h \
$$PWD/vmath.h \ $$PWD/vmath.h \
$$PWD/vsettings.h \
$$PWD/vabstractapplication.h \ $$PWD/vabstractapplication.h \
$$PWD/projectversion.h \ $$PWD/projectversion.h \
$$PWD/vcommonsettings.h \ $$PWD/vcommonsettings.h \
$$PWD/vtapesettings.h \
$$PWD/debugbreak.h \ $$PWD/debugbreak.h \
$$PWD/vlockguard.h \ $$PWD/vlockguard.h \
$$PWD/vsysexits.h \ $$PWD/vsysexits.h \
@ -51,8 +46,7 @@ HEADERS += \
$$PWD/vdatastreamenum.h \ $$PWD/vdatastreamenum.h \
$$PWD/vmodifierkey.h \ $$PWD/vmodifierkey.h \
$$PWD/typedef.h \ $$PWD/typedef.h \
$$PWD/backport/qscopeguard.h \ $$PWD/backport/qscopeguard.h
$$PWD/vpuzzlesettings.h
contains(DEFINES, APPIMAGE) { contains(DEFINES, APPIMAGE) {
SOURCES += \ SOURCES += \

View File

@ -1,37 +0,0 @@
/************************************************************************
**
** @file vpuzzlesettings.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 16 2, 2020
**
** @brief
** @copyright
** This source code is part of the Valentina project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2020 Valentina project
** <https://gitlab.com/smart-pattern/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 "vpuzzlesettings.h"
//---------------------------------------------------------------------------------------------------------------------
VPuzzleSettings::VPuzzleSettings(Format format, Scope scope, const QString &organization, const QString &application,
QObject *parent)
:VCommonSettings(format, scope, organization, application, parent)
{
}

View File

@ -56,7 +56,7 @@
#include "vsimplecurve.h" #include "vsimplecurve.h"
#include "vcontrolpointspline.h" #include "vcontrolpointspline.h"
#include "../vmisc/vabstractapplication.h" #include "../vmisc/vabstractapplication.h"
#include "../vmisc/vsettings.h" #include "../vmisc/vcommonsettings.h"
#include "vabstractmainwindow.h" #include "vabstractmainwindow.h"
const qreal maxSceneSize = ((20.0 * 1000.0) / 25.4) * PrintDPI; // 20 meters in pixels const qreal maxSceneSize = ((20.0 * 1000.0) / 25.4) * PrintDPI; // 20 meters in pixels
@ -70,7 +70,7 @@ qreal ScrollingSteps(QWheelEvent* wheel_event)
const QPoint numPixels = wheel_event->pixelDelta(); const QPoint numPixels = wheel_event->pixelDelta();
const QPoint numDegrees = wheel_event->angleDelta() / 8; const QPoint numDegrees = wheel_event->angleDelta() / 8;
qreal numSteps = 0; qreal numSteps = 0;
VSettings *settings = qobject_cast<VSettings *>(qApp->Settings()); VCommonSettings *settings = qApp->Settings();
if (not numPixels.isNull()) if (not numPixels.isNull())
{ {
@ -105,7 +105,7 @@ qreal PrepareScrolling(qreal scheduledScrollings, QWheelEvent *wheel_event)
scheduledScrollings += numSteps; scheduledScrollings += numSteps;
} }
scheduledScrollings *= qobject_cast<VSettings *>(qApp->Settings())->GetScrollingAcceleration(); scheduledScrollings *= qApp->Settings()->GetScrollingAcceleration();
return scheduledScrollings; return scheduledScrollings;
} }
@ -197,7 +197,7 @@ void GraphicsViewZoom::set_zoom_factor_base(double value)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void GraphicsViewZoom::InitScrollingAnimation() void GraphicsViewZoom::InitScrollingAnimation()
{ {
VSettings *settings = qobject_cast<VSettings *>(qApp->Settings()); VCommonSettings *settings = qApp->Settings();
if (not verticalScrollAnim.isNull()) if (not verticalScrollAnim.isNull())
{ {
@ -427,7 +427,7 @@ VMainGraphicsView::VMainGraphicsView(QWidget *parent)
m_oldCursor(), m_oldCursor(),
m_currentCursor(Qt::ArrowCursor) m_currentCursor(Qt::ArrowCursor)
{ {
VSettings *settings = qobject_cast<VSettings *>(qApp->Settings()); VCommonSettings *settings = qApp->Settings();
if (settings && settings->IsOpenGLRender()) if (settings && settings->IsOpenGLRender())
{ {
QOpenGLWidget *viewport = new QOpenGLWidget(); QOpenGLWidget *viewport = new QOpenGLWidget();