Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Maui
Pix
Commits
cbfb009e
Commit
cbfb009e
authored
Apr 23, 2019
by
Camilo higuita
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save different default sources
parent
05f484ba
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
3 deletions
+40
-3
src/pix.cpp
src/pix.cpp
+4
-1
src/utils/pic.h
src/utils/pic.h
+34
-0
src/view_models/PixPic.qml
src/view_models/PixPic.qml
+1
-1
src/widgets/views/Viewer/PixViewer.qml
src/widgets/views/Viewer/PixViewer.qml
+1
-1
No files found.
src/pix.cpp
View file @
cbfb009e
...
...
@@ -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
);
}
src/utils/pic.h
View file @
cbfb009e
...
...
@@ -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
src/view_models/PixPic.qml
View file @
cbfb009e
...
...
@@ -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
{
...
...
src/widgets/views/Viewer/PixViewer.qml
View file @
cbfb009e
...
...
@@ -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
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment