diff --git a/511.gif b/511.gif
new file mode 100644
index 0000000..5ad4d8c
Binary files /dev/null and b/511.gif differ
diff --git a/512.gif b/512.gif
new file mode 100644
index 0000000..c65f862
Binary files /dev/null and b/512.gif differ
diff --git a/513.gif b/513.gif
new file mode 100644
index 0000000..0b45b32
Binary files /dev/null and b/513.gif differ
diff --git a/YANG-PCpet.pro b/YANG-PCpet.pro
new file mode 100644
index 0000000..28afd61
--- /dev/null
+++ b/YANG-PCpet.pro
@@ -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
diff --git a/YANG-PCpet.pro.user b/YANG-PCpet.pro.user
new file mode 100644
index 0000000..2666818
--- /dev/null
+++ b/YANG-PCpet.pro.user
@@ -0,0 +1,268 @@
+
+
+
+
+
+ EnvironmentId
+ {5913d737-a7b3-40d5-81b3-ef43144c2778}
+
+
+ ProjectExplorer.Project.ActiveTarget
+ 0
+
+
+ ProjectExplorer.Project.EditorSettings
+
+ true
+ false
+ true
+
+ Cpp
+
+ CppGlobal
+
+
+
+ QmlJS
+
+ QmlJSGlobal
+
+
+ 2
+ UTF-8
+ false
+ 4
+ false
+ 80
+ true
+ true
+ 1
+ 0
+ false
+ true
+ false
+ 0
+ true
+ true
+ 0
+ 8
+ true
+ false
+ 1
+ true
+ true
+ true
+ *.md, *.MD, Makefile
+ false
+ true
+ true
+
+
+
+ ProjectExplorer.Project.PluginSettings
+
+
+ true
+ false
+ true
+ true
+ true
+ true
+
+
+ 0
+ true
+
+ true
+ true
+ Builtin.DefaultTidyAndClazy
+ 8
+ false
+
+
+
+ true
+
+
+
+
+ ProjectExplorer.Project.Target.0
+
+ Desktop
+ Desktop Qt 6.6.0 MinGW 64-bit
+ Desktop Qt 6.6.0 MinGW 64-bit
+ qt.qt6.dev.win64_mingw_kit
+ 1
+ 0
+ 0
+
+ 0
+ C:\Users\qw200\Documents\C or C++ for YANG\build-YANG-PCpet-Desktop_Qt_6_6_0_MinGW_64_bit-Debug
+ C:/Users/qw200/Documents/C or C++ for YANG/build-YANG-PCpet-Desktop_Qt_6_6_0_MinGW_64_bit-Debug
+
+
+ true
+ QtProjectManager.QMakeBuildStep
+ false
+
+
+
+ true
+ Qt4ProjectManager.MakeStep
+
+ 2
+ 构建
+ 构建
+ ProjectExplorer.BuildSteps.Build
+
+
+
+ true
+ Qt4ProjectManager.MakeStep
+ clean
+
+ 1
+ 清除
+ 清除
+ ProjectExplorer.BuildSteps.Clean
+
+ 2
+ false
+
+ false
+
+ Debug
+ Qt4ProjectManager.Qt4BuildConfiguration
+ 2
+
+
+ C:\Users\qw200\Documents\C or C++ for YANG\build-YANG-PCpet-Desktop_Qt_6_6_0_MinGW_64_bit-Release
+ C:/Users/qw200/Documents/C or C++ for YANG/build-YANG-PCpet-Desktop_Qt_6_6_0_MinGW_64_bit-Release
+
+
+ true
+ QtProjectManager.QMakeBuildStep
+ false
+
+
+
+ true
+ Qt4ProjectManager.MakeStep
+
+ 2
+ 构建
+ 构建
+ ProjectExplorer.BuildSteps.Build
+
+
+
+ true
+ Qt4ProjectManager.MakeStep
+ clean
+
+ 1
+ 清除
+ 清除
+ ProjectExplorer.BuildSteps.Clean
+
+ 2
+ false
+
+ false
+
+ Release
+ Qt4ProjectManager.Qt4BuildConfiguration
+ 0
+ 0
+
+
+ 0
+ C:\Users\qw200\Documents\C or C++ for YANG\build-YANG-PCpet-Desktop_Qt_6_6_0_MinGW_64_bit-Profile
+ C:/Users/qw200/Documents/C or C++ for YANG/build-YANG-PCpet-Desktop_Qt_6_6_0_MinGW_64_bit-Profile
+
+
+ true
+ QtProjectManager.QMakeBuildStep
+ false
+
+
+
+ true
+ Qt4ProjectManager.MakeStep
+
+ 2
+ 构建
+ 构建
+ ProjectExplorer.BuildSteps.Build
+
+
+
+ true
+ Qt4ProjectManager.MakeStep
+ clean
+
+ 1
+ 清除
+ 清除
+ ProjectExplorer.BuildSteps.Clean
+
+ 2
+ false
+
+ false
+
+ Profile
+ Qt4ProjectManager.Qt4BuildConfiguration
+ 0
+ 0
+ 0
+
+ 3
+
+
+ 0
+ 部署
+ 部署
+ ProjectExplorer.BuildSteps.Deploy
+
+ 1
+
+ false
+ ProjectExplorer.DefaultDeployConfiguration
+
+ 1
+
+ true
+ true
+ 0
+ true
+
+
+ 2
+
+ false
+ YANG-PCpet2
+ Qt4ProjectManager.Qt4RunConfiguration:E:/C++-QT/YANG-PCpet/YANG-PCpet.pro
+ E:/C++-QT/YANG-PCpet/YANG-PCpet.pro
+ true
+ true
+ true
+ true
+ C:/Users/qw200/Documents/C or C++ for YANG/build-YANG-PCpet-Desktop_Qt_6_6_0_MinGW_64_bit-Release
+
+ 1
+
+
+
+ ProjectExplorer.Project.TargetCount
+ 1
+
+
+ ProjectExplorer.Project.Updater.FileVersion
+ 22
+
+
+ Version
+ 22
+
+
diff --git a/YANG-PCpet_zh_CN.ts b/YANG-PCpet_zh_CN.ts
new file mode 100644
index 0000000..14bccd1
--- /dev/null
+++ b/YANG-PCpet_zh_CN.ts
@@ -0,0 +1,3 @@
+
+
+
diff --git a/form.cpp b/form.cpp
new file mode 100644
index 0000000..875e4d5
--- /dev/null
+++ b/form.cpp
@@ -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()
+{
+
+}
+
diff --git a/form.h b/form.h
new file mode 100644
index 0000000..8a87b6f
--- /dev/null
+++ b/form.h
@@ -0,0 +1,31 @@
+#ifndef FORM_H
+#define FORM_H
+
+#include
+
+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
diff --git a/form.ui b/form.ui
new file mode 100644
index 0000000..20a5b92
--- /dev/null
+++ b/form.ui
@@ -0,0 +1,170 @@
+
+
+ Form
+
+
+
+ 0
+ 0
+ 506
+ 255
+
+
+
+ YANG-PCpet
+
+
+ -
+
+
-
+
+
+ <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>
+
+
+
+ -
+
+
-
+
+
+
+ 16777215
+ 15
+
+
+
+ <html><head/><body><p><span style=" font-weight:700;">自定义属性设置(通常情况下不需要用户设置)</span></p></body></html>
+
+
+
+ -
+
+
-
+
+
+ <html><head/><body><p><span style=" font-weight:700;">上边界</span></p></body></html>
+
+
+
+ -
+
+
+ -
+
+
+ <html><head/><body><p><span style=" font-weight:700;">宽</span></p></body></html>
+
+
+
+ -
+
+
+
+
+ -
+
+
-
+
+
+ <html><head/><body><p><span style=" font-weight:700;">下边界</span></p></body></html>
+
+
+
+ -
+
+
+ -
+
+
+ <html><head/><body><p><span style=" font-weight:700;">高</span></p></body></html>
+
+
+
+ -
+
+
+
+
+ -
+
+
-
+
+
+ <html><head/><body><p><span style=" font-weight:700;">左边界</span></p></body></html>
+
+
+
+ -
+
+
+ -
+
+
+ <html><head/><body><p><span style=" font-weight:700;">缓慢度</span></p></body></html>
+
+
+
+ -
+
+
+
+
+ -
+
+
-
+
+
+ <html><head/><body><p><span style=" font-weight:700;">右边界</span></p></body></html>
+
+
+
+ -
+
+
+ -
+
+
+ 保存设置
+
+
+
+ -
+
+
+ 恢复默认
+
+
+
+
+
+ -
+
+
-
+
+
+ Tonken
+
+
+
+ -
+
+
+ -
+
+
+ 保存
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/main.cpp b/main.cpp
new file mode 100644
index 0000000..9753c55
--- /dev/null
+++ b/main.cpp
@@ -0,0 +1,40 @@
+
+#include "widget.h"
+#include "form.h"
+#include
+#include "widget.h"
+#include
+#include
+#include
+#include
+#include
+#include
+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();
+}
diff --git a/widget.cpp b/widget.cpp
new file mode 100644
index 0000000..3c5952d
--- /dev/null
+++ b/widget.cpp
@@ -0,0 +1,491 @@
+
+#include "widget.h"
+#include "qboxlayout.h"
+#include "ui_widget.h"
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+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(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();
+ });
+}
+
diff --git a/widget.h b/widget.h
new file mode 100644
index 0000000..b57056f
--- /dev/null
+++ b/widget.h
@@ -0,0 +1,96 @@
+
+#ifndef WIDGET_H
+#define WIDGET_H
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+
+
+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
diff --git a/widget.ui b/widget.ui
new file mode 100644
index 0000000..2974ce8
--- /dev/null
+++ b/widget.ui
@@ -0,0 +1,143 @@
+
+
+ Widget
+
+
+
+ 0
+ 0
+ 242
+ 99
+
+
+
+ Widget
+
+
+
+
+ 210
+ 80
+ 31
+ 20
+
+
+
+ 交流
+
+
+
+
+
+ 23
+ 70
+ 91
+ 20
+
+
+
+
+
+
+ 0
+ 0
+ 16
+ 101
+
+
+
+
+ 0
+ 0
+
+
+
+
+ true
+
+
+
+ <html><head/><body><p><br/></p></body></html>
+
+
+ 24
+
+
+ true
+
+
+ Qt::Vertical
+
+
+ false
+
+
+
+
+
+ 210
+ 60
+ 31
+ 20
+
+
+
+ 天气
+
+
+
+
+
+ 210
+ 40
+ 31
+ 20
+
+
+
+ 汇报
+
+
+
+
+
+ 210
+ 20
+ 31
+ 20
+
+
+
+ 洗澡
+
+
+
+
+
+ 210
+ 0
+ 31
+ 20
+
+
+
+ 喂食
+
+
+
+
+
+ 115
+ 70
+ 31
+ 20
+
+
+
+ 发送
+
+
+
+
+
+