2015-07-15 09:16:59 +02:00
|
|
|
/************************************************************************
|
|
|
|
**
|
|
|
|
** @file vcommonsettings.cpp
|
|
|
|
** @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
|
|
|
|
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
|
|
|
**
|
|
|
|
** Valentina is free software: you can redistribute it and/or modify
|
|
|
|
** it under the terms of the GNU General Public License as published by
|
|
|
|
** the Free Software Foundation, either version 3 of the License, or
|
|
|
|
** (at your option) any later version.
|
|
|
|
**
|
|
|
|
** Valentina is distributed in the hope that it will be useful,
|
|
|
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
** GNU General Public License for more details.
|
|
|
|
**
|
|
|
|
** You should have received a copy of the GNU General Public License
|
|
|
|
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
**
|
|
|
|
*************************************************************************/
|
|
|
|
|
|
|
|
#include "vcommonsettings.h"
|
|
|
|
|
|
|
|
#include <QApplication>
|
2016-07-15 11:30:55 +02:00
|
|
|
#include <QDate>
|
2016-08-08 13:44:49 +02:00
|
|
|
#include <QDir>
|
|
|
|
#include <QLocale>
|
|
|
|
#include <QMessageLogger>
|
|
|
|
#include <QStaticStringData>
|
|
|
|
#include <QStringData>
|
|
|
|
#include <QStringDataPtr>
|
|
|
|
#include <QVariant>
|
|
|
|
#include <QtDebug>
|
2017-05-12 14:09:19 +02:00
|
|
|
#include <QTextCodec>
|
2017-07-01 13:41:46 +02:00
|
|
|
#include <QFont>
|
2018-03-14 14:39:15 +01:00
|
|
|
#include <QGlobalStatic>
|
2016-08-08 13:44:49 +02:00
|
|
|
|
2016-08-09 15:55:46 +02:00
|
|
|
#include "../vmisc/def.h"
|
2016-08-16 18:57:32 +02:00
|
|
|
#include "../vmisc/vmath.h"
|
2017-06-01 12:04:25 +02:00
|
|
|
#include "../vpatterndb/pmsystems.h"
|
2015-07-15 09:16:59 +02:00
|
|
|
|
2017-08-19 18:10:57 +02:00
|
|
|
namespace
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsIndividualMeasurements, (QLatin1String("paths/individual_measurements")))
|
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsMultisizeMeasurements, (QLatin1String("paths/standard_measurements")))
|
2019-01-06 01:46:31 +01:00
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsPattern, (QLatin1String("paths/pattern")))
|
2018-03-14 14:39:15 +01:00
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsTemplates, (QLatin1String("paths/templates")))
|
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsLabelTemplate, (QLatin1String("paths/labels")))
|
|
|
|
|
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationOsSeparator, (QLatin1String("configuration/osSeparator")))
|
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationAutosaveState, (QLatin1String("configuration/autosave/state")))
|
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationAutosaveTime , (QLatin1String("configuration/autosave/time")))
|
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationLocale, (QLatin1String("configuration/locale")))
|
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPMSystemCode, (QLatin1String("configuration/pmscode")))
|
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationUnit, (QLatin1String("configuration/unit")))
|
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationConfirmItemDeletion, (QLatin1String("configuration/confirm_item_deletion")))
|
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationConfirmFormatRewriting, (QLatin1String("configuration/confirm_format_rewriting")))
|
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationToolBarStyle, (QLatin1String("configuration/tool_bar_style")))
|
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationFreeCurveMode, (QLatin1String("configuration/freeCurveMode")))
|
2018-05-10 13:12:41 +02:00
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationDoubleClickZoomFitBestCurrentPP, (QLatin1String("configuration/doubleClickZoomFitBestCurrentPP")))
|
2018-03-14 14:39:15 +01:00
|
|
|
|
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternUndo, (QLatin1String("pattern/undo")))
|
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternForbidFlipping, (QLatin1String("pattern/forbidFlipping")))
|
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternForceFlipping, (QLatin1String("pattern/forceFlipping")))
|
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternHideMainPath, (QLatin1String("pattern/hideMainPath")))
|
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDoublePassmark, (QLatin1String("pattern/doublePassmark")))
|
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternDefaultSeamAllowance, (QLatin1String("pattern/defaultSeamAllowance")))
|
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternLabelFont, (QLatin1String("pattern/labelFont")))
|
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternLineWidth, (QLatin1String("pattern/lineWidth")))
|
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternCurveApproximationScale, (QLatin1String("pattern/curveApproximationScale")))
|
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternShowCurveDetails, (QLatin1String("pattern/showCurveDetails")))
|
2019-05-08 18:22:55 +02:00
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternLabelFontSize, (QLatin1String("pattern/labelFontSize")))
|
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternHideLabels, (QLatin1String("pattern/hideLabels")))
|
2018-03-14 14:39:15 +01:00
|
|
|
|
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingGeneralRecentFileList, (QLatin1String("recentFileList")))
|
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingGeneralRestoreFileList, (QLatin1String("restoreFileList")))
|
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingGeneralGeometry, (QLatin1String("geometry")))
|
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingGeneralWindowState, (QLatin1String("windowState")))
|
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingGeneralToolbarsState, (QLatin1String("toolbarsState")))
|
2018-10-29 13:05:49 +01:00
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationDarkMode, (QLatin1String("configuration/dark_mode")))
|
2018-03-14 14:39:15 +01:00
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPreferenceDialogSize, (QLatin1String("preferenceDialogSize")))
|
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingToolSeamAllowanceDialogSize, (QLatin1String("toolSeamAllowanceDialogSize")))
|
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingIncrementsDialogSize, (QLatin1String("toolIncrementsDialogSize")))
|
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingFormulaWizardDialogSize, (QLatin1String("formulaWizardDialogSize")))
|
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingFinalMeasurementsDialogSize, (QLatin1String("finalMeasurementsDialogSize")))
|
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLatestSkippedVersion, (QLatin1String("lastestSkippedVersion")))
|
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDateOfLastRemind, (QLatin1String("dateOfLastRemind")))
|
|
|
|
|
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingCSVWithHeader, (QLatin1String("csv/withHeader")))
|
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingCSVCodec, (QLatin1String("csv/withCodec")))
|
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingCSVSeparator, (QLatin1String("csv/withSeparator")))
|
|
|
|
|
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLabelDateFormat, (QLatin1String("label/dateFormat")))
|
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLabelUserDateFormats, (QLatin1String("label/userDateFormats")))
|
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLabelTimeFormat, (QLatin1String("label/timeFormat")))
|
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLabelUserTimeFormats, (QLatin1String("label/userTimeFormats")))
|
2017-08-19 18:10:57 +02:00
|
|
|
|
2018-01-20 11:35:43 +01:00
|
|
|
// Reading settings file is very expensive, cache curve approximation to speed up getting value
|
|
|
|
qreal curveApproximationCached = -1;
|
2018-03-14 14:39:15 +01:00
|
|
|
Q_GLOBAL_STATIC(QString, localeCached)
|
2018-02-06 18:30:27 +01:00
|
|
|
qreal lineWidthCached = 0;
|
2019-05-08 18:22:55 +02:00
|
|
|
int labelFontSizeCached = 0;
|
2018-01-20 11:35:43 +01:00
|
|
|
|
2017-08-19 18:10:57 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QStringList ClearFormats(const QStringList &predefinedFormats, QStringList formats)
|
|
|
|
{
|
2018-04-03 13:36:38 +02:00
|
|
|
for (auto &f : predefinedFormats)
|
2017-08-19 18:10:57 +02:00
|
|
|
{
|
2018-04-03 13:36:38 +02:00
|
|
|
formats.removeAll(f);
|
2017-08-19 18:10:57 +02:00
|
|
|
}
|
|
|
|
return formats;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-14 14:39:15 +01:00
|
|
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, commonIniFilename, (QLatin1String("common")))
|
2016-06-10 16:48:30 +02:00
|
|
|
|
2017-02-17 19:54:16 +01:00
|
|
|
#if !defined(Q_OS_WIN)
|
|
|
|
const QString VCommonSettings::unixStandardSharePath = QStringLiteral("/usr/share/valentina");
|
|
|
|
#endif
|
|
|
|
|
2017-02-17 19:37:49 +01:00
|
|
|
namespace
|
|
|
|
{
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2017-06-05 15:18:38 +02:00
|
|
|
void SymlinkCopyDirRecursive(const QString &fromDir, const QString &toDir, bool replaceOnConflit)
|
2017-02-17 19:37:49 +01:00
|
|
|
{
|
|
|
|
QDir dir;
|
|
|
|
dir.setPath(fromDir);
|
|
|
|
|
2018-03-14 14:39:15 +01:00
|
|
|
const QStringList list = dir.entryList(QDir::Files);
|
|
|
|
for (const QString ©File : list)
|
2017-02-17 19:37:49 +01:00
|
|
|
{
|
|
|
|
const QString from = fromDir + QDir::separator() + copyFile;
|
2017-06-05 15:18:38 +02:00
|
|
|
QString to = toDir + QDir::separator() + copyFile;
|
2017-02-17 19:37:49 +01:00
|
|
|
|
2017-06-05 15:18:38 +02:00
|
|
|
#ifdef Q_OS_WIN
|
2017-02-17 19:37:49 +01:00
|
|
|
{
|
2017-06-05 15:18:38 +02:00
|
|
|
// To fix issue #702 check each not symlink if it is actually broken symlink.
|
|
|
|
// Also trying to mimic Unix symlink. If a file eaxists do not create a symlink and remove it if exists.
|
|
|
|
QFile fileTo(to);
|
|
|
|
if (fileTo.exists())
|
2017-02-17 19:37:49 +01:00
|
|
|
{
|
2017-06-05 15:18:38 +02:00
|
|
|
if (not fileTo.rename(to + QLatin1String(".lnk")))
|
|
|
|
{
|
|
|
|
QFile::remove(to + QLatin1String(".lnk"));
|
|
|
|
fileTo.rename(to + QLatin1String(".lnk"));
|
|
|
|
}
|
|
|
|
|
|
|
|
QFileInfo info(to + QLatin1String(".lnk"));
|
|
|
|
if (info.symLinkTarget().isEmpty())
|
2017-02-17 19:37:49 +01:00
|
|
|
{
|
2017-06-05 15:18:38 +02:00
|
|
|
fileTo.copy(to);
|
|
|
|
fileTo.remove();
|
|
|
|
continue; // The file already exists, skip creating shortcut
|
2017-02-17 19:37:49 +01:00
|
|
|
}
|
|
|
|
}
|
2017-06-05 15:18:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
to = to + QLatin1String(".lnk");
|
|
|
|
#endif
|
|
|
|
|
2017-11-29 16:03:42 +01:00
|
|
|
QFileInfo fileTo(to);
|
|
|
|
if (not fileTo.isSymLink() && fileTo.exists())
|
2017-06-05 15:18:38 +02:00
|
|
|
{
|
|
|
|
if (replaceOnConflit)
|
|
|
|
{
|
|
|
|
QFile::remove(to);
|
|
|
|
}
|
2017-02-17 19:37:49 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
continue;
|
2017-11-29 16:03:42 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (fileTo.isSymLink())
|
|
|
|
{
|
|
|
|
if (not fileTo.exists())
|
|
|
|
{ // automatically fix broken symlink
|
|
|
|
QFile::remove(to);
|
|
|
|
}
|
|
|
|
else if (replaceOnConflit)
|
|
|
|
{
|
|
|
|
QFile::remove(to);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
continue;
|
2017-02-17 19:37:49 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-05 15:18:38 +02:00
|
|
|
QFile::link(from, to);
|
2017-02-17 19:37:49 +01:00
|
|
|
}
|
|
|
|
|
2018-03-14 14:39:15 +01:00
|
|
|
const QStringList dirList = dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot);
|
|
|
|
for (const QString ©Dir : dirList)
|
2017-02-17 19:37:49 +01:00
|
|
|
{
|
|
|
|
const QString from = fromDir + QDir::separator() + copyDir;
|
|
|
|
const QString to = toDir + QDir::separator() + copyDir;
|
|
|
|
|
|
|
|
if (dir.mkpath(to) == false)
|
|
|
|
{
|
2017-06-05 15:18:38 +02:00
|
|
|
return;
|
2017-02-17 19:37:49 +01:00
|
|
|
}
|
|
|
|
|
2017-06-05 15:18:38 +02:00
|
|
|
SymlinkCopyDirRecursive(from, to, replaceOnConflit);
|
2017-02-17 19:37:49 +01:00
|
|
|
}
|
|
|
|
}
|
2017-06-05 16:52:42 +02:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QString PrepareStandardFiles(const QString ¤tPath, const QString &standardPath, const QString &defPath)
|
|
|
|
{
|
|
|
|
QDir standardPathDir(standardPath);
|
|
|
|
QDir currentPathDir(currentPath);
|
|
|
|
if ((currentPath == defPath || not currentPathDir.exists()) && standardPathDir.exists())
|
|
|
|
{
|
|
|
|
const QDir localdata (defPath);
|
2018-04-13 08:14:55 +02:00
|
|
|
if (localdata.mkpath(QChar('.')))
|
2017-06-05 16:52:42 +02:00
|
|
|
{
|
|
|
|
SymlinkCopyDirRecursive(standardPath, defPath, false);
|
|
|
|
}
|
|
|
|
return defPath;
|
|
|
|
}
|
|
|
|
return currentPath;
|
|
|
|
}
|
2017-02-17 19:37:49 +01:00
|
|
|
}
|
2016-10-30 13:34:55 +01:00
|
|
|
|
2015-07-15 09:16:59 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-10-18 11:56:47 +02:00
|
|
|
VCommonSettings::VCommonSettings(Format format, Scope scope, const QString &organization,
|
|
|
|
const QString &application, QObject *parent)
|
2015-10-18 13:51:14 +02:00
|
|
|
:QSettings(format, scope, organization, application, parent)
|
2015-07-15 09:16:59 +02:00
|
|
|
{}
|
|
|
|
|
2015-11-18 13:42:25 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2016-10-30 13:34:55 +01:00
|
|
|
QString VCommonSettings::SharePath(const QString &shareItem)
|
2015-11-18 13:42:25 +01:00
|
|
|
{
|
|
|
|
#ifdef Q_OS_WIN
|
2017-07-09 08:02:26 +02:00
|
|
|
return QCoreApplication::applicationDirPath() + shareItem;
|
2015-11-18 13:42:25 +01:00
|
|
|
#elif defined(Q_OS_MAC)
|
2017-07-09 08:02:26 +02:00
|
|
|
QDir dirBundle(QCoreApplication::applicationDirPath() + QStringLiteral("/../Resources") + shareItem);
|
2015-11-18 13:42:25 +01:00
|
|
|
if (dirBundle.exists())
|
|
|
|
{
|
|
|
|
return dirBundle.absolutePath();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-10-25 16:54:51 +02:00
|
|
|
QDir appDir = QDir(qApp->applicationDirPath());
|
|
|
|
appDir.cdUp();
|
|
|
|
appDir.cdUp();
|
|
|
|
appDir.cdUp();
|
2016-10-30 13:34:55 +01:00
|
|
|
QDir dir(appDir.absolutePath() + shareItem);
|
2015-11-18 13:42:25 +01:00
|
|
|
if (dir.exists())
|
|
|
|
{
|
|
|
|
return dir.absolutePath();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-02-04 12:28:47 +01:00
|
|
|
return VCommonSettings::unixStandardSharePath + shareItem;
|
2015-11-18 13:42:25 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#else // Unix
|
2016-10-30 13:34:55 +01:00
|
|
|
#ifdef QT_DEBUG
|
2017-07-09 08:02:26 +02:00
|
|
|
return QCoreApplication::applicationDirPath() + shareItem;
|
2016-10-30 13:34:55 +01:00
|
|
|
#else
|
2017-07-09 08:02:26 +02:00
|
|
|
QDir dir(QCoreApplication::applicationDirPath() + shareItem);
|
2016-10-30 13:34:55 +01:00
|
|
|
if (dir.exists())
|
|
|
|
{
|
|
|
|
return dir.absolutePath();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-02-04 12:28:47 +01:00
|
|
|
return VCommonSettings::unixStandardSharePath + shareItem;
|
2016-10-30 13:34:55 +01:00
|
|
|
}
|
|
|
|
#endif
|
2015-11-18 13:42:25 +01:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2016-10-30 13:34:55 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2017-07-12 20:21:48 +02:00
|
|
|
QString VCommonSettings::MultisizeTablesPath()
|
2016-10-30 13:34:55 +01:00
|
|
|
{
|
2017-07-12 20:21:48 +02:00
|
|
|
return SharePath(QStringLiteral("/tables/multisize"));
|
2016-10-30 13:34:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2017-02-17 19:37:49 +01:00
|
|
|
QString VCommonSettings::StandardTemplatesPath()
|
2016-10-30 13:34:55 +01:00
|
|
|
{
|
|
|
|
return SharePath(QStringLiteral("/tables/templates"));
|
|
|
|
}
|
|
|
|
|
2017-09-12 10:50:23 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QString VCommonSettings::LabelTemplatesPath()
|
|
|
|
{
|
|
|
|
return SharePath(QStringLiteral("/labels"));
|
|
|
|
}
|
|
|
|
|
2017-02-17 19:37:49 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2017-06-05 16:52:42 +02:00
|
|
|
QString VCommonSettings::PrepareStandardTemplates(const QString & currentPath)
|
2017-02-17 19:37:49 +01:00
|
|
|
{
|
2017-06-05 16:52:42 +02:00
|
|
|
return PrepareStandardFiles(currentPath, StandardTemplatesPath(), GetDefPathTemplate());
|
2017-02-17 19:37:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2017-07-12 20:21:48 +02:00
|
|
|
QString VCommonSettings::PrepareMultisizeTables(const QString ¤tPath)
|
2017-02-17 19:37:49 +01:00
|
|
|
{
|
2017-07-12 20:21:48 +02:00
|
|
|
return PrepareStandardFiles(currentPath, MultisizeTablesPath(), GetDefPathMultisizeMeasurements());
|
2017-02-17 19:37:49 +01:00
|
|
|
}
|
|
|
|
|
2017-09-12 10:50:23 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QString VCommonSettings::PrepareLabelTemplates(const QString ¤tPath)
|
|
|
|
{
|
|
|
|
return PrepareStandardFiles(currentPath, LabelTemplatesPath(), GetDefPathLabelTemplate());
|
|
|
|
}
|
|
|
|
|
2017-02-17 19:37:49 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QString VCommonSettings::GetDefPathIndividualMeasurements()
|
|
|
|
{
|
|
|
|
return QDir::homePath() + QLatin1String("/valentina/") + tr("measurements") + QLatin1String("/") + tr("individual");
|
|
|
|
}
|
|
|
|
|
2015-07-18 14:39:33 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QString VCommonSettings::GetPathIndividualMeasurements() const
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename);
|
|
|
|
return settings.value(*settingPathsIndividualMeasurements, GetDefPathIndividualMeasurements()).toString();
|
2015-07-18 14:39:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetPathIndividualMeasurements(const QString &value)
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename);
|
|
|
|
settings.setValue(*settingPathsIndividualMeasurements, value);
|
2015-10-18 14:38:05 +02:00
|
|
|
settings.sync();
|
2015-07-18 14:39:33 +02:00
|
|
|
}
|
|
|
|
|
2017-02-17 19:37:49 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2017-07-12 20:21:48 +02:00
|
|
|
QString VCommonSettings::GetDefPathMultisizeMeasurements()
|
2017-02-17 19:37:49 +01:00
|
|
|
{
|
|
|
|
return QDir::homePath() + QLatin1String("/valentina/") + tr("measurements") + QLatin1String("/") + tr("multisize");
|
|
|
|
}
|
|
|
|
|
2015-07-18 14:39:33 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2017-07-12 20:21:48 +02:00
|
|
|
QString VCommonSettings::GetPathMultisizeMeasurements() const
|
2015-07-18 14:39:33 +02:00
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename);
|
|
|
|
return settings.value(*settingPathsMultisizeMeasurements, GetDefPathMultisizeMeasurements()).toString();
|
2015-07-18 14:39:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2017-07-12 20:21:48 +02:00
|
|
|
void VCommonSettings::SetPathMultisizeMeasurements(const QString &value)
|
2015-07-18 14:39:33 +02:00
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename);
|
|
|
|
settings.setValue(*settingPathsMultisizeMeasurements, value);
|
2015-10-18 14:38:05 +02:00
|
|
|
settings.sync();
|
2015-07-18 14:39:33 +02:00
|
|
|
}
|
|
|
|
|
2019-01-06 01:46:31 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QString VCommonSettings::GetDefPathPattern()
|
|
|
|
{
|
|
|
|
return QDir::homePath() + QLatin1String("/valentina/") + tr("patterns");
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QString VCommonSettings::GetPathPattern() const
|
|
|
|
{
|
|
|
|
QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename);
|
|
|
|
return settings.value(*settingPathsPattern, GetDefPathPattern()).toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetPathPattern(const QString &value)
|
|
|
|
{
|
|
|
|
QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename);
|
|
|
|
settings.setValue(*settingPathsPattern, value);
|
|
|
|
settings.sync();
|
|
|
|
}
|
|
|
|
|
2017-02-17 19:37:49 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QString VCommonSettings::GetDefPathTemplate()
|
|
|
|
{
|
|
|
|
return QDir::homePath() + QLatin1String("/valentina/") + tr("templates");
|
|
|
|
}
|
2015-10-18 12:01:38 +02:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QString VCommonSettings::GetPathTemplate() const
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename);
|
|
|
|
return settings.value(*settingPathsTemplates, GetDefPathTemplate()).toString();
|
2015-10-18 12:01:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetPathTemplate(const QString &value)
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename);
|
|
|
|
settings.setValue(*settingPathsTemplates, value);
|
2015-10-18 14:38:05 +02:00
|
|
|
settings.sync();
|
2015-10-18 12:01:38 +02:00
|
|
|
}
|
|
|
|
|
2017-08-10 13:51:17 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QString VCommonSettings::GetDefPathLabelTemplate()
|
|
|
|
{
|
|
|
|
return QDir::homePath() + QLatin1String("/valentina/") + tr("label templates");
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QString VCommonSettings::GetPathLabelTemplate() const
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
return value(*settingPathsLabelTemplate, GetDefPathLabelTemplate()).toString();
|
2017-08-10 13:51:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetPathLabelTemplate(const QString &value)
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
setValue(*settingPathsLabelTemplate, value);
|
2017-08-10 13:51:17 +02:00
|
|
|
}
|
|
|
|
|
2015-07-15 09:16:59 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool VCommonSettings::GetOsSeparator() const
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
return value(*settingConfigurationOsSeparator, 1).toBool();
|
2015-07-15 09:16:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetOsSeparator(const bool &value)
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
setValue(*settingConfigurationOsSeparator, value);
|
2015-07-15 09:16:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool VCommonSettings::GetAutosaveState() const
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
return value(*settingConfigurationAutosaveState, 1).toBool();
|
2015-07-15 09:16:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetAutosaveState(const bool &value)
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
setValue(*settingConfigurationAutosaveState, value);
|
2015-07-15 09:16:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
int VCommonSettings::GetAutosaveTime() const
|
|
|
|
{
|
|
|
|
bool ok = false;
|
2018-03-14 14:39:15 +01:00
|
|
|
int val = value(*settingConfigurationAutosaveTime, 1).toInt(&ok);
|
2015-07-15 09:16:59 +02:00
|
|
|
if (ok == false)
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
qDebug()<<"Could not convert value"<<value(*settingConfigurationAutosaveTime, 1)
|
2015-07-15 09:16:59 +02:00
|
|
|
<<"to int. Return default value for autosave time"<<1<<"minutes.";
|
|
|
|
val = 1;
|
|
|
|
}
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetAutosaveTime(const int &value)
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
setValue(*settingConfigurationAutosaveTime, value);
|
2015-07-15 09:16:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QString VCommonSettings::GetLocale() const
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
if (localeCached->isEmpty())
|
2018-01-21 15:00:53 +01:00
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
*localeCached = value(*settingConfigurationLocale, QLocale().name()).toString();
|
2018-01-21 15:00:53 +01:00
|
|
|
}
|
2018-03-14 14:39:15 +01:00
|
|
|
return *localeCached;
|
2015-07-15 09:16:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetLocale(const QString &value)
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
setValue(*settingConfigurationLocale, value);
|
|
|
|
*localeCached = value;
|
2015-07-15 09:16:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-08-02 17:27:18 +02:00
|
|
|
QString VCommonSettings::GetPMSystemCode() const
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
return value(*settingPMSystemCode, "p998").toString();
|
2015-08-02 17:27:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetPMSystemCode(const QString &value)
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
setValue(*settingPMSystemCode, value);
|
2015-08-02 17:27:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-07-15 09:16:59 +02:00
|
|
|
QString VCommonSettings::GetUnit() const
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
return value(*settingConfigurationUnit,
|
2017-06-16 15:01:09 +02:00
|
|
|
QLocale().measurementSystem() == QLocale::MetricSystem ? unitCM : unitINCH).toString();
|
2015-07-15 09:16:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetUnit(const QString &value)
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
setValue(*settingConfigurationUnit, value);
|
2015-07-15 09:16:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool VCommonSettings::GetConfirmItemDelete() const
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
return value(*settingConfigurationConfirmItemDeletion, 1).toBool();
|
2015-07-15 09:16:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetConfirmItemDelete(const bool &value)
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
setValue(*settingConfigurationConfirmItemDeletion, value);
|
2015-07-15 09:16:59 +02:00
|
|
|
}
|
|
|
|
|
2017-04-12 08:49:05 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool VCommonSettings::GetConfirmFormatRewriting() const
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
return value(*settingConfigurationConfirmFormatRewriting, 1).toBool();
|
2017-04-12 08:49:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetConfirmFormatRewriting(const bool &value)
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
setValue(*settingConfigurationConfirmFormatRewriting, value);
|
2017-04-12 08:49:05 +02:00
|
|
|
}
|
|
|
|
|
2015-07-15 09:16:59 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool VCommonSettings::GetToolBarStyle() const
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
return value(*settingConfigurationToolBarStyle, 1).toBool();
|
2015-07-15 09:16:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetToolBarStyle(const bool &value)
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
setValue(*settingConfigurationToolBarStyle, value);
|
2015-07-15 09:16:59 +02:00
|
|
|
}
|
|
|
|
|
2018-10-29 13:05:49 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool VCommonSettings::GetDarkMode() const
|
|
|
|
{
|
2018-10-29 18:39:14 +01:00
|
|
|
return value(*settingConfigurationDarkMode, 0).toBool();
|
2018-10-29 13:05:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetDarkMode(const bool &value)
|
|
|
|
{
|
|
|
|
setValue(*settingConfigurationDarkMode, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-10-03 12:01:56 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool VCommonSettings::IsFreeCurveMode() const
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
return value(*settingConfigurationFreeCurveMode, 1).toBool();
|
2017-10-03 12:01:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetFreeCurveMode(bool value)
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
setValue(*settingConfigurationFreeCurveMode, value);
|
2017-10-03 12:01:56 +02:00
|
|
|
}
|
|
|
|
|
2018-05-10 13:12:41 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool VCommonSettings::IsDoubleClickZoomFitBestCurrentPP() const
|
|
|
|
{
|
|
|
|
return value(*settingConfigurationDoubleClickZoomFitBestCurrentPP, 1).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetDoubleClickZoomFitBestCurrentPP(bool value)
|
|
|
|
{
|
|
|
|
setValue(*settingConfigurationDoubleClickZoomFitBestCurrentPP, value);
|
|
|
|
}
|
|
|
|
|
2015-07-15 09:16:59 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
int VCommonSettings::GetUndoCount() const
|
|
|
|
{
|
|
|
|
bool ok = false;
|
2018-03-14 14:39:15 +01:00
|
|
|
int val = value(*settingPatternUndo, 0).toInt(&ok);
|
2015-07-15 09:16:59 +02:00
|
|
|
if (ok == false)
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
qDebug()<<"Could not convert value"<<value(*settingPatternUndo, 0)
|
2015-07-15 09:16:59 +02:00
|
|
|
<<"to int. Return default value for undo counts 0 (no limit).";
|
|
|
|
val = 0;
|
|
|
|
}
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetUndoCount(const int &value)
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
setValue(*settingPatternUndo, value);
|
2015-07-15 09:16:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QStringList VCommonSettings::GetRecentFileList() const
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
const QStringList files = value(*settingGeneralRecentFileList).toStringList();
|
2016-09-09 13:01:57 +02:00
|
|
|
QStringList cleared;
|
|
|
|
|
2018-04-03 13:36:38 +02:00
|
|
|
for (auto &f : files)
|
2016-09-09 13:01:57 +02:00
|
|
|
{
|
2018-04-03 13:36:38 +02:00
|
|
|
if (QFileInfo::exists(f))
|
2016-09-09 13:01:57 +02:00
|
|
|
{
|
2018-04-03 13:36:38 +02:00
|
|
|
cleared.append(f);
|
2016-09-09 13:01:57 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return cleared;
|
2015-07-15 09:16:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetRecentFileList(const QStringList &value)
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
setValue(*settingGeneralRecentFileList, value);
|
2015-07-15 09:16:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QStringList VCommonSettings::GetRestoreFileList() const
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
return value(*settingGeneralRestoreFileList).toStringList();
|
2015-07-15 09:16:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetRestoreFileList(const QStringList &value)
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
setValue(*settingGeneralRestoreFileList, value);
|
2015-07-15 09:16:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QByteArray VCommonSettings::GetGeometry() const
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
return value(*settingGeneralGeometry).toByteArray();
|
2015-07-15 09:16:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetGeometry(const QByteArray &value)
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
setValue(*settingGeneralGeometry, value);
|
2015-07-15 09:16:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QByteArray VCommonSettings::GetWindowState() const
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
return value(*settingGeneralWindowState).toByteArray();
|
2015-07-15 09:16:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetWindowState(const QByteArray &value)
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
setValue(*settingGeneralWindowState, value);
|
2015-07-15 09:16:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QByteArray VCommonSettings::GetToolbarsState() const
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
return value(*settingGeneralToolbarsState).toByteArray();
|
2015-07-15 09:16:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetToolbarsState(const QByteArray &value)
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
setValue(*settingGeneralToolbarsState, value);
|
2015-07-15 09:16:59 +02:00
|
|
|
}
|
2016-06-10 21:34:21 +02:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QSize VCommonSettings::GetPreferenceDialogSize() const
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
return value(*settingPreferenceDialogSize, QSize(0, 0)).toSize();
|
2016-06-10 21:34:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetPreferenceDialogSize(const QSize& sz)
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
setValue(*settingPreferenceDialogSize, sz);
|
2016-06-10 21:34:21 +02:00
|
|
|
}
|
2016-07-15 11:00:00 +02:00
|
|
|
|
2017-05-30 10:47:27 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QSize VCommonSettings::GetToolSeamAllowanceDialogSize() const
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
return value(*settingToolSeamAllowanceDialogSize, QSize(0, 0)).toSize();
|
2017-05-30 10:47:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetToolSeamAllowanceDialogSize(const QSize &sz)
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
setValue(*settingToolSeamAllowanceDialogSize, sz);
|
2017-05-30 10:47:27 +02:00
|
|
|
}
|
|
|
|
|
2017-06-16 16:05:35 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QSize VCommonSettings::GetFormulaWizardDialogSize() const
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
return value(*settingFormulaWizardDialogSize, QSize(0, 0)).toSize();
|
2017-06-16 16:05:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetFormulaWizardDialogSize(const QSize &sz)
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
setValue(*settingFormulaWizardDialogSize, sz);
|
2017-06-16 16:05:35 +02:00
|
|
|
}
|
|
|
|
|
2017-07-26 08:13:29 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QSize VCommonSettings::GetIncrementsDialogSize() const
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
return value(*settingIncrementsDialogSize, QSize(0, 0)).toSize();
|
2017-07-26 08:13:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetIncrementsDialogSize(const QSize &sz)
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
setValue(*settingIncrementsDialogSize, sz);
|
2017-07-26 08:13:29 +02:00
|
|
|
}
|
|
|
|
|
2017-09-26 16:24:02 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QSize VCommonSettings::GetFinalMeasurementsDialogSize() const
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
return value(*settingFinalMeasurementsDialogSize, QSize(0, 0)).toSize();
|
2017-09-26 16:24:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetFinalMeasurementsDialogSize(const QSize &sz)
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
setValue(*settingFinalMeasurementsDialogSize, sz);
|
2017-09-26 16:24:02 +02:00
|
|
|
}
|
|
|
|
|
2016-07-15 11:00:00 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
int VCommonSettings::GetLatestSkippedVersion() const
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename);
|
|
|
|
return settings.value(*settingLatestSkippedVersion, 0x0).toInt();
|
2016-07-15 11:00:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetLatestSkippedVersion(int value)
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename);
|
|
|
|
settings.setValue(*settingLatestSkippedVersion, value);
|
2016-07-15 12:14:48 +02:00
|
|
|
settings.sync();
|
2016-07-15 11:00:00 +02:00
|
|
|
}
|
2016-07-15 11:30:55 +02:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QDate VCommonSettings::GetDateOfLastRemind() const
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename);
|
|
|
|
return settings.value(*settingDateOfLastRemind, QDate(1900, 1, 1)).toDate();
|
2016-07-15 11:30:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetDateOfLastRemind(const QDate &date)
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename);
|
|
|
|
settings.setValue(*settingDateOfLastRemind, date);
|
2016-07-15 12:14:48 +02:00
|
|
|
settings.sync();
|
2016-07-15 11:30:55 +02:00
|
|
|
}
|
2016-08-12 01:22:23 +02:00
|
|
|
|
2016-09-06 16:05:54 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool VCommonSettings::GetForbidWorkpieceFlipping() const
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
return value(*settingPatternForbidFlipping, false).toBool();
|
2016-09-06 16:05:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetForbidWorkpieceFlipping(bool value)
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
setValue(*settingPatternForbidFlipping, value);
|
2017-12-17 14:06:46 +01:00
|
|
|
|
|
|
|
if (value)
|
|
|
|
{
|
|
|
|
SetForceWorkpieceFlipping(not value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool VCommonSettings::GetForceWorkpieceFlipping() const
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
return value(*settingPatternForceFlipping, false).toBool();
|
2017-12-17 14:06:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetForceWorkpieceFlipping(bool value)
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
setValue(*settingPatternForceFlipping, value);
|
2017-12-17 14:06:46 +01:00
|
|
|
|
|
|
|
if (value)
|
|
|
|
{
|
|
|
|
SetForbidWorkpieceFlipping(not value);
|
|
|
|
}
|
2016-09-06 16:05:54 +02:00
|
|
|
}
|
2017-04-05 12:22:33 +02:00
|
|
|
|
2017-05-16 14:16:50 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool VCommonSettings::IsHideMainPath() const
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
return value(*settingPatternHideMainPath, false).toBool();
|
2017-05-16 14:16:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetHideMainPath(bool value)
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
setValue(*settingPatternHideMainPath, value);
|
2017-05-16 14:16:50 +02:00
|
|
|
}
|
|
|
|
|
2017-04-05 12:22:33 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool VCommonSettings::IsDoublePassmark() const
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
return value(*settingDoublePassmark, false).toBool();
|
2017-04-05 12:22:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetDoublePassmark(bool value)
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
setValue(*settingDoublePassmark, value);
|
2017-04-05 12:22:33 +02:00
|
|
|
}
|
2017-05-12 14:09:19 +02:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetCSVWithHeader(bool withHeader)
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename);
|
|
|
|
settings.setValue(*settingCSVWithHeader, withHeader);
|
2017-05-12 14:09:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool VCommonSettings::GetCSVWithHeader() const
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename);
|
|
|
|
return settings.value(*settingCSVWithHeader, GetDefCSVWithHeader()).toBool();
|
2017-05-12 14:09:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2017-09-27 12:25:18 +02:00
|
|
|
bool VCommonSettings::GetDefCSVWithHeader()
|
2017-05-12 14:09:19 +02:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetCSVCodec(int mib)
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename);
|
|
|
|
settings.setValue(*settingCSVCodec, mib);
|
2017-05-12 14:09:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
int VCommonSettings::GetCSVCodec() const
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename);
|
|
|
|
return settings.value(*settingCSVCodec, GetDefCSVCodec()).toInt();
|
2017-05-12 14:09:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2017-09-27 12:25:18 +02:00
|
|
|
int VCommonSettings::GetDefCSVCodec()
|
2017-05-12 14:09:19 +02:00
|
|
|
{
|
|
|
|
return QTextCodec::codecForLocale()->mibEnum();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetCSVSeparator(const QChar &separator)
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename);
|
2017-05-12 14:09:19 +02:00
|
|
|
switch(separator.toLatin1())
|
|
|
|
{
|
|
|
|
case '\t':
|
2018-03-14 14:39:15 +01:00
|
|
|
settings.setValue(*settingCSVSeparator, 0);
|
2017-05-12 14:09:19 +02:00
|
|
|
break;
|
|
|
|
case ';':
|
2018-03-14 14:39:15 +01:00
|
|
|
settings.setValue(*settingCSVSeparator, 1);
|
2017-05-12 14:09:19 +02:00
|
|
|
break;
|
|
|
|
case ' ':
|
2018-03-14 14:39:15 +01:00
|
|
|
settings.setValue(*settingCSVSeparator, 2);
|
2017-05-12 14:09:19 +02:00
|
|
|
break;
|
|
|
|
default:
|
2018-03-14 14:39:15 +01:00
|
|
|
settings.setValue(*settingCSVSeparator, 3);
|
2017-05-12 14:09:19 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QChar VCommonSettings::GetCSVSeparator() const
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename);
|
|
|
|
const quint8 separator = static_cast<quint8>(settings.value(*settingCSVSeparator, 3).toUInt());
|
2017-05-12 14:09:19 +02:00
|
|
|
switch(separator)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
return QChar('\t');
|
|
|
|
case 1:
|
|
|
|
return QChar(';');
|
|
|
|
case 2:
|
|
|
|
return QChar(' ');
|
|
|
|
default:
|
|
|
|
return QChar(',');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2017-09-27 12:25:18 +02:00
|
|
|
QChar VCommonSettings::GetDefCSVSeparator()
|
2017-05-12 14:09:19 +02:00
|
|
|
{
|
|
|
|
return QChar(',');
|
|
|
|
}
|
2017-07-02 10:14:01 +02:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetDefaultSeamAllowance(double value)
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
setValue(*settingPatternDefaultSeamAllowance, UnitConvertor(value, StrToUnits(GetUnit()), Unit::Cm));
|
2017-07-02 10:14:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
/**
|
|
|
|
* @brief returns the default seam allowance. The corresponding unit is the default unit.
|
|
|
|
* @return the default seam allowance
|
|
|
|
*/
|
|
|
|
double VCommonSettings::GetDefaultSeamAllowance()
|
|
|
|
{
|
|
|
|
double defaultValue;
|
|
|
|
|
2017-07-03 10:23:34 +02:00
|
|
|
const Unit globalUnit = StrToUnits(GetUnit());
|
2017-07-02 10:14:01 +02:00
|
|
|
|
|
|
|
switch (globalUnit)
|
|
|
|
{
|
|
|
|
case Unit::Mm:
|
|
|
|
defaultValue = 10;
|
|
|
|
break;
|
|
|
|
case Unit::Inch:
|
|
|
|
defaultValue = 0.25;
|
|
|
|
break;
|
|
|
|
case Unit::Cm:
|
2017-08-30 09:35:11 +02:00
|
|
|
default:
|
2017-07-02 10:14:01 +02:00
|
|
|
defaultValue = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ok = false;
|
2018-03-14 14:39:15 +01:00
|
|
|
double val = value(*settingPatternDefaultSeamAllowance, -1).toDouble(&ok);
|
2017-07-02 10:14:01 +02:00
|
|
|
if (ok == false)
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
qDebug()<< "Could not convert value"<<value(*settingPatternDefaultSeamAllowance, 0)
|
2017-07-03 10:23:34 +02:00
|
|
|
<< "to real. Return default value for default seam allowance is "
|
2018-04-13 08:14:55 +02:00
|
|
|
<< defaultValue << QChar('.');
|
2017-07-02 10:14:01 +02:00
|
|
|
val = defaultValue;
|
|
|
|
}
|
|
|
|
|
2017-07-03 10:23:34 +02:00
|
|
|
if (val < 0)
|
|
|
|
{
|
|
|
|
val = defaultValue;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
val = UnitConvertor(val, Unit::Cm, globalUnit);
|
|
|
|
}
|
|
|
|
|
2017-07-02 10:14:01 +02:00
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
2017-07-01 13:41:46 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QFont VCommonSettings::GetLabelFont() const
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
return qvariant_cast<QFont>(value(*settingPatternLabelFont, QApplication::font()));
|
2017-07-01 13:41:46 +02:00
|
|
|
}
|
2017-07-02 10:14:01 +02:00
|
|
|
|
2017-07-01 13:41:46 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetLabelFont(const QFont &f)
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
setValue(*settingPatternLabelFont, f);
|
2017-08-19 18:10:57 +02:00
|
|
|
}
|
|
|
|
|
2019-05-08 18:22:55 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
int VCommonSettings::GetLabelFontSize() const
|
|
|
|
{
|
|
|
|
if (labelFontSizeCached <= 0)
|
|
|
|
{
|
|
|
|
bool ok = false;
|
|
|
|
labelFontSizeCached = value(*settingPatternLabelFontSize, GetDefLabelFontSize()).toInt(&ok);
|
|
|
|
if (not ok)
|
|
|
|
{
|
|
|
|
labelFontSizeCached = GetDefLabelFontSize();
|
|
|
|
}
|
|
|
|
labelFontSizeCached = qBound(minLabelFontSize, labelFontSizeCached, maxLabelFontSize);
|
|
|
|
}
|
|
|
|
return labelFontSizeCached;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetLabelFontSize(int size)
|
|
|
|
{
|
|
|
|
size = qBound(minLabelFontSize, size, maxLabelFontSize);
|
|
|
|
setValue(*settingPatternLabelFontSize, size);
|
|
|
|
labelFontSizeCached = size;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
int VCommonSettings::GetDefLabelFontSize()
|
|
|
|
{
|
|
|
|
return 32;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool VCommonSettings::GetHideLabels() const
|
|
|
|
{
|
|
|
|
return value(*settingPatternHideLabels, false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetHideLabels(bool value)
|
|
|
|
{
|
|
|
|
setValue(*settingPatternHideLabels, value);
|
|
|
|
}
|
|
|
|
|
2017-08-19 18:10:57 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QString VCommonSettings::GetLabelDateFormat() const
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
const QString format = value(*settingLabelDateFormat,
|
2019-05-28 16:25:42 +02:00
|
|
|
ConstFirst<QString> (VCommonSettings::PredefinedDateFormats())).toString();
|
2017-08-19 18:10:57 +02:00
|
|
|
const QStringList allFormats = VCommonSettings::PredefinedDateFormats() + GetUserDefinedDateFormats();
|
|
|
|
|
2019-05-28 16:25:42 +02:00
|
|
|
return allFormats.contains(format) ? format : ConstFirst<QString> (VCommonSettings::PredefinedDateFormats());
|
2017-08-19 18:10:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetLabelDateFormat(const QString &format)
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
setValue(*settingLabelDateFormat, format);
|
2017-08-19 18:10:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QStringList VCommonSettings::PredefinedDateFormats()
|
|
|
|
{
|
2019-05-28 15:20:53 +02:00
|
|
|
return QStringList
|
|
|
|
{
|
|
|
|
"MM-dd-yyyy",
|
|
|
|
"d/M/yy",
|
|
|
|
"ddddMMMM dd, yyyy",
|
|
|
|
"dd/MM/yy",
|
|
|
|
"dd/MM/yyyy",
|
|
|
|
"MMM d, yy",
|
|
|
|
"MMM d, yyyy",
|
|
|
|
"d. MMM. yyyy",
|
|
|
|
"MMMM d, yyyy",
|
|
|
|
"d. MMMM yyyy",
|
|
|
|
"ddd, MMM d, yy",
|
|
|
|
"ddd dd/MMM yy",
|
|
|
|
"ddd, MMMM d, yyyy",
|
|
|
|
"ddddMMMM d, yyyy",
|
|
|
|
"MM-dd",
|
|
|
|
"yy-MM-dd",
|
|
|
|
"yyyy-MM-dd",
|
|
|
|
"MM/yy",
|
|
|
|
"MMM dd",
|
|
|
|
"MMMM"
|
|
|
|
};
|
2017-08-19 18:10:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QStringList VCommonSettings::GetUserDefinedDateFormats() const
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
return value(*settingLabelUserDateFormats, QStringList()).toStringList();
|
2017-08-19 18:10:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetUserDefinedDateFormats(const QStringList &formats)
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
setValue(*settingLabelUserDateFormats, ClearFormats(VCommonSettings::PredefinedDateFormats(), formats));
|
2017-08-19 18:10:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QString VCommonSettings::GetLabelTimeFormat() const
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
const QString format = value(*settingLabelTimeFormat,
|
2019-05-28 16:25:42 +02:00
|
|
|
ConstFirst<QString> (VCommonSettings::PredefinedTimeFormats())).toString();
|
2017-08-19 18:10:57 +02:00
|
|
|
const QStringList allFormats = VCommonSettings::PredefinedTimeFormats() + GetUserDefinedTimeFormats();
|
|
|
|
|
2019-05-28 16:25:42 +02:00
|
|
|
return allFormats.contains(format) ? format : ConstFirst<QString> (VCommonSettings::PredefinedTimeFormats());
|
2017-08-19 18:10:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetLabelTimeFormat(const QString &format)
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
setValue(*settingLabelTimeFormat, format);
|
2017-08-19 18:10:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QStringList VCommonSettings::PredefinedTimeFormats()
|
|
|
|
{
|
2019-05-28 15:20:53 +02:00
|
|
|
return QStringList
|
|
|
|
{
|
|
|
|
"hh:mm:ss",
|
|
|
|
"hh:mm:ss AP",
|
|
|
|
"hh:mm",
|
|
|
|
"hh:mm AP"
|
|
|
|
};
|
2017-08-19 18:10:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QStringList VCommonSettings::GetUserDefinedTimeFormats() const
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
return value(*settingLabelUserTimeFormats, QStringList()).toStringList();
|
2017-08-19 18:10:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetUserDefinedTimeFormats(const QStringList &formats)
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
setValue(*settingLabelUserTimeFormats, ClearFormats(VCommonSettings::PredefinedTimeFormats(), formats));
|
2017-07-01 13:41:46 +02:00
|
|
|
}
|
2017-10-11 12:51:06 +02:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
qreal VCommonSettings::GetCurveApproximationScale() const
|
|
|
|
{
|
2018-01-20 11:35:43 +01:00
|
|
|
if (curveApproximationCached < 0)
|
2017-10-11 12:51:06 +02:00
|
|
|
{
|
2018-01-20 11:35:43 +01:00
|
|
|
bool ok = false;
|
2018-03-14 14:39:15 +01:00
|
|
|
const qreal scale = value(*settingPatternCurveApproximationScale, defCurveApproximationScale).toDouble(&ok);
|
2018-01-20 11:35:43 +01:00
|
|
|
if (ok && scale >= minCurveApproximationScale && scale <= maxCurveApproximationScale)
|
|
|
|
{
|
|
|
|
curveApproximationCached = scale;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
curveApproximationCached = defCurveApproximationScale;
|
|
|
|
}
|
2017-10-11 12:51:06 +02:00
|
|
|
}
|
2018-01-20 11:35:43 +01:00
|
|
|
|
|
|
|
return curveApproximationCached;
|
2017-10-11 12:51:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetCurveApproximationScale(qreal value)
|
|
|
|
{
|
|
|
|
if (value >= minCurveApproximationScale && value <= maxCurveApproximationScale)
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
setValue(*settingPatternCurveApproximationScale, value);
|
2018-01-20 11:35:43 +01:00
|
|
|
curveApproximationCached = value;
|
2017-10-11 12:51:06 +02:00
|
|
|
}
|
|
|
|
}
|
2017-10-29 14:13:13 +01:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool VCommonSettings::IsShowCurveDetails() const
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
return value(*settingPatternShowCurveDetails, false).toBool();
|
2017-10-29 14:13:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetShowCurveDetails(bool value)
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
setValue(*settingPatternShowCurveDetails, value);
|
2017-10-29 14:13:13 +01:00
|
|
|
}
|
2018-02-06 18:30:27 +01:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
qreal VCommonSettings::GetLineWidth() const
|
|
|
|
{
|
|
|
|
if (lineWidthCached <= 0)
|
|
|
|
{
|
2018-03-14 14:39:15 +01:00
|
|
|
lineWidthCached = qBound(VCommonSettings::MinimalLineWidth(), value(*settingPatternLineWidth, 1.2).toDouble(),
|
2018-02-06 18:30:27 +01:00
|
|
|
VCommonSettings::MaximalLineWidth());
|
|
|
|
}
|
|
|
|
|
|
|
|
return lineWidthCached;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetLineWidth(qreal width)
|
|
|
|
{
|
|
|
|
lineWidthCached = qBound(VCommonSettings::MinimalLineWidth(), width, VCommonSettings::MaximalLineWidth());
|
2018-03-14 14:39:15 +01:00
|
|
|
setValue(*settingPatternLineWidth, lineWidthCached);
|
2018-02-06 18:30:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
qreal VCommonSettings::WidthMainLine() const
|
|
|
|
{
|
|
|
|
return GetLineWidth() / 25.4 * PrintDPI;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
qreal VCommonSettings::WidthHairLine() const
|
|
|
|
{
|
|
|
|
return WidthMainLine()/3.0;
|
|
|
|
}
|