added first network things
This commit is contained in:
2
main.cpp
2
main.cpp
@@ -1,6 +1,8 @@
|
||||
#include "mainwindow.h"
|
||||
#include <QApplication>
|
||||
|
||||
using namespace yremote;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
|
||||
@@ -1,14 +1,55 @@
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::MainWindow)
|
||||
#include <qnetwork.h>
|
||||
#include <QtNetwork/QNetworkReply>
|
||||
|
||||
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("<YAMAHA_AV cmd=\"GET\"><Main_Zone><Input><Input_Sel>GetParam</Input_Sel></Input></Main_Zone></YAMAHA_AV>");
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
17
mainwindow.h
17
mainwindow.h
@@ -2,11 +2,14 @@
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#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
|
||||
|
||||
294
mainwindow.ui
294
mainwindow.ui
@@ -14,164 +14,142 @@
|
||||
<string>yremote</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralWidget">
|
||||
<widget class="QDial" name="dial">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>370</x>
|
||||
<y>10</y>
|
||||
<width>121</width>
|
||||
<height>121</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="txt_address">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>170</x>
|
||||
<y>10</y>
|
||||
<width>181</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>10.0.0.5</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="lbl_volume">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>370</x>
|
||||
<y>130</y>
|
||||
<width>121</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Source Code Pro Medium</family>
|
||||
<pointsize>16</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>-66.5</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>120</x>
|
||||
<y>10</y>
|
||||
<width>51</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Address:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>40</y>
|
||||
<width>201</width>
|
||||
<height>121</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Input</string>
|
||||
</property>
|
||||
<widget class="QPushButton" name="btn_hdmi1">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>30</y>
|
||||
<width>80</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>HDMI 1</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="btn_hdmi2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>60</y>
|
||||
<width>80</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>HDMI 2</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="btn_hdmi3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>90</y>
|
||||
<width>80</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>HDMI 3</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="btn_spotify">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>110</x>
|
||||
<y>30</y>
|
||||
<width>80</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Spotify</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="btn_airplay">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>110</x>
|
||||
<y>60</y>
|
||||
<width>80</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Airplay</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="btn_onoff">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>10</y>
|
||||
<width>80</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>On</string>
|
||||
</property>
|
||||
</widget>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="btn_onoff">
|
||||
<property name="text">
|
||||
<string>On</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Address:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QLineEdit" name="txt_address">
|
||||
<property name="text">
|
||||
<string>10.0.0.5</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3" rowspan="2">
|
||||
<widget class="QDial" name="dial"/>
|
||||
</item>
|
||||
<item row="1" column="0" rowspan="2" colspan="3">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Input</string>
|
||||
</property>
|
||||
<widget class="QPushButton" name="btn_hdmi1">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>30</y>
|
||||
<width>80</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>HDMI 1</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="btn_hdmi2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>60</y>
|
||||
<width>80</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>HDMI 2</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="btn_hdmi3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>90</y>
|
||||
<width>80</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>HDMI 3</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="btn_spotify">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>110</x>
|
||||
<y>30</y>
|
||||
<width>80</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Spotify</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="btn_airplay">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>110</x>
|
||||
<y>60</y>
|
||||
<width>80</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Airplay</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="btn_audioin">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>110</x>
|
||||
<y>90</y>
|
||||
<width>80</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Audio In</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="3">
|
||||
<widget class="QLabel" name="lbl_volume">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Source Code Pro Medium</family>
|
||||
<pointsize>16</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>-66.5</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#
|
||||
#-------------------------------------------------
|
||||
|
||||
QT += core gui
|
||||
QT += core gui network
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
|
||||
|
||||
Reference in New Issue
Block a user