diff --git a/src/lib/qtlib/.gitignore b/src/lib/qtlib/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..75c107bcc90038bcdd0d643b20eb4d33a13b4245 --- /dev/null +++ b/src/lib/qtlib/.gitignore @@ -0,0 +1 @@ +*.pro.user diff --git a/src/lib/qtlib/README.txt b/src/lib/qtlib/README.txt new file mode 100644 index 0000000000000000000000000000000000000000..3dc2fdfac1edac3d1aabefdcfbe1a3c857a5411a --- /dev/null +++ b/src/lib/qtlib/README.txt @@ -0,0 +1 @@ +A library for Qt app diff --git a/src/lib/qtlib/qtlib-test.pro b/src/lib/qtlib/qtlib-test.pro new file mode 100644 index 0000000000000000000000000000000000000000..6d61b4c4df5ba30cd28d593ae9949fb6a0cd5b1d --- /dev/null +++ b/src/lib/qtlib/qtlib-test.pro @@ -0,0 +1,13 @@ +include(qtlib.pri) + +TARGET = qtlib-test + +TEMPLATE = app + +CONFIG += c++11 + +QT += core + +SOURCES += test/main.cpp + +DISTFILES += README.txt diff --git a/src/lib/qtlib/qtlib.pri b/src/lib/qtlib/qtlib.pri index 2cc38b2c8b9fb68afee226262dff130009ef5104..8d8e38182c47b2e2e8a5e28c514e65bac347562f 100644 --- a/src/lib/qtlib/qtlib.pri +++ b/src/lib/qtlib/qtlib.pri @@ -3,24 +3,24 @@ QT += \ network HEADERS += \ - $${PWD}/qtlib_file.h \ - $${PWD}/qtlib_dir.h \ - $${PWD}/qtlib_json.h \ - $${PWD}/qtlib_config.h \ - $${PWD}/qtlib_networkresource.h \ - $${PWD}/qtlib_ocsapi.h \ - $${PWD}/qtlib_package.h + $${PWD}/src/qtlib_file.h \ + $${PWD}/src/qtlib_dir.h \ + $${PWD}/src/qtlib_json.h \ + $${PWD}/src/qtlib_config.h \ + $${PWD}/src/qtlib_networkresource.h \ + $${PWD}/src/qtlib_ocsapi.h \ + $${PWD}/src/qtlib_package.h SOURCES += \ - $${PWD}/qtlib_file.cpp \ - $${PWD}/qtlib_dir.cpp \ - $${PWD}/qtlib_json.cpp \ - $${PWD}/qtlib_config.cpp \ - $${PWD}/qtlib_networkresource.cpp \ - $${PWD}/qtlib_ocsapi.cpp \ - $${PWD}/qtlib_package.cpp + $${PWD}/src/qtlib_file.cpp \ + $${PWD}/src/qtlib_dir.cpp \ + $${PWD}/src/qtlib_json.cpp \ + $${PWD}/src/qtlib_config.cpp \ + $${PWD}/src/qtlib_networkresource.cpp \ + $${PWD}/src/qtlib_ocsapi.cpp \ + $${PWD}/src/qtlib_package.cpp -INCLUDEPATH += $${PWD} +INCLUDEPATH += $${PWD}/src unix:!ios:!android { DEFINES += QTLIB_UNIX diff --git a/src/lib/qtlib/qtlib_config.cpp b/src/lib/qtlib/src/qtlib_config.cpp similarity index 100% rename from src/lib/qtlib/qtlib_config.cpp rename to src/lib/qtlib/src/qtlib_config.cpp diff --git a/src/lib/qtlib/qtlib_config.h b/src/lib/qtlib/src/qtlib_config.h similarity index 100% rename from src/lib/qtlib/qtlib_config.h rename to src/lib/qtlib/src/qtlib_config.h diff --git a/src/lib/qtlib/qtlib_dir.cpp b/src/lib/qtlib/src/qtlib_dir.cpp similarity index 100% rename from src/lib/qtlib/qtlib_dir.cpp rename to src/lib/qtlib/src/qtlib_dir.cpp diff --git a/src/lib/qtlib/qtlib_dir.h b/src/lib/qtlib/src/qtlib_dir.h similarity index 100% rename from src/lib/qtlib/qtlib_dir.h rename to src/lib/qtlib/src/qtlib_dir.h diff --git a/src/lib/qtlib/qtlib_file.cpp b/src/lib/qtlib/src/qtlib_file.cpp similarity index 100% rename from src/lib/qtlib/qtlib_file.cpp rename to src/lib/qtlib/src/qtlib_file.cpp diff --git a/src/lib/qtlib/qtlib_file.h b/src/lib/qtlib/src/qtlib_file.h similarity index 100% rename from src/lib/qtlib/qtlib_file.h rename to src/lib/qtlib/src/qtlib_file.h diff --git a/src/lib/qtlib/qtlib_json.cpp b/src/lib/qtlib/src/qtlib_json.cpp similarity index 100% rename from src/lib/qtlib/qtlib_json.cpp rename to src/lib/qtlib/src/qtlib_json.cpp diff --git a/src/lib/qtlib/qtlib_json.h b/src/lib/qtlib/src/qtlib_json.h similarity index 100% rename from src/lib/qtlib/qtlib_json.h rename to src/lib/qtlib/src/qtlib_json.h diff --git a/src/lib/qtlib/qtlib_networkresource.cpp b/src/lib/qtlib/src/qtlib_networkresource.cpp similarity index 100% rename from src/lib/qtlib/qtlib_networkresource.cpp rename to src/lib/qtlib/src/qtlib_networkresource.cpp diff --git a/src/lib/qtlib/qtlib_networkresource.h b/src/lib/qtlib/src/qtlib_networkresource.h similarity index 100% rename from src/lib/qtlib/qtlib_networkresource.h rename to src/lib/qtlib/src/qtlib_networkresource.h diff --git a/src/lib/qtlib/qtlib_ocsapi.cpp b/src/lib/qtlib/src/qtlib_ocsapi.cpp similarity index 100% rename from src/lib/qtlib/qtlib_ocsapi.cpp rename to src/lib/qtlib/src/qtlib_ocsapi.cpp diff --git a/src/lib/qtlib/qtlib_ocsapi.h b/src/lib/qtlib/src/qtlib_ocsapi.h similarity index 100% rename from src/lib/qtlib/qtlib_ocsapi.h rename to src/lib/qtlib/src/qtlib_ocsapi.h diff --git a/src/lib/qtlib/qtlib_package.cpp b/src/lib/qtlib/src/qtlib_package.cpp similarity index 95% rename from src/lib/qtlib/qtlib_package.cpp rename to src/lib/qtlib/src/qtlib_package.cpp index c3541c42e5b08bb9719b9850f4808a548cb3b639..570d69f93aee8d3bfd6725f06112b652b5dd20c1 100644 --- a/src/lib/qtlib/qtlib_package.cpp +++ b/src/lib/qtlib/src/qtlib_package.cpp @@ -132,6 +132,13 @@ bool Package::uninstallAsPlasmapkg(const QString &type) #ifdef Q_OS_ANDROID bool Package::installAsApk() { + /* + String apkFile = "/path/to/package.apk"; + Intent intent = new Intent(Intent.ACTION_VIEW); + intent.setDataAndType(Uri.fromFile(new File(apkFile)), "application/vnd.android.package-archive"); + startActivity(intent); + */ + QAndroidJniObject activity = QAndroidJniObject::callStaticObjectMethod("org/qtproject/qt5/android/QtNative", "activity", "()Landroid/app/Activity;"); if (activity.isValid()) { QAndroidJniObject fileUri = QAndroidJniObject::fromString(path()); diff --git a/src/lib/qtlib/qtlib_package.h b/src/lib/qtlib/src/qtlib_package.h similarity index 100% rename from src/lib/qtlib/qtlib_package.h rename to src/lib/qtlib/src/qtlib_package.h diff --git a/src/lib/qtlib/test/main.cpp b/src/lib/qtlib/test/main.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c43cf3da08a8038723a9a53df285cf95839ee5f8 --- /dev/null +++ b/src/lib/qtlib/test/main.cpp @@ -0,0 +1,58 @@ +#include <QObject> +#include <QCoreApplication> +#include <QDebug> + +#include "qtlib_file.h" +#include "qtlib_dir.h" +#include "qtlib_json.h" +#include "qtlib_config.h" +#include "qtlib_networkresource.h" +#include "qtlib_ocsapi.h" +#include "qtlib_package.h" + +class Test : public QObject +{ +public: + Test() {} + virtual ~Test() {} + + void start() { + qDebug() << "Start"; + + qtlib::NetworkResource *resource = new qtlib::NetworkResource( + "LGPL-3.0", + QUrl("https://api.opensource.org/license/LGPL-3.0"), + false, + this); + QJsonObject result = qtlib::Json(resource->get()->readData()).toObject(); + + qDebug() << resource->id() << ":" << result["name"].toString(); + + resource->setUrl(QUrl(result["text"].toArray()[0].toObject()["url"].toString())); + resource->setAsync(true); + connect(resource, &qtlib::NetworkResource::finished, this, &Test::finished); + resource->get(); + } + +public slots: + void finished(qtlib::NetworkResource *resource) { + QString path = qtlib::Dir::tempPath() + "/" + resource->url().fileName(); + resource->saveData(path); + resource->deleteLater(); + + qDebug() << "Downloaded" << resource->id() << ":" << path; + qDebug() << "Finished"; + + QCoreApplication::exit(); + } +}; + +int main(int argc, char *argv[]) +{ + QCoreApplication app(argc, argv); + + Test test; + test.start(); + + return app.exec(); +}