Commit 89ab67e6 authored by Camilo higuita's avatar Camilo higuita

open external images now working again

parent 5e0d9ebf
......@@ -155,6 +155,23 @@ Maui.ApplicationWindow
pix.addSources(paths)
})
}
},
Maui.MenuItem
{
text: "Open..."
onTriggered:
{
dialogLoader.sourceComponent= fmDialogComponent
dialog.mode = dialog.modes.OPEN
dialog.filterType= FMList.IMAGE
dialog.onlyDirs= false
dialog.show(function(paths)
{
pix.openPics(paths)
});
}
}
]
......
......@@ -191,8 +191,27 @@ void Gallery::append(const QVariantMap &pic)
void Gallery::append(const QString &url)
{
emit this->preItemAppended();
qDebug()<< QString("select * from images where url = '%1'").arg(url);
this->list << this->dba->getDBData(QString("select * from images where url = '%1'").arg(url));
if(this->dba->checkExistance("images", "url", url))
this->list << this->dba->getDBData(QString("select * from images where url = '%1'").arg(url));
else
{
QFileInfo info(url);
auto title = info.baseName();
auto format = info.suffix();
auto sourceUrl = info.dir().path();
auto picMap = FMH::getFileInfoModel(url);
picMap[FMH::MODEL_KEY::URL] = title;
picMap[FMH::MODEL_KEY::FAV] = "0";
picMap[FMH::MODEL_KEY::RATE] = "0";
picMap[FMH::MODEL_KEY::COLOR] = QString();
picMap[FMH::MODEL_KEY::FORMAT] = format;
picMap[FMH::MODEL_KEY::DATE] = info.birthTime().toString();
picMap[FMH::MODEL_KEY::SOURCE] = sourceUrl;
this->list << picMap;
}
emit this->postItemAppended();
}
......
......@@ -61,6 +61,7 @@ public slots:
bool fav(const int &index, const bool &value);
void append(const QVariantMap &pic);
void append(const QString &url);
// void appendAt(const QString &url, const int &pos);
void refresh();
void clear();
};
......
......@@ -65,32 +65,8 @@ Pix::~Pix()
}
void Pix::openPics(const QStringList &pics)
{
QVariantList data;
for(auto url : pics)
{
QFileInfo info(url);
auto title = info.baseName();
auto format = info.suffix();
auto sourceUrl = info.dir().path();
QVariantMap picMap =
{
{FMH::MODEL_NAME[FMH::MODEL_KEY::URL], url},
{FMH::MODEL_NAME[FMH::MODEL_KEY::TITLE], title},
{FMH::MODEL_NAME[FMH::MODEL_KEY::FAV], "0"},
{FMH::MODEL_NAME[FMH::MODEL_KEY::RATE], "0"},
{FMH::MODEL_NAME[FMH::MODEL_KEY::COLOR], ""},
{FMH::MODEL_NAME[FMH::MODEL_KEY::SOURCE], sourceUrl},
{FMH::MODEL_NAME[FMH::MODEL_KEY::DATE], info.birthTime().toString()},
{FMH::MODEL_NAME[FMH::MODEL_KEY::FORMAT], format}
};
data << picMap;
}
emit viewPics(data);
{
emit viewPics(pics);
}
void Pix::refreshCollection()
......
......@@ -60,6 +60,6 @@ private:
signals:
void refreshViews(QVariantMap tables);
void viewPics(QVariantList pics);
void viewPics(QStringList pics);
};
#endif // PIX_H
......@@ -33,10 +33,10 @@ Maui.Page
margins: 0
colorScheme.backgroundColor: viewerBackgroundColor
headBarExit: false
allowRiseContent: true
allowRiseContent: false
headBar.drawBorder: false
headBarTitle: currentPic.title ? currentPic.title : ""
headBar.rightContent: [
headBar.rightContent: [
Maui.ToolButton
{
......@@ -91,17 +91,10 @@ Maui.Page
id : viewerConf
}
// EditTools
// {
// id: editTools
// }
backContain: GalleryRoll
{
id: galleryRoll
visible: !holder.visible
onPicClicked: VIEWER.view(index)
}
// EditTools
// {
// id: editTools
// }
floatingBar: true
footBarOverlap: true
......@@ -115,80 +108,100 @@ Maui.Page
PixModel
{
id: pixModel
list: GalleryList {}
}
Viewer
{
id: viewer
ColumnLayout
{
height: parent.height
width: parent.width
floatingBar: true
headBar.visible: false
Viewer
{
id: viewer
Layout.fillHeight: true
Layout.fillWidth: true
footBar.colorScheme.backgroundColor: accentColor
footBar.colorScheme.textColor: altColorText
// footBar.colorScheme.borderColor: accentColor
floatingBar: true
headBar.visible: false
footBar.middleContent: [
footBar.colorScheme.backgroundColor: accentColor
footBar.colorScheme.textColor: altColorText
// footBar.colorScheme.borderColor: accentColor
Maui.ToolButton
{
iconName: "go-previous"
iconColor: altColorText
onClicked: VIEWER.previous()
},
footBar.middleContent: [
Maui.ToolButton
{
iconName: "love"
colorScheme.highlightColor: "#ff557f";
iconColor: pixViewer.currentPicFav ? colorScheme.highlightColor : colorScheme.textColor
onClicked: pixViewer.currentPicFav = VIEWER.fav([pixViewer.currentPic.url])
},
Maui.ToolButton
{
iconName: "go-previous"
iconColor: altColorText
onClicked: VIEWER.previous()
},
Maui.ToolButton
{
iconName: "love"
colorScheme.highlightColor: "#ff557f";
iconColor: pixViewer.currentPicFav ? colorScheme.highlightColor : colorScheme.textColor
onClicked: pixViewer.currentPicFav = VIEWER.fav([pixViewer.currentPic.url])
},
Maui.ToolButton
{
iconName: "go-next"
iconColor: altColorText
onClicked: VIEWER.next()
}
]
Maui.ToolButton
Maui.Holder
{
iconName: "go-next"
iconColor: altColorText
onClicked: VIEWER.next()
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*/
colorScheme.backgroundColor: viewerForegroundColor
}
]
Maui.Holder
{
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*/
colorScheme.backgroundColor: viewerForegroundColor
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)
}
}
footer: Maui.TagsBar
GalleryRoll
{
id: tagBar
visible: !holder.visible && tagBarVisible && !fullScreen
id: galleryRoll
Layout.fillWidth: true
bgColor: viewerBackgroundColor
allowEditMode: true
list.urls: [currentPic.url]
onTagClicked: PIX.searchFor(tag)
onAddClicked:
{
dialogLoader.sourceComponent = tagsDialogComponent
dialog.show(currentPic.url)
}
Layout.margins: space.big
onTagRemovedClicked: list.removeFromUrls(index)
onTagsEdited: list.updateToUrls(tags)
visible: !holder.visible
onPicClicked: VIEWER.view(index)
}
}
function toogleTagbar()
{
tagBarVisible = !tagBarVisible
......
......@@ -6,18 +6,15 @@ function open(list, index)
{
pixViewer.model.list = list
view(index)
if(currentView !== views.viewer)
currentView = views.viewer
currentView = views.viewer
}
function openExternalPics(pics, index)
{
pixViewer.viewer.populate(pics)
view(index)
if(currentView !== views.viewer)
currentView = views.viewer
var oldIndex = pixViewer.viewer.count
pixViewer.viewer.appendPics(pics)
view(Math.max(oldIndex, 0))
currentView = views.viewer
}
function view(index)
......
......@@ -61,12 +61,11 @@ Maui.Page
}
function populate(pics)
function appendPics(pics)
{
viewerList.model.clear()
if(pics.length > 0)
for(var i in pics)
viewerList.model.append(pics[i])
viewerList.model.list.append(pics[i])
}
......
......@@ -3,33 +3,12 @@ import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import org.kde.kirigami 2.2 as Kirigami
import org.kde.mauikit 1.0 as Maui
import FMList 1.0
import "../../../view_models"
Maui.Menu
{
Maui.MenuItem
{
text: "Open..."
onTriggered:
{
dialogLoader.sourceComponent= fmDialogComponent
dialog.mode = dialog.modes.OPEN
dialog.show(function(paths)
{
console.log("OPEN IMAGE", paths)
});
close()
}
}
MenuSeparator{}
Maui.MenuItem
{
checkable: true
......@@ -41,9 +20,9 @@ Maui.Menu
Maui.MenuItem
{
checkable: true
checked: contentIsRised
checked: galleryRoll.visible
text: qsTr("Preview bar")
onTriggered: contentIsRised ? dropContent() : riseContent()
onTriggered: galleryRoll.visible = !galleryRoll.visible
}
}
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