commit 13f207b73c7ea68020bceb8dda346adf52907ce9 Author: gfdgd_xi <3025613752@qq.com> Date: Sat Apr 1 22:46:52 2023 +0800 基本实现 diff --git a/dclc-information.pro b/dclc-information.pro new file mode 100644 index 0000000..045eb0e --- /dev/null +++ b/dclc-information.pro @@ -0,0 +1,40 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2023-04-01T21:09:26 +# +#------------------------------------------------- + +QT += core gui network + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +TARGET = dclc-information +TEMPLATE = app + +# The following define makes your compiler emit warnings if you use +# any feature of Qt which has been marked as deprecated (the exact warnings +# depend on your compiler). Please consult the documentation of the +# deprecated API in order to know how to port your code away from it. +DEFINES += QT_DEPRECATED_WARNINGS + +# You can also make your code fail to compile if you use deprecated APIs. +# In order to do so, uncomment the following line. +# You can also select to disable deprecated APIs only up to a certain version of Qt. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + +CONFIG += c++11 + +SOURCES += \ + main.cpp \ + mainwindow.cpp + +HEADERS += \ + mainwindow.h + +FORMS += \ + mainwindow.ui + +# 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/dclc-information.pro.user b/dclc-information.pro.user new file mode 100644 index 0000000..26daad0 --- /dev/null +++ b/dclc-information.pro.user @@ -0,0 +1,322 @@ + + + + + + EnvironmentId + {4ffd6df9-1365-4837-81b1-582e0e2d1f21} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + true + false + 0 + true + true + 0 + 8 + true + 1 + true + true + true + false + + + + ProjectExplorer.Project.PluginSettings + + + + ProjectExplorer.Project.Target.0 + + Qt 5.15.6 in PATH (qt5) + Qt 5.15.6 in PATH (qt5) + {ab20853c-9d79-473a-820e-8e95c145170e} + 0 + 0 + 0 + + /home/gfdgd_xi/Desktop/build-dclc-information-Qt_5_15_6_in_PATH_qt5-Debug + + + true + qmake + + QtProjectManager.QMakeBuildStep + true + + false + false + false + + + true + Make + + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Debug + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + true + + + /home/gfdgd_xi/Desktop/build-dclc-information-Qt_5_15_6_in_PATH_qt5-Release + + + true + qmake + + QtProjectManager.QMakeBuildStep + false + + false + false + true + + + true + Make + + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + true + + + /home/gfdgd_xi/Desktop/build-dclc-information-Qt_5_15_6_in_PATH_qt5-Profile + + + true + qmake + + QtProjectManager.QMakeBuildStep + true + + false + true + true + + + true + Make + + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Profile + Profile + Qt4ProjectManager.Qt4BuildConfiguration + 0 + true + + 3 + + + 0 + 部署 + + ProjectExplorer.BuildSteps.Deploy + + 1 + Deploy Configuration + + ProjectExplorer.DefaultDeployConfiguration + + 1 + + + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + + Custom Executable + + ProjectExplorer.CustomExecutableRunConfiguration + + 3768 + false + true + false + false + true + + + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.FileVersion + 20 + + + Version + 20 + + diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..6c5a68d --- /dev/null +++ b/main.cpp @@ -0,0 +1,36 @@ +#include "mainwindow.h" +#include +#include +#include + +QString ReadTXT(QString path){ + QFile file(path); + file.open(QIODevice::ReadOnly); + QByteArray array = file.readAll(); + file.close(); + return array; +} + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + QString version = "1.7.0 install 版"; + if(QFile::exists("version.txt")){ + version = ReadTXT("version.txt"); + } + else if (QFile::exists("/etc/version.txt")) { + version = ReadTXT("/etc/version.txt"); + } + else { + QMessageBox::critical(NULL, "错误", "无法正确读取版本号"); + //return 1; + } + QCoreApplication::setApplicationName("dclc-information"); + QCoreApplication::setApplicationVersion(version); + QCoreApplication::setOrganizationName("gfdgd xi"); + QCoreApplication::setOrganizationDomain("https://gitee.com/gfdgd-xi"); + MainWindow w; + w.show(); + + return a.exec(); +} diff --git a/mainwindow.cpp b/mainwindow.cpp new file mode 100644 index 0000000..5073c01 --- /dev/null +++ b/mainwindow.cpp @@ -0,0 +1,105 @@ +#include "mainwindow.h" +#include "ui_mainwindow.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +MainWindow::MainWindow(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::MainWindow) +{ + ui->setupUi(this); + QString version = QCoreApplication::applicationVersion(); + QDateTime time = QDateTime::currentDateTime(); + ui->copyright->setText("

©2022~" + time.toString("yyyy") + " gfdgd xi

