added first network things
This commit is contained in:
2
main.cpp
2
main.cpp
@@ -1,6 +1,8 @@
|
|||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
|
||||||
|
using namespace yremote;
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
|
|||||||
@@ -1,14 +1,55 @@
|
|||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "ui_mainwindow.h"
|
#include "ui_mainwindow.h"
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent) :
|
#include <qnetwork.h>
|
||||||
QMainWindow(parent),
|
#include <QtNetwork/QNetworkReply>
|
||||||
ui(new Ui::MainWindow)
|
|
||||||
|
class QNetworkReply;
|
||||||
|
namespace yremote {
|
||||||
|
|
||||||
|
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
manager = new QNetworkAccessManager(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
{
|
{
|
||||||
delete ui;
|
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
|
#define MAINWINDOW_H
|
||||||
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
|
#include "QtNetwork/QNetworkAccessManager"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class MainWindow;
|
class MainWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace yremote {
|
||||||
|
|
||||||
class MainWindow : public QMainWindow
|
class MainWindow : public QMainWindow
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -15,8 +18,22 @@ public:
|
|||||||
explicit MainWindow(QWidget *parent = 0);
|
explicit MainWindow(QWidget *parent = 0);
|
||||||
~MainWindow();
|
~MainWindow();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void func();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void on_btn_onoff_clicked();
|
||||||
|
|
||||||
|
void on_txt_address_textEdited(const QString &arg1);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
|
QString sendCommand(QString cmd);
|
||||||
|
|
||||||
|
QString mAddress;
|
||||||
|
QNetworkAccessManager *manager;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
|||||||
118
mainwindow.ui
118
mainwindow.ui
@@ -14,25 +14,23 @@
|
|||||||
<string>yremote</string>
|
<string>yremote</string>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="centralWidget">
|
<widget class="QWidget" name="centralWidget">
|
||||||
<widget class="QDial" name="dial">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<property name="geometry">
|
<item row="0" column="0">
|
||||||
<rect>
|
<widget class="QPushButton" name="btn_onoff">
|
||||||
<x>370</x>
|
<property name="text">
|
||||||
<y>10</y>
|
<string>On</string>
|
||||||
<width>121</width>
|
|
||||||
<height>121</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QLineEdit" name="txt_address">
|
</item>
|
||||||
<property name="geometry">
|
<item row="0" column="1">
|
||||||
<rect>
|
<widget class="QLabel" name="label">
|
||||||
<x>170</x>
|
<property name="text">
|
||||||
<y>10</y>
|
<string>Address:</string>
|
||||||
<width>181</width>
|
|
||||||
<height>21</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="2">
|
||||||
|
<widget class="QLineEdit" name="txt_address">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>10.0.0.5</string>
|
<string>10.0.0.5</string>
|
||||||
</property>
|
</property>
|
||||||
@@ -40,56 +38,12 @@
|
|||||||
<set>Qt::AlignCenter</set>
|
<set>Qt::AlignCenter</set>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QLabel" name="lbl_volume">
|
</item>
|
||||||
<property name="geometry">
|
<item row="0" column="3" rowspan="2">
|
||||||
<rect>
|
<widget class="QDial" name="dial"/>
|
||||||
<x>370</x>
|
</item>
|
||||||
<y>130</y>
|
<item row="1" column="0" rowspan="2" colspan="3">
|
||||||
<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">
|
<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">
|
<property name="title">
|
||||||
<string>Input</string>
|
<string>Input</string>
|
||||||
</property>
|
</property>
|
||||||
@@ -158,21 +112,45 @@
|
|||||||
<string>Airplay</string>
|
<string>Airplay</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
<widget class="QPushButton" name="btn_audioin">
|
||||||
<widget class="QPushButton" name="btn_onoff">
|
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>20</x>
|
<x>110</x>
|
||||||
<y>10</y>
|
<y>90</y>
|
||||||
<width>80</width>
|
<width>80</width>
|
||||||
<height>21</height>
|
<height>21</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>On</string>
|
<string>Audio In</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</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>
|
</widget>
|
||||||
<layoutdefault spacing="6" margin="11"/>
|
<layoutdefault spacing="6" margin="11"/>
|
||||||
<resources/>
|
<resources/>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
#
|
#
|
||||||
#-------------------------------------------------
|
#-------------------------------------------------
|
||||||
|
|
||||||
QT += core gui
|
QT += core gui network
|
||||||
|
|
||||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user