Skip to content

Commit

Permalink
Use correct QgsSettings keys for layouts
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jan 5, 2018
1 parent e3daac4 commit 612969c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 29 deletions.
50 changes: 25 additions & 25 deletions src/app/layout/qgslayoutdesignerdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ QgsLayoutDesignerDialog::QgsLayoutDesignerDialog( QWidget *parent, Qt::WindowFla
viewLayout->addWidget( mVerticalRuler, 1, 0 );

//initial state of rulers
bool showRulers = settings.value( QStringLiteral( "LayoutDesigner/showRulers" ), true ).toBool();
bool showRulers = settings.value( QStringLiteral( "LayoutDesigner/showRulers" ), true, QgsSettings::App ).toBool();
mActionShowRulers->setChecked( showRulers );
mHorizontalRuler->setVisible( showRulers );
mVerticalRuler->setVisible( showRulers );
Expand Down Expand Up @@ -950,7 +950,7 @@ void QgsLayoutDesignerDialog::showRulers( bool visible )
mRulerLayoutFix->setVisible( visible );

QgsSettings settings;
settings.setValue( QStringLiteral( "LayoutDesigner/showRulers" ), visible );
settings.setValue( QStringLiteral( "LayoutDesigner/showRulers" ), visible, QgsSettings::App );
}

void QgsLayoutDesignerDialog::showGrid( bool visible )
Expand Down Expand Up @@ -1448,7 +1448,7 @@ void QgsLayoutDesignerDialog::saveAsTemplate()
{
//show file dialog
QgsSettings settings;
QString lastSaveDir = settings.value( QStringLiteral( "UI/lastComposerTemplateDir" ), QDir::homePath() ).toString();
QString lastSaveDir = settings.value( QStringLiteral( "lastComposerTemplateDir" ), QDir::homePath(), QgsSettings::App ).toString();
#ifdef Q_OS_MAC
QgisApp::instance()->activateWindow();
this->raise();
Expand All @@ -1468,7 +1468,7 @@ void QgsLayoutDesignerDialog::saveAsTemplate()
QString saveFileNameWithSuffix = saveFileName.append( ".qpt" );
saveFileInfo = QFileInfo( saveFileNameWithSuffix );
}
settings.setValue( QStringLiteral( "UI/lastComposerTemplateDir" ), saveFileInfo.absolutePath() );
settings.setValue( QStringLiteral( "lastComposerTemplateDir" ), saveFileInfo.absolutePath(), QgsSettings::App );

QgsReadWriteContext context;
context.setPathResolver( QgsProject::instance()->pathResolver() );
Expand All @@ -1484,7 +1484,7 @@ void QgsLayoutDesignerDialog::addItemsFromTemplate()
return;

QgsSettings settings;
QString openFileDir = settings.value( QStringLiteral( "UI/lastComposerTemplateDir" ), QDir::homePath() ).toString();
QString openFileDir = settings.value( QStringLiteral( "lastComposerTemplateDir" ), QDir::homePath(), QgsSettings::App ).toString();
QString openFileString = QFileDialog::getOpenFileName( nullptr, tr( "Load template" ), openFileDir, tr( "Layout templates" ) + " (*.qpt *.QPT)" );

if ( openFileString.isEmpty() )
Expand All @@ -1493,7 +1493,7 @@ void QgsLayoutDesignerDialog::addItemsFromTemplate()
}

QFileInfo openFileInfo( openFileString );
settings.setValue( QStringLiteral( "UI/LastComposerTemplateDir" ), openFileInfo.absolutePath() );
settings.setValue( QStringLiteral( "LastComposerTemplateDir" ), openFileInfo.absolutePath(), QgsSettings::App );

QFile templateFile( openFileString );
if ( !templateFile.open( QIODevice::ReadOnly ) )
Expand Down Expand Up @@ -1714,7 +1714,7 @@ void QgsLayoutDesignerDialog::exportToRaster()
QgsLayoutAtlas *printAtlas = atlas();
if ( printAtlas && printAtlas->enabled() && mActionAtlasPreview->isChecked() )
{
QString lastUsedDir = s.value( QStringLiteral( "UI/lastSaveAsImageDir" ), QDir::homePath() ).toString();
QString lastUsedDir = s.value( QStringLiteral( "lastSaveAsImageDir" ), QDir::homePath(), QgsSettings::App ).toString();
outputFileName = QDir( lastUsedDir ).filePath( QgsFileUtils::stringToSafeFilename( printAtlas->currentFilename() ) );
}

