Debian Codegraph @

src/qml/MenuBarLoader.qml

raw
1 /*
2 * SPDX-FileCopyrightText: 2023 George Florea Bănuș <[email protected]>
3 *
4 * SPDX-License-Identifier: GPL-3.0-or-later
5 */
6
7 pragma ComponentBehavior: Bound
8
9 import QtQuick
10 import QtQuick.Controls as QQC2
11 import Qt.labs.platform as Platform
12
13 import org.kde.kirigami as Kirigami
14
15 import org.kde.haruna
16 import org.kde.haruna.utilities
17 import org.kde.haruna.settings
18
19 Loader {
20 id: root
21
22 required property MpvVideo m_mpv
23 required property RecentFilesModel m_recentFilesModel
24 required property Loader m_settingsLoader
25
26 property bool isShowAnimationRunning: false
27 property bool showGlobalMenu: SystemUtils.platformName() !== "windows"
28 && Kirigami.Settings.hasPlatformMenuBar
29 && !Kirigami.Settings.isMobile
30
31 clip: true
32 asynchronous: !GeneralSettings.showMenuBar
33 state: {
34 const mainWindow = Window.window as Main
35 if (!mainWindow.isFullScreen() && GeneralSettings.showMenuBar) {
36 return "visible"
37 } else {
38 return "hidden"
39 }
40 }
41 sourceComponent: showGlobalMenu ? globalMenuBarComponent : menuBarComponent
42
43 onVisibleChanged: {
44 const mainWindow = Window.window as Main
45 mainWindow.resizeWindow()
46 }
47
48 Component {
49 id: menuBarComponent
50
51 QQC2.MenuBar {
52 hoverEnabled: true
53 Kirigami.Theme.colorSet: Kirigami.Theme.Header
54
55 FileMenu {
56 m_recentFilesModel: root.m_recentFilesModel
57 }
58 ViewMenu {}
59 PlaybackMenu {}
60 VideoMenu {}
61 SubtitlesMenu {
62 m_mpv: root.m_mpv
63 }
64 AudioMenu {
65 m_mpv: root.m_mpv
66 }
67 SettingsMenu {
68 m_settingsLoader: root.m_settingsLoader
69 }
70 HelpMenu {}
71 }
72 }
73
74 Component {
75 id: globalMenuBarComponent
76
77 Platform.MenuBar {
78 GlobalFileMenu {
79 m_recentFilesModel: root.m_recentFilesModel
80 }
81 GlobalViewMenu {}
82 GlobalPlaybackMenu {}
83 GlobalVideoMenu {}
84 GlobalSubtitlesMenu {
85 m_mpv: root.m_mpv
86 }
87 GlobalAudioMenu {
88 m_mpv: root.m_mpv
89 }
90 GlobalSettingsMenu {
91 m_settingsLoader: root.m_settingsLoader
92 }
93 GlobalHelpMenu {}
94 }
95 }
96
97 states: [
98 State {
99 name: "hidden"
100 PropertyChanges {
101 root.height: 0
102 root.visible: false
103 }
104 },
105 State {
106 name : "visible"
107 PropertyChanges {
108 root.height: root.implicitHeight
109 root.visible: true
110 }
111 }
112 ]
113
114 transitions: [
115 Transition {
116 from: "visible"
117 to: "hidden"
118
119 SequentialAnimation {
120 NumberAnimation {
121 target: root
122 property: "height"
123 duration: Kirigami.Units.shortDuration
124 easing.type: Easing.Linear
125 }
126 PropertyAction {
127 target: root
128 property: "visible"
129 value: false
130 }
131 }
132 },
133 Transition {
134 from: "hidden"
135 to: "visible"
136
137 SequentialAnimation {
138 PropertyAction {
139 target: root
140 property: "isShowAnimationRunning"
141 value: true
142 }
143 PropertyAction {
144 target: root
145 property: "visible"
146 value: true
147 }
148 NumberAnimation {
149 target: root
150 property: "height"
151 duration: Kirigami.Units.shortDuration
152 easing.type: Easing.Linear
153 }
154 PropertyAction {
155 target: root
156 property: "isShowAnimationRunning"
157 value: false
158 }
159 }
160 }
161 ]
162 }