整理删除多余商业残留代码

This commit is contained in:
爬山虎 2022-10-27 11:10:56 +08:00
parent 713701bbfb
commit 4b5e531093
17 changed files with 22 additions and 1224 deletions

View File

@ -1,35 +0,0 @@
#include "alignwin.h"
AlignWin::AlignWin(QWidget *parent)
: QWidget(parent)
{
ui.setupUi(this);
}
AlignWin::~AlignWin()
{}
void AlignWin::slot_ok()
{
bool ok = true;
bool ok1 = true;
int leftStart = ui.leftStart->text().toInt(&ok) - 1;
int leftEnd = ui.leftEnd->text().toInt(&ok1) - 1;
if(!ok || !ok1)
{
return;
}
if((leftStart < 0) || (leftStart > leftEnd))
{
return;
}
int type = 0;
//0最简单的两边错开分别单独显示对方一侧做对齐行展示
emit alignLine(type, leftStart, leftEnd);
close();
}

View File

@ -1,21 +0,0 @@
#pragma once
#include <QWidget>
#include "ui_alignwin.h"
class AlignWin : public QWidget
{
Q_OBJECT
public:
AlignWin(QWidget *parent = nullptr);
~AlignWin();
signals:
void alignLine(int type, int start, int end);
private slots:
void slot_ok();
private:
Ui::AlignWinClass ui;
};

View File

@ -1,181 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AlignWinClass</class>
<widget class="QWidget" name="AlignWinClass">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>136</height>
</rect>
</property>
<property name="maximumSize">
<size>
<width>400</width>
<height>150</height>
</size>
</property>
<property name="windowTitle">
<string>Pull Open</string>
</property>
<property name="windowIcon">
<iconset resource="RealCompare.qrc">
<normaloff>:/Resources/img/main.png</normaloff>:/Resources/img/main.png</iconset>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="maximumSize">
<size>
<width>400</width>
<height>150</height>
</size>
</property>
<property name="title">
<string>Pull Open Line Set</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Pull out the section with insufficient comparison results.</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Start LineNum:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="leftStart">
<property name="maxLength">
<number>11</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>End LineNum:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="leftEnd">
<property name="maxLength">
<number>11</number>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<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="pushButton">
<property name="text">
<string>Ok</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<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="pushButton_2">
<property name="text">
<string>Close</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources>
<include location="RealCompare.qrc"/>
</resources>
<connections>
<connection>
<sender>pushButton</sender>
<signal>clicked()</signal>
<receiver>AlignWinClass</receiver>
<slot>slot_ok()</slot>
<hints>
<hint type="sourcelabel">
<x>132</x>
<y>78</y>
</hint>
<hint type="destinationlabel">
<x>158</x>
<y>106</y>
</hint>
</hints>
</connection>
<connection>
<sender>pushButton_2</sender>
<signal>clicked()</signal>
<receiver>AlignWinClass</receiver>
<slot>close()</slot>
<hints>
<hint type="sourcelabel">
<x>301</x>
<y>83</y>
</hint>
<hint type="destinationlabel">
<x>353</x>
<y>110</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>slot_ok()</slot>
</slots>
</ui>

View File

@ -14,7 +14,6 @@
#include "hexfilegoto.h"
#include "qscilexertext.h"
#include "styleset.h"
#include "userregister.h"
#include "qtlangset.h"
#include "columnedit.h"
@ -5443,11 +5442,7 @@ void CCNotePad::slot_toMistyRose()
//获取注册码
void CCNotePad::slot_register()
{
UserRegister* pWin = new UserRegister(this);
pWin->setAttribute(Qt::WA_DeleteOnClose);
connect(pWin, &UserRegister::signSendRegisterKey, this, &CCNotePad::signSendRegisterKey);
connect(this, &CCNotePad::signRegisterReplay, pWin, &UserRegister::slot_registerReplay);
pWin->exec();
}
void CCNotePad::slot_langFormat()

View File

