New standard path for label templates.
--HG-- branch : feature
This commit is contained in:
parent
7f570106db
commit
209a281cdc
|
@ -63,6 +63,7 @@ void PreferencesPathPage::Apply()
|
||||||
settings->SetPathPattern(ui->pathTable->item(2, 1)->text());
|
settings->SetPathPattern(ui->pathTable->item(2, 1)->text());
|
||||||
settings->SetPathLayout(ui->pathTable->item(3, 1)->text());
|
settings->SetPathLayout(ui->pathTable->item(3, 1)->text());
|
||||||
settings->SetPathTemplate(ui->pathTable->item(4, 1)->text());
|
settings->SetPathTemplate(ui->pathTable->item(4, 1)->text());
|
||||||
|
settings->SetPathLabelTemplate(ui->pathTable->item(5, 1)->text());
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -91,6 +92,9 @@ void PreferencesPathPage::DefaultPath()
|
||||||
case 4: // templates
|
case 4: // templates
|
||||||
path = VCommonSettings::GetDefPathTemplate();
|
path = VCommonSettings::GetDefPathTemplate();
|
||||||
break;
|
break;
|
||||||
|
case 5: // label templates
|
||||||
|
path = VSettings::GetDefPathLabelTemplate();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -125,6 +129,9 @@ void PreferencesPathPage::EditPath()
|
||||||
case 4: // templates
|
case 4: // templates
|
||||||
path = qApp->ValentinaSettings()->GetPathTemplate();
|
path = qApp->ValentinaSettings()->GetPathTemplate();
|
||||||
break;
|
break;
|
||||||
|
case 5: // label templates
|
||||||
|
path = qApp->ValentinaSettings()->GetPathLabelTemplate();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -164,7 +171,7 @@ void PreferencesPathPage::EditPath()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void PreferencesPathPage::InitTable()
|
void PreferencesPathPage::InitTable()
|
||||||
{
|
{
|
||||||
ui->pathTable->setRowCount(5);
|
ui->pathTable->setRowCount(6);
|
||||||
ui->pathTable->setColumnCount(2);
|
ui->pathTable->setColumnCount(2);
|
||||||
|
|
||||||
const VSettings *settings = qApp->ValentinaSettings();
|
const VSettings *settings = qApp->ValentinaSettings();
|
||||||
|
@ -204,6 +211,13 @@ void PreferencesPathPage::InitTable()
|
||||||
ui->pathTable->setItem(4, 1, item);
|
ui->pathTable->setItem(4, 1, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
ui->pathTable->setItem(5, 0, new QTableWidgetItem(tr("My label templates")));
|
||||||
|
QTableWidgetItem *item = new QTableWidgetItem(settings->GetPathLabelTemplate());
|
||||||
|
item->setToolTip(settings->GetPathLabelTemplate());
|
||||||
|
ui->pathTable->setItem(5, 1, item);
|
||||||
|
}
|
||||||
|
|
||||||
ui->pathTable->verticalHeader()->setDefaultSectionSize(20);
|
ui->pathTable->verticalHeader()->setDefaultSectionSize(20);
|
||||||
ui->pathTable->resizeColumnsToContents();
|
ui->pathTable->resizeColumnsToContents();
|
||||||
ui->pathTable->resizeRowsToContents();
|
ui->pathTable->resizeRowsToContents();
|
||||||
|
|
|
@ -48,6 +48,7 @@
|
||||||
const QString settingPathsIndividualMeasurements = QStringLiteral("paths/individual_measurements");
|
const QString settingPathsIndividualMeasurements = QStringLiteral("paths/individual_measurements");
|
||||||
const QString settingPathsMultisizeMeasurements = QStringLiteral("paths/standard_measurements");
|
const QString settingPathsMultisizeMeasurements = QStringLiteral("paths/standard_measurements");
|
||||||
const QString settingPathsTemplates = QStringLiteral("paths/templates");
|
const QString settingPathsTemplates = QStringLiteral("paths/templates");
|
||||||
|
const QString settingPathsLabelTemplate = QStringLiteral("paths/labelTemplate");
|
||||||
|
|
||||||
const QString settingConfigurationOsSeparator = QStringLiteral("configuration/osSeparator");
|
const QString settingConfigurationOsSeparator = QStringLiteral("configuration/osSeparator");
|
||||||
const QString settingConfigurationAutosaveState = QStringLiteral("configuration/autosave/state");
|
const QString settingConfigurationAutosaveState = QStringLiteral("configuration/autosave/state");
|
||||||
|
@ -314,6 +315,24 @@ void VCommonSettings::SetPathTemplate(const QString &value)
|
||||||
settings.sync();
|
settings.sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QString VCommonSettings::GetDefPathLabelTemplate()
|
||||||
|
{
|
||||||
|
return QDir::homePath() + QLatin1String("/valentina/") + tr("label templates");
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QString VCommonSettings::GetPathLabelTemplate() const
|
||||||
|
{
|
||||||
|
return value(settingPathsLabelTemplate, GetDefPathLabelTemplate()).toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VCommonSettings::SetPathLabelTemplate(const QString &value)
|
||||||
|
{
|
||||||
|
setValue(settingPathsLabelTemplate, value);
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
bool VCommonSettings::GetOsSeparator() const
|
bool VCommonSettings::GetOsSeparator() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -66,6 +66,10 @@ public:
|
||||||
QString GetPathTemplate() const;
|
QString GetPathTemplate() const;
|
||||||
void SetPathTemplate(const QString &value);
|
void SetPathTemplate(const QString &value);
|
||||||
|
|
||||||
|
static QString GetDefPathLabelTemplate();
|
||||||
|
QString GetPathLabelTemplate() const;
|
||||||
|
void SetPathLabelTemplate(const QString &value);
|
||||||
|
|
||||||
bool GetOsSeparator() const;
|
bool GetOsSeparator() const;
|
||||||
void SetOsSeparator(const bool &value);
|
void SetOsSeparator(const bool &value);
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,7 @@ DialogEditLabel::DialogEditLabel(QWidget *parent)
|
||||||
connect(ui->toolButtonTextRight, &QToolButton::toggled, this, &DialogEditLabel::SaveTextFormating);
|
connect(ui->toolButtonTextRight, &QToolButton::toggled, this, &DialogEditLabel::SaveTextFormating);
|
||||||
connect(ui->listWidget, &QListWidget::itemSelectionChanged, this, &DialogEditLabel::ShowLineDetails);
|
connect(ui->listWidget, &QListWidget::itemSelectionChanged, this, &DialogEditLabel::ShowLineDetails);
|
||||||
connect(ui->toolButtonNewLabel, &QToolButton::clicked, this, &DialogEditLabel::NewTemplate);
|
connect(ui->toolButtonNewLabel, &QToolButton::clicked, this, &DialogEditLabel::NewTemplate);
|
||||||
|
connect(ui->toolButtonExportLabel, &QToolButton::clicked, this, &DialogEditLabel::ExportTemplate);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -262,7 +263,56 @@ void DialogEditLabel::NewTemplate()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogEditLabel::ExportTemplate()
|
void DialogEditLabel::ExportTemplate()
|
||||||
{
|
{
|
||||||
|
QString filters(tr("Label template") + QLatin1String("(*.xml)"));
|
||||||
|
QString dir = qApp->Settings()->GetPathLabelTemplate();
|
||||||
|
|
||||||
|
bool usedNotExistedDir = false;
|
||||||
|
QDir directory(dir);
|
||||||
|
if (not directory.exists())
|
||||||
|
{
|
||||||
|
usedNotExistedDir = directory.mkpath(".");
|
||||||
|
}
|
||||||
|
|
||||||
|
QString fileName = QFileDialog::getSaveFileName(this, tr("Export label template"),
|
||||||
|
dir + QLatin1String("/") + tr("template") + QLatin1String(".xml"),
|
||||||
|
filters, nullptr, QFileDialog::DontUseNativeDialog);
|
||||||
|
|
||||||
|
auto RemoveTempDir = [usedNotExistedDir, dir]()
|
||||||
|
{
|
||||||
|
if (usedNotExistedDir)
|
||||||
|
{
|
||||||
|
QDir directory(dir);
|
||||||
|
directory.rmpath(".");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (fileName.isEmpty())
|
||||||
|
{
|
||||||
|
RemoveTempDir();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QFileInfo f( fileName );
|
||||||
|
if (f.suffix().isEmpty() && f.suffix() != QLatin1String("xml"))
|
||||||
|
{
|
||||||
|
fileName += QLatin1String(".xml");
|
||||||
|
}
|
||||||
|
|
||||||
|
// QString error;
|
||||||
|
// const bool result = doc->SaveDocument(fileName, error);
|
||||||
|
// if (result == false)
|
||||||
|
// {
|
||||||
|
// QMessageBox messageBox(this);
|
||||||
|
// messageBox.setIcon(QMessageBox::Warning);
|
||||||
|
// messageBox.setInformativeText(tr("Could not save file"));
|
||||||
|
// messageBox.setDefaultButton(QMessageBox::Ok);
|
||||||
|
// messageBox.setDetailedText(error);
|
||||||
|
// messageBox.setStandardButtons(QMessageBox::Ok);
|
||||||
|
// messageBox.exec();
|
||||||
|
// }
|
||||||
|
|
||||||
|
RemoveTempDir();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue
Block a user