diff --git a/appmanagercommon.h b/appmanagercommon.h index c591d51ba407a0b2cc4af89a31379232994a723e..54a5fd8344632158c1f09412e3d9d9a2c4f3fcc6 100644 --- a/appmanagercommon.h +++ b/appmanagercommon.h @@ -1,6 +1,6 @@ #pragma once -#include +#include #define ONLY_SHOW_IN_VALUE_DEEPIN "Deepin" #define X_DEEPIN_VENDOR_STR "deepin" @@ -8,7 +8,7 @@ #define APP_THEME_ICON_DEFAULT "application-x-executable" // 列表数据角色定义 -#define AM_LIST_VIEW_ITEM_DATA_ROLE_PKG_NAME Qt::ItemDataRole::UserRole + 1 +#define AM_LIST_VIEW_ITEM_DATA_ROLE_PKG_NAME Dtk::ItemDataRole::UserRole + 1 namespace AM { // 运行状态 diff --git a/appmanagerwidget.cpp b/appmanagerwidget.cpp index 40994682eff565244989b8392889124b9a39123e..dc3c896fdfaafa435de2067fc6a0dbeeff9f8787 100644 --- a/appmanagerwidget.cpp +++ b/appmanagerwidget.cpp @@ -28,6 +28,10 @@ using namespace AM; +Q_DECLARE_METATYPE(QMargins) +const QMargins ListViewItemMargin(5, 3, 5, 3); +const QVariant ListViewItemMarginVar = QVariant::fromValue(ListViewItemMargin); + AppManagerWidget::AppManagerWidget(AppManagerModel *model, QWidget *parent) : QWidget(parent) , m_model(model) @@ -125,6 +129,8 @@ AppManagerWidget::AppManagerWidget(AppManagerModel *model, QWidget *parent) m_appListView = new DListView(this); m_appListView->setSpacing(0); m_appListView->setItemSpacing(1); + m_appListView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + m_appListView->setFrameShape(QFrame::Shape::NoFrame); m_appListView->setTextElideMode(Qt::TextElideMode::ElideMiddle); m_appListView->setEditTriggers(DListView::EditTrigger::NoEditTriggers); m_appListView->setAutoFillBackground(true); @@ -399,6 +405,7 @@ void AppManagerWidget::showAppInfo(const AppInfo &info) if (m_showingAppInfo.installedPkgInfo.version == srvPkgInfo.version) { m_showingAppInfo.installedPkgInfo.pkgSize = srvPkgInfo.pkgSize; m_showingAppInfo.installedPkgInfo.downloadUrl = srvPkgInfo.downloadUrl; + break; } } @@ -408,7 +415,12 @@ void AppManagerWidget::showAppInfo(const AppInfo &info) } else { m_appAbstractLabel->setPixmap(QIcon::fromTheme(APP_THEME_ICON_DEFAULT).pixmap(40, 40)); } - m_appNameLable->setText(m_showingAppInfo.desktopInfo.appName); + + QString appName = m_showingAppInfo.desktopInfo.appName; + if (appName.isEmpty()) { + appName = m_showingAppInfo.pkgName; + } + m_appNameLable->setText(appName); m_infoBtn->setChecked(true); @@ -713,6 +725,7 @@ void AppManagerWidget::setItemModelFromAppInfoList(const QList &appInfo appName = info.pkgName; } QStandardItem *item = new QStandardItem(appName); + item->setData(ListViewItemMarginVar, Dtk::ItemDataRole::MarginsRole); if (!info.desktopInfo.themeIconName.isEmpty()) { item->setIcon(QIcon::fromTheme(info.desktopInfo.themeIconName)); } else {