PixViewer.qml 5.36 KB
Newer Older
Camilo Higuita's avatar
Camilo Higuita committed
1 2 3
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
4
import "../../../view_models"
5
import "../../../widgets/views/Viewer/Viewer.js" as VIEWER
Camilo Higuita's avatar
Camilo Higuita committed
6 7
import "../../../widgets/views/Pix.js" as PIX
import "../../../db/Query.js" as Q
Camilo higuita's avatar
Camilo higuita committed
8
import "../.."
9
import org.kde.kirigami 2.7 as Kirigami
Camilo Higuita's avatar
Camilo Higuita committed
10

11
import org.kde.mauikit 1.0 as Maui
Camilo higuita's avatar
Camilo higuita committed
12 13
import PixModel 1.0
import GalleryList 1.0
14 15

Maui.Page
Camilo Higuita's avatar
Camilo Higuita committed
16
{
Camilo Higuita's avatar
Camilo Higuita committed
17
    id: control
Camilo higuita's avatar
Camilo higuita committed
18

19
    property alias viewer : viewer
20 21
    property alias holder : holder
    property alias tagBar : tagBar
22
    property alias roll : galleryRoll
Camilo higuita's avatar
Camilo higuita committed
23
    property alias model : pixModel
24
    property alias list : pixModel.list
25

26
    property bool currentPicFav: false
27
    property var currentPic : ({})
28
    property int currentPicIndex : 0
29

30 31 32
    property bool tagBarVisible : Maui.FM.loadSettings("TAGBAR", "PIX", true) === "true" ? true : false
    property string viewerBackgroundColor : Maui.FM.loadSettings("VIEWER_BG_COLOR", "PIX", backgroundColor)
    property string viewerForegroundColor : Maui.FM.loadSettings("VIEWER_FG_COLOR", "PIX", textColor)
33

34 35
    padding: 0
    Kirigami.Theme.backgroundColor: viewerBackgroundColor
Camilo higuita's avatar
Camilo higuita committed
36

37

Camilo higuita's avatar
Camilo higuita committed
38 39 40 41 42 43
    //    Connections
    //    {
    //        target: tagsDialog
    //        onPicTagged: if(currentView === views.viewer)
    //                         VIEWER.setCurrentPicTags()
    //    }
44

45 46 47 48 49
    ViewerMenu
    {
        id: viewerMenu
    }

50 51 52 53 54
    ConfigurationDialog
    {
        id : viewerConf
    }

55 56 57 58
    //    EditTools
    //    {
    //        id: editTools
    //    }
59

60 61 62 63 64 65
    PixMenu
    {
        id: _picMenu
        index: viewer.currentIndex
    }

Camilo higuita's avatar
Camilo higuita committed
66 67 68
    PixModel
    {
        id: pixModel
69
        list: GalleryList {}
Camilo higuita's avatar
Camilo higuita committed
70 71
    }

72 73 74 75
    headBar.visible: false

    footBar.rightContent: [

76
        ToolButton
77
        {
78
            icon.name: "document-share"
79 80 81 82 83 84 85 86 87 88 89 90
            onClicked:
            {
                if(isAndroid)
                Maui.Android.shareDialog([pixViewer.currentPic.url])
                else
                {
                    dialogLoader.sourceComponent = shareDialogComponent
                    dialog.show([pixViewer.currentPic.url])
                }
            }
        },

91
        ToolButton
92
        {
93
            icon.name: "object-rotate-left"
94 95 96
            onClicked: viewer.currentItem.rotateLeft()
        },

97
        ToolButton
98
        {
99
            icon.name: "object-rotate-right"
100 101 102
            onClicked: viewer.currentItem.rotateRight()
        },

103
        ToolButton
104
        {
105
            icon.name: "overflow-menu"
106 107 108 109
            onClicked: viewerMenu.popup()
        }
    ]

110

111

112 113
//    footBar.colorScheme.backgroundColor: accentColor
//    footBar.colorScheme.textColor: altColorText
114 115 116 117
    //        footBar.colorScheme.borderColor: accentColor

    footBar.leftContent: [

118
        ToolButton
119
        {
120 121
            icon.name: "go-previous"
//            icon.color: altColorText
122 123 124
            onClicked: VIEWER.previous()
        },

125
        ToolButton
126
        {
127 128 129
            icon.name: "love"
//            colorScheme.highlightColor: "#ff557f";
            icon.color: pixViewer.currentPicFav ? Kirigami.Theme.highlightColor : Kirigami.Theme.textColor
130 131 132
            onClicked: pixViewer.currentPicFav = VIEWER.fav([pixViewer.currentPic.url])
        },

133
        ToolButton
134
        {
135 136
            icon.name: "go-next"
//            icon.color: altColorText
137 138 139 140
            onClicked: VIEWER.next()
        }
    ]

141 142
    ColumnLayout
    {
143 144
        height: parent.height
        width: parent.width
Camilo Higuita's avatar
Camilo Higuita committed
145

146 147 148 149 150
        Viewer
        {
            id: viewer
            Layout.fillHeight: true
            Layout.fillWidth: true
151

152
            Maui.Holder
Camilo higuita's avatar
Camilo higuita committed
153
            {
154 155 156 157 158 159 160 161
                id: holder
                emoji: viewer.count === 0 ? "qrc:/img/assets/Rainbow.png" : "qrc:/img/assets/animat-image-color.gif"
                isMask: false
                isGif : viewer.currentItem.status !== Image.Ready
                title : viewer.count === 0 ? qsTr("No Pic!") : qsTr("Loading...")
                body: viewer.count === 0 ? qsTr("Open an image from your collection") : qsTr("Your pic is almost ready")
                emojiSize: isGif ? iconSizes.enormous : iconSizes.huge
                visible: viewer.count === 0 /*|| viewer.currentItem.status !== Image.Ready*/
162
                Kirigami.Theme.backgroundColor: viewerForegroundColor
Camilo higuita's avatar
Camilo higuita committed
163
            }
164

165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182
            footer: Maui.TagsBar
            {
                id: tagBar
                visible: !holder.visible && tagBarVisible && !fullScreen
                Layout.fillWidth: true
                bgColor: viewerBackgroundColor
                allowEditMode: true
                list.urls: [currentPic.url]
                onTagClicked: PIX.searchFor(tag)
                onAddClicked:
                {
                    dialogLoader.sourceComponent = tagsDialogComponent
                    dialog.show(currentPic.url)
                }

                onTagRemovedClicked: list.removeFromUrls(index)
                onTagsEdited: list.updateToUrls(tags)
            }
183
        }
Camilo Higuita's avatar
Camilo Higuita committed
184

185 186

        GalleryRoll
187
        {
188
            id: galleryRoll
189
            Layout.fillWidth: true
190 191 192
            Layout.margins: 0
            Layout.topMargin: space.medium
            Layout.bottomMargin: space.medium
193
            rollHeight: 120 * unit
194
            visible: false
195
            onPicClicked: VIEWER.view(index)
196
        }
197
    }
198

199

200 201 202
    function toogleTagbar()
    {
        tagBarVisible = !tagBarVisible
203
        Maui.FM.saveSettings("TAGBAR", tagBarVisible, "PIX")
Camilo Higuita's avatar
Camilo Higuita committed
204
    }
Camilo Higuita's avatar
Camilo Higuita committed
205
}