diff --git a/src/main.cpp b/src/main.cpp index 8e5d3a27..f54e4ec5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -109,6 +109,8 @@ int main(int argc, char *argv[]) emit fileControl->imageFileChanged(filePath, isMultiImage, isExist); }); + status.setFileControl(fileControl); + // 光标位置查询工具 CursorTool *cursorTool = new CursorTool(); engine.rootContext()->setContextProperty("cursorTool", cursorTool); diff --git a/src/qml/Control/Animation/SwitchViewAnimation.qml b/src/qml/Control/Animation/SwitchViewAnimation.qml index 28bb6325..19d9e171 100644 --- a/src/qml/Control/Animation/SwitchViewAnimation.qml +++ b/src/qml/Control/Animation/SwitchViewAnimation.qml @@ -29,8 +29,6 @@ Item { } else if (switchType === Album.Types.FadeInOut) { x = 0 switchPropertys = "opacity" - - console.log("switchTypechanged:", switchType) } } @@ -69,7 +67,7 @@ Item { transitions: Transition { enabled: switchType !== Album.Types.HardCut - NumberAnimation{properties: switchPropertys; easing.type: Easing.OutExpo; duration: 400 + NumberAnimation{properties: switchPropertys; easing.type: Easing.OutExpo; duration: GStatus.animationDuration } } } diff --git a/src/qml/Control/BorderImageEx.qml b/src/qml/Control/BorderImageEx.qml index 0f1c9634..f30658f7 100644 --- a/src/qml/Control/BorderImageEx.qml +++ b/src/qml/Control/BorderImageEx.qml @@ -7,10 +7,11 @@ import QtQuick.Controls 2.4 import QtQuick.Layouts 1.11 Image { + id: boerderImageEx smooth: true antialiasing: true fillMode: Image.PreserveAspectCrop - + property string url: "" //border and shadow Rectangle { id: borderRect diff --git a/src/qml/Control/MonthImage.qml b/src/qml/Control/MonthImage.qml index 1a6383fc..11e990e0 100644 --- a/src/qml/Control/MonthImage.qml +++ b/src/qml/Control/MonthImage.qml @@ -35,6 +35,7 @@ Rectangle { width: monthImage.width height: monthImage.height source: "image://collectionPublisher/" + monthImage.displayFlushHelper.toString() + "_M_1_" + paths[0] + url: paths[0] } } @@ -49,6 +50,7 @@ Rectangle { width: monthImage.width / 2 height: monthImage.height source: "image://collectionPublisher/" + monthImage.displayFlushHelper.toString() + "_M_1_" + modelData + url: modelData } } } @@ -63,6 +65,7 @@ Rectangle { width: monthImage.width / 2 height: monthImage.height source: "image://collectionPublisher/" + monthImage.displayFlushHelper.toString() + "_M_1_" + paths[0] + url: paths[0] } Column { @@ -73,6 +76,7 @@ Rectangle { width: monthImage.width / 2 height: monthImage.height / 2 source: "image://collectionPublisher/" + monthImage.displayFlushHelper.toString() + "_M_2_" + modelData + url: modelData } } } @@ -92,6 +96,7 @@ Rectangle { width: monthImage.width / 2 height: monthImage.height / 2 source: "image://collectionPublisher/" + monthImage.displayFlushHelper.toString() + "_M_2_" + modelData + url: modelData } } } @@ -106,6 +111,7 @@ Rectangle { width: monthImage.width height: monthImage.height * 0.618 source: "image://collectionPublisher/" + monthImage.displayFlushHelper.toString() + "_M_3_" + paths[0] + url: paths[0] } Row { @@ -116,6 +122,7 @@ Rectangle { width: monthImage.width / 4 height: monthImage.height * (1 - 0.618) source: "image://collectionPublisher/" + monthImage.displayFlushHelper.toString() + "_M_4_" + modelData + url: modelData } } } @@ -131,6 +138,7 @@ Rectangle { width: monthImage.width height: monthImage.height * 0.618 source: "image://collectionPublisher/" + monthImage.displayFlushHelper.toString() + "_M_3_" + paths[0] + url: paths[0] } Row { @@ -141,6 +149,7 @@ Rectangle { width: monthImage.width / 5 height: monthImage.height * (1 - 0.618) source: "image://collectionPublisher/" + monthImage.displayFlushHelper.toString() + "_M_5_" + modelData + url: modelData } } } diff --git a/src/qml/PreviewImageViewer/ImageViewer.qml b/src/qml/PreviewImageViewer/ImageViewer.qml index 9bef8d5d..367b3041 100644 --- a/src/qml/PreviewImageViewer/ImageViewer.qml +++ b/src/qml/PreviewImageViewer/ImageViewer.qml @@ -1171,7 +1171,22 @@ Rectangle { duration: GStatus.animationDuration easing.type: Easing.OutExpo } - + NumberAnimation { + target: imageviewr + property: "opacity" + from: 0 + to: 1 + duration: GStatus.animationDuration + easing.type: Easing.OutExpo + } + NumberAnimation { + target: view + property: "opacity" + from: 0 + to: 1 + duration: GStatus.animationDuration + easing.type: Easing.OutExpo + } NumberAnimation { target: view properties: "y" diff --git a/src/qml/ThumbnailImageView/CollecttionView/CollecttionView.qml b/src/qml/ThumbnailImageView/CollecttionView/CollecttionView.qml index 2edd3852..915ac89d 100644 --- a/src/qml/ThumbnailImageView/CollecttionView/CollecttionView.qml +++ b/src/qml/ThumbnailImageView/CollecttionView/CollecttionView.qml @@ -25,11 +25,9 @@ BaseView { return if (index === 0) { - yearCollection.flushModel() if (yearCollection.x < 0) yearCollection.x = rollingWidth } else if (index === 1) { - monthCollection.flushModel() if (monthCollection.x < 0) monthCollection.x = rollingWidth } else if (index === 2) { diff --git a/src/qml/ThumbnailImageView/CollecttionView/MonthCollection.qml b/src/qml/ThumbnailImageView/CollecttionView/MonthCollection.qml index 6c2809f8..1a18ea1e 100644 --- a/src/qml/ThumbnailImageView/CollecttionView/MonthCollection.qml +++ b/src/qml/ThumbnailImageView/CollecttionView/MonthCollection.qml @@ -21,16 +21,26 @@ SwitchViewAnimation { signal monthClicked(string year, string month) + property int itemHeight: theView.width * 4 / 7 function scrollToYear(year) { //搜索index - for(var i = 0;i !== theModel.count;++i) { + var index = 0; + for(var i = 0;i !== theModel.count; i++) { if(theModel.get(i).year === year) { + index = i break } } //计算偏移 - theView.contentY = (theView.height / 3 * 2 + theView.spacing) * i + var yValue = (itemHeight + theView.spacing) * index + theView.contentY = 0 + theView.contentY = yValue + } + + onVisibleChanged: { + if (visible) + flushModel() } function flushModel() { diff --git a/src/qml/ThumbnailImageView/CollecttionView/YearCollection.qml b/src/qml/ThumbnailImageView/CollecttionView/YearCollection.qml index 0b18a479..e3662c1b 100644 --- a/src/qml/ThumbnailImageView/CollecttionView/YearCollection.qml +++ b/src/qml/ThumbnailImageView/CollecttionView/YearCollection.qml @@ -19,6 +19,11 @@ SwitchViewAnimation { signal yearClicked(string year) + onVisibleChanged: { + if (visible) + flushModel() + } + function flushModel() { if (!visible) return @@ -64,6 +69,7 @@ SwitchViewAnimation { width: theView.width height: theView.width * 4 / 7 + property string yearPath: albumControl.getYearCoverPath(year) Image { id: image diff --git a/src/qml/ThumbnailImageView/ThumbnailImage.qml b/src/qml/ThumbnailImageView/ThumbnailImage.qml index ffbfdb37..7dd427d7 100644 --- a/src/qml/ThumbnailImageView/ThumbnailImage.qml +++ b/src/qml/ThumbnailImageView/ThumbnailImage.qml @@ -70,6 +70,8 @@ Item { Connections { target: titleAlubmRect function onCollectionBtnClicked(index) { + if (GStatus.currentCollecttionViewIndex === index) + return // 点击按钮,动画切换类型设定为翻页滚动 GStatus.currentSwitchType = Album.Types.FlipScroll collecttionView.setIndex(index) diff --git a/src/src/albumControl.cpp b/src/src/albumControl.cpp index 95025677..46e9c89d 100644 --- a/src/src/albumControl.cpp +++ b/src/src/albumControl.cpp @@ -2505,6 +2505,14 @@ void AlbumControl::importFromMountDevice(const QStringList &paths, const int &in } +QString AlbumControl::getYearCoverPath(const QString &year) +{ + auto paths = DBManager::instance()->getYearPaths(year, 1); + if (paths.isEmpty()) + return ""; + return paths[0]; +} + //获取指定日期的照片路径 QStringList AlbumControl::getDayPaths(const QString &day) { diff --git a/src/src/albumControl.h b/src/src/albumControl.h index 214ad80b..3488d4ae 100644 --- a/src/src/albumControl.h +++ b/src/src/albumControl.h @@ -262,6 +262,9 @@ class AlbumControl : public QObject //手机照片导入 0为已导入,1-n为自定义相册 Q_INVOKABLE void importFromMountDevice(const QStringList &paths, const int &index = 0); + //获取年封面图片路径 + Q_INVOKABLE QString getYearCoverPath(const QString &year); + //获取指定日期的照片路径 Q_INVOKABLE QStringList getDayPaths(const QString &day); diff --git a/src/src/configsetter.cpp b/src/src/configsetter.cpp index 7df46965..b0684f38 100644 --- a/src/src/configsetter.cpp +++ b/src/src/configsetter.cpp @@ -44,6 +44,8 @@ void LibConfigSetter::loadConfig(imageViewerSpace::ImgViewerType type) setValue("", "loadDayView", 1); if (!contains("", "loadImport")) setValue("", "loadImport", 1); + if (!contains("","animationDuration")) + setValue("", "animationDuration", 400); } // if (imageViewerSpace::ImgViewerTypeAlbum == m_viewType) { diff --git a/src/src/globalstatus.cpp b/src/src/globalstatus.cpp index 08cd18df..41f2128b 100644 --- a/src/src/globalstatus.cpp +++ b/src/src/globalstatus.cpp @@ -28,7 +28,6 @@ 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单例类,维护全局状态,同步不同组件间的状态信息 @@ -300,6 +299,14 @@ int GlobalStatus::rightMenuItemHeight() const void GlobalStatus::setFileControl(FileControl *fc) { m_fileControl = fc; + + if (!m_fileControl) + return; + + bool bRet = false; + m_nAnimationDuration = m_fileControl->getConfigValue("", "animationDuration", 400).toInt(&bRet); + if (!bRet) + m_nAnimationDuration = 400; } int GlobalStatus::rightMenuSeparatorHeight() const @@ -354,7 +361,7 @@ int GlobalStatus::needHideSideBarWidth() const int GlobalStatus::animationDuration() const { - return sc_AnimationDuration; + return m_nAnimationDuration; } qreal GlobalStatus::sideBarX() const diff --git a/src/src/globalstatus.h b/src/src/globalstatus.h index 9752717d..fafe1527 100644 --- a/src/src/globalstatus.h +++ b/src/src/globalstatus.h @@ -322,6 +322,7 @@ class GlobalStatus : public QObject bool m_bWindowDisactived = false; // 窗口是否激活标记 bool m_bLoading = true; // 记录相册界面是否处于加载状态 + int m_nAnimationDuration = 400; // 动画持续时间 FileControl* m_fileControl { nullptr }; };