commit 63d1c4abdf0de9c6f4d2a1d93cd9618525935645 Author: Cameron Gutman Date: Sat Apr 28 15:39:50 2018 -0700 Initial work diff --git a/main.cpp b/main.cpp new file mode 100644 index 00000000..b48f94ec --- /dev/null +++ b/main.cpp @@ -0,0 +1,11 @@ +#include "mainwindow.h" +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + MainWindow w; + w.show(); + + return a.exec(); +} diff --git a/mainwindow.cpp b/mainwindow.cpp new file mode 100644 index 00000000..57f85959 --- /dev/null +++ b/mainwindow.cpp @@ -0,0 +1,19 @@ +#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::on_actionExit_triggered() +{ + exit(EXIT_SUCCESS); +} diff --git a/mainwindow.h b/mainwindow.h new file mode 100644 index 00000000..450992cd --- /dev/null +++ b/mainwindow.h @@ -0,0 +1,25 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include + +namespace Ui { +class MainWindow; +} + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit MainWindow(QWidget *parent = 0); + ~MainWindow(); + +private slots: + void on_actionExit_triggered(); + +private: + Ui::MainWindow *ui; +}; + +#endif // MAINWINDOW_H diff --git a/mainwindow.ui b/mainwindow.ui new file mode 100644 index 00000000..0c8dc36f --- /dev/null +++ b/mainwindow.ui @@ -0,0 +1,55 @@ + + + MainWindow + + + + 0 + 0 + 400 + 300 + + + + MainWindow + + + + + + 0 + 0 + 400 + 24 + + + + + File + + + + + + + + + + Settings + + + + + Gamepad Mapping + + + + + Exit + + + + + + + diff --git a/moonlight-qt.pro b/moonlight-qt.pro new file mode 100644 index 00000000..ca0080e2 --- /dev/null +++ b/moonlight-qt.pro @@ -0,0 +1,36 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2018-04-28T14:01:01 +# +#------------------------------------------------- + +QT += core gui network + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +TARGET = moonlight-qt +TEMPLATE = app + +# The following define makes your compiler emit warnings if you use +# any feature of Qt which has been marked as deprecated (the exact warnings +# depend on your compiler). Please consult the documentation of the +# deprecated API in order to know how to port your code away from it. +DEFINES += QT_DEPRECATED_WARNINGS + +# You can also make your code fail to compile if you use deprecated APIs. +# In order to do so, uncomment the following line. +# You can also select to disable deprecated APIs only up to a certain version of Qt. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + + +SOURCES += \ + main.cpp \ + mainwindow.cpp \ + nvhttp.cpp + +HEADERS += \ + mainwindow.h \ + nvhttp.h + +FORMS += \ + mainwindow.ui diff --git a/nvhttp.cpp b/nvhttp.cpp new file mode 100644 index 00000000..d3b50ed2 --- /dev/null +++ b/nvhttp.cpp @@ -0,0 +1,33 @@ +#include "nvhttp.h" + +#include +#include + +NvHTTP::NvHTTP(QString address) +{ + m_BaseUrlHttp.setScheme("http"); + m_BaseUrlHttps.setScheme("https"); + m_BaseUrlHttp.setHost(address); + m_BaseUrlHttps.setHost(address); + m_BaseUrlHttp.setPort(47989); + m_BaseUrlHttps.setPort(47984); +} + +QNetworkReply* +NvHTTP::openConnection(QUrl baseUrl, + QString command, + QString arguments, + bool enableTimeout) +{ + QUrl url(baseUrl); + + url.setPath(command + + "?uniqueid=" + "0" + + "&uuid=" + QUuid::createUuid().toString() + + ((arguments != nullptr) ? (arguments + "&") : "")); + + QNetworkReply* reply = m_Nam.get(QNetworkRequest(url)); + reply->ignoreSslErrors(QList{ QSslError::SelfSignedCertificate }); + + return reply; +} diff --git a/nvhttp.h b/nvhttp.h new file mode 100644 index 00000000..04017331 --- /dev/null +++ b/nvhttp.h @@ -0,0 +1,21 @@ +#pragma once + +#include +#include + +class NvHTTP +{ +public: + NvHTTP(QString address); + +private: + QNetworkReply* + openConnection(QUrl baseUrl, + QString command, + QString arguments, + bool enableTimeout); + + QUrl m_BaseUrlHttp; + QUrl m_BaseUrlHttps; + QNetworkAccessManager m_Nam; +};