Skip to content

Commit afbd1fd

Browse files
committed
Add new settings dialog from overflow menu and hidden files shortcut
Closes: #17
1 parent d9d3570 commit afbd1fd

File tree

3 files changed

+84
-0
lines changed

3 files changed

+84
-0
lines changed

src/app/qml/FolderPage.qml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,19 @@ Page {
6767
shortcut: "Alt+Up"
6868
onTriggered: folderModel.model.cdUp()
6969
},
70+
Action {
71+
visible: false
72+
shortcut: "Ctrl+H"
73+
onTriggered: folderModel.model.toggleShowHiddenFiles();
74+
},
7075
Action {
7176
iconName: "action/open_in_new"
7277
name: qsTr("Open in Terminal")
7378
},
7479
Action {
7580
iconName: "action/settings"
7681
name: qsTr("Settings")
82+
onTriggered: settings.show()
7783
}
7884
]
7985

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
* Files app - File manager for Papyros
3+
* Copyright (C) 2015 Ricardo Vieira <ricardo.vieira@tecnico.ulisboa.pt>
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
19+
import QtQuick 2.2
20+
import Material 0.1
21+
import Material.Extras 0.1
22+
import Material.ListItems 0.1 as ListItem
23+
24+
Dialog {
25+
title: "Settings"
26+
height: parent.height * 0.7
27+
28+
Column {
29+
id: settingsList
30+
anchors.left: parent.left
31+
anchors.right: parent.right
32+
CheckBox {
33+
id: hiddenCheck
34+
text: qsTr("Show hidden files")
35+
checked: folderModel.model.showHiddenFiles
36+
onClicked: folderModel.model.toggleShowHiddenFiles();
37+
38+
// If the checkbox is clicked it loses the connection with
39+
// folderModel.model.showHiddenFiles so we need connect to the signal
40+
Connections {
41+
target: folderModel.model
42+
onShowHiddenFilesChanged:
43+
hiddenCheck.checked = folderModel.model.showHiddenFiles
44+
}
45+
}
46+
ListItem.SimpleMenu {
47+
id: sortByMenu
48+
text: "Sort by:"
49+
model: ["Name", "Date"]
50+
selectedIndex: folderModel.model.sortBy
51+
// Here we can't just toggle, we need to set the selected option
52+
onSelectedIndexChanged: folderModel.model.sortBy = selectedIndex
53+
54+
Connections {
55+
target: folderModel.model
56+
onSortByChanged:
57+
sortByMenu.selectedIndex = folderModel.model.sortBy
58+
}
59+
}
60+
ListItem.SimpleMenu {
61+
id: sortOrderMenu
62+
text: "Sort order:"
63+
model: ["Ascending", "Descending"]
64+
onSelectedIndexChanged: folderModel.model.sortOrder = selectedIndex
65+
66+
Connections {
67+
target: folderModel.model
68+
onSortOrderChanged:
69+
sortOrderMenu.selectedIndex = folderModel.model.sortOrder
70+
}
71+
}
72+
}
73+
}

src/app/qml/main.qml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import Material 0.1
2222
import Material.Extras 0.1
2323
import io.papyros.folderlistmodel 1.0
2424
import "backend"
25+
import "dialogs"
2526

2627
ApplicationWindow {
2728
id: app
@@ -56,6 +57,10 @@ ApplicationWindow {
5657
id: folderModel
5758
}
5859

60+
SettingsDialog {
61+
id: settings
62+
}
63+
5964
Dialog {
6065
id: confirmDialog
6166

0 commit comments

Comments
 (0)