0.2
This commit is contained in:
parent
6db8aa36ee
commit
42d8cb6d1a
3 changed files with 155 additions and 108 deletions
104
mainwindow.cpp
104
mainwindow.cpp
|
@ -6,6 +6,11 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
, ui(new Ui::MainWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
QTimer *timer = new QTimer(this);
|
||||
timer->setInterval(1000);
|
||||
connect(timer,&QTimer::timeout,this,&MainWindow::holen_status);
|
||||
timer->start();
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
|
@ -13,60 +18,93 @@ 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::holen_status(){
|
||||
//Autoplay
|
||||
befehl=befehl_getauto;
|
||||
sende_befehl();
|
||||
if(status=="0"){
|
||||
status_auto="aus";
|
||||
}else{
|
||||
status_auto="an";
|
||||
}
|
||||
//Player1
|
||||
befehl=befehl_playstate1;
|
||||
sende_befehl();
|
||||
if(status=="0"){
|
||||
status_player1="aus";
|
||||
}else if(status=="1"){
|
||||
status_player1="play";
|
||||
}else if(status=="2"){
|
||||
status_player1="pause";
|
||||
}
|
||||
//Player2
|
||||
befehl=befehl_playstate2;
|
||||
sende_befehl();
|
||||
if(status=="0"){
|
||||
status_player2="aus";
|
||||
}else if(status=="1"){
|
||||
status_player2="play";
|
||||
}else if(status=="2"){
|
||||
status_player2="pause";
|
||||
}
|
||||
//Anzeige
|
||||
if(status_player1=="play") ui->checkBox_player1->setChecked(1); else ui->checkBox_player1->setChecked(0);
|
||||
if(status_auto=="an") ui->checkBox_auto->setChecked(1); else ui->checkBox_auto->setChecked(0);
|
||||
if(status_player2=="play") ui->checkBox_player2->setChecked(1); else ui->checkBox_player2->setChecked(0);
|
||||
//Playlist
|
||||
befehl=befehl_file;
|
||||
sende_befehl();
|
||||
ui->lineEdit_titel->setText((status.split("<br>")[0]));
|
||||
}
|
||||
|
||||
void MainWindow::sende_befehl(QString befehl){
|
||||
bool MainWindow::sende_befehl(){
|
||||
ausgabe=url + befehl;
|
||||
|
||||
manager = new QNetworkAccessManager(this);
|
||||
QNetworkRequest request(ausgabe);
|
||||
QNetworkReply *reply = manager->get(request);
|
||||
QEventLoop event_loop;
|
||||
QObject::connect(reply, SIGNAL(finished()), &event_loop, SLOT(quit()));
|
||||
event_loop.exec();
|
||||
|
||||
connect(reply, &QNetworkReply::finished, [=]() {
|
||||
if(reply->error() == QNetworkReply::NoError){
|
||||
QByteArray response = reply->readAll();
|
||||
ui->textBrowser_ausgabe->insertPlainText(response+"\n");
|
||||
ui->statusbar->showMessage("Ok.");
|
||||
status = response;
|
||||
return 1;
|
||||
}else{ // handle error
|
||||
ui->textBrowser_ausgabe->insertPlainText(reply->errorString()+"\n");
|
||||
ui->statusbar->showMessage("Fehler.");
|
||||
ui->statusbar->showMessage(reply->errorString());
|
||||
status = reply->errorString();
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void MainWindow::on_pushButton_pause_clicked(){
|
||||
befehl=pause1;
|
||||
textBrowser_ausgabe(befehl);
|
||||
sende_befehl(befehl);
|
||||
if(status_player1=="play"){
|
||||
befehl=befehl_pause1;
|
||||
sende_befehl();
|
||||
|
||||
befehl=pause2;
|
||||
textBrowser_ausgabe(befehl);
|
||||
sende_befehl(befehl);
|
||||
}else if(status_player2=="play"){
|
||||
befehl=befehl_pause2;
|
||||
sende_befehl();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_pushButton_play_clicked(){
|
||||
befehl=play1;
|
||||
textBrowser_ausgabe(befehl);
|
||||
sende_befehl(befehl);
|
||||
|
||||
befehl=pause2;
|
||||
textBrowser_ausgabe(befehl);
|
||||
sende_befehl(befehl);
|
||||
if(!(status_player1=="play") || !(status_player2=="play")){
|
||||
if(status_player1=="aus" || status_player1=="pause"){
|
||||
befehl=befehl_play1;
|
||||
sende_befehl();
|
||||
}else if(status_player2=="aus" || status_player2=="pause"){
|
||||
befehl=befehl_play2;
|
||||
sende_befehl();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_pushButton_fade_clicked(){
|
||||
befehl=fade;
|
||||
textBrowser_ausgabe(befehl);
|
||||
sende_befehl(befehl);
|
||||
if(status_player1=="play" || status_player2=="play"){
|
||||
befehl=befehl_fade;
|
||||
sende_befehl();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_textBrowser_ausgabe_selectionChanged(){
|
||||
befehl=getfile;
|
||||
textBrowser_ausgabe(befehl);
|
||||
sende_befehl(befehl);
|
||||
}
|
||||
|
||||
|
|
28
mainwindow.h
28
mainwindow.h
|
@ -7,6 +7,8 @@
|
|||
#include <QtNetwork/QNetworkRequest>
|
||||
#include <QtNetwork/QNetworkReply>
|
||||
#include <QPalette>
|
||||
#include <QTimer>
|
||||
#include <QThread>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui { class MainWindow; }
|
||||
|
@ -23,16 +25,13 @@ public:
|
|||
private slots:
|
||||
void on_pushButton_pause_clicked();
|
||||
void on_pushButton_play_clicked();
|
||||
|
||||
void on_pushButton_fade_clicked();
|
||||
|
||||
void on_textBrowser_ausgabe_selectionChanged();
|
||||
void holen_status();
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
|
||||
void textBrowser_ausgabe(QString);
|
||||
void sende_befehl(QString);
|
||||
bool sende_befehl();
|
||||
|
||||
QNetworkAccessManager *manager;
|
||||
|
||||
|
@ -40,11 +39,20 @@ private:
|
|||
QString port="80";
|
||||
QString url="http://" + ip + ":" + port + "/";
|
||||
QString ausgabe;
|
||||
QString status;
|
||||
QString status_player1;
|
||||
QString status_player2;
|
||||
QString status_auto;
|
||||
QString befehl;
|
||||
QString pause1="PAUSE1";
|
||||
QString pause2="PAUSE2";
|
||||
QString play1="PLAY1";
|
||||
QString fade="FADENOW";
|
||||
QString getfile="LIST_GETFILE";
|
||||
QString befehl_getauto="getauto";
|
||||
QString befehl_setauto="setauto1";
|
||||
QString befehl_playstate1="getplaystate1";
|
||||
QString befehl_playstate2="getplaystate2";
|
||||
QString befehl_pause1="pause1";
|
||||
QString befehl_pause2="pause2";
|
||||
QString befehl_play1="play1";
|
||||
QString befehl_play2="play2";
|
||||
QString befehl_fade="fadenow";
|
||||
QString befehl_file="list_getfile";
|
||||
};
|
||||
#endif // MAINWINDOW_H
|
||||
|
|
|
@ -7,32 +7,19 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>302</width>
|
||||
<height>157</height>
|
||||
<height>115</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>BPM-Studio-Net-Client</string>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background-color: rgb(119, 119, 119);</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>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<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>
|
||||
|
@ -40,15 +27,9 @@
|
|||
<string>Pause</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<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>
|
||||
|
@ -56,15 +37,9 @@
|
|||
<string>Play</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<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>
|
||||
|
@ -72,6 +47,32 @@
|
|||
<string>Fade</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="checkBox_player1">
|
||||
<property name="text">
|
||||
<string>Player 1</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QCheckBox" name="checkBox_auto">
|
||||
<property name="text">
|
||||
<string>Auto</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QCheckBox" name="checkBox_player2">
|
||||
<property name="text">
|
||||
<string>Player 2</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="3">
|
||||
<widget class="QLineEdit" name="lineEdit_titel"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
|
|
Loading…
Add table
Reference in a new issue