Skip to content

Add automatic download and installation for PAGViewer #2940

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

YyZz-wy
Copy link
Collaborator

@YyZz-wy YyZz-wy commented Jul 23, 2025

点击预览PAG文件时,检测是否安装PAGViewer,如果未安装则自动下载与安装

@Copilot Copilot AI review requested due to automatic review settings July 23, 2025 07:58
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements automatic download and installation functionality for PAGViewer. When users click to preview PAG files, the system now detects whether PAGViewer is installed and automatically downloads and installs it if not found.

  • Adds cross-platform PAGViewer detection and installation system
  • Implements a Qt-based installation dialog with progress tracking
  • Integrates installation workflow into the PAG file preview process

Reviewed Changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
exporter/src/ui/PAGViewerInstallModel.h/.cpp New Qt model for installation dialog UI and workflow management
exporter/src/platform/win/PlatformHelper.cpp Enhanced with download path utilities and preview integration
exporter/src/platform/win/PAGViewerInstallerWin.cpp Windows-specific PAGViewer installation logic
exporter/src/platform/win/PAGViewerCheck.cpp Windows registry-based PAGViewer detection
exporter/src/platform/mac/PlatformHelper.mm macOS implementation with NSWorkspace integration
exporter/src/platform/mac/PAGViewerInstallerMac.mm macOS-specific installation handling
exporter/src/platform/mac/PAGViewerCheck.mm macOS bundle-based application detection
exporter/src/platform/PlatformHelper.h Added new platform abstraction functions
exporter/src/platform/PAGViewerInstaller.h/.cpp Cross-platform installer with Qt networking
exporter/src/platform/PAGViewerCheck.h Common interfaces for application detection
exporter/assets/qml/PAGViewerInstall.qml Installation dialog UI implementation
exporter/CMakeLists.txt Added Qt6::Network dependency

@codecov-commenter
Copy link

codecov-commenter commented Jul 23, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 77.27%. Comparing base (706c3ae) to head (6929fb0).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2940      +/-   ##
==========================================
- Coverage   77.28%   77.27%   -0.01%     
==========================================
  Files         419      419              
  Lines       22322    22322              
  Branches     6425     6425              
==========================================
- Hits        17251    17250       -1     
- Misses       3795     3796       +1     
  Partials     1276     1276              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

InstallResult result;
std::string errorMessage;

InstallStatus() = default;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

默认构造方法可以不写

Comment on lines +125 to +127
return executeInstaller(filePath);
#else
return extractAndInstall(filePath);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感觉这两个函数也可以合并成一个,在不同的平台上有不同的实现,win上安装exe,mac上解压zip

QDir(tempDir).removeRecursively();
}

void PAGViewerInstaller::onDownloadProgress(qint64 bytesReceived, qint64 bytesTotal) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

看QT的api 文档,bytesTotal是有可能为0和-1的,这里对异常情况处理下
https://doc.qt.io/qt-6/qnetworkreply.html#downloadProgress
Clipboard_Screenshot_1753447233

Comment on lines +47 to +49
NSString* downloadsPath = [NSString stringWithUTF8String:downloadsPathStr.c_str()];
NSString* fullPath = [downloadsPath stringByAppendingPathComponent:@"PAGViewer.dmg"];
return [fullPath UTF8String];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里没必要转NSString,直接使用std::string就可以了

}

void AppConfig::addConfig(const std::string& key, const std::string& value) {
this->platformConfig[key] = value;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

key会空吗?如果key存在,预期的行为是覆盖吗

return info;
}

std::vector<PackageInfo> PAGViewerCheck::findSoftwareByName(const std::string& namePattern) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

函数名和返回值类型匹配起来,例如:findPackageInfoByName

}

static void executePreviewLogic(const std::string& pagFilePath) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

去掉函数名中的Logic


static std::string wstringToString(const std::wstring& wstr) {
if (wstr.empty()) {
return std::string();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return "";

return results.empty() ? PackageInfo() : results[0];
}

std::vector<PackageInfo> PAGViewerCheck::findSoftwareByName(const std::string& namePattern) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

findPackageInfoByName

return "";
}

static void ExecutePreview(const std::string& pagFilePath) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好像叫StartPreview更合适点

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants