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)
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)
......@@ -99,5 +101,6 @@ void Pix::showInFolder(const QStringList &urls)
void Pix::addSources(const QStringList &paths)
{
PIX::saveSourcePath(paths);
this->populateDB(paths);
}
......@@ -33,6 +33,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QJsonDocument>
#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
{
//Q_NAMESPACE
......@@ -170,6 +179,31 @@ inline QString getQuery(const QString &key)
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
......@@ -88,11 +88,11 @@ ItemDelegate
sourceSize.width: control.picSize
cache: control.cachePic
antialiasing: true
asynchronous: true
smooth: true
fillMode: fit ? Image.PreserveAspectFit : Image.PreserveAspectCrop
source: (url && url.length>0) ?
"file://"+encodeURIComponent(url) : "qrc:/img/assets/image-x-generic.svg"
asynchronous: true
Rectangle
{
......
......@@ -193,7 +193,7 @@ Maui.Page
id: galleryRoll
Layout.fillWidth: true
Layout.margins: space.big
rollHeight: 120 * unit
visible: !holder.visible
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