Expand Down Expand Up @@ -1799,7 +1799,7 @@ void QgsLayoutDesignerDialog::exportToPdf()
}

QgsSettings settings;
QString lastUsedFile = settings.value( QStringLiteral( "UI/lastSaveAsPdfFile" ), QStringLiteral( "qgis.pdf" ) ).toString();
QString lastUsedFile = settings.value( QStringLiteral( "lastSaveAsPdfFile" ), QStringLiteral( "qgis.pdf" ), QgsSettings::App ).toString();
QFileInfo file( lastUsedFile );
QString outputFileName;

Expand Down Expand Up @@ -1833,7 +1833,7 @@ void QgsLayoutDesignerDialog::exportToPdf()
outputFileName += QLatin1String( ".pdf" );
}

settings.setValue( QStringLiteral( "UI/lastSaveAsPdfFile" ), outputFileName );
settings.setValue( QStringLiteral( "lastSaveAsPdfFile" ), outputFileName, QgsSettings::App );

mView->setPaintingEnabled( false );
QApplication::setOverrideCursor( Qt::BusyCursor );
Expand Down Expand Up @@ -1901,7 +1901,7 @@ void QgsLayoutDesignerDialog::exportToSvg()
showSvgExportWarning();

QgsSettings settings;
QString lastUsedFile = settings.value( QStringLiteral( "UI/lastSaveAsSvgFile" ), QStringLiteral( "qgis.svg" ) ).toString();
QString lastUsedFile = settings.value( QStringLiteral( "lastSaveAsSvgFile" ), QStringLiteral( "qgis.svg" ), QgsSettings::App ).toString();
QFileInfo file( lastUsedFile );
QString outputFileName = QgsFileUtils::stringToSafeFilename( mMasterLayout->name() );

Expand Down Expand Up @@ -1936,7 +1936,7 @@ void QgsLayoutDesignerDialog::exportToSvg()
}

bool prevSettingLabelsAsOutlines = mLayout->project()->readBoolEntry( QStringLiteral( "PAL" ), QStringLiteral( "/DrawOutlineLabels" ), true );
settings.setValue( QStringLiteral( "UI/lastSaveAsSvgFile" ), outputFileName );
settings.setValue( QStringLiteral( "lastSaveAsSvgFile" ), outputFileName, QgsSettings::App );

QgsLayoutExporter::SvgExportSettings svgSettings;
bool exportAsText = false;
Expand Down Expand Up @@ -2307,7 +2307,7 @@ void QgsLayoutDesignerDialog::exportAtlasToRaster()
}

QgsSettings s;
QString lastUsedDir = s.value( QStringLiteral( "UI/lastSaveAtlasAsImagesDir" ), QDir::homePath() ).toString();
QString lastUsedDir = s.value( QStringLiteral( "lastSaveAtlasAsImagesDir" ), QDir::homePath(), QgsSettings::App ).toString();

QFileDialog dlg( this, tr( "Export Atlas to Directory" ) );
dlg.setFileMode( QFileDialog::Directory );
Expand All @@ -2330,7 +2330,7 @@ void QgsLayoutDesignerDialog::exportAtlasToRaster()
{
return;
}
s.setValue( QStringLiteral( "UI/lastSaveAtlasAsImagesDir" ), dir );
s.setValue( QStringLiteral( "lastSaveAtlasAsImagesDir" ), dir, QgsSettings::App );

// test directory (if it exists and is writable)
if ( !QDir( dir ).exists() || !QFileInfo( dir ).isWritable() )
Expand Down Expand Up @@ -2462,7 +2462,7 @@ void QgsLayoutDesignerDialog::exportAtlasToSvg()
}

