Merge v0.6.0 and v0.6.1 #29
10 changed files with 120 additions and 53 deletions
|
@ -89,4 +89,5 @@
|
|||
</application>
|
||||
|
||||
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="29"/>
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||
</manifest>
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
<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>
|
||||
|
|
|
@ -16,6 +16,7 @@ public:
|
|||
AndroidShareUtils(QObject* parent = nullptr);
|
||||
bool checkMimeTypeView(const QString &mimeType) override;
|
||||
bool checkMimeTypeEdit(const QString &mimeType) override;
|
||||
virtual QString getTemporaryFileLocationPath() override;
|
||||
void shareText(const QString &text) 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;
|
||||
|
|
|
@ -18,6 +18,9 @@
|
|||
|
||||
#include <QObject>
|
||||
#include <QDebug>
|
||||
#include <QStandardPaths>
|
||||
#include <QDesktopServices>
|
||||
#include <QUrl>
|
||||
|
||||
class PlatformShareUtils : public QObject
|
||||
{
|
||||
|
@ -35,6 +38,7 @@ public:
|
|||
virtual ~PlatformShareUtils();
|
||||
virtual bool checkMimeTypeView(const QString &mimeType);
|
||||
virtual bool checkMimeTypeEdit(const QString &mimeType);
|
||||
virtual QString getTemporaryFileLocationPath();
|
||||
virtual void shareText(const QString &text);
|
||||
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);
|
||||
|
|
|
@ -46,6 +46,7 @@ public:
|
|||
explicit ShareUtils(QObject *parent = 0);
|
||||
Q_INVOKABLE bool checkMimeTypeView(const QString &mimeType);
|
||||
Q_INVOKABLE bool checkMimeTypeEdit(const QString &mimeType);
|
||||
Q_INVOKABLE QString getTemporaryFileLocationPath();
|
||||
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 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.Layouts 1.12
|
||||
import QZXing 3.1
|
||||
import QtGraphicalEffects 1.0
|
||||
|
||||
Dialog {
|
||||
id: control
|
||||
|
@ -62,18 +63,45 @@ Dialog {
|
|||
Image {
|
||||
id: qrCodeImage
|
||||
|
||||
property int size: stackLayout.currentIndex === 1 ? (app.landscape() ? app.height * 0.8 : app.width * 0.8):menuRow.height
|
||||
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: size
|
||||
sourceSize.height: 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
|
||||
|
|
|
@ -97,9 +97,26 @@ void BlueRockBackend::shareResultsAsUrl(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";
|
||||
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.setPageMargins(QMargins(0, 0, 0, 0));
|
||||
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.end();
|
||||
file.close();
|
||||
|
||||
int requestId;
|
||||
this->_shareUtils->sendFile(path, compName, "application/pdf", requestId);
|
||||
this->_shareUtils->sendFile(path, compName, "application/pdf", 1);
|
||||
}
|
||||
|
||||
// ------------------------
|
||||
|
|
|
@ -54,6 +54,10 @@ bool AndroidShareUtils::checkMimeTypeEdit(const QString &mimeType)
|
|||
return verified;
|
||||
}
|
||||
|
||||
QString AndroidShareUtils::getTemporaryFileLocationPath() {
|
||||
return QStandardPaths::standardLocations(QStandardPaths::AppDataLocation).value(0) + "/temporaryFiles";
|
||||
}
|
||||
|
||||
void AndroidShareUtils::shareText(const QString &text)
|
||||
{
|
||||
QAndroidJniObject jsText = QAndroidJniObject::fromString(text);
|
||||
|
@ -296,7 +300,7 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_ekkescorner_examples_sharex_QShareActivity_setFileUrlReceived(JNIEnv *env,
|
||||
Java_de_itsblue_blueROCK_MainActivity_setFileUrlReceived(JNIEnv *env,
|
||||
jobject obj,
|
||||
jstring url)
|
||||
{
|
||||
|
@ -308,7 +312,7 @@ Java_org_ekkescorner_examples_sharex_QShareActivity_setFileUrlReceived(JNIEnv *e
|
|||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_ekkescorner_examples_sharex_QShareActivity_setFileReceivedAndSaved(JNIEnv *env,
|
||||
Java_de_itsblue_blueROCK_MainActivity_setFileReceivedAndSaved(JNIEnv *env,
|
||||
jobject obj,
|
||||
jstring url)
|
||||
{
|
||||
|
@ -320,7 +324,7 @@ Java_org_ekkescorner_examples_sharex_QShareActivity_setFileReceivedAndSaved(JNIE
|
|||
}
|
||||
|
||||
JNIEXPORT bool JNICALL
|
||||
Java_org_ekkescorner_examples_sharex_QShareActivity_checkFileExits(JNIEnv *env,
|
||||
Java_de_itsblue_blueROCK_MainActivity_checkFileExits(JNIEnv *env,
|
||||
jobject obj,
|
||||
jstring url)
|
||||
{
|
||||
|
@ -332,7 +336,7 @@ Java_org_ekkescorner_examples_sharex_QShareActivity_checkFileExits(JNIEnv *env,
|
|||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_ekkescorner_examples_sharex_QShareActivity_fireActivityResult(JNIEnv *env,
|
||||
Java_de_itsblue_blueROCK_MainActivity_fireActivityResult(JNIEnv *env,
|
||||
jobject obj,
|
||||
jint requestCode,
|
||||
jint resultCode)
|
||||
|
|
|
@ -17,17 +17,23 @@ bool PlatformShareUtils::checkMimeTypeEdit(const QString &mimeType) {
|
|||
qDebug() << "check edit for " << mimeType;
|
||||
return true;
|
||||
}
|
||||
QString PlatformShareUtils::getTemporaryFileLocationPath() {
|
||||
return QStandardPaths::writableLocation(QStandardPaths::DownloadLocation);
|
||||
}
|
||||
void PlatformShareUtils::shareText(const QString &text) {
|
||||
qDebug() << text;
|
||||
}
|
||||
void PlatformShareUtils::sendFile(const QString &filePath, const QString &title, const QString &mimeType, const int &requestId) {
|
||||
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) {
|
||||
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) {
|
||||
qDebug() << filePath << " - " << title << " requestId: " << requestId << " - " << mimeType << "altImpl? ";
|
||||
QDesktopServices::openUrl(QUrl::fromLocalFile(filePath));
|
||||
}
|
||||
|
||||
void PlatformShareUtils::checkPendingIntents(const QString workingDirPath) {
|
||||
|
|
|
@ -54,6 +54,11 @@ bool ShareUtils::checkMimeTypeEdit(const QString &mimeType)
|
|||
return mPlatformShareUtils->checkMimeTypeEdit(mimeType);
|
||||
}
|
||||
|
||||
QString ShareUtils::getTemporaryFileLocationPath()
|
||||
{
|
||||
return mPlatformShareUtils->getTemporaryFileLocationPath();
|
||||
}
|
||||
|
||||
void ShareUtils::shareText(const QString &text)
|
||||
{
|
||||
mPlatformShareUtils->shareText(text);
|
||||
|
|
Loading…
Reference in a new issue