"); + ui->versionLabel->setText("程序版本号:" + version + ""); + this->setWindowTitle("关于 Deepin Community Live CD " + version); + +} + +QString MainWindow::GetHTTP(QString url){ + QNetworkAccessManager *manager = new QNetworkAccessManager(); + QNetworkRequest req; + req.setUrl(url); + req.setAttribute(QNetworkRequest::FollowRedirectsAttribute, 1); + QNetworkReply *reply = manager->get(req); + + //req.setPriority(); + QEventLoop loop; + connect(reply, &QNetworkReply::finished, &loop, &QEventLoop::quit); + loop.exec(QEventLoop::ExcludeUserInputEvents); + QVariant redirectAttr = reply->attribute(QNetworkRequest::RedirectionTargetAttribute); + if(reply->error() + ||!redirectAttr.isNull()){ + qDebug() << "网络异常" << QString("发送get请求时出现错误:\n网址:%1\n错误信息:%2").arg(reply->request().url().toDisplayString(), reply->errorString()); + } + QByteArray data = reply->readAll(); + reply->deleteLater(); + reply->close(); + delete reply; + return data; +} + +MainWindow::~MainWindow() +{ + delete ui; +} + +void MainWindow::on_pushButton_clicked() +{ + this->close(); +} + +void MainWindow::on_pushButton_2_clicked() +{ + QDesktopServices::openUrl(QUrl("https://github.com/gfdgd-xi/deepin-community-live-cd/")); +} + +QString MainWindow::ReadTXT(QString path){ + QFile file(path); + file.open(QIODevice::ReadOnly); + QByteArray array = file.readAll(); + file.close(); + return array; +} + +void MainWindow::on_isnewest_clicked() +{ + QString typeName = "install"; + if(QFile::exists("systemtype.txt")){ + typeName = ReadTXT("systemtype.txt").replace(" ", "").replace("\n", ""); + } + else if (QFile::exists("/etc/systemtype.txt")) { + typeName = ReadTXT("/etc/systemtype.txt").replace(" ", "").replace("\n", ""); + } + QString version = QCoreApplication::applicationVersion(); + QString miniversion = version; + if(version.contains(" ")){ + miniversion = ""; + for (int i = 0; i < version.indexOf(" "); i++) { + miniversion += version[i]; + } + + } + qDebug() << miniversion; + QString result = GetHTTP("http://dclc.gfdgdxi.top/newversion-" + typeName + ".txt").replace("\n", "").replace(" ", ""); + if(result == ""){ + QMessageBox::critical(this, "错误", "无法连接服务器"); + return; + } + else if(result == miniversion){ + QMessageBox::information(this, "提示", "当前已是最新版本"); + return; + } + else { + if(QMessageBox::question(this, "提示", "当前镜像不是最新版本,是否立即获取?\n检测到的最新版本:" + result + "\n当前版本:" + miniversion) == QMessageBox::Yes) { + QDesktopServices::openUrl(QUrl("https://github.com/gfdgd-xi/deepin-community-live-cd/")); + } + } +} diff --git a/mainwindow.h b/mainwindow.h new file mode 100644 index 0000000..e0b9871 --- /dev/null +++ b/mainwindow.h @@ -0,0 +1,32 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include + +namespace Ui { +class MainWindow; +} + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit MainWindow(QWidget *parent = nullptr); + QString GetHTTP(QString url); + QString ReadTXT(QString path); + ~MainWindow(); + +private slots: + void on_pushButton_clicked(); + + + void on_pushButton_2_clicked(); + + void on_isnewest_clicked(); + +private: + Ui::MainWindow *ui; +}; + +#endif // MAINWINDOW_H diff --git a/mainwindow.ui b/mainwindow.ui new file mode 100644 index 0000000..d1c7e1d --- /dev/null +++ b/mainwindow.ui @@ -0,0 +1,96 @@ + + + MainWindow + + + + 0 + 0 + 967 + 450 + + + + MainWindow + + + + + + + <html><head/><body><p>Deepin Community Live CD(简称 dclc) 旨在用户系统出现问题时进行修复、维护以及临时办公</p><p>此 Live CD 借鉴了以下文章的内容: <br/>https://bbs.deepin.org/post/228930 @deepin-superuser </p><p>https://bbs.deepin.org/post/228568 @木一明 </p><p><span style=" font-weight:600;">install、full 用户密码(包括root密码)为:123456</span><br/><span style=" font-weight:600;">tiny、mini root 密码未知</span></p><p>项目地址:http://dclc.gfdgdxi.top/</p><p>代码仓库:https://gitee.com/gfdgd-xi/deepin-community-live-cd/</p><p>https://github.com/gfdgd-xi/deepin-community-live-cd/</p><p>https://gitlink.org.cn/gfdgd_xi/deepin-community-live-cd/</p></body></html> + + + + + + + <html><head/><body><p>当前版本:1.7.0 install版</p></body></html> + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + ©2022~2023 gfdgd xi + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + 检测程序版本 + + + + + + + 打开程序网站 + + + + + + + 确定 + + + + + + + + + + + +