commit 91988b0bed0f6644955bc6134b7b21b54ac0bd71 Author: Yannik Schmidt Date: Thu Jul 16 21:45:36 2020 +0200 initial diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..b48f94e --- /dev/null +++ b/main.cpp @@ -0,0 +1,11 @@ +#include "mainwindow.h" +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + MainWindow w; + w.show(); + + return a.exec(); +} diff --git a/mainwindow.cpp b/mainwindow.cpp new file mode 100644 index 0000000..1ad7ac0 --- /dev/null +++ b/mainwindow.cpp @@ -0,0 +1,74 @@ +#include "mainwindow.h" +#include "ui_mainwindow.h" +#include +#include +#include +#include +#include +#include +#include + +MainWindow::MainWindow(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::MainWindow) +{ + ui->setupUi(this); + button = ui->centralWidget->findChild("pushButton"); + connect(button, SIGNAL (released()), this, SLOT (importFile())); +} + + +void MainWindow::importFile() +{ + QString filename = QFileDialog::getOpenFileName( + this, + "Open Document", + QDir::currentPath(), + "All files (*.*) ;; Document files (*.doc *.rtf);; PNG files (*.png)"); + if( !filename.isNull() ){ + return; + } +} + +void MainWindow::submitFile(QString filename) +{ + /* prepare auth */ + QString username = "lol"; + QString password = "lol"; + QString concatenated = username + ":" + password; + QByteArray data = concatenated.toLocal8Bit().toBase64(); + QString authHeaderData = "Basic " + data; + + /* prepare request */ + QUrl serviceUrl = QUrl("http://localhost:5000"); + QNetworkRequest request(serviceUrl); + request.setRawHeader("Authorization", authHeaderData.toLocal8Bit()); + request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json"); + + /* read audio as base64 */ + QFile sourceFile(filename); + QByteArray base64Encoded = sourceFile.readAll().toBase64(); + QString dataString = QString::fromUtf8(base64Encoded); + + /* prepare json */ + QJsonObject json = QJsonObject(); + QJsonValue dataFieldContent = QJsonValue(dataString); + + QFileInfo info(filename); + QString basename(info.fileName()); + json["filename"] = filename; + json["data"] = dataFieldContent; + + /* make request */ + QNetworkAccessManager *networkManager = new QNetworkAccessManager(this); + connect(networkManager, SIGNAL(finished(QNetworkReply*)), this, + SLOT(fileSubmissionFinished(QNetworkReply*))); + networkManager->post(request, QJsonDocument(json).toJson()); +} + + + +MainWindow::~MainWindow() +{ + delete ui; +} diff --git a/mainwindow.h b/mainwindow.h new file mode 100644 index 0000000..a474b4b --- /dev/null +++ b/mainwindow.h @@ -0,0 +1,30 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include +#include +#include + +namespace Ui { +class MainWindow; +} + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit MainWindow(QWidget *parent = nullptr); + ~MainWindow(); + +private slots: + void importFile(); + void fileSubmissionFinished(QNetworkReply*); + +private: + Ui::MainWindow *ui; + QPushButton *button; + void submitFile(QString filename); +}; + +#endif // MAINWINDOW_H diff --git a/mainwindow.ui b/mainwindow.ui new file mode 100644 index 0000000..cf58991 --- /dev/null +++ b/mainwindow.ui @@ -0,0 +1,59 @@ + + + MainWindow + + + + 0 + 0 + 519 + 504 + + + + MainWindow + + + + + + + Datei hinzufügen + + + + + + + 24 + + + + + + + + + + + + 0 + 0 + 519 + 20 + + + + + + TopToolBarArea + + + true + + + + + + + diff --git a/untitled.pro b/untitled.pro new file mode 100644 index 0000000..bd9e486 --- /dev/null +++ b/untitled.pro @@ -0,0 +1,40 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2020-07-16T16:18:39 +# +#------------------------------------------------- + +QT += core gui network + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +TARGET = untitled +TEMPLATE = app + +# The following define makes your compiler emit warnings if you use +# any feature of Qt which has been marked as deprecated (the exact warnings +# depend on your compiler). Please consult the documentation of the +# deprecated API in order to know how to port your code away from it. +DEFINES += QT_DEPRECATED_WARNINGS + +# You can also make your code fail to compile if you use deprecated APIs. +# In order to do so, uncomment the following line. +# You can also select to disable deprecated APIs only up to a certain version of Qt. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + +CONFIG += c++11 + +SOURCES += \ + main.cpp \ + mainwindow.cpp + +HEADERS += \ + mainwindow.h + +FORMS += \ + mainwindow.ui + +# Default rules for deployment. +qnx: target.path = /tmp/$${TARGET}/bin +else: unix:!android: target.path = /opt/$${TARGET}/bin +!isEmpty(target.path): INSTALLS += target diff --git a/untitled.pro.user b/untitled.pro.user new file mode 100644 index 0000000..1c73466 --- /dev/null +++ b/untitled.pro.user @@ -0,0 +1,322 @@ + + + + + + EnvironmentId + {39e8c73c-66b3-40fb-add7-3b22c1b231cb} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + true + false + 0 + true + true + 0 + 8 + true + 1 + true + true + true + false + + + + ProjectExplorer.Project.PluginSettings + + + + ProjectExplorer.Project.Target.0 + + Desktop + Desktop + {98c652d7-1dcc-4cb8-bb82-220e38c4e782} + 0 + 0 + 0 + + /home/ik15ydit/qt-projects/build-untitled-Desktop-Debug + + + true + qmake + + QtProjectManager.QMakeBuildStep + true + + false + false + false + + + true + Make + + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Debug + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + true + + + /home/ik15ydit/qt-projects/build-untitled-Desktop-Release + + + true + qmake + + QtProjectManager.QMakeBuildStep + false + + false + false + true + + + true + Make + + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + true + + + /home/ik15ydit/qt-projects/build-untitled-Desktop-Profile + + + true + qmake + + QtProjectManager.QMakeBuildStep + true + + false + true + true + + + true + Make + + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Profile + Profile + Qt4ProjectManager.Qt4BuildConfiguration + 0 + true + + 3 + + + 0 + Deploy + + ProjectExplorer.BuildSteps.Deploy + + 1 + Deploy Configuration + + ProjectExplorer.DefaultDeployConfiguration + + 1 + + + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + + Custom Executable + + ProjectExplorer.CustomExecutableRunConfiguration + + 3768 + false + true + false + false + true + + + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.FileVersion + 20 + + + Version + 20 + +