Commit fb39edeb authored by camilo higuita's avatar camilo higuita

allow multiple selection and initial work on copy,cut,paste,rename,delete actions

parent 2104bdb2
......@@ -158,6 +158,26 @@ QVariantMap Index::getDirInfo(const QString &path, const QString &type)
return data;
}
bool Index::copy(const QString &path, const QString &where)
{
}
bool Index::cut(const QString &path, const QString &where)
{
}
bool Index::remove(const QString &path)
{
}
bool Index::rename(const QString &path, const QString &name)
{
}
void Index::saveSettings(const QString &key, const QVariant &value, const QString &group)
{
INX::saveSettings(key, value, group);
......
......@@ -28,6 +28,13 @@ public:
Q_INVOKABLE static QVariant loadSettings(const QString &key, const QString &group, const QVariant &defaultValue);
Q_INVOKABLE static QVariantMap getDirInfo(const QString &path, const QString &type);
/*FILE ACTIONS*/
Q_INVOKABLE static bool copy(const QString &path, const QString &where);
Q_INVOKABLE static bool cut(const QString &path, const QString &where);
Q_INVOKABLE static bool remove(const QString &path);
Q_INVOKABLE static bool rename(const QString &path, const QString &name);
private:
QFileSystemWatcher *watcher;
......
......@@ -96,6 +96,13 @@ Kirigami.ApplicationWindow
id: itemMenu
onBookmarkClicked: INX.bookmarkFolder(path)
onCopyClicked:
{
if(browser.selectedPaths.indexOf(path) > -1)
browser.copy(browser.selectedPaths)
else browser.copy(path)
}
}
......
......@@ -19,5 +19,8 @@
<file>widgets/views/PathBar.qml</file>
<file>widgets/views/PathBarDelegate.qml</file>
<file>widgets/terminal/Terminal.qml</file>
<file>widgets/views/SelectionBar.qml</file>
<file>widgets/views/BrowserOptions.qml</file>
<file>widgets/views/BrowserMenu.qml</file>
</qresource>
</RCC>
......@@ -10,10 +10,14 @@ import org.kde.kirigami 2.0 as Kirigami
ColumnLayout
{
property string currentPath: inx.homePath()
property var selectedPaths : []
property var copyPaths : []
property var cutPaths : []
property alias terminal : konsole
property var previousPath: []
property var nextPath: []
property bool terminalVisible : inx.loadSettings("TERMINAL_VISIBLE", "INX", false) === "true" ? true : false
property var views : ({
icon : 0,
details : 1,
......@@ -27,6 +31,18 @@ ColumnLayout
onPathModified: browser.refresh()
}
BrowserOptions
{
id: browserOptions
}
BrowserMenu
{
id: browserMenu
}
IndexPage
{
Layout.fillHeight: true
......@@ -65,6 +81,7 @@ ColumnLayout
IndexButton
{
iconName: "overflow-menu"
onClicked: browserOptions.popup()
}
]
......@@ -75,8 +92,8 @@ ColumnLayout
contentItem : ColumnLayout
{
spacing: 0
IconsView
{
id: iconsGrid
......@@ -86,20 +103,40 @@ ColumnLayout
browser.openFolder(path):
browser.openFile(path)
anchors.top: parent.top
anchors.bottom: handle.top
anchors.bottom: terminalVisible ? handle.top : parent.bottom
// SelectionBar
// {
// id: selectionBar
// visible: false
// anchors.bottom: parent.bottom
// }
MouseArea
{
anchors.fill: parent
z: -1
acceptedButtons: Qt.RightButton
onClicked:
{
console.log("right clicked")
if(!isMobile && mouse.button === Qt.RightButton)
browserMenu.popup()
}
}
}
Rectangle
{
id: handle
visible: terminalVisible
Layout.fillWidth: true
height: 5
color: "transparent"
Kirigami.Separator
{
color: "#333"
anchors
{
bottom: parent.bottom
......@@ -115,6 +152,7 @@ ColumnLayout
drag.axis: Drag.YAxis
drag.smoothed: true
cursorShape: Qt.SizeVerCursor
}
}
......@@ -122,14 +160,15 @@ ColumnLayout
Terminal
{
id: konsole
visible: terminalVisible
focus: true
Layout.fillWidth: true
Layout.alignment: Qt.AlignBottom
Layout.minimumHeight: 100
Layout.maximumHeight: parent.height *0.5
anchors.bottom: parent.bottom
anchors.top: handle.bottom
}
}
}
......@@ -149,8 +188,8 @@ ColumnLayout
previousPath.push(currentPath)
populate(path)
konsole.session.sendText("cd " + currentPath + "\n")
if(selectedPaths.length > 0)
clearSelection()
}
function populate(path)
......@@ -194,5 +233,44 @@ ColumnLayout
populate(currentPath)
}
function addToSelection(item, append)
{
var index = selectedPaths.indexOf(item.path)
console.log("insertes",index, item.path)
if(index<0)
selectedPaths.push(item.path)
else
{
if (index !== -1)
selectedPaths.splice(index, 1)
}
}
// function handleSelection()
// {
// if(selectedPaths.length > 0)
// selectionBar.visible = true
// }
function clearSelection()
{
selectedPaths = []
// selectionBar.selectionList.model.clear()
}
function copy(paths)
{
copyPaths = paths
console.log("Paths to copy", copyPaths)
}
function paste()
{
console.log("paste to", currentPath, copyPaths)
}
}
import QtQuick 2.9
import QtQuick.Controls 2.3
import QtQuick.Layouts 1.3
Menu
{
x: parent.width / 2 - width / 2
y: parent.height / 2 - height / 2
modal: true
focus: true
parent: ApplicationWindow.overlay
margins: 1
padding: 2
Column
{
MenuItem
{
text: qsTr("Paste ")+"["+copyPaths.length+"]"
enabled: copyPaths.length > 0
onTriggered: browser.paste()
}
}
}
import QtQuick 2.9
import QtQuick.Controls 2.3
import QtQuick.Layouts 1.3
Menu
{
x: parent.width / 2 - width / 2
y: parent.height / 2 - height / 2
modal: true
focus: true
parent: ApplicationWindow.overlay
margins: 1
padding: 2
Column
{
MenuItem
{
text: qsTr(terminalVisible ? "Hide terminal" : "Show terminal")
onTriggered:
{
terminalVisible = !terminalVisible
inx.saveSettings("TERMINAL_VISIBLE", terminalVisible, "INX")
close()
}
}
}
}
......@@ -140,6 +140,13 @@ Item
}
}
// MouseArea
// {
// anchors.fill: parent
// propagateComposedEvents: true
// onClicked: showEntryBar()
// }
}
function append(path)
......
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import org.kde.kirigami 2.0 as Kirigami
import "../../widgets_templates"
Item
{
property alias selectionList : selectionList
property int barHeight : 54
height: barHeight
width: parent.width
Rectangle
{
anchors.fill: parent
z:-1
color: Kirigami.Theme.complementaryBackgroundColor
radius: 4
opacity: 0.8
border.color: "black"
}
ListView
{
id: selectionList
width: parent.width* 0.9
height: parent.height * 0.9
anchors.centerIn: parent
orientation: ListView.Horizontal
clip: true
spacing: 2
focus: true
interactive: true
model: ListModel{}
delegate: IndexIconDelegate
{
id: delegate
folderSize: 32
showLabel: true
emblemAdded: true
keepEmblemOverlay: true
showSelectionBackground: false
labelColor: "white"
Connections
{
target: delegate
onEmblemClicked: selectionList.model.remove(index)
}
}
}
function append(item)
{
for(var i = 0; i < selectionList.count ; i++ )
if(selectionList.model.get(i).path === item.path)
{
selectionList.model.remove(i)
return
}
selectionList.model.append(item)
}
}
......@@ -8,10 +8,11 @@ Pane
{
property alias grid : grid
signal itemClicked (string path)
signal itemSelected(var item)
IndexGrid
{
id: grid
onFolderClicked: itemClicked(model.get(index).path)
itemIconSize: 48
}
}
......@@ -11,10 +11,11 @@ ToolButton
property color iconColor: textColor
readonly property string defaultColor : textColor
property bool anim : false
property alias kirigamiIcon : kirigamiIcon
Kirigami.Icon
{
id: pixIcon
id: kirigamiIcon
anchors.centerIn: parent
width: iconSize
height: iconSize
......@@ -36,7 +37,7 @@ ToolButton
id: animIcon
PropertyAnimation
{
target: pixIcon
target: kirigamiIcon
property: "color"
easing.type: Easing.InOutQuad
from: highlightColor
......
......@@ -6,7 +6,9 @@ import QtQuick.Layouts 1.3
GridView
{
id: folderGridRoot
property int gridSize : 64
property int itemIconSize : 32
property int gridSize : itemIconSize + (itemIconSize * 0.5)
signal folderClicked(int index)
......@@ -28,7 +30,7 @@ GridView
delegate: IndexIconDelegate
{
id: delegate
folderSize : 32
folderSize : itemIconSize
Connections
{
......@@ -39,8 +41,18 @@ GridView
folderClicked(index)
}
onRightClicked: itemMenu.show(folderGridRoot.model.get(index).path)
onRightClicked:
{
folderGridRoot.currentIndex = index
itemMenu.show(folderGridRoot.model.get(index).path)
}
onEmblemClicked:
{
var item = folderGridRoot.model.get(index)
browser.addToSelection(item, true)
}
}
}
......
......@@ -6,13 +6,18 @@ import org.kde.kirigami 2.2 as Kirigami
ItemDelegate
{
property int folderSize : 32
property color labelColor : GridView.isCurrentItem && !hovered ? highlightedTextColor : textColor
property color hightlightedColor : GridView.isCurrentItem || hovered ? highlightColor : "transparent"
property bool showLabel : true
property bool showSelectionBackground : true
property bool emblemAdded : false
property bool keepEmblemOverlay : true
property color labelColor : (GridView.isCurrentItem || (keepEmblemOverlay && emblemAdded)) && !hovered && showSelectionBackground? highlightedTextColor : textColor
property color hightlightedColor : GridView.isCurrentItem || hovered || (keepEmblemOverlay && emblemAdded) ? highlightColor : "transparent"
signal rightClicked();
signal emblemClicked(int index);
height: folderSize*2
width: folderSize*3
height: folderSize + (folderSize * 0.6)
width: folderSize+ (folderSize * 0.7)
focus: true
hoverEnabled: true
background: Rectangle
......@@ -30,26 +35,52 @@ ItemDelegate
rightClicked()
}
}
IndexButton
{
id: emblem
iconSize: iconSizes.medium
iconName: (keepEmblemOverlay && emblemAdded) ? "emblem-remove" : "emblem-added"
visible: parent.hovered || (keepEmblemOverlay && emblemAdded)
kirigamiIcon.isMask: false
z: 999
anchors
{
top: parent.top
left: parent.left
}
onClicked:
{
emblemAdded = !emblemAdded
emblemClicked(index)
}
}
ColumnLayout
{
anchors.fill: parent
Kirigami.Icon
Item
{
Layout.fillHeight: true
Layout.fillWidth: true
Layout.alignment: Qt.AlignCenter
source: iconName
isMask: false
height: folderSize
Kirigami.Icon
{
anchors.centerIn: parent
source: iconName
isMask: false
width: folderSize
height: folderSize
}
}
Label
{
visible: showLabel
text: label
width: parent.width
Layout.fillWidth: true
......@@ -60,6 +91,7 @@ ItemDelegate
Rectangle
{
visible: parent.visible && showSelectionBackground
anchors.fill: parent
z: -1
radius: 3
......@@ -69,4 +101,5 @@ ItemDelegate
}
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment