Commit 9812414c authored by Camilo Higuita's avatar Camilo Higuita

work on open with on linux #6 #10

parent bc005163
......@@ -9,6 +9,7 @@ linux:unix:!android {
message(Building helpers for Android)
include(android/Android.pri)
include(3rdparty/kirigami/kirigami.pri)
RESOURCES += kirigami-icons.qrc
......@@ -60,3 +61,6 @@ HEADERS += \
src/db/db.h \
src/db/dbactions.h \
src/utils/pic.h
DISTFILES += \
android/Android.pri
android {
QT += androidextras webview
RESOURCES += android.qrc/
ANDROID_PACKAGE_SOURCE_DIR = $$PWD/
}
RESOURCES += \
$$PWD/android.qrc
<RCC>
<qresource prefix="/">
<file>qtquickcontrols2.conf</file>
</qresource>
</RCC>
......@@ -15,7 +15,7 @@ static QVariantMap createActionItem(const QString &label, const QString &actionI
{
QVariantMap map;
map["text"] = label;
map["serviceLabel"] = label;
map["actionId"] = actionId;
if (argument.isValid()) {
......@@ -43,7 +43,7 @@ QVariantList KDE::mimeApps(const QUrl &url)
{
const QString text = service->name().replace('&', "&&");
QVariantMap item = createActionItem(text, "_kicker_fileItem_openWith", service->entryPath());
item["icon"] = service->icon();
item["serviceIcon"] = service->icon();
list << item;
}
......@@ -51,7 +51,6 @@ QVariantList KDE::mimeApps(const QUrl &url)
list << createActionItem(i18n("Properties"), "_kicker_fileItem_properties");
qDebug()<<list;
return list;
} else return list;
}
......@@ -19,11 +19,13 @@ int main(int argc, char *argv[])
#ifdef Q_OS_ANDROID
KirigamiPlugin::getInstance().registerTypes();
#else
// if(QQuickStyle::availableStyles().contains("nomad"))
// QQuickStyle::setStyle("nomad");
#endif
QQmlApplicationEngine engine;
auto context = engine.rootContext();
QQuickStyle::setStyle("nomad");
Pix pix;
context->setContextProperty("pix", &pix);
......
......@@ -133,7 +133,6 @@ QVariantList DBActions::getFolders()
map.insert("folder", QFileInfo(i[PIX::KEY::URL]).baseName());
res << map;
}
qDebug()<< res;
return res;
}
......@@ -28,10 +28,10 @@ class FileLoader : public DBActions
this->t.wait();
}
void requestPath(QString path)
void requestPath(QStringList paths)
{
qDebug()<<"FROM file loader"<< path;
this->queue << path;
qDebug()<<"FROM file loader"<< paths;
this->queue << paths;
for(auto url : this->queue)
{
if(!go)
......
......@@ -59,6 +59,16 @@ Kirigami.ApplicationWindow
property int iconSize : Kirigami.Units.iconSizes.medium
overlay.modal: Rectangle {
color: isMobile ? darkColor : "transparent"
opacity: 0.5
height: root.height
}
overlay.modeless: Rectangle {
color: "transparent"
}
header: PixsBar
{
id: toolBar
......
......@@ -33,7 +33,6 @@ Pix::Pix(QObject *parent) : DBActions(parent)
this->fileLoader = new FileLoader;
connect(this, &Pix::populate, this, &Pix::populateDB);
connect(this->fileLoader, &FileLoader::finished,[this]()
{
......@@ -42,7 +41,7 @@ Pix::Pix(QObject *parent) : DBActions(parent)
{PIX::TABLEMAP[TABLE::IMAGES], true}});
});
emit this->populate(PIX::PicturesPath);
this->populateDB({PIX::PicturesPath, PIX::DownloadsPath});
}
Pix::~Pix()
......@@ -71,15 +70,21 @@ bool Pix::run(const QString &query)
return this->execQuery(query);
}
void Pix::populateDB(const QString &path)
void Pix::populateDB(const QStringList &paths)
{
qDebug() << "Function Name: " << Q_FUNC_INFO
<< "new path for database action: " << path;
auto newPath = path;
<< "new path for database action: " << paths;
QStringList newPaths;
if(path.startsWith("file://"))
newPath = newPath.replace("file://", "");
fileLoader->requestPath(newPath);
for(auto &path : newPaths)
{
if(path.startsWith("file://"))
path.replace("file://", "");
newPaths<<path;
}
fileLoader->requestPath(newPaths);
}
QString Pix::pixColor()
......
......@@ -44,11 +44,10 @@ class Pix : public DBActions
private:
FileLoader *fileLoader;
void populateDB(const QString &path);
void populateDB(const QStringList &paths);
signals:
void refreshTables(QVariantMap tables);
void populate(QString path);
};
......
......@@ -6,7 +6,6 @@
<file>utils/Icons.js</file>
<file>utils/materialdesignicons-webfont.ttf</file>
<file>widgets/PixsBar.qml</file>
<file>qtquickcontrols2.conf</file>
<file>db/script.sql</file>
<file>view_models/PixPic.qml</file>
<file>view_models/PixHolder.qml</file>
......@@ -26,5 +25,9 @@
<file>widgets/views/Viewer/Viewer.qml</file>
<file>widgets/views/Viewer/Viewer.js</file>
<file>widgets/views/Folders/PicsView.qml</file>
<file>view_models/PixPopup.qml</file>
<file>widgets/dialogs/share/ShareDialog.qml</file>
<file>widgets/dialogs/share/ShareGrid.qml</file>
<file>widgets/dialogs/share/ShareDelegate.qml</file>
</qresource>
</RCC>
......@@ -142,6 +142,7 @@ namespace PIX
}
const QString PicturesPath = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation);
const QString DownloadsPath = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation);
const QString HomePath = QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
const QString SettingPath = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation)+"/pix/";
const QString CollectionDBPath = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)+"/pix/";
......
......@@ -13,10 +13,18 @@ ToolButton
readonly property string defaultColor : textColor
property bool anim : false
icon.name: iconName
icon.width: iconSize
icon.height: iconSize
icon.color: iconColor
Kirigami.Icon
{
id: pixIcon
anchors.centerIn: parent
width: iconSize
height: iconSize
visible: true
color: iconColor
source: iconName
isMask: true
}
onClicked: if(anim) animIcon.running = true
......@@ -29,7 +37,7 @@ ToolButton
id: animIcon
PropertyAnimation
{
target: babeButton
target: pixIcon
property: "color"
easing.type: Easing.InOutQuad
from: pix.pixColor()
......
......@@ -15,7 +15,7 @@ Page
property alias headerBarRight : headerbarActionsRight.children
property alias headerBarLeft : headerbarActionsLeft.children
property alias headerBar : header
property alias content : pageContent.children
......
import QtQuick 2.9
import QtQuick.Layouts 1.3
import QtQuick.Controls 2.2
import QtQuick.Controls.Material 2.1
Popup
{
property int maxWidth : 200
property int maxHeight : 200
parent: ApplicationWindow.overlay
width: parent === ApplicationWindow.overlay ? (root.pageStack.wideMode ? parent.width * 0.4 :
(isMobile ? parent.width * 0.8 :
parent.width * 0.7)) :
parent.width * 0.7 > maxWidth ? maxWidth :
parent.width * 0.7
height: parent === ApplicationWindow.overlay ? (root.pageStack.wideMode ? parent.height * 0.5 :
(isMobile ? parent.height * 0.8 :
parent.height * 0.7)) :
parent.height * 0.7 > maxHeight ? maxHeight :
parent.height * 0.7
x: parent.width / 2 - width / 2
y: parent.height / 2 - height / 2
z: 999
modal: true
focus: true
clip: true
margins: 1
padding: 2
enter: Transition
{
NumberAnimation { property: "opacity"; from: 0.0; to: 1.0; duration: 150 }
}
exit: Transition
{
NumberAnimation { property: "opacity"; from: 1.0; to: 0.0; duration: 150 }
}
Material.accent: pix.pixColor()
Material.background: backgroundColor
Material.primary: backgroundColor
Material.foreground: textColor
}
import QtQuick 2.0
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import org.kde.kirigami 2.2 as Kirigami
ItemDelegate
{
property int iconSize : 48
property string labelColor: GridView.isCurrentItem ? highlightedTextColor : textColor
height: 64
width: 64
background: Rectangle
{
color: "transparent"
}
ColumnLayout
{
anchors.fill: parent
Kirigami.Icon
{
Layout.fillHeight: true
Layout.fillWidth: true
Layout.alignment: Qt.AlignCenter
source: serviceIcon
isMask: false
height: iconSize
width: iconSize
}
Label
{
text: serviceLabel
width: parent.width
Layout.fillWidth: true
horizontalAlignment: Qt.AlignHCenter
elide: Qt.ElideRight
font.pointSize: fontSizes.default
color: labelColor
}
}
}
import QtQuick 2.9
import QtQuick.Layouts 1.3
import QtQuick.Controls 2.2
import "../../../view_models"
PixPopup
{
padding: contentMargins
width: 260
height: 230
parent: parent
ColumnLayout
{
anchors.fill: parent
Label
{
text: qsTr("Open with...")
width: parent.width
Layout.fillWidth: true
horizontalAlignment: Qt.AlignHCenter
elide: Qt.ElideRight
font.pointSize: fontSizes.big
padding: contentMargins
font.bold: true
}
ShareGrid
{
id: shareGrid
Layout.fillHeight: true
Layout.fillWidth: true
}
}
onOpened: populate()
function populate()
{
var services = pix.openWith(pixViewer.currentPic.url)
if(services.length>0)
for(var i in services)
shareGrid.model.append(services[i])
}
}
import QtQuick 2.0
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
GridView
{
property int gridSize : 64
clip: true
width: Math.min(model.count, Math.floor(parent.width/cellWidth))*cellWidth
height: parent.height
anchors.horizontalCenter: parent.horizontalCenter
cellHeight: gridSize+(contentMargins*2)
cellWidth: gridSize+(contentMargins*2)
focus: true
boundsBehavior: Flickable.StopAtBounds
flickableDirection: Flickable.AutoFlickDirection
snapMode: GridView.SnapToRow
model: ListModel {id: gridModel}
highlightFollowsCurrentItem: true
highlight: Rectangle
{
width: cellWidth
height: cellHeight
color: highlightColor
radius: 3
}
delegate: ShareDelegate
{
id: delegate
iconSize : 32
Connections
{
target: delegate
onClicked:
{
currentIndex = index
}
}
}
}
......@@ -25,8 +25,8 @@ ItemDelegate
Layout.fillHeight: true
Layout.fillWidth: true
Layout.alignment: Qt.AlignCenter
source: "folder"
isMask: false
height: folderSize
......@@ -34,11 +34,12 @@ ItemDelegate
Label
{
text: folder
width: parent.width
Layout.fillWidth: true
horizontalAlignment: Qt.AlignHCenter
elide: Qt.ElideRight
text: folder
width: parent.width
Layout.fillWidth: true
horizontalAlignment: Qt.AlignHCenter
elide: Qt.ElideRight
font.pointSize: fontSizes.default
}
}
......
......@@ -6,6 +6,9 @@ GridView
{
id: folderGridRoot
property int gridSize : 64
signal folderClicked(int index)
clip: true
height: parent.height
width: parent.width
......@@ -23,7 +26,14 @@ GridView
delegate: FoldersDelegate
{
id: delegate
folderSize : 32
Connections
{
target: delegate
onClicked: folderClicked(index)
}
}
......
......@@ -4,12 +4,21 @@ import "../../../view_models"
PixPage
{
headerbarExit: false
headerbarTitle: qsTr("Folders")
content: FoldersGrid
{
id: folderGrid
onFolderClicked:
{
headerbarTitle = folderGrid.model.get(index).folder
}
}
function populate()
{
var folders = pix.getFolders()
......
......@@ -3,6 +3,7 @@ import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import "../../../view_models"
import "../../../widgets/views/Viewer/Viewer.js" as VIEWER
import "../../dialogs/share"
PixPage
{
......@@ -15,6 +16,7 @@ PixPage
headerbarTitle: currentPic.title || ""
headerbarExit: false
headerbarVisible: !holder.visible
headerBarRight: [
PixButton
......@@ -24,7 +26,7 @@ PixPage
PixButton
{
iconName: "documentinfo"
iconName: "overflow-menu"
}
]
......@@ -44,6 +46,8 @@ PixPage
footer: ToolBar
{
id: footerToolbar
visible: !holder.visible
position: ToolBar.Footer
RowLayout
......@@ -68,7 +72,7 @@ PixPage
ToolTip.visible: hovered
ToolTip.text: qsTr("Share")
onClicked: pix.openWith(currentPic.url)
onClicked: shareDialog.open()
}
}
......@@ -171,11 +175,28 @@ PixPage
PixHolder
{
id: holder
message: "<h2>No Pic!</h2><p>Select or open an image from yuor gallery</p>"
emoji: "qrc:/img/assets/face-hug.png"
visible: Object.keys(currentPic).length === 0
}
ShareDialog
{
id: shareDialog
}
Rectangle
{
id: shadow
width: parent.width
height: parent.height - headerBar.height
y: headerBar.height
color: textColor
opacity: 0.6
visible: shareDialog.opened
}
content: Viewer
{
id: viewer
......
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