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 @@ ...@@ -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/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/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/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> </qresource>
</RCC> </RCC>
...@@ -18,7 +18,6 @@ You should have received a copy of the GNU General Public License ...@@ -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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
***/ ***/
#include <QApplication>
#include <QQmlApplicationEngine> #include <QQmlApplicationEngine>
#include <QQmlContext> #include <QQmlContext>
#include <QQuickStyle> #include <QQuickStyle>
...@@ -28,8 +27,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. ...@@ -28,8 +27,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "src/pix.h" #include "src/pix.h"
#ifdef Q_OS_ANDROID #ifdef Q_OS_ANDROID
#include <QGuiApplication>
#include "./3rdparty/kirigami/src/kirigamiplugin.h" #include "./3rdparty/kirigami/src/kirigamiplugin.h"
#include "android/android.h" #include "android/android.h"
#else
#include <QApplication>
#endif #endif
QStringList getFolderImages(const QString &path) QStringList getFolderImages(const QString &path)
...@@ -67,7 +69,12 @@ int main(int argc, char *argv[]) ...@@ -67,7 +69,12 @@ int main(int argc, char *argv[])
{ {
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#ifdef Q_OS_ANDROID
QGuiApplication app(argc, argv);
#else
QApplication app(argc, argv); QApplication app(argc, argv);
#endif
app.setApplicationName(PIX::App); app.setApplicationName(PIX::App);
app.setApplicationVersion(PIX::version); app.setApplicationVersion(PIX::version);
app.setApplicationDisplayName(PIX::App); app.setApplicationDisplayName(PIX::App);
......
...@@ -39,6 +39,8 @@ import "widgets/dialogs/share" ...@@ -39,6 +39,8 @@ import "widgets/dialogs/share"
import "widgets/dialogs/Albums" import "widgets/dialogs/Albums"
import "widgets/dialogs/Tags" import "widgets/dialogs/Tags"
import "widgets/custom/SelectionBox"
import "widgets/views/Pix.js" as PIX import "widgets/views/Pix.js" as PIX
import "widgets/views/Viewer/Viewer.js" as VIEWER import "widgets/views/Viewer/Viewer.js" as VIEWER
...@@ -48,7 +50,7 @@ Kirigami.ApplicationWindow ...@@ -48,7 +50,7 @@ Kirigami.ApplicationWindow
visible: true visible: true
title: qsTr("Pix") title: qsTr("Pix")
width: Screen.width * (isMobile ? 1 : 0.5) 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 visibility: fullScreen ? ApplicationWindow.FullScreen : ApplicationWindow.Windowed
/* FOR MATERIAL*/ /* FOR MATERIAL*/
...@@ -95,13 +97,18 @@ Kirigami.ApplicationWindow ...@@ -95,13 +97,18 @@ Kirigami.ApplicationWindow
property string altColor: Kirigami.Theme.complementaryBackgroundColor property string altColor: Kirigami.Theme.complementaryBackgroundColor
property string pixColor : pix.pixColor() 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 property int rowHeight : 32
// pageStack.defaultColumnWidth: 400 // pageStack.defaultColumnWidth: 400
// pageStack.initialPage: [mainPage] // pageStack.initialPage: [mainPage]
// pageStack.interactive: isMobile // pageStack.interactive: isMobile
// pageStack.separatorVisible: pageStack.wideMode // pageStack.separatorVisible: pageStack.wideMode
overlay.modal: Rectangle { overlay.modal: Rectangle {
color: isMobile ? altColor : "transparent" color: isMobile ? altColor : "transparent"
...@@ -143,48 +150,66 @@ Kirigami.ApplicationWindow ...@@ -143,48 +150,66 @@ Kirigami.ApplicationWindow
id: mainPage id: mainPage
anchors.fill: parent anchors.fill: parent
clip: true clip: true
SwipeView
ColumnLayout
{ {
id: swipeView anchors.fill : parent
width: parent.width
height: parent.height
interactive: isMobile
currentIndex: currentView
onCurrentIndexChanged: currentView = currentIndex SwipeView
{
id: swipeView
Layout.fillHeight: true
Layout.fillWidth: true
interactive: isMobile
currentIndex: currentView
onCurrentIndexChanged: currentView = currentIndex
PixViewer
{
id: pixViewer
}
GalleryView PixViewer
{ {
id: galleryView id: pixViewer
} }
FoldersView GalleryView
{ {
id: foldersView id: galleryView
} }
AlbumsView FoldersView
{ {
id: albumsView id: foldersView
} }
AlbumsView
{
id: albumsView
}
TagsView
{
id: tagsView
}
SearchView
{
id: searchView
}
TagsView
{
id: tagsView
} }
SearchView SelectionBox
{ {
id: searchView 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 PicMenu
......
...@@ -51,5 +51,6 @@ ...@@ -51,5 +51,6 @@
<file>view_models/PixDialog.qml</file> <file>view_models/PixDialog.qml</file>
<file>widgets/PicMenu.qml</file> <file>widgets/PicMenu.qml</file>
<file>widgets/views/Search/SearchView.qml</file> <file>widgets/views/Search/SearchView.qml</file>
<file>widgets/custom/SelectionBox/SelectionBox.qml</file>
</qresource> </qresource>
</RCC> </RCC>
...@@ -6,6 +6,8 @@ ToolButton ...@@ -6,6 +6,8 @@ ToolButton
{ {
id: babeButton id: babeButton
property alias kirigamiIcon : pixIcon
property string iconName property string iconName
property int iconSize : 22 property int iconSize : 22
property color iconColor: textColor property color iconColor: textColor
......
import QtQuick.Controls 2.2 import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import QtQuick 2.9 import QtQuick 2.9
import "../widgets/views/Viewer/Viewer.js" as VIEWER import "../widgets/views/Viewer/Viewer.js" as VIEWER
...@@ -14,6 +15,8 @@ PixPage ...@@ -14,6 +15,8 @@ PixPage
property alias grid: grid property alias grid: grid
property alias holder: holder property alias holder: holder
property bool selectionMode : false
/*signals*/ /*signals*/
signal picClicked(int index) signal picClicked(int index)
...@@ -25,6 +28,17 @@ PixPage ...@@ -25,6 +28,17 @@ PixPage
visible: grid.count === 0 visible: grid.count === 0
} }
PixMenu
{
id:gridMenu
MenuItem
{
text: qsTr(selectionMode ? "Selection OFF" : "Selection ON")
onTriggered: selectionMode = !selectionMode
}
}
headerbarTitle: gridModel.count+" "+qsTr("images") headerbarTitle: gridModel.count+" "+qsTr("images")
headerBarRight: [ headerBarRight: [
...@@ -32,16 +46,21 @@ PixPage ...@@ -32,16 +46,21 @@ PixPage
{ {
id: menuBtn id: menuBtn
iconName: "overflow-menu" iconName: "overflow-menu"
onClicked: gridMenu.popup()
} }
] ]
content: GridView content: GridView
{ {
id: grid id: grid
clip: true
width: parent.width width: parent.width
height: parent.height height: parent.height
clip: true
Layout.fillWidth: true
Layout.fillHeight: true
cellWidth: itemSize + itemSpacing cellWidth: itemSize + itemSpacing
cellHeight: itemSize + itemSpacing cellHeight: itemSize + itemSpacing
...@@ -58,15 +77,15 @@ PixPage ...@@ -58,15 +77,15 @@ PixPage
model: ListModel {id: gridModel} model: ListModel {id: gridModel}
highlightMoveDuration: 0 // highlightMoveDuration: 0
highlightFollowsCurrentItem: true // highlightFollowsCurrentItem: true
highlight: Rectangle // highlight: Rectangle
{ // {
width: itemSize + itemSpacing // width: itemSize + itemSpacing
height: itemSize + itemSpacing // height: itemSize + itemSpacing
color: highlightColor // color: highlightColor
radius: 4 // radius: 4
} // }
onWidthChanged: onWidthChanged:
{ {
...@@ -92,7 +111,10 @@ PixPage ...@@ -92,7 +111,10 @@ PixPage
onClicked: onClicked:
{ {
grid.currentIndex = index grid.currentIndex = index
if(isMobile)
if(selectionMode)
selectionBox.append(gridModel.get(index))
else if(isMobile)
openPic(index) openPic(index)
} }
onDoubleClicked: onDoubleClicked:
...@@ -100,10 +122,15 @@ PixPage ...@@ -100,10 +122,15 @@ PixPage
//picClicked(index) //picClicked(index)
if(!isMobile) if(!isMobile)
openPic(index) openPic(index)
// else
// selectionBox.append(gridModel.get(index))
} }
onPressAndHold: picMenu.show(gridModel.get(index).url) onPressAndHold: picMenu.show(gridModel.get(index).url)
onRightClicked: picMenu.show(gridModel.get(index).url) onRightClicked: picMenu.show(gridModel.get(index).url)
onEmblemClicked: selectionBox.append(gridModel.get(index))
} }
} }
......
...@@ -44,7 +44,6 @@ Page ...@@ -44,7 +44,6 @@ Page
{ {
id: exitBtn id: exitBtn
Layout.alignment : Qt.AlignLeft Layout.alignment : Qt.AlignLeft
Layout.leftMargin: contentMargins
visible: headerbarExit visible: headerbarExit
anim : true anim : true
iconName : headerbarExitIcon iconName : headerbarExitIcon
...@@ -55,7 +54,6 @@ Page ...@@ -55,7 +54,6 @@ Page
{ {
id: headerbarActionsLeft id: headerbarActionsLeft
Layout.alignment : Qt.AlignLeft Layout.alignment : Qt.AlignLeft
Layout.leftMargin: headerbarExit ? 0 : contentMargins
spacing: contentMargins spacing: contentMargins
} }
...@@ -80,7 +78,6 @@ Page ...@@ -80,7 +78,6 @@ Page
id: headerbarActionsRight id: headerbarActionsRight
spacing: contentMargins spacing: contentMargins
Layout.alignment : Qt.AlignRight Layout.alignment : Qt.AlignRight
Layout.rightMargin: contentMargins
} }
} }
......
...@@ -9,14 +9,28 @@ ItemDelegate ...@@ -9,14 +9,28 @@ ItemDelegate
property int picRadius : 0 property int picRadius : 0
property bool showLabel : true property bool showLabel : true
property bool showIndicator : false property bool showIndicator : false
property string indicatorColor: ListView.isCurrentItem ? highlightColor : "transparent" 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 rightClicked();
signal emblemClicked();
height: picSize height: picSize
width: picSize width: picSize
hoverEnabled: !isMobile
focus: true
background: Rectangle background: Rectangle
{ {
color: "transparent" color: "transparent"
...@@ -33,9 +47,27 @@ ItemDelegate ...@@ -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 ColumnLayout
{ {
anchors.fill: parent anchors.fill: parent
Image Image
{ {
id: img id: img
...@@ -94,6 +126,16 @@ ItemDelegate ...@@ -94,6 +126,16 @@ ItemDelegate
elide: Qt.ElideRight elide: Qt.ElideRight
font.pointSize: fontSizes.default font.pointSize: fontSizes.default
color: labelColor 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 ...@@ -7,6 +7,8 @@ PixMenu
{ {
property string picUrl : "" property string picUrl : ""
property bool isFav : false property bool isFav : false
property bool isMultiple: false
signal favClicked(string url) signal favClicked(string url)
signal removeClicked(string url) signal removeClicked(string url)
signal shareClicked(string url) signal shareClicked(string url)
...@@ -15,7 +17,8 @@ PixMenu ...@@ -15,7 +17,8 @@ PixMenu
signal showFolderClicked(string url) signal showFolderClicked(string url)
Column Column
{ {
MenuItem MenuItem
{ {
text: qsTr(isFav ? "UnFav it": "Fav it") text: qsTr(isFav ? "UnFav it": "Fav it")
...@@ -67,6 +70,7 @@ PixMenu ...@@ -67,6 +70,7 @@ PixMenu
MenuItem MenuItem
{ {
text: qsTr("Show in folder...") text: qsTr("Show in folder...")
enabled: !isMultiple
onTriggered: onTriggered:
{ {
showFolderClicked(picUrl) showFolderClicked(picUrl)
...@@ -79,7 +83,15 @@ PixMenu ...@@ -79,7 +83,15 @@ PixMenu
function show(url) function show(url)
{ {
picUrl = url picUrl = url
isMultiple = false
isFav = pix.isFav(picUrl) isFav = pix.isFav(picUrl)
popup() 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)
{