Merged in ValentinaZhuravska/valentina/feature (pull request #68)
Resolved issues #354 and #388 --HG-- branch : develop
This commit is contained in:
commit
475ca2c919
|
@ -66,6 +66,7 @@ void PathPage::Apply()
|
|||
qApp->ValentinaSettings()->SetPathStandardMeasurements(pathTable->item(1, 1)->text());
|
||||
qApp->ValentinaSettings()->SetPathPattern(pathTable->item(2, 1)->text());
|
||||
qApp->ValentinaSettings()->SetPathLayout(pathTable->item(3, 1)->text());
|
||||
qApp->ValentinaSettings()->SetPathTemplate(pathTable->item(4, 1)->text());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -97,6 +98,10 @@ void PathPage::DefaultPath()
|
|||
item->setText(QDir::homePath());
|
||||
item->setToolTip(QDir::homePath());
|
||||
break;
|
||||
case 4: // templates
|
||||
item->setText(qApp->ValentinaSettings()->TemplatesPath());
|
||||
item->setToolTip(qApp->ValentinaSettings()->TemplatesPath());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -124,6 +129,9 @@ void PathPage::EditPath()
|
|||
case 3: // layout path
|
||||
path = qApp->ValentinaSettings()->GetPathLayout();
|
||||
break;
|
||||
case 4: // templates
|
||||
path = qApp->ValentinaSettings()->GetPathTemplate();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -169,7 +177,7 @@ QGroupBox *PathPage::PathGroup()
|
|||
void PathPage::InitTable()
|
||||
{
|
||||
pathTable = new QTableWidget();
|
||||
pathTable->setRowCount(4);
|
||||
pathTable->setRowCount(5);
|
||||
pathTable->setColumnCount(2);
|
||||
pathTable->verticalHeader()->setVisible(false);
|
||||
pathTable->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||
|
@ -208,6 +216,13 @@ void PathPage::InitTable()
|
|||
pathTable->setItem(3, 1, item);
|
||||
}
|
||||
|
||||
{
|
||||
pathTable->setItem(4, 0, new QTableWidgetItem(tr("Templates")));
|
||||
QTableWidgetItem *item = new QTableWidgetItem(qApp->ValentinaSettings()->GetPathTemplate());
|
||||
item->setToolTip(qApp->ValentinaSettings()->GetPathTemplate());
|
||||
pathTable->setItem(4, 1, item);
|
||||
}
|
||||
|
||||
pathTable->verticalHeader()->setDefaultSectionSize(20);
|
||||
pathTable->resizeColumnsToContents();
|
||||
pathTable->resizeRowsToContents();
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
|
||||
const QString VCommonSettings::SettingPathsIndividualMeasurements = QStringLiteral("paths/individual_measurements");
|
||||
const QString VCommonSettings::SettingPathsStandardMeasurements = QStringLiteral("paths/standard_measurements");
|
||||
const QString VCommonSettings::SettingPathsTemplates = QStringLiteral("paths/templates");
|
||||
|
||||
const QString VCommonSettings::SettingConfigurationOsSeparator = QStringLiteral("configuration/osSeparator");
|
||||
const QString VCommonSettings::SettingConfigurationAutosaveState = QStringLiteral("configuration/autosave/state");
|
||||
|
@ -65,33 +66,98 @@ const QString VCommonSettings::SettingGeneralWindowState = QString
|
|||
const QString VCommonSettings::SettingGeneralToolbarsState = QStringLiteral("toolbarsState");
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VCommonSettings::VCommonSettings(Format format, Scope scope, const QString &organization, const QString &application,
|
||||
QObject *parent)
|
||||
VCommonSettings::VCommonSettings(Format format, Scope scope, const QString &organization,
|
||||
const QString &application, QObject *parent)
|
||||
:QSettings(format, scope, organization, application, parent)
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VCommonSettings::GetPathIndividualMeasurements() const
|
||||
{
|
||||
return value(SettingPathsIndividualMeasurements, QDir::homePath()).toString();
|
||||
QSettings settings(this->format(), this->scope(), this->organizationName());
|
||||
return settings.value(SettingPathsIndividualMeasurements, QDir::homePath()).toString();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VCommonSettings::SetPathIndividualMeasurements(const QString &value)
|
||||
{
|
||||
setValue(SettingPathsIndividualMeasurements, value);
|
||||
QSettings settings(this->format(), this->scope(), this->organizationName());
|
||||
settings.setValue(SettingPathsIndividualMeasurements, value);
|
||||
settings.sync();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VCommonSettings::GetPathStandardMeasurements() const
|
||||
{
|
||||
return value(SettingPathsStandardMeasurements, StandardTablesPath()).toString();
|
||||
QSettings settings(this->format(), this->scope(), this->organizationName());
|
||||
return settings.value(SettingPathsStandardMeasurements, StandardTablesPath()).toString();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VCommonSettings::SetPathStandardMeasurements(const QString &value)
|
||||
{
|
||||
setValue(SettingPathsStandardMeasurements, value);
|
||||
QSettings settings(this->format(), this->scope(), this->organizationName());
|
||||
settings.setValue(SettingPathsStandardMeasurements, value);
|
||||
settings.sync();
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VCommonSettings::GetPathTemplate() const
|
||||
{
|
||||
QSettings settings(this->format(), this->scope(), this->organizationName());
|
||||
return settings.value(SettingPathsTemplates, TemplatesPath()).toString();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VCommonSettings::SetPathTemplate(const QString &value)
|
||||
{
|
||||
QSettings settings(this->format(), this->scope(), this->organizationName());
|
||||
settings.setValue(SettingPathsTemplates, value);
|
||||
settings.sync();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VCommonSettings::TemplatesPath() const
|
||||
{
|
||||
const QString stPath = QStringLiteral("/tables/templates");
|
||||
const QString unixFullPath = QStringLiteral("/usr/share/valentina/tables/templates");
|
||||
#ifdef Q_OS_WIN
|
||||
return QApplication::applicationDirPath() + stPath;
|
||||
#elif defined(Q_OS_MAC)
|
||||
QDir dirBundle(QApplication::applicationDirPath() + QStringLiteral("/../Resources") + stPath);
|
||||
if (dirBundle.exists())
|
||||
{
|
||||
return dirBundle.absolutePath();
|
||||
}
|
||||
else
|
||||
{
|
||||
QDir dir(QApplication::applicationDirPath() + stPath);
|
||||
if (dir.exists())
|
||||
{
|
||||
return dir.absolutePath();
|
||||
}
|
||||
else
|
||||
{
|
||||
return unixFullPath;
|
||||
}
|
||||
}
|
||||
#else // Unix
|
||||
#ifdef QT_DEBUG
|
||||
Q_UNUSED(unixFullPath);
|
||||
return QApplication::applicationDirPath() + stPath;
|
||||
#else
|
||||
QDir dir(QApplication::applicationDirPath() + stPath);
|
||||
if (dir.exists())
|
||||
{
|
||||
return dir.absolutePath();
|
||||
}
|
||||
else
|
||||
{
|
||||
return unixFullPath;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -40,6 +40,7 @@ public:
|
|||
QObject *parent = 0);
|
||||
|
||||
virtual QString StandardTablesPath()const=0 ;
|
||||
QString TemplatesPath() const;
|
||||
|
||||
QString GetPathIndividualMeasurements() const;
|
||||
void SetPathIndividualMeasurements(const QString &value);
|
||||
|
@ -47,6 +48,9 @@ public:
|
|||
QString GetPathStandardMeasurements() const;
|
||||
void SetPathStandardMeasurements(const QString &value);
|
||||
|
||||
QString GetPathTemplate() const;
|
||||
void SetPathTemplate(const QString &value);
|
||||
|
||||
bool GetOsSeparator() const;
|
||||
void SetOsSeparator(const bool &value);
|
||||
|
||||
|
@ -97,8 +101,10 @@ public:
|
|||
|
||||
private:
|
||||
Q_DISABLE_COPY(VCommonSettings)
|
||||
|
||||
static const QString SettingPathsIndividualMeasurements;
|
||||
static const QString SettingPathsStandardMeasurements;
|
||||
static const QString SettingPathsTemplates;
|
||||
|
||||
static const QString SettingConfigurationOsSeparator;
|
||||
static const QString SettingConfigurationAutosaveState;
|
||||
|
|
|
@ -91,25 +91,31 @@ void VSettings::SetLabelLanguage(const QString &value)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VSettings::GetPathPattern() const
|
||||
{
|
||||
return value(SettingPathsPattern, QDir::homePath()).toString();
|
||||
QSettings settings(this->format(), this->scope(), this->organizationName());
|
||||
return settings.value(SettingPathsPattern, QDir::homePath()).toString();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSettings::SetPathPattern(const QString &value)
|
||||
{
|
||||
setValue(SettingPathsPattern, value);
|
||||
QSettings settings(this->format(), this->scope(), this->organizationName(), this->applicationName());
|
||||
settings.setValue(SettingPathsPattern, value);
|
||||
settings.sync();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VSettings::GetPathLayout() const
|
||||
{
|
||||
return value(SettingPathsLayout, QDir::homePath()).toString();
|
||||
QSettings settings(this->format(), this->scope(), this->organizationName(), this->applicationName());
|
||||
return settings.value(SettingPathsLayout, QDir::homePath()).toString();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSettings::SetPathLayout(const QString &value)
|
||||
{
|
||||
setValue(SettingPathsLayout, value);
|
||||
QSettings settings(this->format(), this->scope(), this->organizationName(), this->applicationName());
|
||||
settings.setValue(SettingPathsLayout, value);
|
||||
settings.sync();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
#include <QApplication>
|
||||
#include <QDir>
|
||||
|
||||
const QString VTapeSettings::SettingPathsTemplates = QStringLiteral("paths/templates");
|
||||
const QString VTapeSettings::SettingDataBaseGeometry = QStringLiteral("database/geometry");
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -110,61 +109,6 @@ QString VTapeSettings::StandardTablesPath() const
|
|||
#endif
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VTapeSettings::TemplatesPath() const
|
||||
{
|
||||
const QString stPath = QStringLiteral("/tables/templates");
|
||||
const QString unixFullPath = QStringLiteral("/usr/share/valentina/tables/templates");
|
||||
#ifdef Q_OS_WIN
|
||||
return QApplication::applicationDirPath() + stPath;
|
||||
#elif defined(Q_OS_MAC)
|
||||
QDir dirBundle(QApplication::applicationDirPath() + QStringLiteral("/../Resources") + stPath);
|
||||
if (dirBundle.exists())
|
||||
{
|
||||
return dirBundle.absolutePath();
|
||||
}
|
||||
else
|
||||
{
|
||||
QDir dir(QApplication::applicationDirPath() + stPath);
|
||||
if (dir.exists())
|
||||
{
|
||||
return dir.absolutePath();
|
||||
}
|
||||
else
|
||||
{
|
||||
return unixFullPath;
|
||||
}
|
||||
}
|
||||
#else // Unix
|
||||
#ifdef QT_DEBUG
|
||||
Q_UNUSED(unixFullPath);
|
||||
return QApplication::applicationDirPath() + stPath;
|
||||
#else
|
||||
QDir dir(QApplication::applicationDirPath() + stPath);
|
||||
if (dir.exists())
|
||||
{
|
||||
return dir.absolutePath();
|
||||
}
|
||||
else
|
||||
{
|
||||
return unixFullPath;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VTapeSettings::GetPathTemplate() const
|
||||
{
|
||||
return value(SettingPathsTemplates, TemplatesPath()).toString();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VTapeSettings::SetPathTemplate(const QString &value)
|
||||
{
|
||||
setValue(SettingPathsTemplates, value);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QByteArray VTapeSettings::GetDataBaseGeometry() const
|
||||
{
|
||||
|
|
|
@ -39,10 +39,6 @@ public:
|
|||
QObject *parent = 0);
|
||||
|
||||
virtual QString StandardTablesPath()const Q_DECL_OVERRIDE;
|
||||
QString TemplatesPath() const;
|
||||
|
||||
QString GetPathTemplate() const;
|
||||
void SetPathTemplate(const QString &value);
|
||||
|
||||
QByteArray GetDataBaseGeometry() const;
|
||||
void SetDataBaseGeometry(const QByteArray &value);
|
||||
|
@ -50,7 +46,6 @@ public:
|
|||
private:
|
||||
Q_DISABLE_COPY(VTapeSettings)
|
||||
|
||||
static const QString SettingPathsTemplates;
|
||||
static const QString SettingDataBaseGeometry;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user