@ -1,5 +1,4 @@
#include "jsondeploy.h"
#include "netregister.h"
#include <QObject>
#include <QJsonObject>
#include <QtDebug>
@ -13,7 +12,7 @@
//替换JsonDeploy.h的类。不使用数据库直接写一个文件就行。
static int version_num = 24;
//数据库文件是否存在。如果初始化失败,则不存在
bool JsonDeploy::s_isExistDb = false;
@ -261,49 +260,24 @@ void JsonDeploy::init()
#endif
#endif
QString str;
addKeyValueToLongSets("recentdir", str);
addKeyValueToLongSets("recentfile", str);
addKeyValueToLongSets("recentopenfile", str);
//是否对比隐藏文件
addKeyValueToNumSets("cmphidefile", 0);
//对比所有类型文件1; 2 只对比已知支持的文件类型
addKeyValueToNumSets("cmpallfile", 1);
//tab的长度默认为4
addKeyValueToNumSets("tablens", 4);
//space replace tab空格替换tab默认1为true,0为false
addKeyValueToNumSets("tabnouse", 1);
//网络回复回来的消息id
addKeyValueToNumSets("msgid", 1);
addKeyValueToSets("url", "0");
addKeyValueToSets("mac", "0");
addKeyValueToNumSets("padtimes", 0);
addKeyValueToNumSets("serverip", 0);
//hex下lcs和一对一对比模式
addKeyValueToNumSets("hexmode", 1);
//是否高亮不同处背景
addKeyValueToNumSets("hexhigh", 1);
//是否高亮不同处背景
addKeyValueToNumSets("version", version_num);
//目录对比模式0慢1快。默认慢速
addKeyValueToNumSets("dirmode", 0);
//跳过目录。默认不跳过0 不跳过 1 跳过
addKeyValueToNumSets("isskipdir", 0);
addKeyValueToSets("skipdir", ".svn:.vs");
//跳过文件后缀。默认不跳过0 不跳过 1 跳过
addKeyValueToNumSets("isskipext", 0);
addKeyValueToSets("skipext", ".sln:.vcxproj");
//跳过文件后缀。默认不跳过0 不跳过 1 跳过
addKeyValueToNumSets("isskipprefix", 0);
addKeyValueToSets("skipprefix", "ui_");
//皮肤id
addKeyValueToNumSets(SKIN_KEY, 1);

View File

