forked from lubuwest/Friendiqa
v0.5.1
This commit is contained in:
parent
01e9ae06f4
commit
7119d5bdf4
292 changed files with 790 additions and 16347 deletions
|
@ -43,6 +43,7 @@ ALARM::ALARM(QObject *parent) : QObject(parent){}
|
|||
|
||||
void ALARM::setAlarm(int interval)
|
||||
{
|
||||
//qDebug() << "alarm "<< interval;
|
||||
QVariantMap message;
|
||||
message["value"] = interval;
|
||||
AndroidNative::SystemDispatcher::instance()->loadClass("androidnative.Util");
|
||||
|
|
|
@ -29,12 +29,11 @@
|
|||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//#include <QtAndroidExtras/QAndroidJniObject>
|
||||
//#include <QtAndroidExtras/QAndroidJniEnvironment>
|
||||
#include "alarm.h"
|
||||
#include <QtCore/QDebug>
|
||||
#include <QtDBus/QtDBus>
|
||||
//#include "AndroidNative/systemdispatcher.h"
|
||||
#include <QJsonArray>
|
||||
|
||||
|
||||
ALARM *ALARM::instance()
|
||||
{
|
||||
|
@ -49,25 +48,23 @@ void ALARM::setAlarm(int interval)
|
|||
qDebug() << interval;
|
||||
QVariantMap message;
|
||||
message["value"] = interval;
|
||||
// AndroidNative::SystemDispatcher::instance()->loadClass("androidnative.Util");
|
||||
// AndroidNative::SystemDispatcher::instance()->dispatch("androidnative.Util.setSchedule", message);
|
||||
//AndroidNative::SystemDispatcher::instance()->dispatch("androidnative.Util.stopService", message);
|
||||
}
|
||||
|
||||
void ALARM::notify(QString title, QString text, int id)
|
||||
{
|
||||
qDebug() << title << text;
|
||||
QVariantMap message;
|
||||
message["title"] = title;
|
||||
message["message"] = text;
|
||||
// QVariantMap message;
|
||||
// message["title"] = title;
|
||||
// message["message"] = text;
|
||||
QStringList actionlist;
|
||||
QMap<QString,QVariant> hint;
|
||||
QDBusConnection bus = QDBusConnection::sessionBus();
|
||||
QDBusInterface dbus_iface("org.freedesktop.Notifications", "/org/freedesktop/Notifications",
|
||||
"org.freedesktop.Notifications", bus);
|
||||
QString appname="Friendiqa";
|
||||
uint v=12321;
|
||||
if (dbus_iface.isValid()){
|
||||
|
||||
dbus_iface.call("Notify",appname,v,"",title,text,"","",5000);
|
||||
dbus_iface.call("Notify",appname,v,"",title,text,actionlist,hint,10000);
|
||||
//qDebug() << "Qdebug error " << dbus_iface.lastError();
|
||||
}
|
||||
// AndroidNative::SystemDispatcher::instance()->dispatch("Notifier.notify", message);
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
|
||||
#include <QApplication>
|
||||
#include <QtQml/QQmlEngine>
|
||||
#include <QtWebEngine>
|
||||
//#include <QAndroidService>
|
||||
//#include <QtAndroid>
|
||||
#include <QtQuick>
|
||||
|
@ -88,6 +89,7 @@ int main(int argc, char *argv[]) {
|
|||
view.rootContext()->setContextProperty("alarm", alarm);
|
||||
UPDATENEWS* updatenews = UPDATENEWS::instance();
|
||||
view.rootContext()->setContextProperty("updatenews", updatenews);
|
||||
QtWebEngine::initialize();
|
||||
view.setSource(QUrl("qrc:/qml/friendiqa.qml"));
|
||||
view.show();
|
||||
view.connect(view.rootContext()->engine(), SIGNAL(quit()), &app, SLOT(quit()));
|
||||
|
|
|
@ -36,6 +36,19 @@
|
|||
#include <QDebug>
|
||||
#include <QFileInfo>
|
||||
#include <QUrl>
|
||||
#include <QTransform>
|
||||
|
||||
void UploadableImage::setAngle(const int &b) {
|
||||
if (b != m_angle) {
|
||||
m_angle = b;
|
||||
|
||||
qDebug() << "UploadableImage::setAngle : " << m_angle;
|
||||
if (m_angle==0) {
|
||||
emit angleChanged();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UploadableImage::setSource(const QString &a) {
|
||||
if (a != m_source) {
|
||||
|
@ -55,6 +68,12 @@ void UploadableImage::setSource(const QString &a) {
|
|||
}
|
||||
|
||||
QImage fullimage = QImage(QUrl(m_source).toLocalFile());
|
||||
|
||||
if (m_angle!=0){
|
||||
QTransform transform;
|
||||
transform.rotate(qreal(m_angle));
|
||||
fullimage=fullimage.transformed(transform);
|
||||
}
|
||||
if (fullimage.width() > 800 || fullimage.height() > 800) {
|
||||
if (fullimage.width() > fullimage.height()) {
|
||||
m_image = fullimage.scaledToWidth(800);
|
||||
|
@ -101,6 +120,9 @@ QString UploadableImage::source() const {
|
|||
return m_source;
|
||||
}
|
||||
|
||||
int UploadableImage::angle() const{
|
||||
return m_angle;
|
||||
}
|
||||
//QString UploadableImage::base64() const {
|
||||
// return m_base64;
|
||||
//}
|
||||
|
|
|
@ -40,6 +40,7 @@ class UploadableImage : public QObject
|
|||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QString source READ source WRITE setSource NOTIFY sourceChanged)
|
||||
Q_PROPERTY(int angle READ angle WRITE setAngle NOTIFY angleChanged)
|
||||
//Q_PROPERTY(QString base64 READ base64 NOTIFY base64Changed)
|
||||
Q_PROPERTY(QString filename READ filename NOTIFY filenameChanged)
|
||||
Q_PROPERTY(QString mimetype READ mimetype NOTIFY mimetypeChanged)
|
||||
|
@ -47,8 +48,9 @@ class UploadableImage : public QObject
|
|||
|
||||
public:
|
||||
void setSource(const QString &a);
|
||||
void setAngle(const int &b);
|
||||
QString source() const;
|
||||
|
||||
int angle() const;
|
||||
//QString base64() const;
|
||||
QString filename() const;
|
||||
QString mimetype() const;
|
||||
|
@ -56,6 +58,7 @@ public:
|
|||
QByteArray bytes();
|
||||
signals:
|
||||
void sourceChanged();
|
||||
void angleChanged();
|
||||
//void base64Changed();
|
||||
void filenameChanged();
|
||||
void mimetypeChanged();
|
||||
|
@ -63,6 +66,7 @@ signals:
|
|||
private:
|
||||
QString m_source;
|
||||
QImage m_image;
|
||||
int m_angle;
|
||||
//QString m_base64;
|
||||
QString m_filename;
|
||||
QString m_mimetype;
|
||||
|
|
|
@ -251,19 +251,29 @@ void XHR::post()
|
|||
}
|
||||
|
||||
UploadableImage uimg;
|
||||
QHashIterator<QString, QString> ifiles(files);
|
||||
while(ifiles.hasNext()) {
|
||||
ifiles.next();
|
||||
|
||||
uimg.setSource(ifiles.value());
|
||||
//qDebug() << "\t image: " << uimg.mimetype() << ", " << ifiles.key();
|
||||
if (files.contains("media")){
|
||||
uimg.setAngle(files.value("angle").toInt());
|
||||
uimg.setSource(files.value("media"));
|
||||
|
||||
QHttpPart imagePart;
|
||||
imagePart.setHeader(QNetworkRequest::ContentTypeHeader, QVariant(uimg.mimetype()));
|
||||
imagePart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"" + ifiles.key() + "\"; filename=\""+uimg.filename()+"\""));
|
||||
imagePart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"media\"; filename=\""+uimg.filename()+"\""));
|
||||
imagePart.setBody(uimg.bytes());
|
||||
multiPart->append(imagePart);
|
||||
}
|
||||
// QHashIterator<QString, QString> ifiles(files);
|
||||
// while(ifiles.hasNext()) {
|
||||
// ifiles.next();
|
||||
|
||||
// uimg.setSource(ifiles.value());
|
||||
// //qDebug() << "\t image: " << uimg.mimetype() << ", " << ifiles.key();
|
||||
|
||||
// QHttpPart imagePart;
|
||||
// imagePart.setHeader(QNetworkRequest::ContentTypeHeader, QVariant(uimg.mimetype()));
|
||||
// imagePart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"" + ifiles.key() + "\"; filename=\""+uimg.filename()+"\""));
|
||||
// imagePart.setBody(uimg.bytes());
|
||||
// multiPart->append(imagePart);
|
||||
// }
|
||||
|
||||
QByteArray loginData = m_login.toLocal8Bit().toBase64();
|
||||
QString headerData = "Basic " + loginData;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue