mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-08-13 18:14:13 +02:00
Merge pull request #716 from ispyisail/fix/saveas-qet-extension-bug270
Fix bugtracker #270: Save As on Snap produces file with no .qet extension Absolutely correct implementation for portability!
This commit is contained in:
+13
-5
@@ -345,11 +345,19 @@ QString ProjectView::askUserForFilePath(bool assign) {
|
|||||||
// if no filepath is provided, return an empty string
|
// if no filepath is provided, return an empty string
|
||||||
if (filepath.isEmpty()) return(filepath);
|
if (filepath.isEmpty()) return(filepath);
|
||||||
|
|
||||||
// if the name does not end with the .qet extension and we're _not_ using xdg-desktop-portal, append it
|
// Ensure the path ends with exactly one .qet extension, regardless of
|
||||||
bool usesPortal =
|
// whether the active file dialog already appended one. Whether it does
|
||||||
qEnvironmentVariableIsSet("FLATPAK_ID") ||
|
// depends on which backend actually shows the dialog (Qt's own vs. the
|
||||||
qEnvironmentVariableIsSet("SNAP_NAME");
|
// xdg-desktop-portal used by sandboxed Snap/Flatpak builds), and that
|
||||||
if (!filepath.endsWith(".qet", Qt::CaseInsensitive) && !usesPortal) filepath += ".qet";
|
// isn't reliably predictable from environment variables alone -- an
|
||||||
|
// earlier attempt at that (only appending when *not* Snap/Flatpak,
|
||||||
|
// assuming the portal always appends it) left Snap saves with no
|
||||||
|
// extension at all whenever the portal didn't (bugtracker #270).
|
||||||
|
// Stripping any existing suffix first and re-appending it once is
|
||||||
|
// correct either way.
|
||||||
|
if (filepath.endsWith(".qet", Qt::CaseInsensitive))
|
||||||
|
filepath.chop(4);
|
||||||
|
filepath += ".qet";
|
||||||
|
|
||||||
if (assign) {
|
if (assign) {
|
||||||
// assign the provided filepath to the currently edited project
|
// assign the provided filepath to the currently edited project
|
||||||
|
|||||||
Reference in New Issue
Block a user