Refactoring. Keep access to all settings in one place.
--HG-- branch : develop
This commit is contained in:
parent
6e0ff89b6a
commit
85f8035b26
|
@ -30,6 +30,7 @@
|
|||
#include "../container/calculator.h"
|
||||
#include "../container/vcontainer.h"
|
||||
#include "../core/vapplication.h"
|
||||
#include "../core/vsettings.h"
|
||||
#include <QDebug>
|
||||
|
||||
//VFormula
|
||||
|
@ -239,7 +240,7 @@ void VFormula::Eval()
|
|||
else
|
||||
{
|
||||
QLocale loc;
|
||||
if (qApp->getSettings()->value("configuration/osSeparator", 1).toBool())
|
||||
if (qApp->getSettings()->GetOsSeparator())
|
||||
{
|
||||
loc = QLocale::system();
|
||||
}
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
HEADERS += \
|
||||
core/vapplication.h \
|
||||
core/vtranslation.h \
|
||||
core/undoevent.h
|
||||
core/undoevent.h \
|
||||
core/vsettings.h
|
||||
|
||||
SOURCES += \
|
||||
core/vapplication.cpp \
|
||||
core/vtranslation.cpp \
|
||||
core/undoevent.cpp
|
||||
core/undoevent.cpp \
|
||||
core/vsettings.cpp
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "vmaingraphicsview.h"
|
||||
#include "../container/calculator.h"
|
||||
#include "../version.h"
|
||||
#include "vsettings.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
|
@ -1652,10 +1653,8 @@ QString VApplication::FormulaFromUser(const QString &formula)
|
|||
}
|
||||
}
|
||||
|
||||
bool osSeparatorValue = getSettings()->value("configuration/osSeparator", 1).toBool();
|
||||
|
||||
QLocale loc = QLocale::system();
|
||||
if (loc != QLocale(QLocale::C) && osSeparatorValue)
|
||||
if (loc != QLocale(QLocale::C) && getSettings()->GetOsSeparator())
|
||||
{
|
||||
QList<int> nKeys = numbers.keys();
|
||||
QList<QString> nValues = numbers.values();
|
||||
|
@ -1768,10 +1767,8 @@ QString VApplication::FormulaToUser(const QString &formula)
|
|||
}
|
||||
}
|
||||
|
||||
bool osSeparatorValue = getSettings()->value("configuration/osSeparator", 1).toBool();
|
||||
|
||||
QLocale loc = QLocale::system();
|
||||
if (loc != QLocale::C && osSeparatorValue)
|
||||
if (loc != QLocale::C && getSettings()->GetOsSeparator())
|
||||
{
|
||||
QList<int> nKeys = numbers.keys();
|
||||
QList<QString> nValues = numbers.values();
|
||||
|
@ -1838,7 +1835,7 @@ void VApplication::setOpeningPattern()
|
|||
*/
|
||||
void VApplication::OpenSettings()
|
||||
{
|
||||
settings = new QSettings(QSettings::IniFormat, QSettings::UserScope, QApplication::organizationName(),
|
||||
settings = new VSettings(QSettings::IniFormat, QSettings::UserScope, QApplication::organizationName(),
|
||||
QApplication::applicationName(), this);
|
||||
}
|
||||
|
||||
|
@ -1847,7 +1844,7 @@ void VApplication::OpenSettings()
|
|||
* @brief VApplication::getSettings hide settings constructor.
|
||||
* @return pointer to class for acssesing to settings in ini file.
|
||||
*/
|
||||
QSettings *VApplication::getSettings()
|
||||
VSettings *VApplication::getSettings()
|
||||
{
|
||||
SCASSERT(settings != nullptr);
|
||||
return settings;
|
||||
|
@ -2040,7 +2037,7 @@ void VApplication::CollectReports() const
|
|||
return;// Settings was not opened.
|
||||
}
|
||||
|
||||
if (settings->value("configuration/send_report/state", 1).toBool())
|
||||
if (settings->GetSendReportState())
|
||||
{ // Try send report
|
||||
// Remove gist.json file before close app.
|
||||
connect(this, &VApplication::aboutToQuit, this, &VApplication::CleanGist, Qt::UniqueConnection);
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
#include <QApplication>
|
||||
#include "../options.h"
|
||||
#include "vtranslation.h"
|
||||
#include <QSettings>
|
||||
#include "../widgets/vmaingraphicsview.h"
|
||||
|
||||
class VApplication;// used in define
|
||||
|
@ -41,6 +40,7 @@ class VMainGraphicsView;
|
|||
class VMainGraphicsScene;
|
||||
class VPattern;
|
||||
class QFile;
|
||||
class VSettings;
|
||||
|
||||
#if defined(qApp)
|
||||
#undef qApp
|
||||
|
@ -90,8 +90,10 @@ public:
|
|||
void setMainWindow(QWidget *value);
|
||||
bool getOpeningPattern() const;
|
||||
void setOpeningPattern();
|
||||
|
||||
void OpenSettings();
|
||||
QSettings *getSettings();
|
||||
VSettings *getSettings();
|
||||
|
||||
VMainGraphicsScene *getCurrentScene() const;
|
||||
void setCurrentScene(VMainGraphicsScene *value);
|
||||
|
||||
|
@ -147,7 +149,7 @@ private:
|
|||
/**
|
||||
* @brief settings pointer to settings. Help hide constructor creation settings. Make make code more readable.
|
||||
*/
|
||||
QSettings *settings;
|
||||
VSettings *settings;
|
||||
|
||||
VPattern *doc;
|
||||
QFile *log;
|
||||
|
|
402
src/app/core/vsettings.cpp
Normal file
402
src/app/core/vsettings.cpp
Normal file
|
@ -0,0 +1,402 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @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.
|
||||
** Copyright (C) 2014 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 "vsettings.h"
|
||||
|
||||
#include <QDir>
|
||||
|
||||
const QString VSettings::SettingConfigurationOsSeparator = QStringLiteral("configuration/osSeparator");
|
||||
const QString VSettings::SettingConfigurationAutosaveState = QStringLiteral("configuration/autosave/state");
|
||||
const QString VSettings::SettingConfigurationAutosaveTime = QStringLiteral("configuration/autosave/time");
|
||||
const QString VSettings::SettingConfigurationSendReportState = QStringLiteral("configuration/send_report/state");
|
||||
const QString VSettings::SettingConfigurationLocale = QStringLiteral("configuration/locale");
|
||||
const QString VSettings::SettingConfigurationUnit = QStringLiteral("configuration/unit");
|
||||
const QString VSettings::SettingConfigurationLabelLanguage = QStringLiteral("configuration/label_language");
|
||||
|
||||
const QString VSettings::SettingPathsIndividualMeasurements = QStringLiteral("paths/individual_measurements");
|
||||
const QString VSettings::SettingPathsPattern = QStringLiteral("paths/pattern");
|
||||
|
||||
const QString VSettings::SettingPatternUser = QStringLiteral("pattern/user");
|
||||
const QString VSettings::SettingPatternGraphicalOutput = QStringLiteral("pattern/graphicalOutput");
|
||||
const QString VSettings::SettingPatternUndo = QStringLiteral("pattern/undo");
|
||||
|
||||
const QString VSettings::SettingGeneralRecentFileList = QStringLiteral("recentFileList");
|
||||
const QString VSettings::SettingGeneralRestoreFileList = QStringLiteral("restoreFileList");
|
||||
const QString VSettings::SettingGeneralGeometry = QStringLiteral("geometry");
|
||||
const QString VSettings::SettingGeneralWindowState = QStringLiteral("windowState");
|
||||
|
||||
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");
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VSettings::VSettings(Format format, Scope scope, const QString &organization, const QString &application,
|
||||
QObject *parent)
|
||||
:QSettings(format, scope, organization, application, parent)
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool VSettings::GetOsSeparator()
|
||||
{
|
||||
return value(SettingConfigurationOsSeparator, 1).toBool();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSettings::SetOsSeparator(const bool &value)
|
||||
{
|
||||
setValue(SettingConfigurationOsSeparator, value);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool VSettings::GetAutosaveState()
|
||||
{
|
||||
return value(SettingConfigurationAutosaveState, 1).toBool();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSettings::SetAutosaveState(const bool &value)
|
||||
{
|
||||
setValue(SettingConfigurationAutosaveState, value);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
int VSettings::GetAutosaveTime()
|
||||
{
|
||||
bool ok = false;
|
||||
int val = value(SettingConfigurationAutosaveTime, 1).toInt(&ok);
|
||||
if (ok == false)
|
||||
{
|
||||
qDebug()<<"Could not convert value"<<value(SettingConfigurationAutosaveTime, 1)
|
||||
<<"to int. Return default value for autosave time"<<1<<"minutes.";
|
||||
val = 1;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSettings::SetAutosaveTime(const int &value)
|
||||
{
|
||||
setValue(SettingConfigurationAutosaveTime, value);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool VSettings::GetSendReportState()
|
||||
{
|
||||
return value(SettingConfigurationSendReportState, 1).toBool();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSettings::SetSendReportState(const bool &value)
|
||||
{
|
||||
setValue(SettingConfigurationSendReportState, value);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VSettings::GetLocale()
|
||||
{
|
||||
return value(SettingConfigurationLocale, QLocale::system().name()).toString();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSettings::SetLocale(const QString &value)
|
||||
{
|
||||
setValue(SettingConfigurationLocale, value);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VSettings::GetUnit()
|
||||
{
|
||||
return value(SettingConfigurationUnit, "cm").toString();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSettings::SetUnit(const QString &value)
|
||||
{
|
||||
setValue(SettingConfigurationUnit, value);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VSettings::GetLabelLanguage()
|
||||
{
|
||||
return value(SettingConfigurationLabelLanguage, QLocale::system().bcp47Name()).toString();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSettings::SetLabelLanguage(const QString &value)
|
||||
{
|
||||
setValue(SettingConfigurationLabelLanguage, value);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VSettings::GetPathIndividualMeasurements()
|
||||
{
|
||||
return value(SettingPathsIndividualMeasurements, QDir::homePath()).toString();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSettings::SetPathIndividualMeasurements(const QString &value)
|
||||
{
|
||||
setValue(SettingPathsIndividualMeasurements, value);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VSettings::GetPathPattern()
|
||||
{
|
||||
return value(SettingPathsPattern, QDir::homePath()).toString();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSettings::SetPathPattern(const QString &value)
|
||||
{
|
||||
setValue(SettingPathsPattern, value);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VSettings::GetUser()
|
||||
{
|
||||
QString user;
|
||||
#ifdef Q_OS_WIN
|
||||
user = value(SettingPatternUser, QString::fromLocal8Bit(qgetenv("USERNAME").constData())).toString();
|
||||
#else
|
||||
user = value(SettingPatternUser, QString::fromLocal8Bit(qgetenv("USER").constData())).toString();
|
||||
#endif
|
||||
return user;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSettings::SetUser(const QString &value)
|
||||
{
|
||||
setValue(SettingPatternUser, value);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool VSettings::GetGraphicalOutput()
|
||||
{
|
||||
return value(SettingPatternGraphicalOutput, 1).toBool();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSettings::SetGraphicalOutput(const bool &value)
|
||||
{
|
||||
setValue(SettingPatternGraphicalOutput, value);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
int VSettings::GetUndoCount()
|
||||
{
|
||||
bool ok = false;
|
||||
int val = value(SettingPatternUndo, 0).toInt(&ok);
|
||||
if (ok == false)
|
||||
{
|
||||
qDebug()<<"Could not convert value"<<value(SettingPatternUndo, 0)
|
||||
<<"to int. Return default value for undo counts 0 (no limit).";
|
||||
val = 0;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSettings::SetUndoCount(const int &value)
|
||||
{
|
||||
setValue(SettingPatternUndo, value);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QStringList VSettings::GetRecentFileList()
|
||||
{
|
||||
return value(SettingGeneralRecentFileList).toStringList();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSettings::SetRecentFileList(const QStringList &value)
|
||||
{
|
||||
setValue(SettingGeneralRecentFileList, value);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QStringList VSettings::GetRestoreFileList()
|
||||
{
|
||||
return value(SettingGeneralRestoreFileList).toStringList();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSettings::SetRestoreFileList(const QStringList &value)
|
||||
{
|
||||
setValue(SettingGeneralRestoreFileList, value);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QByteArray VSettings::GetGeometry()
|
||||
{
|
||||
return value(SettingGeneralGeometry).toByteArray();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSettings::SetGeometry(const QByteArray &value)
|
||||
{
|
||||
setValue(SettingGeneralGeometry, value);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QByteArray VSettings::GetWindowState()
|
||||
{
|
||||
return value(SettingGeneralWindowState).toByteArray();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSettings::SetWindowState(const QByteArray &value)
|
||||
{
|
||||
setValue(SettingGeneralWindowState, value);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VSettings::GetServer()
|
||||
{
|
||||
return value(SettingCommunityServer, "community.valentina-project.org").toString();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSettings::SetServer(const QString &value)
|
||||
{
|
||||
setValue(SettingCommunityServer, value);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool VSettings::GetServerSecure()
|
||||
{
|
||||
return value(SettingCommunityServerSecure, 0).toBool();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSettings::SetServerSecure(const bool &value)
|
||||
{
|
||||
setValue(SettingCommunityServerSecure, value);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool VSettings::GetProxy()
|
||||
{
|
||||
return value(SettingCommunityUseProxy, 0).toBool();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSettings::SetProxy(const bool &value)
|
||||
{
|
||||
setValue(SettingCommunityUseProxy, value);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VSettings::GetProxyAddress()
|
||||
{
|
||||
return value(SettingCommunityProxyAddress).toString();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSettings::SetProxyAddress(const QString &value)
|
||||
{
|
||||
setValue(SettingCommunityProxyAddress, value);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VSettings::GetProxyPort()
|
||||
{
|
||||
return value(SettingCommunityProxyPort).toString();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSettings::SetProxyPort(const QString &value)
|
||||
{
|
||||
setValue(SettingCommunityProxyPort, value);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VSettings::GetProxyUser()
|
||||
{
|
||||
return value(SettingCommunityProxyUser).toString();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSettings::SetProxyUser(const QString &value)
|
||||
{
|
||||
setValue(SettingCommunityProxyUser, value);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VSettings::GetProxyPass()
|
||||
{
|
||||
return value(SettingCommunityProxyPass).toString();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSettings::SetProxyPass(const QString &value)
|
||||
{
|
||||
setValue(SettingCommunityProxyPass, value);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VSettings::GetUsername()
|
||||
{
|
||||
return value(SettingCommunityUsername).toString();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSettings::SetUsername(const QString &value)
|
||||
{
|
||||
setValue(SettingCommunityUsername, value);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool VSettings::GetSavePassword()
|
||||
{
|
||||
return value(SettingCommunitySavePassword, 0).toBool();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSettings::SetSavePassword(const bool &value)
|
||||
{
|
||||
setValue(SettingCommunitySavePassword, value);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VSettings::GetUserPassword()
|
||||
{
|
||||
return value(SettingCommunityUserPassword).toString();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSettings::SetUserPassword(const QString &value)
|
||||
{
|
||||
setValue(SettingCommunityUserPassword, value);
|
||||
}
|
153
src/app/core/vsettings.h
Normal file
153
src/app/core/vsettings.h
Normal file
|
@ -0,0 +1,153 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file vsettings.h
|
||||
** @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.
|
||||
** Copyright (C) 2014 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/>.
|
||||
**
|
||||
*************************************************************************/
|
||||
|
||||
#ifndef VSETTINGS_H
|
||||
#define VSETTINGS_H
|
||||
|
||||
#include <QSettings>
|
||||
|
||||
class VSettings : public QSettings
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
VSettings(Format format, Scope scope, const QString &organization, const QString &application = QString(),
|
||||
QObject *parent = 0);
|
||||
|
||||
bool GetOsSeparator();
|
||||
void SetOsSeparator(const bool &value);
|
||||
|
||||
bool GetAutosaveState();
|
||||
void SetAutosaveState(const bool &value);
|
||||
|
||||
int GetAutosaveTime();
|
||||
void SetAutosaveTime(const int &value);
|
||||
|
||||
bool GetSendReportState();
|
||||
void SetSendReportState(const bool &value);
|
||||
|
||||
QString GetLocale();
|
||||
void SetLocale(const QString &value);
|
||||
|
||||
QString GetUnit();
|
||||
void SetUnit(const QString &value);
|
||||
|
||||
QString GetLabelLanguage();
|
||||
void SetLabelLanguage(const QString &value);
|
||||
|
||||
QString GetPathIndividualMeasurements();
|
||||
void SetPathIndividualMeasurements(const QString &value);
|
||||
|
||||
QString GetPathPattern();
|
||||
void SetPathPattern(const QString &value);
|
||||
|
||||
QString GetUser();
|
||||
void SetUser(const QString &value);
|
||||
|
||||
bool GetGraphicalOutput();
|
||||
void SetGraphicalOutput(const bool &value);
|
||||
|
||||
int GetUndoCount();
|
||||
void SetUndoCount(const int &value);
|
||||
|
||||
QStringList GetRecentFileList();
|
||||
void SetRecentFileList(const QStringList &value);
|
||||
|
||||
QStringList GetRestoreFileList();
|
||||
void SetRestoreFileList(const QStringList &value);
|
||||
|
||||
QByteArray GetGeometry();
|
||||
void SetGeometry(const QByteArray &value);
|
||||
|
||||
QByteArray GetWindowState();
|
||||
void SetWindowState(const QByteArray &value);
|
||||
|
||||
QString GetServer();
|
||||
void SetServer(const QString &value);
|
||||
|
||||
bool GetServerSecure();
|
||||
void SetServerSecure(const bool &value);
|
||||
|
||||
bool GetProxy();
|
||||
void SetProxy(const bool &value);
|
||||
|
||||
QString GetProxyAddress();
|
||||
void SetProxyAddress(const QString &value);
|
||||
|
||||
QString GetProxyPort();
|
||||
void SetProxyPort(const QString &value);
|
||||
|
||||
QString GetProxyUser();
|
||||
void SetProxyUser(const QString &value);
|
||||
|
||||
QString GetProxyPass();
|
||||
void SetProxyPass(const QString &value);
|
||||
|
||||
QString GetUsername();
|
||||
void SetUsername(const QString &value);
|
||||
|
||||
bool GetSavePassword();
|
||||
void SetSavePassword(const bool &value);
|
||||
|
||||
QString GetUserPassword();
|
||||
void SetUserPassword(const QString &value);
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(VSettings)
|
||||
static const QString SettingConfigurationOsSeparator;
|
||||
static const QString SettingConfigurationAutosaveState;
|
||||
static const QString SettingConfigurationAutosaveTime;
|
||||
static const QString SettingConfigurationSendReportState;
|
||||
static const QString SettingConfigurationLocale;
|
||||
static const QString SettingConfigurationUnit;
|
||||
static const QString SettingConfigurationLabelLanguage;
|
||||
|
||||
static const QString SettingPathsIndividualMeasurements;
|
||||
static const QString SettingPathsPattern;
|
||||
|
||||
static const QString SettingPatternUser;
|
||||
static const QString SettingPatternGraphicalOutput;
|
||||
static const QString SettingPatternUndo;
|
||||
|
||||
static const QString SettingGeneralRecentFileList;
|
||||
static const QString SettingGeneralRestoreFileList;
|
||||
static const QString SettingGeneralGeometry;
|
||||
static const QString SettingGeneralWindowState;
|
||||
|
||||
static const QString SettingCommunityServer;
|
||||
static const QString SettingCommunityServerSecure;
|
||||
static const QString SettingCommunityUseProxy;
|
||||
static const QString SettingCommunityProxyAddress;
|
||||
static const QString SettingCommunityProxyPort;
|
||||
static const QString SettingCommunityProxyUser;
|
||||
static const QString SettingCommunityProxyPass;
|
||||
static const QString SettingCommunityUsername;
|
||||
static const QString SettingCommunitySavePassword;
|
||||
static const QString SettingCommunityUserPassword;
|
||||
};
|
||||
|
||||
#endif // VSETTINGS_H
|
|
@ -29,6 +29,7 @@
|
|||
#include "communitypage.h"
|
||||
#include "../../../options.h"
|
||||
#include "../../../core/vapplication.h"
|
||||
#include "../../../core/vsettings.h"
|
||||
#include <QGroupBox>
|
||||
#include <QLabel>
|
||||
#include <QSettings>
|
||||
|
@ -57,17 +58,17 @@ CommunityPage::CommunityPage(QWidget *parent):
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void CommunityPage::Apply()
|
||||
{
|
||||
qApp->getSettings()->setValue("community/server", this->server->text());
|
||||
qApp->getSettings()->setValue("community/serverSecure", this->secureComm->isChecked());
|
||||
qApp->getSettings()->setValue("community/useProxy", this->useProxy->isChecked());
|
||||
qApp->getSettings()->setValue("community/proxyAddress", this->proxyAddress->text());
|
||||
qApp->getSettings()->setValue("community/proxyPort", this->proxyPort->text());
|
||||
qApp->getSettings()->setValue("community/proxyUser", this->proxyUser->text());
|
||||
qApp->getSettings()->setValue("community/proxyPass", this->proxyPass->text());
|
||||
qApp->getSettings()->SetServer(this->server->text());
|
||||
qApp->getSettings()->SetServerSecure(this->secureComm->isChecked());
|
||||
qApp->getSettings()->SetProxy(this->useProxy->isChecked());
|
||||
qApp->getSettings()->SetProxyAddress(this->proxyAddress->text());
|
||||
qApp->getSettings()->SetProxyPort(this->proxyPort->text());
|
||||
qApp->getSettings()->SetProxyUser(this->proxyUser->text());
|
||||
qApp->getSettings()->SetProxyPass(this->proxyPass->text());
|
||||
|
||||
qApp->getSettings()->setValue("community/username", this->username->text());
|
||||
qApp->getSettings()->setValue("community/savePassword", this->savePassword->isChecked());
|
||||
qApp->getSettings()->setValue("community/userpassword", this->userpassword->text());
|
||||
qApp->getSettings()->SetUsername(this->username->text());
|
||||
qApp->getSettings()->SetSavePassword(this->savePassword->isChecked());
|
||||
qApp->getSettings()->SetUserPassword(this->userpassword->text());
|
||||
|
||||
}
|
||||
|
||||
|
@ -99,17 +100,13 @@ void CommunityPage::PasswordCheckChanged()
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QGroupBox *CommunityPage::ServerGroup()
|
||||
{
|
||||
QSettings *settings = qApp->getSettings();
|
||||
SCASSERT(settings != nullptr);
|
||||
|
||||
QGroupBox *ServerGroup = new QGroupBox(tr("Server"));
|
||||
QFormLayout *serverLayout = new QFormLayout;
|
||||
|
||||
CommunityPage::add_lineedit(&this->server, serverLayout,
|
||||
settings->value("community/server", "community.valentina-project.org").toString(), tr("Server name/IP"));
|
||||
CommunityPage::add_lineedit(&this->server, serverLayout, qApp->getSettings()->GetServer(), tr("Server name/IP"));
|
||||
|
||||
CommunityPage::add_checkbox(&this->secureComm, serverLayout,
|
||||
settings->value("community/serverSecure", 0).toBool(), tr("Secure connection"));
|
||||
CommunityPage::add_checkbox(&this->secureComm, serverLayout, qApp->getSettings()->GetServerSecure(),
|
||||
tr("Secure connection"));
|
||||
|
||||
ServerGroup->setLayout(serverLayout);
|
||||
return ServerGroup;
|
||||
|
@ -140,21 +137,12 @@ QGroupBox *CommunityPage::ProxyGroup()
|
|||
|
||||
QFormLayout *proxyLayout = new QFormLayout;
|
||||
|
||||
CommunityPage::add_checkbox(&this->useProxy, proxyLayout,
|
||||
qApp->getSettings()->value("community/useProxy", 0).toBool(), tr("Use Proxy"));
|
||||
|
||||
CommunityPage::add_lineedit(&this->proxyAddress, proxyLayout,
|
||||
qApp->getSettings()->value("community/proxyAddress", "").toString(), tr("Proxy address"));
|
||||
|
||||
CommunityPage::add_lineedit(&this->proxyPort, proxyLayout,
|
||||
qApp->getSettings()->value("community/proxyPort", "").toString(), tr("Proxy port"));
|
||||
|
||||
CommunityPage::add_lineedit(&this->proxyUser, proxyLayout,
|
||||
qApp->getSettings()->value("community/proxyUser", "").toString(), tr("Proxy user"));
|
||||
|
||||
CommunityPage::add_lineedit(&this->proxyPass, proxyLayout,
|
||||
qApp->getSettings()->value("community/proxyPass", "").toString(), tr("Proxy pass"));
|
||||
|
||||
CommunityPage::add_checkbox(&this->useProxy, proxyLayout, qApp->getSettings()->GetProxy(), tr("Use Proxy"));
|
||||
CommunityPage::add_lineedit(&this->proxyAddress, proxyLayout, qApp->getSettings()->GetProxyAddress(),
|
||||
tr("Proxy address"));
|
||||
CommunityPage::add_lineedit(&this->proxyPort, proxyLayout, qApp->getSettings()->GetProxyPort(), tr("Proxy port"));
|
||||
CommunityPage::add_lineedit(&this->proxyUser, proxyLayout, qApp->getSettings()->GetProxyUser(), tr("Proxy user"));
|
||||
CommunityPage::add_lineedit(&this->proxyPass, proxyLayout, qApp->getSettings()->GetProxyPass(), tr("Proxy pass"));
|
||||
connect(this->useProxy, &QCheckBox::stateChanged, this, &CommunityPage::ProxyCheckChanged);
|
||||
this->ProxyCheckChanged();
|
||||
|
||||
|
@ -169,14 +157,11 @@ QGroupBox *CommunityPage::UserGroup()
|
|||
QGroupBox *userGroup = new QGroupBox(tr("User settings"));
|
||||
QFormLayout *userLayout = new QFormLayout;
|
||||
|
||||
CommunityPage::add_lineedit(&this->username, userLayout,
|
||||
qApp->getSettings()->value("community/username", "").toString(), tr("User Name"));
|
||||
|
||||
CommunityPage::add_checkbox(&this->savePassword, userLayout,
|
||||
qApp->getSettings()->value("community/savePassword", 0).toBool(), tr("Save password"));
|
||||
|
||||
CommunityPage::add_lineedit(&this->userpassword, userLayout,
|
||||
qApp->getSettings()->value("community/userpassword", "").toString(), tr("Password"));
|
||||
CommunityPage::add_lineedit(&this->username, userLayout, qApp->getSettings()->GetUsername(), tr("User Name"));
|
||||
CommunityPage::add_checkbox(&this->savePassword, userLayout, qApp->getSettings()->GetSavePassword(),
|
||||
tr("Save password"));
|
||||
CommunityPage::add_lineedit(&this->userpassword, userLayout, qApp->getSettings()->GetUserPassword(),
|
||||
tr("Password"));
|
||||
|
||||
connect(this->savePassword, &QCheckBox::stateChanged, this, &CommunityPage::PasswordCheckChanged);
|
||||
this->PasswordCheckChanged();
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "configurationpage.h"
|
||||
#include "../../../options.h"
|
||||
#include "../../../core/vapplication.h"
|
||||
#include "../../../core/vsettings.h"
|
||||
#include <QDir>
|
||||
#include <QGroupBox>
|
||||
#include <QLabel>
|
||||
|
@ -62,46 +63,38 @@ ConfigurationPage::ConfigurationPage(QWidget *parent)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void ConfigurationPage::Apply()
|
||||
{
|
||||
qApp->getSettings()->setValue("configuration/autosave/state", autoSaveCheck->isChecked());
|
||||
qApp->getSettings()->setValue("configuration/autosave/time", autoTime->value());
|
||||
qApp->getSettings()->SetAutosaveState(autoSaveCheck->isChecked());
|
||||
qApp->getSettings()->SetAutosaveTime(autoTime->value());
|
||||
|
||||
QTimer *autoSaveTimer = qApp->getAutoSaveTimer();
|
||||
SCASSERT(autoSaveTimer);
|
||||
|
||||
if (autoSaveCheck->isChecked())
|
||||
{
|
||||
autoSaveTimer->start(autoTime->value()*60000);
|
||||
}
|
||||
else
|
||||
{
|
||||
autoSaveTimer->stop();
|
||||
}
|
||||
autoSaveCheck->isChecked() ? autoSaveTimer->start(autoTime->value()*60000) : autoSaveTimer->stop();
|
||||
|
||||
qApp->getSettings()->setValue("configuration/osSeparator", osOptionCheck->isChecked());
|
||||
|
||||
qApp->getSettings()->setValue("configuration/send_report/state", sendReportCheck->isChecked());
|
||||
qApp->getSettings()->SetOsSeparator(osOptionCheck->isChecked());
|
||||
qApp->getSettings()->SetSendReportState(sendReportCheck->isChecked());
|
||||
|
||||
if (langChanged)
|
||||
{
|
||||
QString locale = qvariant_cast<QString>(langCombo->itemData(langCombo->currentIndex()));
|
||||
qApp->getSettings()->setValue("configuration/locale", locale);
|
||||
const QString locale = qvariant_cast<QString>(langCombo->itemData(langCombo->currentIndex()));
|
||||
qApp->getSettings()->SetLocale(locale);
|
||||
langChanged = false;
|
||||
QString text = tr("Setup user interface language updated and will be used the next time start") + " " +
|
||||
QApplication::applicationName();
|
||||
const QString text = tr("Setup user interface language updated and will be used the next time start") + " " +
|
||||
QApplication::applicationName();
|
||||
QMessageBox::information(this, QApplication::applicationName(), text);
|
||||
}
|
||||
if (this->unitChanged)
|
||||
{
|
||||
QString unit = qvariant_cast<QString>(this->unitCombo->itemData(this->unitCombo->currentIndex()));
|
||||
qApp->getSettings()->setValue("configuration/unit", unit);
|
||||
const QString unit = qvariant_cast<QString>(this->unitCombo->itemData(this->unitCombo->currentIndex()));
|
||||
qApp->getSettings()->SetUnit(unit);
|
||||
this->unitChanged = false;
|
||||
QString text = tr("Default unit updated and will be used the next pattern creation");
|
||||
const QString text = tr("Default unit updated and will be used the next pattern creation");
|
||||
QMessageBox::information(this, QApplication::applicationName(), text);
|
||||
}
|
||||
if (labelLangChanged)
|
||||
{
|
||||
QString locale = qvariant_cast<QString>(labelCombo->itemData(labelCombo->currentIndex()));
|
||||
qApp->getSettings()->setValue("configuration/label_language", locale);
|
||||
const QString locale = qvariant_cast<QString>(labelCombo->itemData(labelCombo->currentIndex()));
|
||||
qApp->getSettings()->SetLabelLanguage(locale);
|
||||
labelLangChanged = false;
|
||||
}
|
||||
}
|
||||
|
@ -127,31 +120,19 @@ void ConfigurationPage::LabelLangChanged()
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QGroupBox *ConfigurationPage::SaveGroup()
|
||||
{
|
||||
QSettings *settings = qApp->getSettings();
|
||||
SCASSERT(settings != nullptr);
|
||||
|
||||
QGroupBox *saveGroup = new QGroupBox(tr("Save"));
|
||||
|
||||
autoSaveCheck = new QCheckBox(tr("Auto-save modified pattern"));
|
||||
bool autoSaveValue = settings->value("configuration/autosave/state", 1).toBool();
|
||||
autoSaveCheck->setChecked(autoSaveValue);
|
||||
|
||||
QLabel *intervalLabel = new QLabel(tr("Interval:"));
|
||||
autoSaveCheck->setChecked(qApp->getSettings()->GetAutosaveState());
|
||||
|
||||
autoTime = new QSpinBox();
|
||||
bool ok = true;
|
||||
qint32 autoTimeValue = settings->value("configuration/autosave/time", 1).toInt(&ok);
|
||||
if (ok == false)
|
||||
{
|
||||
autoTimeValue = 5;
|
||||
}
|
||||
autoTime->setRange(1, 60);
|
||||
autoTime->setValue(autoTimeValue);
|
||||
autoTime->setValue(qApp->getSettings()->GetAutosaveTime());
|
||||
autoTime->setSuffix(tr("min"));
|
||||
|
||||
QHBoxLayout *autosaveLayout = new QHBoxLayout;
|
||||
autosaveLayout->addWidget(autoSaveCheck);
|
||||
autosaveLayout->addWidget(intervalLabel);
|
||||
autosaveLayout->addWidget(new QLabel(tr("Interval:")));
|
||||
autosaveLayout->addWidget(autoTime);
|
||||
|
||||
QVBoxLayout *saveLayout = new QVBoxLayout;
|
||||
|
@ -163,19 +144,12 @@ QGroupBox *ConfigurationPage::SaveGroup()
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QGroupBox *ConfigurationPage::LangGroup()
|
||||
{
|
||||
QSettings *settings = qApp->getSettings();
|
||||
SCASSERT(settings != nullptr);
|
||||
|
||||
QGroupBox *langGroup = new QGroupBox(tr("Language"));
|
||||
QLabel *guiLabel = new QLabel(tr("GUI language"));
|
||||
langCombo = new QComboBox;
|
||||
|
||||
// format systems language
|
||||
QString checkedLocale = settings->value("configuration/locale", QLocale::system().name()).toString();
|
||||
|
||||
QString m_langPath = qApp->translationsPath();
|
||||
QDir dir(m_langPath);
|
||||
QStringList fileNames = dir.entryList(QStringList("valentina_*.qm"));
|
||||
QDir dir(qApp->translationsPath());
|
||||
const QStringList fileNames = dir.entryList(QStringList("valentina_*.qm"));
|
||||
|
||||
for (int i = 0; i < fileNames.size(); ++i)
|
||||
{
|
||||
|
@ -198,7 +172,7 @@ QGroupBox *ConfigurationPage::LangGroup()
|
|||
langCombo->addItem(ico, lang, "en_US");
|
||||
|
||||
// set default translators and language checked
|
||||
qint32 index = langCombo->findData(checkedLocale);
|
||||
qint32 index = langCombo->findData(qApp->getSettings()->GetLocale());
|
||||
if (index != -1)
|
||||
{
|
||||
langCombo->setCurrentIndex(index);
|
||||
|
@ -214,8 +188,7 @@ QGroupBox *ConfigurationPage::LangGroup()
|
|||
QLabel *separatorLabel = new QLabel(tr("Decimal separator parts"));
|
||||
|
||||
osOptionCheck = new QCheckBox(tr("With OS options (%1)").arg(QLocale::system().decimalPoint().toLatin1()));
|
||||
bool osOptionValue = settings->value("configuration/osSeparator", 1).toBool();
|
||||
osOptionCheck->setChecked(osOptionValue);
|
||||
osOptionCheck->setChecked(qApp->getSettings()->GetOsSeparator());
|
||||
|
||||
QHBoxLayout *separatorLayout = new QHBoxLayout;
|
||||
separatorLayout->addWidget(separatorLabel);
|
||||
|
@ -225,14 +198,12 @@ QGroupBox *ConfigurationPage::LangGroup()
|
|||
this->unitCombo = new QComboBox;
|
||||
QLabel *unitLabel = new QLabel(tr("Default unit"));
|
||||
|
||||
QString checkedUnit = settings->value("configuration/unit", "cm").toString();
|
||||
|
||||
this->unitCombo->addItem(tr("Centimeters"), "cm");
|
||||
this->unitCombo->addItem(tr("Millimiters"), "mm");
|
||||
this->unitCombo->addItem(tr("Inches"), "in");
|
||||
|
||||
// set default unit
|
||||
qint32 indexUnit = this->unitCombo->findData(checkedUnit);
|
||||
qint32 indexUnit = this->unitCombo->findData(qApp->getSettings()->GetUnit());
|
||||
if (indexUnit != -1)
|
||||
{
|
||||
this->unitCombo->setCurrentIndex(indexUnit);
|
||||
|
@ -249,12 +220,9 @@ QGroupBox *ConfigurationPage::LangGroup()
|
|||
QLabel *labelName = new QLabel(tr("Label language"));
|
||||
labelCombo = new QComboBox;
|
||||
|
||||
QString checkedLabelLocale = settings->value("configuration/label_language",
|
||||
QLocale::system().bcp47Name()).toString();
|
||||
|
||||
SetLabelComboBox(VApplication::LabelLanguages());
|
||||
|
||||
index = labelCombo->findData(checkedLabelLocale);
|
||||
index = labelCombo->findData(qApp->getSettings()->GetLabelLanguage());
|
||||
if (index != -1)
|
||||
{
|
||||
labelCombo->setCurrentIndex(index);
|
||||
|
@ -281,14 +249,10 @@ QGroupBox *ConfigurationPage::LangGroup()
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QGroupBox *ConfigurationPage::SendGroup()
|
||||
{
|
||||
QSettings *settings = qApp->getSettings();
|
||||
SCASSERT(settings != nullptr);
|
||||
|
||||
QGroupBox *sendGroup = new QGroupBox(tr("Send crash reports"));
|
||||
|
||||
sendReportCheck = new QCheckBox(tr("Send crash reports (recommended)"));
|
||||
bool sendReportValue = settings->value("configuration/send_report/state", 1).toBool();
|
||||
sendReportCheck->setChecked(sendReportValue);
|
||||
sendReportCheck->setChecked(qApp->getSettings()->GetSendReportState());
|
||||
|
||||
QLabel *description = new QLabel(tr("After each crash Valentina collect information that may help us fix a "
|
||||
"problem. We do not collect any personal information. Find more about what "
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "pathpage.h"
|
||||
#include "../../../options.h"
|
||||
#include "../../../core/vapplication.h"
|
||||
#include "../../../core/vsettings.h"
|
||||
#include <QDir>
|
||||
#include <QGroupBox>
|
||||
#include <QLabel>
|
||||
|
@ -61,8 +62,8 @@ PathPage::PathPage(QWidget *parent)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void PathPage::Apply()
|
||||
{
|
||||
qApp->getSettings()->setValue("paths/individual_measurements", pathTable->item(0, 1)->text());
|
||||
qApp->getSettings()->setValue("paths/pattern", pathTable->item(1, 1)->text());
|
||||
qApp->getSettings()->SetPathIndividualMeasurements(pathTable->item(0, 1)->text());
|
||||
qApp->getSettings()->SetPathPattern(pathTable->item(1, 1)->text());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -138,15 +139,11 @@ void PathPage::InitTable()
|
|||
QStringList tableHeader = QStringList() << tr("Type") << tr("Path");
|
||||
pathTable->setHorizontalHeaderLabels(tableHeader);
|
||||
|
||||
QString path;
|
||||
|
||||
pathTable->setItem(0, 0, new QTableWidgetItem(tr("Individual measurements")));
|
||||
path = qApp->getSettings()->value("paths/individual_measurements", QDir::homePath()).toString();
|
||||
pathTable->setItem(0, 1, new QTableWidgetItem(path));
|
||||
pathTable->setItem(0, 1, new QTableWidgetItem(qApp->getSettings()->GetPathIndividualMeasurements()));
|
||||
|
||||
pathTable->setItem(1, 0, new QTableWidgetItem(tr("Patterns")));
|
||||
path = qApp->getSettings()->value("paths/pattern", QDir::homePath()).toString();
|
||||
pathTable->setItem(1, 1, new QTableWidgetItem(path));
|
||||
pathTable->setItem(1, 1, new QTableWidgetItem(qApp->getSettings()->GetPathPattern()));
|
||||
|
||||
pathTable->verticalHeader()->setDefaultSectionSize(20);
|
||||
pathTable->resizeColumnsToContents();
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "patternpage.h"
|
||||
#include "../../../options.h"
|
||||
#include "../../../core/vapplication.h"
|
||||
#include "../../../core/vsettings.h"
|
||||
#include "../../../widgets/vmaingraphicsview.h"
|
||||
#include <QGroupBox>
|
||||
#include <QLabel>
|
||||
|
@ -57,35 +58,27 @@ PatternPage::PatternPage(QWidget *parent):
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void PatternPage::Apply()
|
||||
{
|
||||
qApp->getSettings()->setValue("pattern/user", userName->text());
|
||||
qApp->getSettings()->SetUser(userName->text());
|
||||
|
||||
// Scene antialiasing
|
||||
qApp->getSettings()->setValue("pattern/graphicalOutput", graphOutputCheck->isChecked());
|
||||
qApp->getSettings()->SetGraphicalOutput(graphOutputCheck->isChecked());
|
||||
qApp->getSceneView()->setRenderHint(QPainter::Antialiasing, graphOutputCheck->isChecked());
|
||||
qApp->getSceneView()->setRenderHint(QPainter::SmoothPixmapTransform, graphOutputCheck->isChecked());
|
||||
|
||||
/* Maximum number of commands in undo stack may only be set when the undo stack is empty, since setting it on a
|
||||
* non-empty stack might delete the command at the current index. Calling setUndoLimit() on a non-empty stack
|
||||
* prints a warning and does nothing.*/
|
||||
qApp->getSettings()->setValue("pattern/undo", undoCount->value());
|
||||
qApp->getSettings()->SetUndoCount(undoCount->value());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QGroupBox *PatternPage::UserGroup()
|
||||
{
|
||||
QSettings *settings = qApp->getSettings();
|
||||
SCASSERT(settings != nullptr);
|
||||
|
||||
QGroupBox *userGroup = new QGroupBox(tr("User"));
|
||||
QLabel *nameLabel = new QLabel(tr("User name"));
|
||||
|
||||
userName = new QLineEdit;
|
||||
#ifdef Q_OS_WIN
|
||||
QString user = settings->value("pattern/user", QString::fromLocal8Bit(qgetenv("USERNAME").constData())).toString();
|
||||
#else
|
||||
QString user = settings->value("pattern/user", QString::fromLocal8Bit(qgetenv("USER").constData())).toString();
|
||||
#endif
|
||||
userName->setText(user);
|
||||
userName->setText(qApp->getSettings()->GetUser());
|
||||
|
||||
QHBoxLayout *nameLayout = new QHBoxLayout;
|
||||
nameLayout->addWidget(nameLabel);
|
||||
|
@ -103,8 +96,7 @@ QGroupBox *PatternPage::GraphOutputGroup()
|
|||
QGroupBox *graphOutputGroup = new QGroupBox(tr("Graphical output"));
|
||||
|
||||
graphOutputCheck = new QCheckBox(tr("Use antialiasing"));
|
||||
bool graphOutputValue = qApp->getSettings()->value("pattern/graphicalOutput", 1).toBool();
|
||||
graphOutputCheck->setChecked(graphOutputValue);
|
||||
graphOutputCheck->setChecked(qApp->getSettings()->GetGraphicalOutput());
|
||||
|
||||
QHBoxLayout *graphLayout = new QHBoxLayout;
|
||||
graphLayout->addWidget(graphOutputCheck);
|
||||
|
@ -122,13 +114,7 @@ QGroupBox *PatternPage::UndoGroup()
|
|||
QLabel *undoLabel = new QLabel(tr("Count steps (0 - no limit)"));
|
||||
undoCount = new QSpinBox;
|
||||
undoCount->setMinimum(0);
|
||||
bool ok = true;
|
||||
qint32 count = qApp->getSettings()->value("pattern/undo", 0).toInt(&ok);
|
||||
if (ok == false)
|
||||
{
|
||||
count = 0;
|
||||
}
|
||||
undoCount->setValue(count);
|
||||
undoCount->setValue(qApp->getSettings()->GetUndoCount());
|
||||
|
||||
QHBoxLayout *countLayout = new QHBoxLayout;
|
||||
countLayout->addWidget(undoLabel);
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "../../widgets/textdelegate.h"
|
||||
#include "../../xml/vstandardmeasurements.h"
|
||||
#include "../../xml/vindividualmeasurements.h"
|
||||
#include "../../core/vsettings.h"
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QDir>
|
||||
|
@ -510,7 +511,7 @@ void DialogIncrements::OpenTable()
|
|||
const QString filter(tr("Individual measurements (*.vit)"));
|
||||
|
||||
//Use standard path to individual measurements
|
||||
QString path = qApp->getSettings()->value("paths/individual_measurements", QDir::homePath()).toString();
|
||||
const QString path = qApp->getSettings()->GetPathIndividualMeasurements();
|
||||
|
||||
const QString filePath = QFileDialog::getOpenFileName(this, tr("Open file"), path, filter);
|
||||
if (filePath.isEmpty())
|
||||
|
|
|
@ -29,13 +29,15 @@
|
|||
#include "dialogindividualmeasurements.h"
|
||||
#include "ui_dialogindividualmeasurements.h"
|
||||
#include "../../xml/vindividualmeasurements.h"
|
||||
#include "../../core/vapplication.h"
|
||||
#include "../../core/vsettings.h"
|
||||
#include "../../container/vcontainer.h"
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
#include <QPushButton>
|
||||
#include <QSettings>
|
||||
#include <QDesktopWidget>
|
||||
#include "../../core/vapplication.h"
|
||||
#include "../../container/vcontainer.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
DialogIndividualMeasurements::DialogIndividualMeasurements(VContainer *data, const QString &patternPieceName,
|
||||
|
@ -195,7 +197,7 @@ void DialogIndividualMeasurements::CheckState()
|
|||
void DialogIndividualMeasurements::OpenTable()
|
||||
{
|
||||
const QString filter(tr("Individual measurements (*.vit)"));
|
||||
QString path = qApp->getSettings()->value("paths/individual_measurements", QDir::homePath()).toString();
|
||||
const QString path = qApp->getSettings()->GetPathIndividualMeasurements();
|
||||
|
||||
QString fileName = QFileDialog::getOpenFileName(this, tr("Open file"), path, filter);
|
||||
if (fileName.isEmpty())
|
||||
|
@ -251,9 +253,8 @@ void DialogIndividualMeasurements::InitUnits()
|
|||
ui->comboBoxUnits->addItem(tr("Millimiters"), QVariant(VDomDocument::UnitsToStr(Unit::Mm)));
|
||||
ui->comboBoxUnits->addItem(tr("Inches"), QVariant(VDomDocument::UnitsToStr(Unit::Inch)));
|
||||
|
||||
const QString checkedUnit = qApp->getSettings()->value("configuration/unit", "cm").toString();
|
||||
// set default unit
|
||||
const qint32 indexUnit = ui->comboBoxUnits->findData(checkedUnit);
|
||||
const qint32 indexUnit = ui->comboBoxUnits->findData(qApp->getSettings()->GetUnit());
|
||||
if (indexUnit != -1)
|
||||
{
|
||||
ui->comboBoxUnits->setCurrentIndex(indexUnit);
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "../../tools/vabstracttool.h"
|
||||
#include "../../../libs/qmuparser/qmuparsererror.h"
|
||||
#include "../../core/vapplication.h"
|
||||
#include "../../core/vsettings.h"
|
||||
#include "../../xml/vdomdocument.h"
|
||||
#include <QTimer>
|
||||
#include <QCloseEvent>
|
||||
|
@ -512,7 +513,7 @@ qreal DialogTool::Eval(const QString &text, bool &flag, QLabel *label, const QSt
|
|||
else
|
||||
{
|
||||
QLocale loc;
|
||||
if (qApp->getSettings()->value("configuration/osSeparator", 1).toBool())
|
||||
if (qApp->getSettings()->GetOsSeparator())
|
||||
{
|
||||
loc = QLocale::system();
|
||||
}
|
||||
|
|
|
@ -28,15 +28,16 @@
|
|||
|
||||
#include "mainwindow.h"
|
||||
#include "core/vapplication.h"
|
||||
#include "core/vsettings.h"
|
||||
#include "tablewindow.h"
|
||||
#include "version.h"
|
||||
|
||||
#include <QTextCodec>
|
||||
#include <QMessageBox>
|
||||
#include <QThread>
|
||||
#include <QCommandLineParser>
|
||||
|
||||
#include <QtXml>
|
||||
#include <QLibraryInfo>
|
||||
#include "tablewindow.h"
|
||||
#include "version.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
int main(int argc, char *argv[])
|
||||
|
@ -73,7 +74,7 @@ int main(int argc, char *argv[])
|
|||
qDebug()<<"Built on"<<__DATE__<<"at"<<__TIME__;
|
||||
qDebug()<<"Command-line arguments:"<<app.arguments();
|
||||
|
||||
QString checkedLocale = qApp->getSettings()->value("configuration/locale", QLocale::system().name()).toString();
|
||||
const QString checkedLocale = qApp->getSettings()->GetLocale();
|
||||
qDebug()<<"Checked locale:"<<checkedLocale;
|
||||
|
||||
QTranslator qtTranslator;
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include "xml/vindividualmeasurements.h"
|
||||
#include "core/vapplication.h"
|
||||
#include "core/undoevent.h"
|
||||
#include "core/vsettings.h"
|
||||
#include "undocommands/renamepp.h"
|
||||
#include "vtooloptionspropertybrowser.h"
|
||||
#include "options.h"
|
||||
|
@ -1298,11 +1299,10 @@ void MainWindow::ActionDetails(bool checked)
|
|||
bool MainWindow::SaveAs()
|
||||
{
|
||||
QString filters(tr("Pattern files (*.val)"));
|
||||
QString path = qApp->getSettings()->value("paths/pattern", QDir::homePath()).toString();
|
||||
QString dir;
|
||||
if (curFile.isEmpty())
|
||||
{
|
||||
dir = path + "/" + tr("pattern") + ".val";
|
||||
dir = qApp->getSettings()->GetPathPattern() + "/" + tr("pattern") + ".val";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1377,7 +1377,7 @@ void MainWindow::Open()
|
|||
{
|
||||
const QString filter(tr("Pattern files (*.val)"));
|
||||
//Get list last open files
|
||||
const QStringList files = qApp->getSettings()->value("recentFileList").toStringList();
|
||||
const QStringList files = qApp->getSettings()->GetRecentFileList();
|
||||
QString dir;
|
||||
if (files.isEmpty())
|
||||
{
|
||||
|
@ -1464,9 +1464,9 @@ void MainWindow::FileClosedCorrect()
|
|||
WriteSettings();
|
||||
|
||||
//File was closed correct.
|
||||
QStringList restoreFiles = qApp->getSettings()->value("restoreFileList").toStringList();
|
||||
QStringList restoreFiles = qApp->getSettings()->GetRestoreFileList();
|
||||
restoreFiles.removeAll(curFile);
|
||||
qApp->getSettings()->setValue("restoreFileList", restoreFiles);
|
||||
qApp->getSettings()->SetRestoreFileList(restoreFiles);
|
||||
|
||||
// Remove autosave file
|
||||
QFile autofile(curFile +".autosave");
|
||||
|
@ -1997,7 +1997,7 @@ void MainWindow::setCurrentFile(const QString &fileName)
|
|||
}
|
||||
else
|
||||
{
|
||||
QStringList files = qApp->getSettings()->value("recentFileList").toStringList();
|
||||
QStringList files = qApp->getSettings()->GetRecentFileList();
|
||||
files.removeAll(fileName);
|
||||
files.prepend(fileName);
|
||||
while (files.size() > MaxRecentFiles)
|
||||
|
@ -2005,13 +2005,13 @@ void MainWindow::setCurrentFile(const QString &fileName)
|
|||
files.removeLast();
|
||||
}
|
||||
|
||||
qApp->getSettings()->setValue("recentFileList", files);
|
||||
qApp->getSettings()->SetRecentFileList(files);
|
||||
UpdateRecentFileActions();
|
||||
|
||||
QStringList restoreFiles = qApp->getSettings()->value("restoreFileList").toStringList();
|
||||
QStringList restoreFiles = qApp->getSettings()->GetRestoreFileList();
|
||||
restoreFiles.removeAll(fileName);
|
||||
restoreFiles.prepend(fileName);
|
||||
qApp->getSettings()->setValue("restoreFileList", restoreFiles);
|
||||
qApp->getSettings()->SetRestoreFileList(restoreFiles);
|
||||
}
|
||||
shownName+="[*]";
|
||||
setWindowTitle(shownName);
|
||||
|
@ -2034,22 +2034,16 @@ QString MainWindow::strippedName(const QString &fullFileName)
|
|||
*/
|
||||
void MainWindow::ReadSettings()
|
||||
{
|
||||
restoreGeometry(qApp->getSettings()->value("geometry").toByteArray());
|
||||
restoreState(qApp->getSettings()->value("windowState").toByteArray());
|
||||
restoreGeometry(qApp->getSettings()->GetGeometry());
|
||||
restoreState(qApp->getSettings()->GetWindowState());
|
||||
|
||||
// Scene antialiasing
|
||||
bool graphOutputValue = qApp->getSettings()->value("pattern/graphicalOutput", 1).toBool();
|
||||
const bool graphOutputValue = qApp->getSettings()->GetGraphicalOutput();
|
||||
ui->view->setRenderHint(QPainter::Antialiasing, graphOutputValue);
|
||||
ui->view->setRenderHint(QPainter::SmoothPixmapTransform, graphOutputValue);
|
||||
|
||||
// Stack limit
|
||||
bool ok = true;
|
||||
qint32 count = qApp->getSettings()->value("pattern/undo", 0).toInt(&ok);
|
||||
if (ok == false)
|
||||
{
|
||||
count = 0;
|
||||
}
|
||||
qApp->getUndoStack()->setUndoLimit(count);
|
||||
qApp->getUndoStack()->setUndoLimit(qApp->getSettings()->GetUndoCount());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -2058,8 +2052,8 @@ void MainWindow::ReadSettings()
|
|||
*/
|
||||
void MainWindow::WriteSettings()
|
||||
{
|
||||
qApp->getSettings()->setValue("geometry", saveGeometry());
|
||||
qApp->getSettings()->setValue("windowState", saveState());
|
||||
qApp->getSettings()->SetGeometry(saveGeometry());
|
||||
qApp->getSettings()->SetWindowState(saveState());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -2090,9 +2084,8 @@ bool MainWindow::MaybeSave()
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void MainWindow::UpdateRecentFileActions()
|
||||
{
|
||||
QStringList files = qApp->getSettings()->value("recentFileList").toStringList();
|
||||
|
||||
int numRecentFiles = qMin(files.size(), static_cast<int>(MaxRecentFiles));
|
||||
const QStringList files = qApp->getSettings()->GetRecentFileList();
|
||||
const int numRecentFiles = qMin(files.size(), static_cast<int>(MaxRecentFiles));
|
||||
|
||||
for (int i = 0; i < numRecentFiles; ++i)
|
||||
{
|
||||
|
@ -2222,15 +2215,9 @@ void MainWindow::InitAutoSave()
|
|||
connect(autoSaveTimer, &QTimer::timeout, this, &MainWindow::AutoSavePattern);
|
||||
autoSaveTimer->stop();
|
||||
|
||||
bool autoSave = qApp->getSettings()->value("configuration/autosave/state", 1).toBool();
|
||||
if (autoSave)
|
||||
if (qApp->getSettings()->GetAutosaveState())
|
||||
{
|
||||
bool ok = true;
|
||||
qint32 autoTime = qApp->getSettings()->value("configuration/autosave/time", 1).toInt(&ok);
|
||||
if (ok == false)
|
||||
{
|
||||
autoTime = 1;
|
||||
}
|
||||
const qint32 autoTime = qApp->getSettings()->GetAutosaveTime();
|
||||
autoSaveTimer->start(autoTime*60000);
|
||||
qCDebug(vMainWindow)<<"Autosaving each"<<autoTime<<"minutes.";
|
||||
}
|
||||
|
@ -2374,7 +2361,7 @@ void MainWindow::LoadPattern(const QString &fileName)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void MainWindow::ReopenFilesAfterCrash(QStringList &args)
|
||||
{
|
||||
QStringList files = qApp->getSettings()->value("restoreFileList").toStringList();
|
||||
QStringList files = qApp->getSettings()->GetRestoreFileList();
|
||||
if (files.size() > 0)
|
||||
{
|
||||
qCDebug(vMainWindow)<<"Reopen files after crash.";
|
||||
|
@ -2389,7 +2376,7 @@ void MainWindow::ReopenFilesAfterCrash(QStringList &args)
|
|||
}
|
||||
}
|
||||
files.clear();
|
||||
qApp->getSettings()->setValue("restoreFileList", files);
|
||||
qApp->getSettings()->SetRestoreFileList(files);
|
||||
|
||||
if (restoreFiles.size() > 0)
|
||||
{
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include "../exception/vexceptionemptyparameter.h"
|
||||
#include "../exception/vexceptionundo.h"
|
||||
#include "../core/undoevent.h"
|
||||
#include "../core/vsettings.h"
|
||||
#include "vstandardmeasurements.h"
|
||||
#include "vindividualmeasurements.h"
|
||||
#include "../../libs/qmuparser/qmuparsererror.h"
|
||||
|
@ -1701,13 +1702,9 @@ void VPattern::CheckTagExists(const QString &tag)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VPattern::GetLabelBase(unsigned int index) const
|
||||
{
|
||||
QString checkedLocale = qApp->getSettings()->value("configuration/label_language",
|
||||
QLocale::system().bcp47Name()).toString();
|
||||
|
||||
QStringList list = VApplication::LabelLanguages();
|
||||
|
||||
QStringList alphabet;
|
||||
switch (list.indexOf(checkedLocale))
|
||||
switch (list.indexOf(qApp->getSettings()->GetLabelLanguage()))
|
||||
{
|
||||
case 0: // de
|
||||
{
|
||||
|
@ -2378,15 +2375,7 @@ void VPattern::SetGradationSizes(const QMap<GSizes, bool> &options)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VPattern::GetAuthor() const
|
||||
{
|
||||
QSettings *settings = qApp->getSettings();
|
||||
SCASSERT(settings != nullptr);
|
||||
#ifdef Q_OS_WIN
|
||||
QString user = settings->value("pattern/user", QString::fromLocal8Bit(qgetenv("USERNAME").constData())).toString();
|
||||
#else
|
||||
QString user = settings->value("pattern/user", QString::fromLocal8Bit(qgetenv("USER").constData())).toString();
|
||||
#endif
|
||||
|
||||
return UniqueTagText(TagAuthor, user);
|
||||
return UniqueTagText(TagAuthor, qApp->getSettings()->GetUser());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue
Block a user