应用代理界面加载应用列表setPixmap卡顿问题
This commit is contained in:
parent
8c406d4f5d
commit
36cb86cd6b
|
@ -43,12 +43,11 @@ void AppListWidget::setAppChecked(bool flag)
|
|||
|
||||
/**
|
||||
* @brief AppListWidget::setAppIcon
|
||||
* @param icon 应用图标的名称
|
||||
* @param icon 应用图标
|
||||
*/
|
||||
void AppListWidget::setAppIcon(const QPixmap &icon)
|
||||
void AppListWidget::setAppIcon(const QIcon &icon)
|
||||
{
|
||||
m_iconLabel->setAlignment(Qt::AlignCenter);
|
||||
m_iconLabel->setPixmap(icon);
|
||||
m_iconBtn->setIcon(icon);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -119,12 +118,19 @@ void AppListWidget::initUI()
|
|||
mainLayout->setSpacing(8);
|
||||
m_checkBox = new QCheckBox(this);
|
||||
m_checkBox->setAttribute(Qt::WA_TransparentForMouseEvents, true); //m_checkBox不响应鼠标事件,将其传递给父窗口
|
||||
m_iconLabel = new QLabel(this);
|
||||
m_iconLabel->setFixedSize(24, 24);
|
||||
|
||||
m_iconBtn = new QToolButton(this);
|
||||
m_iconBtn->setToolButtonStyle(Qt::ToolButtonStyle::ToolButtonIconOnly);
|
||||
m_iconBtn->setAttribute(Qt::WA_TranslucentBackground, true); //透明
|
||||
m_iconBtn->setAttribute(Qt::WA_TransparentForMouseEvents, true);
|
||||
m_iconBtn->setAutoRaise(true);
|
||||
m_iconBtn->setFixedSize(24, 24);
|
||||
m_iconBtn->setIconSize(QSize(24, 24));
|
||||
|
||||
m_nameLabel = new QLabel(this);
|
||||
|
||||
mainLayout->addWidget(m_checkBox);
|
||||
mainLayout->addWidget(m_iconLabel);
|
||||
mainLayout->addWidget(m_iconBtn);
|
||||
mainLayout->addWidget(m_nameLabel);
|
||||
mainLayout->addStretch();
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include <QHBoxLayout>
|
||||
#include <QDBusInterface>
|
||||
#include <QDBusReply>
|
||||
#include <QToolButton>
|
||||
|
||||
class AppListWidget : public QWidget
|
||||
{
|
||||
|
@ -37,7 +38,7 @@ public:
|
|||
~AppListWidget();
|
||||
|
||||
void setAppChecked(bool flag);
|
||||
void setAppIcon(const QPixmap &icon);
|
||||
void setAppIcon(const QIcon &icon);
|
||||
void setAppName(const QString &text);
|
||||
void onAppCheckStateChanged();
|
||||
void AddAppProxyConfig();
|
||||
|
@ -51,7 +52,7 @@ private:
|
|||
void initDbus();
|
||||
|
||||
QCheckBox *m_checkBox = nullptr;
|
||||
QLabel *m_iconLabel = nullptr;
|
||||
QToolButton *m_iconBtn = nullptr;
|
||||
QLabel *m_nameLabel = nullptr;
|
||||
QString m_path = nullptr;
|
||||
QDBusInterface *m_dbusInterface = nullptr;
|
||||
|
|
|
@ -1227,7 +1227,7 @@ void Proxy::appListPadding()
|
|||
|
||||
AppListWidget *appWidget = new AppListWidget(index, m_appListWidget);
|
||||
appWidget->setAppName(appInfo.value(0));
|
||||
appWidget->setAppIcon(QIcon::fromTheme(appInfo.value(1)).pixmap(24, 24));
|
||||
appWidget->setAppIcon(QIcon::fromTheme(appInfo.value(1)));
|
||||
appWidget->setAppChecked(flag);
|
||||
|
||||
QListWidgetItem *appListWidgetItem = new QListWidgetItem(m_appListWidget);
|
||||
|
|
Loading…
Reference in New Issue