From 7b1449f11ec17d80eb105822d93f75e955a48d24 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Sun, 10 May 2020 18:32:14 +0300 Subject: [PATCH] Redesign settings. All apps settings classes moved to binaries. Use common part to get access from static libraries. Fixed issues with VMainGraphicsView class. --- src/app/puzzle/puzzle.pri | 2 + src/app/puzzle/puzzle.pro | 24 +- src/app/puzzle/puzzleapplication.h | 2 +- src/app/puzzle/vpuzzlesettings.cpp | 81 ++++ .../vmisc => app/puzzle}/vpuzzlesettings.h | 9 + .../tapepreferencesconfigurationpage.cpp | 2 +- .../configpages/tapepreferencespathpage.cpp | 2 +- .../tape/dialogs/dialognewmeasurements.cpp | 2 +- src/app/tape/mapplication.h | 2 +- src/app/tape/tape.pri | 6 +- .../vmisc => app/tape}/vtapesettings.cpp | 0 src/{libs/vmisc => app/tape}/vtapesettings.h | 0 src/app/valentina/core/core.pri | 6 +- src/app/valentina/core/vapplication.cpp | 10 +- src/app/valentina/core/vapplication.h | 4 +- src/app/valentina/core/vcmdexport.cpp | 6 +- .../valentina/core/vvalentinasettings.cpp} | 365 +++++------------- .../valentina/core/vvalentinasettings.h} | 56 +-- .../preferencesconfigurationpage.cpp | 26 +- .../configpages/preferencespathpage.cpp | 10 +- .../configpages/preferencespatternpage.cpp | 8 +- .../dialogs/dialogfinalmeasurements.cpp | 2 +- .../valentina/dialogs/dialogincrements.cpp | 2 +- .../valentina/dialogs/dialoglayoutscale.cpp | 6 +- .../dialogs/dialoglayoutsettings.cpp | 26 +- .../valentina/dialogs/dialognewpattern.cpp | 2 +- .../dialogs/dialogpatternproperties.cpp | 4 +- .../valentina/dialogs/dialogsavelayout.cpp | 6 +- src/app/valentina/mainwindow.cpp | 18 +- src/app/valentina/mainwindowsnogui.cpp | 2 +- src/app/valentina/xml/vpattern.cpp | 2 +- src/libs/vmisc/testvapplication.h | 30 +- src/libs/vmisc/vabstractapplication.h | 1 - src/libs/vmisc/vcommonsettings.cpp | 149 +++++++ src/libs/vmisc/vcommonsettings.h | 86 +++++ src/libs/vmisc/vmisc.pri | 10 +- src/libs/vmisc/vpuzzlesettings.cpp | 37 -- src/libs/vwidgets/vmaingraphicsview.cpp | 10 +- 38 files changed, 548 insertions(+), 468 deletions(-) create mode 100644 src/app/puzzle/vpuzzlesettings.cpp rename src/{libs/vmisc => app/puzzle}/vpuzzlesettings.h (79%) rename src/{libs/vmisc => app/tape}/vtapesettings.cpp (100%) rename src/{libs/vmisc => app/tape}/vtapesettings.h (100%) rename src/{libs/vmisc/vsettings.cpp => app/valentina/core/vvalentinasettings.cpp} (63%) rename src/{libs/vmisc/vsettings.h => app/valentina/core/vvalentinasettings.h} (75%) delete mode 100644 src/libs/vmisc/vpuzzlesettings.cpp diff --git a/src/app/puzzle/puzzle.pri b/src/app/puzzle/puzzle.pri index 418af8d9d..47095dbab 100644 --- a/src/app/puzzle/puzzle.pri +++ b/src/app/puzzle/puzzle.pri @@ -18,6 +18,7 @@ SOURCES += \ $$PWD/vpuzzlemaingraphicsview.cpp \ $$PWD/vpuzzlemimedatapiece.cpp \ $$PWD/vpuzzlepiece.cpp \ + $$PWD/vpuzzlesettings.cpp \ $$PWD/xml/layoutliterals.cpp \ $$PWD/xml/vpuzzlelayoutfilewriter.cpp \ $$PWD/xml/vpuzzlelayoutfilereader.cpp \ @@ -43,6 +44,7 @@ HEADERS += \ $$PWD/vpuzzlemaingraphicsview.h \ $$PWD/vpuzzlemimedatapiece.h \ $$PWD/vpuzzlepiece.h \ + $$PWD/vpuzzlesettings.h \ $$PWD/xml/layoutliterals.h \ $$PWD/xml/vpuzzlelayoutfilewriter.h \ $$PWD/xml/vpuzzlelayoutfilereader.h \ diff --git a/src/app/puzzle/puzzle.pro b/src/app/puzzle/puzzle.pro index be7037a9e..462579124 100644 --- a/src/app/puzzle/puzzle.pro +++ b/src/app/puzzle/puzzle.pro @@ -197,14 +197,14 @@ noRunPath{ # For enable run qmake with CONFIG+=noRunPath #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 -##VWidgets static library -#unix|win32: LIBS += -L$$OUT_PWD/../../libs/vwidgets/$${DESTDIR}/ -lvwidgets +#VWidgets static library +unix|win32: LIBS += -L$$OUT_PWD/../../libs/vwidgets/$${DESTDIR}/ -lvwidgets -#INCLUDEPATH += $$PWD/../../libs/vwidgets -#DEPENDPATH += $$PWD/../../libs/vwidgets +INCLUDEPATH += $$PWD/../../libs/vwidgets +DEPENDPATH += $$PWD/../../libs/vwidgets -#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 +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 ## VFormat static library (depend on VPatternDB, IFC) #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 DEPENDPATH += $${PWD}/../../libs/qmuparser -## VPropertyExplorer library -#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:unix: LIBS += -L$${OUT_PWD}/../../libs/vpropertyexplorer/$${DESTDIR} -lvpropertyexplorer +# VPropertyExplorer library +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:unix: LIBS += -L$${OUT_PWD}/../../libs/vpropertyexplorer/$${DESTDIR} -lvpropertyexplorer -#INCLUDEPATH += $${PWD}/../../libs/vpropertyexplorer -#DEPENDPATH += $${PWD}/../../libs/vpropertyexplorer +INCLUDEPATH += $${PWD}/../../libs/vpropertyexplorer +DEPENDPATH += $${PWD}/../../libs/vpropertyexplorer contains(DEFINES, APPIMAGE) { unix:!macx: LIBS += -licudata -licui18n -licuuc diff --git a/src/app/puzzle/puzzleapplication.h b/src/app/puzzle/puzzleapplication.h index d93748835..0b7b2ac84 100644 --- a/src/app/puzzle/puzzleapplication.h +++ b/src/app/puzzle/puzzleapplication.h @@ -29,7 +29,7 @@ #define PUZZLEAPPLICATION_H #include "../vmisc/def.h" -#include "../vmisc/vpuzzlesettings.h" +#include "vpuzzlesettings.h" #include "../vmisc/vabstractapplication.h" #include "vpuzzlecommandline.h" diff --git a/src/app/puzzle/vpuzzlesettings.cpp b/src/app/puzzle/vpuzzlesettings.cpp new file mode 100644 index 000000000..6d4ad24d0 --- /dev/null +++ b/src/app/puzzle/vpuzzlesettings.cpp @@ -0,0 +1,81 @@ +/************************************************************************ + ** + ** @file vpuzzlesettings.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 . + ** + *************************************************************************/ +#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); +} diff --git a/src/libs/vmisc/vpuzzlesettings.h b/src/app/puzzle/vpuzzlesettings.h similarity index 79% rename from src/libs/vmisc/vpuzzlesettings.h rename to src/app/puzzle/vpuzzlesettings.h index f4ab19b01..97906df41 100644 --- a/src/libs/vmisc/vpuzzlesettings.h +++ b/src/app/puzzle/vpuzzlesettings.h @@ -38,6 +38,15 @@ class VPuzzleSettings : public VCommonSettings public: VPuzzleSettings(Format format, Scope scope, const QString &organization, const QString &application = QString(), 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: Q_DISABLE_COPY(VPuzzleSettings) diff --git a/src/app/tape/dialogs/configpages/tapepreferencesconfigurationpage.cpp b/src/app/tape/dialogs/configpages/tapepreferencesconfigurationpage.cpp index b8d42f37f..07d1ad1c4 100644 --- a/src/app/tape/dialogs/configpages/tapepreferencesconfigurationpage.cpp +++ b/src/app/tape/dialogs/configpages/tapepreferencesconfigurationpage.cpp @@ -29,7 +29,7 @@ #include "tapepreferencesconfigurationpage.h" #include "ui_tapepreferencesconfigurationpage.h" #include "../../mapplication.h" -#include "../vmisc/vtapesettings.h" +#include "../../vtapesettings.h" #include "../vpatterndb/variables/vmeasurement.h" #include "../vpatterndb/pmsystems.h" diff --git a/src/app/tape/dialogs/configpages/tapepreferencespathpage.cpp b/src/app/tape/dialogs/configpages/tapepreferencespathpage.cpp index be64952b3..1908dc500 100644 --- a/src/app/tape/dialogs/configpages/tapepreferencespathpage.cpp +++ b/src/app/tape/dialogs/configpages/tapepreferencespathpage.cpp @@ -29,7 +29,7 @@ #include "tapepreferencespathpage.h" #include "ui_tapepreferencespathpage.h" #include "../../mapplication.h" -#include "../vmisc/vtapesettings.h" +#include "../../vtapesettings.h" #include #include diff --git a/src/app/tape/dialogs/dialognewmeasurements.cpp b/src/app/tape/dialogs/dialognewmeasurements.cpp index 9643fa021..2b206225c 100644 --- a/src/app/tape/dialogs/dialognewmeasurements.cpp +++ b/src/app/tape/dialogs/dialognewmeasurements.cpp @@ -30,7 +30,7 @@ #include "ui_dialognewmeasurements.h" #include "../vpatterndb/variables/vmeasurement.h" -#include "../vmisc/vtapesettings.h" +#include "../vtapesettings.h" #include "../mapplication.h" #include diff --git a/src/app/tape/mapplication.h b/src/app/tape/mapplication.h index a121ced88..839780026 100644 --- a/src/app/tape/mapplication.h +++ b/src/app/tape/mapplication.h @@ -31,7 +31,7 @@ #include "../vpatterndb/vtranslatevars.h" #include "../vmisc/def.h" -#include "../vmisc/vtapesettings.h" +#include "vtapesettings.h" #include "../vmisc/vabstractapplication.h" #include "dialogs/dialogmdatabase.h" diff --git a/src/app/tape/tape.pri b/src/app/tape/tape.pri index 6f46e9e94..c6d13b731 100644 --- a/src/app/tape/tape.pri +++ b/src/app/tape/tape.pri @@ -11,7 +11,8 @@ SOURCES += \ $$PWD/vlitepattern.cpp \ $$PWD/dialogs/dialogtapepreferences.cpp \ $$PWD/dialogs/configpages/tapepreferencesconfigurationpage.cpp \ - $$PWD/dialogs/configpages/tapepreferencespathpage.cpp + $$PWD/dialogs/configpages/tapepreferencespathpage.cpp \ + $$PWD/vtapesettings.cpp *msvc*:SOURCES += $$PWD/stable.cpp @@ -26,7 +27,8 @@ HEADERS += \ $$PWD/vlitepattern.h \ $$PWD/dialogs/dialogtapepreferences.h \ $$PWD/dialogs/configpages/tapepreferencesconfigurationpage.h \ - $$PWD/dialogs/configpages/tapepreferencespathpage.h + $$PWD/dialogs/configpages/tapepreferencespathpage.h \ + $$PWD/vtapesettings.h FORMS += \ $$PWD/tmainwindow.ui \ diff --git a/src/libs/vmisc/vtapesettings.cpp b/src/app/tape/vtapesettings.cpp similarity index 100% rename from src/libs/vmisc/vtapesettings.cpp rename to src/app/tape/vtapesettings.cpp diff --git a/src/libs/vmisc/vtapesettings.h b/src/app/tape/vtapesettings.h similarity index 100% rename from src/libs/vmisc/vtapesettings.h rename to src/app/tape/vtapesettings.h diff --git a/src/app/valentina/core/core.pri b/src/app/valentina/core/core.pri index 8cd2a23c9..4c41cef6e 100644 --- a/src/app/valentina/core/core.pri +++ b/src/app/valentina/core/core.pri @@ -6,11 +6,13 @@ HEADERS += \ $$PWD/vformulaproperty.h \ $$PWD/vformulapropertyeditor.h \ $$PWD/vtooloptionspropertybrowser.h \ - $$PWD/vcmdexport.h + $$PWD/vcmdexport.h \ + $$PWD/vvalentinasettings.h SOURCES += \ $$PWD/vapplication.cpp \ $$PWD/vformulaproperty.cpp \ $$PWD/vformulapropertyeditor.cpp \ $$PWD/vtooloptionspropertybrowser.cpp \ - $$PWD/vcmdexport.cpp + $$PWD/vcmdexport.cpp \ + $$PWD/vvalentinasettings.cpp diff --git a/src/app/valentina/core/vapplication.cpp b/src/app/valentina/core/vapplication.cpp index 91514f439..6d0cf88bc 100644 --- a/src/app/valentina/core/vapplication.cpp +++ b/src/app/valentina/core/vapplication.cpp @@ -447,7 +447,7 @@ bool VApplication::notify(QObject *receiver, QEvent *event) void VApplication::ActivateDarkMode() { - VSettings *settings = qApp->ValentinaSettings(); + VValentinaSettings *settings = qApp->ValentinaSettings(); if (settings->GetDarkMode()) { QFile f(QStringLiteral(":qdarkstyle/style.qss")); @@ -726,15 +726,15 @@ void VApplication::AboutToQuit() */ void VApplication::OpenSettings() { - settings = new VSettings(QSettings::IniFormat, QSettings::UserScope, QCoreApplication::organizationName(), - QCoreApplication::applicationName(), this); + settings = new VValentinaSettings(QSettings::IniFormat, QSettings::UserScope, QCoreApplication::organizationName(), + QCoreApplication::applicationName(), this); } //--------------------------------------------------------------------------------------------------------------------- -VSettings *VApplication::ValentinaSettings() +VValentinaSettings *VApplication::ValentinaSettings() { SCASSERT(settings != nullptr) - return qobject_cast(settings); + return qobject_cast(settings); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/valentina/core/vapplication.h b/src/app/valentina/core/vapplication.h index 94dc56eff..a1af112bc 100644 --- a/src/app/valentina/core/vapplication.h +++ b/src/app/valentina/core/vapplication.h @@ -32,7 +32,7 @@ #include "../vmisc/vabstractapplication.h" #include "../vwidgets/vmaingraphicsview.h" #include "../vpatterndb/vtranslatevars.h" -#include "vsettings.h" +#include "vvalentinasettings.h" #include "vcmdexport.h" class VApplication;// use in define @@ -76,7 +76,7 @@ public: virtual bool IsPedantic() const override; virtual void OpenSettings() override; - VSettings *ValentinaSettings(); + VValentinaSettings *ValentinaSettings(); protected: virtual void InitTrVars() override; diff --git a/src/app/valentina/core/vcmdexport.cpp b/src/app/valentina/core/vcmdexport.cpp index e8354c418..40cfe7a6e 100644 --- a/src/app/valentina/core/vcmdexport.cpp +++ b/src/app/valentina/core/vcmdexport.cpp @@ -32,7 +32,7 @@ #include "../ifc/xml/vdomdocument.h" #include "../vformat/vmeasurements.h" #include "../vmisc/commandoptions.h" -#include "../vmisc/vsettings.h" +#include "vvalentinasettings.h" #include "../vmisc/dialogs/dialogexporttocsv.h" #include "../vlayout/vlayoutgenerator.h" #include "../vpatterndb/variables/vmeasurement.h" @@ -801,7 +801,7 @@ QStringList VCommandLine::OptionValues(const QString &option) const //--------------------------------------------------------------------------------------------------------------------- int VCommandLine::OptNestingTime() const { - int time = VSettings::GetDefNestingTime(); + int time = VValentinaSettings::GetDefNestingTime(); if (IsOptionSet(LONG_OPTION_NESTING_TIME)) { bool ok = false; @@ -821,7 +821,7 @@ int VCommandLine::OptNestingTime() const //--------------------------------------------------------------------------------------------------------------------- qreal VCommandLine::OptEfficiencyCoefficient() const { - qreal coefficient = VSettings::GetDefEfficiencyCoefficient(); + qreal coefficient = VValentinaSettings::GetDefEfficiencyCoefficient(); if (IsOptionSet(LONG_OPTION_EFFICIENCY_COEFFICIENT)) { bool ok = false; diff --git a/src/libs/vmisc/vsettings.cpp b/src/app/valentina/core/vvalentinasettings.cpp similarity index 63% rename from src/libs/vmisc/vsettings.cpp rename to src/app/valentina/core/vvalentinasettings.cpp index dbe6ff220..a12d2b050 100644 --- a/src/libs/vmisc/vsettings.cpp +++ b/src/app/valentina/core/vvalentinasettings.cpp @@ -26,7 +26,7 @@ ** *************************************************************************/ -#include "vsettings.h" +#include "vvalentinasettings.h" #include #include @@ -47,26 +47,6 @@ 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 { 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, settingPatternGraphicalOutput, (QLatin1String("pattern/graphicalOutput"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternUseOpenGLRender, (QLatin1String("pattern/useOpenGLRender"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternKnownMaterials, (QLatin1String("pattern/knownMaterials"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternRememberMaterials, (QLatin1String("pattern/rememberMaterials"))) @@ -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, 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, settingDockWidgetToolOptionsActive, (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, 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) :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) { qRegisterMetaTypeStreamOperators("QMarginsF"); } //--------------------------------------------------------------------------------------------------------------------- -template -inline T VSettings::ValueOrDef(const QString &setting, const T &defValue) const -{ - const QVariant val = value(setting, QVariant::fromValue(defValue)); - return val.canConvert() ? val.value() : defValue; -} - -//--------------------------------------------------------------------------------------------------------------------- -template <> -inline Cases VSettings::ValueOrDef(const QString &setting, const Cases &defValue) const -{ - const QVariant val = value(setting, QVariant::fromValue(static_cast(defValue))); - const int g = val.canConvert() ? val.value() : static_cast(defValue); - if (g < static_cast(Cases::CaseThreeGroup) || g >= static_cast(Cases::UnknownCase)) - { - return defValue; - } - else - { - return static_cast(g); - } -} - -//--------------------------------------------------------------------------------------------------------------------- -QString VSettings::GetLabelLanguage() const +QString VValentinaSettings::GetLabelLanguage() const { return value(*settingConfigurationLabelLanguage, QLocale().bcp47Name()).toString(); } //--------------------------------------------------------------------------------------------------------------------- -void VSettings::SetLabelLanguage(const QString &value) +void VValentinaSettings::SetLabelLanguage(const QString &value) { setValue(*settingConfigurationLabelLanguage, value); } //--------------------------------------------------------------------------------------------------------------------- -QString VSettings::GetDefPathLayout() +QString VValentinaSettings::GetDefPathLayout() { 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()); 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()); 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(*this, *settingLayoutPaperHeight, UnitConvertor(1189/*A0*/, Unit::Mm, Unit::Px)); } //--------------------------------------------------------------------------------------------------------------------- -void VSettings::SetGraphicalOutput(const bool &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(*settingLayoutPaperHeight, UnitConvertor(1189/*A0*/, Unit::Mm, Unit::Px)); -} - -//--------------------------------------------------------------------------------------------------------------------- -void VSettings::SetLayoutPaperHeight(qreal value) +void VValentinaSettings::SetLayoutPaperHeight(qreal value) { setValue(*settingLayoutPaperHeight, value); } //--------------------------------------------------------------------------------------------------------------------- -qreal VSettings::GetLayoutPaperWidth() const +qreal VValentinaSettings::GetLayoutPaperWidth() const { - return ValueOrDef(*settingLayoutPaperWidth, UnitConvertor(841/*A0*/, Unit::Mm, Unit::Px)); + return ValueOrDef(*this, *settingLayoutPaperWidth, UnitConvertor(841/*A0*/, Unit::Mm, Unit::Px)); } //--------------------------------------------------------------------------------------------------------------------- -void VSettings::SetLayoutPaperWidth(qreal value) +void VValentinaSettings::SetLayoutPaperWidth(qreal value) { setValue(*settingLayoutPaperWidth, value); } //--------------------------------------------------------------------------------------------------------------------- -qreal VSettings::GetLayoutWidth() const +qreal VValentinaSettings::GetLayoutWidth() const { - return ValueOrDef(*settingLayoutWidth, GetDefLayoutWidth()); + return ValueOrDef(*this, *settingLayoutWidth, GetDefLayoutWidth()); } //--------------------------------------------------------------------------------------------------------------------- -qreal VSettings::GetDefLayoutWidth() +qreal VValentinaSettings::GetDefLayoutWidth() { return UnitConvertor(2.5, Unit::Mm, Unit::Px); } //--------------------------------------------------------------------------------------------------------------------- -void VSettings::SetLayoutWidth(qreal value) +void VValentinaSettings::SetLayoutWidth(qreal value) { setValue(*settingLayoutWidth, value); } //--------------------------------------------------------------------------------------------------------------------- -int VSettings::GetNestingTime() const +int VValentinaSettings::GetNestingTime() const { - return ValueOrDef(*settingNestingTime, GetDefNestingTime()); + return ValueOrDef(*this, *settingNestingTime, GetDefNestingTime()); } //--------------------------------------------------------------------------------------------------------------------- -void VSettings::SetNestingTime(int value) +void VValentinaSettings::SetNestingTime(int value) { setValue(*settingNestingTime, value); } //--------------------------------------------------------------------------------------------------------------------- -qreal VSettings::GetEfficiencyCoefficient() const +qreal VValentinaSettings::GetEfficiencyCoefficient() const { - return ValueOrDef(*settingEfficiencyCoefficient, GetDefEfficiencyCoefficient()); + return ValueOrDef(*this, *settingEfficiencyCoefficient, GetDefEfficiencyCoefficient()); } //--------------------------------------------------------------------------------------------------------------------- -void VSettings::SetEfficiencyCoefficient(qreal value) +void VValentinaSettings::SetEfficiencyCoefficient(qreal value) { setValue(*settingEfficiencyCoefficient, value); } //--------------------------------------------------------------------------------------------------------------------- -QMarginsF VSettings::GetFields(const QMarginsF &def) const +QMarginsF VValentinaSettings::GetFields(const QMarginsF &def) const { - return ValueOrDef(*settingFields, def); + return ValueOrDef(*this, *settingFields, def); } //--------------------------------------------------------------------------------------------------------------------- -void VSettings::SetFields(const QMarginsF &value) +void VValentinaSettings::SetFields(const QMarginsF &value) { setValue(*settingFields, QVariant::fromValue(value)); } //--------------------------------------------------------------------------------------------------------------------- -Cases VSettings::GetLayoutGroup() const +Cases VValentinaSettings::GetLayoutGroup() const { - return ValueOrDef(*settingLayoutSorting, GetDefLayoutGroup()); + return ValueOrDef(*this, *settingLayoutSorting, GetDefLayoutGroup()); } //--------------------------------------------------------------------------------------------------------------------- -Cases VSettings::GetDefLayoutGroup() +Cases VValentinaSettings::GetDefLayoutGroup() { return Cases::CaseDesc; } //--------------------------------------------------------------------------------------------------------------------- -void VSettings::SetLayoutGroup(const Cases &value) +void VValentinaSettings::SetLayoutGroup(const Cases &value) { setValue(*settingLayoutSorting, static_cast(value)); } //--------------------------------------------------------------------------------------------------------------------- -bool VSettings::GetLayoutFollowGrainline() const +bool VValentinaSettings::GetLayoutFollowGrainline() const { return value(*settingLayoutFollowGrainline, GetDefLayoutFollowGrainline()).toBool(); } //--------------------------------------------------------------------------------------------------------------------- -bool VSettings::GetDefLayoutFollowGrainline() +bool VValentinaSettings::GetDefLayoutFollowGrainline() { return false; } //--------------------------------------------------------------------------------------------------------------------- -void VSettings::SetLayoutFollowGrainline(bool value) +void VValentinaSettings::SetLayoutFollowGrainline(bool value) { setValue(*settingLayoutFollowGrainline, value); } //--------------------------------------------------------------------------------------------------------------------- -bool VSettings::GetLayoutManualPriority() const +bool VValentinaSettings::GetLayoutManualPriority() const { return value(*settingLayoutManualPriority, GetDefLayoutManualPriority()).toBool(); } //--------------------------------------------------------------------------------------------------------------------- -bool VSettings::GetDefLayoutManualPriority() +bool VValentinaSettings::GetDefLayoutManualPriority() { return false; } //--------------------------------------------------------------------------------------------------------------------- -void VSettings::SetLayoutManualPriority(bool value) +void VValentinaSettings::SetLayoutManualPriority(bool value) { setValue(*settingLayoutManualPriority, value); } //--------------------------------------------------------------------------------------------------------------------- -bool VSettings::GetLayoutNestQuantity() const +bool VValentinaSettings::GetLayoutNestQuantity() const { return value(*settingLayoutNestQuantity, GetDefLayoutNestQuantity()).toBool(); } //--------------------------------------------------------------------------------------------------------------------- -bool VSettings::GetDefLayoutNestQuantity() +bool VValentinaSettings::GetDefLayoutNestQuantity() { return false; } //--------------------------------------------------------------------------------------------------------------------- -void VSettings::SetLayoutNestQuantity(bool value) +void VValentinaSettings::SetLayoutNestQuantity(bool value) { setValue(*settingLayoutNestQuantity, value); } //--------------------------------------------------------------------------------------------------------------------- -bool VSettings::GetLayoutAutoCropLength() const +bool VValentinaSettings::GetLayoutAutoCropLength() const { return value(*settingLayoutAutoCropLength, GetDefLayoutAutoCropLength()).toBool(); } //--------------------------------------------------------------------------------------------------------------------- -bool VSettings::GetDefLayoutAutoCropLength() +bool VValentinaSettings::GetDefLayoutAutoCropLength() { return false; } //--------------------------------------------------------------------------------------------------------------------- -void VSettings::SetLayoutAutoCropLength(bool value) +void VValentinaSettings::SetLayoutAutoCropLength(bool value) { setValue(*settingLayoutAutoCropLength, value); } //--------------------------------------------------------------------------------------------------------------------- -bool VSettings::GetLayoutAutoCropWidth() const +bool VValentinaSettings::GetLayoutAutoCropWidth() const { return value(*settingLayoutAutoCropWidth, GetDefLayoutAutoCropWidth()).toBool(); } //--------------------------------------------------------------------------------------------------------------------- -bool VSettings::GetDefLayoutAutoCropWidth() +bool VValentinaSettings::GetDefLayoutAutoCropWidth() { return false; } //--------------------------------------------------------------------------------------------------------------------- -void VSettings::SetLayoutAutoCropWidth(bool value) +void VValentinaSettings::SetLayoutAutoCropWidth(bool value) { setValue(*settingLayoutAutoCropWidth, value); } //--------------------------------------------------------------------------------------------------------------------- -bool VSettings::GetLayoutSaveLength() const +bool VValentinaSettings::GetLayoutSaveLength() const { return value(*settingLayoutSaveLength, GetDefLayoutSaveLength()).toBool(); } //--------------------------------------------------------------------------------------------------------------------- -bool VSettings::GetDefLayoutSaveLength() +bool VValentinaSettings::GetDefLayoutSaveLength() { return false; } //--------------------------------------------------------------------------------------------------------------------- -void VSettings::SetLayoutSaveLength(bool value) +void VValentinaSettings::SetLayoutSaveLength(bool value) { setValue(*settingLayoutSaveLength, value); } //--------------------------------------------------------------------------------------------------------------------- -bool VSettings::GetLayoutPreferOneSheetSolution() const +bool VValentinaSettings::GetLayoutPreferOneSheetSolution() const { return value(*settingLayoutPreferOneSheetSolution, GetDefLayoutPreferOneSheetSolution()).toBool(); } //--------------------------------------------------------------------------------------------------------------------- -bool VSettings::GetDefLayoutPreferOneSheetSolution() +bool VValentinaSettings::GetDefLayoutPreferOneSheetSolution() { return false; } //--------------------------------------------------------------------------------------------------------------------- -void VSettings::SetLayoutPreferOneSheetSolution(bool value) +void VValentinaSettings::SetLayoutPreferOneSheetSolution(bool value) { setValue(*settingLayoutPreferOneSheetSolution, value); } //--------------------------------------------------------------------------------------------------------------------- -bool VSettings::GetLayoutUnitePages() const +bool VValentinaSettings::GetLayoutUnitePages() const { return value(*settingLayoutUnitePages, GetDefLayoutUnitePages()).toBool(); } //--------------------------------------------------------------------------------------------------------------------- -bool VSettings::GetDefLayoutUnitePages() +bool VValentinaSettings::GetDefLayoutUnitePages() { return false; } //--------------------------------------------------------------------------------------------------------------------- -void VSettings::SetLayoutUnitePages(bool value) +void VValentinaSettings::SetLayoutUnitePages(bool value) { setValue(*settingLayoutUnitePages, value); } //--------------------------------------------------------------------------------------------------------------------- -bool VSettings::GetIgnoreAllFields() const +bool VValentinaSettings::GetIgnoreAllFields() const { return value(*settingIgnoreFields, GetDefIgnoreAllFields()).toBool(); } //--------------------------------------------------------------------------------------------------------------------- -bool VSettings::GetDefIgnoreAllFields() +bool VValentinaSettings::GetDefIgnoreAllFields() { return false; } //--------------------------------------------------------------------------------------------------------------------- -void VSettings::SetIgnoreAllFields(bool value) +void VValentinaSettings::SetIgnoreAllFields(bool value) { setValue(*settingIgnoreFields, value); } //--------------------------------------------------------------------------------------------------------------------- -bool VSettings::GetStripOptimization() const +bool VValentinaSettings::GetStripOptimization() const { return value(*settingStripOptimization, GetDefStripOptimization()).toBool(); } //--------------------------------------------------------------------------------------------------------------------- -bool VSettings::GetDefStripOptimization() +bool VValentinaSettings::GetDefStripOptimization() { return false; } //--------------------------------------------------------------------------------------------------------------------- -void VSettings::SetStripOptimization(bool value) +void VValentinaSettings::SetStripOptimization(bool value) { setValue(*settingStripOptimization, value); } //--------------------------------------------------------------------------------------------------------------------- -quint8 VSettings::GetMultiplier() const +quint8 VValentinaSettings::GetMultiplier() const { return static_cast(value(*settingMultiplier, GetDefMultiplier()).toUInt()); } //--------------------------------------------------------------------------------------------------------------------- -quint8 VSettings::GetDefMultiplier() +quint8 VValentinaSettings::GetDefMultiplier() { return 1; } //--------------------------------------------------------------------------------------------------------------------- -void VSettings::SetMultiplier(quint8 value) +void VValentinaSettings::SetMultiplier(quint8 value) { setValue(*settingMultiplier, value); } //--------------------------------------------------------------------------------------------------------------------- -bool VSettings::GetTextAsPaths() const +bool VValentinaSettings::GetTextAsPaths() const { return value(*settingTextAsPaths, GetDefTextAsPaths()).toBool(); } //--------------------------------------------------------------------------------------------------------------------- -bool VSettings::GetDefTextAsPaths() +bool VValentinaSettings::GetDefTextAsPaths() { return false; } //--------------------------------------------------------------------------------------------------------------------- -void VSettings::SetTextAsPaths(bool value) +void VValentinaSettings::SetTextAsPaths(bool value) { setValue(*settingTextAsPaths, value); } //--------------------------------------------------------------------------------------------------------------------- -QStringList VSettings::GetKnownMaterials() const +QStringList VValentinaSettings::GetKnownMaterials() const { return value(*settingPatternKnownMaterials, QStringList()).toStringList(); } //--------------------------------------------------------------------------------------------------------------------- -void VSettings::SetKnownMaterials(const QStringList &list) +void VValentinaSettings::SetKnownMaterials(const QStringList &list) { setValue(*settingPatternKnownMaterials, list); } //--------------------------------------------------------------------------------------------------------------------- -bool VSettings::IsRememberPatternMaterials() const +bool VValentinaSettings::IsRememberPatternMaterials() const { return value(*settingPatternRememberMaterials, true).toBool(); } //--------------------------------------------------------------------------------------------------------------------- -void VSettings::SetRememberPatternMaterials(bool value) +void VValentinaSettings::SetRememberPatternMaterials(bool value) { setValue(*settingPatternRememberMaterials, value); } @@ -569,10 +485,11 @@ void VSettings::SetRememberPatternMaterials(bool value) * internaly as mm so there is conversion beeing made. * @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. - return UnitConvertor(ValueOrDef(*settingTiledPDFMargins, QMarginsF(10, 10, 10, 10)), Unit::Mm, unit); + return UnitConvertor(ValueOrDef(*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 * 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))); } @@ -594,9 +511,9 @@ void VSettings::SetTiledPDFMargins(const QMarginsF &value, const Unit &unit) * internaly as mm so there is conversion beeing made. * @return tiled pdf paper height */ -qreal VSettings::GetTiledPDFPaperHeight(const Unit &unit) const +qreal VValentinaSettings::GetTiledPDFPaperHeight(const Unit &unit) const { - return UnitConvertor(ValueOrDef(*settingTiledPDFPaperHeight, 297 /*A4*/), Unit::Mm, unit); + return UnitConvertor(ValueOrDef(*this, *settingTiledPDFPaperHeight, 297 /*A4*/), Unit::Mm, unit); } //--------------------------------------------------------------------------------------------------------------------- @@ -605,7 +522,7 @@ qreal VSettings::GetTiledPDFPaperHeight(const Unit &unit) const * @param value in mm * @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)); } @@ -617,9 +534,9 @@ void VSettings::SetTiledPDFPaperHeight(qreal value, const Unit &unit) * internaly as mm so there is conversion beeing made. * @return tiled pdf paper width */ -qreal VSettings::GetTiledPDFPaperWidth(const Unit &unit) const +qreal VValentinaSettings::GetTiledPDFPaperWidth(const Unit &unit) const { - return UnitConvertor(ValueOrDef(*settingTiledPDFPaperWidth, 210 /*A4*/), Unit::Mm, unit); + return UnitConvertor(ValueOrDef(*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 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)); } //--------------------------------------------------------------------------------------------------------------------- -PageOrientation VSettings::GetTiledPDFOrientation() const +PageOrientation VValentinaSettings::GetTiledPDFOrientation() const { bool defaultValue = static_cast(PageOrientation::Portrait); 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 (value)); } -//--------------------------------------------------------------------------------------------------------------------- -int VSettings::GetScrollingDuration() const -{ - return GetCachedValue(scrollingDurationCached, *settingScrollingDuration, defaultScrollingDuration, - scrollingDurationMin, scrollingDurationMax); -} + //--------------------------------------------------------------------------------------------------------------------- -void VSettings::SetScrollingDuration(int duration) -{ - scrollingDurationCached = qBound(scrollingDurationMin, duration, scrollingDurationMax); - setValue(*settingScrollingDuration, scrollingDurationCached); -} - -//--------------------------------------------------------------------------------------------------------------------- -int VSettings::GetScrollingUpdateInterval() const -{ - return GetCachedValue(scrollingUpdateIntervalCached, *settingScrollingUpdateInterval, - defaultScrollingUpdateInterval, scrollingUpdateIntervalMin, scrollingUpdateIntervalMax); -} - -//--------------------------------------------------------------------------------------------------------------------- -void VSettings::SetScrollingUpdateInterval(int updateInterval) -{ - scrollingUpdateIntervalCached = qBound(scrollingUpdateIntervalMin, updateInterval, scrollingUpdateIntervalMax); - setValue(*settingScrollingUpdateInterval, scrollingUpdateIntervalCached); -} - -//--------------------------------------------------------------------------------------------------------------------- -qreal VSettings::GetSensorMouseScale() const -{ - return GetCachedValue(scrollingSensorMouseScaleCached, *settingScrollingSensorMouseScale, defaultSensorMouseScale, - sensorMouseScaleMin, sensorMouseScaleMax); -} - -//--------------------------------------------------------------------------------------------------------------------- -void VSettings::SetSensorMouseScale(qreal scale) -{ - scrollingSensorMouseScaleCached = qBound(sensorMouseScaleMin, scale, sensorMouseScaleMax); - setValue(*settingScrollingSensorMouseScale, scrollingSensorMouseScaleCached); -} - -//--------------------------------------------------------------------------------------------------------------------- -qreal VSettings::GetWheelMouseScale() const -{ - return GetCachedValue(scrollingWheelMouseScaleCached, *settingScrollingWheelMouseScale, defaultWheelMouseScale, - wheelMouseScaleMin, wheelMouseScaleMax); -} - -//--------------------------------------------------------------------------------------------------------------------- -void VSettings::SetWheelMouseScale(qreal scale) -{ - scrollingWheelMouseScaleCached = qBound(wheelMouseScaleMin, scale, wheelMouseScaleMax); - setValue(*settingScrollingWheelMouseScale, scrollingWheelMouseScaleCached); -} - -//--------------------------------------------------------------------------------------------------------------------- -qreal VSettings::GetScrollingAcceleration() const -{ - return GetCachedValue(scrollingAccelerationCached, *settingScrollingAcceleration, defaultScrollingAcceleration, - scrollingAccelerationMin, scrollingAccelerationMax); -} - -//--------------------------------------------------------------------------------------------------------------------- -void VSettings::SetScrollingAcceleration(qreal acceleration) -{ - scrollingAccelerationCached = qBound(scrollingAccelerationMin, acceleration, scrollingAccelerationMax); - setValue(*settingScrollingAcceleration, scrollingAccelerationCached); -} - -//--------------------------------------------------------------------------------------------------------------------- -bool VSettings::IsDockWidgetGroupsActive() const +bool VValentinaSettings::IsDockWidgetGroupsActive() const { return value(*settingdockWidgetGroupsActive, GetDefDockWidgetGroupsActive()).toBool(); } //--------------------------------------------------------------------------------------------------------------------- -bool VSettings::GetDefDockWidgetGroupsActive() +bool VValentinaSettings::GetDefDockWidgetGroupsActive() { return true; } //--------------------------------------------------------------------------------------------------------------------- -void VSettings::SetDockWidgetGroupsActive(bool value) +void VValentinaSettings::SetDockWidgetGroupsActive(bool value) { setValue(*settingdockWidgetGroupsActive, value); } //--------------------------------------------------------------------------------------------------------------------- -bool VSettings::IsDockWidgetToolOptionsActive() const +bool VValentinaSettings::IsDockWidgetToolOptionsActive() const { return value(*settingDockWidgetToolOptionsActive, GetDefDockWidgetToolOptionsActive()).toBool(); } //--------------------------------------------------------------------------------------------------------------------- -bool VSettings::GetDefDockWidgetToolOptionsActive() +bool VValentinaSettings::GetDefDockWidgetToolOptionsActive() { return true; } //--------------------------------------------------------------------------------------------------------------------- -void VSettings::SetDockWidgetToolOptionsActive(bool value) +void VValentinaSettings::SetDockWidgetToolOptionsActive(bool value) { setValue(*settingDockWidgetToolOptionsActive, value); } //--------------------------------------------------------------------------------------------------------------------- -bool VSettings::IsDockWidgetPatternMessagesActive() const +bool VValentinaSettings::IsDockWidgetPatternMessagesActive() const { return value(*settingDockWidgetPatternMessagesActive, GetDefDockWidgetPatternMessagesActive()).toBool(); } //--------------------------------------------------------------------------------------------------------------------- -bool VSettings::GetDefDockWidgetPatternMessagesActive() +bool VValentinaSettings::GetDefDockWidgetPatternMessagesActive() { return true; } //--------------------------------------------------------------------------------------------------------------------- -void VSettings::SetDockWidgetPatternMessagesActive(bool value) +void VValentinaSettings::SetDockWidgetPatternMessagesActive(bool value) { setValue(*settingDockWidgetPatternMessagesActive, value); } //--------------------------------------------------------------------------------------------------------------------- -int VSettings::GetPatternMessageFontSize(int fontSizeDef) const +int VValentinaSettings::GetPatternMessageFontSize(int fontSizeDef) const { fontSizeDef = qBound(GetDefMinPatternMessageFontSize(), fontSizeDef, GetDefMaxPatternMessageFontSize()); 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; } //--------------------------------------------------------------------------------------------------------------------- -int VSettings::GetDefMaxPatternMessageFontSize() +int VValentinaSettings::GetDefMaxPatternMessageFontSize() { return 40; } //--------------------------------------------------------------------------------------------------------------------- -void VSettings::SetPatternMessageFontSize(int size) +void VValentinaSettings::SetPatternMessageFontSize(int size) { setValue(*settingPatternMessagesFontSize, qBound(GetDefMinPatternMessageFontSize(), size, GetDefMaxPatternMessageFontSize())); } //--------------------------------------------------------------------------------------------------------------------- -bool VSettings::GetAutoRefreshPatternMessage() const +bool VValentinaSettings::GetAutoRefreshPatternMessage() const { return value(*settingAutoRefreshPatternMessage, true).toBool(); } //--------------------------------------------------------------------------------------------------------------------- -void VSettings::SetAutoRefreshPatternMessage(bool value) +void VValentinaSettings::SetAutoRefreshPatternMessage(bool value) { setValue(*settingAutoRefreshPatternMessage, value); } //--------------------------------------------------------------------------------------------------------------------- -QSize VSettings::GetWatermarkEditorSize() const +QSize VValentinaSettings::GetWatermarkEditorSize() const { return value(*settingWatermarkEditorSize, QSize(0, 0)).toSize(); } //--------------------------------------------------------------------------------------------------------------------- -void VSettings::SetWatermarkEditorSize(const QSize &sz) +void VValentinaSettings::SetWatermarkEditorSize(const QSize &sz) { setValue(*settingWatermarkEditorSize, sz); } - -//--------------------------------------------------------------------------------------------------------------------- -template -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; -} diff --git a/src/libs/vmisc/vsettings.h b/src/app/valentina/core/vvalentinasettings.h similarity index 75% rename from src/libs/vmisc/vsettings.h rename to src/app/valentina/core/vvalentinasettings.h index 8b6d0aacd..90b362b49 100644 --- a/src/libs/vmisc/vsettings.h +++ b/src/app/valentina/core/vvalentinasettings.h @@ -26,8 +26,8 @@ ** *************************************************************************/ -#ifndef VSETTINGS_H -#define VSETTINGS_H +#ifndef VVALENTINASETTINGS_H +#define VVALENTINASETTINGS_H #include #include @@ -39,13 +39,13 @@ #include "vcommonsettings.h" #include "../vlayout/vbank.h" -class VSettings : public VCommonSettings +class VValentinaSettings : public VCommonSettings { Q_OBJECT 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); - VSettings(const QString &fileName, Format format, QObject *parent = nullptr); + VValentinaSettings(const QString &fileName, Format format, QObject *parent = nullptr); QString GetLabelLanguage() const; void SetLabelLanguage(const QString &value); @@ -54,12 +54,6 @@ public: QString GetPathLayout() const; void SetPathLayout(const QString &value); - bool GetGraphicalOutput() const; - void SetGraphicalOutput(const bool &value); - - bool IsOpenGLRender() const; - void SetOpenGLRender(bool value); - // Layout settings qreal GetLayoutPaperHeight() const; void SetLayoutPaperHeight(qreal value); @@ -153,36 +147,6 @@ public: PageOrientation GetTiledPDFOrientation() const; 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; static bool GetDefDockWidgetGroupsActive(); void SetDockWidgetGroupsActive(bool value); @@ -207,13 +171,7 @@ public: void SetWatermarkEditorSize(const QSize& sz); private: - Q_DISABLE_COPY(VSettings) - - template - T GetCachedValue(T &cache, const QString &setting, T defValue, T valueMin, T valueMax) const; - - template - T ValueOrDef(const QString &setting, const T &defValue) const; + Q_DISABLE_COPY(VValentinaSettings) }; -#endif // VSETTINGS_H +#endif // VVALENTINASETTINGS_H diff --git a/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.cpp b/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.cpp index 42b28b929..00dd4c869 100644 --- a/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.cpp +++ b/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.cpp @@ -110,13 +110,13 @@ PreferencesConfigurationPage::PreferencesConfigurationPage(QWidget *parent) //----------------------------- Pattern Editing connect(ui->resetWarningsButton, &QPushButton::released, this, []() { - VSettings *settings = qApp->ValentinaSettings(); + VValentinaSettings *settings = qApp->ValentinaSettings(); settings->SetConfirmItemDelete(true); settings->SetConfirmFormatRewriting(true); }); - VSettings *settings = qApp->ValentinaSettings(); + VValentinaSettings *settings = qApp->ValentinaSettings(); ui->checkBoxFreeCurve->setChecked(settings->IsFreeCurveMode()); ui->checkBoxZoomFitBestCurrentPP->setChecked(settings->IsDoubleClickZoomFitBestCurrentPP()); @@ -128,24 +128,24 @@ PreferencesConfigurationPage::PreferencesConfigurationPage(QWidget *parent) ui->darkModeCheck->setChecked(settings->GetDarkMode()); // Tab Scrolling - ui->spinBoxDuration->setMinimum(VSettings::scrollingDurationMin); - ui->spinBoxDuration->setMaximum(VSettings::scrollingDurationMax); + ui->spinBoxDuration->setMinimum(VValentinaSettings::scrollingDurationMin); + ui->spinBoxDuration->setMaximum(VValentinaSettings::scrollingDurationMax); ui->spinBoxDuration->setValue(settings->GetScrollingDuration()); - ui->spinBoxUpdateInterval->setMinimum(VSettings::scrollingUpdateIntervalMin); - ui->spinBoxUpdateInterval->setMaximum(VSettings::scrollingUpdateIntervalMax); + ui->spinBoxUpdateInterval->setMinimum(VValentinaSettings::scrollingUpdateIntervalMin); + ui->spinBoxUpdateInterval->setMaximum(VValentinaSettings::scrollingUpdateIntervalMax); ui->spinBoxUpdateInterval->setValue(settings->GetScrollingUpdateInterval()); - ui->doubleSpinBoxSensor->setMinimum(VSettings::sensorMouseScaleMin); - ui->doubleSpinBoxSensor->setMaximum(VSettings::sensorMouseScaleMax); + ui->doubleSpinBoxSensor->setMinimum(VValentinaSettings::sensorMouseScaleMin); + ui->doubleSpinBoxSensor->setMaximum(VValentinaSettings::sensorMouseScaleMax); ui->doubleSpinBoxSensor->setValue(settings->GetSensorMouseScale()); - ui->doubleSpinBoxWheel->setMinimum(VSettings::wheelMouseScaleMin); - ui->doubleSpinBoxWheel->setMaximum(VSettings::wheelMouseScaleMax); + ui->doubleSpinBoxWheel->setMinimum(VValentinaSettings::wheelMouseScaleMin); + ui->doubleSpinBoxWheel->setMaximum(VValentinaSettings::wheelMouseScaleMax); ui->doubleSpinBoxWheel->setValue(settings->GetWheelMouseScale()); - ui->doubleSpinBoxAcceleration->setMinimum(VSettings::scrollingAccelerationMin); - ui->doubleSpinBoxAcceleration->setMaximum(VSettings::scrollingAccelerationMax); + ui->doubleSpinBoxAcceleration->setMinimum(VValentinaSettings::scrollingAccelerationMin); + ui->doubleSpinBoxAcceleration->setMaximum(VValentinaSettings::scrollingAccelerationMax); ui->doubleSpinBoxAcceleration->setValue(settings->GetScrollingAcceleration()); } @@ -160,7 +160,7 @@ QStringList PreferencesConfigurationPage::Apply() { // Tab General QStringList preferences; - VSettings *settings = qApp->ValentinaSettings(); + VValentinaSettings *settings = qApp->ValentinaSettings(); settings->SetAutosaveState(ui->autoSaveCheck->isChecked()); settings->SetAutosaveTime(ui->autoTime->value()); diff --git a/src/app/valentina/dialogs/configpages/preferencespathpage.cpp b/src/app/valentina/dialogs/configpages/preferencespathpage.cpp index 182ab1c35..63a23fc87 100644 --- a/src/app/valentina/dialogs/configpages/preferencespathpage.cpp +++ b/src/app/valentina/dialogs/configpages/preferencespathpage.cpp @@ -28,7 +28,7 @@ #include "preferencespathpage.h" #include "ui_preferencespathpage.h" -#include "../vmisc/vsettings.h" +#include "../../core/vvalentinasettings.h" #include "../../core/vapplication.h" #include @@ -65,7 +65,7 @@ PreferencesPathPage::~PreferencesPathPage() //--------------------------------------------------------------------------------------------------------------------- QStringList PreferencesPathPage::Apply() { - VSettings *settings = qApp->ValentinaSettings(); + VValentinaSettings *settings = qApp->ValentinaSettings(); settings->SetPathIndividualMeasurements(ui->pathTable->item(0, 1)->text()); settings->SetPathMultisizeMeasurements(ui->pathTable->item(1, 1)->text()); settings->SetPathPattern(ui->pathTable->item(2, 1)->text()); @@ -105,13 +105,13 @@ void PreferencesPathPage::DefaultPath() path = VCommonSettings::GetDefPathMultisizeMeasurements(); break; case 2: // pattern path - path = VSettings::GetDefPathPattern(); + path = VValentinaSettings::GetDefPathPattern(); break; case 0: // individual measurements path = VCommonSettings::GetDefPathIndividualMeasurements(); break; case 3: // layout path - path = VSettings::GetDefPathLayout(); + path = VValentinaSettings::GetDefPathLayout(); break; case 4: // templates path = VCommonSettings::GetDefPathTemplate(); @@ -206,7 +206,7 @@ void PreferencesPathPage::InitTable() ui->pathTable->setRowCount(7); 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"))); diff --git a/src/app/valentina/dialogs/configpages/preferencespatternpage.cpp b/src/app/valentina/dialogs/configpages/preferencespatternpage.cpp index 58a436366..ee71cc4d2 100644 --- a/src/app/valentina/dialogs/configpages/preferencespatternpage.cpp +++ b/src/app/valentina/dialogs/configpages/preferencespatternpage.cpp @@ -63,7 +63,7 @@ PreferencesPatternPage::PreferencesPatternPage(QWidget *parent) ui->setupUi(this); RetranslateUi(); - VSettings *settings = qApp->ValentinaSettings(); + VValentinaSettings *settings = qApp->ValentinaSettings(); ui->graphOutputCheck->setChecked(settings->GetGraphicalOutput()); ui->checkBoxOpenGLRender->setChecked(settings->IsOpenGLRender()); @@ -125,7 +125,7 @@ QStringList PreferencesPatternPage::Apply() { QStringList preferences; - VSettings *settings = qApp->ValentinaSettings(); + VValentinaSettings *settings = qApp->ValentinaSettings(); // Scene antialiasing if (settings->GetGraphicalOutput() != ui->graphOutputCheck->isChecked()) @@ -200,7 +200,7 @@ void PreferencesPatternPage::changeEvent(QEvent *event) //--------------------------------------------------------------------------------------------------------------------- void PreferencesPatternPage::EditDateTimeFormats() { - VSettings *settings = qApp->ValentinaSettings(); + VValentinaSettings *settings = qApp->ValentinaSettings(); QPushButton *button = qobject_cast(sender()); if (button == ui->pushButtonEditDateFormats) @@ -230,7 +230,7 @@ void PreferencesPatternPage::ManageKnownMaterials() //--------------------------------------------------------------------------------------------------------------------- void PreferencesPatternPage::InitLabelDateTimeFormats() { - VSettings *settings = qApp->ValentinaSettings(); + VValentinaSettings *settings = qApp->ValentinaSettings(); InitComboBoxFormats(ui->comboBoxDateFormats, VCommonSettings::PredefinedDateFormats() + settings->GetUserDefinedDateFormats(), diff --git a/src/app/valentina/dialogs/dialogfinalmeasurements.cpp b/src/app/valentina/dialogs/dialogfinalmeasurements.cpp index eed634d6a..0a4348df4 100644 --- a/src/app/valentina/dialogs/dialogfinalmeasurements.cpp +++ b/src/app/valentina/dialogs/dialogfinalmeasurements.cpp @@ -28,7 +28,7 @@ #include "dialogfinalmeasurements.h" #include "ui_dialogfinalmeasurements.h" -#include "../vmisc/vsettings.h" +#include "../core/vvalentinasettings.h" #include "../vmisc/compatibility.h" #include "../qmuparser/qmudef.h" #include "../qmuparser/qmutokenparser.h" diff --git a/src/app/valentina/dialogs/dialogincrements.cpp b/src/app/valentina/dialogs/dialogincrements.cpp index b626b416c..958164d59 100644 --- a/src/app/valentina/dialogs/dialogincrements.cpp +++ b/src/app/valentina/dialogs/dialogincrements.cpp @@ -29,7 +29,7 @@ #include "dialogincrements.h" #include "ui_dialogincrements.h" #include "../vwidgets/vwidgetpopup.h" -#include "../vmisc/vsettings.h" +#include "../core/vvalentinasettings.h" #include "../qmuparser/qmudef.h" #include "../qmuparser/qmutokenparser.h" #include "../vpatterndb/vtranslatevars.h" diff --git a/src/app/valentina/dialogs/dialoglayoutscale.cpp b/src/app/valentina/dialogs/dialoglayoutscale.cpp index 256c66f14..8178c3151 100644 --- a/src/app/valentina/dialogs/dialoglayoutscale.cpp +++ b/src/app/valentina/dialogs/dialoglayoutscale.cpp @@ -29,7 +29,7 @@ #include "dialoglayoutscale.h" #include "ui_dialoglayoutscale.h" #include "../core/vapplication.h" -#include "../vmisc/vsettings.h" +#include "../core/vvalentinasettings.h" #include @@ -180,7 +180,7 @@ void DialogLayoutScale::VerticalScaleChanged(double d) //--------------------------------------------------------------------------------------------------------------------- void DialogLayoutScale::ReadSettings() { - VSettings *settings = qApp->ValentinaSettings(); + VValentinaSettings *settings = qApp->ValentinaSettings(); const Unit unit = qApp->patternUnit(); // read Margins top, right, bottom, left @@ -200,7 +200,7 @@ void DialogLayoutScale::ReadSettings() //--------------------------------------------------------------------------------------------------------------------- void DialogLayoutScale::WriteSettings() const { - VSettings *settings = qApp->ValentinaSettings(); + VValentinaSettings *settings = qApp->ValentinaSettings(); const Unit unit = qApp->patternUnit(); // write Margins top, right, bottom, left diff --git a/src/app/valentina/dialogs/dialoglayoutsettings.cpp b/src/app/valentina/dialogs/dialoglayoutsettings.cpp index 04549ef52..39665e287 100644 --- a/src/app/valentina/dialogs/dialoglayoutsettings.cpp +++ b/src/app/valentina/dialogs/dialoglayoutsettings.cpp @@ -30,7 +30,7 @@ #include "ui_dialoglayoutsettings.h" #include "../core/vapplication.h" #include "../ifc/xml/vdomdocument.h" -#include "../vmisc/vsettings.h" +#include "../core/vvalentinasettings.h" #include "../vmisc/vmath.h" #include "../vlayout/vlayoutgenerator.h" @@ -698,17 +698,17 @@ void DialogLayoutSettings::RestoreDefaults() InitPrinter(); ui->comboBoxPrinter->blockSignals(false); - SetLayoutWidth(VSettings::GetDefLayoutWidth()); - SetGroup(VSettings::GetDefLayoutGroup()); - SetFollowGrainline(VSettings::GetDefLayoutFollowGrainline()); - SetManualPriority(VSettings::GetDefLayoutManualPriority()); + SetLayoutWidth(VValentinaSettings::GetDefLayoutWidth()); + SetGroup(VValentinaSettings::GetDefLayoutGroup()); + SetFollowGrainline(VValentinaSettings::GetDefLayoutFollowGrainline()); + SetManualPriority(VValentinaSettings::GetDefLayoutManualPriority()); SetFields(GetDefPrinterFields()); - SetIgnoreAllFields(VSettings::GetDefIgnoreAllFields()); - SetMultiplier(VSettings::GetDefMultiplier()); - SetNestingTime(VSettings::GetDefNestingTime()); - SetEfficiencyCoefficient(VSettings::GetDefEfficiencyCoefficient()); - SetNestQuantity(VSettings::GetDefLayoutNestQuantity()); - SetPreferOneSheetSolution(VSettings::GetDefLayoutPreferOneSheetSolution()); + SetIgnoreAllFields(VValentinaSettings::GetDefIgnoreAllFields()); + SetMultiplier(VValentinaSettings::GetDefMultiplier()); + SetNestingTime(VValentinaSettings::GetDefNestingTime()); + SetEfficiencyCoefficient(VValentinaSettings::GetDefEfficiencyCoefficient()); + SetNestQuantity(VValentinaSettings::GetDefLayoutNestQuantity()); + SetPreferOneSheetSolution(VValentinaSettings::GetDefLayoutPreferOneSheetSolution()); CorrectMaxFileds(); IgnoreAllFields(ui->checkBoxIgnoreFileds->isChecked()); @@ -1019,7 +1019,7 @@ void DialogLayoutSettings::MinimumLayoutSize() //--------------------------------------------------------------------------------------------------------------------- void DialogLayoutSettings::ReadSettings() { - const VSettings *settings = qApp->ValentinaSettings(); + const VValentinaSettings *settings = qApp->ValentinaSettings(); SetLayoutWidth(settings->GetLayoutWidth()); SetNestingTime(settings->GetNestingTime()); SetEfficiencyCoefficient(settings->GetEfficiencyCoefficient()); @@ -1051,7 +1051,7 @@ void DialogLayoutSettings::ReadSettings() //--------------------------------------------------------------------------------------------------------------------- void DialogLayoutSettings::WriteSettings() const { - VSettings *settings = qApp->ValentinaSettings(); + VValentinaSettings *settings = qApp->ValentinaSettings(); settings->SetLayoutWidth(GetLayoutWidth()); settings->SetLayoutGroup(GetGroup()); settings->SetLayoutPaperHeight(GetPaperHeight()); diff --git a/src/app/valentina/dialogs/dialognewpattern.cpp b/src/app/valentina/dialogs/dialognewpattern.cpp index d3277640f..b31592ffa 100644 --- a/src/app/valentina/dialogs/dialognewpattern.cpp +++ b/src/app/valentina/dialogs/dialognewpattern.cpp @@ -29,7 +29,7 @@ #include "dialognewpattern.h" #include "ui_dialognewpattern.h" #include "../core/vapplication.h" -#include "../vmisc/vsettings.h" +#include "../core/vvalentinasettings.h" #include "../vpatterndb/vcontainer.h" #include diff --git a/src/app/valentina/dialogs/dialogpatternproperties.cpp b/src/app/valentina/dialogs/dialogpatternproperties.cpp index a4a70120a..a73e74251 100644 --- a/src/app/valentina/dialogs/dialogpatternproperties.cpp +++ b/src/app/valentina/dialogs/dialogpatternproperties.cpp @@ -81,7 +81,7 @@ DialogPatternProperties::DialogPatternProperties(VPattern *doc, VContainer *pat SCASSERT(doc != nullptr) - VSettings *settings = qApp->ValentinaSettings(); + VValentinaSettings *settings = qApp->ValentinaSettings(); settings->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c()); patternMaterials = doc->GetPatternMaterials(); @@ -951,7 +951,7 @@ void DialogPatternProperties::EditLabel() //--------------------------------------------------------------------------------------------------------------------- void DialogPatternProperties::ManagePatternMaterials() { - VSettings *settings = qApp->ValentinaSettings(); + VValentinaSettings *settings = qApp->ValentinaSettings(); DialogPatternMaterials editor(patternMaterials, settings->IsRememberPatternMaterials()); diff --git a/src/app/valentina/dialogs/dialogsavelayout.cpp b/src/app/valentina/dialogs/dialogsavelayout.cpp index 58ec2458a..305ce6907 100644 --- a/src/app/valentina/dialogs/dialogsavelayout.cpp +++ b/src/app/valentina/dialogs/dialogsavelayout.cpp @@ -29,7 +29,7 @@ #include "dialogsavelayout.h" #include "ui_dialogsavelayout.h" #include "../core/vapplication.h" -#include "../vmisc/vsettings.h" +#include "../core/vvalentinasettings.h" #include "../ifc/exception/vexception.h" #include @@ -903,7 +903,7 @@ void DialogSaveLayout::RemoveFormatFromList(LayoutExportFormats format) */ void DialogSaveLayout::ReadSettings() { - VSettings *settings = qApp->ValentinaSettings(); + VValentinaSettings *settings = qApp->ValentinaSettings(); const Unit unit = qApp->patternUnit(); // read Margins top, right, bottom, left @@ -957,7 +957,7 @@ void DialogSaveLayout::WriteSettings() const return; } - VSettings *settings = qApp->ValentinaSettings(); + VValentinaSettings *settings = qApp->ValentinaSettings(); const Unit unit = qApp->patternUnit(); // write Margins top, right, bottom, left diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index 9b12bdc46..afb76e1d1 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -37,7 +37,7 @@ #include "version.h" #include "core/vapplication.h" #include "../vmisc/customevents.h" -#include "../vmisc/vsettings.h" +#include "core/vvalentinasettings.h" #include "../vmisc/def.h" #include "../vmisc/qxtcsvmodel.h" #include "../vmisc/vmodifierkey.h" @@ -301,7 +301,7 @@ MainWindow::MainWindow(QWidget *parent) connect(ui->toolButtonMessagesZoomInFont, &QToolButton::clicked, this, [this]() { - VSettings *settings = qApp->ValentinaSettings(); + VValentinaSettings *settings = qApp->ValentinaSettings(); QFont f = ui->plainTextEditPatternMessages->font(); if (f.pointSize() < settings->GetDefMaxPatternMessageFontSize()) { @@ -313,7 +313,7 @@ MainWindow::MainWindow(QWidget *parent) connect(ui->toolButtonMessagesZoomOutFont, &QToolButton::clicked, this, [this]() { - VSettings *settings = qApp->ValentinaSettings(); + VValentinaSettings *settings = qApp->ValentinaSettings(); QFont f = ui->plainTextEditPatternMessages->font(); if (f.pointSize() > settings->GetDefMinPatternMessageFontSize()) { @@ -2195,7 +2195,7 @@ void MainWindow::ToolBarTools() ui->actionIncreaseLabelFont->setShortcut(QKeySequence(Qt::ShiftModifier + Qt::Key_Plus)); connect(ui->actionIncreaseLabelFont, &QAction::triggered, this, [this]() { - VSettings *settings = qApp->ValentinaSettings(); + VValentinaSettings *settings = qApp->ValentinaSettings(); settings->SetLabelFontSize(settings->GetLabelFontSize() + 1); if (sceneDraw) { @@ -2211,7 +2211,7 @@ void MainWindow::ToolBarTools() ui->actionDecreaseLabelFont->setShortcut(QKeySequence(Qt::ShiftModifier + Qt::Key_Minus)); connect(ui->actionDecreaseLabelFont, &QAction::triggered, this, [this]() { - VSettings *settings = qApp->ValentinaSettings(); + VValentinaSettings *settings = qApp->ValentinaSettings(); settings->SetLabelFontSize(settings->GetLabelFontSize() - 1); if (sceneDraw) { @@ -2227,7 +2227,7 @@ void MainWindow::ToolBarTools() ui->actionOriginalLabelFont->setShortcut(QKeySequence(Qt::ShiftModifier + Qt::Key_0)); connect(ui->actionOriginalLabelFont, &QAction::triggered, this, [this]() { - VSettings *settings = qApp->ValentinaSettings(); + VValentinaSettings *settings = qApp->ValentinaSettings(); settings->SetLabelFontSize(settings->GetDefLabelFontSize()); if (sceneDraw) { @@ -4172,7 +4172,7 @@ void MainWindow::setCurrentFile(const QString &fileName) if (not qApp->GetPatternPath().isEmpty() && VApplication::IsGUIMode()) { qCDebug(vMainWindow, "Updating recent file list."); - VSettings *settings = qApp->ValentinaSettings(); + VValentinaSettings *settings = qApp->ValentinaSettings(); QStringList files = settings->GetRecentFileList(); files.removeAll(fileName); files.prepend(fileName); @@ -4201,7 +4201,7 @@ void MainWindow::setCurrentFile(const QString &fileName) void MainWindow::ReadSettings() { qCDebug(vMainWindow, "Reading settings."); - const VSettings *settings = qApp->ValentinaSettings(); + const VValentinaSettings *settings = qApp->ValentinaSettings(); if (settings->status() == QSettings::NoError) { @@ -4243,7 +4243,7 @@ void MainWindow::WriteSettings() { ActionDraw(true); - VSettings *settings = qApp->ValentinaSettings(); + VValentinaSettings *settings = qApp->ValentinaSettings(); settings->SetGeometry(saveGeometry()); settings->SetWindowState(saveState()); settings->SetToolbarsState(saveState(APP_VERSION)); diff --git a/src/app/valentina/mainwindowsnogui.cpp b/src/app/valentina/mainwindowsnogui.cpp index adfb73090..eb15fd5f6 100644 --- a/src/app/valentina/mainwindowsnogui.cpp +++ b/src/app/valentina/mainwindowsnogui.cpp @@ -1820,7 +1820,7 @@ void MainWindowsNoGUI::SetPrinterSettings(QPrinter *printer, const PrintType &pr } else { - VSettings *settings = qApp->ValentinaSettings(); + VValentinaSettings *settings = qApp->ValentinaSettings(); pageMargin = QMarginsF(settings->GetTiledPDFMargins(Unit::Mm)); orientation = settings->GetTiledPDFOrientation(); } diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index f3a6824cb..7c5ae24c7 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -40,7 +40,7 @@ #include "../ifc/exception/vexceptionundo.h" #include "../ifc/xml/vpatternconverter.h" #include "../vmisc/customevents.h" -#include "../vmisc/vsettings.h" +#include "../core/vvalentinasettings.h" #include "../vmisc/vmath.h" #include "../vmisc/projectversion.h" #include "../vmisc/compatibility.h" diff --git a/src/libs/vmisc/testvapplication.h b/src/libs/vmisc/testvapplication.h index b19c21541..ab21aa014 100644 --- a/src/libs/vmisc/testvapplication.h +++ b/src/libs/vmisc/testvapplication.h @@ -37,7 +37,17 @@ #endif #define qApp (static_cast(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"); + } +}; class TestVApplication : public VAbstractApplication { @@ -50,7 +60,7 @@ public: setApplicationName("ValentinaTest"); setOrganizationName(VER_COMPANYNAME_STR); - OpenSettings(); + TestVApplication::OpenSettings(); } virtual ~TestVApplication() Q_DECL_EQ_DEFAULT; @@ -62,8 +72,8 @@ public: virtual void OpenSettings() override { - settings = new VSettings(QSettings::IniFormat, QSettings::UserScope, QCoreApplication::organizationName(), - QCoreApplication::applicationName(), this); + settings = new VTestSettings(QSettings::IniFormat, QSettings::UserScope, QCoreApplication::organizationName(), + QCoreApplication::applicationName(), this); } virtual bool IsAppInGUIMode() const override @@ -88,16 +98,4 @@ private: 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"); - } -}; - #endif // TESTVAPPLICATION_H diff --git a/src/libs/vmisc/vabstractapplication.h b/src/libs/vmisc/vabstractapplication.h index d3e16cd5a..47bc7b6e9 100644 --- a/src/libs/vmisc/vabstractapplication.h +++ b/src/libs/vmisc/vabstractapplication.h @@ -45,7 +45,6 @@ #include "def.h" #include "vcommonsettings.h" #include "vlockguard.h" -#include "vsettings.h" class QUndoStack; class VAbstractApplication;// use in define diff --git a/src/libs/vmisc/vcommonsettings.cpp b/src/libs/vmisc/vcommonsettings.cpp index c394aafcf..170eb7561 100644 --- a/src/libs/vmisc/vcommonsettings.cpp +++ b/src/libs/vmisc/vcommonsettings.cpp @@ -47,6 +47,26 @@ #include "../vmisc/compatibility.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 { 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, settingPatternLabelFontSize, (QLatin1String("pattern/labelFontSize"))) 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, 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, 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 qreal curveApproximationCached = -1; Q_GLOBAL_STATIC(QString, localeCached) qreal lineWidthCached = 0; int labelFontSizeCached = 0; 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) @@ -1219,3 +1253,118 @@ qreal VCommonSettings::WidthHairLine() const { 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(); +} diff --git a/src/libs/vmisc/vcommonsettings.h b/src/libs/vmisc/vcommonsettings.h index c8ff8bba9..710752a59 100644 --- a/src/libs/vmisc/vcommonsettings.h +++ b/src/libs/vmisc/vcommonsettings.h @@ -38,6 +38,8 @@ #include #include +#include "../vlayout/vbank.h" + class VCommonSettings : public QSettings { Q_OBJECT @@ -225,6 +227,52 @@ public: void SetLineWidth(qreal width); qreal WidthMainLine() 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 + static T GetCachedValue(const QSettings &settings, T &cache, const QString &setting, T defValue, T valueMin, + T valueMax); + + template + static T ValueOrDef(const QSettings &settings, const QString &setting, const T &defValue); + private: Q_DISABLE_COPY(VCommonSettings) }; @@ -247,4 +295,42 @@ inline qreal VCommonSettings::MaximalLineWidth() return 5.0; // mm } +//--------------------------------------------------------------------------------------------------------------------- +template +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 +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() ? val.value() : defValue; +} + +//--------------------------------------------------------------------------------------------------------------------- +template <> +inline Cases VCommonSettings::ValueOrDef(const QSettings &settings, const QString &setting, + const Cases &defValue) +{ + const QVariant val = settings.value(setting, QVariant::fromValue(static_cast(defValue))); + const int g = val.canConvert() ? val.value() : static_cast(defValue); + if (g < static_cast(Cases::CaseThreeGroup) || g >= static_cast(Cases::UnknownCase)) + { + return defValue; + } + else + { + return static_cast(g); + } +} + #endif // VCOMMONSETTINGS_H diff --git a/src/libs/vmisc/vmisc.pri b/src/libs/vmisc/vmisc.pri index c91baa68f..db111a201 100644 --- a/src/libs/vmisc/vmisc.pri +++ b/src/libs/vmisc/vmisc.pri @@ -3,18 +3,15 @@ SOURCES += \ $$PWD/def.cpp \ - $$PWD/vsettings.cpp \ $$PWD/vabstractapplication.cpp \ $$PWD/projectversion.cpp \ $$PWD/vcommonsettings.cpp \ - $$PWD/vtapesettings.cpp \ $$PWD/commandoptions.cpp \ $$PWD/qxtcsvmodel.cpp \ $$PWD/vtablesearch.cpp \ $$PWD/dialogs/dialogexporttocsv.cpp \ $$PWD/literals.cpp \ - $$PWD/vmodifierkey.cpp \ - $$PWD/vpuzzlesettings.cpp + $$PWD/vmodifierkey.cpp *msvc*:SOURCES += $$PWD/stable.cpp @@ -29,11 +26,9 @@ HEADERS += \ $$PWD/stable.h \ $$PWD/def.h \ $$PWD/vmath.h \ - $$PWD/vsettings.h \ $$PWD/vabstractapplication.h \ $$PWD/projectversion.h \ $$PWD/vcommonsettings.h \ - $$PWD/vtapesettings.h \ $$PWD/debugbreak.h \ $$PWD/vlockguard.h \ $$PWD/vsysexits.h \ @@ -51,8 +46,7 @@ HEADERS += \ $$PWD/vdatastreamenum.h \ $$PWD/vmodifierkey.h \ $$PWD/typedef.h \ - $$PWD/backport/qscopeguard.h \ - $$PWD/vpuzzlesettings.h + $$PWD/backport/qscopeguard.h contains(DEFINES, APPIMAGE) { SOURCES += \ diff --git a/src/libs/vmisc/vpuzzlesettings.cpp b/src/libs/vmisc/vpuzzlesettings.cpp deleted file mode 100644 index 337fcb69a..000000000 --- a/src/libs/vmisc/vpuzzlesettings.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/************************************************************************ - ** - ** @file vpuzzlesettings.cpp - ** @author Roman Telezhynskyi - ** @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 - ** 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 . - ** - *************************************************************************/ -#include "vpuzzlesettings.h" - - -//--------------------------------------------------------------------------------------------------------------------- -VPuzzleSettings::VPuzzleSettings(Format format, Scope scope, const QString &organization, const QString &application, - QObject *parent) - :VCommonSettings(format, scope, organization, application, parent) -{ - -} diff --git a/src/libs/vwidgets/vmaingraphicsview.cpp b/src/libs/vwidgets/vmaingraphicsview.cpp index 439f75140..6e903f4d2 100644 --- a/src/libs/vwidgets/vmaingraphicsview.cpp +++ b/src/libs/vwidgets/vmaingraphicsview.cpp @@ -56,7 +56,7 @@ #include "vsimplecurve.h" #include "vcontrolpointspline.h" #include "../vmisc/vabstractapplication.h" -#include "../vmisc/vsettings.h" +#include "../vmisc/vcommonsettings.h" #include "vabstractmainwindow.h" 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 numDegrees = wheel_event->angleDelta() / 8; qreal numSteps = 0; - VSettings *settings = qobject_cast(qApp->Settings()); + VCommonSettings *settings = qApp->Settings(); if (not numPixels.isNull()) { @@ -105,7 +105,7 @@ qreal PrepareScrolling(qreal scheduledScrollings, QWheelEvent *wheel_event) scheduledScrollings += numSteps; } - scheduledScrollings *= qobject_cast(qApp->Settings())->GetScrollingAcceleration(); + scheduledScrollings *= qApp->Settings()->GetScrollingAcceleration(); return scheduledScrollings; } @@ -197,7 +197,7 @@ void GraphicsViewZoom::set_zoom_factor_base(double value) //--------------------------------------------------------------------------------------------------------------------- void GraphicsViewZoom::InitScrollingAnimation() { - VSettings *settings = qobject_cast(qApp->Settings()); + VCommonSettings *settings = qApp->Settings(); if (not verticalScrollAnim.isNull()) { @@ -427,7 +427,7 @@ VMainGraphicsView::VMainGraphicsView(QWidget *parent) m_oldCursor(), m_currentCursor(Qt::ArrowCursor) { - VSettings *settings = qobject_cast(qApp->Settings()); + VCommonSettings *settings = qApp->Settings(); if (settings && settings->IsOpenGLRender()) { QOpenGLWidget *viewport = new QOpenGLWidget();