🦄 refactor(UI模块): 调整文件结构
|
@ -11,23 +11,6 @@ enum DeviceType {
|
|||
Pc = 0,
|
||||
Android,
|
||||
};
|
||||
enum MultType {
|
||||
QQPicture,
|
||||
QQVideo,
|
||||
QQMusic,
|
||||
QQDoc,
|
||||
WPicture,
|
||||
WVideo,
|
||||
WMusic,
|
||||
WDoc,
|
||||
Picture,
|
||||
Video,
|
||||
Music,
|
||||
Doc,
|
||||
Wechat,
|
||||
QQ,
|
||||
HomePage
|
||||
};
|
||||
|
||||
} // namespace PublicAttributes
|
||||
|
||||
|
|
Before Width: | Height: | Size: 458 B After Width: | Height: | Size: 458 B |
After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
|
@ -0,0 +1,21 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="16px" height="16px" viewBox="0 0 16 16" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<title>btn/ checkbox/ normal</title>
|
||||
<g id="客户端-TM" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<g id="TM-客户端-图片-图标模式" transform="translate(-530.000000, -468.000000)">
|
||||
<g id="客户端" transform="translate(-2.000000, -6.000000)">
|
||||
<g id="编组-4备份" transform="translate(70.000000, 414.000000)">
|
||||
<g id="image/-大备份-3" transform="translate(386.000000, 56.000000)">
|
||||
<g id="Checkbox/selected-normal" transform="translate(76.000000, 4.000000)">
|
||||
<rect id="Not_selected-_click备份" stroke="#3790FA" fill="#FFFFFF" x="0.5" y="0.5" width="15" height="15" rx="4"></rect>
|
||||
<g id="勾选" transform="translate(1.000000, 1.000000)" fill="#3790FA">
|
||||
<rect id="矩形" fill-rule="nonzero" opacity="0" x="0" y="0" width="14" height="14"></rect>
|
||||
<path d="M1.89415882,6.81603382 C1.70672589,7.00346674 1.70139387,7.30566985 1.88209812,7.49959812 L5.16334812,10.7808481 C5.35550964,10.9727707 5.66681161,10.9727707 5.85897312,10.7808481 L11.4370981,5.20272312 C11.6178024,5.00879485 11.6124704,4.70659174 11.4250374,4.51915882 C11.2376045,4.33172589 10.9354014,4.32639387 10.7414731,4.50709812 L5.51116062,9.73675437 L2.57772312,6.80331687 C2.38379485,6.62326887 2.08159174,6.62860089 1.89415882,6.81603382 Z" id="路径"></path>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 466 B After Width: | Height: | Size: 466 B |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 449 B After Width: | Height: | Size: 449 B |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 5.3 KiB |
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 287 B |
Before Width: | Height: | Size: 289 KiB |
Before Width: | Height: | Size: 320 B |
Before Width: | Height: | Size: 1.2 KiB |
|
@ -1,27 +1,7 @@
|
|||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>font/fontawesome-webfont.ttf</file>
|
||||
<file>png/image/arrow_line_expand.png</file>
|
||||
<file>png/image/arrow_line_retract.png</file>
|
||||
<file>png/image/forward.png</file>
|
||||
<file>png/image/icon_mode.png</file>
|
||||
<file>png/image/list_mode.png</file>
|
||||
<file>png/image/refresh.png</file>
|
||||
<file>png/image/retreat.png</file>
|
||||
<file>icon/documentIcon.png</file>
|
||||
<file>connectinterface/defaultCode.png</file>
|
||||
<file>icon/icon_mode.png</file>
|
||||
<file>icon/list_mode.png</file>
|
||||
<file>icon/mobileFileIcon.png</file>
|
||||
<file>icon/musicIcon.png</file>
|
||||
<file>icon/pictureIcon.png</file>
|
||||
<file>icon/qqIcon.png</file>
|
||||
<file>icon/refresh.png</file>
|
||||
<file>icon/videoIcon.png</file>
|
||||
<file>icon/weChatIcon.png</file>
|
||||
<file>icon/kylin-connectivity.png</file>
|
||||
<file>png/image/play.png</file>
|
||||
<file>png/image/cover.png</file>
|
||||
<file>connectinterface/hw/darken1.png</file>
|
||||
<file>connectinterface/hw/darken2.png</file>
|
||||
<file>connectinterface/hw/darkzh1.png</file>
|
||||
|
@ -61,17 +41,12 @@
|
|||
<file>connectinterface/nextIcon.png</file>
|
||||
<file>connectinterface/backDarkIcon.png</file>
|
||||
<file>connectinterface/nextDarkIcon.png</file>
|
||||
<file>icon/add.png</file>
|
||||
<file>png/image/back.png</file>
|
||||
<file>icon/mobileDarkIcon.png</file>
|
||||
<file>icon/mobileLightIcon.png</file>
|
||||
<file>devicetype/pc.svg</file>
|
||||
<file>devicetype/phone.svg</file>
|
||||
<file>homepage/homepage.svg</file>
|
||||
<file>homepage/remote.svg</file>
|
||||
<file>homepage/folder.svg</file>
|
||||
<file>homepage/screen-share.svg</file>
|
||||
<file>png/image/icon_select.svg</file>
|
||||
<file>view/ellipse.svg</file>
|
||||
<file>view/exit.svg</file>
|
||||
<file>tabbaricon/control.svg</file>
|
||||
|
@ -87,6 +62,18 @@
|
|||
<file>tabbaricon/rectangledark.svg</file>
|
||||
<file>tabbaricon/tabbarlight.svg</file>
|
||||
<file>tabbaricon/tabbardark.svg</file>
|
||||
<file>png/image/rectangle.svg</file>
|
||||
<file>filemanagewin/weChatIcon.png</file>
|
||||
<file>filemanagewin/videoIcon.png</file>
|
||||
<file>filemanagewin/qqIcon.png</file>
|
||||
<file>filemanagewin/play.png</file>
|
||||
<file>filemanagewin/pictureIcon.png</file>
|
||||
<file>filemanagewin/musicIcon.png</file>
|
||||
<file>filemanagewin/mobileLightIcon.png</file>
|
||||
<file>filemanagewin/mobileFileIcon.png</file>
|
||||
<file>filemanagewin/mobileDarkIcon.png</file>
|
||||
<file>filemanagewin/icon_select.svg</file>
|
||||
<file>filemanagewin/documentIcon.png</file>
|
||||
<file>filemanagewin/cover.png</file>
|
||||
<file>filemanagewin/add.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
|
@ -1,3 +1,14 @@
|
|||
set(UI_BASE_WIDGET
|
||||
basewidget/loaddialog.h
|
||||
basewidget/loaddialog.cpp
|
||||
basewidget/transmissiondialog.h
|
||||
basewidget/transmissiondialog.cpp
|
||||
basewidget/backgroundwin.cpp
|
||||
basewidget/backgroundwin.h
|
||||
basewidget/levitationbutton.cpp
|
||||
basewidget/levitationbutton.h
|
||||
)
|
||||
source_group(basewidget FILES ${UI_BASE_WIDGET})
|
||||
|
||||
set(MOBILE_UI_CLASSIFICATIONLIST_SOURCES
|
||||
classificationlist/arrowlinebutton.h
|
||||
|
@ -6,8 +17,6 @@ set(MOBILE_UI_CLASSIFICATIONLIST_SOURCES
|
|||
classificationlist/mobilefilelistdelegate.cpp
|
||||
classificationlist/mobilefilelistview.h
|
||||
classificationlist/mobilefilelistview.cpp
|
||||
classificationlist/mobilefilesecondwidget.h
|
||||
classificationlist/mobilefilesecondwidget.cpp
|
||||
classificationlist/mobilefilewidget.h
|
||||
classificationlist/mobilefilewidget.cpp
|
||||
classificationlist/timelineview.h
|
||||
|
@ -16,14 +25,20 @@ set(MOBILE_UI_CLASSIFICATIONLIST_SOURCES
|
|||
classificationlist/timelinelistwidget.cpp
|
||||
classificationlist/timelineitem.h
|
||||
classificationlist/timelineitem.cpp
|
||||
classificationlist/clicklabel.h
|
||||
classificationlist/clicklabel.cpp
|
||||
)
|
||||
source_group(classificationlist FILES ${MOBILE_UI_CLASSIFICATIONLIST_SOURCES})
|
||||
|
||||
set(UI_FILEMANAGEVIEW_SOURCES
|
||||
filemanageview/filemanagewin.h
|
||||
filemanageview/filemanagewin.cpp
|
||||
filemanageview/multimediawin.h
|
||||
filemanageview/multimediawin.cpp
|
||||
filemanageview/androiditem.h
|
||||
filemanageview/androiditem.cpp
|
||||
filemanageview/clicklabel.h
|
||||
filemanageview/clicklabel.cpp
|
||||
filemanageview/androidhomepage.h
|
||||
filemanageview/androidhomepage.cpp
|
||||
)
|
||||
source_group(filemanageview FILES ${UI_FILEMANAGEVIEW_SOURCES})
|
||||
|
||||
|
@ -62,30 +77,19 @@ set(MOBILE_UI_STORAGELIST_SOURCES
|
|||
source_group(storagelist FILES ${MOBILE_UI_STORAGELIST_SOURCES})
|
||||
|
||||
set(MOBILE_UI_VIEW_SOURCES
|
||||
view/loaddialog.h
|
||||
view/loaddialog.cpp
|
||||
view/connectedwin.h
|
||||
view/connectedwin.cpp
|
||||
view/homepage.h
|
||||
view/homepage.cpp
|
||||
view/mobilefilelist.h
|
||||
view/mobilefilelist.cpp
|
||||
view/mobilefilelistitem.h
|
||||
view/mobilefilelistitem.cpp
|
||||
view/titlebar.h
|
||||
view/titlebar.cpp
|
||||
view/transmissiondialog.h
|
||||
view/transmissiondialog.cpp
|
||||
view/searchedit.cpp
|
||||
view/searchedit.h
|
||||
view/backgroundwin.cpp
|
||||
view/backgroundwin.h
|
||||
view/levitationbutton.cpp
|
||||
view/levitationbutton.h
|
||||
)
|
||||
source_group(view FILES ${MOBILE_UI_VIEW_SOURCES})
|
||||
|
||||
set(MOBILE_UI_SOURCES
|
||||
${UI_BASE_WIDGET}
|
||||
${MOBILE_UI_CLASSIFICATIONLIST_SOURCES}
|
||||
${MOBILE_UI_INITCONNECTWIN_SOURCES}
|
||||
${MOBILE_UI_STORAGELIST_SOURCES}
|
||||
|
@ -96,6 +100,7 @@ set(MOBILE_UI_SOURCES
|
|||
|
||||
add_library(mobileui ${MOBILE_UI_SOURCES})
|
||||
|
||||
target_include_directories(mobileui PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/basewidget)
|
||||
target_include_directories(mobileui PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/classificationlist)
|
||||
target_include_directories(mobileui PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/connectinterface)
|
||||
target_include_directories(mobileui PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/storagelist)
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
HEADERS += \
|
||||
$$PWD/backgroundwin.h \
|
||||
$$PWD/transmissiondialog.h\
|
||||
$$PWD/loaddialog.h \
|
||||
$$PWD/levitationbutton.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/backgroundwin.cpp \
|
||||
$$PWD/transmissiondialog.cpp \
|
||||
$$PWD/loaddialog.cpp\
|
||||
$$PWD/levitationbutton.cpp
|
|
@ -2,20 +2,16 @@ HEADERS += \
|
|||
$$PWD/arrowlinebutton.h \
|
||||
$$PWD/mobilefilelistdelegate.h \
|
||||
$$PWD/mobilefilelistview.h \
|
||||
$$PWD/mobilefilesecondwidget.h \
|
||||
$$PWD/mobilefilewidget.h \
|
||||
$$PWD/timelineitem.h \
|
||||
$$PWD/timelinelistwidget.h \
|
||||
$$PWD/timelineview.h \
|
||||
$$PWD/clicklabel.h
|
||||
$$PWD/timelineview.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/arrowlinebutton.cpp \
|
||||
$$PWD/mobilefilelistdelegate.cpp \
|
||||
$$PWD/mobilefilelistview.cpp \
|
||||
$$PWD/mobilefilesecondwidget.cpp \
|
||||
$$PWD/mobilefilewidget.cpp \
|
||||
$$PWD/timelineitem.cpp \
|
||||
$$PWD/timelinelistwidget.cpp \
|
||||
$$PWD/timelineview.cpp \
|
||||
$$PWD/clicklabel.cpp
|
||||
$$PWD/timelineview.cpp
|
||||
|
|
|
@ -1,291 +0,0 @@
|
|||
#include "mobilefilesecondwidget.h"
|
||||
|
||||
#include <QVBoxLayout>
|
||||
#include <QScrollArea>
|
||||
#include <QDebug>
|
||||
#include <kbreadcrumb.h>
|
||||
#include "generatetools.h"
|
||||
|
||||
using namespace kdk;
|
||||
|
||||
const QString ITEM_ICON_PATH = ":/icon/";
|
||||
const QStringList ITEM_ICON_LIST = {"pictureIcon.png", "videoIcon.png", "musicIcon.png", "documentIcon.png"};
|
||||
const QStringList ITEM_NAME_LIST = {"Picture", "Video", "Music", "Document"};
|
||||
const int ICON_MODE_LIST_WIDGET_WIDTH = 240;
|
||||
const int LIST_WIDGET_HEIGHT = 420;
|
||||
const int LIST_WIDGET_ITEM_WIDTH = 208;
|
||||
const int LIST_WIDGET_ITEM_HEIGHT = 80;
|
||||
const int LIST_MODE_LIST_WIDGET_WIDTH = 750;
|
||||
|
||||
MobileFileSecondWidget::MobileFileSecondWidget(int text, QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
m_text = text;
|
||||
initUI();
|
||||
setItem();
|
||||
}
|
||||
|
||||
MobileFileSecondWidget::~MobileFileSecondWidget()
|
||||
{
|
||||
if (m_fileSecondListWidget != nullptr) {
|
||||
delete m_fileSecondListWidget;
|
||||
m_fileSecondListWidget = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void MobileFileSecondWidget::setItemCount(const QMap<QString, int> &map)
|
||||
{
|
||||
if (map.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
QMap<QString, int>::const_iterator it;
|
||||
QMap<QString, MobileFileListItem *>::iterator itemIt = m_itemMap.begin();
|
||||
MobileFileListItem *item = nullptr;
|
||||
while (m_itemMap.end() != itemIt) {
|
||||
item = itemIt.value();
|
||||
it = map.find(itemIt.key());
|
||||
item->setItemCount(it.value());
|
||||
itemIt++;
|
||||
}
|
||||
}
|
||||
|
||||
void MobileFileSecondWidget::initUI()
|
||||
{
|
||||
QVBoxLayout *mainVLayout = new QVBoxLayout();
|
||||
mainVLayout->setContentsMargins(0, 24, 0, 0);
|
||||
mainVLayout->setSpacing(0);
|
||||
this->setLayout(mainVLayout);
|
||||
|
||||
QHBoxLayout *fileListHLayout = new QHBoxLayout();
|
||||
|
||||
QPushButton *retreatButton = new QPushButton(this);
|
||||
retreatButton->setIcon(QIcon::fromTheme("go-next-rtl-symbolic"));
|
||||
retreatButton->setFixedSize(16, 16);
|
||||
retreatButton->setFlat(true);
|
||||
retreatButton->setCursor(Qt::PointingHandCursor);
|
||||
|
||||
QFont font;
|
||||
font.setBold(true);
|
||||
//面包屑
|
||||
KBreadCrumb *crumb = new KBreadCrumb(this);
|
||||
crumb->setFont(font);
|
||||
crumb->setFlat(false);
|
||||
crumb->addTab(tr("Mobile file list")); // Mobile file list手机文件列表
|
||||
if (m_text == SECOND_FILE_LIST_WIN_TYPE::WECHAT) {
|
||||
crumb->addTab(tr("WeChat")); // WeChat
|
||||
} else if (m_text == SECOND_FILE_LIST_WIN_TYPE::QQ) {
|
||||
crumb->addTab(tr("QQ")); // QQ
|
||||
}
|
||||
crumb->setCurrentIndex(1);
|
||||
// crumb->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
|
||||
//模式
|
||||
m_modeButton = new QPushButton(this);
|
||||
m_modeButton->setIcon(QIcon::fromTheme("view-grid-symbolic"));
|
||||
m_modeButton->setToolTip(tr("List Mode")); // List Mode列表模式
|
||||
m_modeButton->setCursor(Qt::PointingHandCursor);
|
||||
m_modeButton->setFixedSize(20, 20);
|
||||
m_modeButton->setFlat(true);
|
||||
|
||||
//刷新
|
||||
QPushButton *refreshButton = new QPushButton(this);
|
||||
refreshButton->setIcon(QIcon::fromTheme("view-refresh-symbolic"));
|
||||
refreshButton->setToolTip(tr("Refresh")); // Refresh刷新
|
||||
refreshButton->setCursor(Qt::PointingHandCursor);
|
||||
refreshButton->setFixedSize(20, 20);
|
||||
refreshButton->setFlat(true);
|
||||
|
||||
fileListHLayout->addWidget(retreatButton);
|
||||
fileListHLayout->addWidget(crumb);
|
||||
fileListHLayout->addStretch();
|
||||
fileListHLayout->addWidget(m_modeButton);
|
||||
fileListHLayout->addSpacing(20);
|
||||
fileListHLayout->addWidget(refreshButton);
|
||||
fileListHLayout->setContentsMargins(68, 0, 68, 0);
|
||||
|
||||
m_fileSecondListWidget = new QListWidget();
|
||||
//设置显示图标模式
|
||||
m_fileSecondListWidget->setViewMode(QListView::IconMode);
|
||||
//自适应布局
|
||||
m_fileSecondListWidget->setResizeMode(QListView::Adjust);
|
||||
//列表中的图标不可拖动
|
||||
m_fileSecondListWidget->setMovement(QListView::Static);
|
||||
//去边框
|
||||
m_fileSecondListWidget->setFrameShape(QListWidget::NoFrame);
|
||||
|
||||
m_fileSecondListWidget->setSpacing(16);
|
||||
|
||||
QVBoxLayout *scrollVLayout = new QVBoxLayout();
|
||||
QVBoxLayout *layout = new QVBoxLayout();
|
||||
|
||||
QWidget *listWidget = new QWidget();
|
||||
listWidget->setLayout(layout);
|
||||
|
||||
scrollVLayout->addWidget(listWidget);
|
||||
scrollVLayout->setContentsMargins(56, 0, 0, 0);
|
||||
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
layout->addWidget(m_fileSecondListWidget);
|
||||
layout->addStretch();
|
||||
|
||||
mainVLayout->addLayout(fileListHLayout);
|
||||
mainVLayout->addSpacing(8);
|
||||
mainVLayout->addLayout(scrollVLayout);
|
||||
mainVLayout->addStretch();
|
||||
|
||||
this->setAutoFillBackground(true);
|
||||
this->setBackgroundRole(QPalette::Base);
|
||||
|
||||
connect(retreatButton, &QPushButton::clicked, this, [=]() {
|
||||
int currentIndex = crumb->currentIndex();
|
||||
if (currentIndex > 0) {
|
||||
crumb->setCurrentIndex(currentIndex - 1);
|
||||
}
|
||||
});
|
||||
|
||||
connect(refreshButton, &QPushButton::clicked, this, [=]() {
|
||||
if (m_text == SECOND_FILE_LIST_TYPE::QQPICTURE) {
|
||||
Q_EMIT sigUpdateClicked(SECOND_FILE_LIST_TYPE::QQPICTURE);
|
||||
} else if (m_text == SECOND_FILE_LIST_TYPE::QQVIDEO) {
|
||||
Q_EMIT sigUpdateClicked(SECOND_FILE_LIST_TYPE::QQVIDEO);
|
||||
} else if (m_text == SECOND_FILE_LIST_TYPE::QQMUSIC) {
|
||||
Q_EMIT sigUpdateClicked(SECOND_FILE_LIST_TYPE::QQMUSIC);
|
||||
} else if (m_text == SECOND_FILE_LIST_TYPE::QQDOCUMENT) {
|
||||
Q_EMIT sigUpdateClicked(SECOND_FILE_LIST_TYPE::QQDOCUMENT);
|
||||
} else if (m_text == SECOND_FILE_LIST_TYPE::WECHATPICTURE) {
|
||||
Q_EMIT sigUpdateClicked(SECOND_FILE_LIST_TYPE::WECHATPICTURE);
|
||||
} else if (m_text == SECOND_FILE_LIST_TYPE::WECHATVIDEO) {
|
||||
Q_EMIT sigUpdateClicked(SECOND_FILE_LIST_TYPE::WECHATVIDEO);
|
||||
} else if (m_text == SECOND_FILE_LIST_TYPE::WECHATMUSIC) {
|
||||
Q_EMIT sigUpdateClicked(SECOND_FILE_LIST_TYPE::WECHATMUSIC);
|
||||
} else if (m_text == SECOND_FILE_LIST_TYPE::WECHATDOCUMENT) {
|
||||
Q_EMIT sigUpdateClicked(SECOND_FILE_LIST_TYPE::WECHATDOCUMENT);
|
||||
}
|
||||
});
|
||||
connect(m_modeButton, &QPushButton::clicked, this, &MobileFileSecondWidget::slotModeButtonClicked);
|
||||
connect(crumb, &KBreadCrumb::currentChanged, this, [=](int index) {
|
||||
QString text = crumb->tabText(index);
|
||||
if (index == 0 && text == tr("Mobile file list")) { // Mobile file list手机文件列表
|
||||
Q_EMIT sigHideCopyToComputerWidget();
|
||||
Q_EMIT sigShowMobileFileListWidget();
|
||||
Q_EMIT sigUpdateClicked(SECOND_FILE_LIST_WIN_TYPE::HOMEPAGE);
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = crumb->count() - 1; i > index; i--) {
|
||||
crumb->removeTab(i);
|
||||
}
|
||||
|
||||
Q_EMIT sigHideCopyToComputerWidget();
|
||||
});
|
||||
}
|
||||
|
||||
void MobileFileSecondWidget::slotModeButtonClicked()
|
||||
{
|
||||
// 切换视图埋点
|
||||
GenerateTools::buriedPoint(kabase::BuriedPoint::PT::KylinMobileAssistantSwitchView);
|
||||
switch (m_mode) {
|
||||
case 0:
|
||||
qInfo() << "列表模式";
|
||||
++m_mode;
|
||||
m_modeButton->setIcon(QIcon::fromTheme("view-list-symbolic"));
|
||||
m_modeButton->setToolTip(tr("Icon Mode")); // Icon Mode图标模式
|
||||
m_fileSecondListWidget->setViewMode(QListView::ListMode);
|
||||
m_fileSecondListWidget->setFixedSize(ICON_MODE_LIST_WIDGET_WIDTH, LIST_WIDGET_HEIGHT);
|
||||
break;
|
||||
case 1:
|
||||
m_mode = 0;
|
||||
m_modeButton->setIcon(QIcon::fromTheme("view-grid-symbolic"));
|
||||
m_modeButton->setToolTip(tr("List Mode")); // List Mode列表模式
|
||||
m_fileSecondListWidget->setViewMode(QListView::IconMode);
|
||||
m_fileSecondListWidget->setFixedSize(LIST_MODE_LIST_WIDGET_WIDTH, LIST_WIDGET_HEIGHT);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void MobileFileSecondWidget::setItem()
|
||||
{
|
||||
for (int i = 0; i < 4; i++) {
|
||||
QListWidgetItem *item = new QListWidgetItem(m_fileSecondListWidget);
|
||||
MobileFileListItem *mobileFileListItem = new MobileFileListItem();
|
||||
m_fileSecondListWidget->setItemWidget(item, mobileFileListItem);
|
||||
item->setSizeHint(QSize(LIST_WIDGET_ITEM_WIDTH, LIST_WIDGET_ITEM_HEIGHT));
|
||||
mobileFileListItem->setItemCount(0);
|
||||
mobileFileListItem->setItemIcon(ITEM_ICON_PATH + ITEM_ICON_LIST.value(i));
|
||||
if (m_text == SECOND_FILE_LIST_WIN_TYPE::WECHAT) { // WeChat微信
|
||||
m_itemMap.insert("wechat" + ITEM_NAME_LIST.value(i), mobileFileListItem);
|
||||
} else {
|
||||
m_itemMap.insert("qq" + ITEM_NAME_LIST.value(i), mobileFileListItem);
|
||||
}
|
||||
switch (i) {
|
||||
case 0:
|
||||
mobileFileListItem->setItemName(tr("Picture")); // Picture图片
|
||||
connect(mobileFileListItem, &MobileFileListItem::clicked, this,
|
||||
&MobileFileSecondWidget::slotPictureButtonClicked);
|
||||
break;
|
||||
case 1:
|
||||
mobileFileListItem->setItemName(tr("Video")); // Video视频
|
||||
connect(mobileFileListItem, &MobileFileListItem::clicked, this,
|
||||
&MobileFileSecondWidget::slotVideoButtonClicked);
|
||||
break;
|
||||
case 2:
|
||||
mobileFileListItem->setItemName(tr("Music")); // Music音乐
|
||||
connect(mobileFileListItem, &MobileFileListItem::clicked, this,
|
||||
&MobileFileSecondWidget::slotMusicButtonClicked);
|
||||
break;
|
||||
case 3:
|
||||
mobileFileListItem->setItemName(tr("Document")); // Document文档
|
||||
connect(mobileFileListItem, &MobileFileListItem::clicked, this,
|
||||
&MobileFileSecondWidget::slotDocumentButtonClicked);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MobileFileSecondWidget::slotPictureButtonClicked()
|
||||
{
|
||||
if (m_text == SECOND_FILE_LIST_WIN_TYPE::WECHAT) {
|
||||
Q_EMIT sigItemButtonClicked(SECOND_FILE_LIST_TYPE::WECHATPICTURE);
|
||||
} else {
|
||||
Q_EMIT sigItemButtonClicked(SECOND_FILE_LIST_TYPE::QQPICTURE);
|
||||
}
|
||||
}
|
||||
|
||||
void MobileFileSecondWidget::slotVideoButtonClicked()
|
||||
{
|
||||
if (m_text == SECOND_FILE_LIST_WIN_TYPE::WECHAT) {
|
||||
Q_EMIT sigItemButtonClicked(SECOND_FILE_LIST_TYPE::WECHATVIDEO);
|
||||
} else {
|
||||
Q_EMIT sigItemButtonClicked(SECOND_FILE_LIST_TYPE::QQVIDEO);
|
||||
}
|
||||
}
|
||||
|
||||
void MobileFileSecondWidget::slotMusicButtonClicked()
|
||||
{
|
||||
if (m_text == SECOND_FILE_LIST_WIN_TYPE::WECHAT) {
|
||||
Q_EMIT sigItemButtonClicked(SECOND_FILE_LIST_TYPE::WECHATMUSIC);
|
||||
} else {
|
||||
Q_EMIT sigItemButtonClicked(SECOND_FILE_LIST_TYPE::QQMUSIC);
|
||||
}
|
||||
}
|
||||
|
||||
void MobileFileSecondWidget::slotDocumentButtonClicked()
|
||||
{
|
||||
if (m_text == SECOND_FILE_LIST_WIN_TYPE::WECHAT) {
|
||||
Q_EMIT sigItemButtonClicked(SECOND_FILE_LIST_TYPE::WECHATDOCUMENT);
|
||||
} else {
|
||||
Q_EMIT sigItemButtonClicked(SECOND_FILE_LIST_TYPE::QQDOCUMENT);
|
||||
}
|
||||
}
|
||||
|
||||
void MobileFileSecondWidget::setTheme(PublicAttributes::Theme theme)
|
||||
{
|
||||
for (int i = 0; i < 4; i++) {
|
||||
MobileFileListItem *fileListItem = dynamic_cast<MobileFileListItem *>
|
||||
(m_fileSecondListWidget->itemWidget(m_fileSecondListWidget->item(i)));
|
||||
fileListItem->setTheme(theme);
|
||||
}
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
#ifndef MOBILEFILESECONDWIDGET_H
|
||||
#define MOBILEFILESECONDWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QPushButton>
|
||||
#include <QListWidget>
|
||||
#include "mobilefilelistitem.h"
|
||||
|
||||
class MobileFileSecondWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MobileFileSecondWidget(int text, QWidget *parent = nullptr);
|
||||
~MobileFileSecondWidget();
|
||||
|
||||
enum SECOND_FILE_LIST_TYPE {QQPICTURE, QQVIDEO, QQMUSIC, QQDOCUMENT,
|
||||
WECHATPICTURE, WECHATVIDEO, WECHATMUSIC, WECHATDOCUMENT};
|
||||
|
||||
enum SECOND_FILE_LIST_WIN_TYPE {WECHAT = 12, QQ, HOMEPAGE};
|
||||
//设置项的个数
|
||||
void setItemCount(const QMap<QString, int> &map);
|
||||
void setTheme(PublicAttributes::Theme theme);
|
||||
|
||||
private Q_SLOTS:
|
||||
//模式切换
|
||||
void slotModeButtonClicked();
|
||||
//图片项
|
||||
void slotPictureButtonClicked();
|
||||
//视频项
|
||||
void slotVideoButtonClicked();
|
||||
//音乐项
|
||||
void slotMusicButtonClicked();
|
||||
//文档项
|
||||
void slotDocumentButtonClicked();
|
||||
|
||||
Q_SIGNALS:
|
||||
void sigShowMobileFileListWidget();
|
||||
void sigHideCopyToComputerWidget();
|
||||
void sigItemButtonClicked(int text);
|
||||
void sigUpdateClicked(int);
|
||||
|
||||
private:
|
||||
void initUI();
|
||||
void setItem();
|
||||
QPushButton *m_modeButton = nullptr;
|
||||
int m_mode = 0;
|
||||
int m_text;
|
||||
QListWidget *m_fileSecondListWidget = nullptr;
|
||||
QMap<QString, MobileFileListItem *> m_itemMap;
|
||||
};
|
||||
|
||||
#endif // MOBILEFILESECONDWIDGET_H
|
|
@ -1,3 +1,4 @@
|
|||
include($$PWD/basewidget/basewidget.pri)
|
||||
include($$PWD/view/view.pri)
|
||||
include($$PWD/connectinterface/connectinterface.pri)
|
||||
include($$PWD/classificationlist/classificationlist.pri)
|
||||
|
@ -19,6 +20,7 @@ HEADERS += $$PWD/mainwindow.h
|
|||
SOURCES += $$PWD/mainwindow.cpp
|
||||
|
||||
INCLUDEPATH += \
|
||||
$$PWD/basewidget \
|
||||
$$PWD/view \
|
||||
$$PWD/connectinterface \
|
||||
$$PWD/classificationlist \
|
||||
|
|
|
@ -1,245 +0,0 @@
|
|||
#include "mobilefilelist.h"
|
||||
#include "mobilefilewidget.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
const QString ITEM_ICON_PATH = ":/icon/";
|
||||
const QStringList ITEM_ICON_LIST = {"pictureIcon.png", "videoIcon.png", "musicIcon.png",
|
||||
"documentIcon.png", "weChatIcon.png", "qqIcon.png"};
|
||||
const QStringList ITEM_NAME_LIST = {"picture", "video", "music", "document", "wechat", "qq"};
|
||||
const int FILE_LIST_WIDGET_HEIGHT = 266;
|
||||
const int STROAGE_WIDGET_HEIGHT = 175;
|
||||
const int FILE_LIST_WIDGET_ITEM_WIDTH = 208;
|
||||
const int FILE_LIST_WIDGET_ITEM_HEIGHT = 80;
|
||||
const int STROAGE_WIDGET_ITEM_WIDTH = 208;
|
||||
const int STROAGE_WIDGET_ITEM_HEIGHT = 80;
|
||||
|
||||
MobileFileList::MobileFileList(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
initWidget();
|
||||
setItem();
|
||||
show();
|
||||
}
|
||||
|
||||
MobileFileList::~MobileFileList() {}
|
||||
|
||||
void MobileFileList::setItemCount(const QMap<QString, int> &map)
|
||||
{
|
||||
if (map.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
QMap<QString, int>::const_iterator it;
|
||||
QMap<QString, MobileFileListItem *>::iterator itemIt = m_itemMap.begin();
|
||||
MobileFileListItem *item = nullptr;
|
||||
while (m_itemMap.end() != itemIt) {
|
||||
item = itemIt.value();
|
||||
it = map.find(itemIt.key());
|
||||
item->setItemCount(it.value());
|
||||
itemIt++;
|
||||
}
|
||||
}
|
||||
|
||||
void MobileFileList::initWidget()
|
||||
{
|
||||
QVBoxLayout *mainVLayout = new QVBoxLayout();
|
||||
|
||||
QHBoxLayout *mobileFileListHLayout = new QHBoxLayout();
|
||||
QHBoxLayout *fileListWidgetHLayout = new QHBoxLayout();
|
||||
QHBoxLayout *mobileStorageHLayout = new QHBoxLayout();
|
||||
QHBoxLayout *storageWidgetHLayout = new QHBoxLayout();
|
||||
//手机文件列表
|
||||
QLabel *mobileFileListLabel = new QLabel();
|
||||
QFont font;
|
||||
font.setBold(true);
|
||||
mobileFileListLabel->setFont(font);
|
||||
mobileFileListLabel->setText(tr("Mobile file list")); // Mobile file list手机文件列表
|
||||
|
||||
m_searchButton = new QPushButton(this);
|
||||
m_searchButton->setIcon(QIcon::fromTheme("system-search-symbolic"));
|
||||
m_searchButton->setFixedSize(16, 16);
|
||||
m_searchButton->setFlat(true);
|
||||
m_searchButton->setCursor(Qt::PointingHandCursor);
|
||||
|
||||
mobileFileListHLayout->setContentsMargins(34, 0, 80, 0);
|
||||
mobileFileListHLayout->addWidget(mobileFileListLabel);
|
||||
mobileFileListHLayout->addStretch();
|
||||
mobileFileListHLayout->addWidget(m_searchButton);
|
||||
|
||||
QWidget *mobileFileListWid = new QWidget(this);
|
||||
mobileFileListWid->setLayout(mobileFileListHLayout);
|
||||
mobileFileListWid->setFixedHeight(40);
|
||||
|
||||
//手机存储
|
||||
QLabel *mobileStorageLabel = new QLabel();
|
||||
mobileStorageLabel->setFont(font);
|
||||
mobileStorageLabel->setText(tr("Mobile storage")); // Mobile storage移动存储
|
||||
|
||||
mobileStorageHLayout->setMargin(0);
|
||||
mobileStorageHLayout->addWidget(mobileStorageLabel);
|
||||
mobileStorageHLayout->setContentsMargins(34, 0, 0, 0);
|
||||
mobileStorageHLayout->addStretch();
|
||||
|
||||
//手机文件列表widget
|
||||
m_fileListWidget = new QListWidget(this);
|
||||
m_fileListWidget->setFixedHeight(FILE_LIST_WIDGET_HEIGHT);
|
||||
|
||||
//设置显示图标模式
|
||||
m_fileListWidget->setViewMode(QListView::IconMode);
|
||||
//自适应布局
|
||||
m_fileListWidget->setResizeMode(QListView::Adjust);
|
||||
//列表中的图标不可拖动
|
||||
m_fileListWidget->setMovement(QListView::Static);
|
||||
//去边框
|
||||
m_fileListWidget->setFrameShape(QListWidget::NoFrame);
|
||||
//设置边距
|
||||
m_fileListWidget->setSpacing(16);
|
||||
//不可选择项目
|
||||
// m_fileListWidget->setSelectionMode(QListView::NoSelection);
|
||||
|
||||
QWidget *fileWidget = new QWidget();
|
||||
fileWidget->setLayout(fileListWidgetHLayout);
|
||||
fileWidget->setFixedHeight(FILE_LIST_WIDGET_HEIGHT);
|
||||
fileWidget->adjustSize();
|
||||
|
||||
fileListWidgetHLayout->setContentsMargins(0, 0, 0, 0);
|
||||
fileListWidgetHLayout->addWidget(m_fileListWidget);
|
||||
|
||||
//手机存储widget
|
||||
m_storageWidget = new QListWidget(this);
|
||||
|
||||
QWidget *storageWidget = new QWidget();
|
||||
storageWidget->setLayout(storageWidgetHLayout);
|
||||
storageWidget->setFixedHeight(STROAGE_WIDGET_HEIGHT);
|
||||
|
||||
storageWidgetHLayout->setContentsMargins(0, 0, 0, 0);
|
||||
storageWidgetHLayout->addWidget(m_storageWidget);
|
||||
storageWidgetHLayout->addStretch();
|
||||
|
||||
//设置显示图标模式
|
||||
m_storageWidget->setViewMode(QListView::IconMode);
|
||||
//自适应布局
|
||||
m_storageWidget->setResizeMode(QListView::Adjust);
|
||||
//列表中的图标不可拖动
|
||||
m_storageWidget->setMovement(QListView::Static);
|
||||
//去边框
|
||||
m_storageWidget->setFrameShape(QListWidget::NoFrame);
|
||||
//设置边距
|
||||
m_storageWidget->setSpacing(16);
|
||||
|
||||
mainVLayout->setContentsMargins(56, 24, 0, 0);
|
||||
mainVLayout->setSpacing(0);
|
||||
mainVLayout->addWidget(mobileFileListWid);
|
||||
mainVLayout->addSpacing(1);
|
||||
mainVLayout->addWidget(fileWidget);
|
||||
mainVLayout->addSpacing(25);
|
||||
mainVLayout->addLayout(mobileStorageHLayout);
|
||||
mainVLayout->addSpacing(1);
|
||||
mainVLayout->addWidget(storageWidget);
|
||||
mainVLayout->addStretch();
|
||||
this->setLayout(mainVLayout);
|
||||
|
||||
this->setAutoFillBackground(true);
|
||||
this->setBackgroundRole(QPalette::Base);
|
||||
|
||||
connect(m_searchButton, &QPushButton::clicked, this, [=]() {
|
||||
Q_EMIT sigMobileFileListSearchClicked();
|
||||
});
|
||||
}
|
||||
|
||||
void MobileFileList::setItem()
|
||||
{
|
||||
for (int i = 0; i < 6; i++) {
|
||||
QListWidgetItem *item = new QListWidgetItem(m_fileListWidget);
|
||||
MobileFileListItem *mobileFileListItem = new MobileFileListItem();
|
||||
m_fileListWidget->setItemWidget(item, mobileFileListItem);
|
||||
item->setSizeHint(QSize(FILE_LIST_WIDGET_ITEM_WIDTH, FILE_LIST_WIDGET_ITEM_HEIGHT));
|
||||
mobileFileListItem->setFocusPolicy(Qt::NoFocus);
|
||||
mobileFileListItem->setItemCount(0);
|
||||
mobileFileListItem->setFixedSize(208, 80);
|
||||
mobileFileListItem->setItemIcon(ITEM_ICON_PATH + ITEM_ICON_LIST.value(i));
|
||||
m_itemMap.insert(ITEM_NAME_LIST.value(i), mobileFileListItem);
|
||||
switch (i) {
|
||||
case 0:
|
||||
mobileFileListItem->setItemName(tr("Picture")); // Picture图片
|
||||
connect(mobileFileListItem, &MobileFileListItem::clicked, this, &MobileFileList::slotPictureButtonClicked);
|
||||
break;
|
||||
case 1:
|
||||
mobileFileListItem->setItemName(tr("Video")); // Video视频
|
||||
connect(mobileFileListItem, &MobileFileListItem::clicked, this, &MobileFileList::slotVideoButtonClicked);
|
||||
break;
|
||||
case 2:
|
||||
mobileFileListItem->setItemName(tr("Music")); // Music音乐
|
||||
connect(mobileFileListItem, &MobileFileListItem::clicked, this, &MobileFileList::slotMusicButtonClicked);
|
||||
break;
|
||||
case 3:
|
||||
mobileFileListItem->setItemName(tr("Document")); // Document文档
|
||||
connect(mobileFileListItem, &MobileFileListItem::clicked, this, &MobileFileList::slotDocumentButtonClicked);
|
||||
break;
|
||||
case 4:
|
||||
mobileFileListItem->setItemName(tr("WeChat")); // WeChat微信
|
||||
connect(mobileFileListItem, &MobileFileListItem::clicked, this, &MobileFileList::slotWeChatButtonClicked);
|
||||
break;
|
||||
case 5:
|
||||
mobileFileListItem->setItemName(tr("QQ")); // QQ QQ
|
||||
connect(mobileFileListItem, &MobileFileListItem::clicked, this, &MobileFileList::slotQQButtonClicked);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
QListWidgetItem *item = new QListWidgetItem(m_storageWidget);
|
||||
MobileFileListItem *mobileFileListItem = new MobileFileListItem();
|
||||
m_storageWidget->setItemWidget(item, mobileFileListItem);
|
||||
item->setSizeHint(QSize(STROAGE_WIDGET_ITEM_WIDTH, STROAGE_WIDGET_ITEM_HEIGHT));
|
||||
mobileFileListItem->setItemName(tr("Mobile")); // Mobile手机
|
||||
mobileFileListItem->setAllFile(tr("All File")); // All File所有文件
|
||||
mobileFileListItem->setFixedSize(208, 80);
|
||||
mobileFileListItem->setItemIcon(":/icon/mobileFileIcon.png");
|
||||
connect(mobileFileListItem, &MobileFileListItem::clicked, this, &MobileFileList::slotMobileButtonClicked);
|
||||
}
|
||||
|
||||
void MobileFileList::slotPictureButtonClicked()
|
||||
{
|
||||
Q_EMIT sigPictureClicked(FILE_LIST_TYPE::PICTURE);
|
||||
}
|
||||
|
||||
void MobileFileList::slotVideoButtonClicked()
|
||||
{
|
||||
Q_EMIT sigVideoClicked(FILE_LIST_TYPE::VIDEO);
|
||||
}
|
||||
|
||||
void MobileFileList::slotMusicButtonClicked()
|
||||
{
|
||||
Q_EMIT sigMusicClicked(FILE_LIST_TYPE::MUSIC);
|
||||
}
|
||||
|
||||
void MobileFileList::slotDocumentButtonClicked()
|
||||
{
|
||||
Q_EMIT sigDocumentClicked(FILE_LIST_TYPE::DOCUMENT);
|
||||
}
|
||||
|
||||
void MobileFileList::slotWeChatButtonClicked()
|
||||
{
|
||||
Q_EMIT sigWeChatClicked(FILE_LIST_TYPE::WECHAT);
|
||||
}
|
||||
|
||||
void MobileFileList::slotQQButtonClicked()
|
||||
{
|
||||
Q_EMIT sigQQClicked(FILE_LIST_TYPE::QQ);
|
||||
}
|
||||
|
||||
void MobileFileList::slotMobileButtonClicked()
|
||||
{
|
||||
Q_EMIT sigMobileStorageClicked("/");
|
||||
}
|
||||
|
||||
void MobileFileList::setTheme(PublicAttributes::Theme theme)
|
||||
{
|
||||
for (int i = 0; i < 6; i++) {
|
||||
MobileFileListItem *fileListItem = dynamic_cast<MobileFileListItem *>(m_fileListWidget->itemWidget(m_fileListWidget->item(i)));
|
||||
fileListItem->setTheme(theme);
|
||||
}
|
||||
MobileFileListItem *storageListItem = dynamic_cast<MobileFileListItem *>(m_storageWidget->itemWidget(m_storageWidget->item(0)));
|
||||
storageListItem->setTheme(theme);
|
||||
}
|
||||
|
|
@ -1,67 +0,0 @@
|
|||
#ifndef MOBILEFILELIST_H
|
||||
#define MOBILEFILELIST_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QListWidget>
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QAbstractItemModel>
|
||||
#include "mobilefilelistitem.h"
|
||||
#include "publicattributes.hpp"
|
||||
#include "searchedit.h"
|
||||
|
||||
class MobileFileList : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit MobileFileList(QWidget *parent = nullptr);
|
||||
|
||||
~MobileFileList();
|
||||
|
||||
enum FILE_LIST_TYPE {PICTURE = 8, VIDEO, MUSIC, DOCUMENT, WECHAT, QQ};
|
||||
|
||||
void setItemCount(const QMap<QString, int> &map);
|
||||
|
||||
void setTheme(PublicAttributes::Theme theme);
|
||||
|
||||
private Q_SLOTS:
|
||||
//图片项点击
|
||||
void slotPictureButtonClicked();
|
||||
//视频项点击
|
||||
void slotVideoButtonClicked();
|
||||
//音乐项点击
|
||||
void slotMusicButtonClicked();
|
||||
//文档项点击
|
||||
void slotDocumentButtonClicked();
|
||||
//微信项点击
|
||||
void slotWeChatButtonClicked();
|
||||
// QQ项点击
|
||||
void slotQQButtonClicked();
|
||||
//手机存储项点击
|
||||
void slotMobileButtonClicked();
|
||||
|
||||
Q_SIGNALS:
|
||||
void sigPictureClicked(int picture);
|
||||
void sigVideoClicked(int video);
|
||||
void sigMusicClicked(int music);
|
||||
void sigDocumentClicked(int document);
|
||||
void sigWeChatClicked(int weChat);
|
||||
void sigQQClicked(int QQ);
|
||||
void sigMobileStorageClicked(QString mobileStorage);
|
||||
void sigMobileFileListSearchClicked();
|
||||
|
||||
private:
|
||||
void initWidget();
|
||||
|
||||
void setItem();
|
||||
|
||||
private:
|
||||
QListWidget *m_fileListWidget = nullptr;
|
||||
QListWidget *m_storageWidget = nullptr;
|
||||
QPushButton *m_searchButton = nullptr;
|
||||
QMap<QString, MobileFileListItem *> m_itemMap;
|
||||
};
|
||||
|
||||
#endif // MOBILEFILELIST_H
|
|
@ -1,119 +0,0 @@
|
|||
#include "mobilefilelistitem.h"
|
||||
|
||||
#include <QFont>
|
||||
#include <QVariant>
|
||||
#include <QEvent>
|
||||
|
||||
const int ITEM_ICON_WIDTH = 42;
|
||||
const int ITEM_ICON_HEIGHT = 42;
|
||||
|
||||
MobileFileListItem::MobileFileListItem(QPushButton *parent) : QPushButton(parent)
|
||||
{
|
||||
initWidget();
|
||||
}
|
||||
|
||||
MobileFileListItem::~MobileFileListItem() {}
|
||||
|
||||
void MobileFileListItem::initWidget()
|
||||
{
|
||||
this->installEventFilter(this);
|
||||
QHBoxLayout *mainHLayout = new QHBoxLayout();
|
||||
|
||||
QVBoxLayout *labelVLayout = new QVBoxLayout();
|
||||
//项按钮
|
||||
m_itemIconLabel = new QLabel(this);
|
||||
m_itemIconLabel->setFixedSize(ITEM_ICON_WIDTH, ITEM_ICON_HEIGHT);
|
||||
m_itemIconLabel->setStyleSheet("background-color:transparent;");
|
||||
//项名称
|
||||
m_itemNameLabel = new QLabel(this);
|
||||
QFont font;
|
||||
font.setBold(true);
|
||||
m_itemNameLabel->setFont(font);
|
||||
m_itemNameLabel->setStyleSheet("background-color:transparent;");
|
||||
//每一项总数
|
||||
m_itemCountLabel = new QLabel(this);
|
||||
m_itemCountLabel->setStyleSheet("background-color:transparent;color:#8F9399;font-size:12px");
|
||||
|
||||
labelVLayout->setContentsMargins(0, 0, 0, 0);
|
||||
labelVLayout->addStretch();
|
||||
labelVLayout->addWidget(m_itemNameLabel);
|
||||
labelVLayout->addSpacing(4);
|
||||
labelVLayout->addWidget(m_itemCountLabel);
|
||||
labelVLayout->addStretch();
|
||||
|
||||
// QLabel *vectorLab = new QLabel(this);
|
||||
// vectorLab->setFixedSize(8, 8);
|
||||
// vectorLab->setPixmap(QPixmap(":/svg/Vector1.svg").scaled(8, 8));
|
||||
|
||||
mainHLayout->setContentsMargins(19, 0, 13, 0);
|
||||
mainHLayout->setSpacing(0);
|
||||
mainHLayout->addWidget(m_itemIconLabel);
|
||||
mainHLayout->addSpacing(11);
|
||||
mainHLayout->addLayout(labelVLayout);
|
||||
mainHLayout->addStretch();
|
||||
// mainHLayout->addWidget(vectorLab);
|
||||
setLayout(mainHLayout);
|
||||
|
||||
this->setProperty("useButtonPalette", true);
|
||||
}
|
||||
|
||||
//设置项按钮
|
||||
void MobileFileListItem::setItemIcon(QString path)
|
||||
{
|
||||
m_itemIconLabel->setPixmap(QIcon(path).pixmap(42, 42));
|
||||
}
|
||||
|
||||
//设置项名称
|
||||
void MobileFileListItem::setItemName(QString name)
|
||||
{
|
||||
m_itemNameLabel->setText(name);
|
||||
}
|
||||
|
||||
//设置项总数
|
||||
void MobileFileListItem::setItemCount(int count)
|
||||
{
|
||||
QString countItem = QString("%1 ").arg(count) + QString(tr("items")); // items项
|
||||
m_itemCountLabel->setText(countItem);
|
||||
}
|
||||
|
||||
//设置所有文件label样式
|
||||
void MobileFileListItem::setAllFile(QString file)
|
||||
{
|
||||
QString allFile = QString("%1").arg(file);
|
||||
m_itemCountLabel->setText(allFile);
|
||||
}
|
||||
|
||||
bool MobileFileListItem::eventFilter(QObject *watch, QEvent *event)
|
||||
{
|
||||
if (watch == this) {
|
||||
if (m_theme == PublicAttributes::Theme::Light) {
|
||||
if (event->type() == QEvent::Enter) {
|
||||
this->setStyleSheet("background-color:#E6F1FE;");
|
||||
} else if (event->type() == QEvent::Leave) {
|
||||
this->setStyleSheet("background-color:#F6F6F6;");
|
||||
}
|
||||
} else if (m_theme == PublicAttributes::Theme::Dark) {
|
||||
if (event->type() == QEvent::Enter) {
|
||||
this->setStyleSheet("background-color:#373737;");
|
||||
} else if (event->type() == QEvent::Leave) {
|
||||
this->setStyleSheet("background-color:#626267;");
|
||||
}
|
||||
}
|
||||
}
|
||||
return QObject::eventFilter(watch, event);
|
||||
}
|
||||
|
||||
void MobileFileListItem::setTheme(PublicAttributes::Theme theme)
|
||||
{
|
||||
m_theme = theme;
|
||||
switch (theme) {
|
||||
case PublicAttributes::Theme::Light: {
|
||||
this->setStyleSheet("background-color:#F6F6F6;");
|
||||
break; }
|
||||
case PublicAttributes::Theme::Dark: {
|
||||
this->setStyleSheet("background-color:#626267;");
|
||||
break; }
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
#ifndef MOBILEFILELISTITEM_H
|
||||
#define MOBILEFILELISTITEM_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
|
||||
#include "publicattributes.hpp"
|
||||
|
||||
class MobileFileListItem : public QPushButton
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit MobileFileListItem(QPushButton *parent = nullptr);
|
||||
|
||||
~MobileFileListItem();
|
||||
|
||||
//设置项按钮
|
||||
void setItemIcon(QString path);
|
||||
|
||||
//设置项名称
|
||||
void setItemName(QString name);
|
||||
|
||||
//设置每一项总数
|
||||
void setItemCount(int count);
|
||||
|
||||
//设置所有文件label样式
|
||||
void setAllFile(QString file);
|
||||
|
||||
void setTheme(PublicAttributes::Theme theme);
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *watch, QEvent *event);
|
||||
|
||||
private:
|
||||
void initWidget();
|
||||
|
||||
private:
|
||||
//项按钮
|
||||
QLabel *m_itemIconLabel = nullptr;
|
||||
//项名称
|
||||
QLabel *m_itemNameLabel = nullptr;
|
||||
//每一项总数
|
||||
QLabel *m_itemCountLabel = nullptr;
|
||||
|
||||
PublicAttributes::Theme m_theme = PublicAttributes::Theme::Light;
|
||||
};
|
||||
|
||||
#endif // MOBILEFILELISTITEM_H
|
|
@ -1,21 +1,9 @@
|
|||
HEADERS += \
|
||||
$$PWD/backgroundwin.h \
|
||||
$$PWD/homepage.h \
|
||||
$$PWD/connectedwin.h \
|
||||
$$PWD/mobilefilelistitem.h \
|
||||
$$PWD/mobilefilelist.h \
|
||||
$$PWD/titlebar.h \
|
||||
$$PWD/transmissiondialog.h\
|
||||
$$PWD/loaddialog.h \
|
||||
$$PWD/levitationbutton.h
|
||||
$$PWD/titlebar.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/backgroundwin.cpp \
|
||||
$$PWD/homepage.cpp \
|
||||
$$PWD/connectedwin.cpp \
|
||||
$$PWD/mobilefilelistitem.cpp \
|
||||
$$PWD/mobilefilelist.cpp \
|
||||
$$PWD/titlebar.cpp \
|
||||
$$PWD/transmissiondialog.cpp \
|
||||
$$PWD/loaddialog.cpp\
|
||||
$$PWD/levitationbutton.cpp
|
||||
$$PWD/titlebar.cpp
|
||||
|
|