28QgsInstallGridShiftFileDialog::QgsInstallGridShiftFileDialog(
const QString &gridName, QWidget *parent )
30 , mGridName( gridName )
35 mInstallButton->setText( tr(
"Install %1 from Folder…" ).arg( mGridName ) );
37 connect( mInstallButton, &QPushButton::clicked,
this, &QgsInstallGridShiftFileDialog::installFromFile );
40void QgsInstallGridShiftFileDialog::setDescription(
const QString &html )
42 mSummaryLabel->setHtml( html );
45void QgsInstallGridShiftFileDialog::setDownloadMessage(
const QString &message )
47 mDownloadLabel->setText( message );
50void QgsInstallGridShiftFileDialog::installFromFile()
53 const QString initialDir = settings.
value( QStringLiteral(
"lastTransformGridFolder" ), QDir::homePath(),
QgsSettings::App ).toString();
54 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" ) +
" (*)" );
56 if ( gridFilePath.isEmpty() )
61 const QFileInfo fi( gridFilePath );
66 const QString destFilePath = baseGridPath +
'/' + mGridName;
67 const QString destPath = QFileInfo( destFilePath ).absolutePath();
69 if ( !QDir( destPath ).exists() )
70 QDir().mkpath( destPath );
72 if ( QFile::copy( gridFilePath, destFilePath ) )
74 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 ) );
79 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.