diff --git a/src/doctype.cpp b/src/doctype.cpp index f4ec5211..10b3ab52 100644 --- a/src/doctype.cpp +++ b/src/doctype.cpp @@ -277,9 +277,17 @@ QString DocType::templateFile( const QString& lang ) QString DocType::defaultTemplateFile() const { - const QString findFile = "kraft/reports/invoice.trml"; - const QString re = QStandardPaths::locate(QStandardPaths::GenericDataLocation, findFile); - return re; + // first check for a country specific file + const QString country = DefaultProvider::self()->locale()->bcp47Name(); + QString findFile = QString("kraft/reports/%1/invoice.trml").arg(country); + QString re = QStandardPaths::locate(QStandardPaths::GenericDataLocation, findFile); + + if( re.isEmpty() ) { + // No lang specific one. + findFile = "kraft/reports/invoice.trml"; + re = QStandardPaths::locate(QStandardPaths::GenericDataLocation, findFile); + } + return re; } void DocType::setTemplateFile( const QString& name ) diff --git a/src/doctype.h b/src/doctype.h index 696788f6..6e6d28f6 100644 --- a/src/doctype.h +++ b/src/doctype.h @@ -66,7 +66,7 @@ class KRAFTCAT_EXPORT DocType void setNumberCycleName( const QString& ); QString defaultTemplateFile() const; - QString templateFile( const QString& language = QString() ); + QString templateFile( const QString& language ); void setTemplateFile( const QString& ); QString watermarkFile(); diff --git a/src/doctypeedit.cpp b/src/doctypeedit.cpp index aaaa7a71..160beec0 100644 --- a/src/doctypeedit.cpp +++ b/src/doctypeedit.cpp @@ -255,7 +255,9 @@ void DocTypeEdit::slotDocTypeSelected( const QString& newValue ) mNumberCycleCombo->setCurrentIndex(mNumberCycleCombo->findText( dt.numberCycleName() )); // mHeader->setText( i18n( "Details for %1:", dt.name() ) ); mExampleId->setText( dt.generateDocumentIdent( 0, nextNum ) ); - mTemplateUrl->setText( dt.templateFile() ); + + const QString country = DefaultProvider::self()->locale()->bcp47Name(); + mTemplateUrl->setText( dt.templateFile(country) ); mWatermarkUrl->setText( dt.watermarkFile() ); int mergeIdent = dt.mergeIdent().toInt(); @@ -326,7 +328,7 @@ void DocTypeEdit::slotTemplateUrlChanged( const QString& newUrl ) dt = mChangedDocTypes[docType]; } - if ( newUrl != dt.templateFile() ) { + if ( newUrl != dt.defaultTemplateFile() ) { dt.setTemplateFile( newUrl ); mChangedDocTypes[docType] = dt; } diff --git a/src/reportgenerator.cpp b/src/reportgenerator.cpp index f2ad6e82..cdcfae57 100644 --- a/src/reportgenerator.cpp +++ b/src/reportgenerator.cpp @@ -130,7 +130,7 @@ QString ReportGenerator::findTemplate( const QString& type ) if ( tmplFile.isEmpty() ) { QMessageBox msgBox; - msgBox.setText(i18n("A document template named %1 could not be loaded. ", dType.templateFile())); + msgBox.setText(i18n("A document template named %1 could not be loaded. ", tmplFile)); msgBox.setInformativeText(i18n("Please check your installation!")); msgBox.setStandardButtons(QMessageBox::Ok); msgBox.exec();