Browser.qml 1.59 KB
Newer Older
1
import QtQuick 2.9
2
import QtQuick.Controls 2.3
3 4 5 6
import QtQuick.Layouts 1.3
import org.kde.kirigami 2.0 as Kirigami
import org.kde.mauikit 1.0 as Maui

7
Maui.FileBrowser
8
{
9
    id: control
camilo higuita's avatar
camilo higuita committed
10 11 12 13

    viewType: Maui.FM.loadSettings("VIEW_TYPE", "BROWSER", Maui.FMList.LIST_VIEW)
    onViewTypeChanged: Maui.FM.saveSettings("VIEW_TYPE", viewType, "BROWSER")

14 15 16
    headBar.rightContent: ToolButton
    {
        visible: terminal
camilo higuita's avatar
camilo higuita committed
17
        icon.name: "utilities-terminal"
camilo higuita's avatar
camilo higuita committed
18 19 20 21 22
        onClicked:
        {
            terminalVisible = !terminalVisible
            Maui.FM.saveSettings("TERMINAL", terminalVisible, "EXTENSIONS")
        }
23 24
        checked : terminalVisible
        checkable: false
25 26
    }

27 28 29 30 31
    onNewBookmark:
    {
        for(var index in paths)
            placesSidebar.list.addPlace(paths[index])
    }
32

camilo higuita's avatar
camilo higuita committed
33 34
    onNewTag: placesSidebar.list.refresh()

35 36
    onCurrentPathChanged:
    {
camilo higuita's avatar
camilo higuita committed
37
        if(terminalVisible && !Kirigami.Settings.isMobile)
camilo higuita's avatar
fixes  
camilo higuita committed
38
            terminal.session.sendText("cd '" + String(currentPath).replace("file://", "") + "'\n")
39

camilo higuita's avatar
camilo higuita committed
40
        placesSidebar.currentIndex = -1
41
        for(var i = 0; i < placesSidebar.count; i++)
42 43
            if(String(currentPath) === placesSidebar.list.get(i).path)
            {
44
                placesSidebar.currentIndex = i
camilo higuita's avatar
fixes  
camilo higuita committed
45
                return;
46
            }
47
    }
48

49
    onItemClicked: openItem(index)
50

51
    onItemDoubleClicked:
52
    {
53
        var item = currentFMList.get(index)
54 55 56 57 58
        console.log(item.mime)
        if(Maui.FM.isDir(item.path) || item.mime === "inode/directory")
            control.openFolder(item.path)
        else
            control.openFile(item.path)
59
    }
60
}