19#include "moc_qgsinstallgridshiftdialog.cpp"
29QgsInstallGridShiftFileDialog::QgsInstallGridShiftFileDialog(
const QString &gridName, QWidget *parent )
31 , mGridName( gridName )
36 mInstallButton->setText( tr(
"Install %1 from Folder…" ).arg( mGridName ) );
38 connect( mInstallButton, &QPushButton::clicked,
this, &QgsInstallGridShiftFileDialog::installFromFile );
41void QgsInstallGridShiftFileDialog::setDescription(
const QString &html )
43 mSummaryLabel->setHtml( html );
46void QgsInstallGridShiftFileDialog::setDownloadMessage(
const QString &message )
48 mDownloadLabel->setText( message );
51void QgsInstallGridShiftFileDialog::installFromFile()
54 const QString initialDir = settings.
value( QStringLiteral(
"lastTransformGridFolder" ), QDir::homePath(),
QgsSettings::App ).toString();
55 const QString gridFilePath = QFileDialog::getOpenFileName(
nullptr, tr(
"Install %1" ).arg( mGridName ), initialDir, QStringLiteral(
"%1 (%1);;" ).arg( mGridName ) + tr(
"Grid Shift Files" ) + QStringLiteral(
" (*.gsb *.GSB *.tif);;" ) + QObject::tr(
"All files" ) +
" (*)" );
57 if ( gridFilePath.isEmpty() )
62 const QFileInfo fi( gridFilePath );
67 const QString destFilePath = baseGridPath +
'/' + mGridName;
68 const QString destPath = QFileInfo( destFilePath ).absolutePath();
70 if ( !QDir( destPath ).exists() )
71 QDir().mkpath( destPath );
73 if ( QFile::copy( gridFilePath, destFilePath ) )
75 QMessageBox::information(
this, tr(
"Install Grid File" ), tr(
"The %1 grid shift file has been successfully installed. Please restart QGIS for this change to take effect." ).arg( mGridName ) );
80 QMessageBox::critical(
this, tr(
"Install Grid File" ), tr(
"Could not copy %1 to %2. Please check folder permissions and retry." ).arg( mGridName, destFilePath ) );
static QString qgisSettingsDirPath()
Returns the path to the settings directory in user's home dir.
static void enableAutoGeometryRestore(QWidget *widget, const QString &key=QString())
Register the widget to allow its position to be automatically saved and restored when open and closed...
This class is a composition of two QSettings instances:
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.