Merge v0.6.0 and v0.6.1 #29
10 changed files with 120 additions and 53 deletions
|
@ -89,4 +89,5 @@
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="29"/>
|
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="29"/>
|
||||||
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||||
</manifest>
|
</manifest>
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
<paths xmlns:android="http://schemas.android.com/apk/res/android">
|
<paths xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<files-path name="my_shared_files" path="share_example_x_files/" />
|
<files-path name="temporaryFiles" path="temporaryFiles/" />
|
||||||
</paths>
|
</paths>
|
||||||
|
|
|
@ -16,6 +16,7 @@ public:
|
||||||
AndroidShareUtils(QObject* parent = nullptr);
|
AndroidShareUtils(QObject* parent = nullptr);
|
||||||
bool checkMimeTypeView(const QString &mimeType) override;
|
bool checkMimeTypeView(const QString &mimeType) override;
|
||||||
bool checkMimeTypeEdit(const QString &mimeType) override;
|
bool checkMimeTypeEdit(const QString &mimeType) override;
|
||||||
|
virtual QString getTemporaryFileLocationPath() override;
|
||||||
void shareText(const QString &text) override;
|
void shareText(const QString &text) override;
|
||||||
void sendFile(const QString &filePath, const QString &title, const QString &mimeType, const int &requestId) override;
|
void sendFile(const QString &filePath, const QString &title, const QString &mimeType, const int &requestId) override;
|
||||||
void viewFile(const QString &filePath, const QString &title, const QString &mimeType, const int &requestId) override;
|
void viewFile(const QString &filePath, const QString &title, const QString &mimeType, const int &requestId) override;
|
||||||
|
|
|
@ -18,6 +18,9 @@
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QStandardPaths>
|
||||||
|
#include <QDesktopServices>
|
||||||
|
#include <QUrl>
|
||||||
|
|
||||||
class PlatformShareUtils : public QObject
|
class PlatformShareUtils : public QObject
|
||||||
{
|
{
|
||||||
|
@ -35,6 +38,7 @@ public:
|
||||||
virtual ~PlatformShareUtils();
|
virtual ~PlatformShareUtils();
|
||||||
virtual bool checkMimeTypeView(const QString &mimeType);
|
virtual bool checkMimeTypeView(const QString &mimeType);
|
||||||
virtual bool checkMimeTypeEdit(const QString &mimeType);
|
virtual bool checkMimeTypeEdit(const QString &mimeType);
|
||||||
|
virtual QString getTemporaryFileLocationPath();
|
||||||
virtual void shareText(const QString &text);
|
virtual void shareText(const QString &text);
|
||||||
virtual void sendFile(const QString &filePath, const QString &title, const QString &mimeType, const int &requestId);
|
virtual void sendFile(const QString &filePath, const QString &title, const QString &mimeType, const int &requestId);
|
||||||
virtual void viewFile(const QString &filePath, const QString &title, const QString &mimeType, const int &requestId);
|
virtual void viewFile(const QString &filePath, const QString &title, const QString &mimeType, const int &requestId);
|
||||||
|
|
|
@ -46,6 +46,7 @@ public:
|
||||||
explicit ShareUtils(QObject *parent = 0);
|
explicit ShareUtils(QObject *parent = 0);
|
||||||
Q_INVOKABLE bool checkMimeTypeView(const QString &mimeType);
|
Q_INVOKABLE bool checkMimeTypeView(const QString &mimeType);
|
||||||
Q_INVOKABLE bool checkMimeTypeEdit(const QString &mimeType);
|
Q_INVOKABLE bool checkMimeTypeEdit(const QString &mimeType);
|
||||||
|
Q_INVOKABLE QString getTemporaryFileLocationPath();
|
||||||
Q_INVOKABLE void shareText(const QString &text);
|
Q_INVOKABLE void shareText(const QString &text);
|
||||||
Q_INVOKABLE void sendFile(const QString &filePath, const QString &title, const QString &mimeType, const int &requestId);
|
Q_INVOKABLE void sendFile(const QString &filePath, const QString &title, const QString &mimeType, const int &requestId);
|
||||||
Q_INVOKABLE void viewFile(const QString &filePath, const QString &title, const QString &mimeType, const int &requestId);
|
Q_INVOKABLE void viewFile(const QString &filePath, const QString &title, const QString &mimeType, const int &requestId);
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
import QtQuick 2.0
|
import QtQuick 2.12
|
||||||
import QtQuick.Controls 2.12
|
import QtQuick.Controls 2.12
|
||||||
import QtQuick.Layouts 1.12
|
import QtQuick.Layouts 1.12
|
||||||
import QZXing 3.1
|
import QZXing 3.1
|
||||||
|
import QtGraphicalEffects 1.0
|
||||||
|
|
||||||
Dialog {
|
Dialog {
|
||||||
id: control
|
id: control
|
||||||
|
@ -31,56 +32,83 @@ Dialog {
|
||||||
Component {
|
Component {
|
||||||
id: shareComponent
|
id: shareComponent
|
||||||
StackLayout {
|
StackLayout {
|
||||||
id: stackLayout
|
id: stackLayout
|
||||||
currentIndex: 0
|
currentIndex: 0
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
id: menuRow
|
id: menuRow
|
||||||
Repeater {
|
Repeater {
|
||||||
id: buttonRepeater
|
id: buttonRepeater
|
||||||
property var buttons: [
|
property var buttons: [
|
||||||
["\uf0c1", "Link", serverConn.shareResultsAsUrl],
|
["\uf0c1", "Link", serverConn.shareResultsAsUrl],
|
||||||
["\uf029", "QR-code", function() {
|
["\uf029", "QR-code", function() {
|
||||||
stackLayout.currentIndex = 1
|
stackLayout.currentIndex = 1
|
||||||
}
|
|
||||||
],
|
|
||||||
["\uf1c1", "Poster", serverConn.shareResultsAsPoster],
|
|
||||||
]
|
|
||||||
|
|
||||||
model: buttons
|
|
||||||
|
|
||||||
delegate: Button {
|
|
||||||
flat: true
|
|
||||||
font.family: fa5solid.name
|
|
||||||
text: "<font size=\"+4\">" + modelData[0] + "</font><br><br> " + modelData[1] + " "
|
|
||||||
onClicked: buttonRepeater.buttons[index][2](_shareUrl, _compName)
|
|
||||||
}
|
}
|
||||||
}
|
],
|
||||||
}
|
["\uf1c1", "Poster", serverConn.shareResultsAsPoster],
|
||||||
|
]
|
||||||
|
|
||||||
|
model: buttons
|
||||||
|
|
||||||
Image {
|
delegate: Button {
|
||||||
id: qrCodeImage
|
flat: true
|
||||||
|
font.family: fa5solid.name
|
||||||
property int size: stackLayout.currentIndex === 1 ? (app.landscape() ? app.height * 0.8 : app.width * 0.8):menuRow.height
|
text: "<font size=\"+4\">" + modelData[0] + "</font><br><br> " + modelData[1] + " "
|
||||||
|
onClicked: buttonRepeater.buttons[index][2](_shareUrl, _compName)
|
||||||
Layout.preferredHeight: size
|
|
||||||
Layout.preferredWidth: size
|
|
||||||
|
|
||||||
sourceSize.width: size
|
|
||||||
sourceSize.height: size
|
|
||||||
|
|
||||||
fillMode: Image.PreserveAspectFit
|
|
||||||
|
|
||||||
source: "image://QZXing/encode/" + _shareUrl + "?border=true&correctionLevel=H"
|
|
||||||
|
|
||||||
Behavior on size {
|
|
||||||
NumberAnimation {
|
|
||||||
duration: 200
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Image {
|
||||||
|
id: qrCodeImage
|
||||||
|
|
||||||
|
property int finalSize: app.landscape() ? app.height * 0.8 : app.width * 0.8
|
||||||
|
property int size: stackLayout.currentIndex === 1 ? finalSize:menuRow.height
|
||||||
|
|
||||||
|
Layout.preferredHeight: size
|
||||||
|
Layout.preferredWidth: size
|
||||||
|
|
||||||
|
sourceSize.width: finalSize
|
||||||
|
sourceSize.height: finalSize
|
||||||
|
|
||||||
|
fillMode: Image.PreserveAspectFit
|
||||||
|
|
||||||
|
source: "image://QZXing/encode/" + _shareUrl + "?border=true&correctionLevel=H"
|
||||||
|
|
||||||
|
RectangularGlow {
|
||||||
|
id: effect
|
||||||
|
anchors.fill: blurRockLogoBackgroundRect
|
||||||
|
glowRadius: 0
|
||||||
|
spread: 0
|
||||||
|
opacity: 0.8
|
||||||
|
color: "black"
|
||||||
|
cornerRadius: blurRockLogoBackgroundRect.radius
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
id: blurRockLogoBackgroundRect
|
||||||
|
anchors.centerIn: parent
|
||||||
|
width: parent.width * 0.25
|
||||||
|
height: width
|
||||||
|
radius: height * 0.2
|
||||||
|
color: "white"
|
||||||
|
Image {
|
||||||
|
anchors.centerIn: parent
|
||||||
|
width: parent.width * 0.8
|
||||||
|
height: width
|
||||||
|
mipmap: true
|
||||||
|
source: "qrc:/icons/blueRockHold.png"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Behavior on size {
|
||||||
|
NumberAnimation {
|
||||||
|
duration: 200
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function appear(shareUrl, compName) {
|
function appear(shareUrl, compName) {
|
||||||
|
|
|
@ -97,9 +97,26 @@ void BlueRockBackend::shareResultsAsUrl(QString url, QString compName) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlueRockBackend::shareResultsAsPoster(QString url, QString compName) {
|
void BlueRockBackend::shareResultsAsPoster(QString url, QString compName) {
|
||||||
QString path = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation);
|
QString path = this->_shareUtils->getTemporaryFileLocationPath(); //QStandardPaths::writableLocation(QStandardPaths::DownloadLocation);
|
||||||
|
if (!QDir(path).exists()) {
|
||||||
|
if (QDir("").mkpath(path)) {
|
||||||
|
qDebug() << "Created app data /files directory. " << path;
|
||||||
|
} else {
|
||||||
|
qWarning() << "Failed to create app data /files directory. " << path;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
path += "/" + compName + ".pdf";
|
path += "/" + compName + ".pdf";
|
||||||
QPdfWriter writer(path);
|
|
||||||
|
QFile file(path);
|
||||||
|
file.remove();
|
||||||
|
if(!file.open(QIODevice::ReadWrite)) {
|
||||||
|
qWarning("Could not open File for writing!!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QPdfWriter writer(&file);
|
||||||
writer.setPageSize(QPageSize(QPageSize::A4));
|
writer.setPageSize(QPageSize(QPageSize::A4));
|
||||||
writer.setPageMargins(QMargins(0, 0, 0, 0));
|
writer.setPageMargins(QMargins(0, 0, 0, 0));
|
||||||
writer.setResolution(600);
|
writer.setResolution(600);
|
||||||
|
@ -115,9 +132,9 @@ void BlueRockBackend::shareResultsAsPoster(QString url, QString compName) {
|
||||||
painter.drawPixmap((writer.width() - size) / 2, size * 0.5, size, size, barcode);
|
painter.drawPixmap((writer.width() - size) / 2, size * 0.5, size, size, barcode);
|
||||||
|
|
||||||
painter.end();
|
painter.end();
|
||||||
|
file.close();
|
||||||
|
|
||||||
int requestId;
|
this->_shareUtils->sendFile(path, compName, "application/pdf", 1);
|
||||||
this->_shareUtils->sendFile(path, compName, "application/pdf", requestId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------
|
// ------------------------
|
||||||
|
|
|
@ -54,6 +54,10 @@ bool AndroidShareUtils::checkMimeTypeEdit(const QString &mimeType)
|
||||||
return verified;
|
return verified;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString AndroidShareUtils::getTemporaryFileLocationPath() {
|
||||||
|
return QStandardPaths::standardLocations(QStandardPaths::AppDataLocation).value(0) + "/temporaryFiles";
|
||||||
|
}
|
||||||
|
|
||||||
void AndroidShareUtils::shareText(const QString &text)
|
void AndroidShareUtils::shareText(const QString &text)
|
||||||
{
|
{
|
||||||
QAndroidJniObject jsText = QAndroidJniObject::fromString(text);
|
QAndroidJniObject jsText = QAndroidJniObject::fromString(text);
|
||||||
|
@ -296,7 +300,7 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
JNIEXPORT void JNICALL
|
JNIEXPORT void JNICALL
|
||||||
Java_org_ekkescorner_examples_sharex_QShareActivity_setFileUrlReceived(JNIEnv *env,
|
Java_de_itsblue_blueROCK_MainActivity_setFileUrlReceived(JNIEnv *env,
|
||||||
jobject obj,
|
jobject obj,
|
||||||
jstring url)
|
jstring url)
|
||||||
{
|
{
|
||||||
|
@ -308,7 +312,7 @@ Java_org_ekkescorner_examples_sharex_QShareActivity_setFileUrlReceived(JNIEnv *e
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL
|
JNIEXPORT void JNICALL
|
||||||
Java_org_ekkescorner_examples_sharex_QShareActivity_setFileReceivedAndSaved(JNIEnv *env,
|
Java_de_itsblue_blueROCK_MainActivity_setFileReceivedAndSaved(JNIEnv *env,
|
||||||
jobject obj,
|
jobject obj,
|
||||||
jstring url)
|
jstring url)
|
||||||
{
|
{
|
||||||
|
@ -320,7 +324,7 @@ Java_org_ekkescorner_examples_sharex_QShareActivity_setFileReceivedAndSaved(JNIE
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT bool JNICALL
|
JNIEXPORT bool JNICALL
|
||||||
Java_org_ekkescorner_examples_sharex_QShareActivity_checkFileExits(JNIEnv *env,
|
Java_de_itsblue_blueROCK_MainActivity_checkFileExits(JNIEnv *env,
|
||||||
jobject obj,
|
jobject obj,
|
||||||
jstring url)
|
jstring url)
|
||||||
{
|
{
|
||||||
|
@ -332,7 +336,7 @@ Java_org_ekkescorner_examples_sharex_QShareActivity_checkFileExits(JNIEnv *env,
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL
|
JNIEXPORT void JNICALL
|
||||||
Java_org_ekkescorner_examples_sharex_QShareActivity_fireActivityResult(JNIEnv *env,
|
Java_de_itsblue_blueROCK_MainActivity_fireActivityResult(JNIEnv *env,
|
||||||
jobject obj,
|
jobject obj,
|
||||||
jint requestCode,
|
jint requestCode,
|
||||||
jint resultCode)
|
jint resultCode)
|
||||||
|
|
|
@ -17,17 +17,23 @@ bool PlatformShareUtils::checkMimeTypeEdit(const QString &mimeType) {
|
||||||
qDebug() << "check edit for " << mimeType;
|
qDebug() << "check edit for " << mimeType;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
QString PlatformShareUtils::getTemporaryFileLocationPath() {
|
||||||
|
return QStandardPaths::writableLocation(QStandardPaths::DownloadLocation);
|
||||||
|
}
|
||||||
void PlatformShareUtils::shareText(const QString &text) {
|
void PlatformShareUtils::shareText(const QString &text) {
|
||||||
qDebug() << text;
|
qDebug() << text;
|
||||||
}
|
}
|
||||||
void PlatformShareUtils::sendFile(const QString &filePath, const QString &title, const QString &mimeType, const int &requestId) {
|
void PlatformShareUtils::sendFile(const QString &filePath, const QString &title, const QString &mimeType, const int &requestId) {
|
||||||
qDebug() << filePath << " - " << title << "requestId " << requestId << " - " << mimeType << "altImpl? ";
|
qDebug() << filePath << " - " << title << "requestId " << requestId << " - " << mimeType << "altImpl? ";
|
||||||
|
QDesktopServices::openUrl(QUrl::fromLocalFile(filePath));
|
||||||
}
|
}
|
||||||
void PlatformShareUtils::viewFile(const QString &filePath, const QString &title, const QString &mimeType, const int &requestId) {
|
void PlatformShareUtils::viewFile(const QString &filePath, const QString &title, const QString &mimeType, const int &requestId) {
|
||||||
qDebug() << filePath << " - " << title << " requestId: " << requestId << " - " << mimeType << "altImpl? ";
|
qDebug() << filePath << " - " << title << " requestId: " << requestId << " - " << mimeType << "altImpl? ";
|
||||||
|
QDesktopServices::openUrl(QUrl::fromLocalFile(filePath));
|
||||||
}
|
}
|
||||||
void PlatformShareUtils::editFile(const QString &filePath, const QString &title, const QString &mimeType, const int &requestId) {
|
void PlatformShareUtils::editFile(const QString &filePath, const QString &title, const QString &mimeType, const int &requestId) {
|
||||||
qDebug() << filePath << " - " << title << " requestId: " << requestId << " - " << mimeType << "altImpl? ";
|
qDebug() << filePath << " - " << title << " requestId: " << requestId << " - " << mimeType << "altImpl? ";
|
||||||
|
QDesktopServices::openUrl(QUrl::fromLocalFile(filePath));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlatformShareUtils::checkPendingIntents(const QString workingDirPath) {
|
void PlatformShareUtils::checkPendingIntents(const QString workingDirPath) {
|
||||||
|
|
|
@ -54,6 +54,11 @@ bool ShareUtils::checkMimeTypeEdit(const QString &mimeType)
|
||||||
return mPlatformShareUtils->checkMimeTypeEdit(mimeType);
|
return mPlatformShareUtils->checkMimeTypeEdit(mimeType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString ShareUtils::getTemporaryFileLocationPath()
|
||||||
|
{
|
||||||
|
return mPlatformShareUtils->getTemporaryFileLocationPath();
|
||||||
|
}
|
||||||
|
|
||||||
void ShareUtils::shareText(const QString &text)
|
void ShareUtils::shareText(const QString &text)
|
||||||
{
|
{
|
||||||
mPlatformShareUtils->shareText(text);
|
mPlatformShareUtils->shareText(text);
|
||||||
|
|
Loading…
Reference in a new issue