Skip to content

Commit 1200e89

Browse files
authored
Refactor footer (#116)
* Reimplement footer * Fix backups * Ensure comment is always completely visible * Add tests * Remove old code
1 parent 9dc281f commit 1200e89

16 files changed

+472
-759
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "mpvQC"
33
version = "0.9.0-alpha"
44
description = "libmpv based application for quality control of videos"
5-
requires-python = ">=3.11,<=3.12"
5+
requires-python = ">=3.11,<=3.13"
66
readme = "README.MD"
77
dependencies = [
88
"inject>=5.2.1",

qml/app/MpvqcContentSplitView.qml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,27 @@ FocusScope {
4646
states: [
4747
State {
4848
name: "fullscreen"
49-
ParentChange { target: _player; parent: root }
50-
PropertyChanges { _tableContainer { visible: false } }
49+
ParentChange {
50+
target: _player
51+
parent: root
52+
}
53+
PropertyChanges {
54+
_tableContainer {
55+
visible: false
56+
}
57+
}
5158
},
5259
State {
5360
name: "normal"
54-
ParentChange { target: _player; parent: _playerContainer }
55-
PropertyChanges { _tableContainer { visible: true } }
61+
ParentChange {
62+
target: _player
63+
parent: _playerContainer
64+
}
65+
PropertyChanges {
66+
_tableContainer {
67+
visible: true
68+
}
69+
}
5670
}
5771
]
5872

qml/app/MpvqcManager.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ MpvqcManagerPyObject {
3434
readonly property Timer backupTimer: Timer {
3535
repeat: true
3636
interval: Math.max(15, root.mpvqcSettings.backupInterval) * 1000
37-
running: root.mpvqcSettings.backupEnabled && mpvqcCommentTable.count > 0
37+
running: root.mpvqcSettings.backupEnabled && mpvqcCommentTable.commentCount > 0
3838

3939
onTriggered: {
4040
root.backup_impl();

qml/footer/MpvqcFooter.qml

Lines changed: 82 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
mpvQC
33
4-
Copyright (C) 2022 mpvQC developers
4+
Copyright (C) 2024 mpvQC developers
55
66
This program is free software: you can redistribute it and/or modify
77
it under the terms of the GNU General Public License as published by
@@ -18,89 +18,105 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
1818
*/
1919

2020
import QtQuick
21-
import QtQuick.Controls
22-
import QtQuick.Layouts
21+
22+
import "../settings"
2323

2424
Item {
2525
id: root
2626

2727
required property var mpvqcApplication
2828

29-
readonly property var mpvqcSettings: mpvqcApplication.mpvqcSettings
30-
31-
readonly property bool horizontalLayout: mpvqcSettings.layoutOrientation === Qt.Horizontal
32-
33-
readonly property int customBottomMargin: mpvqcApplication.maximized ? 2 : 0
34-
readonly property int customLeftMargin: 3
29+
readonly property alias rowSelectionLabelText: _content.rowSelectionLabel // for tests
30+
readonly property alias percentLabelText: _content.percentLabel // for tests
31+
readonly property alias videoTimeLabelText: _content.videoTimeLabel // for tests
32+
33+
height: 25
34+
visible: !root.mpvqcApplication.fullscreen
35+
36+
QtObject {
37+
id: _impl
38+
39+
readonly property var mpvqcSettings: root.mpvqcApplication.mpvqcSettings
40+
readonly property var mpvqcCommentTable: root.mpvqcApplication.mpvqcCommentTable
41+
readonly property var mpvqcLabelWidthCalculator: root.mpvqcApplication.mpvqcLabelWidthCalculator
42+
readonly property var mpvqcMpvPlayerPropertiesPyObject: root.mpvqcApplication.mpvqcMpvPlayerPropertiesPyObject
43+
readonly property var mpvqcUtilityPyObject: root.mpvqcApplication.mpvqcUtilityPyObject
3544

36-
property alias formattingOptionsButton: _formattingOptionsButton
45+
function formatTime(time: int): string {
46+
if (mpvqcMpvPlayerPropertiesPyObject.duration >= 60 * 60) {
47+
return mpvqcUtilityPyObject.formatTimeToStringLong(time);
48+
} else {
49+
return mpvqcUtilityPyObject.formatTimeToStringShort(time);
50+
}
51+
}
3752

38-
height: _content.height
39-
visible: !mpvqcApplication.fullscreen
53+
function recalculateVideoTimeLabelWidth(): real {
54+
const items = [_content.determineTimeLabelText()];
55+
_content.videoTimeLabelWidth = mpvqcLabelWidthCalculator.calculateWidthFor(items, root); // qmllint disable
56+
}
57+
}
4058

41-
Column {
59+
MpvqcFooterContent {
4260
id: _content
43-
width: root.width
44-
spacing: 0
4561

46-
MenuSeparator {
47-
topPadding: 1
48-
bottomPadding: 1
49-
width: root.width
62+
anchors.fill: parent
63+
64+
isApplicationMazimized: root.mpvqcApplication.maximized
65+
66+
selectedCommentIndex: _impl.mpvqcCommentTable.selectedCommentIndex
67+
totalCommentCount: _impl.mpvqcCommentTable.commentCount
68+
69+
playerPercentPosition: _impl.mpvqcMpvPlayerPropertiesPyObject.percent_pos
70+
playerDuration: _impl.mpvqcMpvPlayerPropertiesPyObject.duration
71+
playerVideoLoaded: _impl.mpvqcMpvPlayerPropertiesPyObject.video_loaded
72+
playerTimePosition: _impl.mpvqcMpvPlayerPropertiesPyObject.time_pos
73+
playerTimeRemaining: _impl.mpvqcMpvPlayerPropertiesPyObject.time_remaining
74+
75+
isStatusbarDisplayPercentage: _impl.mpvqcSettings.statusbarPercentage
76+
77+
isTimeFormatCurrentTotalTime: _impl.mpvqcSettings.timeFormat === MpvqcSettings.TimeFormat.CURRENT_TOTAL_TIME
78+
isTimeFormatCurrentTime: _impl.mpvqcSettings.timeFormat === MpvqcSettings.TimeFormat.CURRENT_TIME
79+
isTimeFormatRemainingTime: _impl.mpvqcSettings.timeFormat === MpvqcSettings.TimeFormat.REMAINING_TIME
80+
isTimeFormatEmpty: _impl.mpvqcSettings.timeFormat === MpvqcSettings.TimeFormat.EMPTY
81+
82+
formatTimeFunc: _impl.formatTime
83+
84+
videoTimeLabelWidth: 0
85+
86+
onCurrentTotalTimeSelected: {
87+
_impl.mpvqcSettings.timeFormat = MpvqcSettings.TimeFormat.CURRENT_TOTAL_TIME;
5088
}
5189

52-
RowLayout {
53-
width: _content.width
90+
onCurrentTimeSelected: {
91+
_impl.mpvqcSettings.timeFormat = MpvqcSettings.TimeFormat.CURRENT_TIME;
92+
}
5493

55-
MpvqcRowSelectionLabel {
56-
mpvqcApplication: root.mpvqcApplication
57-
Layout.bottomMargin: root.customBottomMargin
58-
Layout.leftMargin: root.customLeftMargin
59-
}
94+
onRemainingTimeSelected: {
95+
_impl.mpvqcSettings.timeFormat = MpvqcSettings.TimeFormat.REMAINING_TIME;
96+
}
6097

61-
Item {
62-
Layout.fillWidth: true
63-
}
98+
onEmptyTimeSelected: {
99+
_impl.mpvqcSettings.timeFormat = MpvqcSettings.TimeFormat.EMPTY;
100+
}
64101

65-
MpvqcVideoPercentLabel {
66-
mpvqcApplication: root.mpvqcApplication
67-
horizontalAlignment: Text.AlignRight
68-
Layout.bottomMargin: root.customBottomMargin
69-
}
102+
onStatusBarPercentageToggled: {
103+
_impl.mpvqcSettings.statusbarPercentage = !_impl.mpvqcSettings.statusbarPercentage;
104+
}
105+
}
70106

71-
MpvqcVideoTimeLabel {
72-
mpvqcApplication: root.mpvqcApplication
73-
horizontalAlignment: Text.AlignRight
74-
Layout.preferredWidth: width
75-
Layout.bottomMargin: root.customBottomMargin
76-
Layout.leftMargin: 12
77-
}
107+
Connections {
108+
target: _impl.mpvqcSettings
78109

79-
Item {
80-
Layout.minimumHeight: 25
81-
Layout.minimumWidth: 25
82-
Layout.bottomMargin: root.customBottomMargin
83-
84-
ToolButton {
85-
id: _formattingOptionsButton
86-
87-
property var menu: MpvqcFooterSettingsMenu {
88-
mpvqcApplication: root.mpvqcApplication
89-
y: -height // qmllint disable unqualified
90-
transformOrigin: _formattingOptionsButton.mirrored && !root.horizontalLayout ? Popup.BottomLeft : Popup.BottomRight
91-
}
92-
93-
icon.source: "qrc:/data/icons/expand_more_black_24dp.svg"
94-
focusPolicy: Qt.NoFocus
95-
height: parent.height
96-
width: parent.width + 1
97-
padding: 3
98-
99-
onPressed: {
100-
menu.open();
101-
}
102-
}
103-
}
110+
function onTimeFormatChanged() {
111+
_impl.recalculateVideoTimeLabelWidth();
112+
}
113+
}
114+
115+
Connections {
116+
target: _impl.mpvqcMpvPlayerPropertiesPyObject
117+
118+
function onDurationChanged() {
119+
_impl.recalculateVideoTimeLabelWidth();
104120
}
105121
}
106122
}

0 commit comments

Comments
 (0)