kylin-connectivity/ui/filemanageview/multimediawin.cpp

76 lines
2.2 KiB
C++
Raw Normal View History

#include "multimediawin.h"
#include <QDebug>
#include <QScrollBar>
MultiMediaWin::MultiMediaWin(QWidget *parent) : QListWidget(parent)
{
setAutoFillBackground(true);
setBackgroundRole(QPalette::Base);
// 设置显示图标模式
setViewMode(QListView::IconMode);
// 自适应布局
setResizeMode(QListView::Adjust);
setMinimumWidth(920);
// 列表中的图标不可拖动
setMovement(QListView::Static);
// 去边框
setFrameShape(QListWidget::NoFrame);
// 设置边距
setSpacing(16);
// 不可选择项目
setSelectionMode(QListView::NoSelection);
// 禁用滚动
verticalScrollBar()->setDisabled(true);
horizontalScrollBar()->setDisabled(true);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setStyleSheet("QListWidget{background:transparent;}"
"QListWidget::Item{background:transparent;}"
"QListWidget::Item:Hover{background:transparent;}");
for (int i = 0; i < 4; i++) {
addMultiMediaItem(AndroidItem::Type(i));
}
}
MultiMediaWin::~MultiMediaWin() {}
void MultiMediaWin::setAppItem()
{
for (int i = 4; i < 6; i++) {
addMultiMediaItem(AndroidItem::Type(i));
}
}
void MultiMediaWin::setItemCount(AndroidItem::Type type, int num)
{
if (type > m_maxItemIndex) {
qCritical() << "More than the maximum number of items.";
return;
}
m_itemMap.value(type)->setItemCount(num);
}
void MultiMediaWin::setTheme(PublicAttributes::Theme theme)
{
QMap<AndroidItem::Type, AndroidItem *>::iterator itemIt = m_itemMap.begin();
while (m_itemMap.end() != itemIt) {
itemIt.value()->setTheme(theme);
itemIt++;
}
}
void MultiMediaWin::addMultiMediaItem(AndroidItem::Type type)
{
m_maxItemIndex++;
QListWidgetItem *item = new QListWidgetItem(this);
AndroidItem *itemWidget = new AndroidItem(type, this);
item->setSizeHint(itemWidget->size());
addItem(item);
setItemWidget(item, itemWidget);
m_itemMap.insert(type, itemWidget);
connect(itemWidget, &AndroidItem::sigBtnClicked, this, &MultiMediaWin::sigBtnClicked);
}