mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-09-06 19:32:22 +08:00
64 lines
1.6 KiB
C++
64 lines
1.6 KiB
C++
|
|
#include <QPainter>
|
|
#include <QStyleOption>
|
|
#include "spkappitem.h"
|
|
#include "qt/elidedlabel.h"
|
|
|
|
const QSize SpkAppItem::IconSize_;
|
|
|
|
SpkAppItem::SpkAppItem(int appId, QWidget *parent) : QWidget(parent)
|
|
{
|
|
mAppId = appId;
|
|
|
|
mMainLay = new QHBoxLayout(this);
|
|
mLayText = new QVBoxLayout;
|
|
|
|
mIcon = new QLabel;
|
|
mIcon->setFixedSize(IconSize, IconSize);
|
|
mIcon->setAutoFillBackground(false);
|
|
|
|
// NOTE: Make mTitle ElidedTitle too?
|
|
mTitle = new QLabel;
|
|
mTitle->setWordWrap(false);
|
|
mTitle->setObjectName("styAppItmTitle");
|
|
mTitle->setAutoFillBackground(true);
|
|
mDescription = new ElidedLabel;
|
|
// mDescription->setWordWrap(true); // Commented out since ElidedLabel lacks of these methods
|
|
mDescription->setObjectName("styAppItmDesc");
|
|
mDescription->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
|
// mDescription->setAlignment(Qt::AlignTop | Qt::AlignLeft);
|
|
// mDescription->setAutoFillBackground(true);
|
|
mLayText->addWidget(mTitle);
|
|
mLayText->addWidget(mDescription);
|
|
mLayText->setAlignment(Qt::AlignTop);
|
|
|
|
mMainLay->setMargin(5);
|
|
mMainLay->addWidget(mIcon);
|
|
mMainLay->addLayout(mLayText);
|
|
|
|
setMinimumHeight(82);
|
|
setMaximumHeight(82);
|
|
setMinimumWidth(300);
|
|
}
|
|
|
|
void SpkAppItem::paintEvent(QPaintEvent *e)
|
|
{
|
|
Q_UNUSED(e)
|
|
QStyleOption opt;
|
|
opt.init(this);
|
|
QPainter p(this);
|
|
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
|
|
}
|
|
|
|
void SpkAppItem::mousePressEvent(QMouseEvent *e)
|
|
{
|
|
mPressCond = true;
|
|
}
|
|
|
|
void SpkAppItem::mouseReleaseEvent(QMouseEvent *e)
|
|
{
|
|
if(mPressCond)
|
|
emit clicked(mAppId);
|
|
mPressCond = false;
|
|
}
|