Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add switch types to set animation switching effects #228

Merged
merged 1 commit into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/qml/AlbumTitle.qml
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ TitleBar {
visible: GStatus.currentViewType === Album.Types.ViewCollecttion && albumControl.getYears(refreshVisible).length !== 0 && window.width <= showCollComboWidth

property bool refreshVisible: false
property bool blocksignal: false

model: ListModel {
ListElement { text: qsTr("Y"); icon: "" }
Expand All @@ -330,10 +331,21 @@ TitleBar {
collectionCombo.currentIndex = index
}

function updateIndex() {
blocksignal = true
collectionCombo.currentIndex = GStatus.currentCollecttionViewIndex
blocksignal = false
}

onCurrentIndexChanged: {
collectionBtnClicked(currentIndex)
if (!blocksignal)
collectionBtnClicked(currentIndex)
collectionBtnBox.setChecked(currentIndex)
}

Component.onCompleted: {
GStatus.currentCollecttionViewIndexChanged.connect(updateIndex)
}
}
}

Expand Down
22 changes: 20 additions & 2 deletions src/qml/Control/Animation/SwitchViewAnimation.qml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import QtQuick 2.11
import QtQuick.Controls 2.4

import org.deepin.album 1.0 as Album

Item {
id: switchViewAnimation

Expand All @@ -15,6 +17,19 @@ Item {
property real hideOpacity: 0
property real hideX: -width - 20

property int switchType: GStatus.currentSwitchType
property string switchPropertys: "x,opacity"

onSwitchTypeChanged: {
if (switchType === Album.Types.FlipScroll) {
x = width + 20
switchPropertys = "x,opacity"
} else if (switchType === Album.Types.FadeInOut) {
x = 0
switchPropertys = "opacity"
}
}

state: "hide"
states: [
State {
Expand All @@ -37,7 +52,10 @@ Item {
}
]

transitions: Transition {
NumberAnimation{properties: "x,opacity"; easing.type: Easing.OutExpo; duration: 400}
transitions:
Transition {
enabled: switchType !== Album.Types.HardCut
NumberAnimation{properties: switchPropertys; easing.type: Easing.OutExpo; duration: 400
}
}
}
2 changes: 1 addition & 1 deletion src/qml/StatusBar.qml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Item {
right: parent.right
rightMargin: 20
}
visible: !(GStatus.currentViewType === Album.Types.ViewCollecttion && thumbnailImage.m_CollecttionCurrentViewIndex < 2)
visible: !(GStatus.currentViewType === Album.Types.ViewCollecttion && GStatus.currentCollecttionViewIndex < 2)
from: 0
value: 0
stepSize: 1
Expand Down
10 changes: 5 additions & 5 deletions src/qml/ThumbnailImageView/CollecttionView/CollecttionView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,9 @@ BaseView {
dayCollection.flushModel()
if (dayCollection.x < 0)
dayCollection.x = rollingWidth
if (dayCollection.x !== 0) {
if (!dayCollection.visible) {
dayCollection.visible = true
}

GStatus.selectedPaths = []
flushDayViewStatusText()
} else if (index === 3) {
Expand Down Expand Up @@ -83,15 +82,13 @@ BaseView {

YearCollection {
id: yearCollection
x: rollingWidth
width: collecttView.width
height: collecttView.height
show: currentViewIndex === 0
}

MonthCollection {
id: monthCollection
x: rollingWidth
width: collecttView.width
height: collecttView.height
show: currentViewIndex === 1
Expand All @@ -100,7 +97,6 @@ BaseView {
DayCollection {
id: dayCollection
visible: false
x: rollingWidth
width: collecttView.width
height: collecttView.height
show: currentViewIndex === 2
Expand All @@ -127,11 +123,15 @@ BaseView {
}

function onYearClicked(year) {
// 点击在图片上,动画切换类型为渐显渐隐
GStatus.currentSwitchType = Album.Types.FadeInOut
setIndex(1)
monthCollection.scrollToYear(year)
}

function onMonthClicked(year, month) {
// 点击在图片上,动画切换类型为渐显渐隐
GStatus.currentSwitchType = Album.Types.FadeInOut
setIndex(2)
dayCollection.scrollToMonth(year, month)
}
Expand Down
11 changes: 4 additions & 7 deletions src/qml/ThumbnailImageView/ThumbnailImage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,8 @@ import "./../"

Item {

property int m_CollecttionCurrentViewIndex: collecttionView.currentViewIndex
signal escKeyPressed()

function setCollecttionViewIndex(index) {
collecttionView.setIndex(index)
}

CollecttionView{
id: collecttionView
visible: GStatus.currentViewType === Album.Types.ViewCollecttion
Expand Down Expand Up @@ -74,8 +69,10 @@ Item {

Connections {
target: titleAlubmRect
onCollectionBtnClicked: {
setCollecttionViewIndex(nIndex)
function onCollectionBtnClicked(index) {
// 点击按钮,动画切换类型设定为翻页滚动
GStatus.currentSwitchType = Album.Types.FlipScroll
collecttionView.setIndex(index)
}
}

Expand Down
13 changes: 13 additions & 0 deletions src/src/globalstatus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,20 @@
}
}

Types::SwitchType GlobalStatus::currentSwitchType() const

Check warning on line 448 in src/src/globalstatus.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'currentSwitchType' is never used.
{
return m_currentSwitchType;
}

void GlobalStatus::setCurrentSwitchType(const int &value)

Check warning on line 453 in src/src/globalstatus.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'setCurrentSwitchType' is never used.
{
if (m_currentSwitchType != value) {
m_currentSwitchType = static_cast<Types::SwitchType>(value);
Q_EMIT currentSwitchTypeChanged();
}
}

int GlobalStatus::currentCustomAlbumUId() const

Check warning on line 461 in src/src/globalstatus.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'currentCustomAlbumUId' is never used.
{
return m_currentCustomAlbumUId;
}
Expand Down
7 changes: 7 additions & 0 deletions src/src/globalstatus.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,12 @@ class GlobalStatus : public QObject
void setCurrentCollecttionViewIndex(const int& value);
Q_SIGNAL void currentCollecttionViewIndexChanged();

// 合集当前动画切换类型
Q_PROPERTY(Types::SwitchType currentSwitchType READ currentSwitchType WRITE setCurrentSwitchType NOTIFY currentSwitchTypeChanged)
Types::SwitchType currentSwitchType() const;
void setCurrentSwitchType(const int& value);
Q_SIGNAL void currentSwitchTypeChanged();

// 当前自定义相册Id
Q_PROPERTY(int currentCustomAlbumUId READ currentCustomAlbumUId WRITE setCurrentCustomAlbumUId NOTIFY currentCustomAlbumUIdChanged)
int currentCustomAlbumUId() const;
Expand Down Expand Up @@ -294,6 +300,7 @@ class GlobalStatus : public QObject
bool m_bRefreshRangeBtnState = false; // 刷新显示比例图标激活状态标记,翻转一次,前端图标就刷新一次
Types::ThumbnailViewType m_currentViewType = Types::ViewImport; // 当前显示的视图类型
int m_currentCollecttionViewIndex = 3; // 合集当前索引 0:年 1:月 2:日 3:所有图片
Types::SwitchType m_currentSwitchType = Types::UnknownSwitchType;
int m_currentCustomAlbumUId = -1; // 当前自定义相册所在UId,-1:照片库(非我的收藏) 0:我的收藏 1:截图录屏 2:相机 3:画板 其他:自定义相册
int m_stackControlCurrent = 0; // 0:相册界面 1:看图界面 2:幻灯片
int m_stackControlLastCurrent = -1; // 记录上一次显示的主界面索引 0:相册界面 1:看图界面 2:幻灯片
Expand Down
12 changes: 12 additions & 0 deletions src/src/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class Types : public QObject
Q_ENUMS(ItemRole)
Q_ENUMS(ImageType)
Q_ENUMS(StackPage)

Q_ENUMS(SwitchType)
public:
explicit Types(QObject *parent = nullptr);
~Types() override;
Expand Down Expand Up @@ -110,6 +112,16 @@ class Types : public QObject
ImageViewPage, ///< 图片展示界面(含缩略图栏)
SliderShowPage, ///< 图片动画展示界面
};

/**
@brief 年月日动画切换类型
*/
enum SwitchType {
UnknownSwitchType = -1,
HardCut, ///< 硬切
FlipScroll, ///< 滚动翻页
FadeInOut, ///< 渐显渐隐
};
};

#endif // TYPES_H
Loading