diff --git a/cmake/NSIS.template.in b/cmake/NSIS.template.in index c04169c8..5a931e19 100644 --- a/cmake/NSIS.template.in +++ b/cmake/NSIS.template.in @@ -51,13 +51,15 @@ Section "Application" SecApplication SectionEnd Section "Update configuration" SecUpdateConfig - WriteRegStr HKCU "Software\Cockatrice\Cockatrice\paths" "carddatabase" "$APPDATA\Cockatrice\cards.xml" - WriteRegStr HKCU "Software\Cockatrice\Cockatrice\paths" "decks" "$APPDATA\Cockatrice\decks" - WriteRegStr HKCU "Software\Cockatrice\Cockatrice\paths" "pics" "$APPDATA\Cockatrice\pics" - WriteRegStr HKCU "Software\Cockatrice\Cockatrice\sound" "path" "$APPDATA\Cockatrice\sounds" + SetShellVarContext current + WriteRegStr HKCU "Software\Cockatrice\Cockatrice\paths" "carddatabase" "$LOCALAPPDATA\Cockatrice\cards.xml" + WriteRegStr HKCU "Software\Cockatrice\Cockatrice\paths" "decks" "$LOCALAPPDATA\Cockatrice\decks" + WriteRegStr HKCU "Software\Cockatrice\Cockatrice\paths" "pics" "$LOCALAPPDATA\Cockatrice\pics" + WriteRegStr HKCU "Software\Cockatrice\Cockatrice\sound" "path" "$LOCALAPPDATA\Cockatrice\sounds" SectionEnd Section "Start menu item" SecStartMenu + SetShellVarContext all createDirectory "$SMPROGRAMS\Cockatrice" createShortCut "$SMPROGRAMS\Cockatrice\Cockatrice.lnk" "$INSTDIR\cockatrice.exe" '--debug-output' createShortCut "$SMPROGRAMS\Cockatrice\Oracle.lnk" "$INSTDIR\oracle.exe" @@ -65,7 +67,7 @@ Section "Start menu item" SecStartMenu SectionEnd Section Uninstall -SetShellVarContext all + SetShellVarContext all RMDir /r "$INSTDIR\zonebg" RMDir /r "$INSTDIR\plugins" RMDir /r "$INSTDIR\sounds" @@ -83,8 +85,10 @@ SetShellVarContext all RMDir "$SMPROGRAMS\Cockatrice" - DeleteRegKey HKCU "Software\Cockatrice" DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" + + SetShellVarContext current + DeleteRegKey HKCU "Software\Cockatrice" SectionEnd LangString DESC_SecApplication ${LANG_ENGLISH} "Cockatrice program files" diff --git a/oracle/src/oraclewizard.cpp b/oracle/src/oraclewizard.cpp index c1c8b982..f0cb3351 100644 --- a/oracle/src/oraclewizard.cpp +++ b/oracle/src/oraclewizard.cpp @@ -7,6 +7,7 @@ #endif #include #include +#include #include #include #include @@ -403,15 +404,13 @@ bool SaveSetsPage::validatePage() QStandardPaths::standardLocations(QStandardPaths::DataLocation).first(); #endif QSettings* settings = new QSettings(this); - QString savePath = settings->value("paths/carddatabase").toString(); - if (savePath.isEmpty()) { - QDir().mkpath(dataDir); - } + QString defaultPath = settings->value("paths/carddatabase").toString(); QString windowName = tr("Save card database"); QString fileType = tr("XML; card database (*.xml)"); + do { QString fileName; - if (savePath.isEmpty()) { + if (defaultPath.isEmpty()) { if (defaultPathCheckBox->isChecked()) fileName = dataDir + "/cards.xml"; else @@ -420,13 +419,19 @@ bool SaveSetsPage::validatePage() } else { if (defaultPathCheckBox->isChecked()) - fileName = savePath; + fileName = defaultPath; else - fileName = QFileDialog::getSaveFileName(this, windowName, savePath, fileType); + fileName = QFileDialog::getSaveFileName(this, windowName, defaultPath, fileType); } if (fileName.isEmpty()) { return false; } + + QFileInfo fi(fileName); + QDir fileDir(fi.path()); + if (!fileDir.exists() && !fileDir.mkpath(fileDir.absolutePath())) { + return false; + } if (wizard()->importer->saveToFile(fileName)) { ok = true;