mirror of
https://github.com/JasonYANG170/PCpet.git
synced 2024-11-23 03:56:35 +00:00
to add
This commit is contained in:
parent
3b4914d43f
commit
e25b8969fd
32
YANG-PCpet.pro
Normal file
32
YANG-PCpet.pro
Normal file
|
@ -0,0 +1,32 @@
|
|||
QT += core gui
|
||||
QT += network
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
|
||||
CONFIG += c++17
|
||||
|
||||
# You can make your code fail to compile if it uses deprecated APIs.
|
||||
# In order to do so, uncomment the following line.
|
||||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||
|
||||
SOURCES += \
|
||||
form.cpp \
|
||||
main.cpp \
|
||||
widget.cpp
|
||||
|
||||
HEADERS += \
|
||||
form.h \
|
||||
widget.h
|
||||
|
||||
FORMS += \
|
||||
form.ui \
|
||||
widget.ui
|
||||
|
||||
TRANSLATIONS += \
|
||||
YANG-PCpet_zh_CN.ts
|
||||
CONFIG += lrelease
|
||||
CONFIG += embed_translations
|
||||
|
||||
# Default rules for deployment.
|
||||
qnx: target.path = /tmp/$${TARGET}/bin
|
||||
else: unix:!android: target.path = /opt/$${TARGET}/bin
|
||||
!isEmpty(target.path): INSTALLS += target
|
268
YANG-PCpet.pro.user
Normal file
268
YANG-PCpet.pro.user
Normal file
|
@ -0,0 +1,268 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by QtCreator 12.0.1, 2024-03-25T16:58:39. -->
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>EnvironmentId</variable>
|
||||
<value type="QByteArray">{5913d737-a7b3-40d5-81b3-ef43144c2778}</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.ActiveTarget</variable>
|
||||
<value type="qlonglong">0</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.EditorSettings</variable>
|
||||
<valuemap type="QVariantMap">
|
||||
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
|
||||
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
|
||||
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
|
||||
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
|
||||
<value type="QString" key="language">Cpp</value>
|
||||
<valuemap type="QVariantMap" key="value">
|
||||
<value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
|
||||
</valuemap>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
|
||||
<value type="QString" key="language">QmlJS</value>
|
||||
<valuemap type="QVariantMap" key="value">
|
||||
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
|
||||
</valuemap>
|
||||
</valuemap>
|
||||
<value type="qlonglong" key="EditorConfiguration.CodeStyle.Count">2</value>
|
||||
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
|
||||
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
|
||||
<value type="int" key="EditorConfiguration.IndentSize">4</value>
|
||||
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
|
||||
<value type="int" key="EditorConfiguration.MarginColumn">80</value>
|
||||
<value type="bool" key="EditorConfiguration.MouseHiding">true</value>
|
||||
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
|
||||
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
|
||||
<value type="int" key="EditorConfiguration.PreferAfterWhitespaceComments">0</value>
|
||||
<value type="bool" key="EditorConfiguration.PreferSingleLineComments">false</value>
|
||||
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
|
||||
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
|
||||
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
|
||||
<value type="bool" key="EditorConfiguration.SmartSelectionChanging">true</value>
|
||||
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
|
||||
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
|
||||
<value type="int" key="EditorConfiguration.TabSize">8</value>
|
||||
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
|
||||
<value type="bool" key="EditorConfiguration.UseIndenter">false</value>
|
||||
<value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
|
||||
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
|
||||
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
|
||||
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
|
||||
<value type="QString" key="EditorConfiguration.ignoreFileTypes">*.md, *.MD, Makefile</value>
|
||||
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
|
||||
<value type="bool" key="EditorConfiguration.skipTrailingWhitespace">true</value>
|
||||
<value type="bool" key="EditorConfiguration.tintMarginArea">true</value>
|
||||
</valuemap>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.PluginSettings</variable>
|
||||
<valuemap type="QVariantMap">
|
||||
<valuemap type="QVariantMap" key="AutoTest.ActiveFrameworks">
|
||||
<value type="bool" key="AutoTest.Framework.Boost">true</value>
|
||||
<value type="bool" key="AutoTest.Framework.CTest">false</value>
|
||||
<value type="bool" key="AutoTest.Framework.Catch">true</value>
|
||||
<value type="bool" key="AutoTest.Framework.GTest">true</value>
|
||||
<value type="bool" key="AutoTest.Framework.QtQuickTest">true</value>
|
||||
<value type="bool" key="AutoTest.Framework.QtTest">true</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="AutoTest.CheckStates"/>
|
||||
<value type="int" key="AutoTest.RunAfterBuild">0</value>
|
||||
<value type="bool" key="AutoTest.UseGlobal">true</value>
|
||||
<valuemap type="QVariantMap" key="ClangTools">
|
||||
<value type="bool" key="ClangTools.AnalyzeOpenFiles">true</value>
|
||||
<value type="bool" key="ClangTools.BuildBeforeAnalysis">true</value>
|
||||
<value type="QString" key="ClangTools.DiagnosticConfig">Builtin.DefaultTidyAndClazy</value>
|
||||
<value type="int" key="ClangTools.ParallelJobs">8</value>
|
||||
<value type="bool" key="ClangTools.PreferConfigFile">false</value>
|
||||
<valuelist type="QVariantList" key="ClangTools.SelectedDirs"/>
|
||||
<valuelist type="QVariantList" key="ClangTools.SelectedFiles"/>
|
||||
<valuelist type="QVariantList" key="ClangTools.SuppressedDiagnostics"/>
|
||||
<value type="bool" key="ClangTools.UseGlobalSettings">true</value>
|
||||
</valuemap>
|
||||
</valuemap>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.Target.0</variable>
|
||||
<valuemap type="QVariantMap">
|
||||
<value type="QString" key="DeviceType">Desktop</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 6.6.0 MinGW 64-bit</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 6.6.0 MinGW 64-bit</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.qt6.dev.win64_mingw_kit</value>
|
||||
<value type="qlonglong" key="ProjectExplorer.Target.ActiveBuildConfiguration">1</value>
|
||||
<value type="qlonglong" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
|
||||
<value type="qlonglong" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
|
||||
<value type="int" key="EnableQmlDebugging">0</value>
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:\Users\qw200\Documents\C or C++ for YANG\build-YANG-PCpet-Desktop_Qt_6_6_0_MinGW_64_bit-Debug</value>
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">C:/Users/qw200/Documents/C or C++ for YANG/build-YANG-PCpet-Desktop_Qt_6_6_0_MinGW_64_bit-Debug</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
|
||||
<valuelist type="QVariantList" key="QtProjectManager.QMakeBuildStep.SelectedAbis"/>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||
</valuemap>
|
||||
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
|
||||
</valuemap>
|
||||
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">清除</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">清除</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
|
||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Debug</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
|
||||
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:\Users\qw200\Documents\C or C++ for YANG\build-YANG-PCpet-Desktop_Qt_6_6_0_MinGW_64_bit-Release</value>
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">C:/Users/qw200/Documents/C or C++ for YANG/build-YANG-PCpet-Desktop_Qt_6_6_0_MinGW_64_bit-Release</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
|
||||
<valuelist type="QVariantList" key="QtProjectManager.QMakeBuildStep.SelectedAbis"/>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||
</valuemap>
|
||||
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
|
||||
</valuemap>
|
||||
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">清除</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">清除</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
|
||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Release</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
|
||||
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
|
||||
<value type="int" key="QtQuickCompiler">0</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2">
|
||||
<value type="int" key="EnableQmlDebugging">0</value>
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:\Users\qw200\Documents\C or C++ for YANG\build-YANG-PCpet-Desktop_Qt_6_6_0_MinGW_64_bit-Profile</value>
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">C:/Users/qw200/Documents/C or C++ for YANG/build-YANG-PCpet-Desktop_Qt_6_6_0_MinGW_64_bit-Profile</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
|
||||
<valuelist type="QVariantList" key="QtProjectManager.QMakeBuildStep.SelectedAbis"/>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||
</valuemap>
|
||||
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
|
||||
</valuemap>
|
||||
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">清除</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">清除</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
|
||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Profile</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
|
||||
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
|
||||
<value type="int" key="QtQuickCompiler">0</value>
|
||||
<value type="int" key="SeparateDebugInfo">0</value>
|
||||
</valuemap>
|
||||
<value type="qlonglong" key="ProjectExplorer.Target.BuildConfigurationCount">3</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">部署</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">部署</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.DeployConfiguration.CustomData"/>
|
||||
<value type="bool" key="ProjectExplorer.DeployConfiguration.CustomDataEnabled">false</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
|
||||
</valuemap>
|
||||
<value type="qlonglong" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
|
||||
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
|
||||
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
|
||||
<value type="int" key="Analyzer.Valgrind.Callgrind.CostFormat">0</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
|
||||
<value type="QList<int>" key="Analyzer.Valgrind.VisibleErrorKinds"></value>
|
||||
<valuelist type="QVariantList" key="CustomOutputParsers"/>
|
||||
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
|
||||
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
||||
<value type="bool" key="PE.EnvironmentAspect.PrintOnRun">false</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">YANG-PCpet2</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:E:/C++-QT/YANG-PCpet/YANG-PCpet.pro</value>
|
||||
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">E:/C++-QT/YANG-PCpet/YANG-PCpet.pro</value>
|
||||
<value type="bool" key="ProjectExplorer.RunConfiguration.Customized">true</value>
|
||||
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
||||
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
|
||||
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
||||
<value type="QString" key="RunConfiguration.WorkingDirectory.default">C:/Users/qw200/Documents/C or C++ for YANG/build-YANG-PCpet-Desktop_Qt_6_6_0_MinGW_64_bit-Release</value>
|
||||
</valuemap>
|
||||
<value type="qlonglong" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
|
||||
</valuemap>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.TargetCount</variable>
|
||||
<value type="qlonglong">1</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
|
||||
<value type="int">22</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>Version</variable>
|
||||
<value type="int">22</value>
|
||||
</data>
|
||||
</qtcreator>
|
3
YANG-PCpet_zh_CN.ts
Normal file
3
YANG-PCpet_zh_CN.ts
Normal file
|
@ -0,0 +1,3 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1" language="zh_CN"></TS>
|
59
form.cpp
Normal file
59
form.cpp
Normal file
|
@ -0,0 +1,59 @@
|
|||
#include "form.h"
|
||||
#include "ui_form.h"
|
||||
|
||||
#include "widget.h"
|
||||
Form::Form(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::Form)
|
||||
{
|
||||
|
||||
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
Form::~Form()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void Form::on_pushButton_clicked()
|
||||
{
|
||||
int x1=ui->lineEdit->text().toInt();
|
||||
int x2=ui->lineEdit_2->text().toInt();
|
||||
int x3=ui->lineEdit_3->text().toInt();
|
||||
int x4=ui->lineEdit_4->text().toInt();
|
||||
int x5=ui->lineEdit_5->text().toInt();
|
||||
int x6=ui->lineEdit_6->text().toInt();
|
||||
int x7=ui->lineEdit_6->text().toInt();
|
||||
Widget widget;
|
||||
connect(this, &Form::vesChanged, &widget, &Widget::setVes); // Connect the signal from Form to the slot in Widget
|
||||
|
||||
emit vesChanged(x1,x2,x3,x4,x5,x6,x7); // Emit the signal to set the version information in Widget
|
||||
|
||||
QMessageBox::warning(this, "Error", "设置成功,重启程序后生效。");
|
||||
|
||||
}
|
||||
|
||||
|
||||
void Form::on_pushButton_2_clicked()
|
||||
{
|
||||
Widget widget;
|
||||
connect(this, &Form::vesChanged, &widget, &Widget::setVes); // Connect the signal from Form to the slot in Widget
|
||||
int x=0;
|
||||
int x2=0;
|
||||
int x3=0;
|
||||
int x4=0;
|
||||
int x5=200;
|
||||
int x6=100;
|
||||
int x7=20;
|
||||
emit vesChanged(x,x2,x3,x4,x5,x6,x7); // Emit the signal to set the version information in Widget
|
||||
|
||||
QMessageBox::warning(this, "Error", "设置成功,重启程序后生效。");
|
||||
}
|
||||
|
||||
|
||||
void Form::on_pushButton_3_clicked()
|
||||
{
|
||||
|
||||
}
|
||||
|
31
form.h
Normal file
31
form.h
Normal file
|
@ -0,0 +1,31 @@
|
|||
#ifndef FORM_H
|
||||
#define FORM_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ui {
|
||||
class Form;
|
||||
}
|
||||
|
||||
class Form : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Form(QWidget *parent = nullptr);
|
||||
~Form();
|
||||
signals:
|
||||
void vesChanged(int &newVes1,int &newVes2,int &newVes3,int &newVes4,int &newVes5,int &newVes6,int &newVes7); // 版本信息变化的信号
|
||||
|
||||
private slots:
|
||||
void on_pushButton_clicked();
|
||||
|
||||
void on_pushButton_2_clicked();
|
||||
|
||||
void on_pushButton_3_clicked();
|
||||
|
||||
private:
|
||||
Ui::Form *ui;
|
||||
};
|
||||
|
||||
#endif // FORM_H
|
170
form.ui
Normal file
170
form.ui
Normal file
|
@ -0,0 +1,170 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Form</class>
|
||||
<widget class="QWidget" name="Form">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>506</width>
|
||||
<height>255</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>YANG-PCpet</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_10">
|
||||
<property name="text">
|
||||
<string><html><head/><body><p align="center"><span style=" font-size:10pt; font-weight:700;">YANG-PCpet</span></p><p><span style=" font-weight:700;">版本:</span>V3.5</p><p><span style=" font-weight:700;">使用说明:</span></p><p>按住ALT启动娱乐模式,宠物将逃离你的鼠标指针。</p><p><span style=" font-weight:700;">日志:</span></p><p>1.新增宠物忠心进度条。2.新增饥饿系统。</p><p>3.新增卫生系统。4.新增天气预报。</p><p>5.新增ChatGPTAI聊天系统。详细日志请查看官网。</p><p><span style=" font-weight:700;">开发及维护:</span>JasonYANG170</p><p><span style=" font-weight:700;">本项目官网:</span><a href="https://github.com/JasonYANG170/YANG-PCpet"><span style=" text-decoration: underline; color:#0000ff;">JasonYANG170/YANG-PCpet (github.com)</span></a></p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>15</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><html><head/><body><p><span style=" font-weight:700;">自定义属性设置(通常情况下不需要用户设置)</span></p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string><html><head/><body><p><span style=" font-weight:700;">上边界</span></p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string><html><head/><body><p><span style=" font-weight:700;">宽</span></p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_5"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string><html><head/><body><p><span style=" font-weight:700;">下边界</span></p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_2"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string><html><head/><body><p><span style=" font-weight:700;">高</span></p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_6"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string><html><head/><body><p><span style=" font-weight:700;">左边界</span></p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_3"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string><html><head/><body><p><span style=" font-weight:700;">缓慢度</span></p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_7"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string><html><head/><body><p><span style=" font-weight:700;">右边界</span></p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_4"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="text">
|
||||
<string>保存设置</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_2">
|
||||
<property name="text">
|
||||
<string>恢复默认</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Tonken</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_8"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_3">
|
||||
<property name="text">
|
||||
<string>保存</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
40
main.cpp
Normal file
40
main.cpp
Normal file
|
@ -0,0 +1,40 @@
|
|||
|
||||
#include "widget.h"
|
||||
#include "form.h"
|
||||
#include <QApplication>
|
||||
#include "widget.h"
|
||||
#include <QApplication>
|
||||
#include <QLocale>
|
||||
#include <QTranslator>
|
||||
#include <QLabel>
|
||||
#include <QMovie>
|
||||
#include <QGraphicsDropShadowEffect>
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
|
||||
QTranslator translator;
|
||||
const QStringList uiLanguages = QLocale::system().uiLanguages();
|
||||
for (const QString &locale : uiLanguages) {
|
||||
const QString baseName = "YANG-PCpet_" + QLocale(locale).name();
|
||||
if (translator.load(":/i18n/" + baseName)) {
|
||||
a.installTranslator(&translator);
|
||||
break;
|
||||
}
|
||||
}
|
||||
Form ss;
|
||||
Widget w;
|
||||
QGraphicsDropShadowEffect effect;
|
||||
effect.setBlurRadius(30);
|
||||
effect.setColor(Qt::black);
|
||||
effect.setOffset(0);
|
||||
|
||||
w.setGraphicsEffect(&effect);
|
||||
|
||||
ss.show();
|
||||
|
||||
w.show();
|
||||
QString programDirPath = QCoreApplication::applicationDirPath();
|
||||
qDebug() << "程序所在目录:" << programDirPath;
|
||||
return a.exec();
|
||||
}
|
491
widget.cpp
Normal file
491
widget.cpp
Normal file
|
@ -0,0 +1,491 @@
|
|||
|
||||
#include "widget.h"
|
||||
#include "qboxlayout.h"
|
||||
#include "ui_widget.h"
|
||||
#include <QSettings>
|
||||
#include <QApplication>
|
||||
#include <QJsonDocument>
|
||||
#include <QApplication>
|
||||
#include <QLabel>
|
||||
#include <QMovie>
|
||||
#include <QGraphicsDropShadowEffect>
|
||||
#include <QDesktopServices>
|
||||
#include <QUrl>
|
||||
#include <QLineEdit>
|
||||
#include <QGraphicsProxyWidget>
|
||||
#include <QGraphicsScene>
|
||||
#include <QImage>
|
||||
#include <QPixmap>
|
||||
#include <QSystemTrayIcon>
|
||||
#include <QMenu>
|
||||
#include <QIcon>
|
||||
#include <QStyle>
|
||||
#include <QAction>
|
||||
#include <QGraphicsView>
|
||||
int px=200;
|
||||
int py=100;
|
||||
int x1=0,x2=0,x3=0,x4=0,speed=0;
|
||||
int progress,eat,clear,fat;
|
||||
QString ves="V3.0";
|
||||
QSettings settings("HKEY_CURRENT_USER\\SOFTWARE\\YANG-PCpetV3.0", QSettings::NativeFormat);
|
||||
Widget::Widget(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, ui(new Ui::Widget)
|
||||
{
|
||||
QPixmap img(":/Win11.jpg");
|
||||
|
||||
connect(ui->pushButton_5, &QPushButton::clicked, this, &Widget::on_pushButton_5_clicked);
|
||||
|
||||
QIcon icon = QApplication::style()->standardIcon((QStyle::StandardPixmap)0);
|
||||
QIcon icon1 = QApplication::style()->standardIcon((QStyle::StandardPixmap)9);
|
||||
|
||||
//设置通知栏的图标
|
||||
trayIcon = new QSystemTrayIcon(this);
|
||||
trayIcon->setIcon(icon);
|
||||
|
||||
//设置通知栏的单击事件
|
||||
// connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(stTrayIconActive(QSystemTrayIcon::ActivationReason)));
|
||||
|
||||
//设置通知栏的右键菜单
|
||||
//QMenu * menu = new QMenu();
|
||||
|
||||
//设置菜单项目
|
||||
// QAction *actionHide = new QAction(icon, "Hide", menu);
|
||||
|
||||
//menu->addAction(actionHide);
|
||||
// trayIcon->setContextMenu(menu);
|
||||
// 设置Action的响应
|
||||
//connect(actionHide, SIGNAL(triggered()), this, SLOT(stActionHide()));
|
||||
trayIcon->show();
|
||||
|
||||
ui->setupUi(this);
|
||||
// 读取注册表数据
|
||||
x1= settings.value("x1").toInt();
|
||||
x2= settings.value("x2").toInt();
|
||||
x3= settings.value("x3").toInt();
|
||||
x4= settings.value("x4").toInt();
|
||||
px= settings.value("px").toInt();
|
||||
py = settings.value("py").toInt();
|
||||
speed = settings.value("speed").toInt();
|
||||
progress= settings.value("progress").toInt();
|
||||
ui->progressBar->setValue(progress);
|
||||
if((settings.value("py").toString())==""||(settings.value("py").toInt())==0){
|
||||
px=200;
|
||||
py=100;
|
||||
}
|
||||
if((settings.value("speed").toString())==""||(settings.value("speed").toInt())==0){
|
||||
speed=20;
|
||||
}
|
||||
qDebug() << "Alt key pressed"+settings.value("py").toString();
|
||||
setAttribute(Qt::WA_TranslucentBackground);
|
||||
setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
|
||||
ui->pushButton->setStyleSheet("QPushButton:focus { outline: none; box-shadow: none; }");
|
||||
// 添加宠物GIF图片
|
||||
m_movie1 = new QMovie(".\\512.gif");
|
||||
m_movie2 = new QMovie(".\\511.gif");
|
||||
m_movie3 = new QMovie(".\\513.gif");
|
||||
|
||||
m_petLabel = new QLabel(this);
|
||||
m_petLabel->setMovie(m_movie3);
|
||||
m_petLabel->setFixedSize(px, py); // 设置宠物的大小
|
||||
m_petLabel->setScaledContents(true);
|
||||
|
||||
m_movie3->start();
|
||||
// 创建布局管理器
|
||||
|
||||
centerPet(); // 图片居中
|
||||
|
||||
|
||||
//ui->progressBar->raise();
|
||||
// 提升文本框到最前面
|
||||
|
||||
|
||||
// 获取屏幕信息
|
||||
QScreen *screen = qApp->primaryScreen();
|
||||
m_screenRect = screen->availableGeometry();
|
||||
|
||||
// 计时器用于检测鼠标靠近和边界检测
|
||||
m_timer = new QTimer(this);
|
||||
connect(m_timer, &QTimer::timeout, this, &Widget::moveAwayFromCursor);
|
||||
m_timer->start(speed); // 每隔50毫秒检测一次
|
||||
|
||||
|
||||
checkNewVersion();
|
||||
timer = new QTimer(this);
|
||||
int interval = 60000; // 5 minutes (300000 milliseconds)
|
||||
timer->setInterval(interval);
|
||||
|
||||
connect(timer, &QTimer::timeout, this, &Widget::executeCode);
|
||||
|
||||
timer->start();
|
||||
}
|
||||
|
||||
Widget::~Widget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void Widget::setVes(int &newVes1,int &newVes2,int &newVes3,int &newVes4,int &newVes5,int &newVes6,int &newVes7)
|
||||
{
|
||||
x1 = newVes1; // 设置版本信息值
|
||||
x2 = newVes2;
|
||||
x3 = newVes3;
|
||||
x4 = newVes4;
|
||||
px=newVes5;
|
||||
py=newVes6;
|
||||
speed=newVes7;
|
||||
// 写入注册表数据
|
||||
settings.setValue("x1", newVes1);
|
||||
settings.setValue("x2", newVes2);
|
||||
settings.setValue("x3", newVes3);
|
||||
settings.setValue("x4", newVes4);
|
||||
settings.setValue("px", newVes5);
|
||||
settings.setValue("py", newVes6);
|
||||
settings.setValue("speed", newVes7);
|
||||
|
||||
}
|
||||
void Widget::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
m_dragStartPosition = event->pos();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Widget::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
if (event->buttons() & Qt::LeftButton) {
|
||||
QPoint distance = event->pos() - m_dragStartPosition;
|
||||
moveWithBoundaries(pos() + distance); // 添加边界限制
|
||||
}
|
||||
}
|
||||
|
||||
void Widget::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
}
|
||||
int x31=1;
|
||||
void Widget::keyPressEvent(QKeyEvent* event)
|
||||
{
|
||||
if (event->key() == Qt::Key_Alt) {
|
||||
// 当按下Alt键时执行的代码
|
||||
qDebug() << "Alt key pressed";
|
||||
xx = 1;
|
||||
}
|
||||
|
||||
// if (event->key() == Qt::Key_Shift&&x31%2==0) {
|
||||
// 当按下Alt键时执行的代码
|
||||
// qDebug() << "Alt key pressedSS";
|
||||
// GPT();
|
||||
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
void Widget::keyReleaseEvent(QKeyEvent* event)
|
||||
{
|
||||
if (event->key() == Qt::Key_Alt) {
|
||||
// 当释放Alt键时执行的代码
|
||||
qDebug() << "Alt key released";
|
||||
xx = 0;
|
||||
//m_petLabel->movie()->start(); // 恢复GIF播放
|
||||
m_movie3->start();
|
||||
m_petLabel->setMovie(m_movie3);
|
||||
m_petLabel->setScaledContents(true);
|
||||
if(fat>0){
|
||||
fat-=1;
|
||||
settings.setValue("fat", fat);
|
||||
}
|
||||
if(progress<100){
|
||||
progress+=1;
|
||||
settings.setValue("progress", progress);
|
||||
}
|
||||
ui->progressBar->setValue(progress);
|
||||
trayIcon->showMessage("YANG-PCpet", "运动后我感到开心");
|
||||
}
|
||||
else {
|
||||
QWidget::keyPressEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
void Widget::centerPet()
|
||||
{
|
||||
int x = (width() / 2 - m_petLabel->width() / 2)-11;
|
||||
int y = height() / 2 - m_petLabel->height() / 2;
|
||||
m_petLabel->move(x, y);
|
||||
}
|
||||
|
||||
void Widget::moveAwayFromCursor()
|
||||
{
|
||||
QPoint cursorPos = QCursor::pos();
|
||||
QPoint widgetPos = mapToGlobal(rect().topLeft());
|
||||
|
||||
int dx = cursorPos.x() - widgetPos.x() - m_petLabel->width() / 2;
|
||||
int dy = cursorPos.y() - widgetPos.y() - m_petLabel->height() / 2;
|
||||
|
||||
int distance = std::sqrt(dx * dx + dy * dy);
|
||||
|
||||
if (xx == 1) {
|
||||
if (distance > 10) {
|
||||
int moveStep = std::min(8, distance / 10); // 控制移动
|
||||
QPoint moveBy(dx * moveStep / distance, dy * moveStep / distance);
|
||||
|
||||
if (dx < 0) { // 向左移动时切换到另一个GIF
|
||||
m_movie2->start();
|
||||
m_petLabel->setMovie(m_movie2);
|
||||
m_petLabel->setScaledContents(true);
|
||||
} else {
|
||||
m_movie1->start();
|
||||
m_petLabel->setMovie(m_movie1);
|
||||
m_petLabel->setScaledContents(true);
|
||||
}
|
||||
|
||||
moveWithBoundaries(pos() - moveBy); // 添加边界限制
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Widget::moveWithBoundaries(const QPoint &newPos)
|
||||
{
|
||||
QPoint boundedPos(newPos);
|
||||
|
||||
// 获取屏幕几何信息
|
||||
const QRect screenRect = QGuiApplication::primaryScreen()->availableGeometry();
|
||||
const int frameThickness = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
|
||||
|
||||
// 设置边界限制
|
||||
boundedPos.setX(qMax(screenRect.left()+x3, boundedPos.x()));
|
||||
boundedPos.setY(qMax(screenRect.top() +x1, boundedPos.y()));
|
||||
boundedPos.setX(qMin(screenRect.right() - width()+x4, boundedPos.x()));
|
||||
boundedPos.setY(qMin(screenRect.bottom() - height()+x2, boundedPos.y()));
|
||||
|
||||
move(boundedPos);
|
||||
}
|
||||
|
||||
void Widget::checkNewVersion()
|
||||
{
|
||||
QNetworkAccessManager *manager = new QNetworkAccessManager(this);
|
||||
QUrl url("https://api.vvhan.com/api/qqsc?key=c4c63feac2129cb548942c31dfb8badf");
|
||||
QNetworkRequest request(url);
|
||||
|
||||
// Set unsafe SSL configuration
|
||||
QSslConfiguration config = request.sslConfiguration();
|
||||
config.setPeerVerifyMode(QSslSocket::VerifyNone);
|
||||
request.setSslConfiguration(config);
|
||||
|
||||
QNetworkReply *reply = manager->get(request);
|
||||
|
||||
// Connect to the finished signal
|
||||
connect(reply, &QNetworkReply::finished, [=]() {
|
||||
if (reply->error() == QNetworkReply::NoError) {
|
||||
// Read the JSON data
|
||||
QByteArray data = reply->readAll();
|
||||
|
||||
// Display the JSON data in a message box
|
||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(QString(data).toUtf8());
|
||||
QJsonObject jsonObj = jsonDoc.object();
|
||||
|
||||
// 获取数据
|
||||
QString info = jsonObj["content"].toString();
|
||||
if (info != ves) {
|
||||
QMessageBox::warning(this, "Error", "已发布新版本\"" + info + "\"。\n点击\"设置\"下载最新版本。");
|
||||
// ui->pushButton_4->setText("发现新版本");
|
||||
QUrl url("https://github.com/JasonYANG170/YANG-PCpet/releases");
|
||||
QDesktopServices::openUrl(url);
|
||||
}
|
||||
else {
|
||||
// ui->pushButton_4->setText("暂无更新");
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Display an error message
|
||||
QMessageBox::warning(this, "Error", reply->errorString());
|
||||
}
|
||||
|
||||
// Clean up
|
||||
reply->deleteLater();
|
||||
manager->deleteLater();
|
||||
});
|
||||
}
|
||||
|
||||
void Widget::on_pushButton_clicked()
|
||||
{
|
||||
x31++;
|
||||
if(x31%2==0){
|
||||
|
||||
ui->pushButton_6->raise();
|
||||
ui->textEdit->raise();
|
||||
}else{
|
||||
ui->pushButton_6->lower();
|
||||
ui->textEdit->lower();
|
||||
ui->pushButton->setFocusPolicy(Qt::NoFocus); // 禁用焦点
|
||||
ui->pushButton->setFocusPolicy(Qt::NoFocus); // 禁用焦点
|
||||
}
|
||||
}
|
||||
void Widget::GPT(QString message)
|
||||
{
|
||||
QNetworkAccessManager manager;
|
||||
|
||||
// 创建POST请求
|
||||
QUrl url("https://aigptx.top/api/v1/ai/chatgpt/chat"); // 更换为你要访问的API地址
|
||||
QNetworkRequest request(url);
|
||||
QString accessToken = "eyJhbGciOiJFUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjQ2ODYiLCJlbWFpbCI6InF3MjAwNDc3QDE2My5jb20iLCJwdXJwb3NlIjoid2ViIiwiaWF0IjoxNzAxNzQzMTcwLCJleHAiOjE3MDI5NTI3NzB9.AeFiM5wAbpFfR05cN-zu8UJX8Vg6nMjPWhNmafh9KFleOfxtSEfMXfswvjbS2KlWNGTdAguZDGDJkG-2aCLmSbh0AO-YbWTOcFEFqlENe1PucnH1XjRFqyab40eNkFk-mi1CadJ5UBIWtmzsURRlUTQSe0lZRFglfuT6Qe25z8CBJn6_";
|
||||
QByteArray authHeader = "Bearer " + accessToken.toUtf8();
|
||||
|
||||
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
|
||||
request.setRawHeader("Authorization", authHeader);
|
||||
// 准备POST数据
|
||||
QByteArray postData;
|
||||
postData.append("session_id=9a77571d-b687-4325-bbff-716ff1466ea2&content=[{\"role\":\"system\",\"content\":\"你是一只企鹅宠物,我是你的主人\"},{\"role\":\"user\",\"content\":\""+message.toUtf8()+"\"}]&max_context_length=5¶ms={\"model\":\"gpt-3.5-turbo\",\"temperature\":1,\"max_tokens\":2048,\"presence_penalty\":0,\"frequency_penalty\":0,\"max_context_length\":5,\"voiceShortName\":\"zh-CN-XiaoxiaoNeural\",\"rate\":1,\"pitch\":1}"); // 根据API要求,构建合适的POST参数
|
||||
|
||||
// 发送POST请求
|
||||
QNetworkReply *reply = manager.post(request, postData);
|
||||
|
||||
// 等待请求完成
|
||||
QEventLoop loop;
|
||||
QObject::connect(reply, &QNetworkReply::finished, &loop, &QEventLoop::quit);
|
||||
loop.exec();
|
||||
|
||||
|
||||
// 获取返回值
|
||||
if(reply->error() == QNetworkReply::NoError) {
|
||||
QString response = reply->readAll();
|
||||
|
||||
trayIcon->showMessage("YANG-PCpet", response);
|
||||
|
||||
} else {
|
||||
qDebug() << "Error:" << reply->errorString();
|
||||
}
|
||||
|
||||
// 清理
|
||||
reply->deleteLater();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Widget::on_pushButton_6_clicked()
|
||||
{
|
||||
QString disscus=ui->textEdit->toPlainText();
|
||||
GPT(disscus);
|
||||
}
|
||||
|
||||
void Widget::on_pushButton_5_clicked()
|
||||
{
|
||||
QPushButton *button = qobject_cast<QPushButton *>(sender());
|
||||
if (button)
|
||||
{
|
||||
button->setEnabled(false); // 禁用按钮
|
||||
// 执行事件程序
|
||||
// ...
|
||||
trayIcon->showMessage("pet", "喂食中。。。");
|
||||
if(progress<100){
|
||||
progress+=1;
|
||||
settings.setValue("progress", progress);
|
||||
}
|
||||
if(eat>0){
|
||||
eat-=1;
|
||||
settings.setValue("eat", eat);
|
||||
}
|
||||
ui->progressBar->setValue(progress);
|
||||
GPT("主人对你喂食");
|
||||
button->setEnabled(true); // 禁用按钮
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Widget::on_pushButton_4_clicked()
|
||||
{
|
||||
if(progress<100){
|
||||
progress+=1;
|
||||
settings.setValue("progress", progress);
|
||||
}
|
||||
if(clear<100){
|
||||
clear+=1;
|
||||
}
|
||||
settings.setValue("clear", clear);
|
||||
ui->progressBar->setValue(progress);
|
||||
GPT("主人为你洗澡");
|
||||
}
|
||||
|
||||
|
||||
void Widget::on_pushButton_3_clicked()
|
||||
{
|
||||
clear = settings.value("clear").toInt();
|
||||
eat = settings.value("eat").toInt();
|
||||
fat = settings.value("fat").toInt();
|
||||
|
||||
trayIcon->showMessage("YANG-PCpet", "健康度:"+QString::number(fat)+"\n饥饿度:"+QString::number(eat)+"\n干净度:"+QString::number(clear));
|
||||
|
||||
}
|
||||
void Widget::executeCode()
|
||||
{
|
||||
if(progress>0){
|
||||
progress-=1;
|
||||
settings.setValue("progress", progress);
|
||||
|
||||
}
|
||||
if(eat<100){
|
||||
eat+=1;
|
||||
settings.setValue("eat", eat);
|
||||
|
||||
}
|
||||
if(fat<100){
|
||||
fat+=1;
|
||||
settings.setValue("fat", fat);
|
||||
|
||||
}
|
||||
if(clear>0){
|
||||
clear-=1;
|
||||
settings.setValue("clear", clear);
|
||||
|
||||
}
|
||||
// 在这个槽函数中执行需要定期执行的代码
|
||||
qDebug() << "Executing code every 5 minutes";
|
||||
}
|
||||
|
||||
void Widget::on_pushButton_2_clicked()
|
||||
{
|
||||
QNetworkAccessManager *manager = new QNetworkAccessManager(this);
|
||||
QUrl url("https://api.vvhan.com/api/weather");
|
||||
QNetworkRequest request(url);
|
||||
|
||||
// Set unsafe SSL configuration
|
||||
QSslConfiguration config = request.sslConfiguration();
|
||||
config.setPeerVerifyMode(QSslSocket::VerifyNone);
|
||||
request.setSslConfiguration(config);
|
||||
|
||||
QNetworkReply *reply = manager->get(request);
|
||||
|
||||
// Connect to the finished signal
|
||||
connect(reply, &QNetworkReply::finished, [=]() {
|
||||
if (reply->error() == QNetworkReply::NoError) {
|
||||
// Read the JSON data
|
||||
QByteArray data = reply->readAll();
|
||||
|
||||
// Display the JSON data in a message box
|
||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(QString(data).toUtf8());
|
||||
QJsonObject jsonObj = jsonDoc.object();
|
||||
|
||||
// 获取数据
|
||||
QString city = jsonObj["city"].toString();
|
||||
QJsonObject jObj2 = jsonDoc["info"].toObject();
|
||||
QString high = jObj2 ["high"].toString();
|
||||
QString type = jObj2 ["type"].toString();
|
||||
QJsonObject jObj23 = jObj2["air"].toObject();
|
||||
QString aqiname = jObj23 ["aqi_name"].toString();
|
||||
QString tip =jObj2["tip"].toString();
|
||||
QString info = "主人好呀,今天"+city+type+",温度"+high+"空气质量"+aqiname;
|
||||
trayIcon->showMessage(tip, info);
|
||||
}
|
||||
else {
|
||||
// Display an error message
|
||||
QMessageBox::warning(this, "Error", reply->errorString());
|
||||
}
|
||||
|
||||
// Clean up
|
||||
reply->deleteLater();
|
||||
manager->deleteLater();
|
||||
});
|
||||
}
|
||||
|
96
widget.h
Normal file
96
widget.h
Normal file
|
@ -0,0 +1,96 @@
|
|||
|
||||
#ifndef WIDGET_H
|
||||
#define WIDGET_H
|
||||
#include <QWidget>
|
||||
#include <QMovie>
|
||||
#include <QTimer>
|
||||
#include <QScreen>
|
||||
#include <QLabel>
|
||||
#include <QMouseEvent>
|
||||
#include <QShortcut>
|
||||
#include <QKeyEvent>
|
||||
#include <QJsonObject>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkReply>
|
||||
#include <QStyle>
|
||||
#include <QJsonDocument>
|
||||
#include <QMessageBox>
|
||||
#include <cmath>
|
||||
#include <QString>
|
||||
#include <QWidget>
|
||||
#include <QDialog>
|
||||
#include <QDialog>
|
||||
#include <QWidget>
|
||||
#include <QImage>
|
||||
#include <QPixmap>
|
||||
#include <QSystemTrayIcon>
|
||||
#include <QMenu>
|
||||
#include <QIcon>
|
||||
#include <QAction>
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui { class Widget; }
|
||||
QT_END_NAMESPACE
|
||||
|
||||
class Widget : public QWidget
|
||||
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Widget(QWidget *parent = nullptr);
|
||||
~Widget();
|
||||
void mousePressEvent(QMouseEvent *event) override;
|
||||
void mouseMoveEvent(QMouseEvent *event) override;
|
||||
void mouseReleaseEvent(QMouseEvent *event) override;
|
||||
void keyPressEvent(QKeyEvent* event) override;
|
||||
void keyReleaseEvent(QKeyEvent* event) override;
|
||||
void keyPressEvent2(QKeyEvent* event2) ;
|
||||
|
||||
void setVes(int &newVes1,int &newVes2,int &newVes3,int &newVes4,int &newVes5,int &newVes6,int &newVes7); // 设置版本信息的函数
|
||||
void GPT(QString message);
|
||||
QSystemTrayIcon *trayIcon;
|
||||
signals:
|
||||
void vesChanged(int &newVes1,int &newVes2,int &newVes3,int &newVes4,int &newVes5,int &newVes6,int &newVes7); // 版本信息变化的信号
|
||||
|
||||
|
||||
private slots:
|
||||
|
||||
|
||||
void executeCode();
|
||||
void on_pushButton_clicked();
|
||||
|
||||
void on_pushButton_6_clicked();
|
||||
|
||||
void on_pushButton_5_clicked();
|
||||
|
||||
void on_pushButton_4_clicked();
|
||||
|
||||
void on_pushButton_3_clicked();
|
||||
|
||||
void on_pushButton_2_clicked();
|
||||
|
||||
private:
|
||||
void stTrayIconActive(QSystemTrayIcon::ActivationReason acReason);
|
||||
Ui::Widget *ui;
|
||||
void centerPet();
|
||||
void moveAwayFromCursor();
|
||||
void moveWithBoundaries(const QPoint &newPos);
|
||||
|
||||
QPoint m_dragStartPosition;
|
||||
QLabel *m_petLabel;
|
||||
QTimer *m_timer;
|
||||
QRect m_screenRect;
|
||||
QMovie *m_movie1;
|
||||
QMovie *m_movie2;
|
||||
QMovie *m_movie3;
|
||||
int xx;
|
||||
QTimer* timer;
|
||||
|
||||
void checkNewVersion();
|
||||
};
|
||||
|
||||
#endif // WIDGET_H
|
143
widget.ui
Normal file
143
widget.ui
Normal file
|
@ -0,0 +1,143 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Widget</class>
|
||||
<widget class="QWidget" name="Widget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>242</width>
|
||||
<height>99</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Widget</string>
|
||||
</property>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>210</x>
|
||||
<y>80</y>
|
||||
<width>31</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>交流</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QTextEdit" name="textEdit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>23</x>
|
||||
<y>70</y>
|
||||
<width>91</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QProgressBar" name="progressBar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>16</width>
|
||||
<height>101</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<kerning>true</kerning>
|
||||
</font>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<string><html><head/><body><p><br/></p></body></html></string>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>24</number>
|
||||
</property>
|
||||
<property name="textVisible">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="invertedAppearance">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>210</x>
|
||||
<y>60</y>
|
||||
<width>31</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>天气</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>210</x>
|
||||
<y>40</y>
|
||||
<width>31</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>汇报</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_4">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>210</x>
|
||||
<y>20</y>
|
||||
<width>31</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>洗澡</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_5">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>210</x>
|
||||
<y>0</y>
|
||||
<width>31</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>喂食</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_6">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>115</x>
|
||||
<y>70</y>
|
||||
<width>31</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>发送</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
Loading…
Reference in New Issue
Block a user