Merge pull request #167 from mammonsama666/0311-dev

fix(frontend): Software center will not refresh which is already opened.
This commit is contained in:
iaom 2021-03-11 22:36:19 +08:00 committed by GitHub
commit fcb4203a26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 30 additions and 10 deletions

View File

@ -329,7 +329,7 @@ void AppMatch::parseSoftWareCenterReturn(QList<QMap<QString,QString>> list,QMap<
appdiscription=list.at(i).value("discription");
appicon=list.at(i).value("icon");
name.app_name = appname;
pkgname.isEmpty() ? softwarereturn.insert(name,applist<<""<<appicon<<appdiscription) : softwarereturn.insert(name,applist<<""<<appicon<<pkgname<<appdiscription);
pkgname.isEmpty() ? softwarereturn.insert(name,applist<<""<<appicon<<""<<appdiscription) : softwarereturn.insert(name,applist<<""<<appicon<<pkgname<<appdiscription);
applist.clear();
}
}

View File

@ -33,6 +33,7 @@
#include <QApplication>
#include <QFileInfo>
#include <QDateTime>
#include <QDBusMetaType>
#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)
{
//打开软件商店下载此软件
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<bool>(interface->call(QString("show_search_result"), name));
return reply;
} else {
//软件商店未打开,打开软件商店下载此软件
qDebug()<<"软件商店未打开,打开软件商店下载此软件"<<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;
return process.startDetached(QString("kylin-software-center -find %1").arg(name));
}
}
void SearchDetailView::paintEvent(QPaintEvent *event) {

View File

@ -67,6 +67,7 @@ private:
int m_type = 0;
QString m_path = 0;
QString m_name = 0; //目前只有未安装应用在打开软件商店时需要此参数
QString m_pkgname = 0; //目前只有未安装应用在打开软件商店时需要此参数
void initUI();
QLabel * m_iconLabel = nullptr;

View File

@ -159,8 +159,14 @@ int main(int argc, char *argv[])
qInstallMessageHandler(messageOutput);
qRegisterMetaType<QPair<QString,QStringList>>("QPair<QString,QStringList>");
qRegisterMetaType<Document>("Document");
#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);

View File

@ -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;