PixViewer.qml 5.75 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 "../.."
Camilo Higuita's avatar
Camilo Higuita committed
9

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

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

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

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

29 30 31
    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)
32

Camilo Higuita's avatar
Camilo Higuita committed
33
    margins: 0
34 35
    colorScheme.backgroundColor: viewerBackgroundColor
    headBarExit: false
Camilo higuita's avatar
Camilo higuita committed
36
    headBarTitle: currentPic.title ? currentPic.title : ""
37
    headBar.rightContent: [
38 39 40
        Maui.ToolButton
        {
            iconName: "document-save-as"
41 42 43 44 45
            onClicked:
            {
                dialogLoader.sourceComponent = albumsDialogComponent
                dialog.show()
            }
46 47 48 49 50
        },

        Maui.ToolButton
        {
            iconName: "object-rotate-left"
51
            onClicked: viewer.currentItem.rotateLeft()
52 53 54 55 56
        },

        Maui.ToolButton
        {
            iconName: "object-rotate-right"
57
            onClicked: viewer.currentItem.rotateRight()
58 59
        },

60 61 62
        Maui.ToolButton
        {
            iconName: "overflow-menu"
63
            onClicked: viewerMenu.popup()
64 65
        }
    ]
Camilo higuita's avatar
Camilo higuita committed
66

67
    headBar.leftContent: [
68 69 70
        Maui.ToolButton
        {
            iconName: "document-share"
71 72 73 74 75 76 77 78 79 80
            onClicked:
            {
                if(isAndroid)
                Maui.Android.shareDialog([pixViewer.currentPic.url])
                else
                {
                    dialogLoader.sourceComponent = shareDialogComponent
                    dialog.show([pixViewer.currentPic.url])
                }
            }
81 82
        },

83 84
        Maui.ToolButton
        {
Camilo higuita's avatar
Camilo higuita committed
85
            iconName: "image-preview"
Camilo higuita's avatar
Camilo higuita committed
86
            onClicked: control.contentIsRised ? dropContent() : riseContent()
87
            iconColor: control.contentIsRised ? colorScheme.highlightColor: colorScheme.textColor
Camilo higuita's avatar
Camilo higuita committed
88

89
        },
90

91 92
        Maui.ToolButton
        {
93
            iconName: "tag"
94 95 96 97
            onClicked: toogleTagbar()
            iconColor: tagBarVisible ? colorScheme.highlightColor: colorScheme.textColor
        }
    ]
98

Camilo higuita's avatar
Camilo higuita committed
99 100 101 102 103 104
    //    Connections
    //    {
    //        target: tagsDialog
    //        onPicTagged: if(currentView === views.viewer)
    //                         VIEWER.setCurrentPicTags()
    //    }
105

106 107 108 109 110
    ViewerMenu
    {
        id: viewerMenu
    }

111 112 113 114 115
    ConfigurationDialog
    {
        id : viewerConf
    }

116 117 118 119 120
    EditTools
    {
        id: editTools
    }

121
    backContain: GalleryRoll
122
    {
123 124 125 126 127 128 129 130
        id: galleryRoll
        visible: !holder.visible
        onPicClicked: VIEWER.view(index)
    }

    floatingBar: true
    footBarOverlap: true

131 132 133 134 135 136
    PixMenu
    {
        id: _picMenu
        index: viewer.currentIndex
    }

Camilo higuita's avatar
Camilo higuita committed
137 138 139 140 141
    PixModel
    {
        id: pixModel
    }

142 143 144 145
    Viewer
    {
        id: viewer

146 147
        height: parent.height
        width: parent.width
Camilo Higuita's avatar
Camilo Higuita committed
148

149
        floatingBar: true
150
        headBar.visible: false
151

152 153
        footBar.colorScheme.backgroundColor: accentColor
        footBar.colorScheme.textColor: altColorText
154

Camilo higuita's avatar
Camilo higuita committed
155 156 157 158 159 160 161 162 163 164 165 166
        footBar.middleContent: [

            Maui.ToolButton
            {
                iconName: "go-previous"
                iconColor: altColorText
                onClicked: VIEWER.previous()
            },

            Maui.ToolButton
            {
                iconName: "love"
167 168
                colorScheme.highlightColor: "#ff557f";
                iconColor: pixViewer.currentPicFav ? colorScheme.highlightColor : colorScheme.textColor
Camilo higuita's avatar
Camilo higuita committed
169 170 171 172 173 174 175 176 177 178
                onClicked: pixViewer.currentPicFav = VIEWER.fav([pixViewer.currentPic.url])
            },

            Maui.ToolButton
            {
                iconName: "go-next"
                iconColor: altColorText
                onClicked: VIEWER.next()
            }
        ]
179

180 181 182
        Maui.Holder
        {
            id: holder
183
            emoji: viewer.count === 0 ? "qrc:/img/assets/Rainbow.png" : "qrc:/img/assets/animat-image-color.gif"
184
            isMask: false
185 186 187 188 189
            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
190
            colorScheme.backgroundColor: viewerForegroundColor
191
        }
Camilo Higuita's avatar
Camilo Higuita committed
192

193
        footer: Maui.TagsBar
194 195 196 197 198 199
        {
            id: tagBar
            visible: !holder.visible && tagBarVisible && !fullScreen
            Layout.fillWidth: true
            bgColor: viewerBackgroundColor
            allowEditMode: true
200
            list.urls: [currentPic.url]
201
            onTagClicked: PIX.searchFor(tag)
202 203 204 205 206
            onAddClicked:
            {
                dialogLoader.sourceComponent = tagsDialogComponent
                dialog.show(currentPic.url)
            }
Camilo higuita's avatar
Camilo higuita committed
207

208 209
            onTagRemovedClicked: list.removeFromUrls(index)
            onTagsEdited: list.updateToUrls(tags)
210
        }
211
    }
212

213 214 215
    function toogleTagbar()
    {
        tagBarVisible = !tagBarVisible
216
        Maui.FM.saveSettings("TAGBAR", tagBarVisible, "PIX")
Camilo Higuita's avatar
Camilo Higuita committed
217
    }
Camilo Higuita's avatar
Camilo Higuita committed
218
}