Commit cbfb009e authored by Camilo higuita's avatar Camilo higuita

save different default sources

parent 05f484ba
...@@ -71,7 +71,9 @@ void Pix::openPics(const QStringList &pics) ...@@ -71,7 +71,9 @@ void Pix::openPics(const QStringList &pics)
void Pix::refreshCollection() void Pix::refreshCollection()
{ {
this->populateDB({FMH::PicturesPath, FMH::DownloadsPath, FMH::DocumentsPath, FMH::CloudCachePath}); const auto sources = PIX::getSourcePaths();
qDebug()<< "getting default sources to look up" << sources;
this->populateDB(sources);
} }
void Pix::populateDB(const QStringList &paths) void Pix::populateDB(const QStringList &paths)
...@@ -99,5 +101,6 @@ void Pix::showInFolder(const QStringList &urls) ...@@ -99,5 +101,6 @@ void Pix::showInFolder(const QStringList &urls)
void Pix::addSources(const QStringList &paths) void Pix::addSources(const QStringList &paths)
{ {
PIX::saveSourcePath(paths);
this->populateDB(paths); this->populateDB(paths);
} }
...@@ -33,6 +33,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. ...@@ -33,6 +33,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QJsonDocument> #include <QJsonDocument>
#include <QJsonObject> #include <QJsonObject>
#if (defined (Q_OS_LINUX) && !defined (Q_OS_ANDROID))
#include <MauiKit/utils.h>
#include <MauiKit/fmh.h>
#else
#include "utils.h"
#include "fmh.h"
#endif
namespace PIX namespace PIX
{ {
//Q_NAMESPACE //Q_NAMESPACE
...@@ -170,6 +179,31 @@ inline QString getQuery(const QString &key) ...@@ -170,6 +179,31 @@ inline QString getQuery(const QString &key)
return itemMap.value(key).toString(); return itemMap.value(key).toString();
} }
inline QStringList getSourcePaths()
{
const auto defaultSources = QStringList() << FMH::PicturesPath << FMH::DownloadsPath << FMH::DocumentsPath << FMH::CloudCachePath;
const auto sources = UTIL::loadSettings("Sources", "Settings", defaultSources).toStringList();
if(sources.isEmpty())
UTIL::saveSettings("Sources", defaultSources, "Settings");
return sources;
}
inline void saveSourcePath(QStringList const& paths)
{
auto sources = PIX::getSourcePaths();
for(const auto &path : paths)
{
if(sources.contains(path))
continue;
sources << path;
UTIL::saveSettings("Sources", sources, "Settings");
}
}
} }
#endif // PIC_H #endif // PIC_H
...@@ -88,11 +88,11 @@ ItemDelegate ...@@ -88,11 +88,11 @@ ItemDelegate
sourceSize.width: control.picSize sourceSize.width: control.picSize
cache: control.cachePic cache: control.cachePic
antialiasing: true antialiasing: true
asynchronous: true
smooth: true smooth: true
fillMode: fit ? Image.PreserveAspectFit : Image.PreserveAspectCrop fillMode: fit ? Image.PreserveAspectFit : Image.PreserveAspectCrop
source: (url && url.length>0) ? source: (url && url.length>0) ?
"file://"+encodeURIComponent(url) : "qrc:/img/assets/image-x-generic.svg" "file://"+encodeURIComponent(url) : "qrc:/img/assets/image-x-generic.svg"
asynchronous: true
Rectangle Rectangle
{ {
......
...@@ -193,7 +193,7 @@ Maui.Page ...@@ -193,7 +193,7 @@ Maui.Page
id: galleryRoll id: galleryRoll
Layout.fillWidth: true Layout.fillWidth: true
Layout.margins: space.big Layout.margins: space.big
rollHeight: 120 * unit
visible: !holder.visible visible: !holder.visible
onPicClicked: VIEWER.view(index) onPicClicked: VIEWER.view(index)
} }
......
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