QgsSettings s;
QString lastUsedDir = s.value( QStringLiteral( "UI/lastSaveAtlasAsSvgDir" ), QDir::homePath() ).toString();
QString lastUsedDir = s.value( QStringLiteral( "lastSaveAtlasAsSvgDir" ), QDir::homePath(), QgsSettings::App ).toString();

QFileDialog dlg( this, tr( "Export Atlas to Directory" ) );
dlg.setFileMode( QFileDialog::Directory );
Expand All @@ -2488,7 +2488,7 @@ void QgsLayoutDesignerDialog::exportAtlasToSvg()
{
return;
}
s.setValue( QStringLiteral( "UI/lastSaveAtlasAsSvgDir" ), dir );
s.setValue( QStringLiteral( "lastSaveAtlasAsSvgDir" ), dir, QgsSettings::App );

// test directory (if it exists and is writable)
if ( !QDir( dir ).exists() || !QFileInfo( dir ).isWritable() )
Expand Down Expand Up @@ -2626,7 +2626,7 @@ void QgsLayoutDesignerDialog::exportAtlasToPdf()
QgsSettings settings;
if ( singleFile )
{
QString lastUsedFile = settings.value( QStringLiteral( "UI/lastSaveAsPdfFile" ), QStringLiteral( "qgis.pdf" ) ).toString();
QString lastUsedFile = settings.value( QStringLiteral( "lastSaveAsPdfFile" ), QStringLiteral( "qgis.pdf" ), QgsSettings::App ).toString();
QFileInfo file( lastUsedFile );

QgsLayoutAtlas *printAtlas = atlas();
Expand Down Expand Up @@ -2658,7 +2658,7 @@ void QgsLayoutDesignerDialog::exportAtlasToPdf()
{
outputFileName += QLatin1String( ".pdf" );
}
settings.setValue( QStringLiteral( "UI/lastSaveAsPdfFile" ), outputFileName );
settings.setValue( QStringLiteral( "lastSaveAsPdfFile" ), outputFileName, QgsSettings::App );
}
else
{
Expand All @@ -2677,7 +2677,7 @@ void QgsLayoutDesignerDialog::exportAtlasToPdf()
}


QString lastUsedDir = settings.value( QStringLiteral( "UI/lastSaveAtlasAsPdfDir" ), QDir::homePath() ).toString();
QString lastUsedDir = settings.value( QStringLiteral( "lastSaveAtlasAsPdfDir" ), QDir::homePath(), QgsSettings::App ).toString();

QFileDialog dlg( this, tr( "Export Atlas to Directory" ) );
dlg.setFileMode( QFileDialog::Directory );
Expand All @@ -2703,7 +2703,7 @@ void QgsLayoutDesignerDialog::exportAtlasToPdf()
{
return;
}
settings.setValue( QStringLiteral( "UI/lastSaveAtlasAsPdfDir" ), dir );
settings.setValue( QStringLiteral( "lastSaveAtlasAsPdfDir" ), dir, QgsSettings::App );

// test directory (if it exists and is writable)
if ( !QDir( dir ).exists() || !QFileInfo( dir ).isWritable() )
Expand Down Expand Up @@ -2929,7 +2929,7 @@ void QgsLayoutDesignerDialog::exportReportToSvg()
showSvgExportWarning();

QgsSettings settings;
QString lastUsedFile = settings.value( QStringLiteral( "UI/lastSaveAsSvgFile" ), QStringLiteral( "qgis.svg" ) ).toString();
QString lastUsedFile = settings.value( QStringLiteral( "lastSaveAsSvgFile" ), QStringLiteral( "qgis.svg" ), QgsSettings::App ).toString();
QFileInfo file( lastUsedFile );
QString outputFileName = file.path() + '/' + QgsFileUtils::stringToSafeFilename( mMasterLayout->name() ) + QStringLiteral( ".svg" );

Expand All @@ -2953,7 +2953,7 @@ void QgsLayoutDesignerDialog::exportReportToSvg()
this->raise();
#endif
bool prevSettingLabelsAsOutlines = mMasterLayout->layoutProject()->readBoolEntry( QStringLiteral( "PAL" ), QStringLiteral( "/DrawOutlineLabels" ), true );
settings.setValue( QStringLiteral( "UI/lastSaveAsSvgFile" ), outputFileName );
settings.setValue( QStringLiteral( "lastSaveAsSvgFile" ), outputFileName, QgsSettings::App );

