diff --git a/src/qml/Control/Animation/SwitchViewAnimation.qml b/src/qml/Control/Animation/SwitchViewAnimation.qml index 1b56fd0a..28bb6325 100644 --- a/src/qml/Control/Animation/SwitchViewAnimation.qml +++ b/src/qml/Control/Animation/SwitchViewAnimation.qml @@ -10,6 +10,8 @@ import org.deepin.album 1.0 as Album Item { id: switchViewAnimation + property int viewType: -1 + property bool show: false property real showOpacity: 1 property real showX: 0 @@ -27,6 +29,18 @@ Item { } else if (switchType === Album.Types.FadeInOut) { x = 0 switchPropertys = "opacity" + + console.log("switchTypechanged:", switchType) + } + } + + onOpacityChanged: { + // 当前视图渐隐后,应将视图移到视图区域外,否则当前视图的鼠标事件依然生效 + if (opacity === 0 && switchType === Album.Types.FadeInOut) { + if (!show) { + if (x === 0) + x = -width - 20 + } } } diff --git a/src/qml/Control/ListView/ThumbnailListDelegate.qml b/src/qml/Control/ListView/ThumbnailListDelegate.qml index b1987a53..7374878d 100755 --- a/src/qml/Control/ListView/ThumbnailListDelegate.qml +++ b/src/qml/Control/ListView/ThumbnailListDelegate.qml @@ -23,7 +23,6 @@ Item { property string m_index property string m_url property string m_displayFlushHelper - property var m_favoriteBtn: itemFavoriteBtn property string remainDays property bool bShowDamageIcon: image.bLoadError property bool bSelected: theView.ism.indexOf(parent.m_index) !== -1 || GStatus.selectedPaths.indexOf(m_url) !== -1 @@ -36,6 +35,7 @@ Item { property Item favoriteBtn: null property Item remainDaysLbl: null property Item videoLabel: null + property int nDuration: GStatus.animationDuration //缩略图本体 Image { @@ -102,13 +102,28 @@ Item { height: image.paintedHeight color:"black" radius: 10 + + Behavior on width { + NumberAnimation { + duration: nDuration + easing.type: Easing.OutExpo // 缓动类型 + } + } + + Behavior on height { + NumberAnimation { + duration: nDuration + easing.type: Easing.OutExpo // 缓动类型 + } + } } + visible: false } OpacityMask{ id: opacityMask - anchors.fill: image + anchors.fill: maskRec source: image maskSource: mask } @@ -116,7 +131,7 @@ Item { FastBlur { anchors.top: opacityMask.top; anchors.topMargin: 6 anchors.left: opacityMask.left; anchors.leftMargin: 1 - width: opacityMask.width - 2; height: opacityMask.width - 6 + width: opacityMask.width - 2; height: opacityMask.height - 6 source: opacityMask radius: 10 transparentBorder: true @@ -125,7 +140,7 @@ Item { //遮罩执行 OpacityMask { id: mask - anchors.fill: image + anchors.fill: maskRec source: image maskSource: maskRec antialiasing: true @@ -143,6 +158,20 @@ Item { border.width: 1 visible: true radius: 10 + + Behavior on width { + NumberAnimation { + duration: nDuration + easing.type: Easing.OutExpo // 缓动类型 + } + } + + Behavior on height { + NumberAnimation { + duration: nDuration + easing.type: Easing.OutExpo // 缓动类型 + } + } } MouseArea { @@ -151,9 +180,6 @@ Item { hoverEnabled: true propagateComposedEvents: true - //属性:是否hover - property bool bHovered: false - onClicked: { //允许鼠标事件传递给子控件处理,否则鼠标点击缩略图收藏图标不能正常工作 mouse.accepted = false @@ -161,55 +187,16 @@ Item { onEntered: { bHovered = true + if (favoriteBtn == null && model.modelType !== Album.Types.Device && model.modelType !== Album.Types.RecentlyDeleted) + favoriteBtn = favoriteComponent.createObject(main) } onExited: { bHovered = false - } - } - - //收藏图标 - ActionButton { - id: itemFavoriteBtn - visible: albumControl.photoHaveFavorited(m_url, GStatus.bRefreshFavoriteIconFlag) || mouseAreaTopParentRect.bHovered - anchors { - bottom: image.bottom - left: image.left - leftMargin : (image.width - image.paintedWidth) / 2 + 5 - bottomMargin : (image.height - image.paintedHeight) / 2 + 5 - } - hoverEnabled: false //设置为false,可以解决鼠标移动到图标附近时,图标闪烁问题 - - icon { - name: albumControl.photoHaveFavorited(m_url, GStatus.bRefreshFavoriteIconFlag) ? "collected" : "collection2" - } - - MouseArea { - id:mouseAreaFavoriteBtn - anchors.fill: itemFavoriteBtn - propagateComposedEvents: true - - onClicked: { - var paths = [] - paths.push(m_url) - - if (albumControl.photoHaveFavorited(m_url, GStatus.bRefreshFavoriteIconFlag)) { - //取消收藏 - albumControl.removeFromAlbum(0, paths) - } else { - //收藏 - albumControl.insertIntoAlbum(0, paths) - } - - GStatus.bRefreshFavoriteIconFlag = !GStatus.bRefreshFavoriteIconFlag - // 若当前视图为我的收藏,需要实时刷新我的收藏列表内容 - if (GStatus.currentViewType === Album.Types.ViewFavorite && GStatus.currentCustomAlbumUId === 0) { - GStatus.sigFlushCustomAlbumView(GStatus.currentCustomAlbumUId) - } - - mouse.accepted = true + if (favoriteBtn && !bFavorited) { + favoriteBtn.destroy() + favoriteBtn = null } - } } @@ -269,8 +256,8 @@ Item { id: iconArea anchors.centerIn: parent// 确保阴影框居中于图片 - width: image.paintedWidth + 14 - height: image.paintedHeight + 14 + width: borderRect.width + 14 + height: borderRect.height + 14 Rectangle { anchors.top: parent.top @@ -321,16 +308,14 @@ Item { Component { id: selectedFrameComponent Item { - anchors.fill: image + anchors.fill: borderRect z: -1 // 计算图片区域的位置 Rectangle { id: imageArea - anchors.centerIn: parent - width: image.paintedWidth - height: image.paintedHeight + anchors.fill: parent visible: false } @@ -338,8 +323,8 @@ Item { Rectangle { id: selectShader anchors.centerIn: parent// 确保阴影框居中于图片 - width: image.paintedWidth + 14 - height: image.paintedHeight + 14 + width: imageArea.width + 14 + height: imageArea.height + 14 radius: 10 color: "#AAAAAA" visible: true @@ -361,31 +346,20 @@ Item { } } - - // 收藏图标组件 Component { id: favoriteComponent Item { - anchors.fill: parent - - // 计算图片区域的位置 - Rectangle { - id: imageArea - anchors.fill: parent - width: parent.width - 14 - height: parent.height - 14 - visible: false - } + anchors.fill: borderRect //收藏图标 ActionButton { id: itemFavoriteBtn anchors { - bottom: imageArea.bottom - left: imageArea.left - leftMargin : (imageArea.width - image.paintedWidth) / 2 + 5 - bottomMargin : (imageArea.height - image.paintedHeight) / 2 + 5 + bottom: parent.bottom + left: parent.left + leftMargin : 5 + bottomMargin : 5 } hoverEnabled: false //设置为false,可以解决鼠标移动到图标附近时,图标闪烁问题 @@ -428,23 +402,14 @@ Item { Component { id: remainDaysComponent Item { - anchors.fill: parent - - // 计算图片区域的位置 - Rectangle { - id: imageArea - anchors.centerIn: parent - width: parent.width - 14 - height: parent.height - 14 - visible: false - } + anchors.fill: borderRect VideoLabel { id: labelRemainDays visible: true anchors { - bottom: imageArea.bottom - left: imageArea.left + bottom: parent.bottom + left: parent.left leftMargin : 9 bottomMargin : 5 } @@ -458,23 +423,14 @@ Item { Component { id: videoTimeComponent Item { - anchors.fill: parent - - // 计算图片区域的位置 - Rectangle { - id: imageArea - anchors.centerIn: parent - width: parent.width - 14 - height: parent.height - 14 - visible: false - } + anchors.fill: borderRect VideoLabel { id: videoLabel visible: bShowVideoLabel anchors { - bottom: imageArea.bottom - right: imageArea.right + bottom: parent.bottom + right: parent.right rightMargin : 9 bottomMargin : 5 } diff --git a/src/qml/Control/ListView/ThumbnailListDelegate2.qml b/src/qml/Control/ListView/ThumbnailListDelegate2.qml old mode 100755 new mode 100644 index a54c9343..45694718 --- a/src/qml/Control/ListView/ThumbnailListDelegate2.qml +++ b/src/qml/Control/ListView/ThumbnailListDelegate2.qml @@ -33,13 +33,12 @@ Item { property bool bFavorited: albumControl.photoHaveFavorited(model.url, GStatus.bRefreshFavoriteIconFlag) property bool bShowRemainDays: GStatus.currentViewType === Album.Types.ViewRecentlyDeleted && !model.blank property bool bShowVideoLabel: fileControl.isVideo(model.url) && !model.blank - property Item imageItem: null - property Item damageIcon: null property Item selectIcon: null property Item selectFrame: null property Item favoriteBtn: null property Item remainDaysLbl: null property Item videoLabel: null + property int nDuration: GStatus.animationDuration // 缩略图本体 Album.QImageItem { @@ -59,7 +58,7 @@ Item { // 图片保存完成,缩略图区域重新加载当前图片 Connections { target: fileControl - function onCallSavePicDone() { + function onCallSavePicDone(path) { if (path === model.url) { model.reloadThumbnail } @@ -80,6 +79,20 @@ Item { height: image.paintedHeight color:"black" radius: 10 + + Behavior on width { + NumberAnimation { + duration: nDuration + easing.type: Easing.OutExpo // 缓动类型 + } + } + + Behavior on height { + NumberAnimation { + duration: nDuration + easing.type: Easing.OutExpo // 缓动类型 + } + } } visible: false @@ -87,7 +100,7 @@ Item { OpacityMask{ id: opacityMask - anchors.fill: image + anchors.fill: maskRec source: image maskSource: mask } @@ -95,7 +108,7 @@ Item { FastBlur { anchors.top: opacityMask.top; anchors.topMargin: 6 anchors.left: opacityMask.left; anchors.leftMargin: 1 - width: opacityMask.width - 2; height: opacityMask.width - 6 + width: opacityMask.width - 2; height: opacityMask.height - 6 source: opacityMask radius: 10 transparentBorder: true @@ -104,7 +117,7 @@ Item { //遮罩执行 OpacityMask { id: mask - anchors.fill: image + anchors.fill: maskRec source: image maskSource: maskRec antialiasing: true @@ -122,6 +135,20 @@ Item { border.width: 1 visible: true radius: 10 + + Behavior on width { + NumberAnimation { + duration: nDuration + easing.type: Easing.OutExpo // 缓动类型 + } + } + + Behavior on height { + NumberAnimation { + duration: nDuration + easing.type: Easing.OutExpo // 缓动类型 + } + } } MouseArea { @@ -209,8 +236,8 @@ Item { id: iconArea anchors.centerIn: parent// 确保阴影框居中于图片 - width: image.paintedWidth + 14 - height: image.paintedHeight + 14 + width: borderRect.width + 14 + height: borderRect.height + 14 Rectangle { anchors.top: parent.top @@ -261,16 +288,14 @@ Item { Component { id: selectedFrameComponent Item { - anchors.fill: image + anchors.fill: borderRect z: -1 // 计算图片区域的位置 Rectangle { id: imageArea - anchors.centerIn: parent - width: image.paintedWidth - height: image.paintedHeight + anchors.fill: parent visible: false } @@ -278,8 +303,8 @@ Item { Rectangle { id: selectShader anchors.centerIn: parent// 确保阴影框居中于图片 - width: image.paintedWidth + 14 - height: image.paintedHeight + 14 + width: imageArea.width + 14 + height: imageArea.height + 14 radius: 10 color: "#AAAAAA" visible: true @@ -301,30 +326,20 @@ Item { } } - // 收藏图标组件 Component { id: favoriteComponent Item { - anchors.fill: parent - - // 计算图片区域的位置 - Rectangle { - id: imageArea - anchors.fill: parent - width: parent.width - 14 - height: parent.height - 14 - visible: false - } + anchors.fill: borderRect //收藏图标 ActionButton { id: itemFavoriteBtn anchors { - bottom: imageArea.bottom - left: imageArea.left - leftMargin : (imageArea.width - image.paintedWidth) / 2 + 5 - bottomMargin : (imageArea.height - image.paintedHeight) / 2 + 5 + bottom: parent.bottom + left: parent.left + leftMargin : 5 + bottomMargin : 5 } hoverEnabled: false //设置为false,可以解决鼠标移动到图标附近时,图标闪烁问题 @@ -358,7 +373,6 @@ Item { mouse.accepted = true } - } } } @@ -368,23 +382,14 @@ Item { Component { id: remainDaysComponent Item { - anchors.fill: parent - - // 计算图片区域的位置 - Rectangle { - id: imageArea - anchors.centerIn: parent - width: parent.width - 14 - height: parent.height - 14 - visible: false - } + anchors.fill: borderRect VideoLabel { id: labelRemainDays visible: true anchors { - bottom: imageArea.bottom - left: imageArea.left + bottom: parent.bottom + left: parent.left leftMargin : 9 bottomMargin : 5 } @@ -398,23 +403,14 @@ Item { Component { id: videoTimeComponent Item { - anchors.fill: parent - - // 计算图片区域的位置 - Rectangle { - id: imageArea - anchors.centerIn: parent - width: parent.width - 14 - height: parent.height - 14 - visible: false - } + anchors.fill: borderRect VideoLabel { id: videoLabel visible: bShowVideoLabel anchors { - bottom: imageArea.bottom - right: imageArea.right + bottom: parent.bottom + right: parent.right rightMargin : 9 bottomMargin : 5 } diff --git a/src/qml/Control/ListView/ThumbnailListView2.qml b/src/qml/Control/ListView/ThumbnailListView2.qml index 59895286..6e335f5d 100644 --- a/src/qml/Control/ListView/ThumbnailListView2.qml +++ b/src/qml/Control/ListView/ThumbnailListView2.qml @@ -37,7 +37,7 @@ FocusScope { // 存在已选项 property bool haveSelect: thumbnailModel.selectedIndexes.length > 0 // 已选择全部缩略图 - property bool haveSelectAll: thumbnailModel.selectedIndexes.length === thumbnailModel.rowCount() + property bool haveSelectAll: thumbnailModel.selectedIndexes.length === thumbnailModel.rowCount() && thumbnailModel.selectedIndexes.length > 0 // 已选项个数 property int haveSelectCount: thumbnailModel.selectedIndexes.length @@ -96,6 +96,16 @@ FocusScope { return thumbnailModel.allUrls() } + function executeViewImage() { + ThumbnailTools.executeViewImage() + } + + function runDeleteImg() { + if (!visible) + return + ThumbnailTools.executeDelete() + } + //统计当前页面的缩略图时间范围 function totalTimeScope() { if(thumnailListType === Album.Types.ThumbnailAllCollection && @@ -113,41 +123,45 @@ FocusScope { } } -// // 提供给合集日视图和已导入视图使用,用来刷新 -// function flushRectSel(x,y,w,h,ctrl,mousePress, inPress) { -// if (gridView.contains(x,y) && gridView.contains(x+w, y+h) && w !== 0 && h !== 0) { -// // 按住Ctrl,鼠标点击事件释放时,处理点选逻辑 -// if (ctrl && mousePress) { -// if (!inPress) { -// var rectSel = gridView.flushRectSel(x, y + gridView.contentY, w, h) -// if (rectSel.length === 1) { -// //不直接往theView.ism里面push,是为了触发onIsmChanged -// var tempIsm = gridView.ism -// if (gridView.ism.indexOf(rectSel[0]) === -1) { -// tempIsm.push(rectSel[0]) -// } else { -// tempIsm.splice(tempIsm.indexOf(rectSel[0]), 1) -// } -// gridView.ism = tempIsm -// } -// } -// } else { -// gridView.ism = gridView.flushRectSel(x, y + gridView.contentY, w, h) -// } -// } else { -// // 1.按住ctrl,鼠标垮区域框选时,需要清空框选区域外的已选项 -// // 2.不按住ctrl,鼠标单选,需要清空其他列表的已选项 -// if (!ctrl && mousePress || ctrl && !mousePress) -// gridView.ism = [] -// } - -// // 跨区域框选后,需要手动激活列表焦点,这样快捷键才能生效 -// if (gridView.ism.length > 0) { -// gridView.forceActiveFocus() -// } - -// selectedChanged() -// } + // 提供给合集日视图和已导入视图使用,用来刷新 + function flushRectSel(x,y,w,h,ctrl,mousePress, inPress) { + if (gridView.contains(Qt.point(x,y)) && gridView.contains(Qt.point(x+w, y+h)) && w !== 0 && h !== 0) { + // 按住Ctrl,鼠标点击事件释放时,处理点选逻辑 + if (ctrl && mousePress) { + if (!inPress) { + var rectSel = gridView.rectIndexes(x, y + gridView.contentY, w, h) + if (rectSel.length === 1) { + //不直接往theView.ism里面push,是为了触发onIsmChanged + var tempIsm = gridView.rectSelIndexes + if (tempIsm === undefined || tempIsm === null) { + gridView.rectSelIndexes = rectSel + } else { + if (gridView.rectSelIndexes.indexOf(rectSel[0]) === -1) { + tempIsm.push(rectSel[0]) + } else { + tempIsm.splice(tempIsm.indexOf(rectSel[0]), 1) + } + gridView.rectSelIndexes = tempIsm + } + } + } + } else { + gridView.rectangleSelect(x, y + gridView.contentY, w, h) + } + } else { + // 1.按住ctrl,鼠标垮区域框选时,需要清空框选区域外的已选项 + // 2.不按住ctrl,鼠标单选,需要清空其他列表的已选项 + if (!ctrl && mousePress || ctrl && !mousePress) + gridView.rectSelIndexes = [] + } + + // 跨区域框选后,需要手动激活列表焦点,这样快捷键才能生效 + if (thumbnailModel.selectedIndexes.length > 0) { + gridView.forceActiveFocus() + } + + selectedChanged() + } Connections { target: thumbnailImage @@ -224,10 +238,12 @@ FocusScope { thumbnailModel.clearSelection(); } - if (gridView.ctrlPressed) { - thumbnailModel.toggleSelected(positioner.map(pressedItem.index)); - } else { - thumbnailModel.setSelected(positioner.map(pressedItem.index)); + if (thumnailListType !== Album.Types.ThumbnailDate) { + if (gridView.ctrlPressed) { + thumbnailModel.toggleSelected(positioner.map(pressedItem.index)); + } else { + thumbnailModel.setSelected(positioner.map(pressedItem.index)); + } } } @@ -1069,7 +1085,7 @@ FocusScope { Component.onCompleted: { GStatus.sigThumbnailStateChange.connect(fouceUpdate) - deleteDialog.sigDoDeleteImg.connect(ThumbnailTools.executeDelete) + deleteDialog.sigDoDeleteImg.connect(runDeleteImg) // 缩略图列表模型选中内容有变化,向外发送选中内容改变信号,以便外部维护全局选中队列GStatus.selectedPaths thumbnailModel.selectedIndexesChanged.connect(selectedChanged) diff --git a/src/qml/GlobalVar.qml b/src/qml/GlobalVar.qml index 754dfed3..1af95965 100644 --- a/src/qml/GlobalVar.qml +++ b/src/qml/GlobalVar.qml @@ -53,6 +53,6 @@ Item { } // 大图模式,隐藏相册标题栏,相册模式显示相册标题栏 onStackControlCurrentChanged: { - window.showTitleBar(stackControlCurrent != 1) + window.showTitleBar(stackControlCurrent != 1 && stackControlCurrent != 2) } } diff --git a/src/qml/ThumbnailImageView/CollecttionView/CollecttionView.qml b/src/qml/ThumbnailImageView/CollecttionView/CollecttionView.qml index a24284c3..2edd3852 100644 --- a/src/qml/ThumbnailImageView/CollecttionView/CollecttionView.qml +++ b/src/qml/ThumbnailImageView/CollecttionView/CollecttionView.qml @@ -84,6 +84,7 @@ BaseView { id: yearCollection width: collecttView.width height: collecttView.height + viewType: 0 show: currentViewIndex === 0 } @@ -91,6 +92,7 @@ BaseView { id: monthCollection width: collecttView.width height: collecttView.height + viewType: 1 show: currentViewIndex === 1 } @@ -99,6 +101,7 @@ BaseView { visible: false width: collecttView.width height: collecttView.height + viewType: 2 show: currentViewIndex === 2 } @@ -107,6 +110,7 @@ BaseView { x: 0 width: collecttView.width height: collecttView.height + viewType: 3 show: currentViewIndex === 3 } @@ -126,6 +130,8 @@ BaseView { // 点击在图片上,动画切换类型为渐显渐隐 GStatus.currentSwitchType = Album.Types.FadeInOut setIndex(1) + allCollection.x = -rollingWidth + dayCollection.x = -rollingWidth monthCollection.scrollToYear(year) } @@ -133,6 +139,7 @@ BaseView { // 点击在图片上,动画切换类型为渐显渐隐 GStatus.currentSwitchType = Album.Types.FadeInOut setIndex(2) + allCollection.x = -rollingWidth dayCollection.scrollToMonth(year, month) } diff --git a/src/qml/ThumbnailImageView/CollecttionView/DayCollection.qml b/src/qml/ThumbnailImageView/CollecttionView/DayCollection.qml index 0504989d..6f01ee91 100644 --- a/src/qml/ThumbnailImageView/CollecttionView/DayCollection.qml +++ b/src/qml/ThumbnailImageView/CollecttionView/DayCollection.qml @@ -495,20 +495,17 @@ SwitchViewAnimation { topPadding: -1 } - ListModel { - id: viewModel - } - - ThumbnailListView { + ThumbnailListView2 { id: theSubView - thumbnailListModel: viewModel anchors { top: selectAllBox.bottom left: selectAllBox.left } - enableWheel: false + enableMouse: false width: parent.width - height: Math.abs(Math.ceil(theSubView.count() / Math.floor((parent.width) / itemWidth)) * itemHeight) + height: Math.abs(Math.ceil(theSubView.count / Math.floor((parent.width) / itemWidth)) * itemHeight) + thumnailListType: Album.Types.ThumbnailDate + proxyModel.sourceModel: Album.ImageDataModel { id: dataModel; modelType: Album.Types.DayCollecttion} Connections { target: rubberBand @@ -528,7 +525,7 @@ SwitchViewAnimation { target: theSubView function onSelectedChanged() { if (index > -1) { - theModel.selectedPathObjs[index].paths = theSubView.selectedPaths + theModel.selectedPathObjs[index].paths = theSubView.selectedUrls } updateSelectedPaths() } @@ -544,7 +541,7 @@ SwitchViewAnimation { Connections { target: theView function onDbClicked(url) { - var openPaths = theSubView.allOriginUrls() + var openPaths = theSubView.allUrls() if (openPaths.indexOf(url) !== -1) theSubView.executeViewImage() } @@ -552,31 +549,21 @@ SwitchViewAnimation { } function flushView() { - var picTotal = 0 - var videoTotal = 0 + var picTotal = albumControl.getDayInfoCount(m_dayToken, 3) + var videoTotal = albumControl.getDayInfoCount(m_dayToken, 4) //1.刷新图片显示 - var paths = albumControl.getDayPaths(m_dayToken) - viewModel.clear() - for (var i = 0;i !== paths.length;++i) { - viewModel.append({url: paths[i], filePath: albumControl.url2localPath(paths[i])}) - - //顺便统计下图片和视频的数量 - if(fileControl.isImage(paths[i])) { - picTotal++ - } else { - videoTotal++ - } - } + dataModel.dayToken = m_dayToken + theSubView.proxyModel.refresh() //2.刷新checkbox var str = "" - if(picTotal == 1) { + if(picTotal === 1) { str += qsTr("1 photo ") } else if(picTotal > 1) { str += qsTr("%1 photos ").arg(picTotal) } - if(videoTotal == 1) { + if(videoTotal === 1) { str += qsTr("1 video") } else if(videoTotal > 1) { str += qsTr("%1 videos").arg(videoTotal) diff --git a/src/qml/ThumbnailImageView/HaveImportedView/ImportedlListView.qml b/src/qml/ThumbnailImageView/HaveImportedView/ImportedlListView.qml index 1944696b..941bf246 100755 --- a/src/qml/ThumbnailImageView/HaveImportedView/ImportedlListView.qml +++ b/src/qml/ThumbnailImageView/HaveImportedView/ImportedlListView.qml @@ -17,7 +17,6 @@ import "../../Control" import "../../" Item { id : importedListView - signal rectSelTitleChanged(rect rt) signal sigUnSelectAll() signal sigListViewPressed(int x, int y) signal sigListViewReleased(int x, int y) @@ -44,29 +43,28 @@ Item { // 从后台获取所有已导入数据,倒序 var titleInfos = [] if (Number(fileControl.getConfigValue("", "loadImport", 1))) - titleInfos = albumControl.getImportTimelinesTitleInfosReverse(filterCombo.currentIndex); - console.log("imported model has refreshed.. filterType:", filterCombo.currentIndex, " done...") + titleInfos = albumControl.getAllImportTimelinesTitle(filterCombo.currentIndex); + console.log("imported model has refreshed.. filterType:", filterCombo.currentIndex, " done...") var i = 0 var dayHeight = 0 var listHeight = 0 theView.listContentHeight = 0 - + var titlePaths for (var j = 0; j < titleInfos.length; j++) { - var listItem = titleInfos[j] - - for (var key in listItem) { - theModel.append({"title":key, "items":listItem[key]}) - var tmpPath = [] - var selectedPathObj = {"id": i, "paths":tmpPath} - theModel.selectedPathObjs.push(selectedPathObj) - - // 计算每个日期列表高度 - listHeight = Math.abs(Math.ceil(listItem[key].length / Math.floor(importedListView.width / realCellWidth)) * realCellWidth) - dayHeight = listHeight + listMargin * 2 + importCheckboxHeight + (i === 0 ? spaceCtrlHeight : 0) - dayHeights.push(dayHeight) - theView.listContentHeight += dayHeight - i++ - } + theModel.append({"title": titleInfos[j]}) + + // 当前标题列表选中数据初始化 + titlePaths = [] + var selectedPathObj = {"id": j, "paths": titlePaths} + theModel.selectedPathObjs.push(selectedPathObj) + + // 计算每个标题列表高度 + titlePaths = albumControl.getTimelinesTitlePaths(titleInfos[j], filterCombo.currentIndex) + listHeight = Math.abs(Math.ceil(titlePaths.length / Math.floor(importedListView.width / realCellWidth)) * realCellWidth) + dayHeight = listHeight + listMargin * 2 + importCheckboxHeight + (j === 0 ? spaceCtrlHeight : 0) + dayHeights.push(dayHeight) + theView.listContentHeight += dayHeight + } } } @@ -88,16 +86,6 @@ Item { } } - // 通知已导入视图标题栏区域,调整色差校正框选框大小 - Connections { - target: rubberBandImport - onRectSelChanged: { - var pos1 = theView.contentItem.mapToItem(importedListView, rubberBandImport.left(), rubberBandImport.top()) - var pos2 = theView.contentItem.mapToItem(importedListView, rubberBandImport.right(), rubberBandImport.bottom()) - rectSelTitleChanged(albumControl.rect(pos1, pos2)) - } - } - //已导入列表本体 ListView { id: theView @@ -149,12 +137,6 @@ Item { return } - //取消全选,初始化选中数据 - GStatus.selectedPaths = [] - for (var i = 0; i != theModel.count; ++i) { - theModel.selectedPathObjs[i].paths.length = 0 - } - ctrlPressed = Qt.ControlModifier & mouse.modifiers theView.scrollDirType = Album.Types.NoType @@ -227,9 +209,6 @@ Item { theView.scrollDirType = Album.Types.NoType rubberBandImport.clearRect() - - // 清除标题栏色差矫校正框选框 - rectSelTitleChanged(albumControl.rect(Qt.point(0, 0), Qt.point(0, 0))) } onWheel: { // 滚动时,激活滚动条显示 @@ -328,23 +307,6 @@ Item { vbar.increase() } } - - //处理全选消息 - onSigSelectAll: { - if (visible) { - var paths = [] - for (var i = 0; i != theModel.count; ++i) { - var array = theModel.get(i).items - //清空 - theModel.selectedPathObjs[i].paths.length = 0 - for (var j = 0; j < array.count; ++j) { - paths.push(array.get(j).url) - theModel.selectedPathObjs[i].paths[j] = array.get(j).url - } - } - GStatus.selectedPaths = paths - } - } } //已导入列表代理控件 @@ -358,7 +320,6 @@ Item { height: importedGridView.height + importedListView.listMargin * 2 + importedListView.importCheckboxHeight + spaceRect.height property string m_index: index property var theViewTitle: global.objIsEmpty(theModel.get(index)) ? "" : theModel.get(index).title //日期标题文本内容 - property var theViewItems: global.objIsEmpty(theModel.get(index)) ? "" : theModel.get(index).items //日期标题对应图片信息链表 Item { id: spaceRect @@ -410,11 +371,11 @@ Item { topPadding: 1 font: DTK.fontManager.t6 id: importedLabel - text: qsTr("Imported on") + " " + theViewTitle + " " + (importedGridView.count() === 1 ? qsTr("1 item") : qsTr("%1 items").arg(importedGridView.count())) + text: qsTr("Imported on") + " " + theViewTitle + " " + (importedGridView.count === 1 ? qsTr("1 item") : qsTr("%1 items").arg(importedGridView.count)) } //缩略图网格表 - ThumbnailListView { + ThumbnailListView2 { id: importedGridView anchors { left: parent.left @@ -422,15 +383,11 @@ Item { topMargin: importedListView.listMargin bottomMargin: importedListView.listMargin } + enableMouse: false width: parent.width - height: Math.abs(Math.ceil(importedGridView.count() / Math.floor((parent.width) / itemWidth)) * itemHeight) - - enableWheel: false - - // 装载数据 - thumbnailListModel: { - theViewItems - } + height: Math.abs(Math.ceil(importedGridView.count / Math.floor((parent.width) / itemWidth)) * itemHeight) + thumnailListType: Album.Types.ThumbnailDate + proxyModel.sourceModel: Album.ImageDataModel { id: dataModel; modelType: Album.Types.HaveImported} Connections { target: rubberBandImport @@ -449,10 +406,8 @@ Item { Connections { target: importedGridView onSelectedChanged: { - theModel.selectedPathObjs[m_index].paths.length = 0; - for (var i = 0; i < importedGridView.selectedPaths.length; i++) { - var url = importedGridView.selectedPaths[i] - theModel.selectedPathObjs[m_index].paths.push(url) + if (index > -1) { + theModel.selectedPathObjs[index].paths = importedGridView.selectedUrls } updateSelectedPaths() @@ -469,14 +424,20 @@ Item { Connections { target: theView onDbClicked: { - var openPaths = importedGridView.allOriginUrls() + var openPaths = importedGridView.allUrls() if (openPaths.indexOf(url) !== -1) importedGridView.executeViewImage() } } + function flushView() { + dataModel.importTitle = theViewTitle + importedGridView.proxyModel.refresh(filterCombo.currentIndex) + } + Component.onCompleted: { - importedGridView.initIsm(theModel.selectedPathObjs[index].paths) + importedGridView.flushView() + importedGridView.selectUrls(theModel.selectedPathObjs[index].paths) } } } diff --git a/src/src/albumControl.cpp b/src/src/albumControl.cpp index cce5a9b3..95025677 100644 --- a/src/src/albumControl.cpp +++ b/src/src/albumControl.cpp @@ -475,7 +475,7 @@ QStringList AlbumControl::getTimelinesTitlePaths(const QString &titleName, const } else if (m_dayDateMap.keys().contains(titleName)) { dblist = m_dayDateMap.value(titleName); } else { - dblist = m_timeLinePathsMap.value(titleName); + dblist = m_importTimeLinePathsMap.value(titleName); } for (DBImgInfo info : dblist) { if (filterType == 2 && info.itemType == ItemTypePic) { @@ -2198,7 +2198,6 @@ QString AlbumControl::getFileTime(const QString &path1, const QString &path2) auto str2 = time2.toString("yyyy/MM/dd"); QString language = QLocale::system().name(); - qWarning() << "language:" << language; if (language == "zh_CN") { str1 = QString(tr("%1Year%2Month%3Day")) .arg(time1.date().year()) @@ -2512,6 +2511,25 @@ QStringList AlbumControl::getDayPaths(const QString &day) return DBManager::instance()->getDayPaths(day); } +int AlbumControl::getDayInfoCount(const QString &day, const int &filterType) +{ + int rePicVideoConut = 0; + QStringList list = getDayPaths(day); + for (QString path : list) { + QVariantMap tmpMap; + if (LibUnionImage_NameSpace::isImage(url2localPath(path))) { + if (filterType == ItemTypePic) { + rePicVideoConut++; + } + } else if (LibUnionImage_NameSpace::isVideo(url2localPath(path))) { + if (filterType == ItemTypeVideo) { + rePicVideoConut++; + } + } + } + return rePicVideoConut; +} + //获取日期 QStringList AlbumControl::getDays() { diff --git a/src/src/albumControl.h b/src/src/albumControl.h index 9449381d..214ad80b 100644 --- a/src/src/albumControl.h +++ b/src/src/albumControl.h @@ -265,6 +265,9 @@ class AlbumControl : public QObject //获取指定日期的照片路径 Q_INVOKABLE QStringList getDayPaths(const QString &day); + //获取指定日期的图片和视频数量 + Q_INVOKABLE int getDayInfoCount(const QString &day, const int &filterType); + //获取日期 Q_INVOKABLE QStringList getDays(); diff --git a/src/src/globalstatus.cpp b/src/src/globalstatus.cpp index 0f14038f..08cd18df 100644 --- a/src/src/globalstatus.cpp +++ b/src/src/globalstatus.cpp @@ -28,6 +28,7 @@ static const int sc_VerticalScrollBarWidth = 15; // 垂直滚动条宽度 static const int sc_RectSelScrollStep = 30; // 框选滚动步进 static const int sc_ThumbnailListRightMargin = 10; // 框选滚动步进 static const int sc_ThumbnialListCellSpace = 4; // 框选滚动步进 +static const int sc_AnimationDuration = 400; // 动画持续时间 /** @class GlobalStatus @brief QML单例类,维护全局状态,同步不同组件间的状态信息 @@ -351,6 +352,11 @@ int GlobalStatus::needHideSideBarWidth() const return sc_NeedHideSideBarWidth; } +int GlobalStatus::animationDuration() const +{ + return sc_AnimationDuration; +} + qreal GlobalStatus::sideBarX() const { return m_sideBar_X; diff --git a/src/src/globalstatus.h b/src/src/globalstatus.h index 1ba6e559..9752717d 100644 --- a/src/src/globalstatus.h +++ b/src/src/globalstatus.h @@ -35,6 +35,7 @@ class GlobalStatus : public QObject Q_PROPERTY(int rectSelScrollStep READ rectSelScrollStep CONSTANT) Q_PROPERTY(int thumbnailListRightMargin READ thumbnailListRightMargin CONSTANT) Q_PROPERTY(int thumbnialListCellSpace READ thumbnialListCellSpace CONSTANT) + Q_PROPERTY(int animationDuration READ animationDuration CONSTANT) public: explicit GlobalStatus(QObject *parent = nullptr); @@ -260,6 +261,7 @@ class GlobalStatus : public QObject int rectSelScrollStep() const; int thumbnailListRightMargin() const; int thumbnialListCellSpace() const; + int animationDuration() const; // 相册相关信号 Q_SIGNALS: diff --git a/src/src/thumbnailview/imagedatamodel.cpp b/src/src/thumbnailview/imagedatamodel.cpp index 82b0e293..7a7780f7 100644 --- a/src/src/thumbnailview/imagedatamodel.cpp +++ b/src/src/thumbnailview/imagedatamodel.cpp @@ -161,6 +161,19 @@ void ImageDataModel::setDayToken(QString dayToken) m_dayToken = dayToken; } +QString ImageDataModel::importTitle() +{ + return m_importTitle; +} + +void ImageDataModel::setImportTitle(QString importTitle) +{ + if (m_importTitle != importTitle) + emit importTitleChanged(); + + m_importTitle = importTitle; +} + DBImgInfo ImageDataModel::dataForIndex(const QModelIndex &index) const { if (!index.isValid()) @@ -194,6 +207,8 @@ void ImageDataModel::loadData(Types::ItemType type) m_infoList = AlbumControl::instance()->searchPicFromAlbum2(m_albumID, m_keyWord, false); } else if (m_modelType == Types::DayCollecttion) { m_infoList = DBManager::instance()->getInfosByDay(m_dayToken); + } else if (m_modelType == Types::HaveImported) { + m_infoList = DBManager::instance()->getInfosByImportTimeline(QDateTime::fromString(m_importTitle, "yyyy/MM/dd hh:mm"), itemType); } endResetModel(); qDebug() << QString("loadData modelType:[%1] cost [%2]ms..").arg(m_modelType).arg(time.elapsed()); diff --git a/src/src/thumbnailview/imagedatamodel.h b/src/src/thumbnailview/imagedatamodel.h index ba892210..36c04cfb 100644 --- a/src/src/thumbnailview/imagedatamodel.h +++ b/src/src/thumbnailview/imagedatamodel.h @@ -18,6 +18,8 @@ class ImageDataModel : public QAbstractListModel Q_PROPERTY(QString keyWord READ keyWord WRITE setKeyWord NOTIFY keyWordChanged) Q_PROPERTY(QString devicePath READ devicePath WRITE setDevicePath NOTIFY devicePathChanged) Q_PROPERTY(QString dayToken READ dayToken WRITE setDayToken NOTIFY dayTokenChanged) + Q_PROPERTY(QString importTitle READ importTitle WRITE setImportTitle NOTIFY importTitleChanged) + public: explicit ImageDataModel(QObject *parent = nullptr); @@ -40,6 +42,9 @@ class ImageDataModel : public QAbstractListModel QString dayToken(); void setDayToken(QString dayToken); + QString importTitle(); + void setImportTitle(QString importTitle); + DBImgInfo dataForIndex(const QModelIndex &index) const; Q_INVOKABLE void loadData(Types::ItemType type = Types::All); @@ -50,6 +55,7 @@ class ImageDataModel : public QAbstractListModel void keyWordChanged(); void devicePathChanged(); void dayTokenChanged(); + void importTitleChanged(); private: Types::ModelType m_modelType; @@ -57,6 +63,7 @@ class ImageDataModel : public QAbstractListModel QString m_devicePath; QString m_keyWord; QString m_dayToken; + QString m_importTitle; QList> m_locations; DBImgInfoList m_infoList; diff --git a/src/src/thumbnailview/qimageitem.cpp b/src/src/thumbnailview/qimageitem.cpp index c4c89b8e..53171ae7 100644 --- a/src/src/thumbnailview/qimageitem.cpp +++ b/src/src/thumbnailview/qimageitem.cpp @@ -6,13 +6,16 @@ */ #include "qimageitem.h" +#include "../imageengine/imagedataservice.h" -#include #include #include DGUI_USE_NAMESPACE +#include +#include + QImage QImageItem::s_damage = QImage(); QImageItem::QImageItem(QQuickItem *parent) @@ -40,8 +43,21 @@ void QImageItem::setImage(const QImage &image) { bool oldImageNull = m_image.isNull(); m_image = image; + + QRect oldPaintedRect = m_paintedRect; updatePaintedRect(); - update(); + // 若图片显示方式从方图变为原始比例,需要延迟刷新图片,以便比例切换动画能正常显示 + if (ImageDataService::instance()->getLoadMode() == 1) { + if (m_paintedRect.width() < oldPaintedRect.width() || m_paintedRect.height() < oldPaintedRect.height()) { + QTimer::singleShot(100, this, [=] { + update(); + }); + } else { + update(); + } + } else { + update(); + } Q_EMIT nativeWidthChanged(); Q_EMIT nativeHeightChanged(); Q_EMIT imageChanged(); @@ -170,6 +186,7 @@ void QImageItem::updatePaintedRect() case PreserveAspectFit: { QSizeF scaled = pImage->size(); + QSizeF size = boundingRect().size(); scaled.scale(boundingRect().size(), Qt::KeepAspectRatio); destRect = QRectF(QPoint(0, 0), scaled); destRect.moveCenter(boundingRect().center().toPoint()); diff --git a/src/src/types.h b/src/src/types.h index 5c10df6d..e290b96b 100644 --- a/src/src/types.h +++ b/src/src/types.h @@ -61,6 +61,7 @@ class Types : public QObject ThumbnailCustomAlbum, // 自定义相册 ThumbnailAutoImport, // 自动导入路径 ThumbnailAllCollection, // 合集模式 + ThumbnailDate, // 日期模式 ThumbnailDevice // 设备列表 };