Commit 230b4b69 authored by Camilo Higuita's avatar Camilo Higuita

allow multiple selections fix #21 and use qguiapp instead og qapp on android

parent ac21fc2c
......@@ -38,5 +38,7 @@
<file alias="org/kde/kirigami/icons/love.svg">3rdparty/breeze-icons/icons/actions/22/love.svg</file>
<file alias="org/kde/kirigami/icons/application-menu.svg">3rdparty/breeze-icons/icons/actions/22/application-menu.svg</file>
<file alias="org/kde/kirigami/icons/folder.svg">3rdparty/breeze-icons/icons/places/32/folder.svg</file>
<file alias="org/kde/kirigami/icons/emblem-added.svg">3rdparty/breeze-icons/icons/emblems/16/emblem-added.svg</file>
<file alias="org/kde/kirigami/icons/emblem-remove.svg">3rdparty/breeze-icons/icons/emblems/16/emblem-remove.svg</file>
</qresource>
</RCC>
......@@ -18,7 +18,6 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
***/
#include <QApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include <QQuickStyle>
......@@ -28,8 +27,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "src/pix.h"
#ifdef Q_OS_ANDROID
#include <QGuiApplication>
#include "./3rdparty/kirigami/src/kirigamiplugin.h"
#include "android/android.h"
#else
#include <QApplication>
#endif
QStringList getFolderImages(const QString &path)
......@@ -67,7 +69,12 @@ int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#ifdef Q_OS_ANDROID
QGuiApplication app(argc, argv);
#else
QApplication app(argc, argv);
#endif
app.setApplicationName(PIX::App);
app.setApplicationVersion(PIX::version);
app.setApplicationDisplayName(PIX::App);
......
......@@ -39,6 +39,8 @@ import "widgets/dialogs/share"
import "widgets/dialogs/Albums"
import "widgets/dialogs/Tags"
import "widgets/custom/SelectionBox"
import "widgets/views/Pix.js" as PIX
import "widgets/views/Viewer/Viewer.js" as VIEWER
......@@ -48,7 +50,7 @@ Kirigami.ApplicationWindow
visible: true
title: qsTr("Pix")
width: Screen.width * (isMobile ? 1 : 0.5)
// height: Screen.height * (isMobile ? 1 : 0.4)
// height: Screen.height * (isMobile ? 1 : 0.4)
visibility: fullScreen ? ApplicationWindow.FullScreen : ApplicationWindow.Windowed
/* FOR MATERIAL*/
......@@ -95,13 +97,18 @@ Kirigami.ApplicationWindow
property string altColor: Kirigami.Theme.complementaryBackgroundColor
property string pixColor : pix.pixColor()
property int iconSize : Kirigami.Units.iconSizes.medium
property int iconSize : iconSizes.medium
property var iconSizes : ({
small : 16,
medium : 22,
large: 48,
})
property int rowHeight : 32
// pageStack.defaultColumnWidth: 400
// pageStack.initialPage: [mainPage]
// pageStack.interactive: isMobile
// pageStack.separatorVisible: pageStack.wideMode
// pageStack.defaultColumnWidth: 400
// pageStack.initialPage: [mainPage]
// pageStack.interactive: isMobile
// pageStack.separatorVisible: pageStack.wideMode
overlay.modal: Rectangle {
color: isMobile ? altColor : "transparent"
......@@ -143,11 +150,16 @@ Kirigami.ApplicationWindow
id: mainPage
anchors.fill: parent
clip: true
ColumnLayout
{
anchors.fill : parent
SwipeView
{
id: swipeView
width: parent.width
height: parent.height
Layout.fillHeight: true
Layout.fillWidth: true
interactive: isMobile
currentIndex: currentView
......@@ -185,6 +197,19 @@ Kirigami.ApplicationWindow
}
}
SelectionBox
{
id: selectionBox
Layout.fillWidth : true
Layout.leftMargin: contentMargins*2
Layout.rightMargin: contentMargins*2
Layout.bottomMargin: contentMargins*2
visible: selectionList.count > 0 && currentView !== views.viewer
}
}
}
PicMenu
......
......@@ -51,5 +51,6 @@
<file>view_models/PixDialog.qml</file>
<file>widgets/PicMenu.qml</file>
<file>widgets/views/Search/SearchView.qml</file>
<file>widgets/custom/SelectionBox/SelectionBox.qml</file>
</qresource>
</RCC>
......@@ -6,6 +6,8 @@ ToolButton
{
id: babeButton
property alias kirigamiIcon : pixIcon
property string iconName
property int iconSize : 22
property color iconColor: textColor
......
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import QtQuick 2.9
import "../widgets/views/Viewer/Viewer.js" as VIEWER
......@@ -14,6 +15,8 @@ PixPage
property alias grid: grid
property alias holder: holder
property bool selectionMode : false
/*signals*/
signal picClicked(int index)
......@@ -25,6 +28,17 @@ PixPage
visible: grid.count === 0
}
PixMenu
{
id:gridMenu
MenuItem
{
text: qsTr(selectionMode ? "Selection OFF" : "Selection ON")
onTriggered: selectionMode = !selectionMode
}
}
headerbarTitle: gridModel.count+" "+qsTr("images")
headerBarRight: [
......@@ -32,16 +46,21 @@ PixPage
{
id: menuBtn
iconName: "overflow-menu"
onClicked: gridMenu.popup()
}
]
content: GridView
{
id: grid
clip: true
width: parent.width
height: parent.height
clip: true
Layout.fillWidth: true
Layout.fillHeight: true
cellWidth: itemSize + itemSpacing
cellHeight: itemSize + itemSpacing
......@@ -58,15 +77,15 @@ PixPage
model: ListModel {id: gridModel}
highlightMoveDuration: 0
highlightFollowsCurrentItem: true
highlight: Rectangle
{
width: itemSize + itemSpacing
height: itemSize + itemSpacing
color: highlightColor
radius: 4
}
// highlightMoveDuration: 0
// highlightFollowsCurrentItem: true
// highlight: Rectangle
// {
// width: itemSize + itemSpacing
// height: itemSize + itemSpacing
// color: highlightColor
// radius: 4
// }
onWidthChanged:
{
......@@ -92,7 +111,10 @@ PixPage
onClicked:
{
grid.currentIndex = index
if(isMobile)
if(selectionMode)
selectionBox.append(gridModel.get(index))
else if(isMobile)
openPic(index)
}
onDoubleClicked:
......@@ -100,10 +122,15 @@ PixPage
//picClicked(index)
if(!isMobile)
openPic(index)
// else
// selectionBox.append(gridModel.get(index))
}
onPressAndHold: picMenu.show(gridModel.get(index).url)
onRightClicked: picMenu.show(gridModel.get(index).url)
onEmblemClicked: selectionBox.append(gridModel.get(index))
}
}
......
......@@ -44,7 +44,6 @@ Page
{
id: exitBtn
Layout.alignment : Qt.AlignLeft
Layout.leftMargin: contentMargins
visible: headerbarExit
anim : true
iconName : headerbarExitIcon
......@@ -55,7 +54,6 @@ Page
{
id: headerbarActionsLeft
Layout.alignment : Qt.AlignLeft
Layout.leftMargin: headerbarExit ? 0 : contentMargins
spacing: contentMargins
}
......@@ -80,7 +78,6 @@ Page
id: headerbarActionsRight
spacing: contentMargins
Layout.alignment : Qt.AlignRight
Layout.rightMargin: contentMargins
}
}
......
......@@ -9,14 +9,28 @@ ItemDelegate
property int picRadius : 0
property bool showLabel : true
property bool showIndicator : false
property string indicatorColor: ListView.isCurrentItem ? highlightColor : "transparent"
property color labelColor : GridView.isCurrentItem ? highlightedTextColor : textColor
property color labelColor : (GridView.isCurrentItem || (keepEmblemOverlay && emblemAdded)) && !hovered && showSelectionBackground? highlightedTextColor : textColor
property color hightlightedColor : GridView.isCurrentItem || hovered || (keepEmblemOverlay && emblemAdded) ? highlightColor : "transparent"
property bool showSelectionBackground : true
property bool emblemAdded : false
property bool keepEmblemOverlay : false
signal rightClicked();
signal emblemClicked();
height: picSize
width: picSize
hoverEnabled: !isMobile
focus: true
background: Rectangle
{
color: "transparent"
......@@ -33,9 +47,27 @@ ItemDelegate
}
}
PixButton
{
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
anchors.left: parent.left
onClicked:
{
emblemAdded = !emblemAdded
emblemClicked(index)
}
}
ColumnLayout
{
anchors.fill: parent
Image
{
id: img
......@@ -94,6 +126,16 @@ ItemDelegate
elide: Qt.ElideRight
font.pointSize: fontSizes.default
color: labelColor
Rectangle
{
visible: parent.visible && showSelectionBackground
anchors.fill: parent
z: -1
radius: 3
color: hightlightedColor
opacity: hovered ? 0.25 : 1
}
}
}
}
......@@ -7,6 +7,8 @@ PixMenu
{
property string picUrl : ""
property bool isFav : false
property bool isMultiple: false
signal favClicked(string url)
signal removeClicked(string url)
signal shareClicked(string url)
......@@ -16,6 +18,7 @@ PixMenu
Column
{
MenuItem
{
text: qsTr(isFav ? "UnFav it": "Fav it")
......@@ -67,6 +70,7 @@ PixMenu
MenuItem
{
text: qsTr("Show in folder...")
enabled: !isMultiple
onTriggered:
{
showFolderClicked(picUrl)
......@@ -79,7 +83,15 @@ PixMenu
function show(url)
{
picUrl = url
isMultiple = false
isFav = pix.isFav(picUrl)
popup()
}
function showMultiple()
{
picUrl = ""
isMultiple = true
popup()
}
}
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import org.kde.kirigami 2.0 as Kirigami
import "../../../view_models"
Item
{
property alias selectionList : selectionList
property var selectedPaths : []
property alias anim : anim
property int barHeight : 64
property color animColor : "black"
height: barHeight
width: parent.width
Rectangle
{
id: bg
anchors.fill: parent
z:-1
color: Kirigami.Theme.complementaryBackgroundColor
radius: 4
opacity: 0.6
border.color: "black"
SequentialAnimation
{
id: anim
PropertyAnimation
{
target: bg
property: "color"
easing.type: Easing.InOutQuad
from: animColor
to: Kirigami.Theme.complementaryBackgroundColor
duration: 500
}
}
}
RowLayout
{
anchors.fill: parent
Rectangle
{
height: 22
width: 22
radius: Math.min(width, height)
color: Kirigami.Theme.complementaryBackgroundColor
anchors.verticalCenter: parent.top
anchors.horizontalCenter: parent.left
PixButton
{
anchors.centerIn: parent
iconName: "window-close"
iconColor: "white"
iconSize: 16
flat: true
onClicked: clearSelection()
}
}
ListView
{
id: selectionList
Layout.fillHeight: true
Layout.fillWidth: true
anchors.verticalCenter: parent.verticalCenter
height: parent.height
orientation: ListView.Horizontal
clip: true
spacing: 10
focus: true
interactive: true
model: ListModel{}
delegate: PixPic
{
id: delegate
anchors.verticalCenter: parent.verticalCenter
height: 48
picSize: 48
showLabel: false
emblemAdded: true
keepEmblemOverlay: true
showSelectionBackground: false
labelColor: "white"
// showTooltip: true
Connections
{
target: delegate
onEmblemClicked: removeSelection(index)
}
}
}
Item
{
Layout.alignment: Qt.AlignRight
Layout.fillWidth: true
Layout.fillHeight: true
Layout.maximumWidth: 44
PixButton
{
anchors.centerIn: parent
iconName: "overflow-menu"
iconColor: "white"
onClicked: picMenu.showMultiple()
}
}
Rectangle
{
height: 22
width: 22
radius: Math.min(width, height)
color: highlightColor
anchors.verticalCenter: parent.top
anchors.horizontalCenter: parent.right
Label
{
anchors.fill: parent
anchors.centerIn: parent
horizontalAlignment: Qt.AlignHCenter
verticalAlignment: Qt.AlignVCenter
font.pointSize: fontSizes.small
font.bold: true
color: highlightedTextColor
text: selectionList.count
}
}
}
function clearSelection()
{
selectedPaths = []
selectionList.model.clear()
}
function removeSelection(index)
{
var item = selectionList.model.get(index)
var indexof = selectedPaths.indexOf(item.path)
if (indexof !== -1)
{
selectedPaths.splice(index, 1)
selectionList.model.remove(index)
}
}
function append(item)
{
for(var i = 0; i < selectionList.count ; i++ )
if(selectionList.model.get(i).url === item.url)
{
selectionList.model.remove(i)
return
}
selectionList.model.append(item)
selectionList.positionViewAtEnd()
}
function animate(color)
{
animColor = color
anim.running = true
}
}
......@@ -8,34 +8,10 @@ import "../../../widgets/custom/TagBar"
import "../../dialogs/Tags"
PixPage
Page
{
property alias albumsGrid : albumGrid
headerbarExit: stackView.currentItem === picsView
headerbarExitIcon: "go-previous"
headerbarTitle: stackView.currentItem === picsView ? albumGrid.currentAlbum : albumGrid.count+qsTr(" Albums")
onExit: stackView.pop(albumGrid)
headerBarRight: [
PixButton
{
iconName: "overflow-menu"
}
]
headerBarLeft: [
PixButton
{
iconName: "list-add"
visible: stackView.currentItem === albumGrid
onClicked: newAlbumDialog.open()
}
]
footer: ToolBar
{
......@@ -67,25 +43,57 @@ PixPage
onAlbumCreated: albumGrid.model.append({"album": album})
}
content: StackView
StackView
{
id: stackView
height: parent.height
width: parent.width
initialItem: AlbumsGrid
initialItem: PixPage
{
id: albumGrid
id: albumsPage
headerbarTitle: albumGrid.count+qsTr(" Albums")
headerbarExit: false
headerBarRight: [
PixButton
{
iconName: "overflow-menu"
}
]
headerBarLeft: [
PixButton
{
iconName: "list-add"
onClicked: newAlbumDialog.open()
}
]
content: AlbumsGrid
{
id: albumGrid
height: parent.height
width: parent.width
onAlbumClicked: filter(model.get(index).album)
}
}
PixGrid
{
id: picsView
headerbarVisible: false
headerbarVisible: true
holder.message: "<h2>No Pics!</h2><p>This albums is empty</p>"
holder.emoji: "qrc:/img/assets/face-sleeping.png"
headerbarExit: stackView.currentItem === picsView
headerbarExitIcon: "go-previous"
headerbarTitle: albumGrid.currentAlbum
onExit: stackView.pop(albumsPage)
}
}
......@@ -135,7 +143,7 @@ PixPage
for(var i in pics)
picsView.grid.model.append(pics[i])
if(stackView.currentItem === albumGrid)
if(stackView.currentItem === albumsPage)
stackView.push(picsView)
}
......
......@@ -2,39 +2,41 @@ import QtQuick 2.0
import QtQuick.Controls 2.2
import "../../../view_models"
PixPage
Page
{
headerbarExit: stackView.currentItem === picsView
headerbarExitIcon: "go-previous"
headerbarTitle: qsTr("Folders")
onExit: stackView.pop(folderGrid)
content: StackView
StackView
{
id: stackView
height: parent.height
width: parent.width
initialItem: FoldersGrid
initialItem: PixPage
{
id: foldersPage
headerbarTitle: qsTr("Folders")
headerbarExit: false
content: FoldersGrid
{
id: folderGrid
onFolderClicked:
{
headerbarTitle = folderGrid.model.get(index).folder
picsView.headerbarTitle = folderGrid.model.get(index).folder
picsView.clear()
picsView.populate(folderGrid.model.get(index).url)
if(stackView.currentItem === folderGrid)
if(stackView.currentItem === foldersPage)
stackView.push(picsView)
}
}
}
PicsView
{
id: picsView
headerbarVisible: false
headerbarVisible: true
headerbarExit: stackView.currentItem === picsView
headerbarExitIcon: "go-previous"
onExit: stackView.pop(foldersPage)
}
}
......
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