From a25f07cc391fc4a678cbe375943564b9e51ef51e Mon Sep 17 00:00:00 2001 From: feiyangqingyun Date: Sun, 10 Oct 2021 09:57:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- framelesswidget/framelesswidget2.cpp | 5 + framelesswidget/framelesswidget2.h | 2 + ipaddress/ipaddress.cpp | 18 +- moneytool/moneytool.pro | 2 +- netserver/api/appconfig.cpp | 27 ++- netserver/form/frmmain.cpp | 2 +- netserver/form/frmmain.ui | 333 ++++++++++++++++----------- netserver/main.cpp | 2 +- qwtdemo/qwt/qwt_compass_rose.cpp | 5 +- qwtdemo/qwt/qwt_dial_needle.cpp | 7 +- qwtdemo/qwt/qwt_null_paintdevice.cpp | 4 +- qwtdemo/qwt/qwt_painter.cpp | 3 +- qwtdemo/qwt/qwt_painter_command.h | 3 +- qwtdemo/qwt/qwt_plot_panner.cpp | 3 +- qwtdemo/qwt/qwt_plot_renderer.cpp | 4 +- qwtdemo/qwt/qwt_widget_overlay.cpp | 3 +- 16 files changed, 259 insertions(+), 164 deletions(-) diff --git a/framelesswidget/framelesswidget2.cpp b/framelesswidget/framelesswidget2.cpp index 8e19985..f31af66 100644 --- a/framelesswidget/framelesswidget2.cpp +++ b/framelesswidget/framelesswidget2.cpp @@ -204,6 +204,11 @@ void FramelessWidget2::setResizeEnable(bool resizeEnable) this->resizeEnable = resizeEnable; } +void FramelessWidget2::setMousePressed(bool mousePressed) +{ + this->mousePressed = mousePressed; +} + void FramelessWidget2::setWidget(QWidget *widget) { if (this->widget == 0) { diff --git a/framelesswidget/framelesswidget2.h b/framelesswidget/framelesswidget2.h index a332161..ac7c874 100644 --- a/framelesswidget/framelesswidget2.h +++ b/framelesswidget/framelesswidget2.h @@ -56,6 +56,8 @@ public Q_SLOTS: //设置是否可拖动+拉伸 void setMoveEnable(bool moveEnable); void setResizeEnable(bool resizeEnable); + //修复部分控件不能自动识别 MouseButtonRelease 的BUG + void setMousePressed(bool mousePressed); //设置要无边框的窗体 void setWidget(QWidget *widget); diff --git a/ipaddress/ipaddress.cpp b/ipaddress/ipaddress.cpp index 2338ea6..24c889e 100644 --- a/ipaddress/ipaddress.cpp +++ b/ipaddress/ipaddress.cpp @@ -4,12 +4,10 @@ #include "qlabel.h" #include "qlineedit.h" #include "qboxlayout.h" +#include "qregexp.h" #include "qvalidator.h" #include "qevent.h" #include "qdebug.h" -#if (QT_VERSION < QT_VERSION_CHECK(6,0,0)) -#include "qregexp.h" -#endif IPAddress::IPAddress(QWidget *parent) : QWidget(parent) { @@ -55,15 +53,21 @@ IPAddress::IPAddress(QWidget *parent) : QWidget(parent) txtIP4->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); connect(txtIP4, SIGNAL(textChanged(QString)), this, SLOT(textChanged(QString))); -#if (QT_VERSION < QT_VERSION_CHECK(6,0,0)) //设置IP地址校验过滤 - QRegExp regExp("(2[0-5]{2}|2[0-4][0-9]|1?[0-9]{1,2})"); + QString pattern = "(2[0-5]{2}|2[0-4][0-9]|1?[0-9]{1,2})"; + //确切的说 QRegularExpression QRegularExpressionValidator 从5.0 5.1开始就有 +#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0)) + QRegularExpression regExp(pattern); + QRegularExpressionValidator *validator = new QRegularExpressionValidator(regExp, this); +#else + QRegExp regExp(pattern); QRegExpValidator *validator = new QRegExpValidator(regExp, this); +#endif + txtIP1->setValidator(validator); txtIP2->setValidator(validator); txtIP3->setValidator(validator); txtIP4->setValidator(validator); -#endif //绑定事件过滤器,识别键盘按下 txtIP1->installEventFilter(this); @@ -157,13 +161,11 @@ QSize IPAddress::minimumSizeHint() const void IPAddress::setIP(const QString &ip) { -#if (QT_VERSION < QT_VERSION_CHECK(6,0,0)) //先检测IP地址是否合法 QRegExp regExp("((2[0-4]\\d|25[0-5]|[01]?\\d\\d?)\\.){3}(2[0-4]\\d|25[0-5]|[01]?\\d\\d?)"); if (!regExp.exactMatch(ip)) { return; } -#endif if (this->ip != ip) { this->ip = ip; diff --git a/moneytool/moneytool.pro b/moneytool/moneytool.pro index 0502909..fb85fcc 100644 --- a/moneytool/moneytool.pro +++ b/moneytool/moneytool.pro @@ -2,7 +2,7 @@ QT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets greaterThan(QT_MAJOR_VERSION, 5): QT += core5compat -TARGET = mouseline +TARGET = moneytool TEMPLATE = app DESTDIR = $$PWD/../bin CONFIG += warn_off diff --git a/netserver/api/appconfig.cpp b/netserver/api/appconfig.cpp index 1f84b5b..59be10c 100644 --- a/netserver/api/appconfig.cpp +++ b/netserver/api/appconfig.cpp @@ -7,6 +7,7 @@ int AppConfig::ListenPort1 = 6907; int AppConfig::CmdStart1 = 76; int AppConfig::CmdLen1 = 12; bool AppConfig::HexData1 = false; + int AppConfig::ListenPort2 = 6908; int AppConfig::CmdStart2 = 76; int AppConfig::CmdLen2 = 12; @@ -16,15 +17,18 @@ void AppConfig::readConfig() { QSettings set(AppConfig::ConfigFile, QSettings::IniFormat); - set.beginGroup("AppConfig"); - AppConfig::ListenPort1 = set.value("ListenPort1").toInt(); - AppConfig::CmdStart1 = set.value("CmdStart1").toInt(); - AppConfig::CmdLen1 = set.value("CmdLen1").toInt(); - AppConfig::HexData1 = set.value("HexData1").toBool(); - AppConfig::ListenPort2 = set.value("ListenPort2").toInt(); - AppConfig::CmdStart2 = set.value("CmdStart2").toInt(); - AppConfig::CmdLen2 = set.value("CmdLen2").toInt(); - AppConfig::HexData2 = set.value("HexData2").toBool(); + set.beginGroup("AppConfig1"); + AppConfig::ListenPort1 = set.value("ListenPort1", AppConfig::ListenPort1).toInt(); + AppConfig::CmdStart1 = set.value("CmdStart1", AppConfig::CmdStart1).toInt(); + AppConfig::CmdLen1 = set.value("CmdLen1", AppConfig::CmdLen1).toInt(); + AppConfig::HexData1 = set.value("HexData1", AppConfig::HexData1).toBool(); + set.endGroup(); + + set.beginGroup("AppConfig2"); + AppConfig::ListenPort2 = set.value("ListenPort2", AppConfig::ListenPort2).toInt(); + AppConfig::CmdStart2 = set.value("CmdStart2", AppConfig::CmdStart2).toInt(); + AppConfig::CmdLen2 = set.value("CmdLen2", AppConfig::CmdLen2).toInt(); + AppConfig::HexData2 = set.value("HexData2", AppConfig::HexData2).toBool(); set.endGroup(); //配置文件不存在或者不全则重新生成 @@ -38,11 +42,14 @@ void AppConfig::writeConfig() { QSettings set(AppConfig::ConfigFile, QSettings::IniFormat); - set.beginGroup("AppConfig"); + set.beginGroup("AppConfig1"); set.setValue("ListenPort1", AppConfig::ListenPort1); set.setValue("CmdStart1", AppConfig::CmdStart1); set.setValue("CmdLen1", AppConfig::CmdLen1); set.setValue("HexData1", AppConfig::HexData1); + set.endGroup(); + + set.beginGroup("AppConfig2"); set.setValue("ListenPort2", AppConfig::ListenPort2); set.setValue("CmdStart2", AppConfig::CmdStart2); set.setValue("CmdLen2", AppConfig::CmdLen2); diff --git a/netserver/form/frmmain.cpp b/netserver/form/frmmain.cpp index 1518348..03e7e7b 100644 --- a/netserver/form/frmmain.cpp +++ b/netserver/form/frmmain.cpp @@ -37,7 +37,7 @@ void frmMain::initConfig() { ui->txtListenPort1->setText(QString::number(AppConfig::ListenPort1)); connect(ui->txtListenPort1, SIGNAL(textChanged(QString)), this, SLOT(saveConfig())); - +qDebug()<txtListenPort2->setText(QString::number(AppConfig::ListenPort2)); connect(ui->txtListenPort2, SIGNAL(textChanged(QString)), this, SLOT(saveConfig())); } diff --git a/netserver/form/frmmain.ui b/netserver/form/frmmain.ui index 461f9fb..123d652 100644 --- a/netserver/form/frmmain.ui +++ b/netserver/form/frmmain.ui @@ -13,139 +13,208 @@ Form - - - - - true + + + 0 + + + 0 + + + 0 + + + 0 + + + + + 0 - - - - - - - 250 - 16777215 - - - - QFrame::Box - - - QFrame::Sunken - - - - - - - - - - - - 清空 - - - - - - - 监听 - - - - - - - - 0 - 25 - - - - QFrame::Box - - - QFrame::Sunken - - - 共 0 个连接 - - - Qt::AlignCenter - - - - - - - - - - true - - - - - - - - 250 - 16777215 - - - - QFrame::Box - - - QFrame::Sunken - - - - - - 监听 - - - - - - - - - - 清空 - - - - - - - - - - - 0 - 25 - - - - QFrame::Box - - - QFrame::Sunken - - - 共 0 个连接 - - - Qt::AlignCenter - - - - + + + 服务器1 + + + + 6 + + + 6 + + + 6 + + + 6 + + + + + true + + + + + + + + 230 + 16777215 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + + 清空 + + + + + + + 监听 + + + + + + + + 0 + 25 + + + + QFrame::Box + + + QFrame::Sunken + + + 共 0 个连接 + + + Qt::AlignCenter + + + + + + + + + + + 服务器2 + + + + 6 + + + 6 + + + 6 + + + 6 + + + + + true + + + + + + + + 230 + 16777215 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + 监听 + + + + + + + + + + 清空 + + + + + + + + + + + 0 + 25 + + + + QFrame::Box + + + QFrame::Sunken + + + 共 0 个连接 + + + Qt::AlignCenter + + + + + + + + diff --git a/netserver/main.cpp b/netserver/main.cpp index 8c167af..ba25600 100644 --- a/netserver/main.cpp +++ b/netserver/main.cpp @@ -21,7 +21,7 @@ int main(int argc, char *argv[]) AppConfig::readConfig(); frmMain w; - w.setWindowTitle(QString("网络中转服务器V2018 本机IP: %1 QQ: 517216493").arg(QUIHelper::getLocalIP())); + w.setWindowTitle(QString("网络中转服务器V2021 本机IP: %1 QQ: 517216493").arg(QUIHelper::getLocalIP())); w.show(); return a.exec(); diff --git a/qwtdemo/qwt/qwt_compass_rose.cpp b/qwtdemo/qwt/qwt_compass_rose.cpp index 05f7039..fe54c9b 100644 --- a/qwtdemo/qwt/qwt_compass_rose.cpp +++ b/qwtdemo/qwt/qwt_compass_rose.cpp @@ -1,4 +1,4 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** +/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** * Qwt Widget Library * Copyright (C) 1997 Josef Wilgen * Copyright (C) 2002 Uwe Rathmann @@ -10,7 +10,8 @@ #include "qwt_compass_rose.h" #include "qwt_point_polar.h" #include "qwt_painter.h" -#include +#include "qpainterpath.h" +#include "qpainter.h" static QPointF qwtIntersection( QPointF p11, QPointF p12, QPointF p21, QPointF p22 ) diff --git a/qwtdemo/qwt/qwt_dial_needle.cpp b/qwtdemo/qwt/qwt_dial_needle.cpp index 49dd44a..8f2305b 100644 --- a/qwtdemo/qwt/qwt_dial_needle.cpp +++ b/qwtdemo/qwt/qwt_dial_needle.cpp @@ -1,4 +1,4 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** +/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** * Qwt Widget Library * Copyright (C) 1997 Josef Wilgen * Copyright (C) 2002 Uwe Rathmann @@ -11,8 +11,9 @@ #include "qwt_global.h" #include "qwt_math.h" #include "qwt_painter.h" -#include -#include +#include "qapplication.h" +#include "qpainterpath.h" +#include "qpainter.h" #if QT_VERSION < 0x040601 #define qFastSin(x) qSin(x) diff --git a/qwtdemo/qwt/qwt_null_paintdevice.cpp b/qwtdemo/qwt/qwt_null_paintdevice.cpp index 3baf0e9..6450139 100644 --- a/qwtdemo/qwt/qwt_null_paintdevice.cpp +++ b/qwtdemo/qwt/qwt_null_paintdevice.cpp @@ -1,4 +1,4 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** +/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** * Qwt Widget Library * Copyright (C) 1997 Josef Wilgen * Copyright (C) 2002 Uwe Rathmann @@ -10,6 +10,8 @@ #include "qwt_null_paintdevice.h" #include #include +#include "qpainterpath.h" +#include "qpainter.h" class QwtNullPaintDevice::PrivateData { diff --git a/qwtdemo/qwt/qwt_painter.cpp b/qwtdemo/qwt/qwt_painter.cpp index 7959fe5..87883cc 100644 --- a/qwtdemo/qwt/qwt_painter.cpp +++ b/qwtdemo/qwt/qwt_painter.cpp @@ -1,4 +1,4 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** +/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** * Qwt Widget Library * Copyright (C) 1997 Josef Wilgen * Copyright (C) 2002 Uwe Rathmann @@ -27,6 +27,7 @@ #include #include #include +#include #if QT_VERSION >= 0x050000 #include diff --git a/qwtdemo/qwt/qwt_painter_command.h b/qwtdemo/qwt/qwt_painter_command.h index a2f509a..ca0658f 100644 --- a/qwtdemo/qwt/qwt_painter_command.h +++ b/qwtdemo/qwt/qwt_painter_command.h @@ -1,4 +1,4 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** +/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** * Qwt Widget Library * Copyright (C) 1997 Josef Wilgen * Copyright (C) 2002 Uwe Rathmann @@ -15,6 +15,7 @@ #include #include #include +#include class QPainterPath; diff --git a/qwtdemo/qwt/qwt_plot_panner.cpp b/qwtdemo/qwt/qwt_plot_panner.cpp index b7daa05..8b15fae 100644 --- a/qwtdemo/qwt/qwt_plot_panner.cpp +++ b/qwtdemo/qwt/qwt_plot_panner.cpp @@ -1,4 +1,4 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** +/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** * Qwt Widget Library * Copyright (C) 1997 Josef Wilgen * Copyright (C) 2002 Uwe Rathmann @@ -14,6 +14,7 @@ #include #include #include +#include #if QT_VERSION >= 0x050000 #if QT_VERSION < 0x050100 diff --git a/qwtdemo/qwt/qwt_plot_renderer.cpp b/qwtdemo/qwt/qwt_plot_renderer.cpp index 549c4bc..925cf40 100644 --- a/qwtdemo/qwt/qwt_plot_renderer.cpp +++ b/qwtdemo/qwt/qwt_plot_renderer.cpp @@ -1,4 +1,4 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** +/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** * Qwt Widget Library * Copyright (C) 1997 Josef Wilgen * Copyright (C) 2002 Uwe Rathmann @@ -71,6 +71,8 @@ #include #endif +#include + static QPainterPath qwtCanvasClip( const QWidget* canvas, const QRectF &canvasRect ) { diff --git a/qwtdemo/qwt/qwt_widget_overlay.cpp b/qwtdemo/qwt/qwt_widget_overlay.cpp index 5974413..188b9b5 100644 --- a/qwtdemo/qwt/qwt_widget_overlay.cpp +++ b/qwtdemo/qwt/qwt_widget_overlay.cpp @@ -1,4 +1,4 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** +/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** * Qwt Widget Library * Copyright (C) 1997 Josef Wilgen * Copyright (C) 2002 Uwe Rathmann @@ -13,6 +13,7 @@ #include #include #include +#include static QImage::Format qwtMaskImageFormat() {