mirror of
https://gitee.com/drabel/LibQQt.git
synced 2025-01-04 10:18:44 +08:00
remove touchmonitor
This commit is contained in:
parent
309276e4a0
commit
3ae5bef816
@ -61,8 +61,7 @@ SUBDIRS =
|
||||
#some test project
|
||||
#SUBDIRS += test/gumbo_query_test
|
||||
#SUBDIRS += test/customqvariant
|
||||
#
|
||||
SUBDIRS += test/framelesshelperwidget
|
||||
#SUBDIRS += test/framelesshelperwidget
|
||||
#SUBDIRS += test/treeviewtest
|
||||
#SUBDIRS += test/bytearraytest
|
||||
#!contains(QKIT_PRIVATE, iOS|iOSSimulator){
|
||||
@ -94,10 +93,8 @@ SUBDIRS += test/framelesshelperwidget
|
||||
#mac:lessThan(QT_MAJOR_VERSION , 5):SUBDIRS -= test/voicetest
|
||||
|
||||
#网络创建工具
|
||||
#
|
||||
SUBDIRS += demo/QQtClientCreator
|
||||
#
|
||||
SUBDIRS += demo/QQtServerCreator
|
||||
#SUBDIRS += demo/QQtClientCreator
|
||||
#SUBDIRS += demo/QQtServerCreator
|
||||
#这边是个组合项,客户端和服务器一起的。必看
|
||||
#SUBDIRS += examples/qqtclientexample
|
||||
#SUBDIRS += examples/qqtserverexample
|
||||
@ -112,6 +109,7 @@ SUBDIRS += demo/QQtServerCreator
|
||||
#SUBDIRS += test/osdtest
|
||||
#SUBDIRS += test/inputtest
|
||||
#SUBDIRS += demo/SysInfoNotify
|
||||
SUBDIRS += demo/TouchMonitor
|
||||
SUBDIRS += demo/TouchMonitorServer
|
||||
#移除
|
||||
#SUBDIRS += demo/TouchMonitor
|
||||
#SUBDIRS += demo/TouchMonitorServer
|
||||
|
||||
|
@ -1,46 +0,0 @@
|
||||
#-------------------------------------------------
|
||||
#
|
||||
# Project created by QtCreator 2018-05-06T15:03:12
|
||||
#
|
||||
#-------------------------------------------------
|
||||
|
||||
QT += core gui
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
|
||||
TARGET = TouchMonitor
|
||||
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 += touchmonitorprotocol.cpp
|
||||
HEADERS += touchmonitorprotocol.h
|
||||
|
||||
|
||||
SOURCES += \
|
||||
main.cpp \
|
||||
mainwindow.cpp
|
||||
|
||||
HEADERS += \
|
||||
mainwindow.h
|
||||
|
||||
FORMS += \
|
||||
mainwindow.ui
|
||||
|
||||
system("touch main.cpp")
|
||||
#CONFIG += deploy_config
|
||||
contains(CONFIG, deploy_config) {
|
||||
APP_CONFIG_PWD = $${PWD}/AppRoot
|
||||
equals(QMAKE_HOST.os, Windows) {
|
||||
APP_CONFIG_PWD ~=s,/,\\,g
|
||||
}
|
||||
}
|
||||
include(../../src/app_base_manager.pri)
|
@ -1,11 +0,0 @@
|
||||
#include "mainwindow.h"
|
||||
#include <QApplication>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
MainWindow w;
|
||||
w.show();
|
||||
|
||||
return a.exec();
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
|
||||
MainWindow::MainWindow ( QWidget* parent ) :
|
||||
QMainWindow ( parent ),
|
||||
ui ( new Ui::MainWindow )
|
||||
{
|
||||
ui->setupUi ( this );
|
||||
s0 = TouchMonitorInstance ( p0, this );
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
QQtTcpClient* MainWindow::TouchMonitorInstance ( TouchMonitorProtocol*& protocol, QObject* parent )
|
||||
{
|
||||
static TouchMonitorProtocol* p0 = NULL;
|
||||
if ( !p0 )
|
||||
{
|
||||
p0 = new TouchMonitorProtocol ( parent );
|
||||
}
|
||||
protocol = p0;
|
||||
|
||||
static QQtTcpClient* s0 = NULL;
|
||||
if ( !s0 )
|
||||
{
|
||||
s0 = new QQtTcpClient ( parent );
|
||||
s0->installProtocol ( p0 );
|
||||
//s0->setServer
|
||||
//s0->sendConnectToHost();
|
||||
}
|
||||
|
||||
return s0;
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <qqttcpclient.h>
|
||||
#include <touchmonitorprotocol.h>
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
}
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWindow ( QWidget* parent = 0 );
|
||||
~MainWindow();
|
||||
//业务层初始化一下这个实例,总是从这里获取协议句柄进行对外读写。
|
||||
QQtTcpClient* TouchMonitorInstance ( TouchMonitorProtocol*& protocol, QObject* parent = 0 );
|
||||
|
||||
private:
|
||||
Ui::MainWindow* ui;
|
||||
QQtTcpClient* s0;
|
||||
TouchMonitorProtocol* p0;
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
@ -1,107 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>407</width>
|
||||
<height>213</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralWidget">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QStackedWidget" name="stackedWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="page"/>
|
||||
<widget class="QWidget" name="page_2">
|
||||
<widget class="QLineEdit" name="lineEdit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>90</x>
|
||||
<y>36</y>
|
||||
<width>151</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>40</x>
|
||||
<y>40</y>
|
||||
<width>41</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Server IP</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menuBar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>407</width>
|
||||
<height>17</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menu">
|
||||
<property name="title">
|
||||
<string>连接</string>
|
||||
</property>
|
||||
<addaction name="actionConnect"/>
|
||||
<addaction name="actionDisconnect"/>
|
||||
<addaction name="actionServer_IP"/>
|
||||
</widget>
|
||||
<addaction name="menu"/>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusBar"/>
|
||||
<action name="actionConnect">
|
||||
<property name="text">
|
||||
<string>Start</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionDisconnect">
|
||||
<property name="text">
|
||||
<string>Stop</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionIP">
|
||||
<property name="text">
|
||||
<string>Server IP</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionServer_IP">
|
||||
<property name="text">
|
||||
<string>Server IP</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionStart">
|
||||
<property name="text">
|
||||
<string>Start</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionStop">
|
||||
<property name="text">
|
||||
<string>Stop</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
@ -1,10 +0,0 @@
|
||||
#include "touchmonitorprotocol.h"
|
||||
|
||||
QDebug& operator << ( QDebug& dbg, const TouchMonitorMessage& msg )
|
||||
{
|
||||
//这里打印一下,报文里面到底有什么信息,
|
||||
//一般到这里的,都是被解析好的message。
|
||||
|
||||
dbg.nospace() << "{" << hex << msg.size() << hex << msg.cmd() << oct << msg.x() << msg.y() << "}";
|
||||
return dbg.space();
|
||||
}
|
@ -1,165 +0,0 @@
|
||||
#ifndef TOUCHMONITORPROTOCOL_H
|
||||
#define TOUCHMONITORPROTOCOL_H
|
||||
|
||||
#include <qqtmessage.h>
|
||||
#include <qqtprotocol.h>
|
||||
#include <qqttcpclient.h>
|
||||
|
||||
/**
|
||||
* quint8 quint8 quint16 quint16
|
||||
* size cmd xP yP
|
||||
*/
|
||||
class TouchMonitorMessage : public QQtMessage
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit TouchMonitorMessage ( QObject* parent = nullptr ) {
|
||||
mSize = 0x06;//报文定长
|
||||
}
|
||||
~TouchMonitorMessage() {
|
||||
|
||||
}
|
||||
|
||||
quint8& size() { return mSize; }
|
||||
const quint8& size() const { return mSize; }
|
||||
quint8& cmd() { return mCmd; }
|
||||
const quint8& cmd() const { return mCmd; }
|
||||
quint16& x() { return mX; }
|
||||
const quint16& x() const { return mX; }
|
||||
quint16& y() { return mY; }
|
||||
const quint16& y() const { return mY; }
|
||||
|
||||
private:
|
||||
//格式
|
||||
//|quint8 size|quint8 cmd|quint8 data|
|
||||
quint8 mSize;
|
||||
quint8 mCmd;
|
||||
quint16 mX;
|
||||
quint16 mY;
|
||||
|
||||
// QQtMessage interface
|
||||
public:
|
||||
//把报文这条流解析出字段
|
||||
virtual void parser ( const QByteArray& l ) override {
|
||||
QByteArray _l = l;
|
||||
_l >> mSize;
|
||||
_l >> mCmd;
|
||||
_l >> mX;
|
||||
_l >> mY;
|
||||
}
|
||||
//把报文字段组装成流
|
||||
virtual void packer ( QByteArray& l ) const override {
|
||||
l << mSize;
|
||||
l << mCmd;
|
||||
l << mX;
|
||||
l << mY;
|
||||
}
|
||||
};
|
||||
|
||||
QDebug& operator << ( QDebug&, const TouchMonitorMessage& msg );
|
||||
|
||||
|
||||
//业务层总是用这个协议工作,读来到的,写出去的。
|
||||
class TouchMonitorProtocol : public QQtProtocol
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit TouchMonitorProtocol ( QObject* parent = nullptr ) {
|
||||
|
||||
}
|
||||
~TouchMonitorProtocol() {
|
||||
|
||||
}
|
||||
|
||||
//收到外部发来的很多命令,处理一下告诉业务层干点什么。
|
||||
//客户端不干什么
|
||||
void recvCommand1 ( const TouchMonitorMessage& msg ) {
|
||||
//what do you want to do?
|
||||
}
|
||||
void recvCommand2 ( const TouchMonitorMessage& msg ) {
|
||||
//what do you want to do?
|
||||
}
|
||||
|
||||
/**
|
||||
* 0x0a 提交分辨率
|
||||
* 0x0b 提交点击位置
|
||||
*/
|
||||
|
||||
void sendCommand0a ( QPoint point ) {
|
||||
//what do you want to do?
|
||||
//获取窗口的大小,发给Server
|
||||
TouchMonitorMessage msg;
|
||||
msg.cmd() = 0x0a;
|
||||
msg.x() = point.x();
|
||||
msg.y() = point.y();
|
||||
|
||||
QByteArray l;
|
||||
msg.packer ( l );
|
||||
write ( l );
|
||||
}
|
||||
|
||||
void sendCommand0b ( QPoint point ) {
|
||||
//根据当前点击位置,发送坐标给Server
|
||||
TouchMonitorMessage msg;
|
||||
msg.cmd() = 0x0b;
|
||||
msg.x() = point.x();
|
||||
msg.y() = point.y();
|
||||
|
||||
QByteArray l;
|
||||
msg.packer ( l );
|
||||
write ( l );
|
||||
}
|
||||
|
||||
signals:
|
||||
//给业务层发的信号
|
||||
void signalSendtoLogicLevelCode();
|
||||
|
||||
public slots:
|
||||
|
||||
// QQtProtocol interface
|
||||
protected:
|
||||
//报文的最小长度
|
||||
virtual quint16 minlength() override {
|
||||
return 0x06;
|
||||
}
|
||||
//报文的最大长度
|
||||
virtual quint16 maxlength() override {
|
||||
return 0x06;
|
||||
}
|
||||
//报文现在在流里,第一个字节,就是size,读出来,通过返回值告诉QQtProtocol
|
||||
virtual quint16 splitter ( const QByteArray& l ) override { //stream
|
||||
QByteArray s0 = l.left ( 1 );
|
||||
quint8 size = 0;
|
||||
s0 >> size;
|
||||
//0x06;
|
||||
return size;
|
||||
}
|
||||
|
||||
//报文现在被切开,发了进来,第二个字节是cmd,解析出来,在函数里处理处理数据,告诉业务层,拿到数据了干点什么。
|
||||
virtual bool dispatcher ( const QByteArray& m ) override { //message
|
||||
bool ret = true;
|
||||
|
||||
TouchMonitorMessage qMsg;
|
||||
qMsg.parser ( m );
|
||||
pline() << qMsg;
|
||||
|
||||
switch ( qMsg.cmd() ) {
|
||||
case 0x0a ://protocol command 1
|
||||
recvCommand1 ( qMsg );
|
||||
break;
|
||||
|
||||
case 0x0b ://protocol command 2
|
||||
recvCommand2 ( qMsg );
|
||||
break;
|
||||
|
||||
default:
|
||||
ret = false;
|
||||
pline() << "receive unknown command:" << hex << qMsg.cmd();
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // TOUCHMONITORPROTOCOL_H
|
@ -1,52 +0,0 @@
|
||||
#-------------------------------------------------
|
||||
#
|
||||
# Project created by QtCreator 2018-05-06T15:03:12
|
||||
#
|
||||
#-------------------------------------------------
|
||||
|
||||
QT += core gui
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
|
||||
TARGET = TouchMonitorServer
|
||||
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 += touchmonitorserverprotocol.cpp \
|
||||
controlorwidget.cpp
|
||||
HEADERS += touchmonitorserverprotocol.h \
|
||||
controlorwidget.h
|
||||
|
||||
SOURCES += \
|
||||
main.cpp \
|
||||
mainwindow.cpp \
|
||||
testwidget.cpp \
|
||||
qqtosdform.cpp
|
||||
|
||||
HEADERS += \
|
||||
mainwindow.h \
|
||||
testwidget.h \
|
||||
qqtosdform.h
|
||||
|
||||
FORMS += \
|
||||
mainwindow.ui \
|
||||
qqtosdform.ui
|
||||
|
||||
system("touch main.cpp")
|
||||
#CONFIG += deploy_config
|
||||
contains(CONFIG, deploy_config) {
|
||||
APP_CONFIG_PWD = $${PWD}/AppRoot
|
||||
equals(QMAKE_HOST.os, Windows) {
|
||||
APP_CONFIG_PWD ~=s,/,\\,g
|
||||
}
|
||||
}
|
||||
include(../../src/app_base_manager.pri)
|
@ -1,6 +0,0 @@
|
||||
#include "controlorwidget.h"
|
||||
|
||||
ControlorWidget::ControlorWidget ( QWidget* parent ) : QQtOSDWidget ( parent )
|
||||
{
|
||||
setWindowFlag ( Qt::FramelessWindowHint, true );
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
#ifndef CONTROLORWIDGET_H
|
||||
#define CONTROLORWIDGET_H
|
||||
|
||||
#include <qqtosdwidget.h>
|
||||
|
||||
class ControlorWidget : public QQtOSDWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ControlorWidget ( QWidget* parent = nullptr );
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
};
|
||||
|
||||
#endif // CONTROLORWIDGET_H
|
@ -1,27 +0,0 @@
|
||||
#include "mainwindow.h"
|
||||
#include <QQtApplication>
|
||||
#include <qqtosdwidget.h>
|
||||
#include <testwidget.h>
|
||||
#include <qqtosdform.h>
|
||||
|
||||
int main ( int argc, char* argv[] )
|
||||
{
|
||||
QQtApplication a ( argc, argv );
|
||||
|
||||
//其实功能很简单,
|
||||
//收到手机通过网络、或者蓝牙、或者USB线发来的操作信号以后,服务器进行POS转换,模拟点击。
|
||||
//起初,用于手机控制腾讯手游助手里的王者荣耀游戏。
|
||||
|
||||
MainWindow w;
|
||||
//TestWidget w;
|
||||
//macOS success
|
||||
//QQtOsdForm w;
|
||||
//macOS success
|
||||
//QQtOSDWidget w;
|
||||
w.show();
|
||||
//w.setWindowOpacity ( 1 );
|
||||
//w.setWindowFlags ( Qt::FramelessWindowHint );
|
||||
//w.setAttribute ( Qt::WA_TranslucentBackground );
|
||||
|
||||
return a.exec();
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
#include <QPainter>
|
||||
#include <qqtosdwidget.h>
|
||||
|
||||
MainWindow::MainWindow ( QWidget* parent ) :
|
||||
QMainWindow ( parent ),
|
||||
ui ( new Ui::MainWindow )
|
||||
{
|
||||
ui->setupUi ( this );
|
||||
|
||||
//QQtOSDWidget* w = new QQtOSDWidget ( 0 );
|
||||
//w->show();
|
||||
//w->setGeometry ( 0, 0, 400, 400 );
|
||||
|
||||
w0 = new ControlorWidget ( 0 );
|
||||
w0->hide();;
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void MainWindow::on_pushButton_clicked()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::on_pushButton_2_clicked()
|
||||
{
|
||||
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <controlorwidget.h>
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
}
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWindow ( QWidget* parent = 0 );
|
||||
~MainWindow();
|
||||
|
||||
private slots:
|
||||
void on_pushButton_clicked();
|
||||
|
||||
void on_pushButton_2_clicked();
|
||||
|
||||
private:
|
||||
Ui::MainWindow* ui;
|
||||
ControlorWidget* w0;
|
||||
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
@ -1,93 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>224</width>
|
||||
<height>116</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralWidget">
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>40</y>
|
||||
<width>80</width>
|
||||
<height>14</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Start</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>130</x>
|
||||
<y>40</y>
|
||||
<width>80</width>
|
||||
<height>14</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Stop</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>10</y>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>IP</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>50</x>
|
||||
<y>10</y>
|
||||
<width>161</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Server Ip</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menuBar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>224</width>
|
||||
<height>17</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QToolBar" name="mainToolBar">
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
</attribute>
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusBar"/>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
@ -1,57 +0,0 @@
|
||||
#include "qqtosdform.h"
|
||||
#include "ui_qqtosdform.h"
|
||||
#include <QPainter>
|
||||
#include <QBitmap>
|
||||
#include <qqtframelesshelper.h>
|
||||
|
||||
QQtOsdForm::QQtOsdForm ( QWidget* parent ) :
|
||||
QWidget ( parent ),
|
||||
ui ( new Ui::QQtOsdForm )
|
||||
{
|
||||
ui->setupUi ( this );
|
||||
//setStyleSheet ( "QQtOsdForm{ background-color: rgb(222, 222, 222, 0);}" );
|
||||
//setWindowFlag ( Qt::FramelessWindowHint, true );
|
||||
//setWindowFlag ( Qt::WindowStaysOnTopHint, true );
|
||||
//setWindowFlag ( Qt::Tool, true );
|
||||
setAttribute ( Qt::WA_TranslucentBackground, true );
|
||||
//setAttribute ( Qt::WA_TransparentForMouseEvents, true );
|
||||
setAttribute ( Qt::WA_OpaquePaintEvent, true );
|
||||
|
||||
QPalette pal = palette();
|
||||
pal.setColor ( QPalette::Background, QColor ( 255, 255, 255, 255 ) );
|
||||
//ignore
|
||||
//setPalette ( pal );
|
||||
|
||||
QQtFramelessHelper* frameless = new QQtFramelessHelper ( this );
|
||||
frameless->addDragWidget ( this );
|
||||
frameless->setCloseButton ( ui->pushButtonClose );
|
||||
frameless->setMaximizedButton ( ui->pushButtonMax );
|
||||
frameless->setRestoreButton ( ui->pushButtonRestore );
|
||||
frameless->setMinimizedButton ( ui->pushButtonMin, false );
|
||||
|
||||
//setWindowFlag ( Qt::FramelessWindowHint, true );
|
||||
//setWindowFlag ( Qt::CustomizeWindowHint, true );
|
||||
//setWindowFlag ( Qt::SubWindow, true );
|
||||
//setWindowFlag ( Qt::WindowSystemMenuHint, true );
|
||||
}
|
||||
|
||||
QQtOsdForm::~QQtOsdForm()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
void QQtOsdForm::paintEvent ( QPaintEvent* event )
|
||||
{
|
||||
return QWidget::paintEvent ( event );
|
||||
|
||||
//ignore
|
||||
// Use a bitmap as a mask. A bitmap only has two kind of colors: white(value is 0)
|
||||
// or black(other values). When we use it to set mask, we can see the window at the position
|
||||
// where the color value is 0, and other place will be transparent.
|
||||
QBitmap bitMap ( width(), height() ); // A bit map has the same size with current widget
|
||||
QPainter painter ( &bitMap );
|
||||
painter.setPen ( QColor ( 255, 255, 255 ) ); // Any color that is not QRgb(0,0,0) is right
|
||||
painter.drawRect ( 0, 0, width(), height() );
|
||||
setMask ( bitMap );
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
#ifndef QQTOSDFORM_H
|
||||
#define QQTOSDFORM_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ui {
|
||||
class QQtOsdForm;
|
||||
}
|
||||
|
||||
class QQtOsdForm : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit QQtOsdForm ( QWidget* parent = 0 );
|
||||
~QQtOsdForm();
|
||||
|
||||
private:
|
||||
Ui::QQtOsdForm* ui;
|
||||
|
||||
// QWidget interface
|
||||
protected:
|
||||
virtual void paintEvent ( QPaintEvent* event ) override;
|
||||
};
|
||||
|
||||
#endif // QQTOSDFORM_H
|
@ -1,79 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>QQtOsdForm</class>
|
||||
<widget class="QWidget" name="QQtOsdForm">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButtonMin">
|
||||
<property name="text">
|
||||
<string>最小化</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButtonMax">
|
||||
<property name="text">
|
||||
<string>最大化</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButtonRestore">
|
||||
<property name="text">
|
||||
<string>还原</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButtonClose">
|
||||
<property name="text">
|
||||
<string>关闭</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>259</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
@ -1,39 +0,0 @@
|
||||
#include "testwidget.h"
|
||||
#include <QPainter>
|
||||
#include <QBitmap>
|
||||
|
||||
TestWidget::TestWidget ( QWidget* parent ) : QWidget ( parent )
|
||||
{
|
||||
//setAttribute ( Qt::WA_TranslucentBackground, true );
|
||||
//setAttribute ( Qt::WA_OpaquePaintEvent, true );
|
||||
//QPalette pal = palette();
|
||||
//pal.setColor ( QPalette::Background, QColor ( 255, 0, 0, 200 ) );
|
||||
//setPalette ( pal );
|
||||
//setStyleSheet ( "background:transparent" );
|
||||
|
||||
}
|
||||
void TestWidget::paintEvent ( QPaintEvent* event )
|
||||
{
|
||||
|
||||
//return QWidget::paintEvent ( event );
|
||||
|
||||
//QPainter painter ( this );
|
||||
//painter.fillRect ( this->rect(), QColor ( 0, 0, 255, 80 ) );
|
||||
|
||||
//QPainter p ( this );
|
||||
//p.setCompositionMode ( QPainter::CompositionMode_Clear );
|
||||
//p.fillRect ( 10, 10, 300, 300, Qt::SolidPattern );
|
||||
}
|
||||
|
||||
|
||||
void TestWidget::resizeEvent ( QResizeEvent* event )
|
||||
{
|
||||
// Use a bitmap as a mask. A bitmap only has two kind of colors: white(value is 0)
|
||||
// or black(other values). When we use it to set mask, we can see the window at the position
|
||||
// where the color value is 0, and other place will be transparent.
|
||||
QBitmap bitMap ( width(), height() ); // A bit map has the same size with current widget
|
||||
QPainter painter ( &bitMap );
|
||||
painter.setPen ( QColor ( 0, 0, 0 ) ); // Any color that is not QRgb(0,0,0) is right
|
||||
painter.drawRect ( 0, 0, width(), height() );
|
||||
setMask ( bitMap );
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
#ifndef TESTWIDGET_H
|
||||
#define TESTWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <qqtcore.h>
|
||||
|
||||
class TestWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit TestWidget ( QWidget* parent = nullptr );
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
// QWidget interface
|
||||
protected:
|
||||
virtual void paintEvent ( QPaintEvent* event ) override;
|
||||
|
||||
// QWidget interface
|
||||
protected:
|
||||
virtual void resizeEvent ( QResizeEvent* event ) override;
|
||||
};
|
||||
|
||||
#endif // TESTWIDGET_H
|
@ -1,39 +0,0 @@
|
||||
#include "touchmonitorserverprotocol.h"
|
||||
|
||||
QDebug& operator << ( QDebug& dbg, const TouchMonitorServerMessage& msg )
|
||||
{
|
||||
//这里打印一下,报文里面到底有什么信息,
|
||||
//一般到这里的,都是被解析好的message。
|
||||
|
||||
dbg.nospace() << "{" << hex << msg.size() << "}";
|
||||
return dbg.space();
|
||||
}
|
||||
|
||||
QQtTcpServer* TouchMonitorServerInstance ( QQtProtocolManager*& protocolManager, QObject* parent )
|
||||
{
|
||||
static QQtProtocolManager* m0 = 0;
|
||||
if ( !m0 )
|
||||
{
|
||||
//创建Protocol管理者
|
||||
m0 = new QQtProtocolManager ( parent );
|
||||
//注册我实现的Protocol
|
||||
m0->registerProtocol<TouchMonitorServerProtocol> ( );
|
||||
//初始化Protocol管理者完成。
|
||||
}
|
||||
protocolManager = m0;
|
||||
|
||||
static QQtTcpServer* s0 = 0;
|
||||
if ( !s0 )
|
||||
{
|
||||
//新建服务器
|
||||
s0 = new QQtTcpServer ( parent );
|
||||
//安装协议管理者
|
||||
s0->installProtocolManager ( m0 );
|
||||
//开始监听
|
||||
s0->listen ( QHostAddress::Any, 8001 );
|
||||
//服务器初始化完成。
|
||||
}
|
||||
|
||||
//等待客户端发消息过来,Protocol就处理了,去业务层看看。
|
||||
return s0;
|
||||
}
|
@ -1,131 +0,0 @@
|
||||
#ifndef TOUCHMONITORSERVERPROTOCOL_H
|
||||
#define TOUCHMONITORSERVERPROTOCOL_H
|
||||
|
||||
#include <qqtmessage.h>
|
||||
#include <qqtprotocol.h>
|
||||
#include <qqtprotocolmanager.h>
|
||||
#include <qqttcpserver.h>
|
||||
|
||||
class TouchMonitorServerMessage : public QQtMessage
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit TouchMonitorServerMessage ( QObject* parent = nullptr ) {
|
||||
mSize = 0x03;//报文定长
|
||||
}
|
||||
~TouchMonitorServerMessage() {
|
||||
|
||||
}
|
||||
|
||||
quint8& size() { return mSize; }
|
||||
const quint8& size() const { return mSize; }
|
||||
quint8& cmd() { return mCmd; }
|
||||
const quint8& cmd() const { return mCmd; }
|
||||
quint8& data() { return mData; }
|
||||
const quint8& data() const { return mData; }
|
||||
|
||||
private:
|
||||
//格式
|
||||
//|quint8 size|quint8 cmd|quint8 data|
|
||||
quint8 mSize;
|
||||
quint8 mCmd;
|
||||
quint8 mData;
|
||||
|
||||
// QQtMessage interface
|
||||
public:
|
||||
//把报文这条流解析出字段
|
||||
virtual void parser ( const QByteArray& l ) override {
|
||||
QByteArray _l = l;
|
||||
_l >> mSize;
|
||||
_l >> mCmd;
|
||||
_l >> mData;
|
||||
}
|
||||
//把报文字段组装成流
|
||||
virtual void packer ( QByteArray& l ) const override {
|
||||
l << mSize;
|
||||
l << mCmd;
|
||||
l << mData;
|
||||
}
|
||||
};
|
||||
|
||||
QDebug& operator << ( QDebug& dbg, const TouchMonitorServerMessage& msg );
|
||||
|
||||
//业务层总是用这个协议工作,读来到的,写出去的。
|
||||
class TouchMonitorServerProtocol : public QQtProtocol
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit TouchMonitorServerProtocol ( QObject* parent = nullptr ) {
|
||||
|
||||
}
|
||||
~TouchMonitorServerProtocol() {
|
||||
|
||||
}
|
||||
|
||||
//收到外部发来的很多命令,处理一下告诉业务层干点什么。
|
||||
void recvCommand1 ( const TouchMonitorServerMessage& msg ) {
|
||||
//what do you want to do?
|
||||
}
|
||||
void recvCommand2 ( const TouchMonitorServerMessage& msg ) {
|
||||
//what do you want to do?
|
||||
}
|
||||
|
||||
void sendCommand1() {
|
||||
//what do you want to do?
|
||||
}
|
||||
|
||||
signals:
|
||||
//给业务层发的信号
|
||||
void signalSendtoLogicLevelCode();
|
||||
|
||||
public slots:
|
||||
|
||||
// QQtProtocol interface
|
||||
protected:
|
||||
//报文的最小长度
|
||||
virtual quint16 minlength() override {
|
||||
return 0x0a;
|
||||
}
|
||||
//报文的最大长度
|
||||
virtual quint16 maxlength() override {
|
||||
return 0x07FF;
|
||||
}
|
||||
//报文现在在流里,第一个字节,就是size,读出来,通过返回值告诉QQtProtocol
|
||||
virtual quint16 splitter ( const QByteArray& l ) override { //stream
|
||||
QByteArray s0 = l.left ( 1 );
|
||||
quint8 size = 0;
|
||||
s0 >> size;
|
||||
return size;
|
||||
}
|
||||
|
||||
//报文现在被切开,发了进来,第二个字节是cmd,解析出来,在函数里处理处理数据,告诉业务层,拿到数据了干点什么。
|
||||
virtual bool dispatcher ( const QByteArray& m ) override { //message
|
||||
bool ret = true;
|
||||
|
||||
TouchMonitorServerMessage qMsg;
|
||||
qMsg.parser ( m );
|
||||
pline() << qMsg;
|
||||
|
||||
switch ( qMsg.cmd() ) {
|
||||
case 0x0a://protocol command 1
|
||||
recvCommand1 ( qMsg );
|
||||
break;
|
||||
|
||||
case 0x0b://protocol command 2
|
||||
recvCommand2 ( qMsg );
|
||||
break;
|
||||
|
||||
default:
|
||||
ret = false;
|
||||
pline() << "receive unknown command:" << hex << qMsg.cmd();
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
//用户使用这里的ProtocolManager进行必要的和客户端的通信。一般在TouchMonitorServerProtocol里面解决。
|
||||
QQtTcpServer* TouchMonitorServerInstance ( QQtProtocolManager*& protocolManager, QObject* parent );
|
||||
|
||||
#endif // TOUCHMONITORSERVERPROTOCOL_H
|
Loading…
x
Reference in New Issue
Block a user