Changeset View
Changeset View
Standalone View
Standalone View
kcmkwin/kwinrules/package/contents/ui/FileDialogLoader.qml
Show All 30 Lines | 24 | Loader { | |||
---|---|---|---|---|---|
31 | 31 | | |||
32 | signal fileSelected(string path) | 32 | signal fileSelected(string path) | ||
33 | 33 | | |||
34 | sourceComponent: QtDialogs.FileDialog { | 34 | sourceComponent: QtDialogs.FileDialog { | ||
35 | id: fileDialog | 35 | id: fileDialog | ||
36 | 36 | | |||
37 | title: root.title | 37 | title: root.title | ||
38 | selectExisting: !root.isSaveDialog | 38 | selectExisting: !root.isSaveDialog | ||
39 | folder: (root.lastFolder == "") ? shortcuts.home : root.lastFolder | 39 | folder: root.lastFolder || shortcuts.home | ||
broulik: Why not just `!root.lastFolder`? or even
```
root.lastFolder || shortcuts.home
``` | |||||
ognarb: I didn't know that an empty string in js was returning false. | |||||
It's not, but the operators in JS work a little differently. They don't cast to bool. broulik: It's not, but the operators in JS work a little differently. They don't cast to bool. | |||||
I also didn't know that about JS. Python operators also behave that way. Nice! iasensio: I also didn't know that about JS. Python operators also behave that way. Nice! | |||||
There's also ?? operator in Qt 5.15 which is the proper Null coalescing operator broulik: There's also `??` operator in Qt 5.15 which is the proper Null coalescing operator | |||||
40 | nameFilters: [ i18n("KWin Rules (*.kwinrule)") ] | 40 | nameFilters: [ i18n("KWin Rules (*.kwinrule)") ] | ||
41 | defaultSuffix: "*.kwinrule" | 41 | defaultSuffix: "*.kwinrule" | ||
42 | 42 | | |||
43 | Component.onCompleted: { | 43 | Component.onCompleted: { | ||
44 | open(); | 44 | open(); | ||
45 | } | 45 | } | ||
46 | 46 | | |||
47 | onAccepted: { | 47 | onAccepted: { | ||
48 | root.lastFolder = folder; | 48 | root.lastFolder = folder; | ||
49 | if (fileUrl != "") { | 49 | if (fileUrl != "") { | ||
This seems to break importing files for me. iasensio: This seems to break importing files for me.
Checking `lenght > 0` also didn't work, just old… | |||||
If fileUrl is a QUrl, then that can lead to funky results as url basic type isn't astring. So fileUrl != "" it is (not the strict operator).. or fileUrl.toString() !== "" broulik: If `fileUrl` is a `QUrl`, then that can lead to funky results as `url` basic type isn't… | |||||
50 | root.fileSelected(fileUrl); | 50 | root.fileSelected(fileUrl); | ||
51 | } | 51 | } | ||
52 | root.active = false; | 52 | root.active = false; | ||
53 | } | 53 | } | ||
54 | 54 | | |||
55 | onRejected: { | 55 | onRejected: { | ||
56 | root.active = false; | 56 | root.active = false; | ||
57 | } | 57 | } | ||
58 | } | 58 | } | ||
59 | } | 59 | } |
Why not just !root.lastFolder? or even