From b0c688a6c8270d6ea37bd4036c56fa25439aca36 Mon Sep 17 00:00:00 2001 From: momen Date: Tue, 27 May 2025 20:23:19 +0800 Subject: [PATCH 001/114] =?UTF-8?q?update:=E5=88=9D=E5=A7=8B=E5=8C=96?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 + src/CMakeLists.txt | 70 ++++++ src/CMakeLists.txt.user | 462 ++++++++++++++++++++++++++++++++++++++++ src/main.cpp | 11 + src/mainwindow.cpp | 14 ++ src/mainwindow.h | 23 ++ src/mainwindow.ui | 31 +++ 7 files changed, 614 insertions(+) create mode 100644 .gitignore create mode 100644 src/CMakeLists.txt create mode 100644 src/CMakeLists.txt.user create mode 100644 src/main.cpp create mode 100644 src/mainwindow.cpp create mode 100644 src/mainwindow.h create mode 100644 src/mainwindow.ui diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..20e0241 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +build +.vscode +.cache \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..2e04149 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,70 @@ +cmake_minimum_required(VERSION 3.16) + +project(Spark-Update-Tool VERSION 0.1 LANGUAGES CXX) + +set(CMAKE_AUTOUIC ON) +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets) +find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets) + +set(PROJECT_SOURCES + main.cpp + mainwindow.cpp + mainwindow.h + mainwindow.ui +) + +if(${QT_VERSION_MAJOR} GREATER_EQUAL 6) + qt_add_executable(Spark-Update-Tool + MANUAL_FINALIZATION + ${PROJECT_SOURCES} + ) +# Define target properties for Android with Qt 6 as: +# set_property(TARGET Spark-Update-Tool APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR +# ${CMAKE_CURRENT_SOURCE_DIR}/android) +# For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation +else() + if(ANDROID) + add_library(Spark-Update-Tool SHARED + ${PROJECT_SOURCES} + ) +# Define properties for Android with Qt 5 after find_package() calls as: +# set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android") + else() + add_executable(Spark-Update-Tool + ${PROJECT_SOURCES} + ) + endif() +endif() + +target_link_libraries(Spark-Update-Tool PRIVATE Qt${QT_VERSION_MAJOR}::Widgets) + +# Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1. +# If you are developing for iOS or macOS you should consider setting an +# explicit, fixed bundle identifier manually though. +if(${QT_VERSION} VERSION_LESS 6.1.0) + set(BUNDLE_ID_OPTION MACOSX_BUNDLE_GUI_IDENTIFIER com.example.Spark-Update-Tool) +endif() +set_target_properties(Spark-Update-Tool PROPERTIES + ${BUNDLE_ID_OPTION} + MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION} + MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} + MACOSX_BUNDLE TRUE + WIN32_EXECUTABLE TRUE +) + +include(GNUInstallDirs) +install(TARGETS Spark-Update-Tool + BUNDLE DESTINATION . + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} +) + +if(QT_VERSION_MAJOR EQUAL 6) + qt_finalize_executable(Spark-Update-Tool) +endif() diff --git a/src/CMakeLists.txt.user b/src/CMakeLists.txt.user new file mode 100644 index 0000000..97d9b36 --- /dev/null +++ b/src/CMakeLists.txt.user @@ -0,0 +1,462 @@ + + + + + + EnvironmentId + {d06980a7-632a-4db9-8fae-55a42ba2ccc5} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + true + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 0 + 80 + true + true + 1 + 0 + false + true + false + 2 + 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 + + false + + + 0 + true + + true + true + Builtin.DefaultTidyAndClazy + 8 + true + + + + true + + + + + ProjectExplorer.Project.Target.0 + + Desktop + Desktop Qt 6.9.0 + Desktop Qt 6.9.0 + qt.qt6.690.linux_gcc_64_kit + 0 + 0 + 0 + + Debug + 2 + false + + -DCMAKE_COLOR_DIAGNOSTICS:BOOL=ON +-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX} +-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx} +-DCMAKE_GENERATOR:STRING=Ninja +-DCMAKE_BUILD_TYPE:STRING=Debug +-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG} +-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} +-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake +-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} + 0 + /home/momen/Spark-Update-Tool/build/Desktop_Qt_6_9_0-Debug + + + + + all + + false + + true + 构建 + CMakeProjectManager.MakeStep + + 1 + 构建 + 构建 + ProjectExplorer.BuildSteps.Build + + + + + + clean + + false + + true + 构建 + CMakeProjectManager.MakeStep + + 1 + 清除 + 清除 + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Debug + CMakeProjectManager.CMakeBuildConfiguration + + + Release + 2 + false + + -DCMAKE_COLOR_DIAGNOSTICS:BOOL=ON +-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX} +-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx} +-DCMAKE_GENERATOR:STRING=Ninja +-DCMAKE_BUILD_TYPE:STRING=Release +-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG} +-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} +-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake +-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} + /home/momen/Spark-Update-Tool/build/Desktop_Qt_6_9_0-Release + + + + + all + + false + + true + CMakeProjectManager.MakeStep + + 1 + 构建 + 构建 + ProjectExplorer.BuildSteps.Build + + + + + + clean + + false + + true + CMakeProjectManager.MakeStep + + 1 + 清除 + 清除 + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Release + CMakeProjectManager.CMakeBuildConfiguration + + + RelWithDebInfo + 2 + false + + -DCMAKE_COLOR_DIAGNOSTICS:BOOL=ON +-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX} +-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx} +-DCMAKE_GENERATOR:STRING=Ninja +-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo +-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG} +-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} +-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake +-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} + /home/momen/Spark-Update-Tool/build/Desktop_Qt_6_9_0-RelWithDebInfo + + + + + all + + false + + true + CMakeProjectManager.MakeStep + + 1 + 构建 + 构建 + ProjectExplorer.BuildSteps.Build + + + + + + clean + + false + + true + CMakeProjectManager.MakeStep + + 1 + 清除 + 清除 + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Release with Debug Information + CMakeProjectManager.CMakeBuildConfiguration + + + RelWithDebInfo + 2 + false + + -DCMAKE_COLOR_DIAGNOSTICS:BOOL=ON +-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX} +-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx} +-DCMAKE_GENERATOR:STRING=Ninja +-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo +-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG} +-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} +-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake +-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} + 0 + /home/momen/Spark-Update-Tool/build/Desktop_Qt_6_9_0-Profile + + + + + all + + false + + true + CMakeProjectManager.MakeStep + + 1 + 构建 + 构建 + ProjectExplorer.BuildSteps.Build + + + + + + clean + + false + + true + CMakeProjectManager.MakeStep + + 1 + 清除 + 清除 + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Profile + CMakeProjectManager.CMakeBuildConfiguration + + + MinSizeRel + 2 + false + + -DCMAKE_COLOR_DIAGNOSTICS:BOOL=ON +-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX} +-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx} +-DCMAKE_GENERATOR:STRING=Ninja +-DCMAKE_BUILD_TYPE:STRING=MinSizeRel +-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG} +-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} +-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake +-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} + /home/momen/Spark-Update-Tool/build/Desktop_Qt_6_9_0-MinSizeRel + + + + + all + + false + + true + CMakeProjectManager.MakeStep + + 1 + 构建 + 构建 + ProjectExplorer.BuildSteps.Build + + + + + + clean + + false + + true + CMakeProjectManager.MakeStep + + 1 + 清除 + 清除 + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Minimum Size Release + CMakeProjectManager.CMakeBuildConfiguration + + 5 + + + 0 + 部署 + 部署 + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + ProjectExplorer.DefaultDeployConfiguration + + + + + + + + + false + + true + ApplicationManagerPlugin.Deploy.CMakePackageStep + + + install-package --acknowledge + true + Install Application Manager package + ApplicationManagerPlugin.Deploy.InstallPackageStep + + + + + + + + 2 + 部署 + 部署 + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + ApplicationManagerPlugin.Deploy.Configuration + + 2 + + true + true + 0 + true + + 2 + + false + -e cpu-cycles --call-graph dwarf,4096 -F 250 + Spark-Update-Tool + CMakeProjectManager.CMakeRunConfiguration. + Spark-Update-Tool + false + true + true + true + /home/momen/Spark-Update-Tool/build/Desktop_Qt_6_9_0-Debug + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.FileVersion + 22 + + + Version + 22 + + diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..fd3e533 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,11 @@ +#include "mainwindow.h" + +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + MainWindow w; + w.show(); + return a.exec(); +} diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp new file mode 100644 index 0000000..6395a77 --- /dev/null +++ b/src/mainwindow.cpp @@ -0,0 +1,14 @@ +#include "mainwindow.h" +#include "./ui_mainwindow.h" + +MainWindow::MainWindow(QWidget *parent) + : QMainWindow(parent) + , ui(new Ui::MainWindow) +{ + ui->setupUi(this); +} + +MainWindow::~MainWindow() +{ + delete ui; +} diff --git a/src/mainwindow.h b/src/mainwindow.h new file mode 100644 index 0000000..f7a3da3 --- /dev/null +++ b/src/mainwindow.h @@ -0,0 +1,23 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include + +QT_BEGIN_NAMESPACE +namespace Ui { +class MainWindow; +} +QT_END_NAMESPACE + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + MainWindow(QWidget *parent = nullptr); + ~MainWindow(); + +private: + Ui::MainWindow *ui; +}; +#endif // MAINWINDOW_H diff --git a/src/mainwindow.ui b/src/mainwindow.ui new file mode 100644 index 0000000..c6854ca --- /dev/null +++ b/src/mainwindow.ui @@ -0,0 +1,31 @@ + + + MainWindow + + + + 0 + 0 + 800 + 600 + + + + MainWindow + + + + + + 0 + 0 + 800 + 23 + + + + + + + + From e602dd8823e0da60536e00181577b6745a97ac90 Mon Sep 17 00:00:00 2001 From: momen Date: Wed, 28 May 2025 20:12:55 +0800 Subject: [PATCH 002/114] =?UTF-8?q?update:=E6=9B=B4=E6=96=B0=E4=B8=BB?= =?UTF-8?q?=E7=95=8C=E9=9D=A2=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mainwindow.ui | 245 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 240 insertions(+), 5 deletions(-) diff --git a/src/mainwindow.ui b/src/mainwindow.ui index c6854ca..d8e6412 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -6,25 +6,260 @@ 0 0 - 800 - 600 + 1440 + 858 MainWindow - + + + + + 30 + 20 + 1381 + 31 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + Noto Sans Vai + 22 + + + + 软件更新中心 + + + + + + + Qt::Orientation::Horizontal + + + + 1204 + 20 + + + + + + + + + + 30 + 60 + 1376 + 746 + + + + + + 10 + 10 + 1351 + 58 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 320 + 38 + + + + + 320 + 38 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 16 + 16 + + + + + 16 + 16 + + + + + + + + + + + + 200 + 38 + + + + 搜索软件... + + + + + + + + + + Qt::Orientation::Horizontal + + + + 40 + 20 + + + + + + + + + 214 + 40 + + + + + 214 + 40 + + + + + + 0 + 0 + 102 + 38 + + + + + 102 + 38 + + + + + 102 + 38 + + + + + PreferNoHinting + + + + Qt::LayoutDirection::LeftToRight + + + QComboBox::SizeAdjustPolicy::AdjustToContentsOnFirstShow + + + + 按名称 + + + + + + + 118 + 0 + 96 + 40 + + + + 更新全部 + + + + + + + + 0 0 - 800 + 1440 23 - From b8846eb9b6b49d06c48d367a2af092f492fb8819 Mon Sep 17 00:00:00 2001 From: momen Date: Wed, 28 May 2025 20:18:01 +0800 Subject: [PATCH 003/114] =?UTF-8?q?update:=E6=9B=B4=E6=96=B0=E4=B8=BB?= =?UTF-8?q?=E7=95=8C=E9=9D=A2=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mainwindow.ui | 473 ++++++++++++++++++++++++---------------------- 1 file changed, 249 insertions(+), 224 deletions(-) diff --git a/src/mainwindow.ui b/src/mainwindow.ui index d8e6412..0e92b43 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -14,241 +14,266 @@ MainWindow - - - - 30 - 20 - 1381 - 31 - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - Noto Sans Vai - 22 - + + + + + + 0 - - 软件更新中心 + + 0 - - - - - - Qt::Orientation::Horizontal + + 0 - - - 1204 - 20 - + + 0 - - - - - - - - 30 - 60 - 1376 - 746 - - - - - - 10 - 10 - 1351 - 58 - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 320 - 38 - - - - - 320 - 38 - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 16 - 16 - - - - - 16 - 16 - - - - - - - - - - - - 200 - 38 - - - - 搜索软件... - - - - - - - - - - Qt::Orientation::Horizontal - - - - 40 - 20 - - - - - - - - - 214 - 40 - - - - - 214 - 40 - - - - - - 0 - 0 - 102 - 38 - - - - - 102 - 38 - - - - - 102 - 38 - - + + 0 + + + - PreferNoHinting + Noto Sans Vai + 22 - - Qt::LayoutDirection::LeftToRight - - - QComboBox::SizeAdjustPolicy::AdjustToContentsOnFirstShow - - - - 按名称 - - - - - - - 118 - 0 - 96 - 40 - - - 更新全部 + 软件更新中心 - - - - - + + + + + Qt::Orientation::Horizontal + + + + 1245 + 20 + + + + + + + + + + + + 1376 + 746 + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 320 + 38 + + + + + 320 + 38 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 16 + 16 + + + + + 16 + 16 + + + + + + + + + + + + 200 + 38 + + + + 搜索软件... + + + + + + + + + + Qt::Orientation::Horizontal + + + + 40 + 20 + + + + + + + + + 214 + 40 + + + + + 214 + 40 + + + + + + 0 + 0 + 102 + 38 + + + + + 102 + 38 + + + + + 102 + 38 + + + + + PreferNoHinting + + + + Qt::LayoutDirection::LeftToRight + + + QComboBox::SizeAdjustPolicy::AdjustToContentsOnFirstShow + + + + 按名称 + + + + + + + 118 + 0 + 96 + 40 + + + + 更新全部 + + + + + + + + + + + + 0 + 20 + + + + + + 0 + 0 + 96 + 24 + + + + 全选 + + + + + + + + + 598 + 1328 + + + + + + + + From 65172300bea60bf41011e2435bb27047af46a3da Mon Sep 17 00:00:00 2001 From: momen Date: Wed, 28 May 2025 20:40:40 +0800 Subject: [PATCH 004/114] =?UTF-8?q?update:=E6=9B=B4=E6=96=B0=E7=BB=88?= =?UTF-8?q?=E7=AB=AF=E8=B0=83=E7=94=A8aptss=E5=91=BD=E4=BB=A4=E5=B1=95?= =?UTF-8?q?=E7=A4=BA=E5=8F=AF=E6=9B=B4=E6=96=B0=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/CMakeLists.txt | 1 + src/aptssupdater.cpp | 36 ++++++++++++++++++++++++++++++++++++ src/aptssupdater.h | 19 +++++++++++++++++++ src/mainwindow.cpp | 14 ++++++++++++++ src/mainwindow.h | 3 ++- 5 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 src/aptssupdater.cpp create mode 100644 src/aptssupdater.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2e04149..e6f7623 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -23,6 +23,7 @@ if(${QT_VERSION_MAJOR} GREATER_EQUAL 6) qt_add_executable(Spark-Update-Tool MANUAL_FINALIZATION ${PROJECT_SOURCES} + aptssupdater.h aptssupdater.cpp ) # Define target properties for Android with Qt 6 as: # set_property(TARGET Spark-Update-Tool APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR diff --git a/src/aptssupdater.cpp b/src/aptssupdater.cpp new file mode 100644 index 0000000..4e7fd13 --- /dev/null +++ b/src/aptssupdater.cpp @@ -0,0 +1,36 @@ +#include "aptssupdater.h" +#include +#include +#include +aptssUpdater::aptssUpdater(QWidget *parent) + : QWidget(parent) +{ + +} +QStringList aptssUpdater::getUpdateablePackages() +{ + QStringList packageDetails; + QProcess process; + process.start("bash", QStringList() << "-c" << "aptss list --upgradable"); + process.waitForFinished(); + + QString output = process.readAllStandardOutput(); + QTextStream stream(&output); + + // 跳过第一行(提示信息) + stream.readLine(); + + while (!stream.atEnd()) { + QString line = stream.readLine(); + QRegularExpression regex(R"((\S+)/\S+\s+\S+\s+\S+\s+\[可从该版本升级:(.+)\])"); + QRegularExpressionMatch match = regex.match(line); + + if (match.hasMatch()) { + QString packageName = match.captured(1); + QString updateDetails = match.captured(2); + packageDetails << QString("%1: %2").arg(packageName, updateDetails); + } + } + + return packageDetails; +} diff --git a/src/aptssupdater.h b/src/aptssupdater.h new file mode 100644 index 0000000..b79aab1 --- /dev/null +++ b/src/aptssupdater.h @@ -0,0 +1,19 @@ +#ifndef APTSSUPDATER_H +#define APTSSUPDATER_H + +#include +#include + +class aptssUpdater : public QWidget +{ + Q_OBJECT +public: + explicit aptssUpdater(QWidget *parent = nullptr); + + QStringList getUpdateablePackages(); // 查询可更新包列表及更新内容 + qint64 getTotalDownloadSize(); // 获取更新总大小预估 + +signals: +}; + +#endif // APTSSUPDATER_H \ No newline at end of file diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 6395a77..815de12 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -5,8 +5,22 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { + checkUpdates(); ui->setupUi(this); } +void MainWindow::checkUpdates() +{ + aptssUpdater updater; + + // 获取可更新包列表 + QStringList updateablePackages = updater.getUpdateablePackages(); + qDebug() << "可更新包列表:"; + for (const QString &package : updateablePackages) { + qDebug() << package; + } + + +} MainWindow::~MainWindow() { diff --git a/src/mainwindow.h b/src/mainwindow.h index f7a3da3..a172253 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -2,7 +2,7 @@ #define MAINWINDOW_H #include - +#include "aptssupdater.h" QT_BEGIN_NAMESPACE namespace Ui { class MainWindow; @@ -19,5 +19,6 @@ public: private: Ui::MainWindow *ui; + void checkUpdates(); }; #endif // MAINWINDOW_H From 17b5c9afcea6990eddadf9a6607a3b33dce2d1e2 Mon Sep 17 00:00:00 2001 From: momen Date: Wed, 28 May 2025 21:05:04 +0800 Subject: [PATCH 005/114] =?UTF-8?q?update:=E8=BE=93=E5=87=BA=E8=BD=AF?= =?UTF-8?q?=E4=BB=B6=E5=8C=85=E5=A4=A7=E5=B0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/aptssupdater.cpp | 37 ++++++++++++++++++++++++++++++++++--- src/aptssupdater.h | 2 +- src/mainwindow.cpp | 10 ++++++---- 3 files changed, 41 insertions(+), 8 deletions(-) diff --git a/src/aptssupdater.cpp b/src/aptssupdater.cpp index 4e7fd13..de52504 100644 --- a/src/aptssupdater.cpp +++ b/src/aptssupdater.cpp @@ -22,15 +22,46 @@ QStringList aptssUpdater::getUpdateablePackages() while (!stream.atEnd()) { QString line = stream.readLine(); - QRegularExpression regex(R"((\S+)/\S+\s+\S+\s+\S+\s+\[可从该版本升级:(.+)\])"); + QRegularExpression regex(R"((\S+)/\S+\s+(\S+)\s+\S+\s+\[可从该版本升级:(.+)\])"); QRegularExpressionMatch match = regex.match(line); if (match.hasMatch()) { QString packageName = match.captured(1); - QString updateDetails = match.captured(2); - packageDetails << QString("%1: %2").arg(packageName, updateDetails); + QString currentVersion = match.captured(2); + QString updateVersion = match.captured(3); + packageDetails << QString("%1 (%2 -> %3)").arg(packageName, currentVersion, updateVersion); } } return packageDetails; } +QStringList aptssUpdater::getPackageSizes() +{ + QStringList packageSizes; + QProcess process; + process.start("bash", QStringList() << "-c" << "aptss upgrade --assume-no"); + + // 自动回复 "n" 以跳过交互式提示 + if (process.waitForStarted()) { + process.write("n\n"); + } + + process.waitForFinished(); + + QString output = process.readAllStandardOutput(); + QTextStream stream(&output); + + while (!stream.atEnd()) { + QString line = stream.readLine(); + QRegularExpression regex(R"((\S+)\s+\S+\s+(\d+(?:\.\d+)?(?:KiB|MiB)))"); + QRegularExpressionMatch match = regex.match(line); + + if (match.hasMatch()) { + QString packageName = match.captured(1); + QString packageSize = match.captured(2); + packageSizes << QString("%1: %2").arg(packageName, packageSize); + } + } + + return packageSizes; +} \ No newline at end of file diff --git a/src/aptssupdater.h b/src/aptssupdater.h index b79aab1..35a7061 100644 --- a/src/aptssupdater.h +++ b/src/aptssupdater.h @@ -12,7 +12,7 @@ public: QStringList getUpdateablePackages(); // 查询可更新包列表及更新内容 qint64 getTotalDownloadSize(); // 获取更新总大小预估 - + QStringList getPackageSizes(); // 获取每个包的大小 signals: }; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 815de12..e6bb874 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -14,12 +14,14 @@ void MainWindow::checkUpdates() // 获取可更新包列表 QStringList updateablePackages = updater.getUpdateablePackages(); + QStringList packageSizes = updater.getPackageSizes(); + qDebug() << "可更新包列表:"; - for (const QString &package : updateablePackages) { - qDebug() << package; + for (int i = 0; i < updateablePackages.size(); ++i) { + QString packageInfo = updateablePackages.at(i); + QString packageSize = (i < packageSizes.size()) ? packageSizes.at(i) : "未知大小"; + qDebug() << QString("%1 (%2)").arg(packageInfo, packageSize); } - - } MainWindow::~MainWindow() From ddf1f7396b49121b147c3328f8bf94d98be6bd5a Mon Sep 17 00:00:00 2001 From: momen Date: Wed, 28 May 2025 22:22:23 +0800 Subject: [PATCH 006/114] =?UTF-8?q?update:=E4=BB=8Edesktop=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E4=B8=AD=E6=8F=90=E5=8F=96=E5=BA=94=E7=94=A8=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/aptssupdater.cpp | 34 ++++++++++++++++++++++++++++++++++ src/aptssupdater.h | 2 ++ src/mainwindow.cpp | 5 ++++- 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/aptssupdater.cpp b/src/aptssupdater.cpp index de52504..cab8801 100644 --- a/src/aptssupdater.cpp +++ b/src/aptssupdater.cpp @@ -2,11 +2,14 @@ #include #include #include +#include + aptssUpdater::aptssUpdater(QWidget *parent) : QWidget(parent) { } + QStringList aptssUpdater::getUpdateablePackages() { QStringList packageDetails; @@ -35,6 +38,7 @@ QStringList aptssUpdater::getUpdateablePackages() return packageDetails; } + QStringList aptssUpdater::getPackageSizes() { QStringList packageSizes; @@ -64,4 +68,34 @@ QStringList aptssUpdater::getPackageSizes() } return packageSizes; +} + +QStringList aptssUpdater::getDesktopAppNames() +{ + QStringList appNames; + QStringList updateablePackages = getUpdateablePackages(); + + for (const QString &packageDetail : updateablePackages) { + // 提取包名(忽略版本信息) + QString packageName = packageDetail.split(' ').first(); + QString desktopFilePath = QString("/usr/share/applications/%1.desktop").arg(packageName); + + QFile desktopFile(desktopFilePath); + if (desktopFile.exists() && desktopFile.open(QIODevice::ReadOnly)) { + QTextStream stream(&desktopFile); + while (!stream.atEnd()) { + QString line = stream.readLine(); + if (line.startsWith("Name=")) { + QString appName = line.mid(5); // 提取 Name 属性值 + appNames << appName; + break; + } + } + desktopFile.close(); + } else { + appNames << QString("未找到 .desktop 文件: %1").arg(packageName); + } + } + + return appNames; } \ No newline at end of file diff --git a/src/aptssupdater.h b/src/aptssupdater.h index 35a7061..7ff6f87 100644 --- a/src/aptssupdater.h +++ b/src/aptssupdater.h @@ -13,6 +13,8 @@ public: QStringList getUpdateablePackages(); // 查询可更新包列表及更新内容 qint64 getTotalDownloadSize(); // 获取更新总大小预估 QStringList getPackageSizes(); // 获取每个包的大小 + QStringList getDesktopAppNames(); // 获取桌面应用名称列表 + signals: }; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index e6bb874..3ee5562 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -15,13 +15,16 @@ void MainWindow::checkUpdates() // 获取可更新包列表 QStringList updateablePackages = updater.getUpdateablePackages(); QStringList packageSizes = updater.getPackageSizes(); - + QStringList appNames = updater.getDesktopAppNames(); qDebug() << "可更新包列表:"; for (int i = 0; i < updateablePackages.size(); ++i) { QString packageInfo = updateablePackages.at(i); QString packageSize = (i < packageSizes.size()) ? packageSizes.at(i) : "未知大小"; qDebug() << QString("%1 (%2)").arg(packageInfo, packageSize); } + for (const QString &appName : appNames) { + qDebug() << appName; + } } MainWindow::~MainWindow() From 782066cf57f347a3ac96b479f79e36db84c08b9e Mon Sep 17 00:00:00 2001 From: momen Date: Thu, 29 May 2025 20:29:12 +0800 Subject: [PATCH 007/114] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E5=8F=B7=E6=98=BE=E7=A4=BA=E9=94=99=E8=AF=AF=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/aptssupdater.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/aptssupdater.cpp b/src/aptssupdater.cpp index cab8801..e9e7eab 100644 --- a/src/aptssupdater.cpp +++ b/src/aptssupdater.cpp @@ -30,8 +30,8 @@ QStringList aptssUpdater::getUpdateablePackages() if (match.hasMatch()) { QString packageName = match.captured(1); - QString currentVersion = match.captured(2); - QString updateVersion = match.captured(3); + QString updateVersion = match.captured(2); + QString currentVersion = match.captured(3); packageDetails << QString("%1 (%2 -> %3)").arg(packageName, currentVersion, updateVersion); } } From fdd5fcaef14802ca92fe8a3074b5b28b3aa4035b Mon Sep 17 00:00:00 2001 From: momen Date: Fri, 30 May 2025 21:31:12 +0800 Subject: [PATCH 008/114] =?UTF-8?q?docs:=E6=B7=BB=E5=8A=A0readme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- READE.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 READE.md diff --git a/READE.md b/READE.md new file mode 100644 index 0000000..3a1fca0 --- /dev/null +++ b/READE.md @@ -0,0 +1,5 @@ +### 星火软件更新器 +#### 简介 + +欢迎使用星火软件更新器,你可以用这个更新器更新位于你电脑的程序。 + From 7a1eeb8d4d8435cc6908710be75cca8b2f128bc2 Mon Sep 17 00:00:00 2001 From: momen Date: Sat, 31 May 2025 13:01:56 +0800 Subject: [PATCH 009/114] =?UTF-8?q?update:=E6=9B=B4=E6=96=B0readme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- READE.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/READE.md b/READE.md index 3a1fca0..2e25a78 100644 --- a/READE.md +++ b/READE.md @@ -3,3 +3,6 @@ 欢迎使用星火软件更新器,你可以用这个更新器更新位于你电脑的程序。 +#### 当前支持的Linux发行版 + +#### 联系与反馈 \ No newline at end of file From 3dde50ce2783fff53a491ca5b5608dd042accb10 Mon Sep 17 00:00:00 2001 From: momen Date: Sun, 1 Jun 2025 13:11:16 +0800 Subject: [PATCH 010/114] =?UTF-8?q?update:=E5=88=9B=E5=BB=BA=E5=88=9D?= =?UTF-8?q?=E5=A7=8B=E5=8C=96=E6=A0=B7=E5=BC=8F=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mainwindow.cpp | 5 +++++ src/mainwindow.h | 1 + 2 files changed, 6 insertions(+) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 3ee5562..8e4798d 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -7,6 +7,11 @@ MainWindow::MainWindow(QWidget *parent) { checkUpdates(); ui->setupUi(this); +} +//初始化控件样式 +void MainWindow::initStyle() +{ + } void MainWindow::checkUpdates() { diff --git a/src/mainwindow.h b/src/mainwindow.h index a172253..361f01f 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -20,5 +20,6 @@ public: private: Ui::MainWindow *ui; void checkUpdates(); + void initStyle(); }; #endif // MAINWINDOW_H From e331f8d58006153f88f3954af8996235e47f46d8 Mon Sep 17 00:00:00 2001 From: momen Date: Mon, 2 Jun 2025 13:40:47 +0800 Subject: [PATCH 011/114] =?UTF-8?q?update:=E6=9B=B4=E6=96=B0=E8=BE=93?= =?UTF-8?q?=E5=85=A5=E6=A1=86=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mainwindow.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 8e4798d..158882c 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -7,10 +7,18 @@ MainWindow::MainWindow(QWidget *parent) { checkUpdates(); ui->setupUi(this); + initStyle(); } //初始化控件样式 void MainWindow::initStyle() { + ui->plainTextEdit->setStyleSheet( + "QPlainTextEdit {" + " background-color: #FFFFFF;" + " border: 1px solid #E5E7EB;" + " border-radius: 4px;" + "}" + ); } void MainWindow::checkUpdates() From 8e9528dfa81a8d747190ab4e1eff02ccfe12a86e Mon Sep 17 00:00:00 2001 From: momen Date: Tue, 3 Jun 2025 13:54:52 +0800 Subject: [PATCH 012/114] =?UTF-8?q?update:=E6=9B=B4=E6=96=B0=E5=AD=97?= =?UTF-8?q?=E4=BD=93=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mainwindow.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 158882c..4322d6e 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -17,8 +17,15 @@ void MainWindow::initStyle() " background-color: #FFFFFF;" " border: 1px solid #E5E7EB;" " border-radius: 4px;" + " padding-top: 8px;" // 上内边距 + " padding-bottom: 8px;" // 下内边距 + " font-size: 9px;" // 字体大小可调 + " line-height: 1.4;" // 可略调行距(非必须)" + " color: #9CA3AF;" "}" ); + ui->plainTextEdit->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + ui->plainTextEdit->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); } void MainWindow::checkUpdates() From 6d6757154552038cc822d68aaf99ee32b675d796 Mon Sep 17 00:00:00 2001 From: momen Date: Tue, 3 Jun 2025 13:56:42 +0800 Subject: [PATCH 013/114] =?UTF-8?q?update:=E6=8F=90=E5=8D=87=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E5=8F=AF=E8=AF=BB=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mainwindow.cpp | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 4322d6e..cccc631 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -12,18 +12,19 @@ MainWindow::MainWindow(QWidget *parent) //初始化控件样式 void MainWindow::initStyle() { - ui->plainTextEdit->setStyleSheet( - "QPlainTextEdit {" - " background-color: #FFFFFF;" - " border: 1px solid #E5E7EB;" - " border-radius: 4px;" - " padding-top: 8px;" // 上内边距 - " padding-bottom: 8px;" // 下内边距 - " font-size: 9px;" // 字体大小可调 - " line-height: 1.4;" // 可略调行距(非必须)" - " color: #9CA3AF;" - "}" - ); + ui->plainTextEdit->setStyleSheet(R"( + QPlainTextEdit { + background-color: #FFFFFF; + border: 1px solid #E5E7EB; + border-radius: 4px; + padding-top: 8px; + padding-bottom: 8px; + font-size: 9px; + line-height: 1.4; + color: #9CA3AF; + } + )"); + ui->plainTextEdit->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); ui->plainTextEdit->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); From e62451ff89e1606bb4b0f1c4d392e00c030a9048 Mon Sep 17 00:00:00 2001 From: momen Date: Tue, 3 Jun 2025 13:58:17 +0800 Subject: [PATCH 014/114] =?UTF-8?q?update:=E6=9B=B4=E6=96=B0=E6=8C=89?= =?UTF-8?q?=E9=92=AE=E7=B1=BB=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mainwindow.ui | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 0e92b43..526af36 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -181,7 +181,7 @@ 40 - + 0 @@ -219,7 +219,7 @@ - + 118 From aa0bcff0769dd30f9a53ef95ebe1cc0e36db2a80 Mon Sep 17 00:00:00 2001 From: momen Date: Tue, 3 Jun 2025 14:07:09 +0800 Subject: [PATCH 015/114] =?UTF-8?q?update:=E6=9B=B4=E6=94=B9=E4=B8=8B?= =?UTF-8?q?=E6=8B=89=E6=A1=86=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mainwindow.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index cccc631..51861c6 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -12,6 +12,7 @@ MainWindow::MainWindow(QWidget *parent) //初始化控件样式 void MainWindow::initStyle() { + //查询框样式 ui->plainTextEdit->setStyleSheet(R"( QPlainTextEdit { background-color: #FFFFFF; @@ -28,6 +29,31 @@ void MainWindow::initStyle() ui->plainTextEdit->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); ui->plainTextEdit->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + //筛选框样式 + ui->FilterComboBox->setStyleSheet(R"( + QComboBox { + background-color: #FFFFFF; + border: 1px solid #E5E7EB; + border-radius: 4px; + color: #4B5563; + padding: 4px 8px; + } + + QComboBox::drop-down { + border: none; + width: 20px; + } + + QComboBox QAbstractItemView { + background-color: #FFFFFF; + border: 1px solid #E5E7EB; + color: #4B5563; + selection-background-color: #F3F4F6; + selection-color: #111827; + } +)"); + + } void MainWindow::checkUpdates() { From c54785224c782ed2071be8906090f3aabe280285 Mon Sep 17 00:00:00 2001 From: momen Date: Tue, 3 Jun 2025 14:13:58 +0800 Subject: [PATCH 016/114] =?UTF-8?q?update:=E6=9B=B4=E6=96=B0gitignore?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 20e0241..75ea44d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ build .vscode -.cache \ No newline at end of file +.cache +CMakeLists.txt.user +CMakeLists.txt.user.* From 059ac5b27022429656548104feec0d2fd85e7622 Mon Sep 17 00:00:00 2001 From: momen Date: Tue, 3 Jun 2025 14:17:22 +0800 Subject: [PATCH 017/114] =?UTF-8?q?update:=E6=B7=BB=E5=8A=A0=E4=B8=8B?= =?UTF-8?q?=E6=8B=89=E6=8C=89=E9=92=AEsvg=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/CMakeLists.txt | 1 + src/icons.qrc | 1 + src/resources/down_arrow_4B5563.svg | 1 + 3 files changed, 3 insertions(+) create mode 100644 src/icons.qrc create mode 100644 src/resources/down_arrow_4B5563.svg diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e6f7623..b41f81c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -24,6 +24,7 @@ if(${QT_VERSION_MAJOR} GREATER_EQUAL 6) MANUAL_FINALIZATION ${PROJECT_SOURCES} aptssupdater.h aptssupdater.cpp + icons.qrc ) # Define target properties for Android with Qt 6 as: # set_property(TARGET Spark-Update-Tool APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR diff --git a/src/icons.qrc b/src/icons.qrc new file mode 100644 index 0000000..7646d2b --- /dev/null +++ b/src/icons.qrc @@ -0,0 +1 @@ + diff --git a/src/resources/down_arrow_4B5563.svg b/src/resources/down_arrow_4B5563.svg new file mode 100644 index 0000000..4989662 --- /dev/null +++ b/src/resources/down_arrow_4B5563.svg @@ -0,0 +1 @@ + \ No newline at end of file From 623db2ea768f371965dd07850d3afae3f77bf8f9 Mon Sep 17 00:00:00 2001 From: momen Date: Tue, 3 Jun 2025 14:20:29 +0800 Subject: [PATCH 018/114] =?UTF-8?q?update:=E6=9B=B4=E6=96=B0=E4=B8=8B?= =?UTF-8?q?=E6=8B=89=E6=A1=86=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/icons.qrc | 6 +++++- src/mainwindow.cpp | 5 +++++ src/resources/{down_arrow_4B5563.svg => down_arrow.svg} | 0 3 files changed, 10 insertions(+), 1 deletion(-) rename src/resources/{down_arrow_4B5563.svg => down_arrow.svg} (100%) diff --git a/src/icons.qrc b/src/icons.qrc index 7646d2b..41d5fd4 100644 --- a/src/icons.qrc +++ b/src/icons.qrc @@ -1 +1,5 @@ - + + + resources/down_arrow.svg + + diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 51861c6..c0cf3f2 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -44,6 +44,11 @@ void MainWindow::initStyle() width: 20px; } + QComboBox::down-arrow { + image: url(:/resources/down_arrow.svg); + width: 12px; + height: 16px; + } QComboBox QAbstractItemView { background-color: #FFFFFF; border: 1px solid #E5E7EB; diff --git a/src/resources/down_arrow_4B5563.svg b/src/resources/down_arrow.svg similarity index 100% rename from src/resources/down_arrow_4B5563.svg rename to src/resources/down_arrow.svg From 48257722fb228e25ea222efb01b70e47c57dfb49 Mon Sep 17 00:00:00 2001 From: momen Date: Tue, 3 Jun 2025 14:50:47 +0800 Subject: [PATCH 019/114] =?UTF-8?q?update:=E6=9B=B4=E6=96=B0"=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E5=85=A8=E9=83=A8"=E6=8C=89=E9=92=AE=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mainwindow.cpp | 75 +++++++++++++++++++++++++++++++--------------- 1 file changed, 51 insertions(+), 24 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index c0cf3f2..4ecb379 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -31,32 +31,59 @@ void MainWindow::initStyle() //筛选框样式 ui->FilterComboBox->setStyleSheet(R"( - QComboBox { - background-color: #FFFFFF; - border: 1px solid #E5E7EB; - border-radius: 4px; - color: #4B5563; - padding: 4px 8px; - } + QComboBox { + background-color: #FFFFFF; + border: 1px solid #E5E7EB; + border-radius: 4px; + color: #4B5563; + padding: 4px 8px; + } - QComboBox::drop-down { - border: none; - width: 20px; - } + QComboBox::drop-down { + border: none; + width: 20px; + } + + QComboBox::down-arrow { + image: url(:/resources/down_arrow.svg); + width: 12px; + height: 16px; + } + QComboBox QAbstractItemView { + background-color: #FFFFFF; + border: 1px solid #E5E7EB; + color: #4B5563; + selection-background-color: #F3F4F6; + selection-color: #111827; + } + )"); + + //更新软件按钮样式 + ui->updatePushButton->setStyleSheet(R"( + QPushButton { + background-color: #2563EB; + color: #FFFFFF; + border: none; + border-radius: 4px; + font-size: 14px; + padding: 6px 12px; + text-align: center; + } + + QPushButton:hover { + background-color: #1D4ED8; /* 深一点的 hover 效果,可选 */ + } + + QPushButton:pressed { + background-color: #1E40AF; /* 按下效果,可选 */ + } + + QPushButton:disabled { + background-color: #A5B4FC; + color: #F9FAFB; + } + )"); - QComboBox::down-arrow { - image: url(:/resources/down_arrow.svg); - width: 12px; - height: 16px; - } - QComboBox QAbstractItemView { - background-color: #FFFFFF; - border: 1px solid #E5E7EB; - color: #4B5563; - selection-background-color: #F3F4F6; - selection-color: #111827; - } -)"); } From a9c137110c5cc8ce0030c2535d55c3b715e8cfce Mon Sep 17 00:00:00 2001 From: momen Date: Tue, 3 Jun 2025 14:56:05 +0800 Subject: [PATCH 020/114] =?UTF-8?q?update:=E6=9B=B4=E6=96=B0=E8=83=8C?= =?UTF-8?q?=E6=99=AF=E9=A2=9C=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mainwindow.cpp | 11 ++++++++++- src/mainwindow.ui | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 4ecb379..f940bb2 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -5,7 +5,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { - checkUpdates(); + // checkUpdates(); ui->setupUi(this); initStyle(); } @@ -84,7 +84,16 @@ void MainWindow::initStyle() } )"); + //设置背景填充颜色 + ui->backgroundWidget->setStyleSheet(R"( + QWidget { + background-color: #FFFFFF; + border-radius: 12px; + } + )"); + //设置主背景颜色 + this->setStyleSheet("background-color: #F8FAFC;"); } void MainWindow::checkUpdates() diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 526af36..49462f5 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -63,7 +63,7 @@ - + 1376 From b35ac593cb3e142d3df846c702c652e1e0cb97f6 Mon Sep 17 00:00:00 2001 From: momen Date: Tue, 3 Jun 2025 15:03:48 +0800 Subject: [PATCH 021/114] =?UTF-8?q?fix:=E6=90=9C=E7=B4=A2=E6=A1=86?= =?UTF-8?q?=E6=94=B9=E4=B8=BAplaceholdertext=E6=98=BE=E7=A4=BA=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E6=96=87=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mainwindow.ui | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 49462f5..80ac609 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -147,6 +147,12 @@ + + + + 81.000000000000000 + + 搜索软件... From f7fcf5ef1157030430eb1487828e642cd29e4556 Mon Sep 17 00:00:00 2001 From: momen Date: Wed, 4 Jun 2025 08:51:36 +0800 Subject: [PATCH 022/114] =?UTF-8?q?fix:=E5=88=A0=E9=99=A4CmakeLists.txt.us?= =?UTF-8?q?er=E7=9A=84=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/CMakeLists.txt.user | 462 ---------------------------------------- 1 file changed, 462 deletions(-) delete mode 100644 src/CMakeLists.txt.user diff --git a/src/CMakeLists.txt.user b/src/CMakeLists.txt.user deleted file mode 100644 index 97d9b36..0000000 --- a/src/CMakeLists.txt.user +++ /dev/null @@ -1,462 +0,0 @@ - - - - - - EnvironmentId - {d06980a7-632a-4db9-8fae-55a42ba2ccc5} - - - ProjectExplorer.Project.ActiveTarget - 0 - - - ProjectExplorer.Project.EditorSettings - - true - true - true - - Cpp - - CppGlobal - - - - QmlJS - - QmlJSGlobal - - - 2 - UTF-8 - false - 4 - false - 0 - 80 - true - true - 1 - 0 - false - true - false - 2 - 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 - - false - - - 0 - true - - true - true - Builtin.DefaultTidyAndClazy - 8 - true - - - - true - - - - - ProjectExplorer.Project.Target.0 - - Desktop - Desktop Qt 6.9.0 - Desktop Qt 6.9.0 - qt.qt6.690.linux_gcc_64_kit - 0 - 0 - 0 - - Debug - 2 - false - - -DCMAKE_COLOR_DIAGNOSTICS:BOOL=ON --DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX} --DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx} --DCMAKE_GENERATOR:STRING=Ninja --DCMAKE_BUILD_TYPE:STRING=Debug --DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG} --DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} --DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake --DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} - 0 - /home/momen/Spark-Update-Tool/build/Desktop_Qt_6_9_0-Debug - - - - - all - - false - - true - 构建 - CMakeProjectManager.MakeStep - - 1 - 构建 - 构建 - ProjectExplorer.BuildSteps.Build - - - - - - clean - - false - - true - 构建 - CMakeProjectManager.MakeStep - - 1 - 清除 - 清除 - ProjectExplorer.BuildSteps.Clean - - 2 - false - - false - - Debug - CMakeProjectManager.CMakeBuildConfiguration - - - Release - 2 - false - - -DCMAKE_COLOR_DIAGNOSTICS:BOOL=ON --DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX} --DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx} --DCMAKE_GENERATOR:STRING=Ninja --DCMAKE_BUILD_TYPE:STRING=Release --DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG} --DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} --DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake --DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} - /home/momen/Spark-Update-Tool/build/Desktop_Qt_6_9_0-Release - - - - - all - - false - - true - CMakeProjectManager.MakeStep - - 1 - 构建 - 构建 - ProjectExplorer.BuildSteps.Build - - - - - - clean - - false - - true - CMakeProjectManager.MakeStep - - 1 - 清除 - 清除 - ProjectExplorer.BuildSteps.Clean - - 2 - false - - false - - Release - CMakeProjectManager.CMakeBuildConfiguration - - - RelWithDebInfo - 2 - false - - -DCMAKE_COLOR_DIAGNOSTICS:BOOL=ON --DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX} --DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx} --DCMAKE_GENERATOR:STRING=Ninja --DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo --DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG} --DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} --DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake --DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} - /home/momen/Spark-Update-Tool/build/Desktop_Qt_6_9_0-RelWithDebInfo - - - - - all - - false - - true - CMakeProjectManager.MakeStep - - 1 - 构建 - 构建 - ProjectExplorer.BuildSteps.Build - - - - - - clean - - false - - true - CMakeProjectManager.MakeStep - - 1 - 清除 - 清除 - ProjectExplorer.BuildSteps.Clean - - 2 - false - - false - - Release with Debug Information - CMakeProjectManager.CMakeBuildConfiguration - - - RelWithDebInfo - 2 - false - - -DCMAKE_COLOR_DIAGNOSTICS:BOOL=ON --DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX} --DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx} --DCMAKE_GENERATOR:STRING=Ninja --DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo --DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG} --DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} --DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake --DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} - 0 - /home/momen/Spark-Update-Tool/build/Desktop_Qt_6_9_0-Profile - - - - - all - - false - - true - CMakeProjectManager.MakeStep - - 1 - 构建 - 构建 - ProjectExplorer.BuildSteps.Build - - - - - - clean - - false - - true - CMakeProjectManager.MakeStep - - 1 - 清除 - 清除 - ProjectExplorer.BuildSteps.Clean - - 2 - false - - false - - Profile - CMakeProjectManager.CMakeBuildConfiguration - - - MinSizeRel - 2 - false - - -DCMAKE_COLOR_DIAGNOSTICS:BOOL=ON --DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX} --DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx} --DCMAKE_GENERATOR:STRING=Ninja --DCMAKE_BUILD_TYPE:STRING=MinSizeRel --DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG} --DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} --DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake --DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} - /home/momen/Spark-Update-Tool/build/Desktop_Qt_6_9_0-MinSizeRel - - - - - all - - false - - true - CMakeProjectManager.MakeStep - - 1 - 构建 - 构建 - ProjectExplorer.BuildSteps.Build - - - - - - clean - - false - - true - CMakeProjectManager.MakeStep - - 1 - 清除 - 清除 - ProjectExplorer.BuildSteps.Clean - - 2 - false - - false - - Minimum Size Release - CMakeProjectManager.CMakeBuildConfiguration - - 5 - - - 0 - 部署 - 部署 - ProjectExplorer.BuildSteps.Deploy - - 1 - - false - ProjectExplorer.DefaultDeployConfiguration - - - - - - - - - false - - true - ApplicationManagerPlugin.Deploy.CMakePackageStep - - - install-package --acknowledge - true - Install Application Manager package - ApplicationManagerPlugin.Deploy.InstallPackageStep - - - - - - - - 2 - 部署 - 部署 - ProjectExplorer.BuildSteps.Deploy - - 1 - - false - ApplicationManagerPlugin.Deploy.Configuration - - 2 - - true - true - 0 - true - - 2 - - false - -e cpu-cycles --call-graph dwarf,4096 -F 250 - Spark-Update-Tool - CMakeProjectManager.CMakeRunConfiguration. - Spark-Update-Tool - false - true - true - true - /home/momen/Spark-Update-Tool/build/Desktop_Qt_6_9_0-Debug - - 1 - - - - ProjectExplorer.Project.TargetCount - 1 - - - ProjectExplorer.Project.Updater.FileVersion - 22 - - - Version - 22 - - From 24f3be1373d0721959498afa65186c5961e7247c Mon Sep 17 00:00:00 2001 From: momen Date: Wed, 4 Jun 2025 08:58:43 +0800 Subject: [PATCH 023/114] =?UTF-8?q?update:=E6=9B=B4=E6=96=B0=E8=BD=AF?= =?UTF-8?q?=E4=BB=B6=E6=A0=87=E9=A2=98=E6=A0=8F=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mainwindow.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index f940bb2..daf51a6 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -12,6 +12,9 @@ MainWindow::MainWindow(QWidget *parent) //初始化控件样式 void MainWindow::initStyle() { + //设置窗口标题 + this->setWindowTitle("软件更新中心"); + //查询框样式 ui->plainTextEdit->setStyleSheet(R"( QPlainTextEdit { From 93dfdbc57ca8070068d2dfebd3c81810fcbd5254 Mon Sep 17 00:00:00 2001 From: momen Date: Wed, 4 Jun 2025 09:59:47 +0800 Subject: [PATCH 024/114] =?UTF-8?q?update:=E4=BD=BF=E7=94=A8=E5=95=86?= =?UTF-8?q?=E5=BA=97=E6=BA=90=E6=9D=A5=E6=98=BE=E7=A4=BA=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=EF=BC=8C=E8=80=8C=E9=9D=9E=E7=9B=B4=E6=8E=A5aptss?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/aptssupdater.cpp | 30 +++++++++++++++++------------- src/mainwindow.cpp | 14 ++------------ 2 files changed, 19 insertions(+), 25 deletions(-) diff --git a/src/aptssupdater.cpp b/src/aptssupdater.cpp index e9e7eab..2286218 100644 --- a/src/aptssupdater.cpp +++ b/src/aptssupdater.cpp @@ -14,31 +14,35 @@ QStringList aptssUpdater::getUpdateablePackages() { QStringList packageDetails; QProcess process; - process.start("bash", QStringList() << "-c" << "aptss list --upgradable"); - process.waitForFinished(); + QString command = R"(env LANGUAGE=en_US /usr/bin/apt -c /opt/durapps/spark-store/bin/apt-fast-conf/aptss-apt.conf list --upgradable -o Dir::Etc::sourcelist="/opt/durapps/spark-store/bin/apt-fast-conf/sources.list.d/sparkstore.list" -o Dir::Etc::sourceparts="/dev/null" -o APT::Get::List-Cleanup="0" | awk 'NR>1')"; + + process.start("bash", QStringList() << "-c" << command); + if (!process.waitForFinished()) { + qWarning() << "Process failed to finish."; + return packageDetails; + } QString output = process.readAllStandardOutput(); - QTextStream stream(&output); + QStringList lines = output.split('\n', Qt::SkipEmptyParts); - // 跳过第一行(提示信息) - stream.readLine(); + for (const QString &line : lines) { + // 示例行格式: + // code/unknown 1.100.3-1748872405 amd64 [upgradable from: 1.100.2-1747260578] - while (!stream.atEnd()) { - QString line = stream.readLine(); - QRegularExpression regex(R"((\S+)/\S+\s+(\S+)\s+\S+\s+\[可从该版本升级:(.+)\])"); + QRegularExpression regex(R"(([\w\-\+\.]+)/\S+\s+([^\s]+)\s+\S+\s+\[upgradable from: ([^\]]+)\])"); QRegularExpressionMatch match = regex.match(line); - if (match.hasMatch()) { - QString packageName = match.captured(1); - QString updateVersion = match.captured(2); - QString currentVersion = match.captured(3); - packageDetails << QString("%1 (%2 -> %3)").arg(packageName, currentVersion, updateVersion); + QString name = match.captured(1); + QString newVersion = match.captured(2); + QString oldVersion = match.captured(3); + packageDetails << QString("%1: %2 → %3").arg(name, oldVersion, newVersion); } } return packageDetails; } + QStringList aptssUpdater::getPackageSizes() { QStringList packageSizes; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index daf51a6..8444a08 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -5,7 +5,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { - // checkUpdates(); + checkUpdates(); ui->setupUi(this); initStyle(); } @@ -105,17 +105,7 @@ void MainWindow::checkUpdates() // 获取可更新包列表 QStringList updateablePackages = updater.getUpdateablePackages(); - QStringList packageSizes = updater.getPackageSizes(); - QStringList appNames = updater.getDesktopAppNames(); - qDebug() << "可更新包列表:"; - for (int i = 0; i < updateablePackages.size(); ++i) { - QString packageInfo = updateablePackages.at(i); - QString packageSize = (i < packageSizes.size()) ? packageSizes.at(i) : "未知大小"; - qDebug() << QString("%1 (%2)").arg(packageInfo, packageSize); - } - for (const QString &appName : appNames) { - qDebug() << appName; - } + qDebug()< Date: Wed, 4 Jun 2025 14:55:52 +0800 Subject: [PATCH 025/114] =?UTF-8?q?update:=E5=B0=86=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E5=88=B0=E5=BE=85=E6=9B=B4=E6=96=B0=E7=9A=84=E5=86=85=E5=AE=B9?= =?UTF-8?q?=E6=94=BE=E5=88=B0/tmp=E4=B8=8B=E4=B8=B4=E6=97=B6=E5=AD=98?= =?UTF-8?q?=E5=82=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/aptssupdater.cpp | 88 +++++++++++++------------------------------- src/aptssupdater.h | 4 +- 2 files changed, 28 insertions(+), 64 deletions(-) diff --git a/src/aptssupdater.cpp b/src/aptssupdater.cpp index 2286218..65e9cf7 100644 --- a/src/aptssupdater.cpp +++ b/src/aptssupdater.cpp @@ -25,18 +25,33 @@ QStringList aptssUpdater::getUpdateablePackages() QString output = process.readAllStandardOutput(); QStringList lines = output.split('\n', Qt::SkipEmptyParts); - for (const QString &line : lines) { - // 示例行格式: - // code/unknown 1.100.3-1748872405 amd64 [upgradable from: 1.100.2-1747260578] - - QRegularExpression regex(R"(([\w\-\+\.]+)/\S+\s+([^\s]+)\s+\S+\s+\[upgradable from: ([^\]]+)\])"); - QRegularExpressionMatch match = regex.match(line); - if (match.hasMatch()) { - QString name = match.captured(1); - QString newVersion = match.captured(2); - QString oldVersion = match.captured(3); - packageDetails << QString("%1: %2 → %3").arg(name, oldVersion, newVersion); + // 创建临时文件 + QTemporaryFile tempFile; + tempFile.setAutoRemove(false); + if (tempFile.open()) { + QTextStream stream(&tempFile); + + for (const QString &line : lines) { + QRegularExpression regex(R"(([\w\-\+\.]+)/\S+\s+([^\s]+)\s+\S+\s+\[upgradable from: ([^\]]+)\])"); + QRegularExpressionMatch match = regex.match(line); + if (match.hasMatch()) { + QString name = match.captured(1); + QString newVersion = match.captured(2); + QString oldVersion = match.captured(3); + + // 写入内存列表 + packageDetails << QString("%1: %2 → %3").arg(name, oldVersion, newVersion); + + // 写入临时文件(原始数据) + stream << name << "|" << oldVersion << "|" << newVersion << "\n"; + } } + tempFile.close(); + m_tempFilePath = tempFile.fileName(); + qDebug()<< "临时文件路径:" << m_tempFilePath; + + } else { + qWarning() << "无法创建临时文件"; } return packageDetails; @@ -45,61 +60,10 @@ QStringList aptssUpdater::getUpdateablePackages() QStringList aptssUpdater::getPackageSizes() { - QStringList packageSizes; - QProcess process; - process.start("bash", QStringList() << "-c" << "aptss upgrade --assume-no"); - // 自动回复 "n" 以跳过交互式提示 - if (process.waitForStarted()) { - process.write("n\n"); - } - - process.waitForFinished(); - - QString output = process.readAllStandardOutput(); - QTextStream stream(&output); - - while (!stream.atEnd()) { - QString line = stream.readLine(); - QRegularExpression regex(R"((\S+)\s+\S+\s+(\d+(?:\.\d+)?(?:KiB|MiB)))"); - QRegularExpressionMatch match = regex.match(line); - - if (match.hasMatch()) { - QString packageName = match.captured(1); - QString packageSize = match.captured(2); - packageSizes << QString("%1: %2").arg(packageName, packageSize); - } - } - - return packageSizes; } QStringList aptssUpdater::getDesktopAppNames() { - QStringList appNames; - QStringList updateablePackages = getUpdateablePackages(); - for (const QString &packageDetail : updateablePackages) { - // 提取包名(忽略版本信息) - QString packageName = packageDetail.split(' ').first(); - QString desktopFilePath = QString("/usr/share/applications/%1.desktop").arg(packageName); - - QFile desktopFile(desktopFilePath); - if (desktopFile.exists() && desktopFile.open(QIODevice::ReadOnly)) { - QTextStream stream(&desktopFile); - while (!stream.atEnd()) { - QString line = stream.readLine(); - if (line.startsWith("Name=")) { - QString appName = line.mid(5); // 提取 Name 属性值 - appNames << appName; - break; - } - } - desktopFile.close(); - } else { - appNames << QString("未找到 .desktop 文件: %1").arg(packageName); - } - } - - return appNames; } \ No newline at end of file diff --git a/src/aptssupdater.h b/src/aptssupdater.h index 7ff6f87..5a16823 100644 --- a/src/aptssupdater.h +++ b/src/aptssupdater.h @@ -3,7 +3,7 @@ #include #include - +#include class aptssUpdater : public QWidget { Q_OBJECT @@ -14,7 +14,7 @@ public: qint64 getTotalDownloadSize(); // 获取更新总大小预估 QStringList getPackageSizes(); // 获取每个包的大小 QStringList getDesktopAppNames(); // 获取桌面应用名称列表 - + QString m_tempFilePath; signals: }; From 0d1f23e017075765f10fad4d64ec01fbc9c5ddf4 Mon Sep 17 00:00:00 2001 From: momen Date: Wed, 4 Jun 2025 21:09:38 +0800 Subject: [PATCH 026/114] =?UTF-8?q?update:=E6=9B=B4=E6=96=B0markdown?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- READE.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/READE.md b/READE.md index 2e25a78..3259e2d 100644 --- a/READE.md +++ b/READE.md @@ -4,5 +4,17 @@ 欢迎使用星火软件更新器,你可以用这个更新器更新位于你电脑的程序。 #### 当前支持的Linux发行版 +- [x] GXDE +- [x] Ubuntu +- [ ] deepin +- [ ] Kylin -#### 联系与反馈 \ No newline at end of file +#### 功能清单 +|功能模块|描述| +|--|--| +| 应用名识别|采用ss-do-upgrade.sh部分代码| +|应用包大小识别|dkpg完成| +|获取应用icon|使用QDesktopServices完成| +|支持ACE| | + +#### 联系与反馈 From 8ff21d81c4caa188c7bda81453117d901c84ab85 Mon Sep 17 00:00:00 2001 From: momen Date: Thu, 5 Jun 2025 08:54:56 +0800 Subject: [PATCH 027/114] =?UTF-8?q?feat:=E6=96=B0=E5=A2=9E=E8=AF=BB?= =?UTF-8?q?=E5=8F=96=E8=BD=AF=E4=BB=B6=E5=90=8D=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/aptssupdater.cpp | 89 ++++++++++++++++++++++++++++++++++++++++++++ src/aptssupdater.h | 7 ++++ src/mainwindow.cpp | 5 ++- 3 files changed, 99 insertions(+), 2 deletions(-) diff --git a/src/aptssupdater.cpp b/src/aptssupdater.cpp index 65e9cf7..3cdfe80 100644 --- a/src/aptssupdater.cpp +++ b/src/aptssupdater.cpp @@ -65,5 +65,94 @@ QStringList aptssUpdater::getPackageSizes() QStringList aptssUpdater::getDesktopAppNames() { + QStringList appNames; + QProcess dpkgProcess; + + // 获取当前系统语言环境 + QString lang = QLocale().name().replace("_", "-"); + // 遍历所有可更新包(复用已有的临时文件数据) + QStringList packages = getUpdateablePackages(); + + foreach (const QString &package, packages) { + QString packageName = package.split(":")[0]; + + // 获取包文件列表 + dpkgProcess.start("dpkg", QStringList() << "-L" << packageName); + dpkgProcess.waitForFinished(); + QStringList files = QString(dpkgProcess.readAllStandardOutput()).split('\n', Qt::SkipEmptyParts); + + // 检查常规应用目录 + checkDesktopFiles(files.filter("/usr/share/applications/"), + appNames, + lang, + packageName); // 新增包名参数 + + // 检查特殊目录(/opt/apps) + checkDesktopFiles(files.filter(QRegularExpression(QString("/opt/apps/%1/entries/applications").arg(packageName))), + appNames, + lang, + packageName); // 新增包名参数 + + } + + return appNames; +} + +bool aptssUpdater::checkDesktopFiles(const QStringList &desktopFiles, QStringList &appNames, const QString &lang, const QString &packageName) +{ + bool hasFoundName = false; + QRegularExpression noDisplayRe("^NoDisplay=(true|True)"); + QRegularExpression nameRe("^Name\\[?" + lang + "?\\]?=(.*)"); + QRegularExpression nameOrigRe("^Name=(.*)"); + + foreach (const QString &filePath, desktopFiles) { + if (!filePath.endsWith(".desktop")) continue; + + QFile file(filePath); + if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) continue; + + bool skip = false; + QString name; + + QTextStream in(&file); + while (!in.atEnd()) { + QString line = in.readLine().trimmed(); + + // 检查NoDisplay属性 + if (line.startsWith("NoDisplay=")) { + if (noDisplayRe.match(line).hasMatch()) { + skip = true; + break; + } + } + + // 优先匹配本地化名称 + if (name.isEmpty()) { + QRegularExpressionMatch match = nameRe.match(line); + if (match.hasMatch()) { + name = match.captured(1); + continue; + } + + // 匹配原始名称 + match = nameOrigRe.match(line); + if (match.hasMatch()) { + name = match.captured(1); + } + } + } + + if (!skip && !name.isEmpty() && !appNames.contains(name)) { + appNames << name; + hasFoundName = true; // 标记已找到有效名称 + } + } + + // 如果没有找到任何名称,则使用包名 + if (!hasFoundName && !appNames.contains(packageName)) { + appNames << packageName; + } + + return hasFoundName; } \ No newline at end of file diff --git a/src/aptssupdater.h b/src/aptssupdater.h index 5a16823..003160b 100644 --- a/src/aptssupdater.h +++ b/src/aptssupdater.h @@ -4,6 +4,7 @@ #include #include #include +#include class aptssUpdater : public QWidget { Q_OBJECT @@ -16,6 +17,12 @@ public: QStringList getDesktopAppNames(); // 获取桌面应用名称列表 QString m_tempFilePath; signals: +private: + bool checkDesktopFiles(const QStringList &desktopFiles, + QStringList &appNames, + const QString &lang, + const QString &packageName); // 新增包名参数 + }; #endif // APTSSUPDATER_H \ No newline at end of file diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 8444a08..59299fb 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -104,8 +104,9 @@ void MainWindow::checkUpdates() aptssUpdater updater; // 获取可更新包列表 - QStringList updateablePackages = updater.getUpdateablePackages(); - qDebug()< Date: Thu, 5 Jun 2025 09:09:57 +0800 Subject: [PATCH 028/114] =?UTF-8?q?fix:=E4=B8=80=E5=8C=85=E5=A4=9Adesktop?= =?UTF-8?q?=E5=8F=AA=E5=AF=B9=E5=BA=94=E6=9C=80=E5=90=8E=E4=B8=80=E4=B8=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/aptssupdater.cpp | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/src/aptssupdater.cpp b/src/aptssupdater.cpp index 3cdfe80..3459724 100644 --- a/src/aptssupdater.cpp +++ b/src/aptssupdater.cpp @@ -95,13 +95,14 @@ QStringList aptssUpdater::getDesktopAppNames() packageName); // 新增包名参数 } - + qDebug()<< "应用名称列表:" << appNames; return appNames; } bool aptssUpdater::checkDesktopFiles(const QStringList &desktopFiles, QStringList &appNames, const QString &lang, const QString &packageName) { bool hasFoundName = false; + QString lastValidName; QRegularExpression noDisplayRe("^NoDisplay=(true|True)"); QRegularExpression nameRe("^Name\\[?" + lang + "?\\]?=(.*)"); QRegularExpression nameOrigRe("^Name=(.*)"); @@ -113,7 +114,7 @@ bool aptssUpdater::checkDesktopFiles(const QStringList &desktopFiles, QStringLis if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) continue; bool skip = false; - QString name; + QString currentName; QTextStream in(&file); while (!in.atEnd()) { @@ -128,31 +129,37 @@ bool aptssUpdater::checkDesktopFiles(const QStringList &desktopFiles, QStringLis } // 优先匹配本地化名称 - if (name.isEmpty()) { + if (currentName.isEmpty()) { QRegularExpressionMatch match = nameRe.match(line); if (match.hasMatch()) { - name = match.captured(1); + currentName = match.captured(1); continue; } // 匹配原始名称 match = nameOrigRe.match(line); if (match.hasMatch()) { - name = match.captured(1); + currentName = match.captured(1); } } } - if (!skip && !name.isEmpty() && !appNames.contains(name)) { - appNames << name; - hasFoundName = true; // 标记已找到有效名称 + if (!skip && !currentName.isEmpty()) { + lastValidName = currentName; // 只更新最后一个有效名称 } } - // 如果没有找到任何名称,则使用包名 - if (!hasFoundName && !appNames.contains(packageName)) { + // 处理最终的有效名称 + if (!lastValidName.isEmpty()) { + if (!appNames.contains(lastValidName)) { + appNames << lastValidName; + } + return true; + } + + // 回退到包名 + if (!appNames.contains(packageName)) { appNames << packageName; } - - return hasFoundName; + return false; } \ No newline at end of file From d454a586715d3fd86dc673ec494d9a5d12414216 Mon Sep 17 00:00:00 2001 From: momen Date: Thu, 5 Jun 2025 10:17:06 +0800 Subject: [PATCH 029/114] =?UTF-8?q?fix:=E4=BF=AE=E6=AD=A3=E4=BA=86?= =?UTF-8?q?=E6=97=A0=E8=BD=AF=E4=BB=B6=E5=90=8D=E6=97=B6=EF=BC=8C=E8=BD=AF?= =?UTF-8?q?=E4=BB=B6=E5=90=8D=E5=86=85=E5=AE=B9=E4=B8=BA=E7=A9=BA=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/aptssupdater.cpp | 48 ++++++++++++++++++++++++++------------------ src/aptssupdater.h | 6 +----- 2 files changed, 29 insertions(+), 25 deletions(-) diff --git a/src/aptssupdater.cpp b/src/aptssupdater.cpp index 3459724..c671e1a 100644 --- a/src/aptssupdater.cpp +++ b/src/aptssupdater.cpp @@ -76,32 +76,44 @@ QStringList aptssUpdater::getDesktopAppNames() foreach (const QString &package, packages) { QString packageName = package.split(":")[0]; + QString finalName = packageName; // 默认使用包名 // 获取包文件列表 dpkgProcess.start("dpkg", QStringList() << "-L" << packageName); dpkgProcess.waitForFinished(); QStringList files = QString(dpkgProcess.readAllStandardOutput()).split('\n', Qt::SkipEmptyParts); - // 检查常规应用目录 - checkDesktopFiles(files.filter("/usr/share/applications/"), - appNames, - lang, - packageName); // 新增包名参数 + // 先检查常规应用目录 + QStringList regularDesktopFiles = files.filter("/usr/share/applications/"); + QString regularAppName; + if (!regularDesktopFiles.isEmpty()) { + checkDesktopFiles(regularDesktopFiles, regularAppName, lang, packageName); + } - // 检查特殊目录(/opt/apps) - checkDesktopFiles(files.filter(QRegularExpression(QString("/opt/apps/%1/entries/applications").arg(packageName))), - appNames, - lang, - packageName); // 新增包名参数 + // 如果常规目录没有找到,再检查特殊目录 + if (regularAppName.isEmpty()) { + QStringList specialDesktopFiles = files.filter(QRegularExpression(QString("/opt/apps/%1/entries/applications").arg(packageName))); + QString specialAppName; + if (!specialDesktopFiles.isEmpty()) { + checkDesktopFiles(specialDesktopFiles, specialAppName, lang, packageName); + if (!specialAppName.isEmpty()) { + finalName = specialAppName; + } + } + } else { + finalName = regularAppName; + } + // 输出格式为[软件名|包名] + appNames << QString("[%1|%2]").arg(finalName, packageName); } qDebug()<< "应用名称列表:" << appNames; return appNames; } -bool aptssUpdater::checkDesktopFiles(const QStringList &desktopFiles, QStringList &appNames, const QString &lang, const QString &packageName) + +bool aptssUpdater::checkDesktopFiles(const QStringList &desktopFiles, QString &appName, const QString &lang, const QString &packageName) { - bool hasFoundName = false; QString lastValidName; QRegularExpression noDisplayRe("^NoDisplay=(true|True)"); QRegularExpression nameRe("^Name\\[?" + lang + "?\\]?=(.*)"); @@ -145,21 +157,17 @@ bool aptssUpdater::checkDesktopFiles(const QStringList &desktopFiles, QStringLis } if (!skip && !currentName.isEmpty()) { - lastValidName = currentName; // 只更新最后一个有效名称 + lastValidName = currentName; } } // 处理最终的有效名称 if (!lastValidName.isEmpty()) { - if (!appNames.contains(lastValidName)) { - appNames << lastValidName; - } + appName = lastValidName; // 直接赋值而不是使用<< return true; } // 回退到包名 - if (!appNames.contains(packageName)) { - appNames << packageName; - } + appName = packageName; return false; -} \ No newline at end of file +} diff --git a/src/aptssupdater.h b/src/aptssupdater.h index 003160b..99be3b1 100644 --- a/src/aptssupdater.h +++ b/src/aptssupdater.h @@ -18,11 +18,7 @@ public: QString m_tempFilePath; signals: private: - bool checkDesktopFiles(const QStringList &desktopFiles, - QStringList &appNames, - const QString &lang, - const QString &packageName); // 新增包名参数 - +bool checkDesktopFiles(const QStringList &desktopFiles, QString &appName, const QString &lang, const QString &packageName); }; #endif // APTSSUPDATER_H \ No newline at end of file From 42b25b33dc28a0d99275b6aa9ad4d791541079d7 Mon Sep 17 00:00:00 2001 From: momen Date: Thu, 5 Jun 2025 10:41:04 +0800 Subject: [PATCH 030/114] =?UTF-8?q?feat:=E5=BA=94=E7=94=A8=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E5=8F=B7=E7=9B=B8=E5=90=8C=E6=97=B6=E5=88=99=E5=BF=BD?= =?UTF-8?q?=E7=95=A5=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/aptssupdater.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/aptssupdater.cpp b/src/aptssupdater.cpp index c671e1a..5a464dd 100644 --- a/src/aptssupdater.cpp +++ b/src/aptssupdater.cpp @@ -39,6 +39,12 @@ QStringList aptssUpdater::getUpdateablePackages() QString newVersion = match.captured(2); QString oldVersion = match.captured(3); + // 检查版本是否相同,相同则跳过 + if (newVersion == oldVersion) { + qDebug() << "跳过版本相同的包:" << name << "(" << oldVersion << "→" << newVersion << ")"; + continue; + } + // 写入内存列表 packageDetails << QString("%1: %2 → %3").arg(name, oldVersion, newVersion); From 4a846b825c75a2f29fb0b6a83d16af9e8c6b06fd Mon Sep 17 00:00:00 2001 From: momen Date: Thu, 5 Jun 2025 14:25:31 +0800 Subject: [PATCH 031/114] =?UTF-8?q?feat:=E8=8E=B7=E5=8F=96=E5=8C=85?= =?UTF-8?q?=E5=A4=A7=E5=B0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/aptssupdater.cpp | 47 ++++++++++++++++++++++++++++++++++++++++++++ src/mainwindow.cpp | 1 + 2 files changed, 48 insertions(+) diff --git a/src/aptssupdater.cpp b/src/aptssupdater.cpp index 5a464dd..cb08da0 100644 --- a/src/aptssupdater.cpp +++ b/src/aptssupdater.cpp @@ -3,6 +3,7 @@ #include #include #include +#include aptssUpdater::aptssUpdater(QWidget *parent) : QWidget(parent) @@ -66,9 +67,55 @@ QStringList aptssUpdater::getUpdateablePackages() QStringList aptssUpdater::getPackageSizes() { + QStringList packageSizes; + QProcess process; + // 使用绝对路径 + 自动输入N跳过交互 + QString command = R"(echo N | /opt/durapps/spark-store/bin/aptss upgrade --assume-no)"; + + process.start("bash", QStringList() << "-c" << command); + if (!process.waitForFinished()) { + qWarning() << "获取包大小失败:进程未完成"; + return packageSizes; + } + + QString output = process.readAllStandardOutput() + process.readAllStandardError(); + + // 清理颜色控制字符(ANSI 转义序列) + output.remove(QRegularExpression(R"(\x1B\[[0-9;]*[a-zA-Z])")); // \x1B is ESC + + QStringList lines = output.split('\n', Qt::SkipEmptyParts); + + // 从 getUpdateablePackages 获取包名 + QStringList updateablePackages; + for (const QString &pkgInfo : getUpdateablePackages()) { + QString pkgName = pkgInfo.section(":", 0, 0).trimmed(); + updateablePackages << pkgName; + } + + // 匹配 [apt-fast xx:xx:xx] 行,提取内容 + QRegularExpression sizeLineRegex(R"(\[apt-fast [^\]]+\](\S+)\s+\S+\s+(\d+(\.\d+)?[KMG]?iB))"); + + for (const QString &line : lines) { + QRegularExpressionMatch match = sizeLineRegex.match(line.trimmed()); + if (match.hasMatch()) { + QString name = match.captured(1); + QString size = match.captured(2); + + if (updateablePackages.contains(name)) { + packageSizes << QString("%1: %2").arg(name, size); + } + } + } + + qDebug() << "包大小列表:" << packageSizes; + return packageSizes; } + + + + QStringList aptssUpdater::getDesktopAppNames() { QStringList appNames; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 59299fb..2aba374 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -106,6 +106,7 @@ void MainWindow::checkUpdates() // 获取可更新包列表 // QStringList updateablePackages = updater.getUpdateablePackages(); QStringList appName = updater.getDesktopAppNames(); + updater.getPackageSizes(); } From 86b57ecdc1854df6dda097c95d0728ecd6a4f157 Mon Sep 17 00:00:00 2001 From: momen Date: Thu, 5 Jun 2025 14:36:32 +0800 Subject: [PATCH 032/114] =?UTF-8?q?fix:getUpdateablePackages()=E8=A2=AB?= =?UTF-8?q?=E5=A4=9A=E6=AC=A1=E8=B0=83=E7=94=A8=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/aptssupdater.cpp | 8 ++++---- src/aptssupdater.h | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/aptssupdater.cpp b/src/aptssupdater.cpp index cb08da0..5f8c2aa 100644 --- a/src/aptssupdater.cpp +++ b/src/aptssupdater.cpp @@ -8,7 +8,7 @@ aptssUpdater::aptssUpdater(QWidget *parent) : QWidget(parent) { - + packageName = getUpdateablePackages(); } QStringList aptssUpdater::getUpdateablePackages() @@ -86,9 +86,9 @@ QStringList aptssUpdater::getPackageSizes() QStringList lines = output.split('\n', Qt::SkipEmptyParts); - // 从 getUpdateablePackages 获取包名 + // 从 packageName 获取包名 QStringList updateablePackages; - for (const QString &pkgInfo : getUpdateablePackages()) { + for (const QString &pkgInfo : packageName) { QString pkgName = pkgInfo.section(":", 0, 0).trimmed(); updateablePackages << pkgName; } @@ -125,7 +125,7 @@ QStringList aptssUpdater::getDesktopAppNames() QString lang = QLocale().name().replace("_", "-"); // 遍历所有可更新包(复用已有的临时文件数据) - QStringList packages = getUpdateablePackages(); + QStringList packages = packageName; foreach (const QString &package, packages) { QString packageName = package.split(":")[0]; diff --git a/src/aptssupdater.h b/src/aptssupdater.h index 99be3b1..3345d2d 100644 --- a/src/aptssupdater.h +++ b/src/aptssupdater.h @@ -18,7 +18,8 @@ public: QString m_tempFilePath; signals: private: -bool checkDesktopFiles(const QStringList &desktopFiles, QString &appName, const QString &lang, const QString &packageName); + bool checkDesktopFiles(const QStringList &desktopFiles, QString &appName, const QString &lang, const QString &packageName); + QStringList packageName; }; #endif // APTSSUPDATER_H \ No newline at end of file From 0d12df77cc7440ff9839f7b4fe1a9ce41db62be0 Mon Sep 17 00:00:00 2001 From: momen Date: Thu, 5 Jun 2025 14:44:57 +0800 Subject: [PATCH 033/114] =?UTF-8?q?chore:=E5=A2=9E=E5=8A=A0=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E5=8C=85=E5=9B=BE=E6=A0=87=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/aptssupdater.cpp | 5 +++++ src/aptssupdater.h | 2 +- src/mainwindow.cpp | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/aptssupdater.cpp b/src/aptssupdater.cpp index 5f8c2aa..c32271c 100644 --- a/src/aptssupdater.cpp +++ b/src/aptssupdater.cpp @@ -224,3 +224,8 @@ bool aptssUpdater::checkDesktopFiles(const QStringList &desktopFiles, QString &a appName = packageName; return false; } + +QStringList aptssUpdater::getPackageIcons() +{ + +} diff --git a/src/aptssupdater.h b/src/aptssupdater.h index 3345d2d..fbf5b27 100644 --- a/src/aptssupdater.h +++ b/src/aptssupdater.h @@ -12,9 +12,9 @@ public: explicit aptssUpdater(QWidget *parent = nullptr); QStringList getUpdateablePackages(); // 查询可更新包列表及更新内容 - qint64 getTotalDownloadSize(); // 获取更新总大小预估 QStringList getPackageSizes(); // 获取每个包的大小 QStringList getDesktopAppNames(); // 获取桌面应用名称列表 + QStringList getPackageIcons(); // 获取包图标列表 QString m_tempFilePath; signals: private: diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 2aba374..87f4987 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -107,6 +107,7 @@ void MainWindow::checkUpdates() // QStringList updateablePackages = updater.getUpdateablePackages(); QStringList appName = updater.getDesktopAppNames(); updater.getPackageSizes(); + updater.getPackageIcons(); } From 4e1b04bf6eaf17ac25aa732fcc39ecadb5b442ae Mon Sep 17 00:00:00 2001 From: momen Date: Thu, 5 Jun 2025 15:19:37 +0800 Subject: [PATCH 034/114] =?UTF-8?q?chore:=E6=B7=BB=E5=8A=A0=E6=97=A0?= =?UTF-8?q?=E5=9B=BE=E6=A0=87=E5=BA=94=E7=94=A8=E7=9A=84=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E5=BA=94=E7=94=A8=E5=9B=BE=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/icons.qrc | 1 + src/resources/default_icon.svg | 1 + 2 files changed, 2 insertions(+) create mode 100644 src/resources/default_icon.svg diff --git a/src/icons.qrc b/src/icons.qrc index 41d5fd4..cce5944 100644 --- a/src/icons.qrc +++ b/src/icons.qrc @@ -1,5 +1,6 @@ resources/down_arrow.svg + resources/default_icon.svg diff --git a/src/resources/default_icon.svg b/src/resources/default_icon.svg new file mode 100644 index 0000000..7c9cb42 --- /dev/null +++ b/src/resources/default_icon.svg @@ -0,0 +1 @@ + \ No newline at end of file From f72ab76e2c17c90a3aefd2bada9adafc946a9f71 Mon Sep 17 00:00:00 2001 From: momen Date: Fri, 6 Jun 2025 08:35:26 +0800 Subject: [PATCH 035/114] =?UTF-8?q?feat:=E6=8B=BF=E5=88=B0=E5=BA=94?= =?UTF-8?q?=E7=94=A8=E5=AF=B9=E5=BA=94=E7=9A=84=E5=9B=BE=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/aptssupdater.cpp | 72 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 71 insertions(+), 1 deletion(-) diff --git a/src/aptssupdater.cpp b/src/aptssupdater.cpp index c32271c..d3378ea 100644 --- a/src/aptssupdater.cpp +++ b/src/aptssupdater.cpp @@ -227,5 +227,75 @@ bool aptssUpdater::checkDesktopFiles(const QStringList &desktopFiles, QString &a QStringList aptssUpdater::getPackageIcons() { - + QStringList packageIcons; + QProcess dpkgProcess; + + // 遍历所有可更新包 + QStringList packages = packageName; + + foreach (const QString &package, packages) { + QString packageName = package.split(":")[0]; + QString iconPath = ":/resources/default_icon.svg"; // 默认图标 + + // 获取包文件列表 + dpkgProcess.start("dpkg", QStringList() << "-L" << packageName); + dpkgProcess.waitForFinished(); + QStringList files = QString(dpkgProcess.readAllStandardOutput()).split('\n', Qt::SkipEmptyParts); + + // 查找.desktop文件 + QStringList desktopFiles = files.filter(QRegularExpression("/(usr/share|opt/apps)/.*\\.desktop$")); + + // 从.desktop文件中提取图标 + foreach (const QString &desktopFile, desktopFiles) { + QFile file(desktopFile); + if (file.open(QIODevice::ReadOnly | QIODevice::Text)) { + QTextStream in(&file); + while (!in.atEnd()) { + QString line = in.readLine().trimmed(); + if (line.startsWith("Icon=")) { + QString iconName = line.mid(5).trimmed(); + + // 处理相对图标名(如Icon=vscode) + if (!iconName.contains('/')) { + // 查找标准图标路径 + QStringList iconPaths = { + QString("/usr/share/pixmaps/%1.png").arg(iconName), + QString("/usr/share/icons/hicolor/48x48/apps/%1.png").arg(iconName), + QString("/usr/share/icons/hicolor/scalable/apps/%1.svg").arg(iconName), + QString("/opt/apps/%1/entries/icons/hicolor/48x48/apps/%2.png").arg(packageName, iconName) + }; + + foreach (const QString &path, iconPaths) { + if (QFile::exists(path)) { + iconPath = path; + break; + } + } + } else { + // 已经是绝对路径 + if (QFile::exists(iconName)) { + iconPath = iconName; + } + } + break; + } + } + file.close(); + } + } + + // 如果.desktop中没有找到图标,尝试直接查找包中的图标文件 + if (iconPath == ":/resources/default_icon.svg") { + QStringList iconFiles = files.filter(QRegularExpression("/(usr/share/pixmaps|usr/share/icons|opt/apps/.*/entries/icons)/.*\\.(png|svg)$")); + if (!iconFiles.isEmpty()) { + iconPath = iconFiles.first(); + } + } + + qDebug() << "包名:" << packageName << "图标路径:" << iconPath; + packageIcons << QString("%1: %2").arg(packageName, iconPath); + } + + return packageIcons; } + From 051b04bf0b058094f2e57dd9d88761be6080e949 Mon Sep 17 00:00:00 2001 From: momen Date: Fri, 6 Jun 2025 09:03:15 +0800 Subject: [PATCH 036/114] =?UTF-8?q?chore:=E8=BE=93=E5=87=BA=E5=8C=85?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/aptssupdater.cpp | 87 ++++++++++++++++++++++++++++++++++++++++++++ src/aptssupdater.h | 3 ++ src/mainwindow.cpp | 4 +- 3 files changed, 91 insertions(+), 3 deletions(-) diff --git a/src/aptssupdater.cpp b/src/aptssupdater.cpp index d3378ea..e14690b 100644 --- a/src/aptssupdater.cpp +++ b/src/aptssupdater.cpp @@ -299,3 +299,90 @@ QStringList aptssUpdater::getPackageIcons() return packageIcons; } + +QJsonArray aptssUpdater::getUpdateInfoAsJson() +{ + QJsonArray jsonArray; + + // 获取所有需要的信息 + QStringList packages = getUpdateablePackages(); + QStringList sizes = getPackageSizes(); + QStringList names = getDesktopAppNames(); + QStringList icons = getPackageIcons(); + + // 创建包名到各种信息的映射 + QHash> packageInfo; + + // 解析包版本信息 + for (const QString &pkg : packages) { + QStringList parts = pkg.split(": "); + if (parts.size() >= 2) { + QString packageName = parts[0]; + QStringList versions = parts[1].split(" → "); + if (versions.size() == 2) { + packageInfo[packageName]["current_version"] = versions[0]; + packageInfo[packageName]["new_version"] = versions[1]; + } + } + } + + // 解析包大小信息 + for (const QString &sizeInfo : sizes) { + QStringList parts = sizeInfo.split(": "); + if (parts.size() == 2) { + QString packageName = parts[0]; + packageInfo[packageName]["size"] = parts[1]; + } + } + + // 解析应用名称信息 + for (const QString &nameInfo : names) { + if (nameInfo.startsWith("[") && nameInfo.endsWith("]")) { + QString content = nameInfo.mid(1, nameInfo.length() - 2); + QStringList parts = content.split("|"); + if (parts.size() == 2) { + QString displayName = parts[0]; + QString packageName = parts[1]; + packageInfo[packageName]["display_name"] = displayName; + } + } + } + + // 解析图标信息 + for (const QString &iconInfo : icons) { + QStringList parts = iconInfo.split(": "); + if (parts.size() == 2) { + QString packageName = parts[0]; + packageInfo[packageName]["icon"] = parts[1].trimmed(); + } + } + + // 构建JSON数组 + for (const QString &packageName : packageInfo.keys()) { + QJsonObject jsonObj; + jsonObj["package"] = packageName; + + // 使用显示名称(如果有),否则使用包名 + if (packageInfo[packageName].contains("display_name")) { + jsonObj["name"] = packageInfo[packageName]["display_name"]; + } else { + jsonObj["name"] = packageName; + } + + jsonObj["current_version"] = packageInfo[packageName]["current_version"]; + jsonObj["new_version"] = packageInfo[packageName]["new_version"]; + jsonObj["icon"] = packageInfo[packageName]["icon"]; + jsonObj["ignored"] = false; // 默认不忽略 + + // 如果有大小信息也加入 + if (packageInfo[packageName].contains("size")) { + jsonObj["size"] = packageInfo[packageName]["size"]; + } + + jsonArray.append(jsonObj); + } + qDebug()< #include #include +#include +#include class aptssUpdater : public QWidget { Q_OBJECT @@ -15,6 +17,7 @@ public: QStringList getPackageSizes(); // 获取每个包的大小 QStringList getDesktopAppNames(); // 获取桌面应用名称列表 QStringList getPackageIcons(); // 获取包图标列表 + QJsonArray getUpdateInfoAsJson(); // 获取更新信息的 JSON 格式 QString m_tempFilePath; signals: private: diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 87f4987..a8deca0 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -105,9 +105,7 @@ void MainWindow::checkUpdates() // 获取可更新包列表 // QStringList updateablePackages = updater.getUpdateablePackages(); - QStringList appName = updater.getDesktopAppNames(); - updater.getPackageSizes(); - updater.getPackageIcons(); + updater.getUpdateInfoAsJson(); } From 064b06813546218b18d83e85bd3b5af845882207 Mon Sep 17 00:00:00 2001 From: momen Date: Fri, 6 Jun 2025 11:05:31 +0800 Subject: [PATCH 037/114] =?UTF-8?q?feat:=E8=8E=B7=E5=8F=96=E5=88=B0?= =?UTF-8?q?=E5=8C=85json=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/aptssupdater.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/aptssupdater.cpp b/src/aptssupdater.cpp index e14690b..05918c0 100644 --- a/src/aptssupdater.cpp +++ b/src/aptssupdater.cpp @@ -305,7 +305,6 @@ QJsonArray aptssUpdater::getUpdateInfoAsJson() QJsonArray jsonArray; // 获取所有需要的信息 - QStringList packages = getUpdateablePackages(); QStringList sizes = getPackageSizes(); QStringList names = getDesktopAppNames(); QStringList icons = getPackageIcons(); @@ -314,7 +313,7 @@ QJsonArray aptssUpdater::getUpdateInfoAsJson() QHash> packageInfo; // 解析包版本信息 - for (const QString &pkg : packages) { + for (const QString &pkg : packageName) { QStringList parts = pkg.split(": "); if (parts.size() >= 2) { QString packageName = parts[0]; From 3ba3364fb969998ebaa2762e6251d3939a2f36fd Mon Sep 17 00:00:00 2001 From: momen Date: Fri, 6 Jun 2025 13:29:35 +0800 Subject: [PATCH 038/114] =?UTF-8?q?chore:=E7=BB=98=E5=88=B6=E5=8C=85?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E9=AA=A8=E6=9E=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/CMakeLists.txt | 2 ++ src/appdelegate.cpp | 5 +++++ src/appdelegate.h | 15 +++++++++++++++ src/applistmodel.cpp | 5 +++++ src/applistmodel.h | 15 +++++++++++++++ 5 files changed, 42 insertions(+) create mode 100644 src/appdelegate.cpp create mode 100644 src/appdelegate.h create mode 100644 src/applistmodel.cpp create mode 100644 src/applistmodel.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b41f81c..2af8cb8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -25,6 +25,8 @@ if(${QT_VERSION_MAJOR} GREATER_EQUAL 6) ${PROJECT_SOURCES} aptssupdater.h aptssupdater.cpp icons.qrc + appdelegate.h appdelegate.cpp + applistmodel.h applistmodel.cpp ) # Define target properties for Android with Qt 6 as: # set_property(TARGET Spark-Update-Tool APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR diff --git a/src/appdelegate.cpp b/src/appdelegate.cpp new file mode 100644 index 0000000..f5162c6 --- /dev/null +++ b/src/appdelegate.cpp @@ -0,0 +1,5 @@ +#include "appdelegate.h" + +AppDelegate::AppDelegate(QObject *parent) + : QObject{parent} +{} diff --git a/src/appdelegate.h b/src/appdelegate.h new file mode 100644 index 0000000..e3b08a5 --- /dev/null +++ b/src/appdelegate.h @@ -0,0 +1,15 @@ +#ifndef APPDELEGATE_H +#define APPDELEGATE_H + +#include + +class AppDelegate : public QObject +{ + Q_OBJECT +public: + explicit AppDelegate(QObject *parent = nullptr); + +signals: +}; + +#endif // APPDELEGATE_H diff --git a/src/applistmodel.cpp b/src/applistmodel.cpp new file mode 100644 index 0000000..daebc97 --- /dev/null +++ b/src/applistmodel.cpp @@ -0,0 +1,5 @@ +#include "applistmodel.h" + +AppListModel::AppListModel(QObject *parent) + : QObject{parent} +{} diff --git a/src/applistmodel.h b/src/applistmodel.h new file mode 100644 index 0000000..a27ef78 --- /dev/null +++ b/src/applistmodel.h @@ -0,0 +1,15 @@ +#ifndef APPLISTMODEL_H +#define APPLISTMODEL_H + +#include + +class AppListModel : public QObject +{ + Q_OBJECT +public: + explicit AppListModel(QObject *parent = nullptr); + +signals: +}; + +#endif // APPLISTMODEL_H From 9e15e701c26243af3c9bf41f89a5ce901bc03130 Mon Sep 17 00:00:00 2001 From: momen Date: Fri, 6 Jun 2025 14:34:24 +0800 Subject: [PATCH 039/114] =?UTF-8?q?update:=E6=9B=B4=E6=96=B0=E8=BF=90?= =?UTF-8?q?=E8=A1=8C=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mainwindow.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index a8deca0..1d33641 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -5,8 +5,8 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { - checkUpdates(); ui->setupUi(this); + checkUpdates(); initStyle(); } //初始化控件样式 @@ -104,7 +104,6 @@ void MainWindow::checkUpdates() aptssUpdater updater; // 获取可更新包列表 - // QStringList updateablePackages = updater.getUpdateablePackages(); updater.getUpdateInfoAsJson(); } From 50adf557623b804717e3ee4895096dd77b104e94 Mon Sep 17 00:00:00 2001 From: momen Date: Sat, 7 Jun 2025 23:34:38 +0800 Subject: [PATCH 040/114] =?UTF-8?q?chore:=E5=B0=86=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E5=9C=A8=E4=B8=BB=E7=95=8C=E9=9D=A2=E4=B8=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/appdelegate.cpp | 40 +++++++++++++++++++++++++++++++++++++--- src/appdelegate.h | 12 +++++++++--- src/applistmodel.cpp | 41 ++++++++++++++++++++++++++++++++++++++--- src/applistmodel.h | 17 ++++++++++++++--- src/mainwindow.cpp | 18 +++++++++++++++--- src/mainwindow.h | 7 +++++++ 6 files changed, 120 insertions(+), 15 deletions(-) diff --git a/src/appdelegate.cpp b/src/appdelegate.cpp index f5162c6..ff2c11b 100644 --- a/src/appdelegate.cpp +++ b/src/appdelegate.cpp @@ -1,5 +1,39 @@ #include "appdelegate.h" +#include +#include -AppDelegate::AppDelegate(QObject *parent) - : QObject{parent} -{} +AppDelegate::AppDelegate(QObject *parent) : QStyledItemDelegate(parent) {} + +void AppDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const +{ + QStyledItemDelegate::paint(painter, option, index); + + // 获取数据 + QString name = index.data(Qt::DisplayRole).toString(); + QString currentVersion = index.data(Qt::UserRole + 2).toString(); + QString newVersion = index.data(Qt::UserRole + 3).toString(); + QString iconPath = index.data(Qt::UserRole + 4).toString(); + + // 绘制图标 + QIcon icon(iconPath); + QRect iconRect(option.rect.x() + 10, option.rect.y() + 10, 32, 32); + icon.paint(painter, iconRect); + + // 绘制文本 + QRect textRect(iconRect.right() + 10, option.rect.y() + 10, option.rect.width() - iconRect.width() - 20, option.rect.height() - 20); + painter->drawText(textRect, Qt::TextWordWrap, QString("%1\n当前版本: %2 → 新版本: %3").arg(name, currentVersion, newVersion)); +} + +QSize AppDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const +{ + return QSize(option.rect.width(), 60); // 每行高度 60 +} + +bool AppDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index) +{ + if (event->type() == QEvent::MouseButtonRelease) { + qDebug() << "点击了第" << index.row() << "行"; + return true; + } + return QStyledItemDelegate::editorEvent(event, model, option, index); +} \ No newline at end of file diff --git a/src/appdelegate.h b/src/appdelegate.h index e3b08a5..893aacb 100644 --- a/src/appdelegate.h +++ b/src/appdelegate.h @@ -1,15 +1,21 @@ #ifndef APPDELEGATE_H #define APPDELEGATE_H -#include +#include +#include +// 添加 QEvent 头文件 +#include -class AppDelegate : public QObject +class AppDelegate : public QStyledItemDelegate { Q_OBJECT public: explicit AppDelegate(QObject *parent = nullptr); -signals: + // 重写方法 + void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override; + QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override; + bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index) override; }; #endif // APPDELEGATE_H diff --git a/src/applistmodel.cpp b/src/applistmodel.cpp index daebc97..f18ffa3 100644 --- a/src/applistmodel.cpp +++ b/src/applistmodel.cpp @@ -1,5 +1,40 @@ #include "applistmodel.h" -AppListModel::AppListModel(QObject *parent) - : QObject{parent} -{} +AppListModel::AppListModel(QObject *parent) : QAbstractListModel(parent) {} + +int AppListModel::rowCount(const QModelIndex &parent) const +{ + if (parent.isValid()) + return 0; + return m_data.size(); +} + +QVariant AppListModel::data(const QModelIndex &index, int role) const +{ + if (!index.isValid() || index.row() >= m_data.size()) + return QVariant(); + + const QJsonObject obj = m_data.at(index.row()).toObject(); + + switch (role) { + case Qt::DisplayRole: + return obj["name"].toString(); + case Qt::UserRole + 1: // 包名 + return obj["package"].toString(); + case Qt::UserRole + 2: // 当前版本 + return obj["current_version"].toString(); + case Qt::UserRole + 3: // 新版本 + return obj["new_version"].toString(); + case Qt::UserRole + 4: // 图标路径 + return obj["icon"].toString(); + default: + return QVariant(); + } +} + +void AppListModel::setUpdateData(const QJsonArray &data) +{ + beginResetModel(); + m_data = data; + endResetModel(); +} diff --git a/src/applistmodel.h b/src/applistmodel.h index a27ef78..8fc82e7 100644 --- a/src/applistmodel.h +++ b/src/applistmodel.h @@ -1,15 +1,26 @@ #ifndef APPLISTMODEL_H #define APPLISTMODEL_H -#include +#include +#include +// 添加 QJsonObject 头文件 +#include -class AppListModel : public QObject +class AppListModel : public QAbstractListModel { Q_OBJECT public: explicit AppListModel(QObject *parent = nullptr); -signals: + // 重写方法 + int rowCount(const QModelIndex &parent = QModelIndex()) const override; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + + // 设置更新数据 + void setUpdateData(const QJsonArray &data); + +private: + QJsonArray m_data; }; #endif // APPLISTMODEL_H diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 1d33641..b8a02f1 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -4,8 +4,21 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) + , m_model(new AppListModel(this)) + , m_delegate(new AppDelegate(this)) { ui->setupUi(this); + + // 创建 QListView 并设置父控件为 ui->appWidget + listView = new QListView(ui->appWidget); + listView->setModel(m_model); + listView->setItemDelegate(m_delegate); + + // 设置 QListView 填充 ui->appWidget + QVBoxLayout *layout = new QVBoxLayout(ui->appWidget); + layout->addWidget(listView); + layout->setContentsMargins(0, 0, 0, 0); + checkUpdates(); initStyle(); } @@ -102,9 +115,8 @@ void MainWindow::initStyle() void MainWindow::checkUpdates() { aptssUpdater updater; - - // 获取可更新包列表 - updater.getUpdateInfoAsJson(); + QJsonArray updateInfo = updater.getUpdateInfoAsJson(); + m_model->setUpdateData(updateInfo); } diff --git a/src/mainwindow.h b/src/mainwindow.h index 361f01f..9cb6af8 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -3,6 +3,10 @@ #include #include "aptssupdater.h" +#include "applistmodel.h" +#include "appdelegate.h" +#include + QT_BEGIN_NAMESPACE namespace Ui { class MainWindow; @@ -21,5 +25,8 @@ private: Ui::MainWindow *ui; void checkUpdates(); void initStyle(); + AppListModel *m_model; + AppDelegate *m_delegate; + QListView *listView; // 声明 QListView 指针 }; #endif // MAINWINDOW_H From a779a3532bcaa1ca7613a11d01d970ca2a16f7e9 Mon Sep 17 00:00:00 2001 From: momen Date: Sun, 8 Jun 2025 00:57:43 +0800 Subject: [PATCH 041/114] =?UTF-8?q?chore:=E6=98=BE=E7=A4=BA=E5=8C=85?= =?UTF-8?q?=E5=A4=A7=E5=B0=8F=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/appdelegate.cpp | 7 +++++-- src/applistmodel.cpp | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/appdelegate.cpp b/src/appdelegate.cpp index ff2c11b..8aeac93 100644 --- a/src/appdelegate.cpp +++ b/src/appdelegate.cpp @@ -13,15 +13,18 @@ void AppDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, c QString currentVersion = index.data(Qt::UserRole + 2).toString(); QString newVersion = index.data(Qt::UserRole + 3).toString(); QString iconPath = index.data(Qt::UserRole + 4).toString(); + // 获取包大小数据 + QVariant sizeVariant = index.data(Qt::UserRole + 5); + QString size = sizeVariant.isValid() ? sizeVariant.toString() : "未知"; // 绘制图标 QIcon icon(iconPath); QRect iconRect(option.rect.x() + 10, option.rect.y() + 10, 32, 32); icon.paint(painter, iconRect); - // 绘制文本 + // 绘制文本,添加包大小信息 QRect textRect(iconRect.right() + 10, option.rect.y() + 10, option.rect.width() - iconRect.width() - 20, option.rect.height() - 20); - painter->drawText(textRect, Qt::TextWordWrap, QString("%1\n当前版本: %2 → 新版本: %3").arg(name, currentVersion, newVersion)); + painter->drawText(textRect, Qt::TextWordWrap, QString("%1\n当前版本: %2 → 新版本: %3\n包大小: %4").arg(name, currentVersion, newVersion, size)); } QSize AppDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const diff --git a/src/applistmodel.cpp b/src/applistmodel.cpp index f18ffa3..a896b0e 100644 --- a/src/applistmodel.cpp +++ b/src/applistmodel.cpp @@ -27,6 +27,8 @@ QVariant AppListModel::data(const QModelIndex &index, int role) const return obj["new_version"].toString(); case Qt::UserRole + 4: // 图标路径 return obj["icon"].toString(); + case Qt::UserRole + 5: // 文件大小 + return obj["size"].toVariant(); default: return QVariant(); } From 75ac14a8b83226af971b5e1a00ec4cf3137eaa72 Mon Sep 17 00:00:00 2001 From: momen Date: Sun, 8 Jun 2025 01:16:21 +0800 Subject: [PATCH 042/114] =?UTF-8?q?=20feat:=E6=98=BE=E7=A4=BA=E5=8C=85?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/appdelegate.cpp | 74 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 61 insertions(+), 13 deletions(-) diff --git a/src/appdelegate.cpp b/src/appdelegate.cpp index 8aeac93..c5043ea 100644 --- a/src/appdelegate.cpp +++ b/src/appdelegate.cpp @@ -6,30 +6,78 @@ AppDelegate::AppDelegate(QObject *parent) : QStyledItemDelegate(parent) {} void AppDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { - QStyledItemDelegate::paint(painter, option, index); + painter->save(); - // 获取数据 + // 绘制背景 + if (option.state & QStyle::State_Selected) { + painter->fillRect(option.rect, option.palette.highlight()); + } else { + painter->fillRect(option.rect, QColor("#F3F4F6")); + } + + // 设置字体 + QFont boldFont = option.font; + boldFont.setBold(true); + + QFont normalFont = option.font; + + // 数据 QString name = index.data(Qt::DisplayRole).toString(); QString currentVersion = index.data(Qt::UserRole + 2).toString(); QString newVersion = index.data(Qt::UserRole + 3).toString(); QString iconPath = index.data(Qt::UserRole + 4).toString(); - // 获取包大小数据 - QVariant sizeVariant = index.data(Qt::UserRole + 5); - QString size = sizeVariant.isValid() ? sizeVariant.toString() : "未知"; + QString size = index.data(Qt::UserRole + 5).toString(); + QString description = index.data(Qt::UserRole + 6).toString(); // 假设额外说明文本 - // 绘制图标 - QIcon icon(iconPath); - QRect iconRect(option.rect.x() + 10, option.rect.y() + 10, 32, 32); - icon.paint(painter, iconRect); + // 区域定义 + QRect rect = option.rect; + int margin = 10; + int spacing = 6; + int iconSize = 40; - // 绘制文本,添加包大小信息 - QRect textRect(iconRect.right() + 10, option.rect.y() + 10, option.rect.width() - iconRect.width() - 20, option.rect.height() - 20); - painter->drawText(textRect, Qt::TextWordWrap, QString("%1\n当前版本: %2 → 新版本: %3\n包大小: %4").arg(name, currentVersion, newVersion, size)); + // 图标 + QRect iconRect(rect.left() + margin, rect.top() + (rect.height() - iconSize) / 2, iconSize, iconSize); + QIcon(iconPath).paint(painter, iconRect); + + // 文本起点 + int textX = iconRect.right() + margin; + int textWidth = rect.width() - textX - 100; // 留出按钮区域 + + // 绘制应用名称 + QRect nameRect(textX, rect.top() + margin, textWidth, 20); + painter->setFont(boldFont); + painter->setPen(QColor("#333333")); // 改为深色,确保清晰 + painter->drawText(nameRect, Qt::AlignLeft | Qt::AlignVCenter, name); // 绘制应用名称 + + // 绘制版本信息 + QRect versionRect(textX, nameRect.bottom() + spacing, textWidth, 20); + painter->setFont(normalFont); + painter->setPen(QColor("#888888")); // 使用浅灰色,保持对比 + painter->drawText(versionRect, Qt::AlignLeft | Qt::AlignVCenter, + QString("当前版本: %1 → 新版本: %2").arg(currentVersion, newVersion)); + + // 描述行 + QRect descRect(textX, versionRect.bottom() + spacing, textWidth, 40); + painter->setFont(normalFont); + painter->setPen(QColor("#AAAAAA")); + painter->drawText(descRect, Qt::TextWordWrap, + QString("更新说明:%1\n包大小:%2").arg(description, size)); + + // 更新按钮(样式占位) + QRect buttonRect(rect.right() - 80, rect.top() + (rect.height() - 30) / 2, 70, 30); + painter->setPen(Qt::NoPen); + painter->setBrush(QColor("#267AFF")); + painter->drawRoundedRect(buttonRect, 6, 6); + painter->setPen(Qt::white); + painter->drawText(buttonRect, Qt::AlignCenter, "更新"); + + painter->restore(); } + QSize AppDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const { - return QSize(option.rect.width(), 60); // 每行高度 60 + return QSize(option.rect.width(), 110); // 每行高度 110 } bool AppDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index) From 705478fdf0c3157543bb0afca540527e550d762b Mon Sep 17 00:00:00 2001 From: momen Date: Sun, 8 Jun 2025 10:33:34 +0800 Subject: [PATCH 043/114] =?UTF-8?q?chore:=E5=8F=96=E6=B6=88=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E4=BF=A1=E6=81=AF=E7=9A=84=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/appdelegate.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/appdelegate.cpp b/src/appdelegate.cpp index c5043ea..682247b 100644 --- a/src/appdelegate.cpp +++ b/src/appdelegate.cpp @@ -61,7 +61,8 @@ void AppDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, c painter->setFont(normalFont); painter->setPen(QColor("#AAAAAA")); painter->drawText(descRect, Qt::TextWordWrap, - QString("更新说明:%1\n包大小:%2").arg(description, size)); + // QString("更新说明:%1\n包大小:%2").arg(description, size)); + QString("包大小:%1").arg(size)); // 更新按钮(样式占位) QRect buttonRect(rect.right() - 80, rect.top() + (rect.height() - 30) / 2, 70, 30); From 2cb69c72f3355ea7e7c8d17d0809896280e6cb9e Mon Sep 17 00:00:00 2001 From: momen Date: Sun, 8 Jun 2025 10:44:51 +0800 Subject: [PATCH 044/114] =?UTF-8?q?=20chore:=E6=9B=B4=E6=96=B0=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD=E9=AA=A8=E6=9E=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/CMakeLists.txt | 1 + src/appdelegate.cpp | 85 +++++++++++++++++++++++++++++++++++------ src/appdelegate.h | 12 +++++- src/downloadmanager.cpp | 53 +++++++++++++++++++++++++ src/downloadmanager.h | 32 ++++++++++++++++ 5 files changed, 171 insertions(+), 12 deletions(-) create mode 100644 src/downloadmanager.cpp create mode 100644 src/downloadmanager.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2af8cb8..29f7d58 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -27,6 +27,7 @@ if(${QT_VERSION_MAJOR} GREATER_EQUAL 6) icons.qrc appdelegate.h appdelegate.cpp applistmodel.h applistmodel.cpp + downloadmanager.h downloadmanager.cpp ) # Define target properties for Android with Qt 6 as: # set_property(TARGET Spark-Update-Tool APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR diff --git a/src/appdelegate.cpp b/src/appdelegate.cpp index 682247b..9d6fd41 100644 --- a/src/appdelegate.cpp +++ b/src/appdelegate.cpp @@ -1,9 +1,27 @@ #include "appdelegate.h" #include #include +#include "downloadmanager.h" +#include +#include +#include // 包含 QApplication 头文件 -AppDelegate::AppDelegate(QObject *parent) : QStyledItemDelegate(parent) {} - +AppDelegate::AppDelegate(QObject *parent) : QStyledItemDelegate(parent), m_downloadManager(new DownloadManager(this)) +{ + connect(m_downloadManager, &DownloadManager::downloadProgress, this, [this](int progress) { + m_progress = progress; + emit updateDisplay(); // 触发重绘 + }); + connect(m_downloadManager, &DownloadManager::downloadFinished, this, [this](bool success) { + m_isDownloading = false; + emit updateDisplay(); // 触发重绘 + if (success) { + qDebug() << "下载完成"; + } else { + qDebug() << "下载失败"; + } + }); +} void AppDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { painter->save(); @@ -64,18 +82,38 @@ void AppDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, c // QString("更新说明:%1\n包大小:%2").arg(description, size)); QString("包大小:%1").arg(size)); - // 更新按钮(样式占位) - QRect buttonRect(rect.right() - 80, rect.top() + (rect.height() - 30) / 2, 70, 30); - painter->setPen(Qt::NoPen); - painter->setBrush(QColor("#267AFF")); - painter->drawRoundedRect(buttonRect, 6, 6); - painter->setPen(Qt::white); - painter->drawText(buttonRect, Qt::AlignCenter, "更新"); + if (m_isDownloading) { + // 进度条 + QRect progressRect(rect.right() - 180, rect.top() + (rect.height() - 20) / 2, 100, 20); + QStyleOptionProgressBar progressBarOption; + progressBarOption.rect = progressRect; + progressBarOption.minimum = 0; + progressBarOption.maximum = 100; + progressBarOption.progress = m_progress; + progressBarOption.text = QString("%1%").arg(m_progress); + progressBarOption.textVisible = true; + QApplication::style()->drawControl(QStyle::CE_ProgressBar, &progressBarOption, painter); + + // 取消按钮 + QRect cancelButtonRect(rect.right() - 70, rect.top() + (rect.height() - 20) / 2, 60, 20); + QStyleOptionButton cancelButtonOption; + cancelButtonOption.rect = cancelButtonRect; + cancelButtonOption.text = "取消"; + cancelButtonOption.state |= QStyle::State_Enabled; + QApplication::style()->drawControl(QStyle::CE_PushButton, &cancelButtonOption, painter); + } else { + // 更新按钮 + QRect buttonRect(rect.right() - 80, rect.top() + (rect.height() - 30) / 2, 70, 30); + painter->setPen(Qt::NoPen); + painter->setBrush(QColor("#267AFF")); + painter->drawRoundedRect(buttonRect, 6, 6); + painter->setPen(Qt::white); + painter->drawText(buttonRect, Qt::AlignCenter, "更新"); + } painter->restore(); } - QSize AppDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const { return QSize(option.rect.width(), 110); // 每行高度 110 @@ -84,8 +122,33 @@ QSize AppDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelInde bool AppDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index) { if (event->type() == QEvent::MouseButtonRelease) { + QMouseEvent *mouseEvent = static_cast(event); + QRect rect = option.rect; + if (m_isDownloading) { + // 取消按钮区域 + QRect cancelButtonRect(rect.right() - 70, rect.top() + (rect.height() - 20) / 2, 60, 20); + if (cancelButtonRect.contains(mouseEvent->pos())) { + // 修正方法调用,假设 DownloadManager 有 killProcess 方法 + if (m_downloadManager->isRunning()) { + m_downloadManager->killProcess(); + m_isDownloading = false; + emit updateDisplay(); // 触发重绘 + } + return true; + } + } else { + // 更新按钮区域 + QRect buttonRect(rect.right() - 80, rect.top() + (rect.height() - 30) / 2, 70, 30); + if (buttonRect.contains(mouseEvent->pos())) { + QString appName = index.data(Qt::DisplayRole).toString(); + m_isDownloading = true; + m_progress = 0; + m_downloadManager->startDownload(appName); + emit updateDisplay(); // 触发重绘 + return true; + } + } qDebug() << "点击了第" << index.row() << "行"; - return true; } return QStyledItemDelegate::editorEvent(event, model, option, index); } \ No newline at end of file diff --git a/src/appdelegate.h b/src/appdelegate.h index 893aacb..11c78bf 100644 --- a/src/appdelegate.h +++ b/src/appdelegate.h @@ -3,8 +3,10 @@ #include #include -// 添加 QEvent 头文件 #include +#include +// 前向声明 DownloadManager 类 +class DownloadManager; class AppDelegate : public QStyledItemDelegate { @@ -16,6 +18,14 @@ public: void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override; QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override; bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index) override; + +signals: + void updateDisplay(); // 声明更新显示的信号 + +private: + DownloadManager *m_downloadManager; // 声明下载管理器指针 + int m_progress = 0; // 声明下载进度 + bool m_isDownloading = false; // 声明下载状态 }; #endif // APPDELEGATE_H diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp new file mode 100644 index 0000000..e491c7c --- /dev/null +++ b/src/downloadmanager.cpp @@ -0,0 +1,53 @@ +#include "downloadmanager.h" + +DownloadManager::DownloadManager(QObject *parent) : QObject(parent), m_process(new QProcess(this)) +{ + m_progressRegex = QRegularExpression(R"(\((\d+)%\))"); + connect(m_process, &QProcess::readyReadStandardOutput, this, &DownloadManager::onProcessReadyRead); + connect(m_process, QOverload::of(&QProcess::finished), this, &DownloadManager::onProcessFinished); +} + +DownloadManager::~DownloadManager() +{ + if (m_process->state() == QProcess::Running) { + m_process->kill(); + m_process->waitForFinished(); + } +} + +void DownloadManager::startDownload(const QString &appName) +{ + QString command = QString("aptss download --print-uris %1").arg(appName); + m_process->start(command); +} + +void DownloadManager::onProcessReadyRead() +{ + QByteArray output = m_process->readAllStandardOutput(); + QString outputStr = QString::fromUtf8(output); + + QRegularExpressionMatch match = m_progressRegex.match(outputStr); + if (match.hasMatch()) { + int progress = match.captured(1).toInt(); + emit downloadProgress(progress); + } +} + +void DownloadManager::onProcessFinished(int exitCode, QProcess::ExitStatus exitStatus) +{ + bool success = (exitStatus == QProcess::NormalExit && exitCode == 0); + emit downloadFinished(success); +} + +bool DownloadManager::isRunning() const +{ + return m_process->state() == QProcess::Running; +} + +void DownloadManager::killProcess() +{ + if (m_process->state() == QProcess::Running) { + m_process->kill(); + m_process->waitForFinished(); + } +} diff --git a/src/downloadmanager.h b/src/downloadmanager.h new file mode 100644 index 0000000..5cdf54a --- /dev/null +++ b/src/downloadmanager.h @@ -0,0 +1,32 @@ +#ifndef DOWNLOADMANAGER_H +#define DOWNLOADMANAGER_H + +#include +#include +#include + +class DownloadManager : public QObject +{ + Q_OBJECT +public: + explicit DownloadManager(QObject *parent = nullptr); + ~DownloadManager(); + + void startDownload(const QString &appName); + bool isRunning() const; // 声明 isRunning 方法 + void killProcess(); // 声明 killProcess 方法 + +signals: + void downloadProgress(int progress); + void downloadFinished(bool success); + +private slots: + void onProcessReadyRead(); + void onProcessFinished(int exitCode, QProcess::ExitStatus exitStatus); + +private: + QProcess *m_process; + QRegularExpression m_progressRegex; +}; + +#endif // DOWNLOADMANAGER_H From 9ae6e00d71d49c11fd1535fa2dadc65a95398253 Mon Sep 17 00:00:00 2001 From: momen Date: Mon, 9 Jun 2025 21:10:37 +0800 Subject: [PATCH 045/114] =?UTF-8?q?fix:=E4=BF=AE=E6=AD=A3=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E8=BD=AF=E4=BB=B6=E5=90=8D=E8=8E=B7=E5=8F=96=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/appdelegate.cpp | 5 +++-- src/downloadmanager.cpp | 5 +++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/appdelegate.cpp b/src/appdelegate.cpp index 9d6fd41..c799c8e 100644 --- a/src/appdelegate.cpp +++ b/src/appdelegate.cpp @@ -140,10 +140,11 @@ bool AppDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, const QS // 更新按钮区域 QRect buttonRect(rect.right() - 80, rect.top() + (rect.height() - 30) / 2, 70, 30); if (buttonRect.contains(mouseEvent->pos())) { - QString appName = index.data(Qt::DisplayRole).toString(); + // 修改这里:使用Qt::UserRole +1获取包名 + QString packageName = index.data(Qt::UserRole + 1).toString(); m_isDownloading = true; m_progress = 0; - m_downloadManager->startDownload(appName); + m_downloadManager->startDownload(packageName); emit updateDisplay(); // 触发重绘 return true; } diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp index e491c7c..eb48f49 100644 --- a/src/downloadmanager.cpp +++ b/src/downloadmanager.cpp @@ -1,4 +1,5 @@ #include "downloadmanager.h" +#include // 包含 QDebug 头文件 DownloadManager::DownloadManager(QObject *parent) : QObject(parent), m_process(new QProcess(this)) { @@ -17,7 +18,11 @@ DownloadManager::~DownloadManager() void DownloadManager::startDownload(const QString &appName) { + // 输出开始下载的日志 + qDebug() << "开始下载应用:" << appName; QString command = QString("aptss download --print-uris %1").arg(appName); + // 输出执行的命令日志 + qDebug() << "执行命令:" << command; m_process->start(command); } From ef2a0027c12615d233b7f3fa115ad28d9e1aba56 Mon Sep 17 00:00:00 2001 From: momen Date: Mon, 9 Jun 2025 21:38:25 +0800 Subject: [PATCH 046/114] =?UTF-8?q?fix:=E4=BF=AE=E6=AD=A3=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD=E9=94=99=E8=AF=AF=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/downloadmanager.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp index eb48f49..21c8ed2 100644 --- a/src/downloadmanager.cpp +++ b/src/downloadmanager.cpp @@ -19,11 +19,12 @@ DownloadManager::~DownloadManager() void DownloadManager::startDownload(const QString &appName) { // 输出开始下载的日志 - qDebug() << "开始下载应用:" << appName; - QString command = QString("aptss download --print-uris %1").arg(appName); - // 输出执行的命令日志 - qDebug() << "执行命令:" << command; - m_process->start(command); + QString program = "aptss"; + QStringList arguments; + arguments << "download" << "--print-uris" << appName; + + qDebug() << "执行命令:" << program << arguments.join(" "); + m_process->start(program, arguments); } void DownloadManager::onProcessReadyRead() From 8b408d42d3c2a4edc549aab599aa88cf97930c9a Mon Sep 17 00:00:00 2001 From: momen Date: Mon, 9 Jun 2025 21:40:59 +0800 Subject: [PATCH 047/114] =?UTF-8?q?chore:=E5=A2=9E=E5=8A=A0=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD=E8=B6=85=E6=97=B6=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/downloadmanager.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp index 21c8ed2..2bdbfd8 100644 --- a/src/downloadmanager.cpp +++ b/src/downloadmanager.cpp @@ -12,7 +12,13 @@ DownloadManager::~DownloadManager() { if (m_process->state() == QProcess::Running) { m_process->kill(); - m_process->waitForFinished(); + // 原代码 + // m_process->waitForFinished(); + + // 修改后增加超时处理 + if (!m_process->waitForFinished(5000)) { + qWarning() << "进程终止超时"; + } } } From 7ab203c86a69f46e800ded424739281292a3dec9 Mon Sep 17 00:00:00 2001 From: momen Date: Tue, 10 Jun 2025 11:03:31 +0800 Subject: [PATCH 048/114] =?UTF-8?q?chore:=E5=8F=96=E6=B6=88appwidget?= =?UTF-8?q?=E5=9B=BA=E5=AE=9A=E5=A4=A7=E5=B0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mainwindow.ui | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 80ac609..fb71fcd 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -268,11 +268,11 @@ - - - 598 - 1328 - + + + 0 + 0 + From a743002b1286ef724bb42c08b2b298c4534f97d2 Mon Sep 17 00:00:00 2001 From: momen Date: Tue, 10 Jun 2025 11:08:26 +0800 Subject: [PATCH 049/114] =?UTF-8?q?chore:=E8=B0=83=E6=95=B4widget=5F4?= =?UTF-8?q?=E5=9B=BA=E5=AE=9A=E9=AB=98=E5=BA=A6=E5=A4=A7=E5=B0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mainwindow.ui | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/mainwindow.ui b/src/mainwindow.ui index fb71fcd..25ddd74 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -64,15 +64,15 @@ - - - 1376 - 746 - - + + + 0 + 0 + + 0 From 3ef8f4da7fdbc0b8e5ceb367b86ab119cfed8dea Mon Sep 17 00:00:00 2001 From: momen Date: Tue, 10 Jun 2025 11:09:55 +0800 Subject: [PATCH 050/114] =?UTF-8?q?chore:=E5=88=A0=E9=99=A4=E6=97=A0?= =?UTF-8?q?=E5=85=B3=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mainwindow.ui | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 25ddd74..f0aace0 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -119,25 +119,6 @@ 0 - - - - - 16 - 16 - - - - - 16 - 16 - - - - - - - From 616453ed7d1cc3939ee4219b28f37f165e48087f Mon Sep 17 00:00:00 2001 From: momen Date: Tue, 10 Jun 2025 14:26:41 +0800 Subject: [PATCH 051/114] =?UTF-8?q?update:=E6=9B=B4=E6=96=B0listview?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F=EF=BC=8C=E7=BE=8E=E5=8C=96=E6=BB=9A=E5=8A=A8?= =?UTF-8?q?=E6=9D=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mainwindow.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index b8a02f1..ba23551 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -111,6 +111,40 @@ void MainWindow::initStyle() //设置主背景颜色 this->setStyleSheet("background-color: #F8FAFC;"); + // 添加滚动条样式 + listView->setStyleSheet(R"( + QScrollBar:vertical { + background: #F3F4F6; + width: 8px; + margin: 0px; + } + QScrollBar::handle:vertical { + background: #D1D5DB; + border-radius: 4px; + min-height: 30px; + } + QScrollBar::handle:vertical:hover { + background: #9CA3AF; + } + QScrollBar::add-line:vertical, QScrollBar::sub-line:vertical { + background: none; + height: 0px; + } + + QScrollBar:horizontal { + background: #F3F4F6; + height: 8px; + margin: 0px; + } + QScrollBar::handle:horizontal { + background: #D1D5DB; + border-radius: 4px; + min-width: 30px; + } + QScrollBar::handle:horizontal:hover { + background: #9CA3AF; + } + )"); } void MainWindow::checkUpdates() { From d5af9c2cf1ee93bde04fb52b1f5b7aa9321f544c Mon Sep 17 00:00:00 2001 From: momen Date: Wed, 11 Jun 2025 11:18:44 +0800 Subject: [PATCH 052/114] =?UTF-8?q?chore:qdebug=E8=BE=93=E5=87=BA=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E4=B8=8B=E8=BD=BD=E8=BF=9B=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/downloadmanager.cpp | 27 +++++++++++++++++++++------ src/downloadmanager.h | 1 - 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp index 2bdbfd8..a074514 100644 --- a/src/downloadmanager.cpp +++ b/src/downloadmanager.cpp @@ -35,16 +35,31 @@ void DownloadManager::startDownload(const QString &appName) void DownloadManager::onProcessReadyRead() { - QByteArray output = m_process->readAllStandardOutput(); - QString outputStr = QString::fromUtf8(output); + static QString buffer; // 缓存未处理的输出 + buffer += QString::fromUtf8(m_process->readAllStandardOutput()); - QRegularExpressionMatch match = m_progressRegex.match(outputStr); - if (match.hasMatch()) { - int progress = match.captured(1).toInt(); - emit downloadProgress(progress); + const QStringList lines = buffer.split(QRegularExpression("[\r\n]"), Qt::SkipEmptyParts); + + for (const QString &line : lines) { + QRegularExpressionMatch match = m_progressRegex.match(line); + if (match.hasMatch()) { + int progress = match.captured(1).toInt(); + qDebug() << "匹配进度:" << progress << "% => " << line; + emit downloadProgress(progress); + } else { + // qDebug() << "未匹配行:" << line; + } + } + + // 如果最后不是完整的一行,保留最后一部分 + if (!buffer.endsWith('\n') && !buffer.endsWith('\r')) { + buffer = lines.last(); + } else { + buffer.clear(); } } + void DownloadManager::onProcessFinished(int exitCode, QProcess::ExitStatus exitStatus) { bool success = (exitStatus == QProcess::NormalExit && exitCode == 0); diff --git a/src/downloadmanager.h b/src/downloadmanager.h index 5cdf54a..36d204f 100644 --- a/src/downloadmanager.h +++ b/src/downloadmanager.h @@ -4,7 +4,6 @@ #include #include #include - class DownloadManager : public QObject { Q_OBJECT From 59f506c8e616bee9d576971b74557ffa69bd3d26 Mon Sep 17 00:00:00 2001 From: momen Date: Wed, 11 Jun 2025 22:36:36 +0800 Subject: [PATCH 053/114] =?UTF-8?q?update:=E4=BD=BF=E7=94=A8apt=20download?= =?UTF-8?q?=20=20=20--print-uris=20=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E5=8C=85=E5=A4=A7=E5=B0=8F=EF=BC=8C=E4=B8=8B=E8=BD=BD=E9=93=BE?= =?UTF-8?q?=E6=8E=A5=E3=80=81sha512=E7=AD=89=E5=B9=B6=E8=BF=94=E5=9B=9Ejso?= =?UTF-8?q?n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/aptssupdater.cpp | 74 ++++++++++++++++++++++++-------------------- 1 file changed, 40 insertions(+), 34 deletions(-) diff --git a/src/aptssupdater.cpp b/src/aptssupdater.cpp index 05918c0..d5605bf 100644 --- a/src/aptssupdater.cpp +++ b/src/aptssupdater.cpp @@ -67,49 +67,46 @@ QStringList aptssUpdater::getUpdateablePackages() QStringList aptssUpdater::getPackageSizes() { - QStringList packageSizes; + QStringList packageDetails; QProcess process; - // 使用绝对路径 + 自动输入N跳过交互 - QString command = R"(echo N | /opt/durapps/spark-store/bin/aptss upgrade --assume-no)"; - - process.start("bash", QStringList() << "-c" << command); - if (!process.waitForFinished()) { - qWarning() << "获取包大小失败:进程未完成"; - return packageSizes; - } - - QString output = process.readAllStandardOutput() + process.readAllStandardError(); - - // 清理颜色控制字符(ANSI 转义序列) - output.remove(QRegularExpression(R"(\x1B\[[0-9;]*[a-zA-Z])")); // \x1B is ESC - - QStringList lines = output.split('\n', Qt::SkipEmptyParts); - - // 从 packageName 获取包名 + // 获取可更新包名列表 QStringList updateablePackages; for (const QString &pkgInfo : packageName) { - QString pkgName = pkgInfo.section(":", 0, 0).trimmed(); - updateablePackages << pkgName; + updateablePackages << pkgInfo.section(":", 0, 0).trimmed(); } - // 匹配 [apt-fast xx:xx:xx] 行,提取内容 - QRegularExpression sizeLineRegex(R"(\[apt-fast [^\]]+\](\S+)\s+\S+\s+(\d+(\.\d+)?[KMG]?iB))"); + foreach (const QString &packageName, updateablePackages) { + // 构建新命令(包含包名参数) + QString command = QString("apt download %1 --print-uris -c /opt/durapps/spark-store/bin/apt-fast-conf/aptss-apt.conf " + "-o Dir::Etc::sourcelist=\"/opt/durapps/spark-store/bin/apt-fast-conf/sources.list.d/sparkstore.list\" " + "-o Dir::Etc::sourceparts=\"/dev/null\"").arg(packageName); + + process.start("bash", QStringList() << "-c" << command); + if (!process.waitForFinished()) { + qWarning() << "获取包信息失败:" << packageName; + continue; + } + + QString output = process.readAllStandardOutput(); + // 使用正则匹配所有信息 + // 调整正则表达式匹配分组 + QRegularExpression regex(R"('([^']+)'\s+(\S+)\s+(\d+)\s+SHA512:([^\s]+))"); // 分组1:URL 分组2:文件名 分组3:大小 分组4:SHA512 + QRegularExpressionMatch match = regex.match(output); - for (const QString &line : lines) { - QRegularExpressionMatch match = sizeLineRegex.match(line.trimmed()); if (match.hasMatch()) { - QString name = match.captured(1); - QString size = match.captured(2); - - if (updateablePackages.contains(name)) { - packageSizes << QString("%1: %2").arg(name, size); - } + QString url = match.captured(1); + QString fileName = match.captured(2); + QString size = match.captured(3); + QString sha512 = match.captured(4); + + // 调整字段顺序:包名 | 大小 | URL | SHA512 + packageDetails << QString("%1: %2|%3|%4").arg(packageName, size, url, sha512); } } - qDebug() << "包大小列表:" << packageSizes; - return packageSizes; + qDebug() << "完整包信息:" << packageDetails; + return packageDetails; } @@ -325,12 +322,17 @@ QJsonArray aptssUpdater::getUpdateInfoAsJson() } } - // 解析包大小信息 + // 解析包详细信息(新增部分) for (const QString &sizeInfo : sizes) { QStringList parts = sizeInfo.split(": "); if (parts.size() == 2) { QString packageName = parts[0]; - packageInfo[packageName]["size"] = parts[1]; + QStringList details = parts[1].split("|"); + if (details.size() == 3) { // 现在包含大小|URL|SHA512 + packageInfo[packageName]["size"] = details[0]; + packageInfo[packageName]["url"] = details[1]; + packageInfo[packageName]["sha512"] = details[2]; + } } } @@ -378,6 +380,10 @@ QJsonArray aptssUpdater::getUpdateInfoAsJson() jsonObj["size"] = packageInfo[packageName]["size"]; } + // 在构建JSON对象时添加新字段(在jsonObj中添加): + jsonObj["download_url"] = packageInfo[packageName]["url"]; + jsonObj["sha512"] = packageInfo[packageName]["sha512"]; + jsonArray.append(jsonObj); } qDebug()< Date: Wed, 11 Jun 2025 22:49:00 +0800 Subject: [PATCH 054/114] =?UTF-8?q?update:=E6=98=BE=E7=A4=BA=E5=8C=85?= =?UTF-8?q?=E5=A4=A7=E5=B0=8F=E6=97=B6=E7=BB=9F=E4=B8=80=E6=8D=A2=E7=AE=97?= =?UTF-8?q?=E4=B8=BAMiB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/appdelegate.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/appdelegate.cpp b/src/appdelegate.cpp index c799c8e..e23c0cf 100644 --- a/src/appdelegate.cpp +++ b/src/appdelegate.cpp @@ -80,7 +80,7 @@ void AppDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, c painter->setPen(QColor("#AAAAAA")); painter->drawText(descRect, Qt::TextWordWrap, // QString("更新说明:%1\n包大小:%2").arg(description, size)); - QString("包大小:%1").arg(size)); + QString("包大小:%1 MB").arg(QString::number(size.toDouble() / (1024 * 1024), 'f', 2))); if (m_isDownloading) { // 进度条 From a2aadf44e33d223af1f7e65fb043c645a28b004c Mon Sep 17 00:00:00 2001 From: momen Date: Wed, 11 Jun 2025 23:08:35 +0800 Subject: [PATCH 055/114] =?UTF-8?q?chore:=E4=B8=8B=E8=BD=BDmetalink?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 0 src/CMakeLists.txt | 6 +- src/appdelegate.cpp | 26 ++++++--- src/applistmodel.cpp | 40 ++++++++++---- src/applistmodel.h | 2 +- src/aptssupdater.cpp | 9 ++- src/downloadmanager.cpp | 118 ++++++++++++++++++---------------------- src/downloadmanager.h | 24 ++++---- src/mainwindow.cpp | 7 ++- 9 files changed, 129 insertions(+), 103 deletions(-) create mode 100644 CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..e69de29 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 29f7d58..f7f76af 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -9,8 +9,8 @@ set(CMAKE_AUTORCC ON) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) -find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets) -find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets) +find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets Network) +find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets Network) set(PROJECT_SOURCES main.cpp @@ -47,7 +47,7 @@ else() endif() endif() -target_link_libraries(Spark-Update-Tool PRIVATE Qt${QT_VERSION_MAJOR}::Widgets) +target_link_libraries(Spark-Update-Tool PRIVATE Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Network) # Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1. # If you are developing for iOS or macOS you should consider setting an diff --git a/src/appdelegate.cpp b/src/appdelegate.cpp index e23c0cf..c2b6eb7 100644 --- a/src/appdelegate.cpp +++ b/src/appdelegate.cpp @@ -5,6 +5,7 @@ #include #include #include // 包含 QApplication 头文件 +#include // 添加 QDir 头文件 AppDelegate::AppDelegate(QObject *parent) : QStyledItemDelegate(parent), m_downloadManager(new DownloadManager(this)) { @@ -128,23 +129,32 @@ bool AppDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, const QS // 取消按钮区域 QRect cancelButtonRect(rect.right() - 70, rect.top() + (rect.height() - 20) / 2, 60, 20); if (cancelButtonRect.contains(mouseEvent->pos())) { - // 修正方法调用,假设 DownloadManager 有 killProcess 方法 - if (m_downloadManager->isRunning()) { - m_downloadManager->killProcess(); - m_isDownloading = false; - emit updateDisplay(); // 触发重绘 - } + // 修正方法调用,假设 DownloadManager 有 cancelDownload 方法 + m_downloadManager->cancelDownload(); + m_isDownloading = false; + emit updateDisplay(); // 触发重绘 return true; } } else { // 更新按钮区域 QRect buttonRect(rect.right() - 80, rect.top() + (rect.height() - 30) / 2, 70, 30); if (buttonRect.contains(mouseEvent->pos())) { - // 修改这里:使用Qt::UserRole +1获取包名 QString packageName = index.data(Qt::UserRole + 1).toString(); + QString downloadUrl = index.data(Qt::UserRole + 7).toString(); + + qDebug() << "从模型中获取的包名:" << packageName; + qDebug() << "从模型中获取的下载 URL:" << downloadUrl; // 检查模型中是否正确传递 URL + + if (downloadUrl.isEmpty()) { + qWarning() << "下载 URL 为空,无法开始下载,包名:" << packageName; + return false; + } + + QString outputPath = QString("%1/%2.metalink").arg(QDir::tempPath(), packageName); + m_isDownloading = true; m_progress = 0; - m_downloadManager->startDownload(packageName); + m_downloadManager->startDownload(downloadUrl, outputPath); emit updateDisplay(); // 触发重绘 return true; } diff --git a/src/applistmodel.cpp b/src/applistmodel.cpp index a896b0e..31e244a 100644 --- a/src/applistmodel.cpp +++ b/src/applistmodel.cpp @@ -14,29 +14,49 @@ QVariant AppListModel::data(const QModelIndex &index, int role) const if (!index.isValid() || index.row() >= m_data.size()) return QVariant(); - const QJsonObject obj = m_data.at(index.row()).toObject(); - + const QVariantMap &map = m_data.at(index.row()); // 直接访问 QVariantMap switch (role) { case Qt::DisplayRole: - return obj["name"].toString(); + return map.value("name"); case Qt::UserRole + 1: // 包名 - return obj["package"].toString(); + return map.value("package"); case Qt::UserRole + 2: // 当前版本 - return obj["current_version"].toString(); + return map.value("current_version"); case Qt::UserRole + 3: // 新版本 - return obj["new_version"].toString(); + return map.value("new_version"); case Qt::UserRole + 4: // 图标路径 - return obj["icon"].toString(); + return map.value("icon"); case Qt::UserRole + 5: // 文件大小 - return obj["size"].toVariant(); + return map.value("size"); + case Qt::UserRole + 6: // 描述 + return map.value("description"); + case Qt::UserRole + 7: // 下载 URL + return map.value("download_url"); // 返回下载 URL default: return QVariant(); } } -void AppListModel::setUpdateData(const QJsonArray &data) +void AppListModel::setUpdateData(const QJsonArray &updateInfo) { beginResetModel(); - m_data = data; + m_data.clear(); // 清空 QList + + for (const auto &item : updateInfo) { + QJsonObject obj = item.toObject(); + QVariantMap map; + map["package"] = obj["package"].toString(); + map["name"] = obj["name"].toString(); + map["current_version"] = obj["current_version"].toString(); + map["new_version"] = obj["new_version"].toString(); + map["icon"] = obj["icon"].toString(); + map["size"] = obj["size"].toString(); + map["download_url"] = obj["download_url"].toString(); // 确保设置下载 URL + m_data.append(map); // 添加到 QList + + qDebug() << "设置到模型的包名:" << map["package"].toString(); + qDebug() << "设置到模型的下载 URL:" << map["download_url"].toString(); // 检查设置的数据 + } + endResetModel(); } diff --git a/src/applistmodel.h b/src/applistmodel.h index 8fc82e7..2fb36c0 100644 --- a/src/applistmodel.h +++ b/src/applistmodel.h @@ -20,7 +20,7 @@ public: void setUpdateData(const QJsonArray &data); private: - QJsonArray m_data; + QList m_data; // 修改类型为 QList }; #endif // APPLISTMODEL_H diff --git a/src/aptssupdater.cpp b/src/aptssupdater.cpp index d5605bf..c4bd906 100644 --- a/src/aptssupdater.cpp +++ b/src/aptssupdater.cpp @@ -381,9 +381,14 @@ QJsonArray aptssUpdater::getUpdateInfoAsJson() } // 在构建JSON对象时添加新字段(在jsonObj中添加): - jsonObj["download_url"] = packageInfo[packageName]["url"]; + if (packageInfo[packageName].contains("url")) { + jsonObj["download_url"] = packageInfo[packageName]["url"]; + qDebug() << "生成的下载 URL:" << packageInfo[packageName]["url"]; // 检查生成的 URL + } else { + qWarning() << "未找到下载 URL,包名:" << packageName; + jsonObj["download_url"] = ""; // 设置为空字符串以避免崩溃 + } jsonObj["sha512"] = packageInfo[packageName]["sha512"]; - jsonArray.append(jsonObj); } qDebug()< // 包含 QDebug 头文件 +#include +#include -DownloadManager::DownloadManager(QObject *parent) : QObject(parent), m_process(new QProcess(this)) +DownloadManager::DownloadManager(QObject *parent) : QObject(parent) {} + +void DownloadManager::startDownload(const QString &url, const QString &outputPath) { - m_progressRegex = QRegularExpression(R"(\((\d+)%\))"); - connect(m_process, &QProcess::readyReadStandardOutput, this, &DownloadManager::onProcessReadyRead); - connect(m_process, QOverload::of(&QProcess::finished), this, &DownloadManager::onProcessFinished); + qDebug() << "接收到的下载 URL:" << url; // 检查 URL 是否正确传递 + + // 验证 URL 是否包含协议 + QUrl metalinkUrl(url + ".metalink"); + if (!metalinkUrl.isValid() || metalinkUrl.scheme().isEmpty()) { + qWarning() << "无效的 URL:" << metalinkUrl.toString(); + emit downloadFinished(false); + return; + } + + QNetworkRequest request(metalinkUrl); + m_reply = m_networkManager.get(request); + + connect(m_reply, &QNetworkReply::downloadProgress, this, &DownloadManager::onDownloadProgress); + connect(m_reply, &QNetworkReply::finished, this, &DownloadManager::onDownloadFinished); + + // 保存路径 + m_reply->setProperty("outputPath", outputPath); } -DownloadManager::~DownloadManager() +void DownloadManager::onDownloadProgress(qint64 bytesReceived, qint64 bytesTotal) { - if (m_process->state() == QProcess::Running) { - m_process->kill(); - // 原代码 - // m_process->waitForFinished(); - - // 修改后增加超时处理 - if (!m_process->waitForFinished(5000)) { - qWarning() << "进程终止超时"; - } + if (bytesTotal > 0) { + int progress = static_cast((bytesReceived * 100) / bytesTotal); + emit downloadProgress(progress); } } -void DownloadManager::startDownload(const QString &appName) +void DownloadManager::onDownloadFinished() { - // 输出开始下载的日志 - QString program = "aptss"; - QStringList arguments; - arguments << "download" << "--print-uris" << appName; - - qDebug() << "执行命令:" << program << arguments.join(" "); - m_process->start(program, arguments); -} - -void DownloadManager::onProcessReadyRead() -{ - static QString buffer; // 缓存未处理的输出 - buffer += QString::fromUtf8(m_process->readAllStandardOutput()); - - const QStringList lines = buffer.split(QRegularExpression("[\r\n]"), Qt::SkipEmptyParts); - - for (const QString &line : lines) { - QRegularExpressionMatch match = m_progressRegex.match(line); - if (match.hasMatch()) { - int progress = match.captured(1).toInt(); - qDebug() << "匹配进度:" << progress << "% => " << line; - emit downloadProgress(progress); + if (m_reply->error() == QNetworkReply::NoError) { + QString outputPath = m_reply->property("outputPath").toString(); + QFile file(outputPath); + if (file.open(QIODevice::WriteOnly)) { + file.write(m_reply->readAll()); + file.close(); + qDebug() << "文件已保存到路径:" << outputPath; // 输出保存路径 + emit downloadFinished(true); } else { - // qDebug() << "未匹配行:" << line; + qWarning() << "无法保存文件到路径:" << outputPath; + emit downloadFinished(false); } - } - - // 如果最后不是完整的一行,保留最后一部分 - if (!buffer.endsWith('\n') && !buffer.endsWith('\r')) { - buffer = lines.last(); } else { - buffer.clear(); - } -} - - -void DownloadManager::onProcessFinished(int exitCode, QProcess::ExitStatus exitStatus) -{ - bool success = (exitStatus == QProcess::NormalExit && exitCode == 0); - emit downloadFinished(success); -} - -bool DownloadManager::isRunning() const -{ - return m_process->state() == QProcess::Running; -} - -void DownloadManager::killProcess() -{ - if (m_process->state() == QProcess::Running) { - m_process->kill(); - m_process->waitForFinished(); + qWarning() << "下载失败:" << m_reply->errorString(); + emit downloadFinished(false); + } + + m_reply->deleteLater(); + m_reply = nullptr; +} + +void DownloadManager::cancelDownload() +{ + if (m_reply) { + m_reply->abort(); // 取消当前下载 + m_reply->deleteLater(); + m_reply = nullptr; + emit downloadFinished(false); // 发送下载失败信号 } } diff --git a/src/downloadmanager.h b/src/downloadmanager.h index 36d204f..28f4a30 100644 --- a/src/downloadmanager.h +++ b/src/downloadmanager.h @@ -2,30 +2,28 @@ #define DOWNLOADMANAGER_H #include -#include -#include +#include +#include + class DownloadManager : public QObject { Q_OBJECT public: explicit DownloadManager(QObject *parent = nullptr); - ~DownloadManager(); - - void startDownload(const QString &appName); - bool isRunning() const; // 声明 isRunning 方法 - void killProcess(); // 声明 killProcess 方法 + void startDownload(const QString &url, const QString &outputPath); + void cancelDownload(); // 添加取消下载的方法 signals: - void downloadProgress(int progress); - void downloadFinished(bool success); + void downloadProgress(int progress); // 下载进度信号 + void downloadFinished(bool success); // 下载完成信号 private slots: - void onProcessReadyRead(); - void onProcessFinished(int exitCode, QProcess::ExitStatus exitStatus); + void onDownloadProgress(qint64 bytesReceived, qint64 bytesTotal); + void onDownloadFinished(); private: - QProcess *m_process; - QRegularExpression m_progressRegex; + QNetworkAccessManager m_networkManager; + QNetworkReply *m_reply = nullptr; }; #endif // DOWNLOADMANAGER_H diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index ba23551..3aa8cee 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -151,7 +151,12 @@ void MainWindow::checkUpdates() aptssUpdater updater; QJsonArray updateInfo = updater.getUpdateInfoAsJson(); m_model->setUpdateData(updateInfo); - + + for (const auto &item : updateInfo) { + QJsonObject obj = item.toObject(); + qDebug() << "模型设置的包名:" << obj["package"].toString(); + qDebug() << "模型设置的下载 URL:" << obj["download_url"].toString(); // 检查模型数据 + } } MainWindow::~MainWindow() From f071fcb00d99e488858889d89c718475e80b36cb Mon Sep 17 00:00:00 2001 From: momen Date: Wed, 11 Jun 2025 23:11:29 +0800 Subject: [PATCH 056/114] =?UTF-8?q?chore:aria2=E4=B8=8B=E8=BD=BD=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/appdelegate.cpp | 27 ++++++++------- src/downloadmanager.cpp | 73 +++++++++++++++-------------------------- src/downloadmanager.h | 9 +++-- 3 files changed, 46 insertions(+), 63 deletions(-) diff --git a/src/appdelegate.cpp b/src/appdelegate.cpp index c2b6eb7..f211bf7 100644 --- a/src/appdelegate.cpp +++ b/src/appdelegate.cpp @@ -129,8 +129,6 @@ bool AppDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, const QS // 取消按钮区域 QRect cancelButtonRect(rect.right() - 70, rect.top() + (rect.height() - 20) / 2, 60, 20); if (cancelButtonRect.contains(mouseEvent->pos())) { - // 修正方法调用,假设 DownloadManager 有 cancelDownload 方法 - m_downloadManager->cancelDownload(); m_isDownloading = false; emit updateDisplay(); // 触发重绘 return true; @@ -141,19 +139,26 @@ bool AppDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, const QS if (buttonRect.contains(mouseEvent->pos())) { QString packageName = index.data(Qt::UserRole + 1).toString(); QString downloadUrl = index.data(Qt::UserRole + 7).toString(); - - qDebug() << "从模型中获取的包名:" << packageName; - qDebug() << "从模型中获取的下载 URL:" << downloadUrl; // 检查模型中是否正确传递 URL - - if (downloadUrl.isEmpty()) { - qWarning() << "下载 URL 为空,无法开始下载,包名:" << packageName; - return false; - } - QString outputPath = QString("%1/%2.metalink").arg(QDir::tempPath(), packageName); m_isDownloading = true; m_progress = 0; + + connect(m_downloadManager, &DownloadManager::downloadProgress, this, [this](int progress) { + m_progress = progress; + emit updateDisplay(); // 更新界面显示 + }); + + connect(m_downloadManager, &DownloadManager::downloadFinished, this, [this](bool success) { + m_isDownloading = false; + emit updateDisplay(); // 更新界面显示 + if (success) { + qDebug() << "下载完成"; + } else { + qDebug() << "下载失败"; + } + }); + m_downloadManager->startDownload(downloadUrl, outputPath); emit updateDisplay(); // 触发重绘 return true; diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp index 37a78e1..bcc7a80 100644 --- a/src/downloadmanager.cpp +++ b/src/downloadmanager.cpp @@ -1,68 +1,47 @@ #include "downloadmanager.h" #include #include +#include +#include // 添加 QFileInfo 头文件 DownloadManager::DownloadManager(QObject *parent) : QObject(parent) {} void DownloadManager::startDownload(const QString &url, const QString &outputPath) { - qDebug() << "接收到的下载 URL:" << url; // 检查 URL 是否正确传递 + QString metalinkUrl = url + ".metalink"; // 构造 Metalink URL + qDebug() << "开始下载 Metalink 文件:" << metalinkUrl; - // 验证 URL 是否包含协议 - QUrl metalinkUrl(url + ".metalink"); - if (!metalinkUrl.isValid() || metalinkUrl.scheme().isEmpty()) { - qWarning() << "无效的 URL:" << metalinkUrl.toString(); - emit downloadFinished(false); - return; - } + QStringList arguments; + arguments << "--enable-rpc=false" << "--console-log-level=warn" + << "--summary-interval=1" << "--dir=" + QFileInfo(outputPath).absolutePath() + << "--out=" + QFileInfo(outputPath).fileName() << metalinkUrl; - QNetworkRequest request(metalinkUrl); - m_reply = m_networkManager.get(request); + connect(&m_aria2Process, &QProcess::readyReadStandardOutput, this, &DownloadManager::onAria2Progress); + connect(&m_aria2Process, QOverload::of(&QProcess::finished), this, &DownloadManager::onAria2Finished); - connect(m_reply, &QNetworkReply::downloadProgress, this, &DownloadManager::onDownloadProgress); - connect(m_reply, &QNetworkReply::finished, this, &DownloadManager::onDownloadFinished); - - // 保存路径 - m_reply->setProperty("outputPath", outputPath); + m_aria2Process.start("aria2c", arguments); } -void DownloadManager::onDownloadProgress(qint64 bytesReceived, qint64 bytesTotal) +void DownloadManager::onAria2Progress() { - if (bytesTotal > 0) { - int progress = static_cast((bytesReceived * 100) / bytesTotal); - emit downloadProgress(progress); + QString output = m_aria2Process.readAllStandardOutput(); + QRegularExpression regex(R"(Download Progress: (\d+)%.*)"); + QRegularExpressionMatch match = regex.match(output); + + if (match.hasMatch()) { + int progress = match.captured(1).toInt(); + emit downloadProgress(progress); // 发送进度信号 + qDebug() << "下载进度:" << progress << "%"; } } -void DownloadManager::onDownloadFinished() +void DownloadManager::onAria2Finished(int exitCode, QProcess::ExitStatus exitStatus) { - if (m_reply->error() == QNetworkReply::NoError) { - QString outputPath = m_reply->property("outputPath").toString(); - QFile file(outputPath); - if (file.open(QIODevice::WriteOnly)) { - file.write(m_reply->readAll()); - file.close(); - qDebug() << "文件已保存到路径:" << outputPath; // 输出保存路径 - emit downloadFinished(true); - } else { - qWarning() << "无法保存文件到路径:" << outputPath; - emit downloadFinished(false); - } + if (exitCode == 0 && exitStatus == QProcess::NormalExit) { + qDebug() << "下载完成"; + emit downloadFinished(true); // 发送完成信号 } else { - qWarning() << "下载失败:" << m_reply->errorString(); - emit downloadFinished(false); - } - - m_reply->deleteLater(); - m_reply = nullptr; -} - -void DownloadManager::cancelDownload() -{ - if (m_reply) { - m_reply->abort(); // 取消当前下载 - m_reply->deleteLater(); - m_reply = nullptr; - emit downloadFinished(false); // 发送下载失败信号 + qWarning() << "下载失败,退出代码:" << exitCode; + emit downloadFinished(false); // 发送失败信号 } } diff --git a/src/downloadmanager.h b/src/downloadmanager.h index 28f4a30..ca80330 100644 --- a/src/downloadmanager.h +++ b/src/downloadmanager.h @@ -4,6 +4,7 @@ #include #include #include +#include class DownloadManager : public QObject { @@ -11,19 +12,17 @@ class DownloadManager : public QObject public: explicit DownloadManager(QObject *parent = nullptr); void startDownload(const QString &url, const QString &outputPath); - void cancelDownload(); // 添加取消下载的方法 signals: void downloadProgress(int progress); // 下载进度信号 void downloadFinished(bool success); // 下载完成信号 private slots: - void onDownloadProgress(qint64 bytesReceived, qint64 bytesTotal); - void onDownloadFinished(); + void onAria2Progress(); // 处理 aria2 的进度 + void onAria2Finished(int exitCode, QProcess::ExitStatus exitStatus); // 处理 aria2 完成事件 private: - QNetworkAccessManager m_networkManager; - QNetworkReply *m_reply = nullptr; + QProcess m_aria2Process; // 用于运行 aria2 的进程 }; #endif // DOWNLOADMANAGER_H From e416ffdbffee4bdc68df2290d56273a06bd99d48 Mon Sep 17 00:00:00 2001 From: momen Date: Wed, 11 Jun 2025 23:31:10 +0800 Subject: [PATCH 057/114] =?UTF-8?q?chore:=E6=98=BE=E7=A4=BA=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD=E7=99=BE=E5=88=86=E6=AF=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/downloadmanager.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp index bcc7a80..1603928 100644 --- a/src/downloadmanager.cpp +++ b/src/downloadmanager.cpp @@ -25,16 +25,20 @@ void DownloadManager::startDownload(const QString &url, const QString &outputPat void DownloadManager::onAria2Progress() { QString output = m_aria2Process.readAllStandardOutput(); - QRegularExpression regex(R"(Download Progress: (\d+)%.*)"); - QRegularExpressionMatch match = regex.match(output); + QRegularExpression regex(R"(\((\d+)%\))"); + QRegularExpressionMatchIterator i = regex.globalMatch(output); - if (match.hasMatch()) { - int progress = match.captured(1).toInt(); - emit downloadProgress(progress); // 发送进度信号 - qDebug() << "下载进度:" << progress << "%"; + while (i.hasNext()) { + QRegularExpressionMatch match = i.next(); + if (match.hasMatch()) { + int progress = match.captured(1).toInt(); + emit downloadProgress(progress); // 发送进度信号 + qDebug() << "下载进度:" << progress << "%"; + } } } + void DownloadManager::onAria2Finished(int exitCode, QProcess::ExitStatus exitStatus) { if (exitCode == 0 && exitStatus == QProcess::NormalExit) { From 90b21d40cfe22fd944190881e2489277fc675d69 Mon Sep 17 00:00:00 2001 From: momen Date: Thu, 12 Jun 2025 09:23:28 +0800 Subject: [PATCH 058/114] =?UTF-8?q?chore:=E6=9B=B4=E6=96=B0=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD=E8=BF=9B=E5=BA=A6=E6=9D=A1=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/appdelegate.cpp | 91 +++++++++++++++++------------------------ src/appdelegate.h | 10 +++-- src/downloadmanager.cpp | 70 ++++++++++++++++--------------- src/downloadmanager.h | 14 +++---- 4 files changed, 87 insertions(+), 98 deletions(-) diff --git a/src/appdelegate.cpp b/src/appdelegate.cpp index f211bf7..095b571 100644 --- a/src/appdelegate.cpp +++ b/src/appdelegate.cpp @@ -9,17 +9,22 @@ AppDelegate::AppDelegate(QObject *parent) : QStyledItemDelegate(parent), m_downloadManager(new DownloadManager(this)) { - connect(m_downloadManager, &DownloadManager::downloadProgress, this, [this](int progress) { - m_progress = progress; - emit updateDisplay(); // 触发重绘 + connect(m_downloadManager, &DownloadManager::downloadProgress, this, [this](const QString &packageName, int progress) { + if (m_downloads.contains(packageName)) { + m_downloads[packageName].progress = progress; + emit updateDisplay(); // 触发重绘 + } }); - connect(m_downloadManager, &DownloadManager::downloadFinished, this, [this](bool success) { - m_isDownloading = false; - emit updateDisplay(); // 触发重绘 - if (success) { - qDebug() << "下载完成"; - } else { - qDebug() << "下载失败"; + + connect(m_downloadManager, &DownloadManager::downloadFinished, this, [this](const QString &packageName, bool success) { + if (m_downloads.contains(packageName)) { + m_downloads[packageName].isDownloading = false; + emit updateDisplay(); // 触发重绘 + if (success) { + qDebug() << "下载完成:" << packageName; + } else { + qDebug() << "下载失败:" << packageName; + } } }); } @@ -83,33 +88,27 @@ void AppDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, c // QString("更新说明:%1\n包大小:%2").arg(description, size)); QString("包大小:%1 MB").arg(QString::number(size.toDouble() / (1024 * 1024), 'f', 2))); - if (m_isDownloading) { - // 进度条 + QString packageName = index.data(Qt::UserRole + 1).toString(); + bool isDownloading = m_downloads.contains(packageName) && m_downloads[packageName].isDownloading; + int progress = m_downloads.value(packageName, DownloadInfo{0, false}).progress; + if (isDownloading) { + // 进度条区域 QRect progressRect(rect.right() - 180, rect.top() + (rect.height() - 20) / 2, 100, 20); QStyleOptionProgressBar progressBarOption; progressBarOption.rect = progressRect; progressBarOption.minimum = 0; progressBarOption.maximum = 100; - progressBarOption.progress = m_progress; - progressBarOption.text = QString("%1%").arg(m_progress); + progressBarOption.progress = progress; + progressBarOption.text = QString("%1%").arg(progress); progressBarOption.textVisible = true; QApplication::style()->drawControl(QStyle::CE_ProgressBar, &progressBarOption, painter); - - // 取消按钮 - QRect cancelButtonRect(rect.right() - 70, rect.top() + (rect.height() - 20) / 2, 60, 20); - QStyleOptionButton cancelButtonOption; - cancelButtonOption.rect = cancelButtonRect; - cancelButtonOption.text = "取消"; - cancelButtonOption.state |= QStyle::State_Enabled; - QApplication::style()->drawControl(QStyle::CE_PushButton, &cancelButtonOption, painter); } else { - // 更新按钮 - QRect buttonRect(rect.right() - 80, rect.top() + (rect.height() - 30) / 2, 70, 30); - painter->setPen(Qt::NoPen); - painter->setBrush(QColor("#267AFF")); - painter->drawRoundedRect(buttonRect, 6, 6); - painter->setPen(Qt::white); - painter->drawText(buttonRect, Qt::AlignCenter, "更新"); + // 新增:绘制更新按钮 + QStyleOptionButton buttonOption; + buttonOption.rect = QRect(rect.right() - 80, rect.top() + (rect.height() - 30) / 2, 70, 30); + buttonOption.text = "更新"; + buttonOption.state = QStyle::State_Enabled; + QApplication::style()->drawControl(QStyle::CE_PushButton, &buttonOption, painter); } painter->restore(); @@ -125,46 +124,30 @@ bool AppDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, const QS if (event->type() == QEvent::MouseButtonRelease) { QMouseEvent *mouseEvent = static_cast(event); QRect rect = option.rect; - if (m_isDownloading) { + QString packageName = index.data(Qt::UserRole + 1).toString(); + + if (m_downloads.contains(packageName) && m_downloads[packageName].isDownloading) { // 取消按钮区域 QRect cancelButtonRect(rect.right() - 70, rect.top() + (rect.height() - 20) / 2, 60, 20); if (cancelButtonRect.contains(mouseEvent->pos())) { - m_isDownloading = false; - emit updateDisplay(); // 触发重绘 + m_downloadManager->cancelDownload(packageName); + m_downloads.remove(packageName); + emit updateDisplay(); return true; } } else { // 更新按钮区域 QRect buttonRect(rect.right() - 80, rect.top() + (rect.height() - 30) / 2, 70, 30); if (buttonRect.contains(mouseEvent->pos())) { - QString packageName = index.data(Qt::UserRole + 1).toString(); QString downloadUrl = index.data(Qt::UserRole + 7).toString(); QString outputPath = QString("%1/%2.metalink").arg(QDir::tempPath(), packageName); - m_isDownloading = true; - m_progress = 0; - - connect(m_downloadManager, &DownloadManager::downloadProgress, this, [this](int progress) { - m_progress = progress; - emit updateDisplay(); // 更新界面显示 - }); - - connect(m_downloadManager, &DownloadManager::downloadFinished, this, [this](bool success) { - m_isDownloading = false; - emit updateDisplay(); // 更新界面显示 - if (success) { - qDebug() << "下载完成"; - } else { - qDebug() << "下载失败"; - } - }); - - m_downloadManager->startDownload(downloadUrl, outputPath); - emit updateDisplay(); // 触发重绘 + m_downloads[packageName] = {0, true}; + m_downloadManager->startDownload(packageName, downloadUrl, outputPath); + emit updateDisplay(); return true; } } - qDebug() << "点击了第" << index.row() << "行"; } return QStyledItemDelegate::editorEvent(event, model, option, index); } \ No newline at end of file diff --git a/src/appdelegate.h b/src/appdelegate.h index 11c78bf..4afa130 100644 --- a/src/appdelegate.h +++ b/src/appdelegate.h @@ -23,9 +23,13 @@ signals: void updateDisplay(); // 声明更新显示的信号 private: - DownloadManager *m_downloadManager; // 声明下载管理器指针 - int m_progress = 0; // 声明下载进度 - bool m_isDownloading = false; // 声明下载状态 + struct DownloadInfo { + int progress = 0; + bool isDownloading = false; + }; + QHash m_downloads; // 使用包名作为键的下载状态 + DownloadManager *m_downloadManager; + }; #endif // APPDELEGATE_H diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp index 1603928..cef9fb5 100644 --- a/src/downloadmanager.cpp +++ b/src/downloadmanager.cpp @@ -6,46 +6,50 @@ DownloadManager::DownloadManager(QObject *parent) : QObject(parent) {} -void DownloadManager::startDownload(const QString &url, const QString &outputPath) +void DownloadManager::startDownload(const QString &packageName, const QString &url, const QString &outputPath) { - QString metalinkUrl = url + ".metalink"; // 构造 Metalink URL - qDebug() << "开始下载 Metalink 文件:" << metalinkUrl; - + QString metalinkUrl = url + ".metalink"; QStringList arguments; - arguments << "--enable-rpc=false" << "--console-log-level=warn" - << "--summary-interval=1" << "--dir=" + QFileInfo(outputPath).absolutePath() - << "--out=" + QFileInfo(outputPath).fileName() << metalinkUrl; + arguments << "--enable-rpc=false" + << "--console-log-level=warn" + << "--summary-interval=1" + << "--dir=" + QFileInfo(outputPath).absolutePath() + << "--out=" + QFileInfo(outputPath).fileName() + << metalinkUrl; - connect(&m_aria2Process, &QProcess::readyReadStandardOutput, this, &DownloadManager::onAria2Progress); - connect(&m_aria2Process, QOverload::of(&QProcess::finished), this, &DownloadManager::onAria2Finished); + QProcess* process = new QProcess(this); + m_processes.insert(packageName, process); - m_aria2Process.start("aria2c", arguments); -} - -void DownloadManager::onAria2Progress() -{ - QString output = m_aria2Process.readAllStandardOutput(); - QRegularExpression regex(R"(\((\d+)%\))"); - QRegularExpressionMatchIterator i = regex.globalMatch(output); - - while (i.hasNext()) { - QRegularExpressionMatch match = i.next(); - if (match.hasMatch()) { - int progress = match.captured(1).toInt(); - emit downloadProgress(progress); // 发送进度信号 - qDebug() << "下载进度:" << progress << "%"; + connect(process, &QProcess::readyReadStandardOutput, [this, process, packageName]() { + QString output = process->readAllStandardOutput(); + QRegularExpression regex(R"(\((\d+)%\))"); + QRegularExpressionMatchIterator i = regex.globalMatch(output); + while (i.hasNext()) { + QRegularExpressionMatch match = i.next(); + if (match.hasMatch()) { + int progress = match.captured(1).toInt(); + emit downloadProgress(packageName, progress); + qDebug() << "下载进度:" << progress << "%"; + } } - } + }); + + connect(process, QOverload::of(&QProcess::finished), + [this, packageName](int exitCode, QProcess::ExitStatus exitStatus) { + bool success = (exitCode == 0 && exitStatus == QProcess::NormalExit); + emit downloadFinished(packageName, success); + m_processes.remove(packageName); + }); + + process->start("aria2c", arguments); } - -void DownloadManager::onAria2Finished(int exitCode, QProcess::ExitStatus exitStatus) +void DownloadManager::cancelDownload(const QString &packageName) { - if (exitCode == 0 && exitStatus == QProcess::NormalExit) { - qDebug() << "下载完成"; - emit downloadFinished(true); // 发送完成信号 - } else { - qWarning() << "下载失败,退出代码:" << exitCode; - emit downloadFinished(false); // 发送失败信号 + if (m_processes.contains(packageName)) { + QProcess* process = m_processes[packageName]; + process->terminate(); + process->waitForFinished(); + m_processes.remove(packageName); } } diff --git a/src/downloadmanager.h b/src/downloadmanager.h index ca80330..362867d 100644 --- a/src/downloadmanager.h +++ b/src/downloadmanager.h @@ -11,18 +11,16 @@ class DownloadManager : public QObject Q_OBJECT public: explicit DownloadManager(QObject *parent = nullptr); - void startDownload(const QString &url, const QString &outputPath); + void startDownload(const QString &packageName, const QString &url, const QString &outputPath); // 修改参数列表 + void cancelDownload(const QString &packageName); // 移动到public区域 signals: - void downloadProgress(int progress); // 下载进度信号 - void downloadFinished(bool success); // 下载完成信号 - -private slots: - void onAria2Progress(); // 处理 aria2 的进度 - void onAria2Finished(int exitCode, QProcess::ExitStatus exitStatus); // 处理 aria2 完成事件 + void downloadProgress(const QString &packageName, int progress); + void downloadFinished(const QString &packageName, bool success); private: - QProcess m_aria2Process; // 用于运行 aria2 的进程 + QHash m_processes; // 移除旧的m_aria2Process + // 移除旧的onAria2Progress和onAria2Finished声明 }; #endif // DOWNLOADMANAGER_H From f7baf015c04d17e5ccbce6017a3072a67030cb8b Mon Sep 17 00:00:00 2001 From: momen Date: Thu, 12 Jun 2025 17:31:06 +0800 Subject: [PATCH 059/114] =?UTF-8?q?chore:=E6=9B=B4=E6=96=B0=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/downloadmanager.cpp | 36 ++++++++++++++++++------------------ src/downloadmanager.h | 11 +++++------ 2 files changed, 23 insertions(+), 24 deletions(-) diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp index cef9fb5..1b31533 100644 --- a/src/downloadmanager.cpp +++ b/src/downloadmanager.cpp @@ -1,8 +1,7 @@ #include "downloadmanager.h" -#include -#include +#include #include -#include // 添加 QFileInfo 头文件 +#include DownloadManager::DownloadManager(QObject *parent) : QObject(parent) {} @@ -10,22 +9,22 @@ void DownloadManager::startDownload(const QString &packageName, const QString &u { QString metalinkUrl = url + ".metalink"; QStringList arguments; - arguments << "--enable-rpc=false" + arguments << "--enable-rpc=false" << "--console-log-level=warn" - << "--summary-interval=1" + << "--summary-interval=1" << "--dir=" + QFileInfo(outputPath).absolutePath() - << "--out=" + QFileInfo(outputPath).fileName() + << "--out=" + QFileInfo(outputPath).fileName() << metalinkUrl; - QProcess* process = new QProcess(this); + QProcess *process = new QProcess(this); m_processes.insert(packageName, process); + // ✅ 改为按行读取(逐行处理) connect(process, &QProcess::readyReadStandardOutput, [this, process, packageName]() { - QString output = process->readAllStandardOutput(); - QRegularExpression regex(R"(\((\d+)%\))"); - QRegularExpressionMatchIterator i = regex.globalMatch(output); - while (i.hasNext()) { - QRegularExpressionMatch match = i.next(); + while (process->canReadLine()) { + QString line = process->readLine().trimmed(); + QRegularExpression regex(R"(\((\d+)%\))"); + QRegularExpressionMatch match = regex.match(line); if (match.hasMatch()) { int progress = match.captured(1).toInt(); emit downloadProgress(packageName, progress); @@ -34,12 +33,13 @@ void DownloadManager::startDownload(const QString &packageName, const QString &u } }); + // 下载完成 connect(process, QOverload::of(&QProcess::finished), - [this, packageName](int exitCode, QProcess::ExitStatus exitStatus) { - bool success = (exitCode == 0 && exitStatus == QProcess::NormalExit); - emit downloadFinished(packageName, success); - m_processes.remove(packageName); - }); + [this, packageName](int exitCode, QProcess::ExitStatus exitStatus) { + bool success = (exitCode == 0 && exitStatus == QProcess::NormalExit); + emit downloadFinished(packageName, success); + m_processes.remove(packageName); + }); process->start("aria2c", arguments); } @@ -47,7 +47,7 @@ void DownloadManager::startDownload(const QString &packageName, const QString &u void DownloadManager::cancelDownload(const QString &packageName) { if (m_processes.contains(packageName)) { - QProcess* process = m_processes[packageName]; + QProcess *process = m_processes[packageName]; process->terminate(); process->waitForFinished(); m_processes.remove(packageName); diff --git a/src/downloadmanager.h b/src/downloadmanager.h index 362867d..f47cab3 100644 --- a/src/downloadmanager.h +++ b/src/downloadmanager.h @@ -2,25 +2,24 @@ #define DOWNLOADMANAGER_H #include -#include -#include #include +#include class DownloadManager : public QObject { Q_OBJECT + public: explicit DownloadManager(QObject *parent = nullptr); - void startDownload(const QString &packageName, const QString &url, const QString &outputPath); // 修改参数列表 - void cancelDownload(const QString &packageName); // 移动到public区域 + void startDownload(const QString &packageName, const QString &url, const QString &outputPath); + void cancelDownload(const QString &packageName); signals: void downloadProgress(const QString &packageName, int progress); void downloadFinished(const QString &packageName, bool success); private: - QHash m_processes; // 移除旧的m_aria2Process - // 移除旧的onAria2Progress和onAria2Finished声明 + QMap m_processes; }; #endif // DOWNLOADMANAGER_H From 50c916a8cc3d85c1eb52a6dbb0dd58988866bb3c Mon Sep 17 00:00:00 2001 From: momen Date: Thu, 12 Jun 2025 22:44:20 +0800 Subject: [PATCH 060/114] =?UTF-8?q?update:=E6=98=BE=E7=A4=BA=E8=BF=9B?= =?UTF-8?q?=E5=BA=A6=E6=9D=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/appdelegate.cpp | 104 ++++++++++++++++++++------------------------ src/appdelegate.h | 36 +++++++-------- src/mainwindow.cpp | 10 ++++- 3 files changed, 71 insertions(+), 79 deletions(-) diff --git a/src/appdelegate.cpp b/src/appdelegate.cpp index 095b571..ccb3eec 100644 --- a/src/appdelegate.cpp +++ b/src/appdelegate.cpp @@ -1,98 +1,89 @@ #include "appdelegate.h" #include #include -#include "downloadmanager.h" +#include +#include #include #include -#include // 包含 QApplication 头文件 -#include // 添加 QDir 头文件 +#include +#include -AppDelegate::AppDelegate(QObject *parent) : QStyledItemDelegate(parent), m_downloadManager(new DownloadManager(this)) -{ - connect(m_downloadManager, &DownloadManager::downloadProgress, this, [this](const QString &packageName, int progress) { - if (m_downloads.contains(packageName)) { - m_downloads[packageName].progress = progress; - emit updateDisplay(); // 触发重绘 - } - }); - - connect(m_downloadManager, &DownloadManager::downloadFinished, this, [this](const QString &packageName, bool success) { +AppDelegate::AppDelegate(QObject *parent) + : QStyledItemDelegate(parent), m_downloadManager(new DownloadManager(this)) { + + connect(m_downloadManager, &DownloadManager::downloadFinished, this, + [this](const QString &packageName, bool success) { if (m_downloads.contains(packageName)) { m_downloads[packageName].isDownloading = false; - emit updateDisplay(); // 触发重绘 - if (success) { - qDebug() << "下载完成:" << packageName; - } else { - qDebug() << "下载失败:" << packageName; - } + emit updateDisplay(packageName); + qDebug() << (success ? "下载完成:" : "下载失败:") << packageName; + } + }); + + connect(m_downloadManager, &DownloadManager::downloadProgress, this, + [this](const QString &packageName, int progress) { + if (m_downloads.contains(packageName)) { + m_downloads[packageName].progress = progress; + qDebug()<save(); - // 绘制背景 - if (option.state & QStyle::State_Selected) { + if (option.state & QStyle::State_Selected) painter->fillRect(option.rect, option.palette.highlight()); - } else { - painter->fillRect(option.rect, QColor("#F3F4F6")); - } + else + painter->fillRect(option.rect, QColor("#F3F4F6")); - // 设置字体 QFont boldFont = option.font; boldFont.setBold(true); - QFont normalFont = option.font; - // 数据 QString name = index.data(Qt::DisplayRole).toString(); QString currentVersion = index.data(Qt::UserRole + 2).toString(); QString newVersion = index.data(Qt::UserRole + 3).toString(); QString iconPath = index.data(Qt::UserRole + 4).toString(); QString size = index.data(Qt::UserRole + 5).toString(); - QString description = index.data(Qt::UserRole + 6).toString(); // 假设额外说明文本 + QString description = index.data(Qt::UserRole + 6).toString(); - // 区域定义 QRect rect = option.rect; - int margin = 10; - int spacing = 6; - int iconSize = 40; + int margin = 10, spacing = 6, iconSize = 40; - // 图标 QRect iconRect(rect.left() + margin, rect.top() + (rect.height() - iconSize) / 2, iconSize, iconSize); QIcon(iconPath).paint(painter, iconRect); - // 文本起点 int textX = iconRect.right() + margin; - int textWidth = rect.width() - textX - 100; // 留出按钮区域 + int textWidth = rect.width() - textX - 100; - // 绘制应用名称 QRect nameRect(textX, rect.top() + margin, textWidth, 20); painter->setFont(boldFont); - painter->setPen(QColor("#333333")); // 改为深色,确保清晰 - painter->drawText(nameRect, Qt::AlignLeft | Qt::AlignVCenter, name); // 绘制应用名称 + painter->setPen(QColor("#333333")); + painter->drawText(nameRect, Qt::AlignLeft | Qt::AlignVCenter, name); - // 绘制版本信息 QRect versionRect(textX, nameRect.bottom() + spacing, textWidth, 20); painter->setFont(normalFont); - painter->setPen(QColor("#888888")); // 使用浅灰色,保持对比 + painter->setPen(QColor("#888888")); painter->drawText(versionRect, Qt::AlignLeft | Qt::AlignVCenter, QString("当前版本: %1 → 新版本: %2").arg(currentVersion, newVersion)); - // 描述行 QRect descRect(textX, versionRect.bottom() + spacing, textWidth, 40); painter->setFont(normalFont); painter->setPen(QColor("#AAAAAA")); painter->drawText(descRect, Qt::TextWordWrap, - // QString("更新说明:%1\n包大小:%2").arg(description, size)); - QString("包大小:%1 MB").arg(QString::number(size.toDouble() / (1024 * 1024), 'f', 2))); + QString("包大小:%1 MB").arg(QString::number(size.toDouble() / (1024 * 1024), 'f', 2))); QString packageName = index.data(Qt::UserRole + 1).toString(); bool isDownloading = m_downloads.contains(packageName) && m_downloads[packageName].isDownloading; int progress = m_downloads.value(packageName, DownloadInfo{0, false}).progress; + if (isDownloading) { - // 进度条区域 QRect progressRect(rect.right() - 180, rect.top() + (rect.height() - 20) / 2, 100, 20); QStyleOptionProgressBar progressBarOption; progressBarOption.rect = progressRect; @@ -103,7 +94,6 @@ void AppDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, c progressBarOption.textVisible = true; QApplication::style()->drawControl(QStyle::CE_ProgressBar, &progressBarOption, painter); } else { - // 新增:绘制更新按钮 QStyleOptionButton buttonOption; buttonOption.rect = QRect(rect.right() - 80, rect.top() + (rect.height() - 30) / 2, 70, 30); buttonOption.text = "更新"; @@ -114,29 +104,26 @@ void AppDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, c painter->restore(); } -QSize AppDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const -{ - return QSize(option.rect.width(), 110); // 每行高度 110 +QSize AppDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const { + return QSize(option.rect.width(), 110); } -bool AppDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index) -{ +bool AppDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, + const QStyleOptionViewItem &option, const QModelIndex &index) { if (event->type() == QEvent::MouseButtonRelease) { - QMouseEvent *mouseEvent = static_cast(event); + QMouseEvent *mouseEvent = static_cast(event); QRect rect = option.rect; QString packageName = index.data(Qt::UserRole + 1).toString(); if (m_downloads.contains(packageName) && m_downloads[packageName].isDownloading) { - // 取消按钮区域 QRect cancelButtonRect(rect.right() - 70, rect.top() + (rect.height() - 20) / 2, 60, 20); if (cancelButtonRect.contains(mouseEvent->pos())) { m_downloadManager->cancelDownload(packageName); m_downloads.remove(packageName); - emit updateDisplay(); + emit updateDisplay(packageName); return true; } } else { - // 更新按钮区域 QRect buttonRect(rect.right() - 80, rect.top() + (rect.height() - 30) / 2, 70, 30); if (buttonRect.contains(mouseEvent->pos())) { QString downloadUrl = index.data(Qt::UserRole + 7).toString(); @@ -144,10 +131,11 @@ bool AppDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, const QS m_downloads[packageName] = {0, true}; m_downloadManager->startDownload(packageName, downloadUrl, outputPath); - emit updateDisplay(); + emit updateDisplay(packageName); return true; } } } + return QStyledItemDelegate::editorEvent(event, model, option, index); -} \ No newline at end of file +} diff --git a/src/appdelegate.h b/src/appdelegate.h index 4afa130..37f7a77 100644 --- a/src/appdelegate.h +++ b/src/appdelegate.h @@ -1,35 +1,31 @@ -#ifndef APPDELEGATE_H -#define APPDELEGATE_H +#pragma once #include -#include -#include -#include -// 前向声明 DownloadManager 类 -class DownloadManager; +#include +#include "downloadmanager.h" -class AppDelegate : public QStyledItemDelegate -{ +struct DownloadInfo { + int progress = 0; + bool isDownloading = false; +}; + +class AppDelegate : public QStyledItemDelegate { Q_OBJECT public: explicit AppDelegate(QObject *parent = nullptr); - // 重写方法 + void setModel(QAbstractItemModel *model); + void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override; QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override; - bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index) override; + bool editorEvent(QEvent *event, QAbstractItemModel *model, + const QStyleOptionViewItem &option, const QModelIndex &index) override; signals: - void updateDisplay(); // 声明更新显示的信号 + void updateDisplay(const QString &packageName); private: - struct DownloadInfo { - int progress = 0; - bool isDownloading = false; - }; - QHash m_downloads; // 使用包名作为键的下载状态 DownloadManager *m_downloadManager; - + QHash m_downloads; + QAbstractItemModel *m_model = nullptr; }; - -#endif // APPDELEGATE_H diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 3aa8cee..9b20071 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -18,7 +18,15 @@ MainWindow::MainWindow(QWidget *parent) QVBoxLayout *layout = new QVBoxLayout(ui->appWidget); layout->addWidget(listView); layout->setContentsMargins(0, 0, 0, 0); - + connect(m_delegate, &AppDelegate::updateDisplay, this, [=](const QString &packageName) { + for (int i = 0; i < m_model->rowCount(); ++i) { + QModelIndex index = m_model->index(i); + if (index.data(Qt::UserRole + 1).toString() == packageName) { + m_model->dataChanged(index, index); // 刷新该行 + break; + } + } + }); checkUpdates(); initStyle(); } From 73a3733bc1923e48d80e05f271da9024bb05370a Mon Sep 17 00:00:00 2001 From: momen Date: Fri, 13 Jun 2025 09:04:25 +0800 Subject: [PATCH 061/114] =?UTF-8?q?update:=E8=BF=90=E8=A1=8C=E5=A4=9A?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=90=8C=E6=97=B6=E4=B8=8B=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/downloadmanager.cpp | 85 +++++++++++++++++++++++++++++++---------- src/downloadmanager.h | 7 +++- 2 files changed, 69 insertions(+), 23 deletions(-) diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp index 1b31533..271b7bf 100644 --- a/src/downloadmanager.cpp +++ b/src/downloadmanager.cpp @@ -1,44 +1,62 @@ #include "downloadmanager.h" #include +#include +#include #include #include -DownloadManager::DownloadManager(QObject *parent) : QObject(parent) {} +DownloadManager::DownloadManager(QObject *parent) : QObject(parent) +{ + cleanupTempFiles(); +} void DownloadManager::startDownload(const QString &packageName, const QString &url, const QString &outputPath) { + if (m_processes.contains(packageName)) { + qWarning() << packageName << " is already downloading."; + return; + } + QString metalinkUrl = url + ".metalink"; - QStringList arguments; - arguments << "--enable-rpc=false" - << "--console-log-level=warn" - << "--summary-interval=1" - << "--dir=" + QFileInfo(outputPath).absolutePath() - << "--out=" + QFileInfo(outputPath).fileName() - << metalinkUrl; + QFileInfo fileInfo(outputPath); + + QStringList arguments = { + "--enable-rpc=false", + "--console-log-level=warn", + "--summary-interval=1", + "--allow-overwrite=true", + "--dir=" + fileInfo.absolutePath(), + "--out=" + fileInfo.fileName(), + metalinkUrl + }; QProcess *process = new QProcess(this); m_processes.insert(packageName, process); - // ✅ 改为按行读取(逐行处理) - connect(process, &QProcess::readyReadStandardOutput, [this, process, packageName]() { + connect(process, &QProcess::readyReadStandardOutput, this, [this, packageName, process]() { while (process->canReadLine()) { - QString line = process->readLine().trimmed(); + QString line = QString::fromUtf8(process->readLine()).trimmed(); QRegularExpression regex(R"(\((\d+)%\))"); QRegularExpressionMatch match = regex.match(line); if (match.hasMatch()) { int progress = match.captured(1).toInt(); emit downloadProgress(packageName, progress); - qDebug() << "下载进度:" << progress << "%"; } } }); - // 下载完成 connect(process, QOverload::of(&QProcess::finished), - [this, packageName](int exitCode, QProcess::ExitStatus exitStatus) { - bool success = (exitCode == 0 && exitStatus == QProcess::NormalExit); + this, [this, packageName, outputPath](int exitCode, QProcess::ExitStatus status) { + bool success = (exitCode == 0 && status == QProcess::NormalExit); + if (!success) { + qWarning() << "Download failed for" << packageName << "exit code:" << exitCode; + } + + removeAria2Files(outputPath); // 清理残留 .aria2 emit downloadFinished(packageName, success); - m_processes.remove(packageName); + + QProcess *proc = m_processes.take(packageName); + if (proc) proc->deleteLater(); }); process->start("aria2c", arguments); @@ -46,10 +64,35 @@ void DownloadManager::startDownload(const QString &packageName, const QString &u void DownloadManager::cancelDownload(const QString &packageName) { - if (m_processes.contains(packageName)) { - QProcess *process = m_processes[packageName]; - process->terminate(); - process->waitForFinished(); - m_processes.remove(packageName); + if (!m_processes.contains(packageName)) return; + + QProcess *process = m_processes.take(packageName); + if (process) { + process->kill(); // 立即终止 + process->waitForFinished(3000); // 最多等待3秒 + process->deleteLater(); + } + + emit downloadFinished(packageName, false); // 显式通知取消 + +} + +void DownloadManager::removeAria2Files(const QString &filePath) +{ + QString ariaFile = filePath + ".aria2"; + QFile::remove(ariaFile); +} + +bool DownloadManager::isDownloading(const QString &packageName) const +{ + return m_processes.contains(packageName); +} + +void DownloadManager::cleanupTempFiles() +{ + QDir tempDir(QDir::tempPath()); + QStringList leftovers = tempDir.entryList(QStringList() << "*.aria2", QDir::Files); + for (const QString &f : leftovers) { + tempDir.remove(f); } } diff --git a/src/downloadmanager.h b/src/downloadmanager.h index f47cab3..0614368 100644 --- a/src/downloadmanager.h +++ b/src/downloadmanager.h @@ -2,23 +2,26 @@ #define DOWNLOADMANAGER_H #include -#include #include +#include class DownloadManager : public QObject { Q_OBJECT - public: explicit DownloadManager(QObject *parent = nullptr); void startDownload(const QString &packageName, const QString &url, const QString &outputPath); void cancelDownload(const QString &packageName); + bool isDownloading(const QString &packageName) const; signals: void downloadProgress(const QString &packageName, int progress); void downloadFinished(const QString &packageName, bool success); private: + void cleanupTempFiles(); + void removeAria2Files(const QString &filePath); + QMap m_processes; }; From 7da6689e6d70006d8852a51d38c1719ac96a1be8 Mon Sep 17 00:00:00 2001 From: momen Date: Fri, 13 Jun 2025 09:07:25 +0800 Subject: [PATCH 062/114] =?UTF-8?q?chore:=E5=A2=9E=E5=8A=A0=E5=8F=96?= =?UTF-8?q?=E6=B6=88=E6=8C=89=E9=92=AE=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/appdelegate.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/appdelegate.cpp b/src/appdelegate.cpp index ccb3eec..dc78577 100644 --- a/src/appdelegate.cpp +++ b/src/appdelegate.cpp @@ -93,6 +93,13 @@ void AppDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, c progressBarOption.text = QString("%1%").arg(progress); progressBarOption.textVisible = true; QApplication::style()->drawControl(QStyle::CE_ProgressBar, &progressBarOption, painter); + QStyleOptionButton cancelOption; + cancelOption.rect = QRect(progressRect.right() + 10, rect.top() + (rect.height() - 30) / 2, 70, 30); + cancelOption.text = "取消"; + cancelOption.palette.setColor(QPalette::Button, QColor("#ff4444")); + cancelOption.palette.setColor(QPalette::ButtonText, Qt::white); + cancelOption.state = QStyle::State_Enabled; + QApplication::style()->drawControl(QStyle::CE_PushButton, &cancelOption, painter); } else { QStyleOptionButton buttonOption; buttonOption.rect = QRect(rect.right() - 80, rect.top() + (rect.height() - 30) / 2, 70, 30); From b6de24e0988f325b5c37b0d8becb0d61331cac06 Mon Sep 17 00:00:00 2001 From: momen Date: Sat, 14 Jun 2025 22:34:23 +0800 Subject: [PATCH 063/114] =?UTF-8?q?chore:=E6=9B=B4=E6=96=B0=E2=80=98?= =?UTF-8?q?=E2=80=98=E6=9B=B4=E6=96=B0=E2=80=99=E2=80=99=E6=8C=89=E9=92=AE?= =?UTF-8?q?=E9=A2=9C=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/appdelegate.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/appdelegate.cpp b/src/appdelegate.cpp index dc78577..f68492f 100644 --- a/src/appdelegate.cpp +++ b/src/appdelegate.cpp @@ -105,6 +105,10 @@ void AppDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, c buttonOption.rect = QRect(rect.right() - 80, rect.top() + (rect.height() - 30) / 2, 70, 30); buttonOption.text = "更新"; buttonOption.state = QStyle::State_Enabled; + QPalette palette = buttonOption.palette; + palette.setColor(QPalette::Button, QColor("#e9effd")); // 背景色 + palette.setColor(QPalette::ButtonText, QColor("#2563EB")); // 文字颜色 + buttonOption.palette = palette; QApplication::style()->drawControl(QStyle::CE_PushButton, &buttonOption, painter); } From 703713a706f7c2cab377e77942adb514aa847863 Mon Sep 17 00:00:00 2001 From: MeowVing Date: Sun, 15 Jun 2025 07:40:34 +0000 Subject: [PATCH 064/114] rename READE.md to README.md. update README.md. Signed-off-by: MeowVing --- READE.md | 20 -------------------- README.md | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+), 20 deletions(-) delete mode 100644 READE.md create mode 100644 README.md diff --git a/READE.md b/READE.md deleted file mode 100644 index 3259e2d..0000000 --- a/READE.md +++ /dev/null @@ -1,20 +0,0 @@ -### 星火软件更新器 -#### 简介 - -欢迎使用星火软件更新器,你可以用这个更新器更新位于你电脑的程序。 - -#### 当前支持的Linux发行版 -- [x] GXDE -- [x] Ubuntu -- [ ] deepin -- [ ] Kylin - -#### 功能清单 -|功能模块|描述| -|--|--| -| 应用名识别|采用ss-do-upgrade.sh部分代码| -|应用包大小识别|dkpg完成| -|获取应用icon|使用QDesktopServices完成| -|支持ACE| | - -#### 联系与反馈 diff --git a/README.md b/README.md new file mode 100644 index 0000000..fc8a11e --- /dev/null +++ b/README.md @@ -0,0 +1,20 @@ +### 星火软件更新器 +#### 简介 + +欢迎使用星火软件更新器,您可以使用此更新器更新位于您 Linux 计算机的程序。 + +#### 当前支持的 Linux 发行版 +- [x] GXDE OS +- [x] Ubuntu +- [ ] deepin +- [ ] Kylin + +#### 功能清单 +|功能模块|描述| +|--|--| +|应用名识别|采用 `ss-do-upgrade.sh` 部分代码| +|应用包大小识别|使用 dkpg 完成| +|获取应用 Icon|使用 QDesktopServices 完成| +|支持 ACE 兼容环境| | + +#### 联系与反馈 From e539fb59127c9e97fb7c5c6c2e9532b5ee936dd8 Mon Sep 17 00:00:00 2001 From: momen Date: Sun, 15 Jun 2025 16:44:28 +0800 Subject: [PATCH 065/114] =?UTF-8?q?chore:=E5=BC=BA=E5=88=B6=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E8=87=AA=E5=AE=9A=E4=B9=89=E6=8C=89=E9=92=AE=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/appdelegate.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/appdelegate.cpp b/src/appdelegate.cpp index f68492f..c6d6235 100644 --- a/src/appdelegate.cpp +++ b/src/appdelegate.cpp @@ -101,15 +101,15 @@ void AppDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, c cancelOption.state = QStyle::State_Enabled; QApplication::style()->drawControl(QStyle::CE_PushButton, &cancelOption, painter); } else { - QStyleOptionButton buttonOption; - buttonOption.rect = QRect(rect.right() - 80, rect.top() + (rect.height() - 30) / 2, 70, 30); - buttonOption.text = "更新"; - buttonOption.state = QStyle::State_Enabled; - QPalette palette = buttonOption.palette; - palette.setColor(QPalette::Button, QColor("#e9effd")); // 背景色 - palette.setColor(QPalette::ButtonText, QColor("#2563EB")); // 文字颜色 - buttonOption.palette = palette; - QApplication::style()->drawControl(QStyle::CE_PushButton, &buttonOption, painter); + // 修改后的更新按钮绘制代码 + QRect buttonRect(rect.right() - 80, rect.top() + (rect.height() - 30) / 2, 70, 30); + painter->setPen(Qt::NoPen); + painter->setBrush(QColor("#e9effd")); // 背景色 + painter->drawRoundedRect(buttonRect, 4, 4); // 圆角矩形 + + painter->setPen(QColor("#2563EB")); // 文字颜色 + painter->setFont(option.font); + painter->drawText(buttonRect, Qt::AlignCenter, "更新"); } painter->restore(); From 525a90f441b6f477aae9d088637fd62db89352e6 Mon Sep 17 00:00:00 2001 From: momen Date: Sun, 15 Jun 2025 16:47:23 +0800 Subject: [PATCH 066/114] =?UTF-8?q?chore:=E6=9B=B4=E6=96=B0=E5=8F=96?= =?UTF-8?q?=E6=B6=88=E6=8C=89=E9=92=AE=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/appdelegate.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/appdelegate.cpp b/src/appdelegate.cpp index c6d6235..df89b8c 100644 --- a/src/appdelegate.cpp +++ b/src/appdelegate.cpp @@ -93,15 +93,17 @@ void AppDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, c progressBarOption.text = QString("%1%").arg(progress); progressBarOption.textVisible = true; QApplication::style()->drawControl(QStyle::CE_ProgressBar, &progressBarOption, painter); - QStyleOptionButton cancelOption; - cancelOption.rect = QRect(progressRect.right() + 10, rect.top() + (rect.height() - 30) / 2, 70, 30); - cancelOption.text = "取消"; - cancelOption.palette.setColor(QPalette::Button, QColor("#ff4444")); - cancelOption.palette.setColor(QPalette::ButtonText, Qt::white); - cancelOption.state = QStyle::State_Enabled; - QApplication::style()->drawControl(QStyle::CE_PushButton, &cancelOption, painter); + + // 修改后的取消按钮绘制代码 + QRect buttonRect(rect.right() - 80, rect.top() + (rect.height() - 30) / 2, 70, 30); + painter->setPen(Qt::NoPen); + painter->setBrush(QColor("#ff4444")); // 红色背景 + painter->drawRoundedRect(buttonRect, 4, 4); // 圆角矩形 + + painter->setPen(Qt::white); // 白色文字 + painter->setFont(option.font); + painter->drawText(buttonRect, Qt::AlignCenter, "取消"); } else { - // 修改后的更新按钮绘制代码 QRect buttonRect(rect.right() - 80, rect.top() + (rect.height() - 30) / 2, 70, 30); painter->setPen(Qt::NoPen); painter->setBrush(QColor("#e9effd")); // 背景色 From 5211bbb95139c8b00726a3bb4e55eacb01d7a468 Mon Sep 17 00:00:00 2001 From: momen Date: Sun, 15 Jun 2025 16:54:21 +0800 Subject: [PATCH 067/114] =?UTF-8?q?chore:=E6=9B=B4=E6=96=B0=E8=BF=9B?= =?UTF-8?q?=E5=BA=A6=E6=9D=A1=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/appdelegate.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/appdelegate.cpp b/src/appdelegate.cpp index df89b8c..913610d 100644 --- a/src/appdelegate.cpp +++ b/src/appdelegate.cpp @@ -84,7 +84,7 @@ void AppDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, c int progress = m_downloads.value(packageName, DownloadInfo{0, false}).progress; if (isDownloading) { - QRect progressRect(rect.right() - 180, rect.top() + (rect.height() - 20) / 2, 100, 20); + QRect progressRect(rect.right() - 270, rect.top() + (rect.height() - 20) / 2, 150, 20); QStyleOptionProgressBar progressBarOption; progressBarOption.rect = progressRect; progressBarOption.minimum = 0; From 567a24a6ecb5e16ce34858d968b5c5c2b333322e Mon Sep 17 00:00:00 2001 From: momen Date: Mon, 16 Jun 2025 20:39:33 +0800 Subject: [PATCH 068/114] =?UTF-8?q?chore:=E4=B8=8B=E8=BD=BD=E5=AE=8C?= =?UTF-8?q?=E6=88=90=E5=90=8E=E6=94=B9=E4=B8=BA=E2=80=9C=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=E5=AE=8C=E6=88=90=E2=80=9D=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/appdelegate.cpp | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/appdelegate.cpp b/src/appdelegate.cpp index 913610d..57987f9 100644 --- a/src/appdelegate.cpp +++ b/src/appdelegate.cpp @@ -104,14 +104,25 @@ void AppDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, c painter->setFont(option.font); painter->drawText(buttonRect, Qt::AlignCenter, "取消"); } else { + QString packageName = index.data(Qt::UserRole + 1).toString(); + bool isDownloaded = m_downloads.contains(packageName) && !m_downloads[packageName].isDownloading; + QRect buttonRect(rect.right() - 80, rect.top() + (rect.height() - 30) / 2, 70, 30); painter->setPen(Qt::NoPen); - painter->setBrush(QColor("#e9effd")); // 背景色 - painter->drawRoundedRect(buttonRect, 4, 4); // 圆角矩形 - painter->setPen(QColor("#2563EB")); // 文字颜色 - painter->setFont(option.font); - painter->drawText(buttonRect, Qt::AlignCenter, "更新"); + if (isDownloaded) { + // 下载完成状态 + painter->setBrush(QColor("#10B981")); // 绿色背景 + painter->drawRoundedRect(buttonRect, 4, 4); + painter->setPen(Qt::white); + painter->drawText(buttonRect, Qt::AlignCenter, "下载完成"); + } else { + // 更新按钮状态 + painter->setBrush(QColor("#e9effd")); // 背景色 + painter->drawRoundedRect(buttonRect, 4, 4); + painter->setPen(QColor("#2563EB")); // 文字颜色 + painter->drawText(buttonRect, Qt::AlignCenter, "更新"); + } } painter->restore(); From 03c53c397760a9850d2f9e2f469aa5a592e7e8c8 Mon Sep 17 00:00:00 2001 From: momen Date: Mon, 16 Jun 2025 21:16:13 +0800 Subject: [PATCH 069/114] =?UTF-8?q?chore:=E6=8F=90=E6=9D=83=E8=BF=90?= =?UTF-8?q?=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.cpp | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index fd3e533..4f4956f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,10 +1,43 @@ #include "mainwindow.h" - #include +#include +#include +#include // for geteuid +#include // for getenv + +bool isRoot() { + return geteuid() == 0; +} + +bool elevateToRoot() { + QString program = QCoreApplication::applicationFilePath(); + + // 获取当前 DISPLAY 和 XAUTHORITY 环境变量 + QByteArray display = qgetenv("DISPLAY"); + QByteArray xauthority = qgetenv("XAUTHORITY"); + + // 构造带环境变量的 pkexec 命令 + QStringList args; + args << "env" + << "DISPLAY=" + display + << "XAUTHORITY=" + xauthority + << program; + + // 使用 pkexec 启动程序(带环境变量) + return QProcess::startDetached("pkexec", args); +} int main(int argc, char *argv[]) { QApplication a(argc, argv); + + if (!isRoot()) { + if (!elevateToRoot()) { + QMessageBox::critical(nullptr, "权限不足", "提权失败,请确保系统支持 pkexec 并已正确安装 polkit。"); + } + return 0; + } + MainWindow w; w.show(); return a.exec(); From 8177556e5d5a6a0c20952530ff4aa728335aa17b Mon Sep 17 00:00:00 2001 From: momen Date: Mon, 16 Jun 2025 22:39:34 +0800 Subject: [PATCH 070/114] =?UTF-8?q?chore:=E5=AE=8C=E6=88=90=E2=80=9C?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=85=A8=E9=83=A8=E2=80=9D=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=E6=8C=89=E9=92=AE=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/appdelegate.cpp | 15 +++++++++++++++ src/appdelegate.h | 1 + src/mainwindow.cpp | 10 ++++++++++ 3 files changed, 26 insertions(+) diff --git a/src/appdelegate.cpp b/src/appdelegate.cpp index 57987f9..506506b 100644 --- a/src/appdelegate.cpp +++ b/src/appdelegate.cpp @@ -163,3 +163,18 @@ bool AppDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, return QStyledItemDelegate::editorEvent(event, model, option, index); } + +void AppDelegate::startDownloadForAll() { + if (!m_model) return; + for (int row = 0; row < m_model->rowCount(); ++row) { + QModelIndex index = m_model->index(row, 0); + QString packageName = index.data(Qt::UserRole + 1).toString(); + if (m_downloads.contains(packageName) && m_downloads[packageName].isDownloading) + continue; // 跳过正在下载的 + QString downloadUrl = index.data(Qt::UserRole + 7).toString(); + QString outputPath = QString("%1/%2.metalink").arg(QDir::tempPath(), packageName); + m_downloads[packageName] = {0, true}; + m_downloadManager->startDownload(packageName, downloadUrl, outputPath); + emit updateDisplay(packageName); + } +} diff --git a/src/appdelegate.h b/src/appdelegate.h index 37f7a77..9e4ac3a 100644 --- a/src/appdelegate.h +++ b/src/appdelegate.h @@ -20,6 +20,7 @@ public: QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override; bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index) override; + void startDownloadForAll(); // 新增:批量下载所有应用 signals: void updateDisplay(const QString &packageName); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 9b20071..f961afc 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -14,6 +14,9 @@ MainWindow::MainWindow(QWidget *parent) listView->setModel(m_model); listView->setItemDelegate(m_delegate); + // 新增:确保 delegate 拥有 model 指针 + m_delegate->setModel(m_model); + // 设置 QListView 填充 ui->appWidget QVBoxLayout *layout = new QVBoxLayout(ui->appWidget); layout->addWidget(listView); @@ -27,6 +30,13 @@ MainWindow::MainWindow(QWidget *parent) } } }); + + // 新增:点击“更新全部”按钮批量下载 + connect(ui->updatePushButton, &QPushButton::clicked, this, [=](){ + qDebug()<<"更新全部按钮被点击"; + m_delegate->startDownloadForAll(); + }); + checkUpdates(); initStyle(); } From a9d9f035defae785921b43d7c6eed6dbfe6e49b4 Mon Sep 17 00:00:00 2001 From: momen Date: Tue, 17 Jun 2025 22:21:53 +0800 Subject: [PATCH 071/114] =?UTF-8?q?chore:=E5=AE=8C=E6=88=90ssinstall?= =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/appdelegate.cpp | 127 ++++++++++++++++++++++++++++++++++++++------ src/appdelegate.h | 16 +++++- 2 files changed, 126 insertions(+), 17 deletions(-) diff --git a/src/appdelegate.cpp b/src/appdelegate.cpp index 506506b..e873d53 100644 --- a/src/appdelegate.cpp +++ b/src/appdelegate.cpp @@ -9,14 +9,16 @@ #include AppDelegate::AppDelegate(QObject *parent) - : QStyledItemDelegate(parent), m_downloadManager(new DownloadManager(this)) { - + : QStyledItemDelegate(parent), m_downloadManager(new DownloadManager(this)), m_installProcess(nullptr) { connect(m_downloadManager, &DownloadManager::downloadFinished, this, [this](const QString &packageName, bool success) { if (m_downloads.contains(packageName)) { m_downloads[packageName].isDownloading = false; emit updateDisplay(packageName); qDebug() << (success ? "下载完成:" : "下载失败:") << packageName; + if (success) { + enqueueInstall(packageName); + } } }); @@ -28,6 +30,7 @@ AppDelegate::AppDelegate(QObject *parent) emit updateDisplay(packageName); // 实时刷新进度条 } }); + m_spinnerTimer.start(); } void AppDelegate::setModel(QAbstractItemModel *model) { @@ -82,6 +85,8 @@ void AppDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, c QString packageName = index.data(Qt::UserRole + 1).toString(); bool isDownloading = m_downloads.contains(packageName) && m_downloads[packageName].isDownloading; int progress = m_downloads.value(packageName, DownloadInfo{0, false}).progress; + bool isInstalled = m_downloads.value(packageName).isInstalled; + bool isInstalling = m_downloads.value(packageName).isInstalling; if (isDownloading) { QRect progressRect(rect.right() - 270, rect.top() + (rect.height() - 20) / 2, 150, 20); @@ -103,24 +108,37 @@ void AppDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, c painter->setPen(Qt::white); // 白色文字 painter->setFont(option.font); painter->drawText(buttonRect, Qt::AlignCenter, "取消"); + } else if (isInstalling) { + // 安装中:显示转圈和文字 + QRect spinnerRect(option.rect.right() - 80, option.rect.top() + (option.rect.height() - 30) / 2, 30, 30); + int angle = (m_spinnerTimer.elapsed() / 10) % 360; + QPen pen(QColor("#2563EB"), 3); + painter->setPen(pen); + painter->setRenderHint(QPainter::Antialiasing, true); + QRectF arcRect = spinnerRect.adjusted(3, 3, -3, -3); + painter->drawArc(arcRect, angle * 16, 120 * 16); // 120度弧 + + QRect textRect(option.rect.right() - 120, option.rect.top() + (option.rect.height() - 30) / 2, 110, 30); + painter->setPen(QColor("#2563EB")); + painter->setFont(option.font); + painter->drawText(textRect, Qt::AlignLeft | Qt::AlignVCenter, "正在安装中"); } else { - QString packageName = index.data(Qt::UserRole + 1).toString(); - bool isDownloaded = m_downloads.contains(packageName) && !m_downloads[packageName].isDownloading; - - QRect buttonRect(rect.right() - 80, rect.top() + (rect.height() - 30) / 2, 70, 30); + QRect buttonRect(option.rect.right() - 80, option.rect.top() + (option.rect.height() - 30) / 2, 70, 30); painter->setPen(Qt::NoPen); - - if (isDownloaded) { - // 下载完成状态 - painter->setBrush(QColor("#10B981")); // 绿色背景 + if (isInstalled) { + painter->setBrush(QColor("#10B981")); + painter->drawRoundedRect(buttonRect, 4, 4); + painter->setPen(Qt::white); + painter->drawText(buttonRect, Qt::AlignCenter, "已安装"); + } else if (m_downloads.contains(packageName) && !m_downloads[packageName].isDownloading) { + painter->setBrush(QColor("#10B981")); painter->drawRoundedRect(buttonRect, 4, 4); painter->setPen(Qt::white); painter->drawText(buttonRect, Qt::AlignCenter, "下载完成"); } else { - // 更新按钮状态 - painter->setBrush(QColor("#e9effd")); // 背景色 + painter->setBrush(QColor("#e9effd")); painter->drawRoundedRect(buttonRect, 4, 4); - painter->setPen(QColor("#2563EB")); // 文字颜色 + painter->setPen(QColor("#2563EB")); painter->drawText(buttonRect, Qt::AlignCenter, "更新"); } } @@ -169,12 +187,89 @@ void AppDelegate::startDownloadForAll() { for (int row = 0; row < m_model->rowCount(); ++row) { QModelIndex index = m_model->index(row, 0); QString packageName = index.data(Qt::UserRole + 1).toString(); - if (m_downloads.contains(packageName) && m_downloads[packageName].isDownloading) - continue; // 跳过正在下载的 + if (m_downloads.contains(packageName) && (m_downloads[packageName].isDownloading || m_downloads[packageName].isInstalled)) + continue; // 跳过正在下载或已安装的 QString downloadUrl = index.data(Qt::UserRole + 7).toString(); QString outputPath = QString("%1/%2.metalink").arg(QDir::tempPath(), packageName); - m_downloads[packageName] = {0, true}; + m_downloads[packageName] = {0, true, false}; m_downloadManager->startDownload(packageName, downloadUrl, outputPath); emit updateDisplay(packageName); } } + +// 新增:安装队列相关实现 +void AppDelegate::enqueueInstall(const QString &packageName) { + m_installQueue.enqueue(packageName); + if (!m_isInstalling) { + startNextInstall(); + } +} + +void AppDelegate::startNextInstall() { + if (m_installQueue.isEmpty()) { + m_isInstalling = false; + m_installingPackage.clear(); + return; + } + m_isInstalling = true; + QString packageName = m_installQueue.dequeue(); + m_installingPackage = packageName; + m_downloads[packageName].isInstalling = true; + emit updateDisplay(packageName); + + // 查找 /tmp 下以包名开头的 .deb 文件 + QDir tempDir(QDir::tempPath()); + QStringList debs = tempDir.entryList(QStringList() << QString("%1_*.deb").arg(packageName), QDir::Files); + QString debPath; + if (!debs.isEmpty()) { + debPath = tempDir.absoluteFilePath(debs.first()); + } else { + debs = tempDir.entryList(QStringList() << QString("%1*.deb").arg(packageName), QDir::Files); + if (!debs.isEmpty()) { + debPath = tempDir.absoluteFilePath(debs.first()); + } + } + + if (debPath.isEmpty()) { + qWarning() << "未找到deb文件,包名:" << packageName; + m_downloads[packageName].isInstalling = false; + emit updateDisplay(packageName); + m_installingPackage.clear(); + startNextInstall(); + return; + } + + m_installProcess = new QProcess(this); + connect(m_installProcess, &QProcess::readyReadStandardOutput, this, [this, packageName]() { + QByteArray out = m_installProcess->readAllStandardOutput(); + QString text = QString::fromLocal8Bit(out); + qDebug().noquote() << text; + // 检查“软件包已安装”关键字 + if (text.contains(QStringLiteral("软件包已安装"))) { + m_downloads[packageName].isInstalling = false; + m_downloads[packageName].isInstalled = true; + emit updateDisplay(packageName); + } + }); + connect(m_installProcess, &QProcess::readyReadStandardError, this, [this]() { + QByteArray err = m_installProcess->readAllStandardError(); + qDebug().noquote() << QString::fromLocal8Bit(err); + }); + connect(m_installProcess, QOverload::of(&QProcess::finished), + this, [this, packageName](int /*exitCode*/, QProcess::ExitStatus /*status*/) { + // 若未检测到“软件包已安装”,此处兜底 + if (!m_downloads[packageName].isInstalled) { + m_downloads[packageName].isInstalling = false; + } + emit updateDisplay(packageName); + m_installProcess->deleteLater(); + m_installProcess = nullptr; + m_installingPackage.clear(); + startNextInstall(); + }); + + // 注意参数顺序:deb路径在前,--no-create-desktop-entry在后 + QStringList args; + args << debPath << "--no-create-desktop-entry"; + m_installProcess->start("ssinstall", args); +} diff --git a/src/appdelegate.h b/src/appdelegate.h index 9e4ac3a..0545155 100644 --- a/src/appdelegate.h +++ b/src/appdelegate.h @@ -2,11 +2,16 @@ #include #include +#include +#include +#include #include "downloadmanager.h" struct DownloadInfo { int progress = 0; bool isDownloading = false; + bool isInstalled = false; + bool isInstalling = false; // 新增:标记是否正在安装 }; class AppDelegate : public QStyledItemDelegate { @@ -20,7 +25,7 @@ public: QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override; bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index) override; - void startDownloadForAll(); // 新增:批量下载所有应用 + void startDownloadForAll(); signals: void updateDisplay(const QString &packageName); @@ -29,4 +34,13 @@ private: DownloadManager *m_downloadManager; QHash m_downloads; QAbstractItemModel *m_model = nullptr; + + QQueue m_installQueue; + bool m_isInstalling = false; + QProcess *m_installProcess = nullptr; + QString m_installingPackage; // 当前正在安装的包名 + QElapsedTimer m_spinnerTimer; // 用于转圈动画 + + void enqueueInstall(const QString &packageName); + void startNextInstall(); }; From f925ac72424c7cb0b2f6ad73b5a194fbd3bce142 Mon Sep 17 00:00:00 2001 From: momen Date: Wed, 18 Jun 2025 20:47:48 +0800 Subject: [PATCH 072/114] =?UTF-8?q?update:=E4=BF=9D=E5=AD=98=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E5=88=B0/tmp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/appdelegate.cpp | 91 +++++++++++++++++++++++++++++------------ src/downloadmanager.cpp | 41 ++++++++++++++----- 2 files changed, 95 insertions(+), 37 deletions(-) diff --git a/src/appdelegate.cpp b/src/appdelegate.cpp index e873d53..315dcdf 100644 --- a/src/appdelegate.cpp +++ b/src/appdelegate.cpp @@ -240,33 +240,72 @@ void AppDelegate::startNextInstall() { } m_installProcess = new QProcess(this); - connect(m_installProcess, &QProcess::readyReadStandardOutput, this, [this, packageName]() { - QByteArray out = m_installProcess->readAllStandardOutput(); - QString text = QString::fromLocal8Bit(out); - qDebug().noquote() << text; - // 检查“软件包已安装”关键字 - if (text.contains(QStringLiteral("软件包已安装"))) { - m_downloads[packageName].isInstalling = false; - m_downloads[packageName].isInstalled = true; + + // 新增:准备安装日志文件 + QString logPath = QString("/tmp/%1_install.log").arg(packageName); + QFile *logFile = new QFile(logPath, m_installProcess); + if (logFile->open(QIODevice::Append | QIODevice::Text)) { + // 设置权限为777 + QFile::setPermissions(logPath, QFile::ReadOwner | QFile::WriteOwner | QFile::ExeOwner | + QFile::ReadGroup | QFile::WriteGroup | QFile::ExeGroup | + QFile::ReadOther | QFile::WriteOther | QFile::ExeOther); + connect(m_installProcess, &QProcess::readyReadStandardOutput, this, [this, packageName, logFile]() { + QByteArray out = m_installProcess->readAllStandardOutput(); + logFile->write(out); + logFile->flush(); + QString text = QString::fromLocal8Bit(out); + qDebug().noquote() << text; + // 检查“软件包已安装”关键字 + if (text.contains(QStringLiteral("软件包已安装"))) { + m_downloads[packageName].isInstalling = false; + m_downloads[packageName].isInstalled = true; + emit updateDisplay(packageName); + } + }); + connect(m_installProcess, &QProcess::readyReadStandardError, this, [this, logFile]() { + QByteArray err = m_installProcess->readAllStandardError(); + logFile->write(err); + logFile->flush(); + qDebug().noquote() << QString::fromLocal8Bit(err); + }); + connect(m_installProcess, QOverload::of(&QProcess::finished), + this, [this, packageName, logFile](int /*exitCode*/, QProcess::ExitStatus /*status*/) { + if (logFile) logFile->close(); + // 若未检测到“软件包已安装”,此处兜底 + if (!m_downloads[packageName].isInstalled) { + m_downloads[packageName].isInstalling = false; + } emit updateDisplay(packageName); - } - }); - connect(m_installProcess, &QProcess::readyReadStandardError, this, [this]() { - QByteArray err = m_installProcess->readAllStandardError(); - qDebug().noquote() << QString::fromLocal8Bit(err); - }); - connect(m_installProcess, QOverload::of(&QProcess::finished), - this, [this, packageName](int /*exitCode*/, QProcess::ExitStatus /*status*/) { - // 若未检测到“软件包已安装”,此处兜底 - if (!m_downloads[packageName].isInstalled) { - m_downloads[packageName].isInstalling = false; - } - emit updateDisplay(packageName); - m_installProcess->deleteLater(); - m_installProcess = nullptr; - m_installingPackage.clear(); - startNextInstall(); - }); + m_installProcess->deleteLater(); + m_installProcess = nullptr; + m_installingPackage.clear(); + startNextInstall(); + }); + } else { + // 日志文件无法打开时,仍然要连接原有信号 + connect(m_installProcess, &QProcess::readyReadStandardOutput, this, [this, packageName]() { + QByteArray out = m_installProcess->readAllStandardOutput(); + QString text = QString::fromLocal8Bit(out); + qDebug().noquote() << text; + if (text.contains(QStringLiteral("软件包已安装"))) { + m_downloads[packageName].isInstalling = false; + m_downloads[packageName].isInstalled = true; + emit updateDisplay(packageName); + } + }); + connect(m_installProcess, &QProcess::readyReadStandardError, this, [this]() { + QByteArray err = m_installProcess->readAllStandardError(); + qDebug().noquote() << QString::fromLocal8Bit(err); + }); + connect(m_installProcess, QOverload::of(&QProcess::finished), + this, [this, packageName](int /*exitCode*/, QProcess::ExitStatus /*status*/) { + emit updateDisplay(packageName); + m_installProcess->deleteLater(); + m_installProcess = nullptr; + m_installingPackage.clear(); + startNextInstall(); + }); + } // 注意参数顺序:deb路径在前,--no-create-desktop-entry在后 QStringList args; diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp index 271b7bf..9780324 100644 --- a/src/downloadmanager.cpp +++ b/src/downloadmanager.cpp @@ -33,20 +33,37 @@ void DownloadManager::startDownload(const QString &packageName, const QString &u QProcess *process = new QProcess(this); m_processes.insert(packageName, process); - connect(process, &QProcess::readyReadStandardOutput, this, [this, packageName, process]() { - while (process->canReadLine()) { - QString line = QString::fromUtf8(process->readLine()).trimmed(); - QRegularExpression regex(R"(\((\d+)%\))"); - QRegularExpressionMatch match = regex.match(line); - if (match.hasMatch()) { - int progress = match.captured(1).toInt(); - emit downloadProgress(packageName, progress); + // 新增:准备日志文件 + QString logPath = QString("/tmp/%1_download.log").arg(packageName); + QFile *logFile = new QFile(logPath, process); + if (logFile->open(QIODevice::Append | QIODevice::Text)) { + // 设置权限为777 + QFile::setPermissions(logPath, QFile::ReadOwner | QFile::WriteOwner | QFile::ExeOwner | + QFile::ReadGroup | QFile::WriteGroup | QFile::ExeGroup | + QFile::ReadOther | QFile::WriteOther | QFile::ExeOther); + connect(process, &QProcess::readyReadStandardOutput, this, [this, packageName, process, logFile]() { + while (process->canReadLine()) { + QString line = QString::fromUtf8(process->readLine()).trimmed(); + // 写入日志 + logFile->write(line.toUtf8() + '\n'); + logFile->flush(); + QRegularExpression regex(R"(\((\d+)%\))"); + QRegularExpressionMatch match = regex.match(line); + if (match.hasMatch()) { + int progress = match.captured(1).toInt(); + emit downloadProgress(packageName, progress); + } } - } - }); + }); + connect(process, &QProcess::readyReadStandardError, this, [process, logFile]() { + QByteArray err = process->readAllStandardError(); + logFile->write(err); + logFile->flush(); + }); + } connect(process, QOverload::of(&QProcess::finished), - this, [this, packageName, outputPath](int exitCode, QProcess::ExitStatus status) { + this, [this, packageName, outputPath, logFile](int exitCode, QProcess::ExitStatus status) { bool success = (exitCode == 0 && status == QProcess::NormalExit); if (!success) { qWarning() << "Download failed for" << packageName << "exit code:" << exitCode; @@ -55,6 +72,8 @@ void DownloadManager::startDownload(const QString &packageName, const QString &u removeAria2Files(outputPath); // 清理残留 .aria2 emit downloadFinished(packageName, success); + if (logFile) logFile->close(); + QProcess *proc = m_processes.take(packageName); if (proc) proc->deleteLater(); }); From 0607df0967067b539d04038bedccbf798b46d110 Mon Sep 17 00:00:00 2001 From: momen Date: Wed, 18 Jun 2025 21:14:23 +0800 Subject: [PATCH 073/114] =?UTF-8?q?fix:=E6=9B=B4=E6=AD=A3=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E5=AE=8C=E6=88=90=E5=90=8E=E5=86=8D=E6=AC=A1=E7=82=B9?= =?UTF-8?q?=E5=87=BB=E6=8C=89=E9=92=AE=E6=97=B6=E9=87=8D=E6=96=B0=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DownloadButton.jsx | 0 src/appdelegate.cpp | 7 +++++++ 2 files changed, 7 insertions(+) create mode 100644 DownloadButton.jsx diff --git a/DownloadButton.jsx b/DownloadButton.jsx new file mode 100644 index 0000000..e69de29 diff --git a/src/appdelegate.cpp b/src/appdelegate.cpp index 315dcdf..1a1c3e9 100644 --- a/src/appdelegate.cpp +++ b/src/appdelegate.cpp @@ -131,10 +131,12 @@ void AppDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, c painter->setPen(Qt::white); painter->drawText(buttonRect, Qt::AlignCenter, "已安装"); } else if (m_downloads.contains(packageName) && !m_downloads[packageName].isDownloading) { + // 下载完成,按钮绿色,样式不变 painter->setBrush(QColor("#10B981")); painter->drawRoundedRect(buttonRect, 4, 4); painter->setPen(Qt::white); painter->drawText(buttonRect, Qt::AlignCenter, "下载完成"); + // 不需要特殊处理样式,交互在 editorEvent 控制 } else { painter->setBrush(QColor("#e9effd")); painter->drawRoundedRect(buttonRect, 4, 4); @@ -168,6 +170,11 @@ bool AppDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, } else { QRect buttonRect(rect.right() - 80, rect.top() + (rect.height() - 30) / 2, 70, 30); if (buttonRect.contains(mouseEvent->pos())) { + // 判断是否为“下载完成”状态,如果是则不响应点击 + if (m_downloads.contains(packageName) && !m_downloads[packageName].isDownloading) { + // “下载完成”状态,按钮失效,点击无效 + return false; + } QString downloadUrl = index.data(Qt::UserRole + 7).toString(); QString outputPath = QString("%1/%2.metalink").arg(QDir::tempPath(), packageName); From 8e617ceda46dbbe4fe9a89c05b26cb9b1c7db8d3 Mon Sep 17 00:00:00 2001 From: momen Date: Wed, 18 Jun 2025 21:27:24 +0800 Subject: [PATCH 074/114] =?UTF-8?q?chore:=E4=BD=BF=E7=94=A8aptss=20update?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mainwindow.cpp | 22 ++++++++++++++++++++++ src/mainwindow.h | 1 + 2 files changed, 23 insertions(+) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index f961afc..ec1be40 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1,5 +1,7 @@ #include "mainwindow.h" #include "./ui_mainwindow.h" +#include +#include MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) @@ -7,6 +9,8 @@ MainWindow::MainWindow(QWidget *parent) , m_model(new AppListModel(this)) , m_delegate(new AppDelegate(this)) { + runAptssUpgrade(); + ui->setupUi(this); // 创建 QListView 并设置父控件为 ui->appWidget @@ -177,6 +181,24 @@ void MainWindow::checkUpdates() } } +void MainWindow::runAptssUpgrade() +{ + QProcess process; + QStringList args; + args << "aptss" << "upgrade"; + process.start("sudo", args); + if (!process.waitForStarted(5000)) { + QMessageBox::warning(this, "升级失败", "无法启动 sudo aptss upgrade。"); + return; + } + process.write("n\n"); + process.closeWriteChannel(); + process.waitForFinished(-1); + if (process.exitCode() != 0) { + QMessageBox::warning(this, "升级失败", "执行 sudo aptss upgrade 失败,请检查系统环境。"); + } +} + MainWindow::~MainWindow() { delete ui; diff --git a/src/mainwindow.h b/src/mainwindow.h index 9cb6af8..e36db88 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -25,6 +25,7 @@ private: Ui::MainWindow *ui; void checkUpdates(); void initStyle(); + void runAptssUpgrade(); AppListModel *m_model; AppDelegate *m_delegate; QListView *listView; // 声明 QListView 指针 From b5e0b709cc46f1a8347d6b090a3e3f5b1d7f6773 Mon Sep 17 00:00:00 2001 From: momen Date: Wed, 18 Jun 2025 22:04:40 +0800 Subject: [PATCH 075/114] =?UTF-8?q?fix:=E5=88=A0=E9=99=A4=E5=A4=9A?= =?UTF-8?q?=E4=BD=99=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 0 DownloadButton.jsx | 0 2 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 CMakeLists.txt delete mode 100644 DownloadButton.jsx diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index e69de29..0000000 diff --git a/DownloadButton.jsx b/DownloadButton.jsx deleted file mode 100644 index e69de29..0000000 From b68029f5db8bdd933973484592e16098977a1226 Mon Sep 17 00:00:00 2001 From: momen Date: Wed, 18 Jun 2025 22:17:56 +0800 Subject: [PATCH 076/114] =?UTF-8?q?chore:=E5=BC=82=E6=AD=A5=E6=9B=B4?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/CMakeLists.txt | 6 ++-- src/mainwindow.cpp | 76 +++++++++++++++++++++++++++++----------------- 2 files changed, 51 insertions(+), 31 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f7f76af..10e7b56 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -9,8 +9,8 @@ set(CMAKE_AUTORCC ON) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) -find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets Network) -find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets Network) +find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets Network Concurrent) +find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets Network Concurrent) set(PROJECT_SOURCES main.cpp @@ -47,7 +47,7 @@ else() endif() endif() -target_link_libraries(Spark-Update-Tool PRIVATE Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Network) +target_link_libraries(Spark-Update-Tool PRIVATE Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Network Qt${QT_VERSION_MAJOR}::Concurrent) # Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1. # If you are developing for iOS or macOS you should consider setting an diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index ec1be40..3b01b23 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -2,6 +2,9 @@ #include "./ui_mainwindow.h" #include #include +#include +#include // 新增 +#include // 新增 MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) @@ -9,40 +12,57 @@ MainWindow::MainWindow(QWidget *parent) , m_model(new AppListModel(this)) , m_delegate(new AppDelegate(this)) { - runAptssUpgrade(); + QProgressDialog *progressDialog = new QProgressDialog("正在与服务器通信,获取更新信息中...", QString(), 0, 0, this); + progressDialog->setWindowModality(Qt::ApplicationModal); + progressDialog->setCancelButton(nullptr); + progressDialog->setWindowTitle("请稍候"); + progressDialog->setMinimumDuration(0); + progressDialog->setWindowFlags(progressDialog->windowFlags() & ~Qt::WindowCloseButtonHint); // 禁用关闭按钮 + progressDialog->show(); + //异步执行runAptssUpgrade + QFutureWatcher *watcher = new QFutureWatcher(this); + connect(watcher, &QFutureWatcher::finished, this, [=]() { + progressDialog->close(); + progressDialog->deleteLater(); + watcher->deleteLater(); + ui->setupUi(this); - ui->setupUi(this); + // 创建 QListView 并设置父控件为 ui->appWidget + listView = new QListView(ui->appWidget); + listView->setModel(m_model); + listView->setItemDelegate(m_delegate); - // 创建 QListView 并设置父控件为 ui->appWidget - listView = new QListView(ui->appWidget); - listView->setModel(m_model); - listView->setItemDelegate(m_delegate); + // 新增:确保 delegate 拥有 model 指针 + m_delegate->setModel(m_model); - // 新增:确保 delegate 拥有 model 指针 - m_delegate->setModel(m_model); - - // 设置 QListView 填充 ui->appWidget - QVBoxLayout *layout = new QVBoxLayout(ui->appWidget); - layout->addWidget(listView); - layout->setContentsMargins(0, 0, 0, 0); - connect(m_delegate, &AppDelegate::updateDisplay, this, [=](const QString &packageName) { - for (int i = 0; i < m_model->rowCount(); ++i) { - QModelIndex index = m_model->index(i); - if (index.data(Qt::UserRole + 1).toString() == packageName) { - m_model->dataChanged(index, index); // 刷新该行 - break; + // 设置 QListView 填充 ui->appWidget + QVBoxLayout *layout = new QVBoxLayout(ui->appWidget); + layout->addWidget(listView); + layout->setContentsMargins(0, 0, 0, 0); + connect(m_delegate, &AppDelegate::updateDisplay, this, [=](const QString &packageName) { + for (int i = 0; i < m_model->rowCount(); ++i) { + QModelIndex index = m_model->index(i); + if (index.data(Qt::UserRole + 1).toString() == packageName) { + m_model->dataChanged(index, index); // 刷新该行 + break; + } } - } + }); + + // 新增:点击“更新全部”按钮批量下载 + connect(ui->updatePushButton, &QPushButton::clicked, this, [=](){ + qDebug()<<"更新全部按钮被点击"; + m_delegate->startDownloadForAll(); + }); + + checkUpdates(); + initStyle(); }); - // 新增:点击“更新全部”按钮批量下载 - connect(ui->updatePushButton, &QPushButton::clicked, this, [=](){ - qDebug()<<"更新全部按钮被点击"; - m_delegate->startDownloadForAll(); - }); - - checkUpdates(); - initStyle(); + // 启动异步任务 + watcher->setFuture(QtConcurrent::run([this](){ + runAptssUpgrade(); + })); } //初始化控件样式 void MainWindow::initStyle() From 196ae84eb5a079775d74280563604029652f259f Mon Sep 17 00:00:00 2001 From: momen Date: Thu, 19 Jun 2025 00:35:38 +0800 Subject: [PATCH 077/114] =?UTF-8?q?chore:=E6=9B=B4=E6=96=B0debian=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 57 ++++++++++++++++++++++++++++ src/CMakeLists.txt => CMakeLists.txt | 38 +++++++++---------- debian/changelog | 5 +++ debian/compat | 1 + debian/control | 12 ++++++ debian/copyright | 7 ++++ debian/install | 2 + debian/momodesk-mind.desktop | 9 +++++ debian/postrm | 11 ++++++ debian/rules | 7 ++++ debian/source/format | 1 + spark-update-tool.desktop | 9 +++++ src/mainwindow.ui | 1 - 13 files changed, 140 insertions(+), 20 deletions(-) rename src/CMakeLists.txt => CMakeLists.txt (69%) create mode 100644 debian/changelog create mode 100644 debian/compat create mode 100644 debian/control create mode 100644 debian/copyright create mode 100644 debian/install create mode 100644 debian/momodesk-mind.desktop create mode 100644 debian/postrm create mode 100755 debian/rules create mode 100644 debian/source/format create mode 100644 spark-update-tool.desktop diff --git a/.gitignore b/.gitignore index 75ea44d..79c9ac7 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,60 @@ build .cache CMakeLists.txt.user CMakeLists.txt.user.* +obj-x86_64-linux-gnu +# C++ objects and libs +*.slo +*.lo +*.o +*.a +*.la +*.lai +*.so +*.dll +*.dylib + +# Qt-es +object_script.*.Release +object_script.*.Debug +*_plugin_import.cpp +/.qmake.cache +/.qmake.stash +*.pro.user +*.pro.user.* +*.qbs.user +*.qbs.user.* +*.moc +moc_*.cpp +moc_*.h +qrc_*.cpp +ui_*.h +*.qmlc +*.jsc +Makefile* +*build-* + +# Qt unit tests +target_wrapper.* + +# Qt qm files +translations/*.qm + +# QtCreator +*.autosave + +# QtCreator Qml +*.qmlproject.user +*.qmlproject.user.* + +# QtCreator CMake +CMakeLists.txt.user* +build + +# Debian dpkg-buildpackage +debian/*.debhelper* +debian/files +debian/*.substvars +debian/spark-update-tool + +.vscode/* +src/spark-update-tool diff --git a/src/CMakeLists.txt b/CMakeLists.txt similarity index 69% rename from src/CMakeLists.txt rename to CMakeLists.txt index 10e7b56..6c624b4 100644 --- a/src/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.16) -project(Spark-Update-Tool VERSION 0.1 LANGUAGES CXX) +project(spark-update-tool VERSION 0.1 LANGUAGES CXX) set(CMAKE_AUTOUIC ON) set(CMAKE_AUTOMOC ON) @@ -13,49 +13,49 @@ find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets Network Concurrent) find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets Network Concurrent) set(PROJECT_SOURCES - main.cpp - mainwindow.cpp - mainwindow.h - mainwindow.ui + src/main.cpp + src/mainwindow.cpp + src/mainwindow.h + src/mainwindow.ui ) if(${QT_VERSION_MAJOR} GREATER_EQUAL 6) - qt_add_executable(Spark-Update-Tool + qt_add_executable(spark-update-tool MANUAL_FINALIZATION ${PROJECT_SOURCES} - aptssupdater.h aptssupdater.cpp - icons.qrc - appdelegate.h appdelegate.cpp - applistmodel.h applistmodel.cpp - downloadmanager.h downloadmanager.cpp + src/aptssupdater.h src/aptssupdater.cpp + src/icons.qrc + src/appdelegate.h src/appdelegate.cpp + src/applistmodel.h src/applistmodel.cpp + src/downloadmanager.h src/downloadmanager.cpp ) # Define target properties for Android with Qt 6 as: -# set_property(TARGET Spark-Update-Tool APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR +# set_property(TARGET spark-update-tool APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR # ${CMAKE_CURRENT_SOURCE_DIR}/android) # For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation else() if(ANDROID) - add_library(Spark-Update-Tool SHARED + add_library(spark-update-tool SHARED ${PROJECT_SOURCES} ) # Define properties for Android with Qt 5 after find_package() calls as: # set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android") else() - add_executable(Spark-Update-Tool + add_executable(spark-update-tool ${PROJECT_SOURCES} ) endif() endif() -target_link_libraries(Spark-Update-Tool PRIVATE Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Network Qt${QT_VERSION_MAJOR}::Concurrent) +target_link_libraries(spark-update-tool PRIVATE Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Network Qt${QT_VERSION_MAJOR}::Concurrent) # Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1. # If you are developing for iOS or macOS you should consider setting an # explicit, fixed bundle identifier manually though. if(${QT_VERSION} VERSION_LESS 6.1.0) - set(BUNDLE_ID_OPTION MACOSX_BUNDLE_GUI_IDENTIFIER com.example.Spark-Update-Tool) + set(BUNDLE_ID_OPTION MACOSX_BUNDLE_GUI_IDENTIFIER com.example.spark-update-tool) endif() -set_target_properties(Spark-Update-Tool PROPERTIES +set_target_properties(spark-update-tool PROPERTIES ${BUNDLE_ID_OPTION} MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION} MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} @@ -64,12 +64,12 @@ set_target_properties(Spark-Update-Tool PROPERTIES ) include(GNUInstallDirs) -install(TARGETS Spark-Update-Tool +install(TARGETS spark-update-tool BUNDLE DESTINATION . LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ) if(QT_VERSION_MAJOR EQUAL 6) - qt_finalize_executable(Spark-Update-Tool) + qt_finalize_executable(spark-update-tool) endif() diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..de17899 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +spark-update-tool (1.0.0-1) unstable; urgency=low + + * Initial release. + + -- momen Wed, 18 Jun 2025 00:00:00 +0000 \ No newline at end of file diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..f11c82a --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +9 \ No newline at end of file diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..35ec34c --- /dev/null +++ b/debian/control @@ -0,0 +1,12 @@ +Source: spark-update-tool +Section: utils +Priority: optional +Maintainer: momen +Build-Depends: debhelper (>= 9),qt6-base-dev +Standards-Version: 3.9.6 +Homepage: https://gitee.com/spark-store-project/Spark-Update-Tool + +Package: spark-update-tool +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: A Qt-based application for managing tasks and reminders. diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..163489e --- /dev/null +++ b/debian/copyright @@ -0,0 +1,7 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: spark-update-tool +Source: https://gitee.com/spark-store-project/Spark-Update-Tool + +Files: * +Copyright: 2025, momen +License: GPL-3.0+ \ No newline at end of file diff --git a/debian/install b/debian/install new file mode 100644 index 0000000..62266e3 --- /dev/null +++ b/debian/install @@ -0,0 +1,2 @@ +build/spark-update-tool /usr/bin/ +spark-update-tool.desktop /usr/share/applications diff --git a/debian/momodesk-mind.desktop b/debian/momodesk-mind.desktop new file mode 100644 index 0000000..2ef7139 --- /dev/null +++ b/debian/momodesk-mind.desktop @@ -0,0 +1,9 @@ +[Desktop Entry] +Version=1.0 +Name=spark-update-tool +Comment=A Qt-based application for managing tasks and reminders +Exec=/usr/bin/spark-update-tool +Icon=/usr/share/spark-update-tool/img/momen.jpg +Terminal=false +Type=Application +Categories=Utility; \ No newline at end of file diff --git a/debian/postrm b/debian/postrm new file mode 100644 index 0000000..263e9c4 --- /dev/null +++ b/debian/postrm @@ -0,0 +1,11 @@ +#!/bin/sh +set -e + +case "$1" in + purge) + + rm -rf /usr/share/spark-update-tool + ;; +esac + +exit 0 \ No newline at end of file diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..1159ac4 --- /dev/null +++ b/debian/rules @@ -0,0 +1,7 @@ +#!/usr/bin/make -f + +%: + dh $@ + +override_dh_auto_configure: + dh_auto_configure -- -DCMAKE_INSTALL_PREFIX=/usr diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 0000000..9f67427 --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (native) \ No newline at end of file diff --git a/spark-update-tool.desktop b/spark-update-tool.desktop new file mode 100644 index 0000000..688ba0c --- /dev/null +++ b/spark-update-tool.desktop @@ -0,0 +1,9 @@ +[Desktop Entry] +Version=1.0 +Name=Spark Update Tool +Comment=A Qt-based application for managing and updating software +Exec=spark-update-tool +Icon=spark-update-tool +Terminal=false +Type=Application +Categories=Utility; diff --git a/src/mainwindow.ui b/src/mainwindow.ui index f0aace0..1feb345 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -191,7 +191,6 @@ - PreferNoHinting From b261d6433a1136386b919583dd41677f29799111 Mon Sep 17 00:00:00 2001 From: momen Date: Thu, 19 Jun 2025 21:37:59 +0800 Subject: [PATCH 078/114] =?UTF-8?q?docs:=E6=9B=B4=E6=96=B0readme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index fc8a11e..e6b20a5 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ 欢迎使用星火软件更新器,您可以使用此更新器更新位于您 Linux 计算机的程序。 +此版本专为仅有qt5的Linux发行版所使用。 #### 当前支持的 Linux 发行版 - [x] GXDE OS - [x] Ubuntu From 1e8fcf9bb0625581587ffd75f7cb807febb3cf66 Mon Sep 17 00:00:00 2001 From: momen Date: Fri, 20 Jun 2025 23:48:21 +0800 Subject: [PATCH 079/114] =?UTF-8?q?update:=E6=9B=B4=E6=96=B0readme?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index fc8a11e..b06078c 100644 --- a/README.md +++ b/README.md @@ -18,3 +18,4 @@ |支持 ACE 兼容环境| | #### 联系与反馈 +momen@momen.world \ No newline at end of file From f37d73708b024e31c713b51f7744fd3ef517180f Mon Sep 17 00:00:00 2001 From: momen Date: Sat, 21 Jun 2025 23:01:13 +0800 Subject: [PATCH 080/114] =?UTF-8?q?update:=E6=9B=B4=E6=96=B0=E6=8F=90?= =?UTF-8?q?=E6=9D=83=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.cpp | 64 ++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 59 insertions(+), 5 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 4f4956f..71c172d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4,6 +4,7 @@ #include #include // for geteuid #include // for getenv +#include // For debugging output bool isRoot() { return geteuid() == 0; @@ -11,10 +12,13 @@ bool isRoot() { bool elevateToRoot() { QString program = QCoreApplication::applicationFilePath(); + qDebug() << "Current application path:" << program; // 获取当前 DISPLAY 和 XAUTHORITY 环境变量 QByteArray display = qgetenv("DISPLAY"); QByteArray xauthority = qgetenv("XAUTHORITY"); + qDebug() << "DISPLAY:" << display; + qDebug() << "XAUTHORITY:" << xauthority; // 构造带环境变量的 pkexec 命令 QStringList args; @@ -23,22 +27,72 @@ bool elevateToRoot() { << "XAUTHORITY=" + xauthority << program; - // 使用 pkexec 启动程序(带环境变量) - return QProcess::startDetached("pkexec", args); + QProcess *process = new QProcess(); + process->setProgram("pkexec"); + process->setArguments(args); + + qDebug() << "Attempting to elevate using pkexec with arguments:" << args; + + // 启动进程并等待完成 + process->start(); + // 等待 pkexec 完成,通常会弹出密码框 + // 设置一个合理的超时时间,例如 30 秒 + if (!process->waitForFinished(30000)) { + qDebug() << "pkexec process timed out."; + process->kill(); // 如果超时,终止进程 + delete process; + return false; + } + + int exitCode = process->exitCode(); + QProcess::ExitStatus exitStatus = process->exitStatus(); + + qDebug() << "pkexec exit code:" << exitCode; + qDebug() << "pkexec exit status:" << exitStatus; + qDebug() << "pkexec standard error:" << process->readAllStandardError(); + + // 检查 pkexec 是否成功 + // pkexec 成功执行通常返回 0,或者如果用户取消授权,会返回非零值。 + // 但是,如果 pkexec 本身执行失败(例如找不到命令),exitStatus 会是 CrashOrKilled + // 这里我们认为只要pkexec成功启动了,即使授权失败,也算pkexec命令执行成功了, + // 因为这表示pkexec本身是可用的。 + // 只有当pkexec命令无法执行时,才认为是pkexec的问题 + bool pkexecCommandExecuted = (exitStatus == QProcess::NormalExit && exitCode == 0); + + delete process; + return pkexecCommandExecuted; } int main(int argc, char *argv[]) { + // 必须在 QGuiApplication 实例创建之前调用 + // QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough); + QApplication a(argc, argv); if (!isRoot()) { + qDebug() << "Not running as root. Attempting to elevate..."; if (!elevateToRoot()) { - QMessageBox::critical(nullptr, "权限不足", "提权失败,请确保系统支持 pkexec 并已正确安装 polkit。"); + qDebug() << "Elevation failed or pkexec command was not executed successfully."; + QMessageBox::critical(nullptr, + "权限不足", + "提权失败!\n\n您的系统可能不支持 `pkexec` 或 `polkit` 配置不正确," + "或者您取消了授权。\n\n请尝试使用 `sudo` 命令运行此程序:" + "\n\n在终端中输入:\n`sudo " + QCoreApplication::applicationName() + "`"); + return 0; // 提权失败,退出程序 + } else { + // 如果 elevateToRoot 返回 true,说明 pkexec 命令本身执行成功 + // 但这并不意味着原始程序以 root 权限启动了 + // 因为 elevateToRoot 启动的是一个新的进程,当前进程应该退出 + // 否则会并行运行两个程序实例 + qDebug() << "pkexec command executed successfully (new process likely started). Exiting current process."; + return 0; // 当前非root进程退出 } - return 0; + } else { + qDebug() << "Running as root."; } MainWindow w; w.show(); return a.exec(); -} +} \ No newline at end of file From 9fdf0051a1e42958a544fac676ee45d17d278666 Mon Sep 17 00:00:00 2001 From: momen Date: Sun, 22 Jun 2025 10:33:14 +0800 Subject: [PATCH 081/114] =?UTF-8?q?chore:cmakelist.txt=E4=BD=BF=E7=94=A8qt?= =?UTF-8?q?5,=E4=BB=A5=E6=AD=A4=E6=9D=A5=E6=94=AF=E6=8C=81=E6=97=A7?= =?UTF-8?q?=E7=89=88=E7=B3=BB=E7=BB=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 75 +++++++++++++++++++------------------------------- 1 file changed, 29 insertions(+), 46 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6c624b4..49a4d5e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,58 +9,44 @@ set(CMAKE_AUTORCC ON) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) -find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets Network Concurrent) -find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets Network Concurrent) +find_package(Qt5 REQUIRED COMPONENTS Widgets Network Concurrent) + + +find_package(Qt5 REQUIRED COMPONENTS Widgets Network Concurrent Core Gui) + +# 定义所有项目源文件,现在无需条件判断 set(PROJECT_SOURCES - src/main.cpp - src/mainwindow.cpp - src/mainwindow.h - src/mainwindow.ui + src/main.cpp + src/mainwindow.cpp + src/mainwindow.h + src/mainwindow.ui + src/aptssupdater.h src/aptssupdater.cpp + src/icons.qrc + src/appdelegate.h src/appdelegate.cpp + src/applistmodel.h src/applistmodel.cpp + src/downloadmanager.h src/downloadmanager.cpp ) -if(${QT_VERSION_MAJOR} GREATER_EQUAL 6) - qt_add_executable(spark-update-tool - MANUAL_FINALIZATION - ${PROJECT_SOURCES} - src/aptssupdater.h src/aptssupdater.cpp - src/icons.qrc - src/appdelegate.h src/appdelegate.cpp - src/applistmodel.h src/applistmodel.cpp - src/downloadmanager.h src/downloadmanager.cpp - ) -# Define target properties for Android with Qt 6 as: -# set_property(TARGET spark-update-tool APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR -# ${CMAKE_CURRENT_SOURCE_DIR}/android) -# For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation -else() - if(ANDROID) - add_library(spark-update-tool SHARED - ${PROJECT_SOURCES} - ) -# Define properties for Android with Qt 5 after find_package() calls as: -# set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android") - else() - add_executable(spark-update-tool - ${PROJECT_SOURCES} - ) - endif() -endif() -target_link_libraries(spark-update-tool PRIVATE Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Network Qt${QT_VERSION_MAJOR}::Concurrent) +add_executable(spark-update-tool + ${PROJECT_SOURCES} +) + +target_link_libraries(spark-update-tool PRIVATE + Qt5::Widgets + Qt5::Network + Qt5::Concurrent + Qt5::Core + Qt5::Gui +) + -# Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1. -# If you are developing for iOS or macOS you should consider setting an -# explicit, fixed bundle identifier manually though. -if(${QT_VERSION} VERSION_LESS 6.1.0) - set(BUNDLE_ID_OPTION MACOSX_BUNDLE_GUI_IDENTIFIER com.example.spark-update-tool) -endif() set_target_properties(spark-update-tool PROPERTIES - ${BUNDLE_ID_OPTION} + # ${BUNDLE_ID_OPTION} # 如果上面取消注释,这里也取消注释 MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION} MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} - MACOSX_BUNDLE TRUE - WIN32_EXECUTABLE TRUE + ) include(GNUInstallDirs) @@ -70,6 +56,3 @@ install(TARGETS spark-update-tool RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ) -if(QT_VERSION_MAJOR EQUAL 6) - qt_finalize_executable(spark-update-tool) -endif() From 68d7f427512fb0da4de21692055ab95c783b7910 Mon Sep 17 00:00:00 2001 From: momen Date: Sun, 22 Jun 2025 15:26:04 +0800 Subject: [PATCH 082/114] =?UTF-8?q?fix:=E6=8F=90=E6=9D=83=E5=90=8E30s?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E6=98=BE=E7=A4=BA=E6=8F=90=E6=9D=83=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.cpp | 44 ++++++++++++++++---------------------------- 1 file changed, 16 insertions(+), 28 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 71c172d..c834b96 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -14,53 +14,41 @@ bool elevateToRoot() { QString program = QCoreApplication::applicationFilePath(); qDebug() << "Current application path:" << program; - // 获取当前 DISPLAY 和 XAUTHORITY 环境变量 QByteArray display = qgetenv("DISPLAY"); QByteArray xauthority = qgetenv("XAUTHORITY"); - qDebug() << "DISPLAY:" << display; - qDebug() << "XAUTHORITY:" << xauthority; - // 构造带环境变量的 pkexec 命令 QStringList args; args << "env" << "DISPLAY=" + display << "XAUTHORITY=" + xauthority << program; - QProcess *process = new QProcess(); - process->setProgram("pkexec"); - process->setArguments(args); + QProcess process; + process.setProgram("pkexec"); + process.setArguments(args); qDebug() << "Attempting to elevate using pkexec with arguments:" << args; - // 启动进程并等待完成 - process->start(); - // 等待 pkexec 完成,通常会弹出密码框 - // 设置一个合理的超时时间,例如 30 秒 - if (!process->waitForFinished(30000)) { - qDebug() << "pkexec process timed out."; - process->kill(); // 如果超时,终止进程 - delete process; + process.start(); + if (!process.waitForStarted(5000)) { + qDebug() << "Failed to start pkexec."; return false; } - int exitCode = process->exitCode(); - QProcess::ExitStatus exitStatus = process->exitStatus(); + // 阻塞等待提权进程退出(比如主程序窗口关闭) + if (!process.waitForFinished(-1)) { // 等待直到新进程退出 + qDebug() << "pkexec process waitForFinished failed."; + return false; + } + + int exitCode = process.exitCode(); + QProcess::ExitStatus exitStatus = process.exitStatus(); qDebug() << "pkexec exit code:" << exitCode; qDebug() << "pkexec exit status:" << exitStatus; - qDebug() << "pkexec standard error:" << process->readAllStandardError(); + qDebug() << "pkexec stderr:" << process.readAllStandardError(); - // 检查 pkexec 是否成功 - // pkexec 成功执行通常返回 0,或者如果用户取消授权,会返回非零值。 - // 但是,如果 pkexec 本身执行失败(例如找不到命令),exitStatus 会是 CrashOrKilled - // 这里我们认为只要pkexec成功启动了,即使授权失败,也算pkexec命令执行成功了, - // 因为这表示pkexec本身是可用的。 - // 只有当pkexec命令无法执行时,才认为是pkexec的问题 - bool pkexecCommandExecuted = (exitStatus == QProcess::NormalExit && exitCode == 0); - - delete process; - return pkexecCommandExecuted; + return (exitStatus == QProcess::NormalExit && exitCode == 0); } int main(int argc, char *argv[]) From 35d1e8b198b085075745c7a0cba9ce5685547b4a Mon Sep 17 00:00:00 2001 From: momen Date: Mon, 23 Jun 2025 12:21:58 +0800 Subject: [PATCH 083/114] =?UTF-8?q?update:=E6=9B=B4=E6=96=B0debian?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- debian/changelog | 2 +- debian/control | 2 +- debian/install | 2 +- debian/momodesk-mind.desktop | 9 --------- .../spark-update-tool.desktop | 0 5 files changed, 3 insertions(+), 12 deletions(-) delete mode 100644 debian/momodesk-mind.desktop rename spark-update-tool.desktop => debian/spark-update-tool.desktop (100%) diff --git a/debian/changelog b/debian/changelog index de17899..b414fea 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -spark-update-tool (1.0.0-1) unstable; urgency=low +spark-update-tool (1.0.0) unstable; urgency=low * Initial release. diff --git a/debian/control b/debian/control index 35ec34c..b250b67 100644 --- a/debian/control +++ b/debian/control @@ -9,4 +9,4 @@ Homepage: https://gitee.com/spark-store-project/Spark-Update-Tool Package: spark-update-tool Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends} -Description: A Qt-based application for managing tasks and reminders. +Description: 星火应用商店更新插件 diff --git a/debian/install b/debian/install index 62266e3..fdab2a3 100644 --- a/debian/install +++ b/debian/install @@ -1,2 +1,2 @@ build/spark-update-tool /usr/bin/ -spark-update-tool.desktop /usr/share/applications +debian/spark-update-tool.desktop /usr/share/applications diff --git a/debian/momodesk-mind.desktop b/debian/momodesk-mind.desktop deleted file mode 100644 index 2ef7139..0000000 --- a/debian/momodesk-mind.desktop +++ /dev/null @@ -1,9 +0,0 @@ -[Desktop Entry] -Version=1.0 -Name=spark-update-tool -Comment=A Qt-based application for managing tasks and reminders -Exec=/usr/bin/spark-update-tool -Icon=/usr/share/spark-update-tool/img/momen.jpg -Terminal=false -Type=Application -Categories=Utility; \ No newline at end of file diff --git a/spark-update-tool.desktop b/debian/spark-update-tool.desktop similarity index 100% rename from spark-update-tool.desktop rename to debian/spark-update-tool.desktop From f300dd1f4deb2da9692942c26a20c0d33849c958 Mon Sep 17 00:00:00 2001 From: momen Date: Mon, 23 Jun 2025 12:33:01 +0800 Subject: [PATCH 084/114] =?UTF-8?q?chore:=E7=A7=BB=E5=8A=A8=E8=B5=84?= =?UTF-8?q?=E6=BA=90=E6=96=87=E4=BB=B6=E5=88=B0=E6=A0=B9=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- {src/resources => resources}/default_icon.svg | 0 {src/resources => resources}/down_arrow.svg | 0 src/icons.qrc | 4 ++-- 3 files changed, 2 insertions(+), 2 deletions(-) rename {src/resources => resources}/default_icon.svg (100%) rename {src/resources => resources}/down_arrow.svg (100%) diff --git a/src/resources/default_icon.svg b/resources/default_icon.svg similarity index 100% rename from src/resources/default_icon.svg rename to resources/default_icon.svg diff --git a/src/resources/down_arrow.svg b/resources/down_arrow.svg similarity index 100% rename from src/resources/down_arrow.svg rename to resources/down_arrow.svg diff --git a/src/icons.qrc b/src/icons.qrc index cce5944..9f749df 100644 --- a/src/icons.qrc +++ b/src/icons.qrc @@ -1,6 +1,6 @@ - resources/down_arrow.svg - resources/default_icon.svg + ../resources/down_arrow.svg + ../resources/default_icon.svg From c1923ad6afbbf84a1f3b527ed36c77d37476c354 Mon Sep 17 00:00:00 2001 From: MeowVing Date: Mon, 23 Jun 2025 05:24:38 +0000 Subject: [PATCH 085/114] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=9B=BE=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: MeowVing --- resources/spark-update-tool.svg | 1 + 1 file changed, 1 insertion(+) create mode 100644 resources/spark-update-tool.svg diff --git a/resources/spark-update-tool.svg b/resources/spark-update-tool.svg new file mode 100644 index 0000000..3d21d81 --- /dev/null +++ b/resources/spark-update-tool.svg @@ -0,0 +1 @@ + \ No newline at end of file From cc087030fd8369b16dafa7740756d5b5ab83e98c Mon Sep 17 00:00:00 2001 From: momen Date: Mon, 23 Jun 2025 13:14:50 +0800 Subject: [PATCH 086/114] =?UTF-8?q?chore:=E5=8E=BB=E9=99=A4=E5=85=A8?= =?UTF-8?q?=E9=80=89=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mainwindow.ui | 37 ++++++++----------------------------- 1 file changed, 8 insertions(+), 29 deletions(-) diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 1feb345..2a58287 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -49,7 +49,7 @@ - Qt::Orientation::Horizontal + Qt::Horizontal @@ -144,7 +144,7 @@ - Qt::Orientation::Horizontal + Qt::Horizontal @@ -190,14 +190,13 @@ - - + - Qt::LayoutDirection::LeftToRight + Qt::LeftToRight - QComboBox::SizeAdjustPolicy::AdjustToContentsOnFirstShow + QComboBox::AdjustToContentsOnFirstShow @@ -223,31 +222,11 @@ - - - - - 0 - 20 - - - - - - 0 - 0 - 96 - 24 - - - - 全选 - - - - + + true + 0 From c36492cd0b1b50d91a26a5fa7465a66144e16dac Mon Sep 17 00:00:00 2001 From: momen Date: Mon, 23 Jun 2025 14:09:02 +0800 Subject: [PATCH 087/114] =?UTF-8?q?update:=E6=9B=B4=E6=96=B0control?= =?UTF-8?q?=E6=8F=8F=E8=BF=B0=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- debian/control | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/debian/control b/debian/control index b250b67..19c9d62 100644 --- a/debian/control +++ b/debian/control @@ -2,11 +2,12 @@ Source: spark-update-tool Section: utils Priority: optional Maintainer: momen -Build-Depends: debhelper (>= 9),qt6-base-dev +Build-Depends: debhelper (>= 9) Standards-Version: 3.9.6 Homepage: https://gitee.com/spark-store-project/Spark-Update-Tool Package: spark-update-tool Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends} -Description: 星火应用商店更新插件 +Description: Spark Update Tool + 星火应用商店更新组件。This package provides the Spark Update Tool. It includes features for checking for updates, downloading, and applying them seamlessly. \ No newline at end of file From 27e41f35f0c89514d5a08c9249bdde5353d0e533 Mon Sep 17 00:00:00 2001 From: momen Date: Mon, 23 Jun 2025 21:56:59 +0800 Subject: [PATCH 088/114] =?UTF-8?q?chore:=E8=AE=BE=E7=BD=AE=E5=BA=94?= =?UTF-8?q?=E7=94=A8=E5=9B=BE=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- debian/install | 1 + src/icons.qrc | 1 + 2 files changed, 2 insertions(+) diff --git a/debian/install b/debian/install index fdab2a3..ac99078 100644 --- a/debian/install +++ b/debian/install @@ -1,2 +1,3 @@ build/spark-update-tool /usr/bin/ debian/spark-update-tool.desktop /usr/share/applications +resources/spark-update-tool.svg /usr/share/icons/hicolor/scalable/apps/spark-update-tool.svg \ No newline at end of file diff --git a/src/icons.qrc b/src/icons.qrc index 9f749df..0209761 100644 --- a/src/icons.qrc +++ b/src/icons.qrc @@ -2,5 +2,6 @@ ../resources/down_arrow.svg ../resources/default_icon.svg + ../resources/spark-update-tool.svg From d5ad1d020485e17dbe7ee1b37cf688ece6d08776 Mon Sep 17 00:00:00 2001 From: momen Date: Tue, 24 Jun 2025 11:23:47 +0800 Subject: [PATCH 089/114] =?UTF-8?q?fix:=E8=A7=A3=E5=86=B3=E6=BB=9A?= =?UTF-8?q?=E5=8A=A8=E6=9D=A1=E4=B8=8D=E7=94=9F=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mainwindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 3b01b23..e76667c 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -154,7 +154,7 @@ void MainWindow::initStyle() this->setStyleSheet("background-color: #F8FAFC;"); // 添加滚动条样式 - listView->setStyleSheet(R"( + this->setStyleSheet(R"( QScrollBar:vertical { background: #F3F4F6; width: 8px; From ea78b37d860151cd76155f2e5b41537cd04b631e Mon Sep 17 00:00:00 2001 From: momen Date: Wed, 25 Jun 2025 22:06:05 +0800 Subject: [PATCH 090/114] =?UTF-8?q?docs:=E6=9B=B4=E6=96=B0=E6=96=87?= =?UTF-8?q?=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index ffed210..519a94b 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ 欢迎使用星火软件更新器,您可以使用此更新器更新位于您 Linux 计算机的程序。 此版本专为仅有qt5的Linux发行版所使用。 +请在root环境下运行。 #### 当前支持的 Linux 发行版 - [x] GXDE OS - [x] Ubuntu From 63910b64917c87b7bbad467f799f5a01116c350b Mon Sep 17 00:00:00 2001 From: momen Date: Fri, 27 Jun 2025 20:18:25 +0800 Subject: [PATCH 091/114] =?UTF-8?q?update:=E8=AE=BE=E7=BD=AE=E5=BA=94?= =?UTF-8?q?=E7=94=A8=E5=9B=BE=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mainwindow.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index e76667c..a94fedd 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -5,13 +5,16 @@ #include #include // 新增 #include // 新增 - +#include +#include MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) , m_model(new AppListModel(this)) , m_delegate(new AppDelegate(this)) { + QIcon icon(":/resources/spark-update-tool.svg"); + setWindowIcon(icon); QProgressDialog *progressDialog = new QProgressDialog("正在与服务器通信,获取更新信息中...", QString(), 0, 0, this); progressDialog->setWindowModality(Qt::ApplicationModal); progressDialog->setCancelButton(nullptr); @@ -26,7 +29,8 @@ MainWindow::MainWindow(QWidget *parent) progressDialog->deleteLater(); watcher->deleteLater(); ui->setupUi(this); - + QIcon icon(":/resources/spark-update-tool.svg"); + setWindowIcon(icon); // 创建 QListView 并设置父控件为 ui->appWidget listView = new QListView(ui->appWidget); listView->setModel(m_model); From 6bb3e8dfbf8096891b066821abb75e00141867a4 Mon Sep 17 00:00:00 2001 From: momen Date: Sat, 28 Jun 2025 21:45:22 +0800 Subject: [PATCH 092/114] =?UTF-8?q?chore:=E6=9B=B4=E6=96=B0readme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 519a94b..279140c 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ #### 当前支持的 Linux 发行版 - [x] GXDE OS - [x] Ubuntu -- [ ] deepin +- [x] deepin - [ ] Kylin #### 功能清单 From 4acd2332bf93ede57d8f9cf7371e2d219805668b Mon Sep 17 00:00:00 2001 From: momen Date: Sun, 29 Jun 2025 10:15:05 +0800 Subject: [PATCH 093/114] =?UTF-8?q?chore:=E6=9B=B4=E6=96=B0readme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 279140c..df1ec21 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,6 @@ |应用包大小识别|使用 dkpg 完成| |获取应用 Icon|使用 QDesktopServices 完成| |支持 ACE 兼容环境| | - +|aptss|| #### 联系与反馈 momen@momen.world \ No newline at end of file From 5a84a4d3de15634a49683eb7f8248f3490dd943a Mon Sep 17 00:00:00 2001 From: momen Date: Mon, 30 Jun 2025 10:33:02 +0800 Subject: [PATCH 094/114] =?UTF-8?q?chore:=E6=9B=B4=E6=96=B0readme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index df1ec21..9dfd17b 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,6 @@ |应用包大小识别|使用 dkpg 完成| |获取应用 Icon|使用 QDesktopServices 完成| |支持 ACE 兼容环境| | -|aptss|| +|多线程下载|采用aptss方案| #### 联系与反馈 momen@momen.world \ No newline at end of file From 7cad4937c12672e3e5d044349784ff5b60e6cf76 Mon Sep 17 00:00:00 2001 From: momen Date: Wed, 2 Jul 2025 11:14:42 +0800 Subject: [PATCH 095/114] =?UTF-8?q?chore:=E5=8A=A0=E5=85=A5128*128=20logo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/128*128/spark-update-tool.png | Bin 0 -> 9142 bytes src/icons.qrc | 1 + 2 files changed, 1 insertion(+) create mode 100644 resources/128*128/spark-update-tool.png diff --git a/resources/128*128/spark-update-tool.png b/resources/128*128/spark-update-tool.png new file mode 100644 index 0000000000000000000000000000000000000000..138ed83770cf4cce8fdead9c11908a0446e8a135 GIT binary patch literal 9142 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 AL;wH) literal 0 HcmV?d00001 diff --git a/src/icons.qrc b/src/icons.qrc index 0209761..f81e1f8 100644 --- a/src/icons.qrc +++ b/src/icons.qrc @@ -3,5 +3,6 @@ ../resources/down_arrow.svg ../resources/default_icon.svg ../resources/spark-update-tool.svg + ../resources/128*128/spark-update-tool.png From 38a3b4ee4fb3cbb59bbcc46d941677e6b53da820 Mon Sep 17 00:00:00 2001 From: momen Date: Wed, 2 Jul 2025 11:20:12 +0800 Subject: [PATCH 096/114] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E6=A0=8F=E6=B2=A1=E6=9C=89=E6=AD=A3=E7=A1=AE=E6=98=BE?= =?UTF-8?q?=E7=A4=BAlogo=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.cpp | 2 +- src/mainwindow.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index c834b96..049e23f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -57,7 +57,7 @@ int main(int argc, char *argv[]) // QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough); QApplication a(argc, argv); - + QApplication::setWindowIcon(QIcon(":/resources/128*128/spark-update-tool.png")); if (!isRoot()) { qDebug() << "Not running as root. Attempting to elevate..."; if (!elevateToRoot()) { diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index a94fedd..e54ce43 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -13,7 +13,7 @@ MainWindow::MainWindow(QWidget *parent) , m_model(new AppListModel(this)) , m_delegate(new AppDelegate(this)) { - QIcon icon(":/resources/spark-update-tool.svg"); + QIcon icon(":/resources/128*128/spark-update-tool.png"); setWindowIcon(icon); QProgressDialog *progressDialog = new QProgressDialog("正在与服务器通信,获取更新信息中...", QString(), 0, 0, this); progressDialog->setWindowModality(Qt::ApplicationModal); @@ -29,7 +29,7 @@ MainWindow::MainWindow(QWidget *parent) progressDialog->deleteLater(); watcher->deleteLater(); ui->setupUi(this); - QIcon icon(":/resources/spark-update-tool.svg"); + QIcon icon(":/resources/128*128/spark-update-tool.png"); setWindowIcon(icon); // 创建 QListView 并设置父控件为 ui->appWidget listView = new QListView(ui->appWidget); From 2a88c996079be97bf5076050002fb2853fec657d Mon Sep 17 00:00:00 2001 From: momen Date: Wed, 2 Jul 2025 11:48:35 +0800 Subject: [PATCH 097/114] =?UTF-8?q?fix:deb=E5=8C=85=E4=B8=A2=E5=A4=B1?= =?UTF-8?q?=E5=9B=BE=E6=A0=87=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- debian/install | 2 +- src/main.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/install b/debian/install index ac99078..ed44f2c 100644 --- a/debian/install +++ b/debian/install @@ -1,3 +1,3 @@ build/spark-update-tool /usr/bin/ debian/spark-update-tool.desktop /usr/share/applications -resources/spark-update-tool.svg /usr/share/icons/hicolor/scalable/apps/spark-update-tool.svg \ No newline at end of file +resources/128*128/spark-update-tool.png /usr/share/icons/hicolor/128x128/apps diff --git a/src/main.cpp b/src/main.cpp index 049e23f..a3df5a4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -57,7 +57,7 @@ int main(int argc, char *argv[]) // QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough); QApplication a(argc, argv); - QApplication::setWindowIcon(QIcon(":/resources/128*128/spark-update-tool.png")); + a.setWindowIcon(QIcon(":/resources/128*128/spark-update-tool.png")); if (!isRoot()) { qDebug() << "Not running as root. Attempting to elevate..."; if (!elevateToRoot()) { From 2d53e655f75c5b70dc7e2de209c27b1cd27e5c22 Mon Sep 17 00:00:00 2001 From: momen Date: Wed, 2 Jul 2025 15:32:03 +0800 Subject: [PATCH 098/114] =?UTF-8?q?update:=E6=9B=B4=E6=96=B0=E4=B8=BAaptss?= =?UTF-8?q?=20ssupdate=E6=9D=A5=E6=9B=B4=E6=96=B0=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mainwindow.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index e54ce43..dde2a4c 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -209,17 +209,17 @@ void MainWindow::runAptssUpgrade() { QProcess process; QStringList args; - args << "aptss" << "upgrade"; + args << "sudo" <<"aptss" << "ssupdate"; process.start("sudo", args); if (!process.waitForStarted(5000)) { - QMessageBox::warning(this, "升级失败", "无法启动 sudo aptss upgrade。"); + QMessageBox::warning(this, "升级失败", "无法启动 sudo aptss ssupdate"); return; } process.write("n\n"); process.closeWriteChannel(); process.waitForFinished(-1); if (process.exitCode() != 0) { - QMessageBox::warning(this, "升级失败", "执行 sudo aptss upgrade 失败,请检查系统环境。"); + QMessageBox::warning(this, "升级失败", "执行 sudo aptss ssupdate 失败,请检查系统环境。"); } } From 9bf218cfeefea2cdabd8a9f5584a1c931c1d6e7a Mon Sep 17 00:00:00 2001 From: momen Date: Thu, 3 Jul 2025 14:31:57 +0800 Subject: [PATCH 099/114] =?UTF-8?q?chore:=E6=9B=B4=E6=96=B0readme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 9dfd17b..ae2026a 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,29 @@ ### 星火软件更新器 + #### 简介 -欢迎使用星火软件更新器,您可以使用此更新器更新位于您 Linux 计算机的程序。 +欢迎使用星火软件更新器!本工具可帮助您便捷地更新 Linux 计算机上的各类程序。 + +本版本专为仅包含 Qt5 的 Linux 发行版设计。 +**请在 root 权限下运行本程序。** -此版本专为仅有qt5的Linux发行版所使用。 -请在root环境下运行。 #### 当前支持的 Linux 发行版 + - [x] GXDE OS - [x] Ubuntu - [x] deepin - [ ] Kylin #### 功能清单 -|功能模块|描述| -|--|--| -|应用名识别|采用 `ss-do-upgrade.sh` 部分代码| -|应用包大小识别|使用 dkpg 完成| -|获取应用 Icon|使用 QDesktopServices 完成| -|支持 ACE 兼容环境| | -|多线程下载|采用aptss方案| + +| 功能模块 | 描述 | +|------------------|--------------------------------------| +| 应用名识别 | 基于 `ss-do-upgrade.sh` 部分代码实现 | +| 应用包大小识别 | 通过 dpkg 获取包大小信息 | +| 获取应用图标 | 利用 QDesktopServices 实现 | +| 支持 ACE 兼容环境| | +| 多线程下载 | 基于 aptss 方案 | + #### 联系与反馈 -momen@momen.world \ No newline at end of file + +如有问题或建议,欢迎联系:momen@momen.world \ No newline at end of file From ce9aa95eacbf1ae3efb6e9261c3a9c5eb696d276 Mon Sep 17 00:00:00 2001 From: momen Date: Thu, 3 Jul 2025 19:00:11 +0000 Subject: [PATCH 100/114] add LICENSE. Signed-off-by: momen --- LICENSE | 674 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 674 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..3877ae0 --- /dev/null +++ b/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. From 934062aa3bc51dfbce33673e1ed1387716c63ab7 Mon Sep 17 00:00:00 2001 From: momen Date: Fri, 4 Jul 2025 03:18:54 +0800 Subject: [PATCH 101/114] =?UTF-8?q?chore:=E6=9B=B4=E6=96=B0=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E6=A1=86=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mainwindow.ui | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 2a58287..a53a4b8 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -49,7 +49,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -120,7 +120,7 @@ 0 - + 200 @@ -144,7 +144,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -193,10 +193,10 @@ - Qt::LeftToRight + Qt::LayoutDirection::LeftToRight - QComboBox::AdjustToContentsOnFirstShow + QComboBox::SizeAdjustPolicy::AdjustToContentsOnFirstShow From e69deb4b95f6f56276bd1e584c44bf2e4ef1a726 Mon Sep 17 00:00:00 2001 From: momen Date: Fri, 4 Jul 2025 04:08:09 +0800 Subject: [PATCH 102/114] =?UTF-8?q?=E5=B0=86=E6=9B=B4=E6=96=B0=E5=99=A8?= =?UTF-8?q?=E5=90=88=E5=85=A5=E5=88=B0=E6=98=9F=E7=81=AB=E5=95=86=E5=BA=97?= =?UTF-8?q?=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spark-update-tool/.gitignore | 62 +++ spark-update-tool/CMakeLists.txt | 58 +++ spark-update-tool/README.md | 29 ++ spark-update-tool/debian/changelog | 5 + spark-update-tool/debian/compat | 1 + spark-update-tool/debian/control | 13 + spark-update-tool/debian/copyright | 7 + spark-update-tool/debian/install | 3 + spark-update-tool/debian/postrm | 11 + spark-update-tool/debian/rules | 7 + spark-update-tool/debian/source/format | 1 + .../debian/spark-update-tool.desktop | 9 + .../resources/128*128/spark-update-tool.png | Bin 0 -> 9142 bytes spark-update-tool/resources/default_icon.svg | 1 + spark-update-tool/resources/down_arrow.svg | 1 + .../resources/spark-update-tool.svg | 1 + spark-update-tool/src/appdelegate.cpp | 321 ++++++++++++++ spark-update-tool/src/appdelegate.h | 46 ++ spark-update-tool/src/applistmodel.cpp | 62 +++ spark-update-tool/src/applistmodel.h | 26 ++ spark-update-tool/src/aptssupdater.cpp | 398 ++++++++++++++++++ spark-update-tool/src/aptssupdater.h | 28 ++ spark-update-tool/src/downloadmanager.cpp | 117 +++++ spark-update-tool/src/downloadmanager.h | 28 ++ spark-update-tool/src/icons.qrc | 8 + spark-update-tool/src/main.cpp | 86 ++++ spark-update-tool/src/mainwindow.cpp | 229 ++++++++++ spark-update-tool/src/mainwindow.h | 33 ++ spark-update-tool/src/mainwindow.ui | 256 +++++++++++ 29 files changed, 1847 insertions(+) create mode 100644 spark-update-tool/.gitignore create mode 100644 spark-update-tool/CMakeLists.txt create mode 100644 spark-update-tool/README.md create mode 100644 spark-update-tool/debian/changelog create mode 100644 spark-update-tool/debian/compat create mode 100644 spark-update-tool/debian/control create mode 100644 spark-update-tool/debian/copyright create mode 100644 spark-update-tool/debian/install create mode 100644 spark-update-tool/debian/postrm create mode 100755 spark-update-tool/debian/rules create mode 100644 spark-update-tool/debian/source/format create mode 100644 spark-update-tool/debian/spark-update-tool.desktop create mode 100644 spark-update-tool/resources/128*128/spark-update-tool.png create mode 100644 spark-update-tool/resources/default_icon.svg create mode 100644 spark-update-tool/resources/down_arrow.svg create mode 100644 spark-update-tool/resources/spark-update-tool.svg create mode 100644 spark-update-tool/src/appdelegate.cpp create mode 100644 spark-update-tool/src/appdelegate.h create mode 100644 spark-update-tool/src/applistmodel.cpp create mode 100644 spark-update-tool/src/applistmodel.h create mode 100644 spark-update-tool/src/aptssupdater.cpp create mode 100644 spark-update-tool/src/aptssupdater.h create mode 100644 spark-update-tool/src/downloadmanager.cpp create mode 100644 spark-update-tool/src/downloadmanager.h create mode 100644 spark-update-tool/src/icons.qrc create mode 100644 spark-update-tool/src/main.cpp create mode 100644 spark-update-tool/src/mainwindow.cpp create mode 100644 spark-update-tool/src/mainwindow.h create mode 100644 spark-update-tool/src/mainwindow.ui diff --git a/spark-update-tool/.gitignore b/spark-update-tool/.gitignore new file mode 100644 index 0000000..79c9ac7 --- /dev/null +++ b/spark-update-tool/.gitignore @@ -0,0 +1,62 @@ +build +.vscode +.cache +CMakeLists.txt.user +CMakeLists.txt.user.* +obj-x86_64-linux-gnu +# C++ objects and libs +*.slo +*.lo +*.o +*.a +*.la +*.lai +*.so +*.dll +*.dylib + +# Qt-es +object_script.*.Release +object_script.*.Debug +*_plugin_import.cpp +/.qmake.cache +/.qmake.stash +*.pro.user +*.pro.user.* +*.qbs.user +*.qbs.user.* +*.moc +moc_*.cpp +moc_*.h +qrc_*.cpp +ui_*.h +*.qmlc +*.jsc +Makefile* +*build-* + +# Qt unit tests +target_wrapper.* + +# Qt qm files +translations/*.qm + +# QtCreator +*.autosave + +# QtCreator Qml +*.qmlproject.user +*.qmlproject.user.* + +# QtCreator CMake +CMakeLists.txt.user* +build + +# Debian dpkg-buildpackage +debian/*.debhelper* +debian/files +debian/*.substvars +debian/spark-update-tool + +.vscode/* +src/spark-update-tool diff --git a/spark-update-tool/CMakeLists.txt b/spark-update-tool/CMakeLists.txt new file mode 100644 index 0000000..49a4d5e --- /dev/null +++ b/spark-update-tool/CMakeLists.txt @@ -0,0 +1,58 @@ +cmake_minimum_required(VERSION 3.16) + +project(spark-update-tool VERSION 0.1 LANGUAGES CXX) + +set(CMAKE_AUTOUIC ON) +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + + +find_package(Qt5 REQUIRED COMPONENTS Widgets Network Concurrent) + + +find_package(Qt5 REQUIRED COMPONENTS Widgets Network Concurrent Core Gui) + +# 定义所有项目源文件,现在无需条件判断 +set(PROJECT_SOURCES + src/main.cpp + src/mainwindow.cpp + src/mainwindow.h + src/mainwindow.ui + src/aptssupdater.h src/aptssupdater.cpp + src/icons.qrc + src/appdelegate.h src/appdelegate.cpp + src/applistmodel.h src/applistmodel.cpp + src/downloadmanager.h src/downloadmanager.cpp +) + + +add_executable(spark-update-tool + ${PROJECT_SOURCES} +) + +target_link_libraries(spark-update-tool PRIVATE + Qt5::Widgets + Qt5::Network + Qt5::Concurrent + Qt5::Core + Qt5::Gui +) + + +set_target_properties(spark-update-tool PROPERTIES + # ${BUNDLE_ID_OPTION} # 如果上面取消注释,这里也取消注释 + MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION} + MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} + +) + +include(GNUInstallDirs) +install(TARGETS spark-update-tool + BUNDLE DESTINATION . + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} +) + diff --git a/spark-update-tool/README.md b/spark-update-tool/README.md new file mode 100644 index 0000000..ae2026a --- /dev/null +++ b/spark-update-tool/README.md @@ -0,0 +1,29 @@ +### 星火软件更新器 + +#### 简介 + +欢迎使用星火软件更新器!本工具可帮助您便捷地更新 Linux 计算机上的各类程序。 + +本版本专为仅包含 Qt5 的 Linux 发行版设计。 +**请在 root 权限下运行本程序。** + +#### 当前支持的 Linux 发行版 + +- [x] GXDE OS +- [x] Ubuntu +- [x] deepin +- [ ] Kylin + +#### 功能清单 + +| 功能模块 | 描述 | +|------------------|--------------------------------------| +| 应用名识别 | 基于 `ss-do-upgrade.sh` 部分代码实现 | +| 应用包大小识别 | 通过 dpkg 获取包大小信息 | +| 获取应用图标 | 利用 QDesktopServices 实现 | +| 支持 ACE 兼容环境| | +| 多线程下载 | 基于 aptss 方案 | + +#### 联系与反馈 + +如有问题或建议,欢迎联系:momen@momen.world \ No newline at end of file diff --git a/spark-update-tool/debian/changelog b/spark-update-tool/debian/changelog new file mode 100644 index 0000000..b414fea --- /dev/null +++ b/spark-update-tool/debian/changelog @@ -0,0 +1,5 @@ +spark-update-tool (1.0.0) unstable; urgency=low + + * Initial release. + + -- momen Wed, 18 Jun 2025 00:00:00 +0000 \ No newline at end of file diff --git a/spark-update-tool/debian/compat b/spark-update-tool/debian/compat new file mode 100644 index 0000000..f11c82a --- /dev/null +++ b/spark-update-tool/debian/compat @@ -0,0 +1 @@ +9 \ No newline at end of file diff --git a/spark-update-tool/debian/control b/spark-update-tool/debian/control new file mode 100644 index 0000000..19c9d62 --- /dev/null +++ b/spark-update-tool/debian/control @@ -0,0 +1,13 @@ +Source: spark-update-tool +Section: utils +Priority: optional +Maintainer: momen +Build-Depends: debhelper (>= 9) +Standards-Version: 3.9.6 +Homepage: https://gitee.com/spark-store-project/Spark-Update-Tool + +Package: spark-update-tool +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: Spark Update Tool + 星火应用商店更新组件。This package provides the Spark Update Tool. It includes features for checking for updates, downloading, and applying them seamlessly. \ No newline at end of file diff --git a/spark-update-tool/debian/copyright b/spark-update-tool/debian/copyright new file mode 100644 index 0000000..163489e --- /dev/null +++ b/spark-update-tool/debian/copyright @@ -0,0 +1,7 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: spark-update-tool +Source: https://gitee.com/spark-store-project/Spark-Update-Tool + +Files: * +Copyright: 2025, momen +License: GPL-3.0+ \ No newline at end of file diff --git a/spark-update-tool/debian/install b/spark-update-tool/debian/install new file mode 100644 index 0000000..ed44f2c --- /dev/null +++ b/spark-update-tool/debian/install @@ -0,0 +1,3 @@ +build/spark-update-tool /usr/bin/ +debian/spark-update-tool.desktop /usr/share/applications +resources/128*128/spark-update-tool.png /usr/share/icons/hicolor/128x128/apps diff --git a/spark-update-tool/debian/postrm b/spark-update-tool/debian/postrm new file mode 100644 index 0000000..263e9c4 --- /dev/null +++ b/spark-update-tool/debian/postrm @@ -0,0 +1,11 @@ +#!/bin/sh +set -e + +case "$1" in + purge) + + rm -rf /usr/share/spark-update-tool + ;; +esac + +exit 0 \ No newline at end of file diff --git a/spark-update-tool/debian/rules b/spark-update-tool/debian/rules new file mode 100755 index 0000000..1159ac4 --- /dev/null +++ b/spark-update-tool/debian/rules @@ -0,0 +1,7 @@ +#!/usr/bin/make -f + +%: + dh $@ + +override_dh_auto_configure: + dh_auto_configure -- -DCMAKE_INSTALL_PREFIX=/usr diff --git a/spark-update-tool/debian/source/format b/spark-update-tool/debian/source/format new file mode 100644 index 0000000..9f67427 --- /dev/null +++ b/spark-update-tool/debian/source/format @@ -0,0 +1 @@ +3.0 (native) \ No newline at end of file diff --git a/spark-update-tool/debian/spark-update-tool.desktop b/spark-update-tool/debian/spark-update-tool.desktop new file mode 100644 index 0000000..688ba0c --- /dev/null +++ b/spark-update-tool/debian/spark-update-tool.desktop @@ -0,0 +1,9 @@ +[Desktop Entry] +Version=1.0 +Name=Spark Update Tool +Comment=A Qt-based application for managing and updating software +Exec=spark-update-tool +Icon=spark-update-tool +Terminal=false +Type=Application +Categories=Utility; diff --git a/spark-update-tool/resources/128*128/spark-update-tool.png b/spark-update-tool/resources/128*128/spark-update-tool.png new file mode 100644 index 0000000000000000000000000000000000000000..138ed83770cf4cce8fdead9c11908a0446e8a135 GIT binary patch literal 9142 zcmV;nBT3weP)Px#8FWQhbW?9;ba!ELWdL_~cP?peYja~^aAhuUa%Y?FJQ@H1AOJ~3 zK~#90?VWji9mSRJztw#gNtP_zk{4`)H}HyWzyyq0%o?z<4FMAqAcQ0^A<9HEXur0hx-X%+S>#p}l-KD#4Z};j- zmci$vtJ}A`>eT7}ovJ#g>QuFmQgVVmxuhLy0Z!1drASW}CWH_@S>EwVvIm>xZdCvm zz=M8&QppCm^RacOLR4G<9H5JUZ)dts8aaWLZr|2NT4`mdr~+icw}Nc_;Pd@SCs*LJ z-_{R8h>9vfMHIkN>vLdhI22&hEw@Yx@8J33cPeCmlNiWR_wLW@udMG#%# z;RCz|h;3iGb^4I%J~zdLHctpKNC7L{0S+riSAfcxmFHMQ zKK1A-3JPHTR$RIOV%Z8{Y3{AyYxBm9i#~Me%msCk=r=VX#v=jY0eX&l0(@{+fL;i` z^Smi#Q(GqW(_8ubacSJ1CUC&Br8^yjA<@=t+n+V zm%O-i2L(kaO9?_NfTh3B)p{M!_TGN`tbsMv|07@kLK51rk47O9fkXmKkG>fy13sv- z48xsQO%0rRCQO(BC!M6ubsR<3)RZQZABB0&2M)rvX2ix1;e!p3OnR0pCHq>Fop%gg z^vH`S@C_`6Vpv58r2r1_^PjebcYe1v68#Y%N^3s4R zoeN0krU04-=bj4}TmV&7c4i$N?h4Rd;5#XqgthAtD_)1aEnely_Eh>G>mGmbZpu`G zQWPLx^M``IdEvslsw4WsLZaY%QX+el7m2`xi79F~Ozz5JHU|JL)7K7`q zgVRoPXXd5=Jq5nBS9R7lA(s6S4jyuqr_)H^d+MVPerK0b0D}^`gFppv^!YlVbu3(X zcOLvwYkm+#qj1s1(5DY9e+3R%Zn|9XB}&0^3J{ILZMVUYA>PcK3UDmIw^BNd_~V~o zXx!{mT2&e7y+|p z!>U#A{(D^m9|{T}gsS-yC;Bt9D!{P@-%1-cAs&AUIy-R;9MF+5e%R;n2dv#eU{?@E z0djr5zW2*tzG_gPnx|BcAJX9KKLEyzQMGMAgX(K_4NM6~jzDV*Y~2D|w?f9zN7vTE z{2O4)hp>FP{aPvDgX#jL0h1;v1qfo6Q-IzCevVpN5%)g~hq7KuA**anBo_=?{P43_ zT7t3^z}fV#y6O5;&S@OFN?H3Mgd95-W}FXw>tWkg*tru99Dw#VNTpSctf^5}_t>#Y zIo^E--h5Me207AoSa2h3-VAT7a^7%({J_t30Ybu^cS1vhM?wpAbRereyZ}GyZt!z- z=rH0}_Z5^N&r0rJwXb#hj2D+~Cxkr^G#8L>0j3QY@{3U5*Vn^Uvmq9R6)RNj^>g#u z+u-mK)jXehCM;YCFT4or*Qp1S$-tr~;0w3Go;|Q_TQQFy@N;zPso}scmwF0(fckpm zmp+g9^?hnA0YHL)hEFv#+yh*XWu(xHjcY`ZbEL2J_S>(GXxf#^&-bCJXTTS~3{C6d zq2I#hP5$5m>_4E=YZ^2+!^HlW??WXordS0g*kH|9=GS8Hchn>Ir0J@R7>M| zv5VA`;ODXp8i-tQy?RcT5ylAGtd{vV&B219S1^uWNSFY`ym8}V4b@fu=G*5B0iV7S zF1s9_ehOBwdbG0gt@q#51Y5SksL}AuGjQGvm@~Ja1iSaZrcE$o zhUGy>7&#KoImiBBoX6I*t{1yV#{&EujXMp_pI*3-RfL8}{6FS3j*DTRjxVC3F2FI# zqdj!#%mqR)%6Dk@vddx0RCw%B*s;BEe&k5_)H!hSDavY1rKRgF>=fUAau>4hZefe_LhrjU#96hSewY9-nXTj@#@qS3Thh10aa{H zQ33qAzA$$#Xga+2u4)xB8Ffw9;k2Ax;mu{Uf@Tg%KLB*vUpKdweM{Q=C5QP@YmaD6nWJZ zh~GVt!ylxiHWvLh@Hh%fS6jf=1vsa8w|(i>>6#`ccs3wIhN#-Q{1s*FfdX{aY-IpG z@(`?BTL2%FtJl;7zk5X43C+zgd9oT3&e2o<9uB~3JT)77%}f z5BCNiAe}}EVgG2F`UtmAfVJCOz|YZ?NicYD9(({@Fk#E=>pq1AQ>QK9WdjI646g2T zlj7*|Fob~FbD()!!95!@Mtv49g6$s#-^lju@W{jP)4O5M?!tM~R5g9-RHXzXMnGeu zy0Nx4HBMevr}&K+q4ErJ%=C42rqMS~F9RPy2;_w`idwkA)qQTp#}05)00D@hpv5(P zu4mtW`su1aU-rBzbl^Z3It*TZ$=&kzx)CYuet$0Q+O=x5Zp#*>Y}PURojX<80Ez63 zS;GK3Pq%Wy%H&7A5&RrYnWW}8EM->ddd?egRRX615G zYR+5;)nvc6qO=?F10|7wg9nx22!)ysYTO_-|Xw+S%Fm#-N4$P4=7tG8nN(_=!l#F6=(zGN!PT|E~Tl5ABiaI z-%~2b??Hprgic*w*tZXc4OcGY`X=~jyGwqlMh{1gQU+f`1GKajc-PiKd%OBwSEs&h zkwgvwB*jC>Vd!`RACx`Tn49lVt$;2V>BYm@ZWinSwP?dyn)>cjtD1kW8+D!*0hEpvdg*QC#x0!KxW;;?c4pqA2kXt zy;L>(^X94Z9UW?DITlqmK_&y$)k+xvcI@y59~`rQ0dyRL4?sL>0Urdi)+?#24RGtdK>s)Y2;;~c;3^&KEa8$=-MDZzrzA{E-c#`j45Sdo<5a=9Xpls^{ZE9 zEq)R%$-1%i_0ZCy6lB;iIOP;|-fJc>cU%>Rlbivd9`cq#y%GF8e=GRjc}w3SX3G|3 z%=z)P3cGht;rPfA^*wpAGRku4Hf>VJu^0>=rdo<4N8pj)!T9m2|29qaS(Tl4xah)c z-p#OeTd_RW<544(SK&n;C-C!mECu>x_X!D;xQ-oIh8bN+*Okwo3*FkfRfTr<>!*Ot zxsvne!=gpXeOtK_Hh&0XPg7IKd-tkAqUqUh9_LhCVX7<~1saP`&7_>0A0 zTeAXq_;C2j9dPkX#k2V%rC2Y&tc=2WbJY38PpNSQAMlApVA2F{c}u?cUJiafkJSzI z=2Q9x5kbv#v7L9#Jme=FO^>pMSnmkUe{pcTiQO{QYUu+>GOB(RK{K;qLd&Pu<_?VtH>WvMqpc; z8s*E)_T|Vl)g;i~y=u&%r3HR-pBnqWW}Y(q?tc*0uMY+vkTcHpmp3dOH{eqYz7Mz~{76RT+NrhPwCT2z=)`=`TpQE+8!UxwNmpt}J~aRE@p)W_aNR zRjXI7gf(kn`gAprQ&*Q=k6#PzN0sutzgiiEIh$hMTzKz&wP-}jaNrApyyT)_c?0kL zcm&`2UA7nCU{*@Ot*t7gD;KUkVg!8UE6N*KvQ&8pFTSW2fYj8eA>BkmwE#}O)m3WX zCpY>S27G`ilMCYnUh)Rf@d&<6hOT-6<$#}~KmXajvKN#qcU zrGyW+ln#DX9C_sx{_+OV@eF=W5bIcg2YI&u9>V~kBW#jMc=lN}u5VqrbMkQb+i$>z zjj(Z}0@xW7=vGcx@Buk{7WA$2mN$sH5q!CO59Yd!(6SG?rv-WN5VEQoqqYy2CbBbu zkOEO(i#BX9`UU5pH997;N(H}5T|iL5Zp?G(wr+)c?}dg&xa1NTn%#b-x*E=ysy>FH zX7aZ0P{!Sko%XqXXBh$DGi5TIb%wXRK~!Pz&3D(ppOzz9_aRIJP1g{~G-i8ezJ5s{ zeKh6X5PAP!Ou}L1!tWJFTMaHMykOb>#(e@D;vQY^tt?1 zc==DoWdwmgcrfzXx!&>yQH8*l8#W^sFGV|a5M9sSt3WMG0f^XpUIE175t0dqOAKHb zr0#nh{mj!5RUv~~oc({72ZG84U!wZ>r=EsSUjawj;P;E+`s>_d_;NJ;T;(PnI#k#> zD-u;>1}j#&msQsndF##D(63_yzI<{CV$B+~&a@qH2MJ9tI;Tf8G+o0qibLvUXD8eC1L ze-(v#4eCAoSrnQKe26~9S5p&An06QL!(Akl4&0=h64psn{7BXNMAV2{s0lxKk z=T3O^aRu<`(Q4-Jq#?>isPC&3!!Xo%!Oq=k=5fO&$NqVavikKy-u8JF2iL>k%MBY5 zix;C+=@84-_O!=VbPf_i6g^6z3G|4L;oK<&Fq?M<%47c>3_g_V1#|^`YuaQ|Mfo%} zb;;Ui$PnZgZq6tXPJ`Tx*54?>lrIS;7-Uadqdrqk)70CM+UUwQ1p;Q+s@Hh>q8 zu7KCo{8OhWgD>i_AS8&&1Yhpii}=lbs@7``6qA|o;{eXQSrVFXwFS)m2bIju?$ZfA zF5q|B4eU+e*Hj~~o()qcd-D#WGQl@re-r)Hmy2tCj*=m3Kj3F5M4}ogr!kmHBagHr z>gx*UT)?*BSJE#M0QQzs*5U0Il6?8%zHcq#gp^+hgRo(u`8fbDQXQbgBDlPP)> z=KcfdIRz*M{IcD^-T=N3Fkw9Ml9~3nzMcgCp~uknHhVVPK(_fWg}+Z)q1?iZb9?*! z2VwMxih&PZ9SQ7C@Z)iqayoMQIpweY?`j@EKDr2P???Wws{}eT-q+p8xplpRG+i%x zzkzw+FnS>P*2}^7T>eO4cYt5t7eGg;Pj?KdDb0%E}AAH?Fi^VCWvbJ+OYWwk)QVsP+V}-3@tiotQ#rDVJP*;a+Y*Y&x zhn^I?dZ#B1zE@sD-?lM0WX7cQ+7E#(fDoW*0@I>cGL;)DE)o2)yZ{sOOSu3BH$aPr zFIrWlR_x^V+wao{X=J>Id&|M3Cu{!BJ?L+&@EppuQG2TNa*W)IKKw~&ntcsMDn%gp zP6}`Y{9Aw^(si|u&n1@>cI*g}te1n2VIm&9AL1Uao|RIDGXAW^8WJ-ehsFj(B!WD2 z812Ym^`@^}gX;D2DhFx0z_7CS>vr8J4}Q5`fFIS=zzsLpqi%vE>+Rr6kaztIEe!ak zgf{ySwJ~A@;*KvMB8B|9Ra)k|s}YYsg{BLn%SfLa6>aVri{#}Dq!8dkxe8EU54YZ` zB7B^s`Uq4q^)UG6{STq*AqR7gr1FNJG)&B!Z$wP>-c&`LH5JaBg846Z!Qu8$ML4}q z5sg+9dS)sG9#V17H6B8T13Y!o36GXu2@wFTtEU%NKkb{pi~mjUirM1;wss zZU?XcQqw@;o<*<%IQd+5S>eS>o{7R;^3K!4HUGaKKx_UWc$yj@kx_16mW=8e#D(XT zB%l7>{}sFuCB~N1@KdVGQfvYjlhq=e*5ybkD~3`hKTC^OUA9# znTGb_cs=P7+7(tlar%VdCuqqps;dxn9y`612|kpf0QLP;7m(v#N$LUc<<8xR2Od!K z_|Xt<9;n-FPeQ`OGw|y*g5=XQWC<*^@nhV(DUWi(KArGEp}FnYjz{pHdl7BzyWaEo zZj_PGmh^t(I3Ntu{b_`dPaZfF>~L5O#|dM7ulw`yz7#$vw6USU$?r8Vxobhqqm_3l zR4Vwt_%&MMu=hNEQ3h0#-;oZ~bs<0|QxLbfXCdV?|ME`oG=qheKGC57C4ujqHoyz8 zWZb?Z?_K8i*>~G-UymU5NU&Ai6X4(Va|M1F-yW22e<-2+{4hmn0{Q6T(&dxD^4Efs zWh;{y&=2io%PQvzfe&4s3kc@lHQrswBk%gZXu>_jx`@)Is`05(Lb?=bO&=hW$ z-j2S0wOXBHpyu5TslHQY(Mp_3k|quK&!1z|)FP*zj+izTbRBa`GrYeBv3?^W6FzVx zSNo$^Us@vg*+biT?<{2mg@%*Go~MUK`2OpDvhCloAx%S1bRb{*3+D4LsZ(XL%47_* zA%loa_t-$oNo9Z!zB`46JQqYg1ity$Q)tH${4B|gf!XG=mvSjQq{K8#V)L&KH(FUH z_)v*WqI~o8P|eR6Xz#pNdcF#i0>7inV`Z6)i9U7=`q^iMD71X=q5Kvqn0hjR^OyG_ z!o=@&Bgu3I^GHX@(ZOzH2#wespYvab0HMM6TOeM77f`~D_3(VYW_?}lF(8>pWov!~ zz|WXOZkUHQI3Q@m6MVZ2GGJCHq!-Y8!3USvIR|f33gqCyaQ?Z_eiZTYE6Qr`DoHRq z639fz0jCgToIITPWfumNTN&^nlo!yu!OtDqR6t5hErL05JogoA!3Pji zCn2UzD!z~}%DpUc(G1K%1JUk(I9Lg!L?+Uhoym&y^+oJ2n~64Us&D!ELyz<2Q04au z4#lf-;0G7wpGk~A4f9*yKzdp4rituGVjOJ8>_~JA_~w{VXxGp2PS8!@Ls#Yk$`zm& zfuAEWs1f;tZxzBEq(ml_TW1_R+HJKSz^ti3|GPWA6I1|vzoeyyg_j{fm-6_@;9FFQ znflhjKmP-1EvjmJdj~R|DX;L5BmwQ~cX*HXl>@%hJ}P@C*o9eWu9eE;CxdTMWy%+i zq5t^%n3KkLC+>wJCyqyq815}k?$G0WaUM?=o>bagKv=Go$m1u2Z&4vLNr~LK8}q}h zaJ0jAN&ouo$g3{*$XFRN(a^s5IZxU0haTsP^Vok#>3PvcUEeFXJMuucfiK(IFz&ez zt$8~FnP0pqV=?5JQ_yd{0U{B!>tf`s2mRDh_KTGS-!X_+0WY9LRC*!!a>s7O`hcZaSrW-4#siPp3 zL;KmkVvZSAhMbaAGEFL}Ru}1$$JvK_D-M1*77)q{kk%i;)C<7}Fdlq7baXfX@2#*8(&AAmLo-X@2!W1A<>7QirNvn~1l{q6$xa`4TqA0dKTFAvhr zn&K;`7&QW;u8wrdpz~-d3%qxHfIf91+VFx)*)8BpiEQ0xOJiVc^J4940{|FOZnPDU z&VX~_LoWv(DKS>Br}JovL}!{z+EDB5La;JMjYRaV3rr_xo=-ZJ36@XOiG6l%A)iA| z?*cr2cw~{S`yscXWY&n!NV&-?m)A(3Od7_zxO0W?wq~`fXOPf-)PvvyWLCWkfN7Zd zE!c$sP1n$bKxo+y*?s&3aMBPW-&z=|7}4LkS(ZCRFTVh7nA%&ZyTAu9H*B`0kw6N$ z&MQ~G1(1cOECF`3wJmoh7Mnf{7TS+`7<_Zz0nCqzU$r8o>aWvjgH$p@vNKJhGeshi z!JK^s`agaBr#Vv0fj(t2|Ley^UoVCxdV+r3CLYwCJp0RTb5K3)`owmp#=BJQh|x5%=_y@ zWz)}_M)kja4}JWpC6^-)9P&vB@!J-lk3OaQ!3WH@S3@dkOPWv^O3TMaUhSL& zj~2411F_=u(z<|S1U`UtY5uLG4Q{0BI}54$+HL;9m_FqgTbezSM(18ZAQ-unyXWWQQd$@wE+fBrdC?Kf~~{=q{5 zz}^Y~diwLXFOCQ?+m@)R8hPiJVDP|T!M*P1I0oM>T~C59ckLy8_r1tmOk?(XM#|^v zmp}7aviqdqQTrh{ASBm+m~Zae_YEo8XS>qbiMan^IC$s;_(er_Gx+-tlD_A^i@=wX z*0(zL{ViGC0=W822irXY^ZaGc>}*LTZwD;fV@f!D81Y~K1ABblZR^gzr1aTLA=7#M z_?Uoi?#|ZygNN7bj@F^Sozpf+m;1fkPAK<8w`N5zS&;E=;zpplo zD^~%)W)SA=0j=Yv+wQ8?BVQ{LPzdE6eEL$)jT29R@AwfG{A7~Ml4TfwdacOd14x+W zJq@oe`5pz}O#*5^girvm8H57Rhl0NO=G*S777_cDnauv{SC5>1B}|!QTYrB7e8-P4 z;7f`5_WNX>e74Z!JMwlK<}aqKSn|DHkf8+dp)>^mr3Cp;+k!8AyEYpAC&-1_TQyU{ zph3u)=fmVl$au)DRIT($20xL+e0w#6oiwxKlN~8QRIa2h_R!QqenwS|H^G9{c!|h{0 z<@I7IF^_ga`%z>|Yf&VR7x)<|pIh19^1o-l^ZHI4;D-f1MRR=)T)cEGL2q5FF`>XHKFnRqKg{H_*Ebe2yxj0C{GGZUGz$U^(aZ{YfY3 z^KAp2E;RRUR8a*0TWbK}f&Zi`g7e|~DS|qvFklr|02}k-JzP%!?@nHdpnh~CNZqOc zMTPlp>U)B6)SZAksYeyy1ob{Twwvsqpkq$|AM*Vy)j-fNXaE2J07*qoM6N<$f(zKx AL;wH) literal 0 HcmV?d00001 diff --git a/spark-update-tool/resources/default_icon.svg b/spark-update-tool/resources/default_icon.svg new file mode 100644 index 0000000..7c9cb42 --- /dev/null +++ b/spark-update-tool/resources/default_icon.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/spark-update-tool/resources/down_arrow.svg b/spark-update-tool/resources/down_arrow.svg new file mode 100644 index 0000000..4989662 --- /dev/null +++ b/spark-update-tool/resources/down_arrow.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/spark-update-tool/resources/spark-update-tool.svg b/spark-update-tool/resources/spark-update-tool.svg new file mode 100644 index 0000000..3d21d81 --- /dev/null +++ b/spark-update-tool/resources/spark-update-tool.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/spark-update-tool/src/appdelegate.cpp b/spark-update-tool/src/appdelegate.cpp new file mode 100644 index 0000000..1a1c3e9 --- /dev/null +++ b/spark-update-tool/src/appdelegate.cpp @@ -0,0 +1,321 @@ +#include "appdelegate.h" +#include +#include +#include +#include +#include +#include +#include +#include + +AppDelegate::AppDelegate(QObject *parent) + : QStyledItemDelegate(parent), m_downloadManager(new DownloadManager(this)), m_installProcess(nullptr) { + connect(m_downloadManager, &DownloadManager::downloadFinished, this, + [this](const QString &packageName, bool success) { + if (m_downloads.contains(packageName)) { + m_downloads[packageName].isDownloading = false; + emit updateDisplay(packageName); + qDebug() << (success ? "下载完成:" : "下载失败:") << packageName; + if (success) { + enqueueInstall(packageName); + } + } + }); + + connect(m_downloadManager, &DownloadManager::downloadProgress, this, + [this](const QString &packageName, int progress) { + if (m_downloads.contains(packageName)) { + m_downloads[packageName].progress = progress; + qDebug()<save(); + + if (option.state & QStyle::State_Selected) + painter->fillRect(option.rect, option.palette.highlight()); + else + painter->fillRect(option.rect, QColor("#F3F4F6")); + + QFont boldFont = option.font; + boldFont.setBold(true); + QFont normalFont = option.font; + + QString name = index.data(Qt::DisplayRole).toString(); + QString currentVersion = index.data(Qt::UserRole + 2).toString(); + QString newVersion = index.data(Qt::UserRole + 3).toString(); + QString iconPath = index.data(Qt::UserRole + 4).toString(); + QString size = index.data(Qt::UserRole + 5).toString(); + QString description = index.data(Qt::UserRole + 6).toString(); + + QRect rect = option.rect; + int margin = 10, spacing = 6, iconSize = 40; + + QRect iconRect(rect.left() + margin, rect.top() + (rect.height() - iconSize) / 2, iconSize, iconSize); + QIcon(iconPath).paint(painter, iconRect); + + int textX = iconRect.right() + margin; + int textWidth = rect.width() - textX - 100; + + QRect nameRect(textX, rect.top() + margin, textWidth, 20); + painter->setFont(boldFont); + painter->setPen(QColor("#333333")); + painter->drawText(nameRect, Qt::AlignLeft | Qt::AlignVCenter, name); + + QRect versionRect(textX, nameRect.bottom() + spacing, textWidth, 20); + painter->setFont(normalFont); + painter->setPen(QColor("#888888")); + painter->drawText(versionRect, Qt::AlignLeft | Qt::AlignVCenter, + QString("当前版本: %1 → 新版本: %2").arg(currentVersion, newVersion)); + + QRect descRect(textX, versionRect.bottom() + spacing, textWidth, 40); + painter->setFont(normalFont); + painter->setPen(QColor("#AAAAAA")); + painter->drawText(descRect, Qt::TextWordWrap, + QString("包大小:%1 MB").arg(QString::number(size.toDouble() / (1024 * 1024), 'f', 2))); + + QString packageName = index.data(Qt::UserRole + 1).toString(); + bool isDownloading = m_downloads.contains(packageName) && m_downloads[packageName].isDownloading; + int progress = m_downloads.value(packageName, DownloadInfo{0, false}).progress; + bool isInstalled = m_downloads.value(packageName).isInstalled; + bool isInstalling = m_downloads.value(packageName).isInstalling; + + if (isDownloading) { + QRect progressRect(rect.right() - 270, rect.top() + (rect.height() - 20) / 2, 150, 20); + QStyleOptionProgressBar progressBarOption; + progressBarOption.rect = progressRect; + progressBarOption.minimum = 0; + progressBarOption.maximum = 100; + progressBarOption.progress = progress; + progressBarOption.text = QString("%1%").arg(progress); + progressBarOption.textVisible = true; + QApplication::style()->drawControl(QStyle::CE_ProgressBar, &progressBarOption, painter); + + // 修改后的取消按钮绘制代码 + QRect buttonRect(rect.right() - 80, rect.top() + (rect.height() - 30) / 2, 70, 30); + painter->setPen(Qt::NoPen); + painter->setBrush(QColor("#ff4444")); // 红色背景 + painter->drawRoundedRect(buttonRect, 4, 4); // 圆角矩形 + + painter->setPen(Qt::white); // 白色文字 + painter->setFont(option.font); + painter->drawText(buttonRect, Qt::AlignCenter, "取消"); + } else if (isInstalling) { + // 安装中:显示转圈和文字 + QRect spinnerRect(option.rect.right() - 80, option.rect.top() + (option.rect.height() - 30) / 2, 30, 30); + int angle = (m_spinnerTimer.elapsed() / 10) % 360; + QPen pen(QColor("#2563EB"), 3); + painter->setPen(pen); + painter->setRenderHint(QPainter::Antialiasing, true); + QRectF arcRect = spinnerRect.adjusted(3, 3, -3, -3); + painter->drawArc(arcRect, angle * 16, 120 * 16); // 120度弧 + + QRect textRect(option.rect.right() - 120, option.rect.top() + (option.rect.height() - 30) / 2, 110, 30); + painter->setPen(QColor("#2563EB")); + painter->setFont(option.font); + painter->drawText(textRect, Qt::AlignLeft | Qt::AlignVCenter, "正在安装中"); + } else { + QRect buttonRect(option.rect.right() - 80, option.rect.top() + (option.rect.height() - 30) / 2, 70, 30); + painter->setPen(Qt::NoPen); + if (isInstalled) { + painter->setBrush(QColor("#10B981")); + painter->drawRoundedRect(buttonRect, 4, 4); + painter->setPen(Qt::white); + painter->drawText(buttonRect, Qt::AlignCenter, "已安装"); + } else if (m_downloads.contains(packageName) && !m_downloads[packageName].isDownloading) { + // 下载完成,按钮绿色,样式不变 + painter->setBrush(QColor("#10B981")); + painter->drawRoundedRect(buttonRect, 4, 4); + painter->setPen(Qt::white); + painter->drawText(buttonRect, Qt::AlignCenter, "下载完成"); + // 不需要特殊处理样式,交互在 editorEvent 控制 + } else { + painter->setBrush(QColor("#e9effd")); + painter->drawRoundedRect(buttonRect, 4, 4); + painter->setPen(QColor("#2563EB")); + painter->drawText(buttonRect, Qt::AlignCenter, "更新"); + } + } + + painter->restore(); +} + +QSize AppDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const { + return QSize(option.rect.width(), 110); +} + +bool AppDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, + const QStyleOptionViewItem &option, const QModelIndex &index) { + if (event->type() == QEvent::MouseButtonRelease) { + QMouseEvent *mouseEvent = static_cast(event); + QRect rect = option.rect; + QString packageName = index.data(Qt::UserRole + 1).toString(); + + if (m_downloads.contains(packageName) && m_downloads[packageName].isDownloading) { + QRect cancelButtonRect(rect.right() - 70, rect.top() + (rect.height() - 20) / 2, 60, 20); + if (cancelButtonRect.contains(mouseEvent->pos())) { + m_downloadManager->cancelDownload(packageName); + m_downloads.remove(packageName); + emit updateDisplay(packageName); + return true; + } + } else { + QRect buttonRect(rect.right() - 80, rect.top() + (rect.height() - 30) / 2, 70, 30); + if (buttonRect.contains(mouseEvent->pos())) { + // 判断是否为“下载完成”状态,如果是则不响应点击 + if (m_downloads.contains(packageName) && !m_downloads[packageName].isDownloading) { + // “下载完成”状态,按钮失效,点击无效 + return false; + } + QString downloadUrl = index.data(Qt::UserRole + 7).toString(); + QString outputPath = QString("%1/%2.metalink").arg(QDir::tempPath(), packageName); + + m_downloads[packageName] = {0, true}; + m_downloadManager->startDownload(packageName, downloadUrl, outputPath); + emit updateDisplay(packageName); + return true; + } + } + } + + return QStyledItemDelegate::editorEvent(event, model, option, index); +} + +void AppDelegate::startDownloadForAll() { + if (!m_model) return; + for (int row = 0; row < m_model->rowCount(); ++row) { + QModelIndex index = m_model->index(row, 0); + QString packageName = index.data(Qt::UserRole + 1).toString(); + if (m_downloads.contains(packageName) && (m_downloads[packageName].isDownloading || m_downloads[packageName].isInstalled)) + continue; // 跳过正在下载或已安装的 + QString downloadUrl = index.data(Qt::UserRole + 7).toString(); + QString outputPath = QString("%1/%2.metalink").arg(QDir::tempPath(), packageName); + m_downloads[packageName] = {0, true, false}; + m_downloadManager->startDownload(packageName, downloadUrl, outputPath); + emit updateDisplay(packageName); + } +} + +// 新增:安装队列相关实现 +void AppDelegate::enqueueInstall(const QString &packageName) { + m_installQueue.enqueue(packageName); + if (!m_isInstalling) { + startNextInstall(); + } +} + +void AppDelegate::startNextInstall() { + if (m_installQueue.isEmpty()) { + m_isInstalling = false; + m_installingPackage.clear(); + return; + } + m_isInstalling = true; + QString packageName = m_installQueue.dequeue(); + m_installingPackage = packageName; + m_downloads[packageName].isInstalling = true; + emit updateDisplay(packageName); + + // 查找 /tmp 下以包名开头的 .deb 文件 + QDir tempDir(QDir::tempPath()); + QStringList debs = tempDir.entryList(QStringList() << QString("%1_*.deb").arg(packageName), QDir::Files); + QString debPath; + if (!debs.isEmpty()) { + debPath = tempDir.absoluteFilePath(debs.first()); + } else { + debs = tempDir.entryList(QStringList() << QString("%1*.deb").arg(packageName), QDir::Files); + if (!debs.isEmpty()) { + debPath = tempDir.absoluteFilePath(debs.first()); + } + } + + if (debPath.isEmpty()) { + qWarning() << "未找到deb文件,包名:" << packageName; + m_downloads[packageName].isInstalling = false; + emit updateDisplay(packageName); + m_installingPackage.clear(); + startNextInstall(); + return; + } + + m_installProcess = new QProcess(this); + + // 新增:准备安装日志文件 + QString logPath = QString("/tmp/%1_install.log").arg(packageName); + QFile *logFile = new QFile(logPath, m_installProcess); + if (logFile->open(QIODevice::Append | QIODevice::Text)) { + // 设置权限为777 + QFile::setPermissions(logPath, QFile::ReadOwner | QFile::WriteOwner | QFile::ExeOwner | + QFile::ReadGroup | QFile::WriteGroup | QFile::ExeGroup | + QFile::ReadOther | QFile::WriteOther | QFile::ExeOther); + connect(m_installProcess, &QProcess::readyReadStandardOutput, this, [this, packageName, logFile]() { + QByteArray out = m_installProcess->readAllStandardOutput(); + logFile->write(out); + logFile->flush(); + QString text = QString::fromLocal8Bit(out); + qDebug().noquote() << text; + // 检查“软件包已安装”关键字 + if (text.contains(QStringLiteral("软件包已安装"))) { + m_downloads[packageName].isInstalling = false; + m_downloads[packageName].isInstalled = true; + emit updateDisplay(packageName); + } + }); + connect(m_installProcess, &QProcess::readyReadStandardError, this, [this, logFile]() { + QByteArray err = m_installProcess->readAllStandardError(); + logFile->write(err); + logFile->flush(); + qDebug().noquote() << QString::fromLocal8Bit(err); + }); + connect(m_installProcess, QOverload::of(&QProcess::finished), + this, [this, packageName, logFile](int /*exitCode*/, QProcess::ExitStatus /*status*/) { + if (logFile) logFile->close(); + // 若未检测到“软件包已安装”,此处兜底 + if (!m_downloads[packageName].isInstalled) { + m_downloads[packageName].isInstalling = false; + } + emit updateDisplay(packageName); + m_installProcess->deleteLater(); + m_installProcess = nullptr; + m_installingPackage.clear(); + startNextInstall(); + }); + } else { + // 日志文件无法打开时,仍然要连接原有信号 + connect(m_installProcess, &QProcess::readyReadStandardOutput, this, [this, packageName]() { + QByteArray out = m_installProcess->readAllStandardOutput(); + QString text = QString::fromLocal8Bit(out); + qDebug().noquote() << text; + if (text.contains(QStringLiteral("软件包已安装"))) { + m_downloads[packageName].isInstalling = false; + m_downloads[packageName].isInstalled = true; + emit updateDisplay(packageName); + } + }); + connect(m_installProcess, &QProcess::readyReadStandardError, this, [this]() { + QByteArray err = m_installProcess->readAllStandardError(); + qDebug().noquote() << QString::fromLocal8Bit(err); + }); + connect(m_installProcess, QOverload::of(&QProcess::finished), + this, [this, packageName](int /*exitCode*/, QProcess::ExitStatus /*status*/) { + emit updateDisplay(packageName); + m_installProcess->deleteLater(); + m_installProcess = nullptr; + m_installingPackage.clear(); + startNextInstall(); + }); + } + + // 注意参数顺序:deb路径在前,--no-create-desktop-entry在后 + QStringList args; + args << debPath << "--no-create-desktop-entry"; + m_installProcess->start("ssinstall", args); +} diff --git a/spark-update-tool/src/appdelegate.h b/spark-update-tool/src/appdelegate.h new file mode 100644 index 0000000..0545155 --- /dev/null +++ b/spark-update-tool/src/appdelegate.h @@ -0,0 +1,46 @@ +#pragma once + +#include +#include +#include +#include +#include +#include "downloadmanager.h" + +struct DownloadInfo { + int progress = 0; + bool isDownloading = false; + bool isInstalled = false; + bool isInstalling = false; // 新增:标记是否正在安装 +}; + +class AppDelegate : public QStyledItemDelegate { + Q_OBJECT +public: + explicit AppDelegate(QObject *parent = nullptr); + + void setModel(QAbstractItemModel *model); + + void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override; + QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override; + bool editorEvent(QEvent *event, QAbstractItemModel *model, + const QStyleOptionViewItem &option, const QModelIndex &index) override; + void startDownloadForAll(); + +signals: + void updateDisplay(const QString &packageName); + +private: + DownloadManager *m_downloadManager; + QHash m_downloads; + QAbstractItemModel *m_model = nullptr; + + QQueue m_installQueue; + bool m_isInstalling = false; + QProcess *m_installProcess = nullptr; + QString m_installingPackage; // 当前正在安装的包名 + QElapsedTimer m_spinnerTimer; // 用于转圈动画 + + void enqueueInstall(const QString &packageName); + void startNextInstall(); +}; diff --git a/spark-update-tool/src/applistmodel.cpp b/spark-update-tool/src/applistmodel.cpp new file mode 100644 index 0000000..31e244a --- /dev/null +++ b/spark-update-tool/src/applistmodel.cpp @@ -0,0 +1,62 @@ +#include "applistmodel.h" + +AppListModel::AppListModel(QObject *parent) : QAbstractListModel(parent) {} + +int AppListModel::rowCount(const QModelIndex &parent) const +{ + if (parent.isValid()) + return 0; + return m_data.size(); +} + +QVariant AppListModel::data(const QModelIndex &index, int role) const +{ + if (!index.isValid() || index.row() >= m_data.size()) + return QVariant(); + + const QVariantMap &map = m_data.at(index.row()); // 直接访问 QVariantMap + switch (role) { + case Qt::DisplayRole: + return map.value("name"); + case Qt::UserRole + 1: // 包名 + return map.value("package"); + case Qt::UserRole + 2: // 当前版本 + return map.value("current_version"); + case Qt::UserRole + 3: // 新版本 + return map.value("new_version"); + case Qt::UserRole + 4: // 图标路径 + return map.value("icon"); + case Qt::UserRole + 5: // 文件大小 + return map.value("size"); + case Qt::UserRole + 6: // 描述 + return map.value("description"); + case Qt::UserRole + 7: // 下载 URL + return map.value("download_url"); // 返回下载 URL + default: + return QVariant(); + } +} + +void AppListModel::setUpdateData(const QJsonArray &updateInfo) +{ + beginResetModel(); + m_data.clear(); // 清空 QList + + for (const auto &item : updateInfo) { + QJsonObject obj = item.toObject(); + QVariantMap map; + map["package"] = obj["package"].toString(); + map["name"] = obj["name"].toString(); + map["current_version"] = obj["current_version"].toString(); + map["new_version"] = obj["new_version"].toString(); + map["icon"] = obj["icon"].toString(); + map["size"] = obj["size"].toString(); + map["download_url"] = obj["download_url"].toString(); // 确保设置下载 URL + m_data.append(map); // 添加到 QList + + qDebug() << "设置到模型的包名:" << map["package"].toString(); + qDebug() << "设置到模型的下载 URL:" << map["download_url"].toString(); // 检查设置的数据 + } + + endResetModel(); +} diff --git a/spark-update-tool/src/applistmodel.h b/spark-update-tool/src/applistmodel.h new file mode 100644 index 0000000..2fb36c0 --- /dev/null +++ b/spark-update-tool/src/applistmodel.h @@ -0,0 +1,26 @@ +#ifndef APPLISTMODEL_H +#define APPLISTMODEL_H + +#include +#include +// 添加 QJsonObject 头文件 +#include + +class AppListModel : public QAbstractListModel +{ + Q_OBJECT +public: + explicit AppListModel(QObject *parent = nullptr); + + // 重写方法 + int rowCount(const QModelIndex &parent = QModelIndex()) const override; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + + // 设置更新数据 + void setUpdateData(const QJsonArray &data); + +private: + QList m_data; // 修改类型为 QList +}; + +#endif // APPLISTMODEL_H diff --git a/spark-update-tool/src/aptssupdater.cpp b/spark-update-tool/src/aptssupdater.cpp new file mode 100644 index 0000000..c4bd906 --- /dev/null +++ b/spark-update-tool/src/aptssupdater.cpp @@ -0,0 +1,398 @@ +#include "aptssupdater.h" +#include +#include +#include +#include +#include + +aptssUpdater::aptssUpdater(QWidget *parent) + : QWidget(parent) +{ + packageName = getUpdateablePackages(); +} + +QStringList aptssUpdater::getUpdateablePackages() +{ + QStringList packageDetails; + QProcess process; + QString command = R"(env LANGUAGE=en_US /usr/bin/apt -c /opt/durapps/spark-store/bin/apt-fast-conf/aptss-apt.conf list --upgradable -o Dir::Etc::sourcelist="/opt/durapps/spark-store/bin/apt-fast-conf/sources.list.d/sparkstore.list" -o Dir::Etc::sourceparts="/dev/null" -o APT::Get::List-Cleanup="0" | awk 'NR>1')"; + + process.start("bash", QStringList() << "-c" << command); + if (!process.waitForFinished()) { + qWarning() << "Process failed to finish."; + return packageDetails; + } + + QString output = process.readAllStandardOutput(); + QStringList lines = output.split('\n', Qt::SkipEmptyParts); + + // 创建临时文件 + QTemporaryFile tempFile; + tempFile.setAutoRemove(false); + if (tempFile.open()) { + QTextStream stream(&tempFile); + + for (const QString &line : lines) { + QRegularExpression regex(R"(([\w\-\+\.]+)/\S+\s+([^\s]+)\s+\S+\s+\[upgradable from: ([^\]]+)\])"); + QRegularExpressionMatch match = regex.match(line); + if (match.hasMatch()) { + QString name = match.captured(1); + QString newVersion = match.captured(2); + QString oldVersion = match.captured(3); + + // 检查版本是否相同,相同则跳过 + if (newVersion == oldVersion) { + qDebug() << "跳过版本相同的包:" << name << "(" << oldVersion << "→" << newVersion << ")"; + continue; + } + + // 写入内存列表 + packageDetails << QString("%1: %2 → %3").arg(name, oldVersion, newVersion); + + // 写入临时文件(原始数据) + stream << name << "|" << oldVersion << "|" << newVersion << "\n"; + } + } + tempFile.close(); + m_tempFilePath = tempFile.fileName(); + qDebug()<< "临时文件路径:" << m_tempFilePath; + + } else { + qWarning() << "无法创建临时文件"; + } + + return packageDetails; +} + + +QStringList aptssUpdater::getPackageSizes() +{ + QStringList packageDetails; + QProcess process; + + // 获取可更新包名列表 + QStringList updateablePackages; + for (const QString &pkgInfo : packageName) { + updateablePackages << pkgInfo.section(":", 0, 0).trimmed(); + } + + foreach (const QString &packageName, updateablePackages) { + // 构建新命令(包含包名参数) + QString command = QString("apt download %1 --print-uris -c /opt/durapps/spark-store/bin/apt-fast-conf/aptss-apt.conf " + "-o Dir::Etc::sourcelist=\"/opt/durapps/spark-store/bin/apt-fast-conf/sources.list.d/sparkstore.list\" " + "-o Dir::Etc::sourceparts=\"/dev/null\"").arg(packageName); + + process.start("bash", QStringList() << "-c" << command); + if (!process.waitForFinished()) { + qWarning() << "获取包信息失败:" << packageName; + continue; + } + + QString output = process.readAllStandardOutput(); + // 使用正则匹配所有信息 + // 调整正则表达式匹配分组 + QRegularExpression regex(R"('([^']+)'\s+(\S+)\s+(\d+)\s+SHA512:([^\s]+))"); // 分组1:URL 分组2:文件名 分组3:大小 分组4:SHA512 + QRegularExpressionMatch match = regex.match(output); + + if (match.hasMatch()) { + QString url = match.captured(1); + QString fileName = match.captured(2); + QString size = match.captured(3); + QString sha512 = match.captured(4); + + // 调整字段顺序:包名 | 大小 | URL | SHA512 + packageDetails << QString("%1: %2|%3|%4").arg(packageName, size, url, sha512); + } + } + + qDebug() << "完整包信息:" << packageDetails; + return packageDetails; +} + + + + + +QStringList aptssUpdater::getDesktopAppNames() +{ + QStringList appNames; + QProcess dpkgProcess; + + // 获取当前系统语言环境 + QString lang = QLocale().name().replace("_", "-"); + + // 遍历所有可更新包(复用已有的临时文件数据) + QStringList packages = packageName; + + foreach (const QString &package, packages) { + QString packageName = package.split(":")[0]; + QString finalName = packageName; // 默认使用包名 + + // 获取包文件列表 + dpkgProcess.start("dpkg", QStringList() << "-L" << packageName); + dpkgProcess.waitForFinished(); + QStringList files = QString(dpkgProcess.readAllStandardOutput()).split('\n', Qt::SkipEmptyParts); + + // 先检查常规应用目录 + QStringList regularDesktopFiles = files.filter("/usr/share/applications/"); + QString regularAppName; + if (!regularDesktopFiles.isEmpty()) { + checkDesktopFiles(regularDesktopFiles, regularAppName, lang, packageName); + } + + // 如果常规目录没有找到,再检查特殊目录 + if (regularAppName.isEmpty()) { + QStringList specialDesktopFiles = files.filter(QRegularExpression(QString("/opt/apps/%1/entries/applications").arg(packageName))); + QString specialAppName; + if (!specialDesktopFiles.isEmpty()) { + checkDesktopFiles(specialDesktopFiles, specialAppName, lang, packageName); + if (!specialAppName.isEmpty()) { + finalName = specialAppName; + } + } + } else { + finalName = regularAppName; + } + + // 输出格式为[软件名|包名] + appNames << QString("[%1|%2]").arg(finalName, packageName); + } + qDebug()<< "应用名称列表:" << appNames; + return appNames; +} + + +bool aptssUpdater::checkDesktopFiles(const QStringList &desktopFiles, QString &appName, const QString &lang, const QString &packageName) +{ + QString lastValidName; + QRegularExpression noDisplayRe("^NoDisplay=(true|True)"); + QRegularExpression nameRe("^Name\\[?" + lang + "?\\]?=(.*)"); + QRegularExpression nameOrigRe("^Name=(.*)"); + + foreach (const QString &filePath, desktopFiles) { + if (!filePath.endsWith(".desktop")) continue; + + QFile file(filePath); + if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) continue; + + bool skip = false; + QString currentName; + + QTextStream in(&file); + while (!in.atEnd()) { + QString line = in.readLine().trimmed(); + + // 检查NoDisplay属性 + if (line.startsWith("NoDisplay=")) { + if (noDisplayRe.match(line).hasMatch()) { + skip = true; + break; + } + } + + // 优先匹配本地化名称 + if (currentName.isEmpty()) { + QRegularExpressionMatch match = nameRe.match(line); + if (match.hasMatch()) { + currentName = match.captured(1); + continue; + } + + // 匹配原始名称 + match = nameOrigRe.match(line); + if (match.hasMatch()) { + currentName = match.captured(1); + } + } + } + + if (!skip && !currentName.isEmpty()) { + lastValidName = currentName; + } + } + + // 处理最终的有效名称 + if (!lastValidName.isEmpty()) { + appName = lastValidName; // 直接赋值而不是使用<< + return true; + } + + // 回退到包名 + appName = packageName; + return false; +} + +QStringList aptssUpdater::getPackageIcons() +{ + QStringList packageIcons; + QProcess dpkgProcess; + + // 遍历所有可更新包 + QStringList packages = packageName; + + foreach (const QString &package, packages) { + QString packageName = package.split(":")[0]; + QString iconPath = ":/resources/default_icon.svg"; // 默认图标 + + // 获取包文件列表 + dpkgProcess.start("dpkg", QStringList() << "-L" << packageName); + dpkgProcess.waitForFinished(); + QStringList files = QString(dpkgProcess.readAllStandardOutput()).split('\n', Qt::SkipEmptyParts); + + // 查找.desktop文件 + QStringList desktopFiles = files.filter(QRegularExpression("/(usr/share|opt/apps)/.*\\.desktop$")); + + // 从.desktop文件中提取图标 + foreach (const QString &desktopFile, desktopFiles) { + QFile file(desktopFile); + if (file.open(QIODevice::ReadOnly | QIODevice::Text)) { + QTextStream in(&file); + while (!in.atEnd()) { + QString line = in.readLine().trimmed(); + if (line.startsWith("Icon=")) { + QString iconName = line.mid(5).trimmed(); + + // 处理相对图标名(如Icon=vscode) + if (!iconName.contains('/')) { + // 查找标准图标路径 + QStringList iconPaths = { + QString("/usr/share/pixmaps/%1.png").arg(iconName), + QString("/usr/share/icons/hicolor/48x48/apps/%1.png").arg(iconName), + QString("/usr/share/icons/hicolor/scalable/apps/%1.svg").arg(iconName), + QString("/opt/apps/%1/entries/icons/hicolor/48x48/apps/%2.png").arg(packageName, iconName) + }; + + foreach (const QString &path, iconPaths) { + if (QFile::exists(path)) { + iconPath = path; + break; + } + } + } else { + // 已经是绝对路径 + if (QFile::exists(iconName)) { + iconPath = iconName; + } + } + break; + } + } + file.close(); + } + } + + // 如果.desktop中没有找到图标,尝试直接查找包中的图标文件 + if (iconPath == ":/resources/default_icon.svg") { + QStringList iconFiles = files.filter(QRegularExpression("/(usr/share/pixmaps|usr/share/icons|opt/apps/.*/entries/icons)/.*\\.(png|svg)$")); + if (!iconFiles.isEmpty()) { + iconPath = iconFiles.first(); + } + } + + qDebug() << "包名:" << packageName << "图标路径:" << iconPath; + packageIcons << QString("%1: %2").arg(packageName, iconPath); + } + + return packageIcons; +} + + +QJsonArray aptssUpdater::getUpdateInfoAsJson() +{ + QJsonArray jsonArray; + + // 获取所有需要的信息 + QStringList sizes = getPackageSizes(); + QStringList names = getDesktopAppNames(); + QStringList icons = getPackageIcons(); + + // 创建包名到各种信息的映射 + QHash> packageInfo; + + // 解析包版本信息 + for (const QString &pkg : packageName) { + QStringList parts = pkg.split(": "); + if (parts.size() >= 2) { + QString packageName = parts[0]; + QStringList versions = parts[1].split(" → "); + if (versions.size() == 2) { + packageInfo[packageName]["current_version"] = versions[0]; + packageInfo[packageName]["new_version"] = versions[1]; + } + } + } + + // 解析包详细信息(新增部分) + for (const QString &sizeInfo : sizes) { + QStringList parts = sizeInfo.split(": "); + if (parts.size() == 2) { + QString packageName = parts[0]; + QStringList details = parts[1].split("|"); + if (details.size() == 3) { // 现在包含大小|URL|SHA512 + packageInfo[packageName]["size"] = details[0]; + packageInfo[packageName]["url"] = details[1]; + packageInfo[packageName]["sha512"] = details[2]; + } + } + } + + // 解析应用名称信息 + for (const QString &nameInfo : names) { + if (nameInfo.startsWith("[") && nameInfo.endsWith("]")) { + QString content = nameInfo.mid(1, nameInfo.length() - 2); + QStringList parts = content.split("|"); + if (parts.size() == 2) { + QString displayName = parts[0]; + QString packageName = parts[1]; + packageInfo[packageName]["display_name"] = displayName; + } + } + } + + // 解析图标信息 + for (const QString &iconInfo : icons) { + QStringList parts = iconInfo.split(": "); + if (parts.size() == 2) { + QString packageName = parts[0]; + packageInfo[packageName]["icon"] = parts[1].trimmed(); + } + } + + // 构建JSON数组 + for (const QString &packageName : packageInfo.keys()) { + QJsonObject jsonObj; + jsonObj["package"] = packageName; + + // 使用显示名称(如果有),否则使用包名 + if (packageInfo[packageName].contains("display_name")) { + jsonObj["name"] = packageInfo[packageName]["display_name"]; + } else { + jsonObj["name"] = packageName; + } + + jsonObj["current_version"] = packageInfo[packageName]["current_version"]; + jsonObj["new_version"] = packageInfo[packageName]["new_version"]; + jsonObj["icon"] = packageInfo[packageName]["icon"]; + jsonObj["ignored"] = false; // 默认不忽略 + + // 如果有大小信息也加入 + if (packageInfo[packageName].contains("size")) { + jsonObj["size"] = packageInfo[packageName]["size"]; + } + + // 在构建JSON对象时添加新字段(在jsonObj中添加): + if (packageInfo[packageName].contains("url")) { + jsonObj["download_url"] = packageInfo[packageName]["url"]; + qDebug() << "生成的下载 URL:" << packageInfo[packageName]["url"]; // 检查生成的 URL + } else { + qWarning() << "未找到下载 URL,包名:" << packageName; + jsonObj["download_url"] = ""; // 设置为空字符串以避免崩溃 + } + jsonObj["sha512"] = packageInfo[packageName]["sha512"]; + jsonArray.append(jsonObj); + } + qDebug()< +#include +#include +#include +#include +#include +class aptssUpdater : public QWidget +{ + Q_OBJECT +public: + explicit aptssUpdater(QWidget *parent = nullptr); + + QStringList getUpdateablePackages(); // 查询可更新包列表及更新内容 + QStringList getPackageSizes(); // 获取每个包的大小 + QStringList getDesktopAppNames(); // 获取桌面应用名称列表 + QStringList getPackageIcons(); // 获取包图标列表 + QJsonArray getUpdateInfoAsJson(); // 获取更新信息的 JSON 格式 + QString m_tempFilePath; +signals: +private: + bool checkDesktopFiles(const QStringList &desktopFiles, QString &appName, const QString &lang, const QString &packageName); + QStringList packageName; +}; + +#endif // APTSSUPDATER_H \ No newline at end of file diff --git a/spark-update-tool/src/downloadmanager.cpp b/spark-update-tool/src/downloadmanager.cpp new file mode 100644 index 0000000..9780324 --- /dev/null +++ b/spark-update-tool/src/downloadmanager.cpp @@ -0,0 +1,117 @@ +#include "downloadmanager.h" +#include +#include +#include +#include +#include + +DownloadManager::DownloadManager(QObject *parent) : QObject(parent) +{ + cleanupTempFiles(); +} + +void DownloadManager::startDownload(const QString &packageName, const QString &url, const QString &outputPath) +{ + if (m_processes.contains(packageName)) { + qWarning() << packageName << " is already downloading."; + return; + } + + QString metalinkUrl = url + ".metalink"; + QFileInfo fileInfo(outputPath); + + QStringList arguments = { + "--enable-rpc=false", + "--console-log-level=warn", + "--summary-interval=1", + "--allow-overwrite=true", + "--dir=" + fileInfo.absolutePath(), + "--out=" + fileInfo.fileName(), + metalinkUrl + }; + + QProcess *process = new QProcess(this); + m_processes.insert(packageName, process); + + // 新增:准备日志文件 + QString logPath = QString("/tmp/%1_download.log").arg(packageName); + QFile *logFile = new QFile(logPath, process); + if (logFile->open(QIODevice::Append | QIODevice::Text)) { + // 设置权限为777 + QFile::setPermissions(logPath, QFile::ReadOwner | QFile::WriteOwner | QFile::ExeOwner | + QFile::ReadGroup | QFile::WriteGroup | QFile::ExeGroup | + QFile::ReadOther | QFile::WriteOther | QFile::ExeOther); + connect(process, &QProcess::readyReadStandardOutput, this, [this, packageName, process, logFile]() { + while (process->canReadLine()) { + QString line = QString::fromUtf8(process->readLine()).trimmed(); + // 写入日志 + logFile->write(line.toUtf8() + '\n'); + logFile->flush(); + QRegularExpression regex(R"(\((\d+)%\))"); + QRegularExpressionMatch match = regex.match(line); + if (match.hasMatch()) { + int progress = match.captured(1).toInt(); + emit downloadProgress(packageName, progress); + } + } + }); + connect(process, &QProcess::readyReadStandardError, this, [process, logFile]() { + QByteArray err = process->readAllStandardError(); + logFile->write(err); + logFile->flush(); + }); + } + + connect(process, QOverload::of(&QProcess::finished), + this, [this, packageName, outputPath, logFile](int exitCode, QProcess::ExitStatus status) { + bool success = (exitCode == 0 && status == QProcess::NormalExit); + if (!success) { + qWarning() << "Download failed for" << packageName << "exit code:" << exitCode; + } + + removeAria2Files(outputPath); // 清理残留 .aria2 + emit downloadFinished(packageName, success); + + if (logFile) logFile->close(); + + QProcess *proc = m_processes.take(packageName); + if (proc) proc->deleteLater(); + }); + + process->start("aria2c", arguments); +} + +void DownloadManager::cancelDownload(const QString &packageName) +{ + if (!m_processes.contains(packageName)) return; + + QProcess *process = m_processes.take(packageName); + if (process) { + process->kill(); // 立即终止 + process->waitForFinished(3000); // 最多等待3秒 + process->deleteLater(); + } + + emit downloadFinished(packageName, false); // 显式通知取消 + +} + +void DownloadManager::removeAria2Files(const QString &filePath) +{ + QString ariaFile = filePath + ".aria2"; + QFile::remove(ariaFile); +} + +bool DownloadManager::isDownloading(const QString &packageName) const +{ + return m_processes.contains(packageName); +} + +void DownloadManager::cleanupTempFiles() +{ + QDir tempDir(QDir::tempPath()); + QStringList leftovers = tempDir.entryList(QStringList() << "*.aria2", QDir::Files); + for (const QString &f : leftovers) { + tempDir.remove(f); + } +} diff --git a/spark-update-tool/src/downloadmanager.h b/spark-update-tool/src/downloadmanager.h new file mode 100644 index 0000000..0614368 --- /dev/null +++ b/spark-update-tool/src/downloadmanager.h @@ -0,0 +1,28 @@ +#ifndef DOWNLOADMANAGER_H +#define DOWNLOADMANAGER_H + +#include +#include +#include + +class DownloadManager : public QObject +{ + Q_OBJECT +public: + explicit DownloadManager(QObject *parent = nullptr); + void startDownload(const QString &packageName, const QString &url, const QString &outputPath); + void cancelDownload(const QString &packageName); + bool isDownloading(const QString &packageName) const; + +signals: + void downloadProgress(const QString &packageName, int progress); + void downloadFinished(const QString &packageName, bool success); + +private: + void cleanupTempFiles(); + void removeAria2Files(const QString &filePath); + + QMap m_processes; +}; + +#endif // DOWNLOADMANAGER_H diff --git a/spark-update-tool/src/icons.qrc b/spark-update-tool/src/icons.qrc new file mode 100644 index 0000000..f81e1f8 --- /dev/null +++ b/spark-update-tool/src/icons.qrc @@ -0,0 +1,8 @@ + + + ../resources/down_arrow.svg + ../resources/default_icon.svg + ../resources/spark-update-tool.svg + ../resources/128*128/spark-update-tool.png + + diff --git a/spark-update-tool/src/main.cpp b/spark-update-tool/src/main.cpp new file mode 100644 index 0000000..a3df5a4 --- /dev/null +++ b/spark-update-tool/src/main.cpp @@ -0,0 +1,86 @@ +#include "mainwindow.h" +#include +#include +#include +#include // for geteuid +#include // for getenv +#include // For debugging output + +bool isRoot() { + return geteuid() == 0; +} + +bool elevateToRoot() { + QString program = QCoreApplication::applicationFilePath(); + qDebug() << "Current application path:" << program; + + QByteArray display = qgetenv("DISPLAY"); + QByteArray xauthority = qgetenv("XAUTHORITY"); + + QStringList args; + args << "env" + << "DISPLAY=" + display + << "XAUTHORITY=" + xauthority + << program; + + QProcess process; + process.setProgram("pkexec"); + process.setArguments(args); + + qDebug() << "Attempting to elevate using pkexec with arguments:" << args; + + process.start(); + if (!process.waitForStarted(5000)) { + qDebug() << "Failed to start pkexec."; + return false; + } + + // 阻塞等待提权进程退出(比如主程序窗口关闭) + if (!process.waitForFinished(-1)) { // 等待直到新进程退出 + qDebug() << "pkexec process waitForFinished failed."; + return false; + } + + int exitCode = process.exitCode(); + QProcess::ExitStatus exitStatus = process.exitStatus(); + + qDebug() << "pkexec exit code:" << exitCode; + qDebug() << "pkexec exit status:" << exitStatus; + qDebug() << "pkexec stderr:" << process.readAllStandardError(); + + return (exitStatus == QProcess::NormalExit && exitCode == 0); +} + +int main(int argc, char *argv[]) +{ + // 必须在 QGuiApplication 实例创建之前调用 + // QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough); + + QApplication a(argc, argv); + a.setWindowIcon(QIcon(":/resources/128*128/spark-update-tool.png")); + if (!isRoot()) { + qDebug() << "Not running as root. Attempting to elevate..."; + if (!elevateToRoot()) { + qDebug() << "Elevation failed or pkexec command was not executed successfully."; + QMessageBox::critical(nullptr, + "权限不足", + "提权失败!\n\n您的系统可能不支持 `pkexec` 或 `polkit` 配置不正确," + "或者您取消了授权。\n\n请尝试使用 `sudo` 命令运行此程序:" + "\n\n在终端中输入:\n`sudo " + QCoreApplication::applicationName() + "`"); + return 0; // 提权失败,退出程序 + } else { + // 如果 elevateToRoot 返回 true,说明 pkexec 命令本身执行成功 + // 但这并不意味着原始程序以 root 权限启动了 + // 因为 elevateToRoot 启动的是一个新的进程,当前进程应该退出 + // 否则会并行运行两个程序实例 + qDebug() << "pkexec command executed successfully (new process likely started). Exiting current process."; + return 0; // 当前非root进程退出 + } + } else { + qDebug() << "Running as root."; + } + + MainWindow w; + w.show(); + return a.exec(); +} \ No newline at end of file diff --git a/spark-update-tool/src/mainwindow.cpp b/spark-update-tool/src/mainwindow.cpp new file mode 100644 index 0000000..dde2a4c --- /dev/null +++ b/spark-update-tool/src/mainwindow.cpp @@ -0,0 +1,229 @@ +#include "mainwindow.h" +#include "./ui_mainwindow.h" +#include +#include +#include +#include // 新增 +#include // 新增 +#include +#include +MainWindow::MainWindow(QWidget *parent) + : QMainWindow(parent) + , ui(new Ui::MainWindow) + , m_model(new AppListModel(this)) + , m_delegate(new AppDelegate(this)) +{ + QIcon icon(":/resources/128*128/spark-update-tool.png"); + setWindowIcon(icon); + QProgressDialog *progressDialog = new QProgressDialog("正在与服务器通信,获取更新信息中...", QString(), 0, 0, this); + progressDialog->setWindowModality(Qt::ApplicationModal); + progressDialog->setCancelButton(nullptr); + progressDialog->setWindowTitle("请稍候"); + progressDialog->setMinimumDuration(0); + progressDialog->setWindowFlags(progressDialog->windowFlags() & ~Qt::WindowCloseButtonHint); // 禁用关闭按钮 + progressDialog->show(); + //异步执行runAptssUpgrade + QFutureWatcher *watcher = new QFutureWatcher(this); + connect(watcher, &QFutureWatcher::finished, this, [=]() { + progressDialog->close(); + progressDialog->deleteLater(); + watcher->deleteLater(); + ui->setupUi(this); + QIcon icon(":/resources/128*128/spark-update-tool.png"); + setWindowIcon(icon); + // 创建 QListView 并设置父控件为 ui->appWidget + listView = new QListView(ui->appWidget); + listView->setModel(m_model); + listView->setItemDelegate(m_delegate); + + // 新增:确保 delegate 拥有 model 指针 + m_delegate->setModel(m_model); + + // 设置 QListView 填充 ui->appWidget + QVBoxLayout *layout = new QVBoxLayout(ui->appWidget); + layout->addWidget(listView); + layout->setContentsMargins(0, 0, 0, 0); + connect(m_delegate, &AppDelegate::updateDisplay, this, [=](const QString &packageName) { + for (int i = 0; i < m_model->rowCount(); ++i) { + QModelIndex index = m_model->index(i); + if (index.data(Qt::UserRole + 1).toString() == packageName) { + m_model->dataChanged(index, index); // 刷新该行 + break; + } + } + }); + + // 新增:点击“更新全部”按钮批量下载 + connect(ui->updatePushButton, &QPushButton::clicked, this, [=](){ + qDebug()<<"更新全部按钮被点击"; + m_delegate->startDownloadForAll(); + }); + + checkUpdates(); + initStyle(); + }); + + // 启动异步任务 + watcher->setFuture(QtConcurrent::run([this](){ + runAptssUpgrade(); + })); +} +//初始化控件样式 +void MainWindow::initStyle() +{ + //设置窗口标题 + this->setWindowTitle("软件更新中心"); + + //查询框样式 + ui->plainTextEdit->setStyleSheet(R"( + QPlainTextEdit { + background-color: #FFFFFF; + border: 1px solid #E5E7EB; + border-radius: 4px; + padding-top: 8px; + padding-bottom: 8px; + font-size: 9px; + line-height: 1.4; + color: #9CA3AF; + } + )"); + + ui->plainTextEdit->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + ui->plainTextEdit->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + + //筛选框样式 + ui->FilterComboBox->setStyleSheet(R"( + QComboBox { + background-color: #FFFFFF; + border: 1px solid #E5E7EB; + border-radius: 4px; + color: #4B5563; + padding: 4px 8px; + } + + QComboBox::drop-down { + border: none; + width: 20px; + } + + QComboBox::down-arrow { + image: url(:/resources/down_arrow.svg); + width: 12px; + height: 16px; + } + QComboBox QAbstractItemView { + background-color: #FFFFFF; + border: 1px solid #E5E7EB; + color: #4B5563; + selection-background-color: #F3F4F6; + selection-color: #111827; + } + )"); + + //更新软件按钮样式 + ui->updatePushButton->setStyleSheet(R"( + QPushButton { + background-color: #2563EB; + color: #FFFFFF; + border: none; + border-radius: 4px; + font-size: 14px; + padding: 6px 12px; + text-align: center; + } + + QPushButton:hover { + background-color: #1D4ED8; /* 深一点的 hover 效果,可选 */ + } + + QPushButton:pressed { + background-color: #1E40AF; /* 按下效果,可选 */ + } + + QPushButton:disabled { + background-color: #A5B4FC; + color: #F9FAFB; + } + )"); + + //设置背景填充颜色 + ui->backgroundWidget->setStyleSheet(R"( + QWidget { + background-color: #FFFFFF; + border-radius: 12px; + } + )"); + + //设置主背景颜色 + this->setStyleSheet("background-color: #F8FAFC;"); + + // 添加滚动条样式 + this->setStyleSheet(R"( + QScrollBar:vertical { + background: #F3F4F6; + width: 8px; + margin: 0px; + } + QScrollBar::handle:vertical { + background: #D1D5DB; + border-radius: 4px; + min-height: 30px; + } + QScrollBar::handle:vertical:hover { + background: #9CA3AF; + } + QScrollBar::add-line:vertical, QScrollBar::sub-line:vertical { + background: none; + height: 0px; + } + + QScrollBar:horizontal { + background: #F3F4F6; + height: 8px; + margin: 0px; + } + QScrollBar::handle:horizontal { + background: #D1D5DB; + border-radius: 4px; + min-width: 30px; + } + QScrollBar::handle:horizontal:hover { + background: #9CA3AF; + } + )"); +} +void MainWindow::checkUpdates() +{ + aptssUpdater updater; + QJsonArray updateInfo = updater.getUpdateInfoAsJson(); + m_model->setUpdateData(updateInfo); + + for (const auto &item : updateInfo) { + QJsonObject obj = item.toObject(); + qDebug() << "模型设置的包名:" << obj["package"].toString(); + qDebug() << "模型设置的下载 URL:" << obj["download_url"].toString(); // 检查模型数据 + } +} + +void MainWindow::runAptssUpgrade() +{ + QProcess process; + QStringList args; + args << "sudo" <<"aptss" << "ssupdate"; + process.start("sudo", args); + if (!process.waitForStarted(5000)) { + QMessageBox::warning(this, "升级失败", "无法启动 sudo aptss ssupdate"); + return; + } + process.write("n\n"); + process.closeWriteChannel(); + process.waitForFinished(-1); + if (process.exitCode() != 0) { + QMessageBox::warning(this, "升级失败", "执行 sudo aptss ssupdate 失败,请检查系统环境。"); + } +} + +MainWindow::~MainWindow() +{ + delete ui; +} diff --git a/spark-update-tool/src/mainwindow.h b/spark-update-tool/src/mainwindow.h new file mode 100644 index 0000000..e36db88 --- /dev/null +++ b/spark-update-tool/src/mainwindow.h @@ -0,0 +1,33 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include +#include "aptssupdater.h" +#include "applistmodel.h" +#include "appdelegate.h" +#include + +QT_BEGIN_NAMESPACE +namespace Ui { +class MainWindow; +} +QT_END_NAMESPACE + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + MainWindow(QWidget *parent = nullptr); + ~MainWindow(); + +private: + Ui::MainWindow *ui; + void checkUpdates(); + void initStyle(); + void runAptssUpgrade(); + AppListModel *m_model; + AppDelegate *m_delegate; + QListView *listView; // 声明 QListView 指针 +}; +#endif // MAINWINDOW_H diff --git a/spark-update-tool/src/mainwindow.ui b/spark-update-tool/src/mainwindow.ui new file mode 100644 index 0000000..2a58287 --- /dev/null +++ b/spark-update-tool/src/mainwindow.ui @@ -0,0 +1,256 @@ + + + MainWindow + + + + 0 + 0 + 1440 + 858 + + + + MainWindow + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + Noto Sans Vai + 22 + + + + 软件更新中心 + + + + + + + Qt::Horizontal + + + + 1245 + 20 + + + + + + + + + + + + + + + 0 + 0 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 320 + 38 + + + + + 320 + 38 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 200 + 38 + + + + + + + 81.000000000000000 + + + 搜索软件... + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 214 + 40 + + + + + 214 + 40 + + + + + + 0 + 0 + 102 + 38 + + + + + 102 + 38 + + + + + 102 + 38 + + + + + + + Qt::LeftToRight + + + QComboBox::AdjustToContentsOnFirstShow + + + + 按名称 + + + + + + + 118 + 0 + 96 + 40 + + + + 更新全部 + + + + + + + + + + + true + + + + 0 + 0 + + + + + + + + + + + + + 0 + 0 + 1440 + 23 + + + + + + + From 7b6df76276821c30647f8028cc9098eefa813f16 Mon Sep 17 00:00:00 2001 From: momen Date: Sat, 5 Jul 2025 20:26:05 +0800 Subject: [PATCH 103/114] =?UTF-8?q?chore:=E6=9B=B4=E6=96=B0=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E6=A1=86=E7=9A=84=E5=90=8D=E7=A7=B0=E4=B8=BAsearchPla?= =?UTF-8?q?inTextEdit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mainwindow.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index dde2a4c..2b45c27 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -75,7 +75,7 @@ void MainWindow::initStyle() this->setWindowTitle("软件更新中心"); //查询框样式 - ui->plainTextEdit->setStyleSheet(R"( + ui->searchPlainTextEdit->setStyleSheet(R"( QPlainTextEdit { background-color: #FFFFFF; border: 1px solid #E5E7EB; @@ -88,8 +88,8 @@ void MainWindow::initStyle() } )"); - ui->plainTextEdit->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - ui->plainTextEdit->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + ui->searchPlainTextEdit->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + ui->searchPlainTextEdit->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); //筛选框样式 ui->FilterComboBox->setStyleSheet(R"( From 1be6e62d5585b617a2935200bca621541d949f3e Mon Sep 17 00:00:00 2001 From: momen Date: Sun, 6 Jul 2025 20:14:51 +0800 Subject: [PATCH 104/114] =?UTF-8?q?update:=E5=AE=8C=E5=96=84=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mainwindow.cpp | 27 +++++++++++++++++++++++++++ src/mainwindow.h | 3 +++ 2 files changed, 30 insertions(+) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 2b45c27..afd7d9b 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -60,6 +60,11 @@ MainWindow::MainWindow(QWidget *parent) }); checkUpdates(); + // 新增:监听搜索框文本变化 + connect(ui->searchPlainTextEdit, &QPlainTextEdit::textChanged, this, [=]() { + QString keyword = ui->searchPlainTextEdit->toPlainText(); + filterAppsByKeyword(keyword); + }); initStyle(); }); @@ -196,6 +201,7 @@ void MainWindow::checkUpdates() { aptssUpdater updater; QJsonArray updateInfo = updater.getUpdateInfoAsJson(); + m_allApps = updateInfo; // 保存所有应用数据 m_model->setUpdateData(updateInfo); for (const auto &item : updateInfo) { @@ -205,6 +211,27 @@ void MainWindow::checkUpdates() } } +// 新增:根据关键字过滤应用 +void MainWindow::filterAppsByKeyword(const QString &keyword) +{ + if (keyword.trimmed().isEmpty()) { + m_model->setUpdateData(m_allApps); + return; + } + QJsonArray filtered; + for (const auto &item : m_allApps) { + QJsonObject obj = item.toObject(); + // 可根据需要匹配更多字段 + QString name = obj.value("name").toString(); + QString package = obj.value("package").toString(); + if (name.contains(keyword, Qt::CaseInsensitive) || + package.contains(keyword, Qt::CaseInsensitive)) { + filtered.append(item); + } + } + m_model->setUpdateData(filtered); +} + void MainWindow::runAptssUpgrade() { QProcess process; diff --git a/src/mainwindow.h b/src/mainwindow.h index e36db88..bc7f9d7 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -6,6 +6,7 @@ #include "applistmodel.h" #include "appdelegate.h" #include +#include // 添加头文件 QT_BEGIN_NAMESPACE namespace Ui { @@ -29,5 +30,7 @@ private: AppListModel *m_model; AppDelegate *m_delegate; QListView *listView; // 声明 QListView 指针 + QJsonArray m_allApps; // 新增:保存所有应用数据 + void filterAppsByKeyword(const QString &keyword); // 新增:搜索过滤函数声明 }; #endif // MAINWINDOW_H From b693c27adfccfd1af50077f2ec6aec30b9800ab9 Mon Sep 17 00:00:00 2001 From: momen Date: Mon, 7 Jul 2025 05:29:46 +0800 Subject: [PATCH 105/114] =?UTF-8?q?fix:=E6=90=9C=E7=B4=A2=E6=A1=86?= =?UTF-8?q?=E6=B2=A1=E6=9C=89=E6=8F=90=E7=A4=BA=E5=AD=97=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mainwindow.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index afd7d9b..54f064c 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -66,6 +66,9 @@ MainWindow::MainWindow(QWidget *parent) filterAppsByKeyword(keyword); }); initStyle(); + + // 确保搜索框内容为空,placeholder 能显示 + ui->searchPlainTextEdit->clear(); }); // 启动异步任务 @@ -91,6 +94,9 @@ void MainWindow::initStyle() line-height: 1.4; color: #9CA3AF; } + QPlainTextEdit[placeholderText]:empty { + color: #9CA3AF; + } )"); ui->searchPlainTextEdit->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); From e603dc3fce0b8c8614b717e78692c8fd3393c317 Mon Sep 17 00:00:00 2001 From: momen Date: Thu, 10 Jul 2025 00:00:52 +0800 Subject: [PATCH 106/114] =?UTF-8?q?chore:=E6=B7=BB=E5=8A=A0spark-update-to?= =?UTF-8?q?ol=E4=BB=A3=E7=A0=81=E8=BF=9B=E5=85=A5pro=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spark-store-project.pro | 7 +++ src/mainwindow-dtk.cpp | 35 ++++++++++++--- src/spark-update-tool/spark-update-tool.pro | 48 +++++++++++++++++++++ 3 files changed, 83 insertions(+), 7 deletions(-) create mode 100644 src/spark-update-tool/spark-update-tool.pro diff --git a/spark-store-project.pro b/spark-store-project.pro index bb6b540..b0cbbc7 100644 --- a/spark-store-project.pro +++ b/spark-store-project.pro @@ -79,3 +79,10 @@ INSTALLS += \ fish_completion \ polkit-1 # 暂时不添加 + +SUBDIRS += src/spark-update-tool + +spark-update-tool.subdir = src/spark-update-tool +spark-update-tool.file = src/spark-update-tool/spark-update-tool.pro +spark-update-tool.target = spark-update-tool +spark-update-tool.depends = spark-store diff --git a/src/mainwindow-dtk.cpp b/src/mainwindow-dtk.cpp index 45bc6e2..c457f76 100755 --- a/src/mainwindow-dtk.cpp +++ b/src/mainwindow-dtk.cpp @@ -551,13 +551,34 @@ void MainWindow::on_pushButton_14_clicked() QFile upgradeStatus("/tmp/spark-store/upgradeStatus.txt"); if (!upgradeStatus.exists()) { - QtConcurrent::run([=] - { - auto upgradeP = new QProcess(); - upgradeP->startDetached("/opt/durapps/spark-store/bin/update-upgrade/ss-do-upgrade.sh", QStringList()); - upgradeP->waitForStarted(); - upgradeP->waitForFinished(-1); - upgradeP->deleteLater(); }); + QString appPath; + + // 开发环境路径(构建目录) + #ifdef QT_DEBUG + appPath = QCoreApplication::applicationDirPath() + + "/../spark-update-tool/spark-update-tool"; + #else + // 安装后路径(系统PATH) + appPath = QStandardPaths::findExecutable("spark-update-tool"); + #endif + + if (appPath.isEmpty()) { + qWarning() << "spark-update-tool not found!"; + return; + } + + QProcess *process = new QProcess(this); + process->start(appPath, {"--silent"}); + + connect(process, QOverload::of(&QProcess::finished), + [=](int exitCode) { + if (exitCode == 0) { + qDebug() << "Update check successful"; + } else { + qDebug() << "Update check failed"; + } + process->deleteLater(); + }); } } } diff --git a/src/spark-update-tool/spark-update-tool.pro b/src/spark-update-tool/spark-update-tool.pro new file mode 100644 index 0000000..69dc500 --- /dev/null +++ b/src/spark-update-tool/spark-update-tool.pro @@ -0,0 +1,48 @@ +# spark-update-tool.pro +QT += core gui widgets network concurrent +TARGET = spark-update-tool +TEMPLATE = app + +# Set C++ standard to C++17 +CONFIG += c++17 + +# Enable auto features (uic, moc, rcc) +CONFIG += qt warn_on release +QT_CONFIG += no-pkg-config + +# Version info (replace with your actual version) +VERSION = 0.1.0 +DEFINES += APP_VERSION=\\\"$$VERSION\\\" + +# Source files +SOURCES += \ + src/main.cpp \ + src/mainwindow.cpp \ + src/aptssupdater.cpp \ + src/appdelegate.cpp \ + src/applistmodel.cpp \ + src/downloadmanager.cpp + +HEADERS += \ + src/mainwindow.h \ + src/aptssupdater.h \ + src/appdelegate.h \ + src/applistmodel.h \ + src/downloadmanager.h + +FORMS += \ + src/mainwindow.ui + +RESOURCES += \ + src/icons.qrc + +# macOS bundle properties (optional) +macx { + QMAKE_INFO_PLIST = Info.plist + ICON = resources/spark-update-tool.icns + BUNDLE_IDENTIFIER = org.spark.store.update-tool +} + +# Installation paths (matches CMake install) +target.path = $$[QT_INSTALL_BINS] +INSTALLS += target \ No newline at end of file From 59588c90d592eb3b723123bde308a5729ebd323d Mon Sep 17 00:00:00 2001 From: momen Date: Fri, 11 Jul 2025 00:31:18 +0800 Subject: [PATCH 107/114] =?UTF-8?q?chore:=E7=82=B9=E5=87=BB=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E6=97=B6=EF=BC=8C=E8=B0=83=E7=94=A8=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mainwindow-dtk.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/mainwindow-dtk.cpp b/src/mainwindow-dtk.cpp index c457f76..9993c43 100755 --- a/src/mainwindow-dtk.cpp +++ b/src/mainwindow-dtk.cpp @@ -552,11 +552,11 @@ void MainWindow::on_pushButton_14_clicked() if (!upgradeStatus.exists()) { QString appPath; - + // 开发环境路径(构建目录) #ifdef QT_DEBUG - appPath = QCoreApplication::applicationDirPath() + - "/../spark-update-tool/spark-update-tool"; + appPath = QCoreApplication::applicationDirPath() + + "/spark-update-tool/spark-update-tool"; #else // 安装后路径(系统PATH) appPath = QStandardPaths::findExecutable("spark-update-tool"); @@ -569,8 +569,8 @@ void MainWindow::on_pushButton_14_clicked() QProcess *process = new QProcess(this); process->start(appPath, {"--silent"}); - - connect(process, QOverload::of(&QProcess::finished), + + connect(process, QOverload::of(&QProcess::finished), [=](int exitCode) { if (exitCode == 0) { qDebug() << "Update check successful"; From a20e96c63f400fe39ed1dddef11883bf51a6758d Mon Sep 17 00:00:00 2001 From: momen Date: Sat, 12 Jul 2025 12:17:11 +0800 Subject: [PATCH 108/114] =?UTF-8?q?chore:=E6=9B=B4=E6=96=B0readme=E5=AF=B9?= =?UTF-8?q?deepin=E7=94=A8=E6=88=B7=E4=BD=BF=E7=94=A8=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E5=99=A8=E7=9A=84=E5=8F=99=E8=BF=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.zh.md | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/README.zh.md b/README.zh.md index 2f62191..7c0f2be 100644 --- a/README.zh.md +++ b/README.zh.md @@ -48,14 +48,23 @@ https://github.com/spark-store-project/spark-store ## 目录 -- [阅读版权声明](#阅读版权声明) -- [确定您的系统架构](#确定你的系统架构) -- [系统支持与安装指引](#系统支持与安装指引) - - [对于 deepin / UOS 用户](#对于deepin用户) - - [对于 Ubuntu 用户](#对于ubuntu用户) - - [对于 Debian 用户](#对于debian用户) -- [常见问题(FAQ)](#常见问题faq) -- [联系与反馈](#联系与反馈) +- [星火应用商店](#星火应用商店) + - [简介](#简介) + - [关于团队协作](#关于团队协作) + - [目录](#目录) + - [阅读版权声明](#阅读版权声明) + - [确定你的系统架构](#确定你的系统架构) + - [系统支持与安装指引](#系统支持与安装指引) + - [对于 deepin 用户](#对于-deepin-用户) + - [对于 deepin 用户](#对于-deepin-用户-1) + - [对于 Ubuntu 用户](#对于-ubuntu-用户) + - [对于 Ubuntu 20.04 用户](#对于-ubuntu-2004-用户) + - [对于 Ubuntu 22.04 及更高版本的 Ubuntu 用户](#对于-ubuntu-2204-及更高版本的-ubuntu-用户) + - [对于 Debian 用户](#对于-debian-用户) + - [对于 Debian 11 用户](#对于-debian-11-用户) + - [对于 Debian 12+ 用户](#对于-debian-12-用户) + - [常见问题(FAQ)](#常见问题faq) + - [联系与反馈](#联系与反馈) --- @@ -103,6 +112,9 @@ https://github.com/spark-store-project/spark-store cd ~/Downloads sudo apt install ./spark-store*.deb ``` +2. **使用更新器** + 您可以在应用商店左下角找到更新按钮,点击并输入密码即可。 + ### 对于 Ubuntu 用户 From 0c3151948c928f14fda79bfe89b502a4b1a41063 Mon Sep 17 00:00:00 2001 From: momen Date: Sun, 13 Jul 2025 16:27:02 +0800 Subject: [PATCH 109/114] =?UTF-8?q?update:=E6=9E=84=E5=BB=BA=E8=BD=AF?= =?UTF-8?q?=E9=93=BE=E6=8E=A5=EF=BC=8C=E5=B0=86=E6=9B=B4=E6=96=B0=E5=99=A8?= =?UTF-8?q?=E6=94=BE=E5=85=A5/usr/bin/=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- debian/spark-store.postinst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/spark-store.postinst b/debian/spark-store.postinst index 879a976..89b442d 100755 --- a/debian/spark-store.postinst +++ b/debian/spark-store.postinst @@ -41,7 +41,7 @@ case "$1" in ln -s -f /opt/durapps/spark-store/bin/aptss /usr/local/bin/ss-apt-fast ln -s -f /opt/durapps/spark-store/bin/aptss /usr/bin/aptss - + ln -sf /usr/lib/qt5/bin/spark-update-tool /usr/bin/spark-update-tool # Install key From 9bf8ff8c50917c3c45d16bcaf20f7db0ea040147 Mon Sep 17 00:00:00 2001 From: momen Date: Mon, 14 Jul 2025 23:39:23 +0800 Subject: [PATCH 110/114] =?UTF-8?q?chore:=E6=B7=BB=E5=8A=A0=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E5=99=A8=E7=9A=84policy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../actions/store.spark-update-tool.policy | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 pkg/usr/share/polkit-1/actions/store.spark-update-tool.policy diff --git a/pkg/usr/share/polkit-1/actions/store.spark-update-tool.policy b/pkg/usr/share/polkit-1/actions/store.spark-update-tool.policy new file mode 100644 index 0000000..012a66a --- /dev/null +++ b/pkg/usr/share/polkit-1/actions/store.spark-update-tool.policy @@ -0,0 +1,16 @@ + + + + + Run the Spark Update Tool + Authentication is required to update the system + /usr/bin/spark-update-tool + true + + yes + no + + + From 1f6e68ca3fc0759f4b4733dd6d687ac487d8818e Mon Sep 17 00:00:00 2001 From: momen Date: Mon, 14 Jul 2025 23:52:34 +0800 Subject: [PATCH 111/114] =?UTF-8?q?chore:=E5=88=A0=E9=99=A4=E6=97=A7?= =?UTF-8?q?=E5=AE=89=E8=A3=85=E5=99=A8policy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../store.spark-app.ss-do-upgrade.policy | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 pkg/usr/share/polkit-1/actions/store.spark-app.ss-do-upgrade.policy diff --git a/pkg/usr/share/polkit-1/actions/store.spark-app.ss-do-upgrade.policy b/pkg/usr/share/polkit-1/actions/store.spark-app.ss-do-upgrade.policy deleted file mode 100644 index d82d670..0000000 --- a/pkg/usr/share/polkit-1/actions/store.spark-app.ss-do-upgrade.policy +++ /dev/null @@ -1,18 +0,0 @@ - - - - Spark Store - x-package-repository - - 运行ss-do-upgrade需要权限 - 要使用ss-do-upgrade需要权限 - - yes - yes - yes - - /opt/durapps/spark-store/bin/update-upgrade/ss-do-upgrade.sh - true - - From 30acad75166b1303897c736d5213846d558d9727 Mon Sep 17 00:00:00 2001 From: momen Date: Tue, 15 Jul 2025 00:45:42 +0800 Subject: [PATCH 112/114] =?UTF-8?q?chore:=E4=BD=BF=E7=94=A8pkexec=E8=B0=83?= =?UTF-8?q?=E7=94=A8=E6=9B=B4=E6=96=B0=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mainwindow-dtk.cpp | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/src/mainwindow-dtk.cpp b/src/mainwindow-dtk.cpp index 9993c43..5baca0e 100755 --- a/src/mainwindow-dtk.cpp +++ b/src/mainwindow-dtk.cpp @@ -345,7 +345,7 @@ void MainWindow::refreshTheme(bool isDarkMode) ui->applistpage->setTheme(isDarkMode); ui->applistpage_1->setTheme(isDarkMode); ui->appintopage->setTheme(isDarkMode); - ui->settingspage->setTheme(isDarkMode); + ui->settingspage->setTheme(isDarkMode); } void MainWindow::initConnections() @@ -551,16 +551,15 @@ void MainWindow::on_pushButton_14_clicked() QFile upgradeStatus("/tmp/spark-store/upgradeStatus.txt"); if (!upgradeStatus.exists()) { - QString appPath; + QString appPath; - // 开发环境路径(构建目录) - #ifdef QT_DEBUG - appPath = QCoreApplication::applicationDirPath() + - "/spark-update-tool/spark-update-tool"; - #else - // 安装后路径(系统PATH) - appPath = QStandardPaths::findExecutable("spark-update-tool"); - #endif + // 判断路径:开发环境 vs 安装后 + #ifdef QT_DEBUG + appPath = QCoreApplication::applicationDirPath() + + "/spark-update-tool/spark-update-tool"; + #else + appPath = QStandardPaths::findExecutable("spark-update-tool"); + #endif if (appPath.isEmpty()) { qWarning() << "spark-update-tool not found!"; @@ -568,17 +567,27 @@ void MainWindow::on_pushButton_14_clicked() } QProcess *process = new QProcess(this); - process->start(appPath, {"--silent"}); - connect(process, QOverload::of(&QProcess::finished), - [=](int exitCode) { + #ifdef QT_DEBUG + // 开发模式:直接运行本地构建的更新器 + process->start(appPath, {"--silent"}); + #else + // 安装模式:使用 pkexec 提权运行系统路径下的 spark-update-tool + QString program = "pkexec"; + QStringList arguments; + arguments << appPath << "--silent"; + process->start(program, arguments); + #endif + + QObject::connect(process, QOverload::of(&QProcess::finished), + [process](int exitCode) { if (exitCode == 0) { qDebug() << "Update check successful"; } else { - qDebug() << "Update check failed"; + qWarning() << "Update check failed with exit code:" << exitCode; } process->deleteLater(); }); - } - } + } + } } From 4c93f0e389cfdb49037b5d6033351d37cd57706e Mon Sep 17 00:00:00 2001 From: momen Date: Wed, 16 Jul 2025 14:45:26 +0800 Subject: [PATCH 113/114] =?UTF-8?q?chore:=E6=9B=B4=E6=96=B0=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- debian/changelog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/debian/changelog b/debian/changelog index 84b1509..7799257 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +spark-store (4.8.1~test1) UNRELEASED; urgency=medium + + * 添加全新的更新器 + * 替换了新版更新器的polkit policy + -- momen Tue, 15 Jul 2025 01:03:08 +0800 + spark-store (4.8.0) UNRELEASED; urgency=medium * ssinstall重写,支持安装到ACE和自动安装到ACE,支持只允许安装到本地 From b704ee0093b371c042fe5ed7e4a71861fd0745bf Mon Sep 17 00:00:00 2001 From: momen Date: Thu, 17 Jul 2025 21:29:52 +0800 Subject: [PATCH 114/114] =?UTF-8?q?chore:=E6=9B=B4=E6=96=B0readme=E5=85=B3?= =?UTF-8?q?=E4=BA=8E=E6=9B=B4=E6=96=B0=E5=99=A8=E7=9A=84=E9=83=A8=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.zh.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.zh.md b/README.zh.md index 7c0f2be..8472861 100644 --- a/README.zh.md +++ b/README.zh.md @@ -113,7 +113,7 @@ https://github.com/spark-store-project/spark-store sudo apt install ./spark-store*.deb ``` 2. **使用更新器** - 您可以在应用商店左下角找到更新按钮,点击并输入密码即可。 + 您可以在应用商店左下角找到更新按钮,点击即可查看更新列表。 ### 对于 Ubuntu 用户