diff --git a/libsearch/appsearch/app-match.cpp b/libsearch/appsearch/app-match.cpp index 5ae27ad..c099ae8 100644 --- a/libsearch/appsearch/app-match.cpp +++ b/libsearch/appsearch/app-match.cpp @@ -329,7 +329,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;