diff --git a/BPM-Studio-Net-Client.pro b/BPM-Studio-Net-Client.pro new file mode 100644 index 0000000..fbc8d5a --- /dev/null +++ b/BPM-Studio-Net-Client.pro @@ -0,0 +1,24 @@ +QT += core gui network + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +CONFIG += c++17 + +# You can make your code fail to compile if it uses deprecated APIs. +# In order to do so, uncomment the following line. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + +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/main.cpp b/main.cpp new file mode 100644 index 0000000..fd3e533 --- /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..64095ab --- /dev/null +++ b/mainwindow.cpp @@ -0,0 +1,72 @@ +#include "mainwindow.h" +#include "ui_mainwindow.h" + +MainWindow::MainWindow(QWidget *parent) + : QMainWindow(parent) + , ui(new Ui::MainWindow) +{ + ui->setupUi(this); +} + +MainWindow::~MainWindow() +{ + delete ui; +} + +void MainWindow::textBrowser_ausgabe(QString befehl){ + ausgabe=url + befehl + "\n"; + ui->textBrowser_ausgabe->clear(); + ui->textBrowser_ausgabe->insertPlainText(ausgabe); +} + +void MainWindow::sende_befehl(QString befehl){ + ausgabe=url + befehl; + + manager = new QNetworkAccessManager(this); + QNetworkRequest request(ausgabe); + QNetworkReply *reply = manager->get(request); + + connect(reply, &QNetworkReply::finished, [=]() { + if(reply->error() == QNetworkReply::NoError){ + QByteArray response = reply->readAll(); + ui->textBrowser_ausgabe->insertPlainText(response+"\n"); + ui->statusbar->showMessage("Ok."); + }else{ // handle error + ui->textBrowser_ausgabe->insertPlainText(reply->errorString()+"\n"); + ui->statusbar->showMessage("Fehler."); + } + }); +} + +void MainWindow::on_pushButton_pause_clicked(){ + befehl=pause1; + textBrowser_ausgabe(befehl); + sende_befehl(befehl); + + befehl=pause2; + textBrowser_ausgabe(befehl); + sende_befehl(befehl); +} + +void MainWindow::on_pushButton_play_clicked(){ + befehl=play1; + textBrowser_ausgabe(befehl); + sende_befehl(befehl); + + befehl=pause2; + textBrowser_ausgabe(befehl); + sende_befehl(befehl); +} + +void MainWindow::on_pushButton_fade_clicked(){ + befehl=fade; + textBrowser_ausgabe(befehl); + sende_befehl(befehl); +} + +void MainWindow::on_textBrowser_ausgabe_selectionChanged(){ + befehl=getfile; + textBrowser_ausgabe(befehl); + sende_befehl(befehl); +} + diff --git a/mainwindow.h b/mainwindow.h new file mode 100644 index 0000000..60e7984 --- /dev/null +++ b/mainwindow.h @@ -0,0 +1,50 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE +namespace Ui { class MainWindow; } +QT_END_NAMESPACE + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + MainWindow(QWidget *parent = nullptr); + ~MainWindow(); + +private slots: + void on_pushButton_pause_clicked(); + void on_pushButton_play_clicked(); + + void on_pushButton_fade_clicked(); + + void on_textBrowser_ausgabe_selectionChanged(); + +private: + Ui::MainWindow *ui; + + void textBrowser_ausgabe(QString); + void sende_befehl(QString); + + QNetworkAccessManager *manager; + + QString ip="192.168.100.7"; + QString port="80"; + QString url="http://" + ip + ":" + port + "/"; + QString ausgabe; + QString befehl; + QString pause1="PAUSE1"; + QString pause2="PAUSE2"; + QString play1="PLAY1"; + QString fade="FADENOW"; + QString getfile="LIST_GETFILE"; +}; +#endif // MAINWINDOW_H diff --git a/mainwindow.ui b/mainwindow.ui new file mode 100644 index 0000000..84a8698 --- /dev/null +++ b/mainwindow.ui @@ -0,0 +1,90 @@ + + + MainWindow + + + + 0 + 0 + 302 + 157 + + + + BPM-Studio-Net-Client + + + + + + 10 + 40 + 281 + 71 + + + + + + + 10 + 10 + 80 + 24 + + + + background-color: rgb(255, 0, 0); + + + Pause + + + + + + 110 + 10 + 80 + 24 + + + + background-color: rgb(0, 255, 0); + + + Play + + + + + + 210 + 10 + 80 + 24 + + + + background-color: rgb(255, 255, 0); + + + Fade + + + + + + + 0 + 0 + 302 + 21 + + + + + + + +