QgsLayoutExporter::SvgExportSettings svgSettings;
bool exportAsText = false;
Expand Down Expand Up @@ -3058,7 +3058,7 @@ void QgsLayoutDesignerDialog::exportReportToPdf()
{
QgsSettings settings;

QString lastUsedFile = settings.value( QStringLiteral( "UI/lastSaveAsPdfFile" ), QStringLiteral( "qgis.pdf" ) ).toString();
QString lastUsedFile = settings.value( QStringLiteral( "lastSaveAsPdfFile" ), QStringLiteral( "qgis.pdf" ), QgsSettings::App ).toString();
QFileInfo file( lastUsedFile );

QString outputFileName = file.path() + '/' + QgsFileUtils::stringToSafeFilename( mMasterLayout->name() ) + QStringLiteral( ".pdf" );
Expand All @@ -3082,7 +3082,7 @@ void QgsLayoutDesignerDialog::exportReportToPdf()
{
outputFileName += QLatin1String( ".pdf" );
}
settings.setValue( QStringLiteral( "UI/lastSaveAsPdfFile" ), outputFileName );
settings.setValue( QStringLiteral( "lastSaveAsPdfFile" ), outputFileName, QgsSettings::App );

mView->setPaintingEnabled( false );
QApplication::setOverrideCursor( Qt::BusyCursor );
Expand Down Expand Up @@ -3357,9 +3357,9 @@ QgsLayoutView *QgsLayoutDesignerDialog::view()
void QgsLayoutDesignerDialog::saveWindowState()
{
QgsSettings settings;
settings.setValue( QStringLiteral( "LayoutDesigner/geometry" ), saveGeometry() );
settings.setValue( QStringLiteral( "LayoutDesigner/geometry" ), saveGeometry(), QgsSettings::App );
// store the toolbar/dock widget settings using Qt settings API
settings.setValue( QStringLiteral( "LayoutDesigner/state" ), saveState() );
settings.setValue( QStringLiteral( "LayoutDesigner/state" ), saveState(), QgsSettings::App );
}

void QgsLayoutDesignerDialog::restoreWindowState()
Expand Down
8 changes: 4 additions & 4 deletions src/app/layout/qgslayoutmanagerdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ QgsLayoutManagerDialog::QgsLayoutManagerDialog( QWidget *parent, Qt::WindowFlags
mTemplateFileWidget->setDialogTitle( tr( "Select a Template" ) );
mTemplateFileWidget->lineEdit()->setShowClearButton( false );
QgsSettings settings;
mTemplateFileWidget->setDefaultRoot( settings.value( QStringLiteral( "UI/lastComposerTemplateDir" ), QString() ).toString() );
mTemplateFileWidget->setFilePath( settings.value( QStringLiteral( "UI/ComposerManager/templatePath" ), QString() ).toString() );
mTemplateFileWidget->setDefaultRoot( settings.value( QStringLiteral( "lastComposerTemplateDir" ), QString(), QgsSettings::App ).toString() );
mTemplateFileWidget->setFilePath( settings.value( QStringLiteral( "ComposerManager/templatePath" ), QString(), QgsSettings::App ).toString() );

connect( mTemplateFileWidget, &QgsFileWidget::fileChanged, this, [ = ]
{
QgsSettings settings;
settings.setValue( QStringLiteral( "UI/ComposerManager/templatePath" ), mTemplateFileWidget->filePath() );
settings.setValue( QStringLiteral( "ComposerManager/templatePath" ), mTemplateFileWidget->filePath(), QgsSettings::App );
QFileInfo tmplFileInfo( mTemplateFileWidget->filePath() );
settings.setValue( QStringLiteral( "UI/lastComposerTemplateDir" ), tmplFileInfo.absolutePath() );
settings.setValue( QStringLiteral( "lastComposerTemplateDir" ), tmplFileInfo.absolutePath(), QgsSettings::App );
} );

mModel = new QgsLayoutManagerModel( QgsProject::instance()->layoutManager(),
Expand Down

0 comments on commit 612969c

Please sign in to comment.