From 3519dbe2c274d9f9b90300755c28460657cee062 Mon Sep 17 00:00:00 2001 From: zhangjiaping Date: Thu, 11 Mar 2021 11:09:47 +0800 Subject: [PATCH] fix(frontend): Software center will not refresh which is already opened. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Description: 修复软件商店打开后点击安装不会再跳转的bug Log: 修复软件商店打开后点击安装不会再跳转的bug Bug: http://172.17.66.192/biz/bug-view-41150.html --- libsearch/appsearch/app-match.cpp | 2 +- src/control/search-detail-view.cpp | 25 +++++++++++++++++++------ src/control/search-detail-view.h | 1 + src/main.cpp | 10 ++++++++-- src/search-app-thread.cpp | 2 +- 5 files changed, 30 insertions(+), 10 deletions(-) diff --git a/libsearch/appsearch/app-match.cpp b/libsearch/appsearch/app-match.cpp index 45439f3..3136a3f 100644 --- a/libsearch/appsearch/app-match.cpp +++ b/libsearch/appsearch/app-match.cpp @@ -327,7 +327,7 @@ void AppMatch::parseSoftWareCenterReturn(QList> list,QMap< appdiscription=list.at(i).value("discription"); appicon=list.at(i).value("icon"); name.app_name = appname; - pkgname.isEmpty() ? softwarereturn.insert(name,applist<<""< #include #include +#include #include "config-file.h" SearchDetailView::SearchDetailView(QWidget *parent) : QWidget(parent) @@ -178,6 +179,7 @@ void SearchDetailView::setAppWidget(const QString &appname, const QString &path, m_type = SearchListView::ResType::App; m_path = path; m_name = appname.contains("/") ? appname.left(appname.indexOf("/")) : appname; + m_pkgname = appname.contains("/") ? appname.mid(appname.indexOf("/") + 1) : appname; m_isEmpty = false; clearLayout(); m_iconLabel->show(); @@ -377,7 +379,7 @@ void SearchDetailView::execActions(const int& type, const int& option, const QSt break; } case OptionView::Options::Install: { - installAppAction(m_name); //未安装应用点击此选项,不使用路径作为参数,而是使用软件名 + installAppAction(m_pkgname); //未安装应用点击此选项,不使用路径作为参数,而是使用软件名 } default: break; @@ -588,11 +590,22 @@ bool SearchDetailView::copyPathAction(const QString& path) { */ bool SearchDetailView::installAppAction(const QString & name) { - //打开软件商店下载此软件 - QProcess process; - QString app_name = name.contains("/") ? name.mid(name.indexOf("/") + 1) : name; - bool res = process.startDetached(QString("kylin-software-center -find %1").arg(app_name)); - return res; + QDBusInterface * interface = new QDBusInterface( "com.kylin.softwarecenter", + "/com/kylin/softwarecenter", + "com.kylin.utiliface", + QDBusConnection::sessionBus() ); + + if (interface->isValid()) { + //软件商店已打开,直接跳转 + interface->call("show_search_result",name); + bool reply = QDBusReply(interface->call(QString("show_search_result"), name)); + return reply; + } else { + //软件商店未打开,打开软件商店下载此软件 + qDebug()<<"软件商店未打开,打开软件商店下载此软件"<>("QPair"); qRegisterMetaType("Document"); - QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); - QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); + +#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)) + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); + QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); +#endif +#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) + QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough); +#endif QtSingleApplication app("ukui-search", argc, argv); app.setQuitOnLastWindowClosed(false); diff --git a/src/search-app-thread.cpp b/src/search-app-thread.cpp index a5bd942..58a8ea6 100644 --- a/src/search-app-thread.cpp +++ b/src/search-app-thread.cpp @@ -49,7 +49,7 @@ void SearchAppThread::run() uninstalled_iter.next(); QString name; //当返回列表的value中含包名时,将名称按“应用名/包名”的格式存储 - if (uninstalled_iter.value().length() > 2) { + if (!uninstalled_iter.value().at(2).isEmpty() && uninstalled_iter.value().at(2) != "") { name = uninstalled_iter.key().app_name + "/" + uninstalled_iter.value().at(2); } else name = uninstalled_iter.key().app_name; nameList << name;