@ -259,7 +259,7 @@ int main(int argc, char *argv[])
shared.create(32);
#elif defined (Q_OS_MAC)
{
//mac下面不需要有他自身的机制保证。当程序已经在时,再打开程序,系统会自动调用已经存在的程序出现
//mac下面不需要有他自身的机制保证。当程序已经在线时,再打开程序,系统会自动调用已经存在的程序出现
//不需要使用类似linux下面的机制。
shared.create(32);
nppShared.create(32);
@ -292,13 +292,17 @@ drop_old:
pMainNotepad->setShareMem(&shared);
pMainNotepad->show();
pMainNotepad->syncCurSkinToMenu(id);
//这里不能给parent否则会导致父子对象不在同一个线程的错误
NetRegister *pNetReg = new NetRegister(nullptr);
#ifdef uos
QFont font("Noto Sans CJK JP,9,-1,5,50,0,0,0,0,0,Regular", 9);
QApplication::setFont(font);
#endif
#ifdef Q_OS_MAC
//这里的字体大小,务必要和查找结果框的高度匹配,否则会结构字体拥挤
QFont font("Courier New,11,-1,5,50,0,0,0,0,0,Regular", 11);
QApplication::setFont(font);
#endif
#ifdef Q_OS_WIN
//HWND hwnd = ::FindWindowA("Qt5QWindowIcon", "CCNotebook");

View File

@ -1,214 +0,0 @@
#include "netregister.h"
#include "jsondeploy.h"
#include "donate.h"
#include "doctypelistview.h"
#include "rcglobal.h"
#include <QNetworkInterface>
#include <QFontDatabase>
#include <qmessagebox.h>
#include <QTimer>
//5 1.3
//6 1.4 20211027日
#define uos
#if defined(Q_OS_MAC)
#undef uos
#endif
#if defined(Q_OS_WIN)
#undef uos
#endif
#ifdef uos
QString loadFontFromFile(QString path,int code)
{
QString font;
static QMap<int,QString> codelist;
if(codelist.contains(code))
{
return codelist.value(code);
}
int loadedFontID = QFontDatabase::addApplicationFont(path);
QStringList loadedFontFamilies = QFontDatabase::applicationFontFamilies(loadedFontID);
if(!loadedFontFamilies.empty())
{
if ((code == 0) && loadedFontFamilies.size() >=7)
{
font = loadedFontFamilies.at(6);
}
else
{
font = loadedFontFamilies.at(0);
}
}
codelist.insert(code,font);
return font;
}
#endif
RC_LINE_FORM getLineEndType(QString line)
{
if (line.endsWith("\r\n"))
{
return DOS_LINE;
}
else if (line.endsWith("\n"))
{
return UNIX_LINE;
}
else if (line.endsWith("\r"))
{
return MAC_LINE;
}
return UNKNOWN_LINE;
}
RC_LINE_FORM getLineEndType(const LineNode& lines)
{
if (lines.lineText.isEmpty())
{
return UNKNOWN_LINE;
}
return getLineEndType((lines.lineText.last().text));
}
NetRegister::NetRegister(QObject *parent): QObject(parent)
{
#ifdef uos
//QString fontName = loadFontFromFile("/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc",0);
QFont font("Noto Sans CJK JP,9,-1,5,50,0,0,0,0,0,Regular",9);
//qDebug() << "font name uos" << fontName;
QApplication::setFont(font);
#endif
#ifdef Q_OS_MAC
//这里的字体大小,务必要和查找结果框的高度匹配,否则会结构字体拥挤
QFont font("Courier New,11,-1,5,50,0,0,0,0,0,Regular",11);
// qDebug() << "font name mac";
QApplication::setFont(font);
// qDebug() << QApplication::font().toString();
#endif
#ifdef Q_OS_WIN
#if 0 //不在这里做了,避免影响启动速度。也不方便弹出消息
QFont srcFont = QApplication::font();
//qDebug() << QApplication::font().toString();
//win11发现字体是楷体。检测并设置一下
if (QString("SimSun") != srcFont.family())
{
if (!setAppFont(QString("SimSun")))
{
if (!setAppFont(QString("Courier")))
{
if (!setAppFont(QString("Times New Roman")))
{
//让用户安装字体。这里可以弹出qmessage,这里还是在主线程中
QMessageBox::warning(nullptr, tr("Font Lost"), tr("Please Install System Font [Courier/SimSun/Times New Roman].The interface font will display exceptions"));
}
}
}
}
#endif
#endif
//qDebug() << QApplication::font().toString();
JsonDeploy::init();
}
//退出做回收工作。通知socket停止监听
void NetRegister::quit()
{
JsonDeploy::close();
}
NetRegister::~NetRegister()
{
quit();
}
QStringList NetRegister::getLocalMac()
{
QStringList mac_list;
QString strMac;
QList<QNetworkInterface> ifaces = QNetworkInterface::allInterfaces();
for (int i = 0; i < ifaces.count(); i++)
{
QNetworkInterface iface = ifaces.at(i);
//过滤掉本地回环地址、没有开启的地址
if (iface.flags().testFlag(QNetworkInterface::IsUp) && \
iface.flags().testFlag(QNetworkInterface::IsRunning) && \
iface.flags().testFlag(QNetworkInterface::CanBroadcast) && \
!iface.flags().testFlag(QNetworkInterface::IsLoopBack))
{
//过滤掉虚拟地址
if (!(iface.humanReadableName().contains("VMware", Qt::CaseInsensitive)))
{
strMac = iface.hardwareAddress();
if (!strMac.isEmpty() && strMac.compare("00:00:00:00:00:00") != 0)
{
strMac.replace(":", "");
mac_list.append(strMac);
break;
}
}
}
}
//实在没有找到合适的,就放宽条件选第一个
if (mac_list.isEmpty() && !ifaces.isEmpty())
{
for (int i = 0; i < ifaces.count(); i++)
{
QNetworkInterface iface = ifaces.at(i);
//过滤掉本地回环地址、没有开启的地址
if (!iface.flags().testFlag(QNetworkInterface::IsLoopBack))
{
//过滤掉虚拟地址
if (!(iface.humanReadableName().contains("VMware", Qt::CaseInsensitive)))
{
strMac = iface.hardwareAddress();
if (!strMac.isEmpty() && strMac.compare("00:00:00:00:00:00") != 0)
{
strMac.replace(":", "");
mac_list.append(strMac);
break;
}
}
}
}
}
return mac_list;
}
QString NetRegister::getLocalFirstMac()
{
QString key("mac");
QString v = JsonDeploy::getKeyValueFromSets(key);
if (v.isEmpty() || v == "0")
{
QStringList macList = getLocalMac();
if (!macList.isEmpty())
{
JsonDeploy::updataKeyValueFromSets(key, macList[0]);
return macList[0];
}
return QString();
}
return v;
}

View File

@ -1,35 +0,0 @@
#pragma once
#include <QObject>
#include <QLabel>
class CompareDirs;
class CompareWin;
class chatSocket;
#if defined(Q_OS_MAC)
const int VERIFY_CODE = 12;
#elif defined(Q_OS_UNIX)
const int VERIFY_CODE = 9;
#elif defined(Q_OS_WIN)
const int VERIFY_CODE = 8; //验证注册.windows 8 linux 9 MAC 12 (10,11给了我的写作
#endif
static short version_num = 23;
//这个类完全简化了只保护网络验证的功能。其余UI操作放入到ccnotepad中去了
class NetRegister : public QObject
{
Q_OBJECT
public:
NetRegister(QObject *parent = Q_NULLPTR);
virtual ~NetRegister();
static QString getLocalFirstMac();
private:
static QStringList getLocalMac();
void quit();
};

View File

@ -31,16 +31,6 @@ enum RC_ITEM_STATUS
RC_EXPANDED,
};
enum BLOCKSTATUS {
UNKNOWN_BLOCK = 0,
EQUAL_BLOCK = 1,
UNEQUAL_BLOCK,
PAD_BLOCK,
//EMPTY_BLOCK,
LAST_PAD_EMPTY_BLOCK, // 最后一个用于对齐的空行
TEMP_INSERT_BLOCK
};
/* 是放置在block中的userState-1是保留行因为-1是默认没有时的值标识新插入行 */
enum RC_LINE_FORM
{
@ -52,35 +42,6 @@ enum RC_LINE_FORM
MAC_LINE,
};
typedef struct equalLineInfo_ {
int index;//相等行序号,左右值
int leftLineNums;
int rightLineNums;
}EqualLineInfo;
typedef struct noequalblock_ {
int startBlockNums; //开始的块号。左右两边都是一样的
int blockLens;//左右长度。理论上二者是相等的,故只需要一个
bool isDeleted; //是否已经被同步。即被删除过了,下次跳过这个
int type; //
noequalblock_()
{
type = UNKNOWN_BLOCK;
}
noequalblock_(int start, int lens)
{
startBlockNums = start;
blockLens = lens;
isDeleted = false;
type = UNKNOWN_BLOCK;
}
bool operator==(const noequalblock_& other)
{
return (startBlockNums == other.startBlockNums);
}
}NoEqualBlock;
enum CODE_ID {
UNKOWN = -2,//其实应该是ANSI中的非GBK编码。暂时不考虑其它国家语言编码则直接按照ASCII进行字节处理
@ -100,91 +61,6 @@ enum CODE_ID {
CODE_END //最后一个标志,在UI上是显示一个UNKNOWN这是一个特殊
};
/*作用:这个类主要统计左右不同的块,给界面上的“上一部分”和“下一部分”来使用。
*/
typedef struct BlocksInfo_ {
public:
BlocksInfo_()
{
startLine = 0;
endLine = 0;
}
BlocksInfo_(bool equal_, int startLine_, int endLine_, int actualNums_)
{
equal = equal_;
actualNums = actualNums_;
startLine = startLine_;
endLine = endLine_;
}
public:
bool equal;//相同true不同false
int actualNums;//实际数据行数
int startLine; //起点块的行号码
int endLine;//终点块,不包含此块
}BlocksInfo;
//每一小段的字符,主要是将相等和不等的字符段分开
typedef struct SectionNode_ {
bool equal; //是否相等
QString text;
//QByteArray text;
}SectionNode;
//每一小段的二进制字节,主要是将相等和不等的二进制字符段分开
typedef struct BinSectionNode_ {
bool equal; //是否相等
QVector<uchar> bytes;
}BinSectionNode;
typedef struct BinUnequalPos_ {
int start;
int end;
}BinUnequalPos;
//每一行的数据结构。每一行包含许多相等或不相等的小段
typedef struct LineNode_ {
int lineNums;//行的号码
bool totalEqual;//是否完全相等
QVector<SectionNode> lineText;
LineNode_()
{
totalEqual = false;
}
void clear()
{
totalEqual = false;
lineText.clear();
}
}LineNode;
extern RC_LINE_FORM getLineEndType(QString line);
extern RC_LINE_FORM getLineEndType(const LineNode& lines);
#ifdef Q_OS_UNIX
extern QString loadFontFromFile(QString path,int code=0);
#endif
typedef struct ModifyRecords_ {
int position;//当前修改位置
int modificationType;//1增加 2 删除
int length;//修改的长度
int linesAdded;//增加多少行。正为增加,负数为减少
bool isInPaste;//是否在拷贝中,在的话前面一个删除不能做处理,要等到后续添加消息
ModifyRecords_(int position_, int type_, int length_, int linesAdded_) :position(position_), modificationType(type_), length(length_), linesAdded(linesAdded_)
{
isInPaste = false;
}
}ModifyRecords;
typedef struct fileAttriNode_ {
QString relativePath;//不带/而且不带最外层目录路径
@ -208,15 +84,6 @@ typedef struct fileAttriNode_ {
}fileAttriNode;
struct WalkFileInfo {
int direction;
QTreeWidgetItem* root;
QString path;
WalkFileInfo(int dire_, QTreeWidgetItem* root_, QString path_) :direction(dire_), root(root_), path(path_)
{
}
};
const int MARGIN_NONE = 0;
@ -242,22 +109,17 @@ enum WORK_STATUS
class BlockUserData;
struct OperatorInfo {
int startLineNums; //开始行号
int lineLens;//左右长度。理论上二者是相等的,故只需要一个
int type;
QList<int> lineLength; //每一行的长度
QList<char*> lineContents;// 每一行的内容
QList<BlockUserData*> lineExternInfo; //每一行的额外信息
NoEqualBlock noEqualBlockInfo;
int noEqualindex;
struct WalkFileInfo {
int direction;
QTreeWidgetItem* root;
QString path;
WalkFileInfo(int dire_, QTreeWidgetItem* root_, QString path_) :direction(dire_), root(root_), path(path_)
{
}
};
enum OperRecordStatus {
RC_OPER_SYNC = 1,//同步导致
RC_OPER_EDIT,//编辑导致
};
const int Item_RelativePath = Qt::ToolTipRole;
const int Item_Index = Qt::UserRole + 1;
const int DIR_ITEM_MAXSIZE_FILE = Qt::UserRole + 2;

View File

@ -1,74 +0,0 @@
#pragma once
#include "command.h"
#include "rcglobal.h"
#include "blockuserdata.h"
#include <QList>
class CompareWin;
enum USER_DATA_OPER_TYPE {
DEL_USER_DATA = 1,
ADD_USER_DATA
};
//记录undo与redo的操作记录的userdata相关操作
class UserDataOperRecords {
public:
RC_DIRECTION dir;
int operType; //1DEL_USER_DATA 2ADD_USER_DATA
QList<BlockUserData*> userData;
UserDataOperRecords(RC_DIRECTION dir_) :dir(dir_), isLastOne(false)
{
}
~UserDataOperRecords()
{
for (int j = 0; j < userData.size(); ++j)
{
delete userData.at(j);
}
userData.clear();
}
UserDataOperRecords() = default;
UserDataOperRecords(const UserDataOperRecords& other) = delete;
//记录是否是最后一个操作,因为最后一个要做一个额外的操作
bool isLastOne;
};
class UserDataCommand :public Command
{
public:
UserDataCommand(CompareWin* operWin);
virtual ~UserDataCommand();
virtual int getOperIndex()override;
virtual void undo()override;
virtual QString desc()override;
void setDesc(QString v);
void setOperIndex(int v);
void addRecord(UserDataOperRecords* v);
private:
CompareWin* m_operWin;
QList<UserDataOperRecords*> m_record;
int m_index;
QString m_desc;
UserDataCommand(const UserDataCommand& o) = delete;
UserDataCommand& operator=(const UserDataCommand& o) = delete;
};

View File

@ -1,120 +0,0 @@
#include "userregister.h"
#include "jsondeploy.h"
#include <qmessagebox.h>
#include <QTimer>
UserRegister::UserRegister(QWidget *parent)
: QDialog(parent), m_isNetReplayCome(-1)
{
ui.setupUi(this);
JsonDeploy::init();
int status = JsonDeploy::getKeyValueFromNumSets(SOFT_STATUS);
m_regeisterStatus = status;
if (0 == status)
{
ui.status->setText(tr("Free Trial"));
}
else if (1 == status)
{
ui.status->setText(tr("Registered Version"));
}
else if (2 == status)
{
ui.status->setText(tr("License Expired"));
}
else if (3 == status)
{
ui.status->setText(tr("License Error"));
}
QString mac = JsonDeploy::getKeyValueFromSets("mac");
ui.machineId->setText(mac);
QString softKey = JsonDeploy::getKeyValueFromSets(SOFT_KEY);
if (!softKey.isEmpty() && softKey != "0")
{
ui.licenceKey->setText(softKey);
}
}
UserRegister::~UserRegister()
{
JsonDeploy::close();
}
//服务器返回而来的注册验证消息
void UserRegister::slot_registerReplay(int code)
{
if (code == 1)
{
//如果是正版,给出正版提示。
ui.status->setText(tr("Registered Version"));
m_regeisterStatus = 1;
}
else
{
}
m_isNetReplayCome = code;
}
void UserRegister::slot_register()
{
if (m_regeisterStatus == 1)
{
QMessageBox::warning(this, tr("Licence Key"), tr("It is already a registered version."));
return;
}
if (ui.licenceKey->text().isEmpty())
{
QMessageBox::warning(this, tr("Licence Key"), tr("Please scanning the donation, Write your email address in the message area.\nYou will get the registration code!"));
}
else
{
QString key = ui.licenceKey->text();
if (key.size() != 12)
{
QMessageBox::warning(this, tr("Licence Key"), tr("Please enter the correct registration code!"));
return;
}
emit signSendRegisterKey(key);
//QMessageBox::information(this, tr("Licence Key"), tr("Processing succeeded. We will process your registration code in the background. It may take 1-3 days."));
QString oldKey = JsonDeploy::getKeyValueFromSets(SOFT_KEY);
if (oldKey.isEmpty() || oldKey == "0" || oldKey != key)
{
JsonDeploy::updataKeyValueFromSets(SOFT_KEY, key);
}
QEventLoop loop(this);
QTimer::singleShot(5000, &loop, SLOT(quit()));//创建单次定时器,槽函数为事件循环的退出函数
loop.exec(QEventLoop::ExcludeUserInputEvents);
//表示来了消息
if (m_isNetReplayCome != -1)
{
if (m_isNetReplayCome == 1)
{
QMessageBox::information(this, tr("Licence Key"), tr("Congratulations on your successful registration."));
}
else
{
QMessageBox::information(this, tr("Licence Key"), tr("Registration failed. Please try again later."));
}
}
else
{
QMessageBox::information(this, tr("Licence Key"), tr("Registration failed. Please try again later."));
}
}
}

View File

@ -1,27 +0,0 @@
#pragma once
#include <QDialog>
#include "ui_userregister.h"
class UserRegister : public QDialog
{
Q_OBJECT
public:
UserRegister(QWidget *parent = nullptr);
~UserRegister();
signals:
void signSendRegisterKey(QString key);
public slots:
void slot_registerReplay(int code);
private slots:
void slot_register();
private:
Ui::UserRegisterClass ui;
int m_isNetReplayCome;
int m_regeisterStatus;
};

View File

@ -1,242 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>UserRegisterClass</class>
<widget class="QDialog" name="UserRegisterClass">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>609</width>
<height>395</height>
</rect>
</property>
<property name="maximumSize">
<size>
<width>650</width>
<height>400</height>
</size>
</property>
<property name="windowTitle">
<string>UserRegister</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<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="QLabel" name="label_2">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="RealCompare.qrc">:/Resources/img/6688.png</pixmap>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<spacer name="horizontalSpacer_3">
<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="QLabel" name="label">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="RealCompare.qrc">:/Resources/img/register.png</pixmap>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="enabled">
<bool>true</bool>
</property>
<property name="title">
<string>Status</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Status</string>
</property>
</widget>
</item>
<item row="0" column="1" colspan="2">
<widget class="QLineEdit" name="status">
<property name="enabled">
<bool>false</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Machine Id</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLineEdit" name="machineId">
<property name="enabled">
<bool>false</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Licence Key</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLineEdit" name="licenceKey">
<property name="maxLength">
<number>35</number>
</property>
<property name="placeholderText">
<string>22874567148</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QPushButton" name="registerBt">
<property name="text">
<string>Register</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="clostBt">
<property name="text">
<string>Close</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Wechat scans the appreciation code on the left.&lt;/p&gt;&lt;p&gt;Leave your contact email in the donation message.&lt;/p&gt;&lt;p&gt;We will send you the registration code later.&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources>
<include location="RealCompare.qrc"/>
</resources>
<connections>
<connection>
<sender>clostBt</sender>
<signal>clicked()</signal>
<receiver>UserRegisterClass</receiver>
<slot>close()</slot>
<hints>
<hint type="sourcelabel">
<x>617</x>
<y>220</y>
</hint>
<hint type="destinationlabel">
<x>632</x>
<y>256</y>
</hint>
</hints>
</connection>
<connection>
<sender>registerBt</sender>
<signal>clicked()</signal>
<receiver>UserRegisterClass</receiver>
<slot>slot_register()</slot>
<hints>
<hint type="sourcelabel">
<x>416</x>
<y>220</y>
</hint>
<hint type="destinationlabel">
<x>437</x>
<y>235</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>slot_register()</slot>
</slots>
</ui>

View File

@ -1,20 +0,0 @@
#include "workerthread.h"
WorkerThread::WorkerThread(QObject *parent)
: QObject(parent)
{
}
WorkerThread::~WorkerThread()
{
}
/* 这个函数是运行在多线程里面 */
void WorkerThread::doWork(std::function<int (void *)> fun, void *parameter)
{
//从外面传递一个函数进来,执行
int ret = fun(parameter);
emit resultReady(ret);
}

View File

@ -1,19 +0,0 @@
#pragma once
#include <QObject>
#include <functional>
class WorkerThread : public QObject
{
Q_OBJECT
public:
WorkerThread(QObject *parent=nullptr);
~WorkerThread();
signals:
void resultReady(int);
public slots:
void doWork(std::function<int (void*)> fun, void * parameter);
};

View File

@ -1,29 +0,0 @@
#include "workthreadctl.h"
#include "workerthread.h"
WorkThreadCtl::WorkThreadCtl(QObject *parent): QObject(parent)
{
WorkerThread *worker = new WorkerThread;
worker->moveToThread(&workerThread);
connect(&workerThread, &QThread::finished, worker, &QObject::deleteLater);
connect(this, &WorkThreadCtl::operate, worker, &WorkerThread::doWork);
//connect(worker, &WorkerThread::resultReady, this, &WorkThreadCtl::handleResults);
workerThread.start();
}
WorkThreadCtl::~WorkThreadCtl()
{
workerThread.quit();
workerThread.wait();
}
//提交信号,执行槽函数在多线程中
void WorkThreadCtl::commitTask(std::function<int(void*)> fun, void * parameter)
{
operate(fun, parameter);
}

View File

@ -1,20 +0,0 @@
#pragma once
#include <QObject>
#include <QThread>
class WorkThreadCtl : public QObject
{
Q_OBJECT
public:
WorkThreadCtl(QObject *parent=nullptr);
~WorkThreadCtl();
void commitTask(std::function<int(void*)> fun, void *);
signals:
void operate(std::function<int(void*)> fun, void *);
private:
QThread workerThread;
};