2 import Sailfish.Silica 1.0
3 import "../pages/functions.js" as Functions
5 // This component displays a list of dir options on top of a page
8 property int menuTop: 100
10 property int _selectedMenu: 0
11 property Item _contextMenu
16 _contextMenu = contextMenuComponent.createObject(rect);
20 var rootSpace = engine.diskSpace("/");
21 if (rootSpace.length > 0) {
22 _contextMenu.rootSpaceText = qsTr("Root (%1)").arg(rootSpace[0]);
23 _contextMenu.rootSpaceSubtext = rootSpace[1];
25 _contextMenu.rootSpaceText = qsTr("Root");
26 _contextMenu.rootSpaceSubtext = "";
29 var sdCardSpace = engine.diskSpace(Functions.sdcardPath());
30 if (sdCardSpace.length > 0) {
31 _contextMenu.sdCardSpaceText = qsTr("SD Card (%1)").arg(sdCardSpace[0]);
32 _contextMenu.sdCardSpaceSubtext = sdCardSpace[1];
34 _contextMenu.sdCardSpaceText = qsTr("SD Card");
35 _contextMenu.sdCardSpaceSubtext = "";
38 _contextMenu.show(rect);
49 // bg rectangle for context menu so it covers underlying items
54 height: _contextMenu ? _contextMenu.height : 0
59 id: contextMenuComponent
62 property string sdCardSpaceText: ""
63 property string sdCardSpaceSubtext: ""
64 property string rootSpaceText: ""
65 property string rootSpaceSubtext: ""
67 // delayed action so that menu has already closed when page transition happens
69 if (_selectedMenu == 1) {
72 } else if (_selectedMenu == 2) {
73 var sdcard = Functions.sdcardPath();
74 if (engine.exists(sdcard)) {
75 Functions.goToFolder(sdcard);
77 // this assumes that the page has a notificationPanel
78 notificationPanel.showText(qsTr("SD Card not found"), sdcard);
81 } else if (_selectedMenu == 3) {
82 var androidSdcard = Functions.androidSdcardPath();
83 if (engine.exists(androidSdcard)) {
84 Functions.goToFolder(androidSdcard);
86 // this assumes that the page has a notificationPanel
87 notificationPanel.showText(qsTr("Android Storage not found"), androidSdcard);
90 } else if (_selectedMenu == 4) {
98 onClicked: _selectedMenu = 1
101 text: sdCardSpaceText
102 subtext: sdCardSpaceSubtext
103 onClicked: _selectedMenu = 2
106 text: qsTr("Android Storage")
107 onClicked: _selectedMenu = 3
111 subtext: rootSpaceSubtext
112 onClicked: _selectedMenu = 4