2014-11-22 17:15:47 +01:00
|
|
|
/************************************************************************
|
|
|
|
**
|
|
|
|
** @file vsettings.cpp
|
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
|
|
|
** @date 22 11, 2014
|
|
|
|
**
|
|
|
|
** @brief
|
|
|
|
** @copyright
|
|
|
|
** This source code is part of the Valentine project, a pattern making
|
|
|
|
** program, whose allow create and modeling patterns of clothing.
|
2015-02-27 11:27:48 +01:00
|
|
|
** Copyright (C) 2013-2015 Valentina project
|
2014-11-22 17:15:47 +01:00
|
|
|
** <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 "vsettings.h"
|
|
|
|
|
|
|
|
#include <QDir>
|
2014-11-28 19:33:28 +01:00
|
|
|
#include <QLocale>
|
2016-08-08 13:44:49 +02:00
|
|
|
#include <QMetaType>
|
2015-11-09 12:33:36 +01:00
|
|
|
#include <QPrinter>
|
|
|
|
#include <QSharedPointer>
|
2016-08-08 13:44:49 +02:00
|
|
|
#include <QStaticStringData>
|
|
|
|
#include <QStringData>
|
|
|
|
#include <QStringDataPtr>
|
|
|
|
#include <QVariant>
|
2014-11-22 17:15:47 +01:00
|
|
|
|
2016-08-09 15:55:46 +02:00
|
|
|
#include "../vmisc/def.h"
|
2016-08-08 13:44:49 +02:00
|
|
|
|
|
|
|
class QMarginsF;
|
2015-05-08 16:24:20 +02:00
|
|
|
|
2015-05-11 10:02:38 +02:00
|
|
|
#if QT_VERSION < QT_VERSION_CHECK(5, 1, 0)
|
2015-10-08 19:07:48 +02:00
|
|
|
# include "../vmisc/vmath.h"
|
2015-05-11 10:02:38 +02:00
|
|
|
#else
|
|
|
|
#endif
|
|
|
|
|
2015-11-16 13:07:28 +01:00
|
|
|
Q_DECLARE_METATYPE(QMarginsF)
|
|
|
|
|
2015-03-02 18:11:43 +01:00
|
|
|
const QString VSettings::SettingConfigurationLabelLanguage = QStringLiteral("configuration/label_language");
|
2014-11-22 17:15:47 +01:00
|
|
|
|
2015-03-02 18:11:43 +01:00
|
|
|
const QString VSettings::SettingPathsPattern = QStringLiteral("paths/pattern");
|
|
|
|
const QString VSettings::SettingPathsLayout = QStringLiteral("paths/layout");
|
2014-11-22 17:15:47 +01:00
|
|
|
|
2015-03-02 18:11:43 +01:00
|
|
|
const QString VSettings::SettingPatternGraphicalOutput = QStringLiteral("pattern/graphicalOutput");
|
2014-11-22 17:15:47 +01:00
|
|
|
|
2015-03-02 18:11:43 +01:00
|
|
|
const QString VSettings::SettingCommunityServer = QStringLiteral("community/server");
|
|
|
|
const QString VSettings::SettingCommunityServerSecure = QStringLiteral("community/serverSecure");
|
|
|
|
const QString VSettings::SettingCommunityUseProxy = QStringLiteral("community/useProxy");
|
|
|
|
const QString VSettings::SettingCommunityProxyAddress = QStringLiteral("community/proxyAddress");
|
|
|
|
const QString VSettings::SettingCommunityProxyPort = QStringLiteral("community/proxyPort");
|
|
|
|
const QString VSettings::SettingCommunityProxyUser = QStringLiteral("community/proxyUser");
|
|
|
|
const QString VSettings::SettingCommunityProxyPass = QStringLiteral("community/proxyPass");
|
|
|
|
const QString VSettings::SettingCommunityUsername = QStringLiteral("community/username");
|
|
|
|
const QString VSettings::SettingCommunitySavePassword = QStringLiteral("community/savePassword");
|
|
|
|
const QString VSettings::SettingCommunityUserPassword = QStringLiteral("community/userpassword");
|
2014-11-22 17:15:47 +01:00
|
|
|
|
2015-05-08 16:24:20 +02:00
|
|
|
const QString VSettings::SettingLayoutWidth = QStringLiteral("layout/width");
|
|
|
|
const QString VSettings::SettingLayoutSorting = QStringLiteral("layout/sorting");
|
|
|
|
const QString VSettings::SettingLayoutPaperHeight = QStringLiteral("layout/paperHeight");
|
|
|
|
const QString VSettings::SettingLayoutPaperWidth = QStringLiteral("layout/paperWidth");
|
|
|
|
const QString VSettings::SettingLayoutShift = QStringLiteral("layout/shift");
|
|
|
|
const QString VSettings::SettingLayoutRotate = QStringLiteral("layout/Rotate");
|
|
|
|
const QString VSettings::SettingLayoutRotationIncrease = QStringLiteral("layout/rotationIncrease");
|
|
|
|
const QString VSettings::SettingLayoutAutoCrop = QStringLiteral("layout/autoCrop");
|
|
|
|
const QString VSettings::SettingLayoutSaveLength = QStringLiteral("layout/saveLength");
|
2015-05-18 13:26:37 +02:00
|
|
|
const QString VSettings::SettingLayoutUnitePages = QStringLiteral("layout/unitePages");
|
2015-11-09 12:33:36 +01:00
|
|
|
const QString VSettings::SettingFields = QStringLiteral("layout/fields");
|
|
|
|
const QString VSettings::SettingIgnoreFields = QStringLiteral("layout/ignoreFields");
|
2016-02-23 13:13:10 +01:00
|
|
|
const QString VSettings::SettingStripOptimization = QStringLiteral("layout/stripOptimization");
|
|
|
|
const QString VSettings::SettingMultiplier = QStringLiteral("layout/multiplier");
|
2015-05-08 16:24:20 +02:00
|
|
|
|
2014-11-22 17:15:47 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
VSettings::VSettings(Format format, Scope scope, const QString &organization, const QString &application,
|
|
|
|
QObject *parent)
|
2015-07-15 09:16:59 +02:00
|
|
|
:VCommonSettings(format, scope, organization, application, parent)
|
2015-11-09 12:33:36 +01:00
|
|
|
{
|
|
|
|
qRegisterMetaTypeStreamOperators<QMarginsF>("QMarginsF");
|
|
|
|
}
|
2014-11-22 17:15:47 +01:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-11-28 19:41:46 +01:00
|
|
|
QString VSettings::GetLabelLanguage() const
|
2014-11-22 17:15:47 +01:00
|
|
|
{
|
|
|
|
return value(SettingConfigurationLabelLanguage, QLocale::system().bcp47Name()).toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VSettings::SetLabelLanguage(const QString &value)
|
|
|
|
{
|
|
|
|
setValue(SettingConfigurationLabelLanguage, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-11-28 19:41:46 +01:00
|
|
|
QString VSettings::GetPathPattern() const
|
2014-11-22 17:15:47 +01:00
|
|
|
{
|
2015-10-18 15:17:56 +02:00
|
|
|
QSettings settings(this->format(), this->scope(), this->organizationName(), this->applicationName());
|
2015-10-18 14:38:05 +02:00
|
|
|
return settings.value(SettingPathsPattern, QDir::homePath()).toString();
|
2014-11-22 17:15:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VSettings::SetPathPattern(const QString &value)
|
|
|
|
{
|
2015-10-18 15:13:51 +02:00
|
|
|
QSettings settings(this->format(), this->scope(), this->organizationName(), this->applicationName());
|
2015-10-18 14:38:05 +02:00
|
|
|
settings.setValue(SettingPathsPattern, value);
|
|
|
|
settings.sync();
|
2014-11-22 17:15:47 +01:00
|
|
|
}
|
|
|
|
|
2015-01-26 15:08:09 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QString VSettings::GetPathLayout() const
|
|
|
|
{
|
2015-10-18 15:13:51 +02:00
|
|
|
QSettings settings(this->format(), this->scope(), this->organizationName(), this->applicationName());
|
2015-10-18 14:38:05 +02:00
|
|
|
return settings.value(SettingPathsLayout, QDir::homePath()).toString();
|
2015-01-26 15:08:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VSettings::SetPathLayout(const QString &value)
|
|
|
|
{
|
2015-10-18 15:13:51 +02:00
|
|
|
QSettings settings(this->format(), this->scope(), this->organizationName(), this->applicationName());
|
2015-10-18 14:38:05 +02:00
|
|
|
settings.setValue(SettingPathsLayout, value);
|
|
|
|
settings.sync();
|
2015-01-26 15:08:09 +01:00
|
|
|
}
|
|
|
|
|
2014-11-22 17:15:47 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-11-28 19:41:46 +01:00
|
|
|
bool VSettings::GetGraphicalOutput() const
|
2014-11-22 17:15:47 +01:00
|
|
|
{
|
|
|
|
return value(SettingPatternGraphicalOutput, 1).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VSettings::SetGraphicalOutput(const bool &value)
|
|
|
|
{
|
|
|
|
setValue(SettingPatternGraphicalOutput, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-11-28 19:41:46 +01:00
|
|
|
QString VSettings::GetServer() const
|
2014-11-22 17:15:47 +01:00
|
|
|
{
|
|
|
|
return value(SettingCommunityServer, "community.valentina-project.org").toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VSettings::SetServer(const QString &value)
|
|
|
|
{
|
|
|
|
setValue(SettingCommunityServer, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-11-28 19:41:46 +01:00
|
|
|
bool VSettings::GetServerSecure() const
|
2014-11-22 17:15:47 +01:00
|
|
|
{
|
|
|
|
return value(SettingCommunityServerSecure, 0).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VSettings::SetServerSecure(const bool &value)
|
|
|
|
{
|
|
|
|
setValue(SettingCommunityServerSecure, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-11-28 19:41:46 +01:00
|
|
|
bool VSettings::GetProxy() const
|
2014-11-22 17:15:47 +01:00
|
|
|
{
|
|
|
|
return value(SettingCommunityUseProxy, 0).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VSettings::SetProxy(const bool &value)
|
|
|
|
{
|
|
|
|
setValue(SettingCommunityUseProxy, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-11-28 19:41:46 +01:00
|
|
|
QString VSettings::GetProxyAddress() const
|
2014-11-22 17:15:47 +01:00
|
|
|
{
|
|
|
|
return value(SettingCommunityProxyAddress).toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VSettings::SetProxyAddress(const QString &value)
|
|
|
|
{
|
|
|
|
setValue(SettingCommunityProxyAddress, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-11-28 19:41:46 +01:00
|
|
|
QString VSettings::GetProxyPort() const
|
2014-11-22 17:15:47 +01:00
|
|
|
{
|
|
|
|
return value(SettingCommunityProxyPort).toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VSettings::SetProxyPort(const QString &value)
|
|
|
|
{
|
|
|
|
setValue(SettingCommunityProxyPort, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-11-28 19:41:46 +01:00
|
|
|
QString VSettings::GetProxyUser() const
|
2014-11-22 17:15:47 +01:00
|
|
|
{
|
|
|
|
return value(SettingCommunityProxyUser).toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VSettings::SetProxyUser(const QString &value)
|
|
|
|
{
|
|
|
|
setValue(SettingCommunityProxyUser, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-11-28 19:41:46 +01:00
|
|
|
QString VSettings::GetProxyPass() const
|
2014-11-22 17:15:47 +01:00
|
|
|
{
|
|
|
|
return value(SettingCommunityProxyPass).toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VSettings::SetProxyPass(const QString &value)
|
|
|
|
{
|
|
|
|
setValue(SettingCommunityProxyPass, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-11-28 19:41:46 +01:00
|
|
|
QString VSettings::GetUsername() const
|
2014-11-22 17:15:47 +01:00
|
|
|
{
|
|
|
|
return value(SettingCommunityUsername).toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VSettings::SetUsername(const QString &value)
|
|
|
|
{
|
|
|
|
setValue(SettingCommunityUsername, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-11-28 19:41:46 +01:00
|
|
|
bool VSettings::GetSavePassword() const
|
2014-11-22 17:15:47 +01:00
|
|
|
{
|
|
|
|
return value(SettingCommunitySavePassword, 0).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VSettings::SetSavePassword(const bool &value)
|
|
|
|
{
|
|
|
|
setValue(SettingCommunitySavePassword, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-11-28 19:41:46 +01:00
|
|
|
QString VSettings::GetUserPassword() const
|
2014-11-22 17:15:47 +01:00
|
|
|
{
|
|
|
|
return value(SettingCommunityUserPassword).toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VSettings::SetUserPassword(const QString &value)
|
|
|
|
{
|
|
|
|
setValue(SettingCommunityUserPassword, value);
|
|
|
|
}
|
2015-01-28 15:46:41 +01:00
|
|
|
|
2015-05-08 16:24:20 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-11-05 12:07:51 +01:00
|
|
|
qreal VSettings::GetLayoutPaperHeight() const
|
2015-05-08 16:24:20 +02:00
|
|
|
{
|
2015-11-05 12:07:51 +01:00
|
|
|
const qreal def = UnitConvertor(1189/*A0*/, Unit::Mm, Unit::Px);
|
2015-05-08 16:24:20 +02:00
|
|
|
bool ok = false;
|
2015-11-05 12:07:51 +01:00
|
|
|
const qreal height = value(SettingLayoutPaperHeight, def).toDouble(&ok);
|
2015-05-08 16:24:20 +02:00
|
|
|
if (ok)
|
|
|
|
{
|
|
|
|
return height;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return def;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-11-05 12:07:51 +01:00
|
|
|
void VSettings::SetLayoutPaperHeight(qreal value)
|
2015-05-08 16:24:20 +02:00
|
|
|
{
|
|
|
|
setValue(SettingLayoutPaperHeight, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-11-05 12:07:51 +01:00
|
|
|
qreal VSettings::GetLayoutPaperWidth() const
|
2015-05-08 16:24:20 +02:00
|
|
|
{
|
2015-11-05 12:07:51 +01:00
|
|
|
const qreal def = UnitConvertor(841/*A0*/, Unit::Mm, Unit::Px);
|
2015-05-08 16:24:20 +02:00
|
|
|
bool ok = false;
|
2015-11-05 12:07:51 +01:00
|
|
|
const qreal width = value(SettingLayoutPaperWidth, def).toDouble(&ok);
|
2015-05-08 16:24:20 +02:00
|
|
|
if (ok)
|
|
|
|
{
|
|
|
|
return width;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return def;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-11-05 12:07:51 +01:00
|
|
|
void VSettings::SetLayoutPaperWidth(qreal value)
|
2015-05-08 16:24:20 +02:00
|
|
|
{
|
|
|
|
setValue(SettingLayoutPaperWidth, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-11-05 13:32:47 +01:00
|
|
|
qreal VSettings::GetLayoutShift() const
|
2015-05-08 16:24:20 +02:00
|
|
|
{
|
2015-11-05 13:32:47 +01:00
|
|
|
const qreal def = GetDefLayoutShift();
|
2015-05-08 16:24:20 +02:00
|
|
|
bool ok = false;
|
2015-11-05 13:32:47 +01:00
|
|
|
const qreal shift = value(SettingLayoutShift, def).toDouble(&ok);
|
2015-05-08 16:24:20 +02:00
|
|
|
if (ok)
|
|
|
|
{
|
|
|
|
return shift;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return def;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-11-05 12:07:51 +01:00
|
|
|
qreal VSettings::GetDefLayoutShift()
|
2015-05-08 16:24:20 +02:00
|
|
|
{
|
2016-03-28 16:19:29 +02:00
|
|
|
return 0;
|
2015-05-08 16:24:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-11-05 13:32:47 +01:00
|
|
|
void VSettings::SetLayoutShift(qreal value)
|
2015-05-08 16:24:20 +02:00
|
|
|
{
|
|
|
|
setValue(SettingLayoutShift, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-11-05 13:32:47 +01:00
|
|
|
qreal VSettings::GetLayoutWidth() const
|
2015-05-08 16:24:20 +02:00
|
|
|
{
|
2015-11-05 13:32:47 +01:00
|
|
|
const qreal def = GetDefLayoutWidth();
|
2015-05-08 16:24:20 +02:00
|
|
|
bool ok = false;
|
2015-11-05 13:32:47 +01:00
|
|
|
const qreal lWidth = value(SettingLayoutWidth, def).toDouble(&ok);
|
2015-05-08 16:24:20 +02:00
|
|
|
if (ok)
|
|
|
|
{
|
|
|
|
return lWidth;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return def;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-11-05 12:07:51 +01:00
|
|
|
qreal VSettings::GetDefLayoutWidth()
|
2015-05-08 16:24:20 +02:00
|
|
|
{
|
2015-11-05 12:07:51 +01:00
|
|
|
return UnitConvertor(2.5, Unit::Mm, Unit::Px);
|
2015-05-08 16:24:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-11-05 13:32:47 +01:00
|
|
|
void VSettings::SetLayoutWidth(qreal value)
|
2015-05-08 16:24:20 +02:00
|
|
|
{
|
|
|
|
setValue(SettingLayoutWidth, value);
|
|
|
|
}
|
|
|
|
|
2015-11-09 12:33:36 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QMarginsF VSettings::GetFields() const
|
|
|
|
{
|
|
|
|
const QMarginsF def = GetDefFields();
|
|
|
|
const QVariant val = value(SettingFields, QVariant::fromValue(def));
|
|
|
|
if (val.canConvert<QMarginsF>())
|
|
|
|
{
|
|
|
|
return val.value<QMarginsF>();
|
|
|
|
}
|
|
|
|
return def;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QMarginsF VSettings::GetDefFields()
|
|
|
|
{
|
|
|
|
QSharedPointer<QPrinter> printer = DefaultPrinter();
|
|
|
|
if (printer.isNull())
|
|
|
|
{
|
|
|
|
return QMarginsF();
|
|
|
|
}
|
|
|
|
|
|
|
|
qreal left = 0;
|
|
|
|
qreal top = 0;
|
|
|
|
qreal right = 0;
|
|
|
|
qreal bottom = 0;
|
|
|
|
printer->getPageMargins(&left, &top, &right, &bottom, QPrinter::Millimeter);
|
|
|
|
// We can't use Unit::Px because our dpi in most cases is different
|
|
|
|
QMarginsF def;
|
|
|
|
def.setLeft(UnitConvertor(left, Unit::Mm, Unit::Px));
|
|
|
|
def.setRight(UnitConvertor(right, Unit::Mm, Unit::Px));
|
|
|
|
def.setTop(UnitConvertor(top, Unit::Mm, Unit::Px));
|
|
|
|
def.setBottom(UnitConvertor(bottom, Unit::Mm, Unit::Px));
|
|
|
|
return def;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VSettings::SetFields(const QMarginsF &value)
|
|
|
|
{
|
|
|
|
QVariant val = QVariant::fromValue(value);
|
|
|
|
QString str = val.toString();
|
|
|
|
setValue(SettingFields, val);
|
|
|
|
}
|
|
|
|
|
2015-05-08 16:24:20 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
Cases VSettings::GetLayoutGroup() const
|
|
|
|
{
|
|
|
|
const Cases def = GetDefLayoutGroup();
|
|
|
|
bool ok = false;
|
|
|
|
const int g = value(SettingLayoutSorting, static_cast<int>(def)).toInt(&ok);
|
|
|
|
if (ok)
|
|
|
|
{
|
|
|
|
if (g >= static_cast<int>(Cases::UnknownCase))
|
|
|
|
{
|
|
|
|
return def;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return static_cast<Cases>(g);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return def;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
Cases VSettings::GetDefLayoutGroup()
|
|
|
|
{
|
|
|
|
return Cases::CaseDesc;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VSettings::SetLayoutGroup(const Cases &value)
|
|
|
|
{
|
|
|
|
setValue(SettingLayoutSorting, static_cast<int>(value));
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool VSettings::GetLayoutRotate() const
|
|
|
|
{
|
|
|
|
return value(SettingLayoutRotate, GetDefLayoutRotate()).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool VSettings::GetDefLayoutRotate()
|
|
|
|
{
|
2016-03-28 16:19:29 +02:00
|
|
|
return false;
|
2015-05-08 16:24:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VSettings::SetLayoutRotate(bool value)
|
|
|
|
{
|
|
|
|
setValue(SettingLayoutRotate, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
int VSettings::GetLayoutRotationIncrease() const
|
|
|
|
{
|
|
|
|
const int def = GetDefLayoutRotationIncrease();
|
|
|
|
bool ok = false;
|
|
|
|
const int r = value(SettingLayoutRotationIncrease, def).toInt(&ok);
|
|
|
|
if (ok)
|
|
|
|
{
|
|
|
|
if (not (r >= 1 && r <= 180 && 360 % r == 0))
|
|
|
|
{
|
|
|
|
return def;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return def;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
int VSettings::GetDefLayoutRotationIncrease()
|
|
|
|
{
|
|
|
|
return 180;/*degree*/
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VSettings::SetLayoutRotationIncrease(int value)
|
|
|
|
{
|
|
|
|
setValue(SettingLayoutRotationIncrease, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool VSettings::GetLayoutAutoCrop() const
|
|
|
|
{
|
2015-11-09 12:33:36 +01:00
|
|
|
return value(SettingLayoutAutoCrop, GetDefLayoutAutoCrop()).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool VSettings::GetDefLayoutAutoCrop()
|
|
|
|
{
|
|
|
|
return false;
|
2015-05-08 16:24:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VSettings::SetLayoutAutoCrop(bool value)
|
|
|
|
{
|
|
|
|
setValue(SettingLayoutAutoCrop, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool VSettings::GetLayoutSaveLength() const
|
|
|
|
{
|
2015-11-09 12:33:36 +01:00
|
|
|
return value(SettingLayoutSaveLength, GetDefLayoutSaveLength()).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool VSettings::GetDefLayoutSaveLength()
|
|
|
|
{
|
|
|
|
return false;
|
2015-05-08 16:24:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VSettings::SetLayoutSaveLength(bool value)
|
|
|
|
{
|
|
|
|
setValue(SettingLayoutSaveLength, value);
|
|
|
|
}
|
|
|
|
|
2015-05-18 13:26:37 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool VSettings::GetLayoutUnitePages() const
|
|
|
|
{
|
2015-11-09 12:33:36 +01:00
|
|
|
return value(SettingLayoutUnitePages, GetDefLayoutUnitePages()).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool VSettings::GetDefLayoutUnitePages()
|
|
|
|
{
|
|
|
|
return false;
|
2015-05-18 13:26:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VSettings::SetLayoutUnitePages(bool value)
|
|
|
|
{
|
|
|
|
setValue(SettingLayoutUnitePages, value);
|
|
|
|
}
|
|
|
|
|
2015-11-09 12:33:36 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool VSettings::GetIgnoreAllFields() const
|
|
|
|
{
|
|
|
|
return value(SettingIgnoreFields, GetDefIgnoreAllFields()).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool VSettings::GetDefIgnoreAllFields()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VSettings::SetIgnoreAllFields(bool value)
|
|
|
|
{
|
|
|
|
setValue(SettingIgnoreFields, value);
|
|
|
|
}
|
2016-02-23 13:13:10 +01:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool VSettings::GetStripOptimization() const
|
|
|
|
{
|
|
|
|
return value(SettingStripOptimization, GetDefStripOptimization()).toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool VSettings::GetDefStripOptimization()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VSettings::SetStripOptimization(bool value)
|
|
|
|
{
|
|
|
|
setValue(SettingStripOptimization, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
quint8 VSettings::GetMultiplier() const
|
|
|
|
{
|
|
|
|
return static_cast<quint8>(value(SettingMultiplier, GetDefMultiplier()).toUInt());
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
quint8 VSettings::GetDefMultiplier()
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VSettings::SetMultiplier(quint8 value)
|
|
|
|
{
|
|
|
|
setValue(SettingMultiplier, value);
|
|
|
|
}
|