adityapk00
5 years ago
10 changed files with 353 additions and 21 deletions
@ -0,0 +1,14 @@ |
|||||
|
#include "mobileappconnector.h" |
||||
|
#include "ui_mobileappconnector.h" |
||||
|
|
||||
|
MobileAppConnector::MobileAppConnector(QWidget *parent) : |
||||
|
QDialog(parent), |
||||
|
ui(new Ui::MobileAppConnector) |
||||
|
{ |
||||
|
ui->setupUi(this); |
||||
|
} |
||||
|
|
||||
|
MobileAppConnector::~MobileAppConnector() |
||||
|
{ |
||||
|
delete ui; |
||||
|
} |
@ -0,0 +1,22 @@ |
|||||
|
#ifndef MOBILEAPPCONNECTOR_H |
||||
|
#define MOBILEAPPCONNECTOR_H |
||||
|
|
||||
|
#include <QDialog> |
||||
|
|
||||
|
namespace Ui { |
||||
|
class MobileAppConnector; |
||||
|
} |
||||
|
|
||||
|
class MobileAppConnector : public QDialog |
||||
|
{ |
||||
|
Q_OBJECT |
||||
|
|
||||
|
public: |
||||
|
explicit MobileAppConnector(QWidget *parent = nullptr); |
||||
|
~MobileAppConnector(); |
||||
|
|
||||
|
private: |
||||
|
Ui::MobileAppConnector *ui; |
||||
|
}; |
||||
|
|
||||
|
#endif // MOBILEAPPCONNECTOR_H
|
@ -0,0 +1,146 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<ui version="4.0"> |
||||
|
<class>MobileAppConnector</class> |
||||
|
<widget class="QDialog" name="MobileAppConnector"> |
||||
|
<property name="geometry"> |
||||
|
<rect> |
||||
|
<x>0</x> |
||||
|
<y>0</y> |
||||
|
<width>532</width> |
||||
|
<height>400</height> |
||||
|
</rect> |
||||
|
</property> |
||||
|
<property name="windowTitle"> |
||||
|
<string>Connect Mobile App</string> |
||||
|
</property> |
||||
|
<layout class="QGridLayout" name="gridLayout"> |
||||
|
<item row="2" column="2"> |
||||
|
<widget class="QGroupBox" name="groupBox"> |
||||
|
<property name="title"> |
||||
|
<string>ZecQT Wallet Companion App</string> |
||||
|
</property> |
||||
|
<layout class="QGridLayout" name="gridLayout_2"> |
||||
|
<item row="0" column="0"> |
||||
|
<widget class="QLabel" name="lblConnectedApp"> |
||||
|
<property name="text"> |
||||
|
<string>Connected Phone Name and Description</string> |
||||
|
</property> |
||||
|
</widget> |
||||
|
</item> |
||||
|
<item row="1" column="0"> |
||||
|
<widget class="QPushButton" name="btnDisconnect"> |
||||
|
<property name="text"> |
||||
|
<string>Disconnect</string> |
||||
|
</property> |
||||
|
</widget> |
||||
|
</item> |
||||
|
<item row="2" column="0"> |
||||
|
<spacer name="verticalSpacer"> |
||||
|
<property name="orientation"> |
||||
|
<enum>Qt::Vertical</enum> |
||||
|
</property> |
||||
|
<property name="sizeHint" stdset="0"> |
||||
|
<size> |
||||
|
<width>20</width> |
||||
|
<height>40</height> |
||||
|
</size> |
||||
|
</property> |
||||
|
</spacer> |
||||
|
</item> |
||||
|
</layout> |
||||
|
</widget> |
||||
|
</item> |
||||
|
<item row="4" column="1" colspan="2"> |
||||
|
<widget class="QDialogButtonBox" name="buttonBox"> |
||||
|
<property name="orientation"> |
||||
|
<enum>Qt::Horizontal</enum> |
||||
|
</property> |
||||
|
<property name="standardButtons"> |
||||
|
<set>QDialogButtonBox::Close</set> |
||||
|
</property> |
||||
|
</widget> |
||||
|
</item> |
||||
|
<item row="2" column="0" colspan="2"> |
||||
|
<widget class="QRCodeLabel" name="qrcode"> |
||||
|
<property name="sizePolicy"> |
||||
|
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding"> |
||||
|
<horstretch>0</horstretch> |
||||
|
<verstretch>0</verstretch> |
||||
|
</sizepolicy> |
||||
|
</property> |
||||
|
<property name="styleSheet"> |
||||
|
<string notr="true">background-color: #fff</string> |
||||
|
</property> |
||||
|
<property name="text"> |
||||
|
<string/> |
||||
|
</property> |
||||
|
</widget> |
||||
|
</item> |
||||
|
<item row="0" column="0" colspan="3"> |
||||
|
<widget class="QLabel" name="label"> |
||||
|
<property name="sizePolicy"> |
||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Minimum"> |
||||
|
<horstretch>0</horstretch> |
||||
|
<verstretch>0</verstretch> |
||||
|
</sizepolicy> |
||||
|
</property> |
||||
|
<property name="text"> |
||||
|
<string>Scan this QRCode from your ZecQT companion app to connect your phone</string> |
||||
|
</property> |
||||
|
</widget> |
||||
|
</item> |
||||
|
<item row="3" column="0" colspan="2"> |
||||
|
<widget class="QLabel" name="lblConnStr"> |
||||
|
<property name="text"> |
||||
|
<string>TextLabel</string> |
||||
|
</property> |
||||
|
<property name="alignment"> |
||||
|
<set>Qt::AlignCenter</set> |
||||
|
</property> |
||||
|
</widget> |
||||
|
</item> |
||||
|
</layout> |
||||
|
</widget> |
||||
|
<customwidgets> |
||||
|
<customwidget> |
||||
|
<class>QRCodeLabel</class> |
||||
|
<extends>QLabel</extends> |
||||
|
<header>qrcodelabel.h</header> |
||||
|
</customwidget> |
||||
|
</customwidgets> |
||||
|
<resources/> |
||||
|
<connections> |
||||
|
<connection> |
||||
|
<sender>buttonBox</sender> |
||||
|
<signal>accepted()</signal> |
||||
|
<receiver>MobileAppConnector</receiver> |
||||
|
<slot>accept()</slot> |
||||
|
<hints> |
||||
|
<hint type="sourcelabel"> |
||||
|
<x>248</x> |
||||
|
<y>254</y> |
||||
|
</hint> |
||||
|
<hint type="destinationlabel"> |
||||
|
<x>157</x> |
||||
|
<y>274</y> |
||||
|
</hint> |
||||
|
</hints> |
||||
|
</connection> |
||||
|
<connection> |
||||
|
<sender>buttonBox</sender> |
||||
|
<signal>rejected()</signal> |
||||
|
<receiver>MobileAppConnector</receiver> |
||||
|
<slot>reject()</slot> |
||||
|
<hints> |
||||
|
<hint type="sourcelabel"> |
||||
|
<x>316</x> |
||||
|
<y>260</y> |
||||
|
</hint> |
||||
|
<hint type="destinationlabel"> |
||||
|
<x>286</x> |
||||
|
<y>274</y> |
||||
|
</hint> |
||||
|
</hints> |
||||
|
</connection> |
||||
|
</connections> |
||||
|
</ui> |
@ -0,0 +1,102 @@ |
|||||
|
<html> |
||||
|
<head> |
||||
|
<title>WebSocket Echo Client</title> |
||||
|
</head> |
||||
|
<body> |
||||
|
<h1>WebSocket Echo Client</h1> |
||||
|
<p> |
||||
|
<button onClick="initWebSocket();">Connect</button> |
||||
|
<button onClick="stopWebSocket();">Disconnect</button> |
||||
|
<button onClick="checkSocket();">State</button> |
||||
|
</p> |
||||
|
<p> |
||||
|
<textarea id="debugTextArea" style="width:400px;height:200px;"></textarea> |
||||
|
</p> |
||||
|
<p> |
||||
|
<input type="text" id="inputText" onkeydown="if(event.keyCode==13)sendMessage();" /> |
||||
|
<button onClick="sendMessage();">Send</button> |
||||
|
</p> |
||||
|
|
||||
|
<script type="text/javascript"> |
||||
|
var debugTextArea = document.getElementById("debugTextArea"); |
||||
|
function debug(message) { |
||||
|
debugTextArea.value += message + "\n"; |
||||
|
debugTextArea.scrollTop = debugTextArea.scrollHeight; |
||||
|
} |
||||
|
|
||||
|
function sendMessage() { |
||||
|
var msg = document.getElementById("inputText").value; |
||||
|
if ( websocket != null ) |
||||
|
{ |
||||
|
document.getElementById("inputText").value = ""; |
||||
|
websocket.send( msg ); |
||||
|
console.log( "string sent :", '"'+msg+'"' ); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
var wsUri = "ws://localhost:8237"; |
||||
|
var websocket = null; |
||||
|
|
||||
|
function initWebSocket() { |
||||
|
try { |
||||
|
if (typeof MozWebSocket == 'function') |
||||
|
WebSocket = MozWebSocket; |
||||
|
if ( websocket && websocket.readyState == 1 ) |
||||
|
websocket.close(); |
||||
|
websocket = new WebSocket( wsUri ); |
||||
|
websocket.onopen = function (evt) { |
||||
|
debug("CONNECTED"); |
||||
|
}; |
||||
|
websocket.onclose = function (evt) { |
||||
|
debug("DISCONNECTED"); |
||||
|
}; |
||||
|
websocket.onmessage = function (evt) { |
||||
|
console.log( "Message received :", evt.data ); |
||||
|
debug( evt.data ); |
||||
|
}; |
||||
|
websocket.onerror = function (evt) { |
||||
|
debug('ERROR: ' + evt.data); |
||||
|
}; |
||||
|
} catch (exception) { |
||||
|
debug('ERROR: ' + exception); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
function stopWebSocket() { |
||||
|
if (websocket) |
||||
|
websocket.close(); |
||||
|
} |
||||
|
|
||||
|
function checkSocket() { |
||||
|
if (websocket != null) { |
||||
|
var stateStr; |
||||
|
switch (websocket.readyState) { |
||||
|
case 0: { |
||||
|
stateStr = "CONNECTING"; |
||||
|
break; |
||||
|
} |
||||
|
case 1: { |
||||
|
stateStr = "OPEN"; |
||||
|
break; |
||||
|
} |
||||
|
case 2: { |
||||
|
stateStr = "CLOSING"; |
||||
|
break; |
||||
|
} |
||||
|
case 3: { |
||||
|
stateStr = "CLOSED"; |
||||
|
break; |
||||
|
} |
||||
|
default: { |
||||
|
stateStr = "UNKNOW"; |
||||
|
break; |
||||
|
} |
||||
|
} |
||||
|
debug("WebSocket state = " + websocket.readyState + " ( " + stateStr + " )"); |
||||
|
} else { |
||||
|
debug("WebSocket is null"); |
||||
|
} |
||||
|
} |
||||
|
</script> |
||||
|
</body> |
||||
|
</html> |
Loading…
Reference in new issue