Commit 5c2d4051 authored by Camilo higuita's avatar Camilo higuita

added image loader for contacts photos and opt for grid view and list

parent 27229d80
......@@ -2,5 +2,6 @@
<qresource prefix="/">
<file>smartphone.svg</file>
<file>Circuit.svg</file>
<file>portrait.jpg</file>
</qresource>
</RCC>
#include "contactimage.h"
#include "mauiandroid.h"
#include <QDebug>
ContactImage::ContactImage() : QQuickImageProvider(QQuickImageProvider::Image)
{
this->no_image = QImage(":/portrait.jpg");
this->blockSignals(false);
}
QImage ContactImage::requestImage(const QString &id, QSize *size, const QSize &requestedSize)
{
qDebug()<< "requesting contact image with id "<< id;
QImage result = MAUIAndroid::contactPhoto(id);
if(result.isNull()) {
result = this->no_image;
}
if(size) {
*size = result.size();
}
if(requestedSize.width() > 0 && requestedSize.height() > 0) {
result = result.scaled(requestedSize.width(), requestedSize.height(), Qt::KeepAspectRatio);
}
return result;
}
void ContactImage::updateImage(const QImage &image)
{
if(this->image != image) {
this->image = image;
emit imageChanged();
}
}
#ifndef CONTACTIMAGE_H
#define CONTACTIMAGE_H
#include <QObject>
#include <QQuickImageProvider>
class ContactImage : public QObject, public QQuickImageProvider
{
Q_OBJECT
public:
ContactImage();
QImage requestImage(const QString &id, QSize *size, const QSize &requestedSize) override;
public slots:
void updateImage(const QImage &image);
signals:
void imageChanged();
private:
QImage image;
QImage no_image;
};
#endif // CONTACTIMAGE_H
......@@ -2,7 +2,7 @@
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include <QQuickStyle>
#include <QQuickStyle>
#include <QIcon>
#include <QCommandLineParser>
#include <QFileInfo>
......@@ -18,6 +18,7 @@
#include "./src/models/basemodel.h"
#include "./src/models/baselist.h"
#include "./src/models/contacts/contactsmodel.h"
#include "interfaces/contactimage.h"
#ifdef STATIC_KIRIGAMI
#include "./3rdparty/kirigami/src/kirigamiplugin.h"
......@@ -34,7 +35,7 @@ int main(int argc, char *argv[])
#ifdef Q_OS_ANDROID
QGuiApplication app(argc, argv);
// QGuiApplication::styleHints()->setMousePressAndHoldInterval(2000); // in [ms]
// QGuiApplication::styleHints()->setMousePressAndHoldInterval(2000); // in [ms]
#else
QApplication app(argc, argv);
#endif
......@@ -44,9 +45,9 @@ int main(int argc, char *argv[])
app.setApplicationDisplayName(APPNAME);
app.setWindowIcon(QIcon(":/smartphone.svg"));
QScopedPointer<ContactImage> contactImageProvider(new ContactImage());
QQmlApplicationEngine engine;
// QQuickStyle::setStyle("Material");
// QQuickStyle::setStyle("Material");
#ifdef STATIC_KIRIGAMI
KirigamiPlugin::getInstance().registerTypes();
......@@ -57,6 +58,7 @@ int main(int argc, char *argv[])
#endif
engine.addImageProvider("contact", contactImageProvider.data());
qmlRegisterUncreatableType<BaseList>("UnionModels", 1, 0, "BaseList", QStringLiteral("BaseList should not be created in QML"));
qmlRegisterType<BaseModel>("UnionModels", 1, 0, "BaseModel");
qmlRegisterType<ContactsModel>("UnionModels", 1, 0, "ContactsList");
......
......@@ -181,7 +181,7 @@ Maui.ApplicationWindow
anchors.centerIn: parent
width: isWide ? _contacsView.width * 0.8 : _contacsView.width * 0.95
// height: rowHeight
placeholderText: qsTr("Search %1 contacts... ".arg(_contacsView.listView.count))
placeholderText: qsTr("Search %1 contacts... ".arg(_contacsView.view.count))
onAccepted: _contacsView.list.query = text
onCleared: _contacsView.list.reset()
colorScheme.backgroundColor: cardColor
......
......@@ -200,7 +200,7 @@ Maui.Dialog
smooth: true
asynchronous: true
source: contact.photo
source: "image://contact/"+ contact.id
layer.enabled: true
layer.effect: OpacityMask
......
This diff is collapsed.
......@@ -27,7 +27,7 @@ linux:unix:!android {
message(Building helpers for Android)
QT += androidextras webview
LIBS += -ljnigraphics
include($$PWD/3rdparty/openssl/openssl.pri)
include($$PWD/mauikit/mauikit.pri)
include($$PWD/3rdparty/kirigami/kirigami.pri)
......@@ -43,6 +43,7 @@ linux:unix:!android {
SOURCES += \
$$PWD/src/main.cpp \
src/interfaces/contactimage.cpp \
src/models/baselist.cpp \
src/models/basemodel.cpp \
src/models/contacts/contactsmodel.cpp \
......@@ -59,6 +60,7 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
HEADERS += \
src/interfaces/contactimage.h \
src/union.h \
src/db/db.h \
src/db/dbactions.h \
......
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