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>
|
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
|
|
|
|
{
|
2017-04-11 10:16:11 +02:00
|
|
|
const QString settingPathsIndividualMeasurements = QStringLiteral("paths/individual_measurements");
|
2017-08-10 13:51:17 +02:00
|
|
|
const QString settingPathsMultisizeMeasurements = QStringLiteral("paths/standard_measurements");
|
2017-04-11 10:16:11 +02:00
|
|
|
const QString settingPathsTemplates = QStringLiteral("paths/templates");
|
2017-08-14 16:17:40 +02:00
|
|
|
const QString settingPathsLabelTemplate = QStringLiteral("paths/labels");
|
2017-04-11 10:16:11 +02:00
|
|
|
|
2017-04-12 08:49:05 +02:00
|
|
|
const QString settingConfigurationOsSeparator = QStringLiteral("configuration/osSeparator");
|
|
|
|
const QString settingConfigurationAutosaveState = QStringLiteral("configuration/autosave/state");
|
|
|
|
const QString settingConfigurationAutosaveTime = QStringLiteral("configuration/autosave/time");
|
|
|
|
const QString settingConfigurationLocale = QStringLiteral("configuration/locale");
|
|
|
|
const QString settingPMSystemCode = QStringLiteral("configuration/pmscode");
|
|
|
|
const QString settingConfigurationUnit = QStringLiteral("configuration/unit");
|
|
|
|
const QString settingConfigurationConfirmItemDeletion = QStringLiteral("configuration/confirm_item_deletion");
|
|
|
|
const QString settingConfigurationConfirmFormatRewriting = QStringLiteral("configuration/confirm_format_rewriting");
|
|
|
|
const QString settingConfigurationToolBarStyle = QStringLiteral("configuration/tool_bar_style");
|
2017-10-03 12:01:56 +02:00
|
|
|
const QString settingConfigurationFreeCurveMode = QStringLiteral("configuration/freeCurveMode");
|
2017-04-11 10:16:11 +02:00
|
|
|
|
2017-07-02 10:14:01 +02:00
|
|
|
const QString settingPatternUndo = QStringLiteral("pattern/undo");
|
|
|
|
const QString settingPatternForbidFlipping = QStringLiteral("pattern/forbidFlipping");
|
2017-12-17 14:06:46 +01:00
|
|
|
const QString settingPatternForceFlipping = QStringLiteral("pattern/forceFlipping");
|
2017-07-02 10:14:01 +02:00
|
|
|
const QString settingPatternHideMainPath = QStringLiteral("pattern/hideMainPath");
|
|
|
|
const QString settingDoublePassmark = QStringLiteral("pattern/doublePassmark");
|
|
|
|
const QString settingPatternDefaultSeamAllowance = QStringLiteral("pattern/defaultSeamAllowance");
|
2017-08-19 18:10:57 +02:00
|
|
|
const QString settingPatternLabelFont = QStringLiteral("pattern/labelFont");
|
2017-10-11 12:51:06 +02:00
|
|
|
const QString settingPatternCurveApproximationScale = QStringLiteral("pattern/curveApproximationScale");
|
2017-10-29 14:13:13 +01:00
|
|
|
const QString settingPatternShowCurveDetails = QStringLiteral("pattern/showCurveDetails");
|
2017-04-11 10:16:11 +02:00
|
|
|
|
2017-05-30 10:47:27 +02:00
|
|
|
const QString settingGeneralRecentFileList = QStringLiteral("recentFileList");
|
|
|
|
const QString settingGeneralRestoreFileList = QStringLiteral("restoreFileList");
|
|
|
|
const QString settingGeneralGeometry = QStringLiteral("geometry");
|
|
|
|
const QString settingGeneralWindowState = QStringLiteral("windowState");
|
|
|
|
const QString settingGeneralToolbarsState = QStringLiteral("toolbarsState");
|
|
|
|
const QString settingPreferenceDialogSize = QStringLiteral("preferenceDialogSize");
|
|
|
|
const QString settingToolSeamAllowanceDialogSize = QStringLiteral("toolSeamAllowanceDialogSize");
|
2017-07-26 08:13:29 +02:00
|
|
|
const QString settingIncrementsDialogSize = QStringLiteral("toolIncrementsDialogSize");
|
2017-06-16 16:05:35 +02:00
|
|
|
const QString settingFormulaWizardDialogSize = QStringLiteral("formulaWizardDialogSize");
|
2017-09-26 16:24:02 +02:00
|
|
|
const QString settingFinalMeasurementsDialogSize = QStringLiteral("finalMeasurementsDialogSize");
|
2017-05-30 10:47:27 +02:00
|
|
|
const QString settingLatestSkippedVersion = QStringLiteral("lastestSkippedVersion");
|
|
|
|
const QString settingDateOfLastRemind = QStringLiteral("dateOfLastRemind");
|
2015-07-15 09:16:59 +02:00
|
|
|
|
2017-05-12 14:09:19 +02:00
|
|
|
const QString settingCSVWithHeader = QStringLiteral("csv/withHeader");
|
|
|
|
const QString settingCSVCodec = QStringLiteral("csv/withCodec");
|
|
|
|
const QString settingCSVSeparator = QStringLiteral("csv/withSeparator");
|
|
|
|
|
2017-08-19 18:10:57 +02:00
|
|
|
const QString settingLabelDateFormat = QStringLiteral("label/dateFormat");
|
|
|
|
const QString settingLabelUserDateFormats = QStringLiteral("label/userDateFormats");
|
|
|
|
const QString settingLabelTimeFormat = QStringLiteral("label/timeFormat");
|
|
|
|
const QString settingLabelUserTimeFormats = QStringLiteral("label/userTimeFormats");
|
|
|
|
|
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-01-21 15:00:53 +01:00
|
|
|
QString localeCached = QString();
|
2018-01-20 11:35:43 +01:00
|
|
|
|
2017-08-19 18:10:57 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QStringList ClearFormats(const QStringList &predefinedFormats, QStringList formats)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < predefinedFormats.size(); ++i)
|
|
|
|
{
|
|
|
|
formats.removeAll(predefinedFormats.at(i));
|
|
|
|
}
|
|
|
|
return formats;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-10 16:48:30 +02:00
|
|
|
static const QString commonIniFilename = QStringLiteral("common");
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
foreach (QString copyFile, dir.entryList(QDir::Files))
|
|
|
|
{
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
foreach (QString copyDir, dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot))
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
if (localdata.mkpath("."))
|
|
|
|
{
|
|
|
|
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
|
|
|
|
{
|
2016-06-10 16:48:30 +02:00
|
|
|
QSettings settings(this->format(), this->scope(), this->organizationName(), commonIniFilename);
|
2017-04-11 10:16:11 +02:00
|
|
|
return settings.value(settingPathsIndividualMeasurements, GetDefPathIndividualMeasurements()).toString();
|
2015-07-18 14:39:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetPathIndividualMeasurements(const QString &value)
|
|
|
|
{
|
2016-06-10 16:48:30 +02:00
|
|
|
QSettings settings(this->format(), this->scope(), this->organizationName(), commonIniFilename);
|
2017-04-11 10:16:11 +02:00
|
|
|
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
|
|
|
{
|
2016-06-10 16:48:30 +02:00
|
|
|
QSettings settings(this->format(), this->scope(), this->organizationName(), commonIniFilename);
|
2017-07-12 20:21:48 +02:00
|
|
|
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
|
|
|
{
|
2016-06-10 16:48:30 +02:00
|
|
|
QSettings settings(this->format(), this->scope(), this->organizationName(), commonIniFilename);
|
2017-07-12 20:21:48 +02:00
|
|
|
settings.setValue(settingPathsMultisizeMeasurements, 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
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QString VCommonSettings::GetDefPathTemplate()
|
|
|
|
{
|
|
|
|
return QDir::homePath() + QLatin1String("/valentina/") + tr("templates");
|
|
|
|
}
|
2015-10-18 12:01:38 +02:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QString VCommonSettings::GetPathTemplate() const
|
|
|
|
{
|
2016-06-10 16:48:30 +02:00
|
|
|
QSettings settings(this->format(), this->scope(), this->organizationName(), commonIniFilename);
|
2017-04-11 10:16:11 +02:00
|
|
|
return settings.value(settingPathsTemplates, GetDefPathTemplate()).toString();
|
2015-10-18 12:01:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetPathTemplate(const QString &value)
|
|
|
|
{
|
2016-06-10 16:48:30 +02:00
|
|
|
QSettings settings(this->format(), this->scope(), this->organizationName(), commonIniFilename);
|
2017-04-11 10:16:11 +02:00
|
|
|
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
|
|
|
|
{
|
|
|
|
return value(settingPathsLabelTemplate, GetDefPathLabelTemplate()).toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetPathLabelTemplate(const QString &value)
|
|
|
|
{
|
|
|
|
setValue(settingPathsLabelTemplate, value);
|
|
|
|
}
|
|
|
|
|
2015-07-15 09:16:59 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool VCommonSettings::GetOsSeparator() const
|
|
|
|
{
|
2017-04-11 10:16:11 +02:00
|
|
|
return value(settingConfigurationOsSeparator, 1).toBool();
|
2015-07-15 09:16:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetOsSeparator(const bool &value)
|
|
|
|
{
|
2017-04-11 10:16:11 +02:00
|
|
|
setValue(settingConfigurationOsSeparator, value);
|
2015-07-15 09:16:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool VCommonSettings::GetAutosaveState() const
|
|
|
|
{
|
2017-04-11 10:16:11 +02:00
|
|
|
return value(settingConfigurationAutosaveState, 1).toBool();
|
2015-07-15 09:16:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetAutosaveState(const bool &value)
|
|
|
|
{
|
2017-04-11 10:16:11 +02:00
|
|
|
setValue(settingConfigurationAutosaveState, value);
|
2015-07-15 09:16:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
int VCommonSettings::GetAutosaveTime() const
|
|
|
|
{
|
|
|
|
bool ok = false;
|
2017-04-11 10:16:11 +02:00
|
|
|
int val = value(settingConfigurationAutosaveTime, 1).toInt(&ok);
|
2015-07-15 09:16:59 +02:00
|
|
|
if (ok == false)
|
|
|
|
{
|
2017-04-11 10:16:11 +02: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)
|
|
|
|
{
|
2017-04-11 10:16:11 +02:00
|
|
|
setValue(settingConfigurationAutosaveTime, value);
|
2015-07-15 09:16:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QString VCommonSettings::GetLocale() const
|
|
|
|
{
|
2018-01-21 15:00:53 +01:00
|
|
|
if (localeCached.isEmpty())
|
|
|
|
{
|
|
|
|
localeCached = value(settingConfigurationLocale, QLocale().name()).toString();
|
|
|
|
}
|
|
|
|
return localeCached;
|
2015-07-15 09:16:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetLocale(const QString &value)
|
|
|
|
{
|
2017-04-11 10:16:11 +02:00
|
|
|
setValue(settingConfigurationLocale, value);
|
2018-01-21 15:00:53 +01:00
|
|
|
localeCached = value;
|
2015-07-15 09:16:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-08-02 17:27:18 +02:00
|
|
|
QString VCommonSettings::GetPMSystemCode() const
|
|
|
|
{
|
2017-06-01 12:04:25 +02:00
|
|
|
return value(settingPMSystemCode, "p998").toString();
|
2015-08-02 17:27:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetPMSystemCode(const QString &value)
|
|
|
|
{
|
2017-04-11 10:16:11 +02:00
|
|
|
setValue(settingPMSystemCode, value);
|
2015-08-02 17:27:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-07-15 09:16:59 +02:00
|
|
|
QString VCommonSettings::GetUnit() const
|
|
|
|
{
|
2017-06-16 15:01:09 +02:00
|
|
|
return value(settingConfigurationUnit,
|
|
|
|
QLocale().measurementSystem() == QLocale::MetricSystem ? unitCM : unitINCH).toString();
|
2015-07-15 09:16:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetUnit(const QString &value)
|
|
|
|
{
|
2017-04-11 10:16:11 +02:00
|
|
|
setValue(settingConfigurationUnit, value);
|
2015-07-15 09:16:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool VCommonSettings::GetConfirmItemDelete() const
|
|
|
|
{
|
2017-04-11 10:16:11 +02:00
|
|
|
return value(settingConfigurationConfirmItemDeletion, 1).toBool();
|
2015-07-15 09:16:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetConfirmItemDelete(const bool &value)
|
|
|
|
{
|
2017-04-11 10:16:11 +02:00
|
|
|
setValue(settingConfigurationConfirmItemDeletion, value);
|
2015-07-15 09:16:59 +02:00
|
|
|
}
|
|
|
|
|
2017-04-12 08:49:05 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool VCommonSettings::GetConfirmFormatRewriting() const
|
|
|
|
{
|
|
|
|
return value(settingConfigurationConfirmFormatRewriting, 1).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetConfirmFormatRewriting(const bool &value)
|
|
|
|
{
|
|
|
|
setValue(settingConfigurationConfirmFormatRewriting, value);
|
|
|
|
}
|
|
|
|
|
2015-07-15 09:16:59 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool VCommonSettings::GetToolBarStyle() const
|
|
|
|
{
|
2017-04-11 10:16:11 +02:00
|
|
|
return value(settingConfigurationToolBarStyle, 1).toBool();
|
2015-07-15 09:16:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetToolBarStyle(const bool &value)
|
|
|
|
{
|
2017-04-11 10:16:11 +02:00
|
|
|
setValue(settingConfigurationToolBarStyle, value);
|
2015-07-15 09:16:59 +02:00
|
|
|
}
|
|
|
|
|
2017-10-03 12:01:56 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool VCommonSettings::IsFreeCurveMode() const
|
|
|
|
{
|
|
|
|
return value(settingConfigurationFreeCurveMode, 1).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetFreeCurveMode(bool value)
|
|
|
|
{
|
|
|
|
setValue(settingConfigurationFreeCurveMode, value);
|
|
|
|
}
|
|
|
|
|
2015-07-15 09:16:59 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
int VCommonSettings::GetUndoCount() const
|
|
|
|
{
|
|
|
|
bool ok = false;
|
2017-04-11 10:16:11 +02:00
|
|
|
int val = value(settingPatternUndo, 0).toInt(&ok);
|
2015-07-15 09:16:59 +02:00
|
|
|
if (ok == false)
|
|
|
|
{
|
2017-04-11 10:16:11 +02: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)
|
|
|
|
{
|
2017-04-11 10:16:11 +02:00
|
|
|
setValue(settingPatternUndo, value);
|
2015-07-15 09:16:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QStringList VCommonSettings::GetRecentFileList() const
|
|
|
|
{
|
2017-04-11 10:16:11 +02:00
|
|
|
const QStringList files = value(settingGeneralRecentFileList).toStringList();
|
2016-09-09 13:01:57 +02:00
|
|
|
QStringList cleared;
|
|
|
|
|
|
|
|
for (int i = 0; i < files.size(); ++i)
|
|
|
|
{
|
|
|
|
if (QFileInfo(files.at(i)).exists())
|
|
|
|
{
|
|
|
|
cleared.append(files.at(i));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return cleared;
|
2015-07-15 09:16:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetRecentFileList(const QStringList &value)
|
|
|
|
{
|
2017-04-11 10:16:11 +02:00
|
|
|
setValue(settingGeneralRecentFileList, value);
|
2015-07-15 09:16:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QStringList VCommonSettings::GetRestoreFileList() const
|
|
|
|
{
|
2017-04-11 10:16:11 +02:00
|
|
|
return value(settingGeneralRestoreFileList).toStringList();
|
2015-07-15 09:16:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetRestoreFileList(const QStringList &value)
|
|
|
|
{
|
2017-04-11 10:16:11 +02:00
|
|
|
setValue(settingGeneralRestoreFileList, value);
|
2015-07-15 09:16:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QByteArray VCommonSettings::GetGeometry() const
|
|
|
|
{
|
2017-04-11 10:16:11 +02:00
|
|
|
return value(settingGeneralGeometry).toByteArray();
|
2015-07-15 09:16:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetGeometry(const QByteArray &value)
|
|
|
|
{
|
2017-04-11 10:16:11 +02:00
|
|
|
setValue(settingGeneralGeometry, value);
|
2015-07-15 09:16:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QByteArray VCommonSettings::GetWindowState() const
|
|
|
|
{
|
2017-04-11 10:16:11 +02:00
|
|
|
return value(settingGeneralWindowState).toByteArray();
|
2015-07-15 09:16:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetWindowState(const QByteArray &value)
|
|
|
|
{
|
2017-04-11 10:16:11 +02:00
|
|
|
setValue(settingGeneralWindowState, value);
|
2015-07-15 09:16:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QByteArray VCommonSettings::GetToolbarsState() const
|
|
|
|
{
|
2017-04-11 10:16:11 +02:00
|
|
|
return value(settingGeneralToolbarsState).toByteArray();
|
2015-07-15 09:16:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetToolbarsState(const QByteArray &value)
|
|
|
|
{
|
2017-04-11 10:16:11 +02:00
|
|
|
setValue(settingGeneralToolbarsState, value);
|
2015-07-15 09:16:59 +02:00
|
|
|
}
|
2016-06-10 21:34:21 +02:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QSize VCommonSettings::GetPreferenceDialogSize() const
|
|
|
|
{
|
2017-04-11 10:16:11 +02:00
|
|
|
return value(settingPreferenceDialogSize, QSize(0, 0)).toSize();
|
2016-06-10 21:34:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetPreferenceDialogSize(const QSize& sz)
|
|
|
|
{
|
2017-04-11 10:16:11 +02: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
|
|
|
|
{
|
|
|
|
return value(settingToolSeamAllowanceDialogSize, QSize(0, 0)).toSize();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetToolSeamAllowanceDialogSize(const QSize &sz)
|
|
|
|
{
|
|
|
|
setValue(settingToolSeamAllowanceDialogSize, sz);
|
|
|
|
}
|
|
|
|
|
2017-06-16 16:05:35 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QSize VCommonSettings::GetFormulaWizardDialogSize() const
|
|
|
|
{
|
|
|
|
return value(settingFormulaWizardDialogSize, QSize(0, 0)).toSize();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetFormulaWizardDialogSize(const QSize &sz)
|
|
|
|
{
|
|
|
|
setValue(settingFormulaWizardDialogSize, sz);
|
|
|
|
}
|
|
|
|
|
2017-07-26 08:13:29 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QSize VCommonSettings::GetIncrementsDialogSize() const
|
|
|
|
{
|
|
|
|
return value(settingIncrementsDialogSize, QSize(0, 0)).toSize();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetIncrementsDialogSize(const QSize &sz)
|
|
|
|
{
|
|
|
|
setValue(settingIncrementsDialogSize, sz);
|
|
|
|
}
|
|
|
|
|
2017-09-26 16:24:02 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QSize VCommonSettings::GetFinalMeasurementsDialogSize() const
|
|
|
|
{
|
|
|
|
return value(settingFinalMeasurementsDialogSize, QSize(0, 0)).toSize();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetFinalMeasurementsDialogSize(const QSize &sz)
|
|
|
|
{
|
|
|
|
setValue(settingFinalMeasurementsDialogSize, sz);
|
|
|
|
}
|
|
|
|
|
2016-07-15 11:00:00 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
int VCommonSettings::GetLatestSkippedVersion() const
|
|
|
|
{
|
2016-07-15 12:14:48 +02:00
|
|
|
QSettings settings(this->format(), this->scope(), this->organizationName(), commonIniFilename);
|
2017-04-11 10:16:11 +02:00
|
|
|
return settings.value(settingLatestSkippedVersion, 0x0).toInt();
|
2016-07-15 11:00:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetLatestSkippedVersion(int value)
|
|
|
|
{
|
2016-07-15 12:14:48 +02:00
|
|
|
QSettings settings(this->format(), this->scope(), this->organizationName(), commonIniFilename);
|
2017-04-11 10:16:11 +02:00
|
|
|
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
|
|
|
|
{
|
2016-07-15 12:14:48 +02:00
|
|
|
QSettings settings(this->format(), this->scope(), this->organizationName(), commonIniFilename);
|
2017-04-11 10:16:11 +02:00
|
|
|
return settings.value(settingDateOfLastRemind, QDate(1900, 1, 1)).toDate();
|
2016-07-15 11:30:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetDateOfLastRemind(const QDate &date)
|
|
|
|
{
|
2016-07-15 12:14:48 +02:00
|
|
|
QSettings settings(this->format(), this->scope(), this->organizationName(), commonIniFilename);
|
2017-04-11 10:16:11 +02:00
|
|
|
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
|
|
|
|
{
|
2017-04-11 10:16:11 +02:00
|
|
|
return value(settingPatternForbidFlipping, false).toBool();
|
2016-09-06 16:05:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetForbidWorkpieceFlipping(bool value)
|
|
|
|
{
|
2017-04-11 10:16:11 +02:00
|
|
|
setValue(settingPatternForbidFlipping, value);
|
2017-12-17 14:06:46 +01:00
|
|
|
|
|
|
|
if (value)
|
|
|
|
{
|
|
|
|
SetForceWorkpieceFlipping(not value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool VCommonSettings::GetForceWorkpieceFlipping() const
|
|
|
|
{
|
|
|
|
return value(settingPatternForceFlipping, false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetForceWorkpieceFlipping(bool value)
|
|
|
|
{
|
|
|
|
setValue(settingPatternForceFlipping, value);
|
|
|
|
|
|
|
|
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
|
|
|
|
{
|
|
|
|
return value(settingPatternHideMainPath, false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetHideMainPath(bool value)
|
|
|
|
{
|
|
|
|
setValue(settingPatternHideMainPath, value);
|
|
|
|
}
|
|
|
|
|
2017-04-05 12:22:33 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool VCommonSettings::IsDoublePassmark() const
|
|
|
|
{
|
2017-04-11 10:16:11 +02:00
|
|
|
return value(settingDoublePassmark, false).toBool();
|
2017-04-05 12:22:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetDoublePassmark(bool value)
|
|
|
|
{
|
2017-04-11 10:16:11 +02: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)
|
|
|
|
{
|
|
|
|
QSettings settings(this->format(), this->scope(), this->organizationName(), commonIniFilename);
|
|
|
|
settings.setValue(settingCSVWithHeader, withHeader);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool VCommonSettings::GetCSVWithHeader() const
|
|
|
|
{
|
|
|
|
QSettings settings(this->format(), this->scope(), this->organizationName(), commonIniFilename);
|
|
|
|
return settings.value(settingCSVWithHeader, GetDefCSVWithHeader()).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
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)
|
|
|
|
{
|
|
|
|
QSettings settings(this->format(), this->scope(), this->organizationName(), commonIniFilename);
|
|
|
|
settings.setValue(settingCSVCodec, mib);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
int VCommonSettings::GetCSVCodec() const
|
|
|
|
{
|
|
|
|
QSettings settings(this->format(), this->scope(), this->organizationName(), commonIniFilename);
|
|
|
|
return settings.value(settingCSVCodec, GetDefCSVCodec()).toInt();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
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)
|
|
|
|
{
|
|
|
|
QSettings settings(this->format(), this->scope(), this->organizationName(), commonIniFilename);
|
|
|
|
switch(separator.toLatin1())
|
|
|
|
{
|
|
|
|
case '\t':
|
|
|
|
settings.setValue(settingCSVSeparator, 0);
|
|
|
|
break;
|
|
|
|
case ';':
|
|
|
|
settings.setValue(settingCSVSeparator, 1);
|
|
|
|
break;
|
|
|
|
case ' ':
|
|
|
|
settings.setValue(settingCSVSeparator, 2);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
settings.setValue(settingCSVSeparator, 3);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QChar VCommonSettings::GetCSVSeparator() const
|
|
|
|
{
|
|
|
|
QSettings settings(this->format(), this->scope(), this->organizationName(), commonIniFilename);
|
|
|
|
const quint8 separator = static_cast<quint8>(settings.value(settingCSVSeparator, 3).toUInt());
|
|
|
|
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)
|
|
|
|
{
|
2017-07-03 10:23:34 +02: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;
|
2017-07-03 10:23:34 +02:00
|
|
|
double val = value(settingPatternDefaultSeamAllowance, -1).toDouble(&ok);
|
2017-07-02 10:14:01 +02:00
|
|
|
if (ok == false)
|
|
|
|
{
|
|
|
|
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 "
|
2017-07-02 10:14:01 +02:00
|
|
|
<< defaultValue << ".";
|
|
|
|
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
|
|
|
|
{
|
2017-08-19 18:10:57 +02: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)
|
|
|
|
{
|
2017-08-19 18:10:57 +02:00
|
|
|
setValue(settingPatternLabelFont, f);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QString VCommonSettings::GetLabelDateFormat() const
|
|
|
|
{
|
|
|
|
const QString format = value(settingLabelDateFormat, VCommonSettings::PredefinedDateFormats().first()).toString();
|
|
|
|
const QStringList allFormats = VCommonSettings::PredefinedDateFormats() + GetUserDefinedDateFormats();
|
|
|
|
|
|
|
|
if (allFormats.contains(format))
|
|
|
|
{
|
|
|
|
return format;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return VCommonSettings::PredefinedDateFormats().first();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetLabelDateFormat(const QString &format)
|
|
|
|
{
|
|
|
|
setValue(settingLabelDateFormat, format);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QStringList VCommonSettings::PredefinedDateFormats()
|
|
|
|
{
|
|
|
|
QStringList formats = 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";
|
|
|
|
return formats;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QStringList VCommonSettings::GetUserDefinedDateFormats() const
|
|
|
|
{
|
|
|
|
return value(settingLabelUserDateFormats, QStringList()).toStringList();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetUserDefinedDateFormats(const QStringList &formats)
|
|
|
|
{
|
|
|
|
setValue(settingLabelUserDateFormats, ClearFormats(VCommonSettings::PredefinedDateFormats(), formats));
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QString VCommonSettings::GetLabelTimeFormat() const
|
|
|
|
{
|
|
|
|
const QString format = value(settingLabelTimeFormat, VCommonSettings::PredefinedTimeFormats().first()).toString();
|
|
|
|
const QStringList allFormats = VCommonSettings::PredefinedTimeFormats() + GetUserDefinedTimeFormats();
|
|
|
|
|
|
|
|
if (allFormats.contains(format))
|
|
|
|
{
|
|
|
|
return format;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return VCommonSettings::PredefinedTimeFormats().first();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetLabelTimeFormat(const QString &format)
|
|
|
|
{
|
|
|
|
setValue(settingLabelTimeFormat, format);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QStringList VCommonSettings::PredefinedTimeFormats()
|
|
|
|
{
|
|
|
|
QStringList formats = QStringList() << "hh:mm:ss"
|
|
|
|
<< "hh:mm:ss AP"
|
|
|
|
<< "hh:mm"
|
|
|
|
<< "hh:mm AP";
|
|
|
|
return formats;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QStringList VCommonSettings::GetUserDefinedTimeFormats() const
|
|
|
|
{
|
|
|
|
return value(settingLabelUserTimeFormats, QStringList()).toStringList();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetUserDefinedTimeFormats(const QStringList &formats)
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
const qreal scale = value(settingPatternCurveApproximationScale, defCurveApproximationScale).toDouble(&ok);
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
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
|
|
|
|
{
|
|
|
|
return value(settingPatternShowCurveDetails, false).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetShowCurveDetails(bool value)
|
|
|
|
{
|
|
|
|
setValue(settingPatternShowCurveDetails, value);
|
|
|
|
}
|