2021-05-21 16:17:22 +02:00
|
|
|
|
/************************************************************************
|
2015-07-15 09:16:59 +02:00
|
|
|
|
**
|
|
|
|
|
** @file vcommonsettings.h
|
|
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
|
|
|
|
** @date 15 7, 2015
|
|
|
|
|
**
|
|
|
|
|
** @brief
|
|
|
|
|
** @copyright
|
2017-10-05 11:20:01 +02:00
|
|
|
|
** This source code is part of the Valentina project, a pattern making
|
2015-07-15 09:16:59 +02:00
|
|
|
|
** program, whose allow create and modeling patterns of clothing.
|
|
|
|
|
** Copyright (C) 2015 Valentina project
|
2020-01-31 07:00:05 +01:00
|
|
|
|
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
|
2015-07-15 09:16:59 +02:00
|
|
|
|
**
|
|
|
|
|
** Valentina is free software: you can redistribute it and/or modify
|
|
|
|
|
** it under the terms of the GNU General Public License as published by
|
|
|
|
|
** the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
** (at your option) any later version.
|
|
|
|
|
**
|
|
|
|
|
** Valentina is distributed in the hope that it will be useful,
|
|
|
|
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
** GNU General Public License for more details.
|
|
|
|
|
**
|
|
|
|
|
** You should have received a copy of the GNU General Public License
|
|
|
|
|
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
**
|
|
|
|
|
*************************************************************************/
|
|
|
|
|
|
|
|
|
|
#ifndef VCOMMONSETTINGS_H
|
|
|
|
|
#define VCOMMONSETTINGS_H
|
|
|
|
|
|
2016-08-08 13:44:49 +02:00
|
|
|
|
#include <QByteArray>
|
|
|
|
|
#include <QMetaObject>
|
|
|
|
|
#include <QObject>
|
2015-07-15 09:16:59 +02:00
|
|
|
|
#include <QSettings>
|
2016-08-08 13:44:49 +02:00
|
|
|
|
#include <QSize>
|
|
|
|
|
#include <QString>
|
|
|
|
|
#include <QStringList>
|
|
|
|
|
#include <QtGlobal>
|
|
|
|
|
|
2020-12-23 14:29:55 +01:00
|
|
|
|
#include "../vmisc/def.h"
|
|
|
|
|
#include "../vlayout/vlayoutdef.h"
|
|
|
|
|
|
|
|
|
|
class QMarginsF;
|
2020-05-10 17:32:14 +02:00
|
|
|
|
|
2015-07-15 09:16:59 +02:00
|
|
|
|
class VCommonSettings : public QSettings
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
|
|
|
|
VCommonSettings(Format format, Scope scope, const QString &organization, const QString &application = QString(),
|
2016-10-30 13:34:55 +01:00
|
|
|
|
QObject *parent = nullptr);
|
2020-03-25 14:28:23 +01:00
|
|
|
|
VCommonSettings(const QString &fileName, Format format, QObject *parent = nullptr);
|
2015-07-15 09:16:59 +02:00
|
|
|
|
|
2016-10-30 13:34:55 +01:00
|
|
|
|
static QString SharePath(const QString &shareItem);
|
2017-07-12 20:21:48 +02:00
|
|
|
|
static QString MultisizeTablesPath();
|
2017-02-17 19:37:49 +01:00
|
|
|
|
static QString StandardTemplatesPath();
|
2017-09-12 10:50:23 +02:00
|
|
|
|
static QString LabelTemplatesPath();
|
2015-07-18 14:39:33 +02:00
|
|
|
|
|
2017-06-05 16:52:42 +02:00
|
|
|
|
static QString PrepareStandardTemplates(const QString ¤tPath);
|
2017-07-12 20:21:48 +02:00
|
|
|
|
static QString PrepareMultisizeTables(const QString ¤tPath);
|
2017-09-12 10:50:23 +02:00
|
|
|
|
static QString PrepareLabelTemplates(const QString ¤tPath);
|
2017-02-17 19:37:49 +01:00
|
|
|
|
|
|
|
|
|
static QString GetDefPathIndividualMeasurements();
|
2015-07-18 14:39:33 +02:00
|
|
|
|
QString GetPathIndividualMeasurements() const;
|
|
|
|
|
void SetPathIndividualMeasurements(const QString &value);
|
|
|
|
|
|
2017-07-12 20:21:48 +02:00
|
|
|
|
static QString GetDefPathMultisizeMeasurements();
|
|
|
|
|
QString GetPathMultisizeMeasurements() const;
|
|
|
|
|
void SetPathMultisizeMeasurements(const QString &value);
|
2015-07-18 14:39:33 +02:00
|
|
|
|
|
2019-01-06 01:46:31 +01:00
|
|
|
|
static QString GetDefPathPattern();
|
|
|
|
|
QString GetPathPattern() const;
|
|
|
|
|
void SetPathPattern(const QString &value);
|
|
|
|
|
|
2017-02-17 19:37:49 +01:00
|
|
|
|
static QString GetDefPathTemplate();
|
2015-10-18 12:01:38 +02:00
|
|
|
|
QString GetPathTemplate() const;
|
|
|
|
|
void SetPathTemplate(const QString &value);
|
2017-08-10 13:51:17 +02:00
|
|
|
|
|
|
|
|
|
static QString GetDefPathLabelTemplate();
|
|
|
|
|
QString GetPathLabelTemplate() const;
|
|
|
|
|
void SetPathLabelTemplate(const QString &value);
|
2015-10-18 12:01:38 +02:00
|
|
|
|
|
2020-04-21 17:57:11 +02:00
|
|
|
|
static QString GetDefPathManualLayouts();
|
|
|
|
|
QString GetPathManualLayouts() const;
|
|
|
|
|
void SetPathManualLayouts(const QString &value);
|
|
|
|
|
|
2015-07-15 09:16:59 +02:00
|
|
|
|
bool GetOsSeparator() const;
|
|
|
|
|
void SetOsSeparator(const bool &value);
|
|
|
|
|
|
|
|
|
|
bool GetAutosaveState() const;
|
|
|
|
|
void SetAutosaveState(const bool &value);
|
|
|
|
|
|
|
|
|
|
int GetAutosaveTime() const;
|
|
|
|
|
void SetAutosaveTime(const int &value);
|
|
|
|
|
|
|
|
|
|
QString GetLocale() const;
|
|
|
|
|
void SetLocale(const QString &value);
|
|
|
|
|
|
2015-08-02 17:27:18 +02:00
|
|
|
|
QString GetPMSystemCode() const;
|
|
|
|
|
void SetPMSystemCode(const QString &value);
|
|
|
|
|
|
2015-07-15 09:16:59 +02:00
|
|
|
|
QString GetUnit() const;
|
|
|
|
|
void SetUnit(const QString &value);
|
|
|
|
|
|
|
|
|
|
bool GetConfirmItemDelete() const;
|
|
|
|
|
void SetConfirmItemDelete(const bool &value);
|
|
|
|
|
|
2017-04-12 08:49:05 +02:00
|
|
|
|
bool GetConfirmFormatRewriting() const;
|
|
|
|
|
void SetConfirmFormatRewriting(const bool &value);
|
|
|
|
|
|
2015-07-15 09:16:59 +02:00
|
|
|
|
bool GetToolBarStyle() const;
|
|
|
|
|
void SetToolBarStyle(const bool &value);
|
|
|
|
|
|
2018-10-29 13:05:49 +01:00
|
|
|
|
bool GetDarkMode() const;
|
|
|
|
|
void SetDarkMode(const bool &value);
|
|
|
|
|
|
2017-10-03 12:01:56 +02:00
|
|
|
|
bool IsFreeCurveMode() const;
|
|
|
|
|
void SetFreeCurveMode(bool value);
|
|
|
|
|
|
2018-05-10 13:12:41 +02:00
|
|
|
|
bool IsDoubleClickZoomFitBestCurrentPP() const;
|
|
|
|
|
void SetDoubleClickZoomFitBestCurrentPP(bool value);
|
|
|
|
|
|
2015-07-15 09:16:59 +02:00
|
|
|
|
int GetUndoCount() const;
|
|
|
|
|
void SetUndoCount(const int &value);
|
|
|
|
|
|
|
|
|
|
QStringList GetRecentFileList() const;
|
|
|
|
|
void SetRecentFileList(const QStringList &value);
|
|
|
|
|
|
|
|
|
|
QStringList GetRestoreFileList() const;
|
|
|
|
|
void SetRestoreFileList(const QStringList &value);
|
|
|
|
|
|
|
|
|
|
QByteArray GetGeometry() const;
|
|
|
|
|
void SetGeometry(const QByteArray &value);
|
|
|
|
|
|
|
|
|
|
QByteArray GetWindowState() const;
|
|
|
|
|
void SetWindowState(const QByteArray &value);
|
|
|
|
|
|
|
|
|
|
QByteArray GetToolbarsState() const;
|
|
|
|
|
void SetToolbarsState(const QByteArray &value);
|
|
|
|
|
|
2016-07-15 11:00:00 +02:00
|
|
|
|
QSize GetPreferenceDialogSize() const;
|
|
|
|
|
void SetPreferenceDialogSize(const QSize& sz);
|
|
|
|
|
|
2017-05-30 10:47:27 +02:00
|
|
|
|
QSize GetToolSeamAllowanceDialogSize() const;
|
|
|
|
|
void SetToolSeamAllowanceDialogSize(const QSize& sz);
|
|
|
|
|
|
2017-06-16 16:05:35 +02:00
|
|
|
|
QSize GetFormulaWizardDialogSize() const;
|
|
|
|
|
void SetFormulaWizardDialogSize(const QSize& sz);
|
|
|
|
|
|
2017-07-26 08:13:29 +02:00
|
|
|
|
QSize GetIncrementsDialogSize() const;
|
|
|
|
|
void SetIncrementsDialogSize(const QSize& sz);
|
|
|
|
|
|
2017-09-26 16:24:02 +02:00
|
|
|
|
QSize GetFinalMeasurementsDialogSize() const;
|
|
|
|
|
void SetFinalMeasurementsDialogSize(const QSize& sz);
|
|
|
|
|
|
2016-07-15 11:00:00 +02:00
|
|
|
|
int GetLatestSkippedVersion() const;
|
|
|
|
|
void SetLatestSkippedVersion(int value);
|
2016-06-10 21:34:21 +02:00
|
|
|
|
|
2016-07-15 11:30:55 +02:00
|
|
|
|
QDate GetDateOfLastRemind() const;
|
|
|
|
|
void SetDateOfLastRemind(const QDate &date);
|
|
|
|
|
|
2016-09-06 16:05:54 +02:00
|
|
|
|
bool GetForbidWorkpieceFlipping() const;
|
|
|
|
|
void SetForbidWorkpieceFlipping(bool value);
|
|
|
|
|
|
2017-12-17 14:06:46 +01:00
|
|
|
|
bool GetForceWorkpieceFlipping() const;
|
|
|
|
|
void SetForceWorkpieceFlipping(bool value);
|
|
|
|
|
|
2017-05-16 14:16:50 +02:00
|
|
|
|
bool IsHideMainPath() const;
|
|
|
|
|
void SetHideMainPath(bool value);
|
|
|
|
|
|
2017-04-05 12:22:33 +02:00
|
|
|
|
bool IsDoublePassmark() const;
|
|
|
|
|
void SetDoublePassmark(bool value);
|
|
|
|
|
|
2017-05-12 14:09:19 +02:00
|
|
|
|
void SetCSVWithHeader(bool withHeader);
|
|
|
|
|
bool GetCSVWithHeader() const;
|
2017-09-27 12:25:18 +02:00
|
|
|
|
static bool GetDefCSVWithHeader();
|
2017-05-12 14:09:19 +02:00
|
|
|
|
|
|
|
|
|
void SetCSVCodec(int mib);
|
|
|
|
|
int GetCSVCodec() const;
|
2017-09-27 12:25:18 +02:00
|
|
|
|
static int GetDefCSVCodec();
|
2017-05-12 14:09:19 +02:00
|
|
|
|
|
|
|
|
|
void SetCSVSeparator(const QChar &separator);
|
|
|
|
|
QChar GetCSVSeparator() const;
|
2017-09-27 12:25:18 +02:00
|
|
|
|
static QChar GetDefCSVSeparator();
|
2017-05-12 14:09:19 +02:00
|
|
|
|
|
2017-07-02 10:14:01 +02:00
|
|
|
|
void SetDefaultSeamAllowance(double value);
|
|
|
|
|
double GetDefaultSeamAllowance();
|
|
|
|
|
|
2017-07-01 13:41:46 +02:00
|
|
|
|
QFont GetLabelFont() const;
|
|
|
|
|
void SetLabelFont(const QFont &f);
|
2017-07-02 10:14:01 +02:00
|
|
|
|
|
2019-05-08 18:22:55 +02:00
|
|
|
|
int GetLabelFontSize() const;
|
|
|
|
|
void SetLabelFontSize(int size);
|
|
|
|
|
static int GetDefLabelFontSize();
|
|
|
|
|
|
|
|
|
|
bool GetHideLabels() const;
|
|
|
|
|
void SetHideLabels(bool value);
|
|
|
|
|
|
2017-02-17 19:54:16 +01:00
|
|
|
|
#if !defined(Q_OS_WIN)
|
|
|
|
|
static const QString unixStandardSharePath;
|
|
|
|
|
#endif
|
|
|
|
|
|
2017-08-19 18:10:57 +02:00
|
|
|
|
QString GetLabelDateFormat() const;
|
|
|
|
|
void SetLabelDateFormat(const QString &format);
|
|
|
|
|
|
|
|
|
|
static QStringList PredefinedDateFormats();
|
|
|
|
|
QStringList GetUserDefinedDateFormats() const;
|
|
|
|
|
void SetUserDefinedDateFormats(const QStringList &formats);
|
|
|
|
|
|
|
|
|
|
QString GetLabelTimeFormat() const;
|
|
|
|
|
void SetLabelTimeFormat(const QString &format);
|
|
|
|
|
|
|
|
|
|
static QStringList PredefinedTimeFormats();
|
|
|
|
|
QStringList GetUserDefinedTimeFormats() const;
|
|
|
|
|
void SetUserDefinedTimeFormats(const QStringList &formats);
|
|
|
|
|
|
2017-10-11 12:51:06 +02:00
|
|
|
|
qreal GetCurveApproximationScale() const;
|
|
|
|
|
void SetCurveApproximationScale(qreal value);
|
|
|
|
|
|
2017-10-29 14:13:13 +01:00
|
|
|
|
bool IsShowCurveDetails() const;
|
|
|
|
|
void SetShowCurveDetails(bool value);
|
2018-02-06 18:30:27 +01:00
|
|
|
|
|
2019-07-23 15:01:39 +02:00
|
|
|
|
bool IsPieceShowMainPath() const;
|
|
|
|
|
void SetPieceShowMainPath(bool value);
|
2019-07-18 19:18:48 +02:00
|
|
|
|
|
2020-12-17 17:43:15 +01:00
|
|
|
|
bool IsDontUseNativeDialog() const;
|
|
|
|
|
void SetDontUseNativeDialog(bool value);
|
|
|
|
|
|
2018-02-06 18:30:27 +01:00
|
|
|
|
static qreal DefaultLineWidth();
|
|
|
|
|
static qreal MinimalLineWidth();
|
|
|
|
|
static qreal MaximalLineWidth();
|
|
|
|
|
qreal GetLineWidth() const;
|
|
|
|
|
void SetLineWidth(qreal width);
|
|
|
|
|
qreal WidthMainLine() const;
|
|
|
|
|
qreal WidthHairLine() const;
|
2020-05-10 17:32:14 +02:00
|
|
|
|
|
2020-12-23 14:29:55 +01:00
|
|
|
|
// settings for the tiled PDFs
|
2020-12-23 17:40:33 +01:00
|
|
|
|
auto GetTiledPDFMargins(const Unit &unit) const -> QMarginsF;
|
|
|
|
|
void SetTiledPDFMargins(const QMarginsF &value, const Unit &unit);
|
|
|
|
|
|
|
|
|
|
auto GetTiledPDFOrientation() const -> PageOrientation;
|
|
|
|
|
void SetTiledPDFOrientation(PageOrientation value);
|
|
|
|
|
|
2020-05-10 17:32:14 +02:00
|
|
|
|
static const int defaultScrollingDuration;
|
|
|
|
|
static const int scrollingDurationMin;
|
|
|
|
|
static const int scrollingDurationMax;
|
|
|
|
|
int GetScrollingDuration() const;
|
|
|
|
|
void SetScrollingDuration(int duration);
|
|
|
|
|
|
|
|
|
|
static const int defaultScrollingUpdateInterval;
|
|
|
|
|
static const int scrollingUpdateIntervalMin;
|
|
|
|
|
static const int scrollingUpdateIntervalMax;
|
|
|
|
|
int GetScrollingUpdateInterval() const;
|
|
|
|
|
void SetScrollingUpdateInterval(int updateInterval);
|
|
|
|
|
|
|
|
|
|
static const qreal defaultSensorMouseScale;
|
|
|
|
|
static const qreal sensorMouseScaleMin;
|
|
|
|
|
static const qreal sensorMouseScaleMax;
|
|
|
|
|
qreal GetSensorMouseScale() const;
|
|
|
|
|
void SetSensorMouseScale(qreal scale);
|
|
|
|
|
|
|
|
|
|
static const qreal defaultWheelMouseScale;
|
|
|
|
|
static const qreal wheelMouseScaleMin;
|
|
|
|
|
static const qreal wheelMouseScaleMax;
|
|
|
|
|
qreal GetWheelMouseScale() const;
|
|
|
|
|
void SetWheelMouseScale(qreal scale);
|
|
|
|
|
|
|
|
|
|
static const qreal defaultScrollingAcceleration;
|
|
|
|
|
static const qreal scrollingAccelerationMin;
|
|
|
|
|
static const qreal scrollingAccelerationMax;
|
|
|
|
|
qreal GetScrollingAcceleration() const;
|
|
|
|
|
void SetScrollingAcceleration(qreal acceleration);
|
|
|
|
|
|
|
|
|
|
bool IsOpenGLRender() const;
|
|
|
|
|
void SetOpenGLRender(bool value);
|
|
|
|
|
|
|
|
|
|
bool GetGraphicalOutput() const;
|
|
|
|
|
void SetGraphicalOutput(const bool &value);
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
|
static T GetCachedValue(const QSettings &settings, T &cache, const QString &setting, T defValue, T valueMin,
|
|
|
|
|
T valueMax);
|
|
|
|
|
|
|
|
|
|
template <class T>
|
|
|
|
|
static T ValueOrDef(const QSettings &settings, const QString &setting, const T &defValue);
|
|
|
|
|
|
2015-07-15 09:16:59 +02:00
|
|
|
|
private:
|
|
|
|
|
Q_DISABLE_COPY(VCommonSettings)
|
|
|
|
|
};
|
|
|
|
|
|
2018-02-06 18:30:27 +01:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
inline qreal VCommonSettings::DefaultLineWidth()
|
|
|
|
|
{
|
|
|
|
|
return 1.2; // mm
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
inline qreal VCommonSettings::MinimalLineWidth()
|
|
|
|
|
{
|
|
|
|
|
return 0.5; // mm
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
inline qreal VCommonSettings::MaximalLineWidth()
|
|
|
|
|
{
|
|
|
|
|
return 5.0; // mm
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-10 17:32:14 +02:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
template<typename T>
|
|
|
|
|
T VCommonSettings::GetCachedValue(const QSettings &settings, T &cache, const QString &setting, T defValue, T valueMin,
|
|
|
|
|
T valueMax)
|
|
|
|
|
{
|
|
|
|
|
if (cache < 0)
|
|
|
|
|
{
|
|
|
|
|
cache = qBound(valueMin, ValueOrDef(settings, setting, defValue), valueMax);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return cache;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
template <class T>
|
|
|
|
|
inline T VCommonSettings::ValueOrDef(const QSettings &settings, const QString &setting, const T &defValue)
|
|
|
|
|
{
|
|
|
|
|
const QVariant val = settings.value(setting, QVariant::fromValue(defValue));
|
|
|
|
|
return val.canConvert<T>() ? val.value<T>() : defValue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
template <>
|
|
|
|
|
inline Cases VCommonSettings::ValueOrDef<Cases>(const QSettings &settings, const QString &setting,
|
|
|
|
|
const Cases &defValue)
|
|
|
|
|
{
|
|
|
|
|
const QVariant val = settings.value(setting, QVariant::fromValue(static_cast<int>(defValue)));
|
|
|
|
|
const int g = val.canConvert<int>() ? val.value<int>() : static_cast<int>(defValue);
|
|
|
|
|
if (g < static_cast<int>(Cases::CaseThreeGroup) || g >= static_cast<int>(Cases::UnknownCase))
|
|
|
|
|
{
|
|
|
|
|
return defValue;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return static_cast<Cases>(g);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-15 09:16:59 +02:00
|
|
|
|
#endif // VCOMMONSETTINGS_H
|