From 906a75afdae4a146e15109062b4bb7b384f77bd9 Mon Sep 17 00:00:00 2001 From: keke <243768648@qq.com> Date: Fri, 10 Mar 2023 14:25:43 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BD=BF=E7=94=A8=E6=98=9F=E7=81=AB?= =?UTF-8?q?=E5=BA=94=E7=94=A8=E5=95=86=E5=BA=97=E5=8A=9F=E8=83=BD=E5=89=8D?= =?UTF-8?q?=E5=BA=94=E8=AF=A5=E9=9C=80=E8=A6=81=E5=88=A4=E6=96=AD=E6=98=9F?= =?UTF-8?q?=E7=81=AB=E5=95=86=E5=BA=97=E6=98=AF=E5=90=A6=E5=B7=B2=E5=AE=89?= =?UTF-8?q?=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/appmanagermodel.cpp | 7 +++++-- src/appmanagermodel.h | 4 ++-- src/appmanagerwidget.cpp | 2 +- src/job/appmanagerjob.h | 1 - src/mainwindow.cpp | 31 +++++++++++++++++++++++++++++-- src/mainwindow.h | 1 + 6 files changed, 38 insertions(+), 8 deletions(-) diff --git a/src/appmanagermodel.cpp b/src/appmanagermodel.cpp index 9feac20..6ede31c 100644 --- a/src/appmanagermodel.cpp +++ b/src/appmanagermodel.cpp @@ -92,6 +92,11 @@ void AppManagerModel::openStoreAppDetailPage(const QString &pkgName) void AppManagerModel::openSpkStoreAppDetailPage(const QString &pkgName) { + if (isPkgInstalled("spark-store")) { + Q_EMIT notifyOpenSparkStoreNeedBeInstallDlg(); + return; + } + QProcess proc; proc.startDetached("spark-store", {QString("spk://search/%1").arg(pkgName)}); proc.waitForStarted(); @@ -295,8 +300,6 @@ void AppManagerModel::initConnection() connect(this, &AppManagerModel::notifyThreadInstallOhMyDDE, m_appManagerJob, &AppManagerJob::installOhMyDDE); // 安装oh-my-dde完成 connect(m_appManagerJob, &AppManagerJob::installOhMyDDEFinished, this, &AppManagerModel::installOhMyDDEFinished); - // 安装proc-info-plugin完成 - connect(m_appManagerJob, &AppManagerJob::installProcInfoPluginFinished, this, &AppManagerModel::installProcInfoPluginFinished); // 包安装变动 connect(m_appManagerJob, &AppManagerJob::appInstalled, this, &AppManagerModel::onAppInstalled); diff --git a/src/appmanagermodel.h b/src/appmanagermodel.h index 0be5c0f..d6c1d25 100644 --- a/src/appmanagermodel.h +++ b/src/appmanagermodel.h @@ -60,8 +60,8 @@ Q_SIGNALS: void notifyThreadInstallOhMyDDE(); // 安装oh-my-dde完成 void installOhMyDDEFinished(bool successed, const QString &err); - // 安装proc-info-plugin完成 - void installProcInfoPluginFinished(bool successed, const QString &err); + // 通知打开星火应用商店需要安装对话框 + void notifyOpenSparkStoreNeedBeInstallDlg(); // 软件安装变动 void appInstalled(const AM::AppInfo &appInfo); void appUpdated(const AM::AppInfo &appInfo); diff --git a/src/appmanagerwidget.cpp b/src/appmanagerwidget.cpp index 8796553..b7b8d0a 100644 --- a/src/appmanagerwidget.cpp +++ b/src/appmanagerwidget.cpp @@ -425,7 +425,7 @@ AppManagerWidget::AppManagerWidget(AppManagerModel *model, QWidget *parent) // 离线获取安装包 connect(getPkgFromLocalBtn, &QPushButton::clicked, this, [this](bool) { // 确认窗口 - DDialog confirmDlg; + DDialog confirmDlg(this); confirmDlg.setMessage("是否开始离线获取安装包?"); // 取消按钮 diff --git a/src/job/appmanagerjob.h b/src/job/appmanagerjob.h index 6cfb5ee..3c97ed6 100644 --- a/src/job/appmanagerjob.h +++ b/src/job/appmanagerjob.h @@ -78,7 +78,6 @@ Q_SIGNALS: // 构建安装包任务完成 void buildPkgTaskFinished(bool successed, const AM::AppInfo &info); void installOhMyDDEFinished(bool successed, const QString &err); - void installProcInfoPluginFinished(bool successed, const QString &err); // 软件安装变动 void appInstalled(const AM::AppInfo &appInfo); void appUpdated(const AM::AppInfo &appInfo); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 9b02c6a..3272d0e 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -22,7 +23,7 @@ MainWindow::MainWindow(QWidget *parent) { setMinimumSize(500, 300); QRect primaryScreenGeometry = qApp->primaryScreen()->geometry(); - int resizedWidth = int(primaryScreenGeometry.width() * 0.7); + int resizedWidth = int(primaryScreenGeometry.width() * 0.65); int resizedHeight = int(resizedWidth * 3 / 5); resize(resizedWidth, resizedHeight); // 设置背景 @@ -149,7 +150,8 @@ MainWindow::MainWindow(QWidget *parent) // 安装完成时 connect(m_appManagerModel, &AppManagerModel::installOhMyDDEFinished, this, &MainWindow::onPkgInstallFinished); - connect(m_appManagerModel, &AppManagerModel::installProcInfoPluginFinished, this, &MainWindow::onPkgInstallFinished); + connect(m_appManagerModel, &AppManagerModel::notifyOpenSparkStoreNeedBeInstallDlg, + this, &MainWindow::openSparkStoreNeedBeInstallDlg); // 下载失败 connect(m_appManagerModel, &AppManagerModel::pkgFileDownloadFailed, this, [this](const PkgInfo &info) { @@ -213,6 +215,31 @@ void MainWindow::onPkgInstallFinished(bool successed, const QString &err) dlg->deleteLater(); } +void MainWindow::openSparkStoreNeedBeInstallDlg() +{ + DDialog *dlg = new DDialog(this); + dlg->setIcon(QIcon::fromTheme("dialog-warning")); + + QLabel *tipLabel = new QLabel(dlg); + tipLabel->setWordWrap(true); + tipLabel->setOpenExternalLinks(true); + tipLabel->setText("本功能需要使用星火应用商店,请前往下面的网址下载安装星火应用商店后,再重试此功能"); + dlg->addContent(tipLabel); + + //超链接标签 + QLabel *linkLabel = new QLabel(dlg); + linkLabel->setWordWrap(true); + linkLabel->setOpenExternalLinks(true);//设置点击连接自动打开((跳转到浏览器) + linkLabel->setTextInteractionFlags(Qt::TextInteractionFlag::TextBrowserInteraction); + const QString websiteLink = "https://gitee.com/deepin-community-store/spark-store/releases"; + QString text = QString("%2").arg(websiteLink).arg(websiteLink); + linkLabel->setText(text); + dlg->addContent(linkLabel); + + dlg->exec(); + dlg->deleteLater(); +} + void MainWindow::updateUIByRunningStatus() { bool enable = (RunningStatus::Normal == m_appManagerModel->getRunningStatus()); diff --git a/src/mainwindow.h b/src/mainwindow.h index 6a4ba94..d73da5f 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -24,6 +24,7 @@ protected: private Q_SLOTS: // 安装包安装完成时 void onPkgInstallFinished(bool successed, const QString &err); + void openSparkStoreNeedBeInstallDlg(); private: void updateUIByRunningStatus(); -- Gitee