Merge branch 'aidan/dev'
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
*pro.user
|
||||
5
main.cpp
@@ -3,9 +3,14 @@
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
// MacOS directive to prevent the menu bar from being merged into the native bar
|
||||
// i.e. it's in the window, and not the top left of the screen
|
||||
QCoreApplication::setAttribute(Qt::AA_DontUseNativeMenuBar);
|
||||
|
||||
QApplication a(argc, argv);
|
||||
MainWindow w;
|
||||
w.show();
|
||||
|
||||
return a.exec();
|
||||
|
||||
}
|
||||
|
||||
@@ -1,11 +1,40 @@
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
#include "popupmanager.h"
|
||||
#include "identitymanager.h"
|
||||
#include "nvpairingmanager.h"
|
||||
#include "nvhttp.h"
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::MainWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
// sample code for an iconized button performing an action
|
||||
// will be useful to implement the game grid UI later
|
||||
// myButton = new QPushButton(this);
|
||||
// myButton->setIcon(QIcon(":/res/icon128.png"));
|
||||
// myButton->setIconSize(QSize(128, 128));
|
||||
// myButton->resize(QSize(128, 128));
|
||||
// connect(myButton, &QAbstractButton::clicked, this, &MainWindow::on_actionExit_triggered);
|
||||
}
|
||||
|
||||
void MainWindow::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
const QMessageBox::StandardButton ret
|
||||
= QMessageBox::warning(this, tr("Application"),
|
||||
tr("something-something-close?"),
|
||||
QMessageBox::Yes | QMessageBox::No);
|
||||
switch (ret) {
|
||||
case QMessageBox::Yes:
|
||||
event->accept();
|
||||
break;
|
||||
case QMessageBox::No:
|
||||
default:
|
||||
event->ignore();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
@@ -17,3 +46,33 @@ void MainWindow::on_actionExit_triggered()
|
||||
{
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
void MainWindow::on_newHostBtn_clicked()
|
||||
{
|
||||
QString hostname = popupmanager::getHostnameDialog(this);
|
||||
if (!hostname.isEmpty()) {
|
||||
|
||||
IdentityManager im = IdentityManager(QDir(QDir::current()));
|
||||
NvPairingManager pm(hostname, im);
|
||||
|
||||
QString pin = pm.generatePinString();
|
||||
NvHTTP http(hostname, im);
|
||||
pm.pair(http.getServerInfo(), pin);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::addHostToDisplay(QMap<QString, bool> hostMdnsMap) {
|
||||
|
||||
QMapIterator<QString, bool> i(hostMdnsMap);
|
||||
while (i.hasNext()) {
|
||||
i.next();
|
||||
ui->hostSelectCombo->addItem(i.key());
|
||||
// we can ignore the mdns for now, it's only useful for displaying unpairing options
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_selectHostComboBox_activated(const QString &selectedHostname)
|
||||
{
|
||||
// TODO: get all the applications that "selectedHostname" has listed
|
||||
// probably populate another combobox of applications for the time being
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QtWidgets>
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
@@ -15,11 +16,18 @@ public:
|
||||
explicit MainWindow(QWidget *parent = 0);
|
||||
~MainWindow();
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
|
||||
private slots:
|
||||
void on_actionExit_triggered();
|
||||
void on_newHostBtn_clicked();
|
||||
void addHostToDisplay(QMap<QString, bool>);
|
||||
void on_selectHostComboBox_activated(const QString &);
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
|
||||
@@ -7,20 +7,65 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
<height>483</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralWidget"/>
|
||||
<widget class="QWidget" name="centralWidget">
|
||||
<widget class="QWidget" name="gridLayoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>50</x>
|
||||
<y>30</y>
|
||||
<width>306</width>
|
||||
<height>191</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetDefaultConstraint</enum>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="newHostBtn">
|
||||
<property name="cursor">
|
||||
<cursorShape>PointingHandCursor</cursorShape>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add New Host</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="resources.qrc">
|
||||
<normaloff>:/res/icon128.png</normaloff>:/res/icon128.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="hostSelectCombo"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menuBar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>24</height>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuFile">
|
||||
@@ -50,6 +95,8 @@
|
||||
</action>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources/>
|
||||
<resources>
|
||||
<include location="resources.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
||||
@@ -22,24 +22,32 @@ DEFINES += QT_DEPRECATED_WARNINGS
|
||||
# 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
|
||||
|
||||
INCLUDEPATH += \
|
||||
/usr/local/opt/openssl/include
|
||||
|
||||
SOURCES += \
|
||||
main.cpp \
|
||||
mainwindow.cpp \
|
||||
nvhttp.cpp \
|
||||
nvpairingmanager.cpp \
|
||||
identitymanager.cpp
|
||||
identitymanager.cpp \
|
||||
popupmanager.cpp
|
||||
|
||||
HEADERS += \
|
||||
mainwindow.h \
|
||||
nvhttp.h \
|
||||
nvpairingmanager.h \
|
||||
identitymanager.h \
|
||||
utils.h
|
||||
utils.h \
|
||||
popupmanager.h
|
||||
|
||||
FORMS += \
|
||||
mainwindow.ui
|
||||
|
||||
RESOURCES += \
|
||||
resources.qrc
|
||||
|
||||
LIBS += \
|
||||
-L/usr/local/opt/openssl/lib \
|
||||
-lssl \
|
||||
-lcrypto
|
||||
|
||||
41
popupmanager.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
#include "popupmanager.h"
|
||||
|
||||
QMessageBox *popupmanager::pinMsgBox = nullptr;
|
||||
|
||||
popupmanager::popupmanager(){}
|
||||
|
||||
// this opens a non-blocking informative message telling the user to enter the given pin
|
||||
// it is open-loop: if the user cancels, nothing happens
|
||||
// it is expected that upon pairing completion, the ::closePinDialog function will be called.
|
||||
void popupmanager::displayPinDialog(QString pin, QWidget* parent) {
|
||||
|
||||
popupmanager::pinMsgBox = new QMessageBox( parent );
|
||||
popupmanager::pinMsgBox->setAttribute( Qt::WA_DeleteOnClose ); //makes sure the msgbox is deleted automatically when closed
|
||||
popupmanager::pinMsgBox->setStandardButtons( QMessageBox::Ok );
|
||||
popupmanager::pinMsgBox->setText("Please enter the number " + pin + " on the GFE dialog on the computer.");
|
||||
popupmanager::pinMsgBox->setInformativeText("This dialog will be dismissed once complete.");
|
||||
popupmanager::pinMsgBox->open();
|
||||
}
|
||||
|
||||
// to be called when the pairing is complete
|
||||
void popupmanager::closePinDialog() {
|
||||
pinMsgBox->close();
|
||||
delete pinMsgBox;
|
||||
}
|
||||
|
||||
QString popupmanager::getHostnameDialog(QWidget* parent) {
|
||||
bool ok;
|
||||
QString responseHost
|
||||
= QInputDialog::getText(parent, QObject::tr("Add Host Manually"),
|
||||
QObject::tr("IP Address or Hostname of GeForce PC"),
|
||||
QLineEdit::Normal,
|
||||
QObject::tr("default string"),
|
||||
&ok);
|
||||
if (ok && !responseHost.isEmpty()) {
|
||||
return responseHost;
|
||||
} else {
|
||||
return QObject::tr("");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
18
popupmanager.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#ifndef POPUPMANAGER_H
|
||||
#define POPUPMANAGER_H
|
||||
|
||||
#include <QtWidgets>
|
||||
|
||||
class popupmanager
|
||||
{
|
||||
public:
|
||||
popupmanager();
|
||||
static void displayPinDialog(QString pin, QWidget* parent);
|
||||
static void closePinDialog();
|
||||
static QString getHostnameDialog(QWidget* parent);
|
||||
|
||||
private:
|
||||
static QMessageBox *pinMsgBox;
|
||||
};
|
||||
|
||||
#endif // POPUPMANAGER_H
|
||||
4
res/ic_add_to_queue_white_48px.svg
Normal file
@@ -0,0 +1,4 @@
|
||||
<svg fill="#FFFFFF" height="48" viewBox="0 0 24 24" width="48" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M0 0h24v24H0V0z" fill="none"/>
|
||||
<path d="M21 3H3c-1.11 0-2 .89-2 2v12c0 1.1.89 2 2 2h5v2h8v-2h5c1.1 0 1.99-.9 1.99-2L23 5c0-1.11-.9-2-2-2zm0 14H3V5h18v12zm-5-7v2h-3v3h-2v-3H8v-2h3V7h2v3h3z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 313 B |
4
res/ic_remove_circle_outline_white_48px.svg
Normal file
@@ -0,0 +1,4 @@
|
||||
<svg fill="#FFFFFF" height="48" viewBox="0 0 24 24" width="48" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M0 0h24v24H0z" fill="none"/>
|
||||
<path d="M7 11v2h10v-2H7zm5-9C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 303 B |
9
res/ic_remove_from_queue_white_48px.svg
Normal file
@@ -0,0 +1,9 @@
|
||||
<svg fill="#FFFFFF" height="48" viewBox="0 0 24 24" width="48" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<defs>
|
||||
<path d="M0 0h24v24H0V0z" id="a"/>
|
||||
</defs>
|
||||
<clipPath id="b">
|
||||
<use overflow="visible" xlink:href="#a"/>
|
||||
</clipPath>
|
||||
<path clip-path="url(#b)" d="M21 3H3c-1.11 0-2 .89-2 2v12c0 1.1.89 2 2 2h5v2h8v-2h5c1.1 0 1.99-.9 1.99-2L23 5c0-1.11-.9-2-2-2zm0 14H3V5h18v12zm-5-7v2H8v-2h8z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 467 B |
4
res/ic_tv_white_48px.svg
Normal file
@@ -0,0 +1,4 @@
|
||||
<svg fill="#FFFFFF" height="48" viewBox="0 0 24 24" width="48" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M0 0h24v24H0z" fill="none"/>
|
||||
<path d="M21 3H3c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h5v2h8v-2h5c1.1 0 1.99-.9 1.99-2L23 5c0-1.1-.9-2-2-2zm0 14H3V5h18v12z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 273 B |
4
res/ic_videogame_asset_white_48px.svg
Normal file
@@ -0,0 +1,4 @@
|
||||
<svg fill="#FFFFFF" height="48" viewBox="0 0 24 24" width="48" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M0 0v24h24V0H0zm23 16c0 1.1-.9 2-2 2H3c-1.1 0-2-.9-2-2V8c0-1.1.9-2 2-2h18c1.1 0 2 .9 2 2v8z" fill="none"/>
|
||||
<path d="M21 6H3c-1.1 0-2 .9-2 2v8c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm-10 7H8v3H6v-3H3v-2h3V8h2v3h3v2zm4.5 2c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5zm4-3c-.83 0-1.5-.67-1.5-1.5S18.67 9 19.5 9s1.5.67 1.5 1.5-.67 1.5-1.5 1.5z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 501 B |
BIN
res/icon128.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
res/no_app_image.png
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
11
resources.qrc
Normal file
@@ -0,0 +1,11 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>res/icon128.png</file>
|
||||
<file>res/ic_add_to_queue_white_48px.svg</file>
|
||||
<file>res/ic_remove_circle_outline_white_48px.svg</file>
|
||||
<file>res/ic_remove_from_queue_white_48px.svg</file>
|
||||
<file>res/ic_tv_white_48px.svg</file>
|
||||
<file>res/ic_videogame_asset_white_48px.svg</file>
|
||||
<file>res/no_app_image.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||