2015-07-15 09:16:59 +02:00
|
|
|
/************************************************************************
|
|
|
|
**
|
|
|
|
** @file vcommonsettings.cpp
|
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
|
|
|
** @date 15 7, 2015
|
|
|
|
**
|
|
|
|
** @brief
|
|
|
|
** @copyright
|
|
|
|
** This source code is part of the Valentine project, a pattern making
|
|
|
|
** 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>
|
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-04-11 10:16:11 +02:00
|
|
|
const QString settingPathsIndividualMeasurements = QStringLiteral("paths/individual_measurements");
|
|
|
|
const QString settingPathsStandardMeasurements = QStringLiteral("paths/standard_measurements");
|
|
|
|
const QString settingPathsTemplates = QStringLiteral("paths/templates");
|
|
|
|
|
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 settingConfigurationSendReportState = QStringLiteral("configuration/send_report/state");
|
|
|
|
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-04-11 10:16:11 +02:00
|
|
|
|
|
|
|
const QString settingPatternUser = QStringLiteral("pattern/user");
|
|
|
|
const QString settingPatternUndo = QStringLiteral("pattern/undo");
|
|
|
|
const QString settingPatternForbidFlipping = QStringLiteral("pattern/forbidFlipping");
|
2017-05-16 14:16:50 +02:00
|
|
|
const QString settingPatternHideMainPath = QStringLiteral("pattern/hideMainPath");
|
2017-04-11 10:16:11 +02:00
|
|
|
const QString settingDoublePassmark = QStringLiteral("pattern/doublePassmark");
|
|
|
|
|
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-06-16 16:05:35 +02:00
|
|
|
const QString settingFormulaWizardDialogSize = QStringLiteral("formulaWizardDialogSize");
|
2017-05-30 10:47:27 +02:00
|
|
|
const QString settingLatestSkippedVersion = QStringLiteral("lastestSkippedVersion");
|
|
|
|
const QString settingDateOfLastRemind = QStringLiteral("dateOfLastRemind");
|
|
|
|
const QString settingUserDefinedMaterials = QStringLiteral("configuration/userDefinedMaterials");
|
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");
|
|
|
|
|
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
|
|
|
|
|
|
|
|
if (QFile::exists(to))
|
|
|
|
{
|
|
|
|
if (replaceOnConflit)
|
|
|
|
{
|
|
|
|
QFile::remove(to);
|
|
|
|
}
|
2017-02-17 19:37:49 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
2016-10-30 13:34:55 +01:00
|
|
|
return QApplication::applicationDirPath() + shareItem;
|
2015-11-18 13:42:25 +01:00
|
|
|
#elif defined(Q_OS_MAC)
|
2016-10-30 13:34:55 +01:00
|
|
|
QDir dirBundle(QApplication::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
|
|
|
|
return QApplication::applicationDirPath() + shareItem;
|
|
|
|
#else
|
|
|
|
QDir dir(QApplication::applicationDirPath() + shareItem);
|
|
|
|
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
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QString VCommonSettings::StandardTablesPath()
|
|
|
|
{
|
|
|
|
return SharePath(QStringLiteral("/tables/standard"));
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
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-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-06-05 16:52:42 +02:00
|
|
|
QString VCommonSettings::PrepareStandardTables(const QString ¤tPath)
|
2017-02-17 19:37:49 +01:00
|
|
|
{
|
2017-06-05 16:52:42 +02:00
|
|
|
return PrepareStandardFiles(currentPath, StandardTablesPath(), GetDefPathStandardMeasurements());
|
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
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QString VCommonSettings::GetDefPathStandardMeasurements()
|
|
|
|
{
|
|
|
|
return QDir::homePath() + QLatin1String("/valentina/") + tr("measurements") + QLatin1String("/") + tr("multisize");
|
|
|
|
}
|
|
|
|
|
2015-07-18 14:39:33 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QString VCommonSettings::GetPathStandardMeasurements() 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(settingPathsStandardMeasurements, GetDefPathStandardMeasurements()).toString();
|
2015-07-18 14:39:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetPathStandardMeasurements(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(settingPathsStandardMeasurements, 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
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool VCommonSettings::GetSendReportState() const
|
|
|
|
{
|
2017-04-11 10:16:11 +02:00
|
|
|
return value(settingConfigurationSendReportState, 1).toBool();
|
2015-07-15 09:16:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetSendReportState(const bool &value)
|
|
|
|
{
|
2017-04-11 10:16:11 +02:00
|
|
|
setValue(settingConfigurationSendReportState, value);
|
2015-07-15 09:16:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QString VCommonSettings::GetLocale() const
|
|
|
|
{
|
2017-04-11 10:16:11 +02:00
|
|
|
return value(settingConfigurationLocale, QLocale().name()).toString();
|
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);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QString VCommonSettings::GetUser() const
|
|
|
|
{
|
|
|
|
QString user;
|
|
|
|
#ifdef Q_OS_WIN
|
2017-04-14 16:47:39 +02:00
|
|
|
user = value(settingPatternUser, QString::fromLocal8Bit(qgetenv("USERNAME").constData())).toString();
|
2015-07-15 09:16:59 +02:00
|
|
|
#else
|
2017-04-11 10:16:11 +02:00
|
|
|
user = value(settingPatternUser, QString::fromLocal8Bit(qgetenv("USER").constData())).toString();
|
2015-07-15 09:16:59 +02:00
|
|
|
#endif
|
|
|
|
return user;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::SetUser(const QString &value)
|
|
|
|
{
|
2017-04-11 10:16:11 +02:00
|
|
|
setValue(settingPatternUser, 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);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QStringList VCommonSettings::GetUserDefinedMaterials() const
|
|
|
|
{
|
2017-04-11 10:16:11 +02:00
|
|
|
return value(settingUserDefinedMaterials).toStringList();
|
2016-08-12 01:22:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::AddUserDefinedMaterial(QString qsMaterial)
|
|
|
|
{
|
|
|
|
QStringList qsl = GetUserDefinedMaterials();
|
|
|
|
qsl << qsMaterial;
|
2017-04-11 10:16:11 +02:00
|
|
|
setValue(settingUserDefinedMaterials, qsl);
|
2016-08-12 01:22:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VCommonSettings::ClearUserDefinedMaterial()
|
|
|
|
{
|
|
|
|
QStringList qsl;
|
2017-04-11 10:16:11 +02:00
|
|
|
setValue(settingUserDefinedMaterials, qsl);
|
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);
|
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();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool VCommonSettings::GetDefCSVWithHeader() const
|
|
|
|
{
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
int VCommonSettings::GetDefCSVCodec() const
|
|
|
|
{
|
|
|
|
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(',');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QChar VCommonSettings::GetDefCSVSeparator() const
|
|
|
|
{
|
|
|
|
return QChar(',');
|
|
|
|
}
|