This commit is contained in:
Thomas resiX 2025-02-15 12:16:34 +01:00
parent 0abe797e4c
commit 6db8aa36ee
5 changed files with 247 additions and 0 deletions

24
BPM-Studio-Net-Client.pro Normal file
View file

@ -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

11
main.cpp Normal file
View file

@ -0,0 +1,11 @@
#include "mainwindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}

72
mainwindow.cpp Normal file
View file

@ -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);
}

50
mainwindow.h Normal file
View file

@ -0,0 +1,50 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QString>
#include <QtNetwork/QNetworkAccessManager>
#include <QtNetwork/QNetworkRequest>
#include <QtNetwork/QNetworkReply>
#include <QPalette>
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

90
mainwindow.ui Normal file
View file

@ -0,0 +1,90 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>302</width>
<height>157</height>
</rect>
</property>
<property name="windowTitle">
<string>BPM-Studio-Net-Client</string>
</property>
<widget class="QWidget" name="centralwidget">
<widget class="QTextBrowser" name="textBrowser_ausgabe">
<property name="geometry">
<rect>
<x>10</x>
<y>40</y>
<width>281</width>
<height>71</height>
</rect>
</property>
</widget>
<widget class="QPushButton" name="pushButton_pause">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>80</width>
<height>24</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(255, 0, 0);</string>
</property>
<property name="text">
<string>Pause</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton_play">
<property name="geometry">
<rect>
<x>110</x>
<y>10</y>
<width>80</width>
<height>24</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(0, 255, 0);</string>
</property>
<property name="text">
<string>Play</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton_fade">
<property name="geometry">
<rect>
<x>210</x>
<y>10</y>
<width>80</width>
<height>24</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(255, 255, 0);</string>
</property>
<property name="text">
<string>Fade</string>
</property>
</widget>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>302</width>
<height>21</height>
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<resources/>
<connections/>
</ui>