Skip to content

Commit

Permalink
perf: 简化ThumbnailImage控件相关代码
Browse files Browse the repository at this point in the history
 简化ThumbnailImage控件相关代码

Log: 简化ThumbnailImage控件相关代码
  • Loading branch information
starhcq committed Sep 1, 2023
1 parent bc89685 commit 7c7d01c
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 59 deletions.
1 change: 1 addition & 0 deletions src/deepin-album.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,6 @@
<file>qml/Control/ListView/ThumbnailListView2.qml</file>
<file>qml/Control/ListView/ThumbnailListDelegate2.qml</file>
<file>qml/Control/ListView/ThumbnailListViewTools.js</file>
<file>qml/Control/BaseView.qml</file>
</qresource>
</RCC>
14 changes: 14 additions & 0 deletions src/qml/Control/BaseView.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

import QtQuick 2.11
import QtQuick.Controls 2.4

Item {
anchors.fill: parent
anchors.topMargin: 0
anchors.leftMargin: 20
anchors.bottomMargin: statusBar.height
}

Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ import QtQuick 2.11
import QtQuick.Controls 2.4
import "../"
import "../../"
import "../../Control"

BaseView {
id: collecttView

Rectangle {
id: root
property int currentViewIndex: 3

// 通知日视图刷新状态栏提示信息
Expand Down
6 changes: 2 additions & 4 deletions src/qml/ThumbnailImageView/CustomAlbum/CustomAlbum.qml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ import "../../Control/ListView"
import "../../"
import "../"

Rectangle {
width: parent.width
height: parent.height
BaseView {

property int customAlbumUId: global.currentCustomAlbumUId
property string customAlbumName: "" //相册名称显示内容
Expand Down Expand Up @@ -171,7 +169,7 @@ Rectangle {
topMargin: 10
}
width: parent.width
height: parent.height - customAlbumTitleRect.height - m_topMargin - statusBar.height
height: parent.height - customAlbumTitleRect.height - m_topMargin
thumnailListType: (global.currentViewIndex === GlobalVar.ThumbnailViewType.CustomAlbum && global.currentCustomAlbumUId > 3) ? GlobalVar.ThumbnailType.CustomAlbum
: GlobalVar.ThumbnailType.Normal
proxyModel.sourceModel: Album.ImageDataModel { id: dataModel; modelType: Album.Types.CustomAlbum}
Expand Down
7 changes: 3 additions & 4 deletions src/qml/ThumbnailImageView/DeviceAlbum/DeviceAlbum.qml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ import "../../Control"
import "../../Control/ListView"
import "../../"

Rectangle {
width: parent.width
height: parent.height
BaseView {
anchors.fill: parentt

property int customAlbumUId: 0
property string devicePath: global.deviceCurrentPath
Expand Down Expand Up @@ -224,7 +223,7 @@ Rectangle {
topMargin: 10
}
width: parent.width
height: parent.height - deviceAlbumTitleRect.height - m_topMargin - statusBar.height
height: parent.height - deviceAlbumTitleRect.height - m_topMargin
visible: numLabelText !== ""
thumnailListType: GlobalVar.ThumbnailType.Device

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ import "../../Control"
import "../../"
import "../"

Rectangle {
width: parent.width
height: parent.height

BaseView {
property int filterType : filterCombo.currentIndex // 筛选类型,默认所有
property string numLabelText: "" //总数标签显示内容
property string selectedText: getSelectedText(selectedPaths)
Expand Down Expand Up @@ -123,9 +120,7 @@ Rectangle {
// 已导入列表控件
ImportedlListView {
id: theView
anchors.top: parent.top
width: parent.width
height: parent.height - statusBar.height
anchors.fill: parent
}

// 若没有数据,显示导入图片视图
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ import "../../Control/ListView"
import "../../"
import "../"

Rectangle {
width: parent.width
height: parent.height
BaseView {

property int filterType : filterCombo.currentIndex // 筛选类型,默认所有
property string numLabelText: ""
Expand Down Expand Up @@ -235,7 +233,7 @@ Rectangle {
topMargin: 10
}
width: parent.width
height: parent.height - recentDelTitleRect.height - m_topMargin - statusBar.height
height: parent.height - recentDelTitleRect.height - m_topMargin
thumnailListType: GlobalVar.ThumbnailType.Trash

proxyModel.sourceModel: Album.ImageDataModel { id: dataModel; modelType: Album.Types.RecentlyDeleted}
Expand Down
6 changes: 2 additions & 4 deletions src/qml/ThumbnailImageView/SearchView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ import org.deepin.album 1.0 as Album
import "../Control"
import "../Control/ListView"

Rectangle {
width: parent.width
height: parent.height
BaseView {

property string currentKeyword: ""
property var searchResults: new Array
Expand Down Expand Up @@ -153,7 +151,7 @@ Rectangle {
topMargin: 10
}
width: parent.width
height: parent.height - resultViewTitleRect.height - m_topMargin - statusBar.height
height: parent.height - resultViewTitleRect.height - m_topMargin

proxyModel.sourceModel: Album.ImageDataModel { id: dataModel; modelType: Album.Types.SearchResult}

Expand Down
35 changes: 1 addition & 34 deletions src/qml/ThumbnailImageView/ThumbnailImage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ import "./../"
//本文件用于替代stackwidget的作用,通过改变global的0-n来切换窗口

Item {
property int m_topMargin: 0
property int m_leftMargin: 20

property int m_CollecttionCurrentViewIndex: collecttionView.currentViewIndex
signal escKeyPressed()

Expand All @@ -32,60 +31,28 @@ Item {

NoPictureView{
visible: global.currentViewIndex === GlobalVar.ThumbnailViewType.NoPicture
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
}
CollecttionView{
id: collecttionView
color: Qt.rgba(0,0,0,0)
visible: global.currentViewIndex === GlobalVar.ThumbnailViewType.Collecttion
anchors.topMargin: m_topMargin
anchors.leftMargin: m_leftMargin
anchors.fill: parent
anchors.bottomMargin: statusBar.height
}
HaveImportedView{
id: haveImportedView
color: Qt.rgba(0,0,0,0)
visible: global.currentViewIndex === GlobalVar.ThumbnailViewType.HaveImported
anchors.topMargin: m_topMargin
anchors.leftMargin: m_leftMargin
anchors.fill: parent
}
CustomAlbum{
color: Qt.rgba(0,0,0,0)
visible: global.currentViewIndex === GlobalVar.ThumbnailViewType.Favorite
anchors.topMargin: m_topMargin
anchors.leftMargin: m_leftMargin
anchors.fill: parent
}
RecentlyDeletedView{
color: Qt.rgba(0,0,0,0)
visible: global.currentViewIndex === GlobalVar.ThumbnailViewType.RecentlyDeleted
anchors.topMargin: m_topMargin
anchors.leftMargin: m_leftMargin
anchors.fill: parent
}
CustomAlbum{
color: Qt.rgba(0,0,0,0)
visible: global.currentViewIndex === GlobalVar.ThumbnailViewType.CustomAlbum
anchors.topMargin: m_topMargin
anchors.leftMargin: m_leftMargin
anchors.fill: parent
}
SearchView{
color: Qt.rgba(0,0,0,0)
visible: global.currentViewIndex === GlobalVar.ThumbnailViewType.SearchResult
anchors.topMargin: m_topMargin
anchors.leftMargin: m_leftMargin
anchors.fill: parent
}
DeviceAlbum{
color: Qt.rgba(0,0,0,0)
visible: global.currentViewIndex === GlobalVar.ThumbnailViewType.Device
anchors.topMargin: m_topMargin
anchors.leftMargin: m_leftMargin
anchors.fill: parent
}

//export窗口
Expand Down

0 comments on commit 7c7d01c

Please sign in to comment.