diff --git a/main.cpp b/main.cpp index b48f94e..b902f6f 100644 --- a/main.cpp +++ b/main.cpp @@ -1,6 +1,8 @@ #include "mainwindow.h" #include +using namespace yremote; + int main(int argc, char *argv[]) { QApplication a(argc, argv); diff --git a/mainwindow.cpp b/mainwindow.cpp index 49d64fc..d1a991f 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -1,14 +1,55 @@ #include "mainwindow.h" #include "ui_mainwindow.h" -MainWindow::MainWindow(QWidget *parent) : - QMainWindow(parent), - ui(new Ui::MainWindow) +#include +#include + +class QNetworkReply; +namespace yremote { + +MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); + manager = new QNetworkAccessManager(this); } MainWindow::~MainWindow() { delete ui; } + +void MainWindow::func() +{ + QNetworkAccessManager *manager = new QNetworkAccessManager(this); + connect(manager, SIGNAL(finished(QNetworkReply*)), + this, SLOT(replyFinished(QNetworkReply*))); + + manager->get(QNetworkRequest(QUrl("http://qt-project.org"))); +} + + +void MainWindow::on_btn_onoff_clicked() +{ + qDebug() << "void MainWindow::on_btn_onoff_clicked()"; + sendCommand("GetParam"); +} + +QString MainWindow::sendCommand(QString cmd) +{ + QString res; + + QNetworkRequest request; + request.setUrl("http://" + mAddress + ":80/YamahaRemoteControl/ctrl"); + + QNetworkReply *reply = manager->get(request); + qDebug() << reply->readAll(); + + + return res; +} +} + +void yremote::MainWindow::on_txt_address_textEdited(const QString &arg1) +{ + mAddress = arg1; +} diff --git a/mainwindow.h b/mainwindow.h index a3948a9..22d4a64 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -2,11 +2,14 @@ #define MAINWINDOW_H #include +#include "QtNetwork/QNetworkAccessManager" namespace Ui { class MainWindow; } +namespace yremote { + class MainWindow : public QMainWindow { Q_OBJECT @@ -15,8 +18,22 @@ public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); +protected: + void func(); + +private slots: + void on_btn_onoff_clicked(); + + void on_txt_address_textEdited(const QString &arg1); + private: Ui::MainWindow *ui; + QString sendCommand(QString cmd); + + QString mAddress; + QNetworkAccessManager *manager; }; +} + #endif // MAINWINDOW_H diff --git a/mainwindow.ui b/mainwindow.ui index 2a74a8c..cc5ef17 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -14,164 +14,142 @@ yremote - - - - 370 - 10 - 121 - 121 - - - - - - - 170 - 10 - 181 - 21 - - - - 10.0.0.5 - - - Qt::AlignCenter - - - - - - 370 - 130 - 121 - 31 - - - - - Source Code Pro Medium - 16 - - - - QFrame::StyledPanel - - - QFrame::Sunken - - - -66.5 - - - Qt::AlignCenter - - - - - - 120 - 10 - 51 - 21 - - - - Address: - - - - - - 10 - 40 - 201 - 121 - - - - Input - - - - - 10 - 30 - 80 - 21 - - - - HDMI 1 - - - - - - 10 - 60 - 80 - 21 - - - - HDMI 2 - - - - - - 10 - 90 - 80 - 21 - - - - HDMI 3 - - - - - - 110 - 30 - 80 - 21 - - - - Spotify - - - - - - 110 - 60 - 80 - 21 - - - - Airplay - - - - - - - 20 - 10 - 80 - 21 - - - - On - - + + + + + On + + + + + + + Address: + + + + + + + 10.0.0.5 + + + Qt::AlignCenter + + + + + + + + + + Input + + + + + 10 + 30 + 80 + 21 + + + + HDMI 1 + + + + + + 10 + 60 + 80 + 21 + + + + HDMI 2 + + + + + + 10 + 90 + 80 + 21 + + + + HDMI 3 + + + + + + 110 + 30 + 80 + 21 + + + + Spotify + + + + + + 110 + 60 + 80 + 21 + + + + Airplay + + + + + + 110 + 90 + 80 + 21 + + + + Audio In + + + + + + + + + Source Code Pro Medium + 16 + + + + QFrame::StyledPanel + + + QFrame::Sunken + + + -66.5 + + + Qt::AlignCenter + + + + diff --git a/yremote.pro b/yremote.pro index 0a73608..9624e95 100644 --- a/yremote.pro +++ b/yremote.pro @@ -4,7 +4,7 @@ # #------------------------------------------------- -QT += core gui +QT += core gui network greaterThan(QT_MAJOR_VERSION, 4): QT += widgets