Skip to content

Commit

Permalink
Use Sailfish.Pickers.FolderPickerPage to configure music directories (#…
Browse files Browse the repository at this point in the history
…33)

* Use Sailfish.Pickers.FolderPickerPage to configure music directories

* Detect if Pickers are available.
  Fallback to old code if the Sailfish.Pickers module is not available in the import path.

---------

Co-authored-by: Damien Caliste <[email protected]>
  • Loading branch information
smokku and dcaliste authored Feb 7, 2024
1 parent 34ee039 commit 0e29326
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions FlowPlayer.pro
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ OTHER_FILES += \
qml/pages/SongsPage.qml \
qml/pages/ManageFolders.qml \
qml/pages/AddFolder.qml \
qml/pages/PickFolder.qml \
qml/pages/AboutPage.qml \
qml/pages/SelectPreset.qml \
qml/pages/LastFM.qml \
Expand Down
2 changes: 1 addition & 1 deletion qml/pages/ManageFolders.qml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Page {
PullDownMenu {
MenuItem {
text: qsTr("Add folder")
onClicked: pageStack.push("AddFolder.qml")
onClicked: pageStack.push(hasPickers ? "PickFolder.qml" : "AddFolder.qml")
}
}

Expand Down
12 changes: 12 additions & 0 deletions qml/pages/PickFolder.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import QtQuick 2.0
import Sailfish.Silica 1.0
import Sailfish.Pickers 1.0
import FlowPlayer 1.0

FolderPickerPage {
dialogTitle: qsTr("Select folder")
showSystemFiles: false
onSelectedPathChanged: {
utils.addFolderToList(selectedPath)
}
}
5 changes: 5 additions & 0 deletions src/FlowPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ int main(int argc, char *argv[])

window->engine()->addImportPath("/usr/share/flowplayer/qml");
window->rootContext()->setContextProperty("appVersion", VERSION);
bool hasPickers = false;
for (const QString &path : window->engine()->importPathList()) {
hasPickers = hasPickers || QFile::exists(path + "/Sailfish/Pickers");
}
window->rootContext()->setContextProperty("hasPickers", hasPickers);

qmlRegisterType<Utils>("FlowPlayer", 1, 0, "Utils");
qmlRegisterType<CoverSearch>("FlowPlayer", 1, 0, "CoverSearch");
Expand Down

0 comments on commit 0e29326

Please sign in to comment.