Commit 16c1f2c4 authored by Camilo Higuita's avatar Camilo Higuita

use maui holder and refresh current view after removing a file

parent 64bcff79
......@@ -70,7 +70,10 @@ QVariantList DBActions::get(const QString &queryTxt)
if(query.record().indexOf(PIX::KEYMAP[key])>-1)
data[PIX::KEYMAP[key]] = query.value(PIX::KEYMAP[key]).toString();
mapList<< data;
if(PIX::fileExists(data[PIX::KEYMAP[PIX::KEY::URL]].toString()))
mapList<< data;
else
removePic(data[PIX::KEYMAP[PIX::KEY::URL]].toString());
}
}else qDebug()<< query.lastError()<< query.lastQuery();
......
......@@ -87,12 +87,6 @@ Maui.ApplicationWindow
headBar.middleContent: PixsBar
{
visible: !fullScreen
onViewerViewClicked: currentView = views.viewer
onGalleryViewClicked: currentView = views.gallery
onFoldersViewClicked: currentView = views.folders
onAlbumsViewClicked: currentView = views.albums
onTagsViewClicked: currentView = views.tags
}
footBar.leftContent: Maui.ToolButton
......
......@@ -103,22 +103,6 @@ void Pix::refreshCollection()
this->populateDB({PIX::PicturesPath, PIX::DownloadsPath, PIX::DocumentsPath});
}
QVariantList Pix::getList(const QStringList &urls)
{
QVariantList mapList;
for(auto url : urls)
{
auto queryTxt = QString("SELECT * FROM %1 WHERE %2 = \"%3\"").arg(TABLEMAP[TABLE::IMAGES],
KEYMAP[KEY::URL], url);
mapList << this->get(queryTxt);
}
return mapList;
}
bool Pix::run(const QString &query)
{
return this->execQuery(query);
......@@ -144,11 +128,6 @@ void Pix::populateDB(const QStringList &paths)
fileLoader->requestPath(newPaths);
}
QString Pix::pixColor()
{
return "#03A9F4";
}
void Pix::saveSettings(const QString &key, const QVariant &value, const QString &group)
{
PIX::saveSettings(key, value, group);
......@@ -160,71 +139,6 @@ QVariant Pix::loadSettings(const QString &key, const QString &group, const QVari
return PIX::loadSettings(key, group, defaultValue);
}
int Pix::screenGeometry(QString &side)
{
side = side.toLower();
auto geo = QApplication::desktop()->screenGeometry();
if(side == "width")
return geo.width();
else if(side == "height")
return geo.height();
else return 0;
}
int Pix::cursorPos(QString &axis)
{
axis = axis.toLower();
auto pos = QCursor::pos();
if(axis == "x")
return pos.x();
else if(axis == "y")
return pos.y();
else return 0;
}
QString Pix::homeDir()
{
return PIX::PicturesPath;
}
QVariantList Pix::getDirs(const QString &pathUrl)
{
auto path = pathUrl;
if(path.startsWith("file://"))
path.replace("file://", "");
qDebug()<<"DIRECTRORY"<<path;
QVariantList paths;
if (QFileInfo(path).isDir())
{
QDirIterator it(path, QDir::Dirs, QDirIterator::NoIteratorFlags);
while (it.hasNext())
{
auto url = it.next();
auto name = QDir(url).dirName();
qDebug()<<name<<url;
QVariantMap map = { {"url", url }, {"name", name} };
paths << map;
}
}
return paths;
}
QVariantMap Pix::getParentDir(const QString &path)
{
auto dir = QDir(path);
dir.cdUp();
auto dirPath = dir.absolutePath();
if(dir.isReadable() && !dir.isRoot() && dir.exists())
return {{"url", dirPath}, {"name", dir.dirName()}};
else
return {{"url", path}, {"name", QFileInfo(path).dir().dirName()}};
}
bool Pix::removeFile(const QString &url)
{
QFile file(url);
......
......@@ -53,27 +53,15 @@ public:
Q_INVOKABLE void refreshCollection();
Q_INVOKABLE QVariantList getList(const QStringList &urls);
Q_INVOKABLE bool run(const QString &query);
Q_INVOKABLE static QString pixColor();
Q_INVOKABLE static void saveSettings(const QString &key, const QVariant &value, const QString &group);
Q_INVOKABLE static QVariant loadSettings(const QString &key, const QString &group, const QVariant &defaultValue);
Q_INVOKABLE static int screenGeometry(QString &side);
Q_INVOKABLE static int cursorPos(QString &axis);
Q_INVOKABLE static QString homeDir();
Q_INVOKABLE static QVariantList getDirs(const QString &pathUrl);
Q_INVOKABLE static QVariantMap getParentDir(const QString &path);
/*File actions*/
Q_INVOKABLE bool removeFile(const QString &url);
Q_INVOKABLE void showInFolder(const QString &url);
private:
FileLoader *fileLoader;
......
......@@ -8,7 +8,6 @@
<file>widgets/PixsBar.qml</file>
<file>db/script.sql</file>
<file>view_models/PixPic.qml</file>
<file>view_models/PixHolder.qml</file>
<file>db/Query.js</file>
<file>view_models/PixPage.qml</file>
<file>widgets/views/Folders/FoldersView.qml</file>
......
......@@ -21,7 +21,7 @@ Maui.Page
/*signals*/
signal picClicked(int index)
PixHolder
Maui.Holder
{
id: holder
message: "<h2>No Pics!</h2><p>There's not images in here</p>"
......
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import QtGraphicalEffects 1.0
Item
{
property string emoji
property string message
clip: true
property color foregroundColor : textColor
focus: true
anchors.fill: parent
GridLayout
{
id:placeHolder
anchors.fill: parent
columns: 1
rows: 2
Rectangle
{
anchors.fill: parent
Layout.row: 1
color: "transparent"
Image
{
id: imageHolder
anchors.centerIn: parent
width: iconSizes.large
height: iconSizes.large
source: emoji? emoji : "qrc:/../assets/face.png"
horizontalAlignment: Qt.AlignHCenter
fillMode: Image.PreserveAspectFit
}
HueSaturation
{
anchors.fill: imageHolder
source: imageHolder
saturation: -1
lightness: 0.3
}
Label
{
id: textHolder
width: parent.width
anchors.top: imageHolder.bottom
opacity: 0.3
text: message ? qsTr(message) : qsTr("Nothing here...")
font.pointSize: fontSizes.default
padding: space.medium
font.bold: true
textFormat: Text.RichText
horizontalAlignment: Qt.AlignHCenter
elide: Text.ElideRight
color: foregroundColor
}
}
}
}
......@@ -28,6 +28,7 @@ PixMenu
close()
}
}
MenuItem
{
text: qsTr("Add to...")
......@@ -57,6 +58,7 @@ PixMenu
close()
}
}
MenuItem
{
text: qsTr("Remove...")
......
......@@ -9,12 +9,13 @@ Row
property string accentColor : highlightColor
signal viewerViewClicked()
signal galleryViewClicked()
signal albumsViewClicked()
signal tagsViewClicked()
signal foldersViewClicked()
signal searchViewClicked()
Maui.ToolButton
{
iconColor: currentView === views.viewer? accentColor : textColor
iconName: "image"
onClicked: currentView = views.viewer
}
Maui.ToolButton
{
......@@ -23,7 +24,7 @@ Row
text: qsTr("Gallery")
iconColor: currentView === views.gallery? accentColor : textColor
iconName: "image-multiple"
onClicked: galleryViewClicked()
onClicked: currentView = views.gallery
}
Maui.ToolButton
......@@ -33,7 +34,7 @@ Row
text: qsTr("Folders")
iconColor: currentView === views.folders? accentColor : textColor
iconName: "image-folder-view"
onClicked: foldersViewClicked()
onClicked: currentView = views.folders
}
Maui.ToolButton
......@@ -43,7 +44,7 @@ Row
text: qsTr("Albums")
iconColor: currentView === views.albums? accentColor : textColor
iconName: "image-frames"
onClicked: albumsViewClicked()
onClicked: currentView = views.albums
}
Maui.ToolButton
......@@ -53,7 +54,7 @@ Row
text: qsTr("Tags")
iconColor: currentView === views.tags? accentColor : textColor
iconName: "tag"
onClicked: tagsViewClicked()
onClicked: currentView = views.tags
}
}
import QtQuick 2.0
import QtQuick.Controls 2.2
import "../../../view_models"
import org.kde.maui 1.0 as Maui
ListView
{
......@@ -20,7 +21,7 @@ ListView
highlightFollowsCurrentItem: true
highlightMoveDuration: 0
PixHolder
Maui.Holder
{
id: holder
message: "<h2>No Albums!</h2><p>Start creating new albums</p>"
......
import QtQuick 2.0
import QtQuick.Controls 2.2
import "../../../view_models"
import org.kde.maui 1.0 as Maui
ListView
{
......@@ -22,7 +23,7 @@ ListView
highlightFollowsCurrentItem: true
highlightMoveDuration: 0
PixHolder
Maui.Holder
{
id: holder
message: "<h2>No Tags!</h2><p>Start tagging your pics</p>"
......
......@@ -12,6 +12,9 @@ Kirigami.PageRow
interactive: foldersPageRoot.currentIndex === 1
clip: true
property string currentFolder : ""
property alias picsView : picsView
PixPage
{
id: foldersPage
......@@ -29,7 +32,8 @@ Kirigami.PageRow
folderGrid.currentIndex = index
picsView.headBarTitle = folderGrid.model.get(index).folder
picsView.clear()
picsView.populate(folderGrid.model.get(index).url)
currentFolder = folderGrid.model.get(index).url
picsView.populate(currentFolder)
foldersPageRoot.currentIndex = 1
}
}
......
......@@ -21,7 +21,26 @@ function addTagToAlbum(tag, url)
function removePic(url)
{
if(pix.removeFile(url))
refreshViews()
{
switch(currentView)
{
case views.gallery :
galleryView.populate()
break
case views.folders:
foldersView.picsView.populate(foldersView.currentFolder)
break
case views.albums:
albumsView.filter(albumsView.albumsGrid.currentAlbum)
break
case views.tags:
tagsView.populateGrid(tagsView.currentTag)
break
case views.search:
searchView.runSearch(searchView.currentQuery)
}
}
}
function addTagsToPic(tags, url)
......
......@@ -8,6 +8,8 @@ import org.kde.maui 1.0 as Maui
Maui.Page
{
property string currentQuery : ""
headBarExitIcon: "edit-clear"
headBarTitle: searchResults.grid.count + qsTr(" results")
headBarVisible: true
......@@ -55,8 +57,7 @@ Maui.Page
searchResults.clear()
if(query)
{
console.log(query)
headBarTitle = query
currentQuery = query
var queries = query.split(",")
for(var i in queries)
......@@ -66,7 +67,6 @@ Maui.Page
function populate(data)
{
if(data.length > 0)
for(var i in data)
searchResults.grid.model.append(data[i])
......
......@@ -38,7 +38,8 @@ Maui.Page
onClicked:
{
tagsList.currentIndex = index
populateGrid(tagsList.model.get(index).tag)
currentTag = tagsList.model.get(index).tag
populateGrid(currentTag)
}
}
}
......
......@@ -15,6 +15,8 @@ Kirigami.PageRow
defaultColumnWidth: Kirigami.Units.gridUnit * 15
interactive: currentIndex === 1
property string currentTag : ""
Connections
{
target: pix
......
......@@ -97,13 +97,13 @@ Maui.Page
id : viewerConf
}
PixHolder
Maui.Holder
{
id: holder
message: "<h2>No Pic!</h2><p>Open an image from your collection</p>"
emoji: "qrc:/img/assets/face-hug.png"
visible: viewer.list.count === 0
foregroundColor: viewerForegroundColor
fgColor: viewerForegroundColor
}
EditTools
......
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