11/*
22mpvQC
33
4- Copyright (C) 2022 mpvQC developers
4+ Copyright (C) 2024 mpvQC developers
55
66This program is free software: you can redistribute it and/or modify
77it 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
2020import QtQuick
21- import QtQuick.Controls
22- import QtQuick.Layouts
21+
22+ import "../settings"
2323
2424Item {
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