Skip to content

Commit 40c3f2c

Browse files
authored
Implement file info display in Viewer (#2768)
1 parent f61dbe7 commit 40c3f2c

27 files changed

+1072
-54
lines changed

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,8 @@ endif ()
185185

186186
if (PAG_USE_QT)
187187
# need to set the CMAKE_PREFIX_PATH to local QT installation path, for example :
188-
# set(CMAKE_PREFIX_PATH /Users/username/Qt5.13.0/5.13.0/clang_64/lib/cmake)
189-
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core)
188+
# set(CMAKE_PREFIX_PATH /Users/username/Qt6.2.0/Qt6.2.0/clang_64/lib/cmake)
189+
find_package(QT NAMES Qt6 REQUIRED COMPONENTS Core)
190190
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets OpenGL Quick)
191191
list(APPEND PAG_SHARED_LIBS Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::OpenGL
192192
Qt${QT_VERSION_MAJOR}::Quick)

ohos/libpag/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ versions, you can download the precompiled libraries from [here](https://github.
104104
- NodeJS 14.14.0+
105105
- Ninja 1.9.0+
106106
- CMake 3.13.0+
107-
- QT 5.13.0+
107+
- QT 6.2.0+
108108
- Emscripten 3.1.58+
109109

110110
### Dependency Management

viewer/qml/Main.qml

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ PAGWindow {
2828

2929
property int windowTitleBarHeight: isWindows ? 32 : 22
3030

31+
property int minWindowHeightWithEditPanel: 650
32+
3133
Settings {
3234
id: settings
3335
property bool isEditPanelOpen: false
@@ -67,6 +69,9 @@ PAGWindow {
6769
let preferredSize = pagView.preferredSize;
6870
let width = Math.max(viewWindow.minimumWidth, preferredSize.width);
6971
let height = Math.max(viewWindow.minimumHeight, preferredSize.height);
72+
if (settings.isEditPanelOpen) {
73+
width += mainForm.rightItem.width + mainForm.splitHandleWidth;
74+
}
7075
let x = Math.max(0, oldX - ((width - oldWidth) / 2));
7176
let y = Math.max(50, oldY - ((height - oldHeight) / 2));
7277
settings.lastX = x;
@@ -289,9 +294,7 @@ PAGWindow {
289294
}
290295

291296
function updateProgress() {
292-
let duration = mainForm.pagView.duration;
293-
let displayedTime = duration * mainForm.pagView.progress;
294-
mainForm.controlForm.timeDisplayedText.text = Utils.msToTime(displayedTime);
297+
mainForm.controlForm.timeDisplayedText.text = mainForm.pagView.displayedTime;
295298
mainForm.controlForm.currentFrameText.text = mainForm.pagView.currentFrame;
296299
mainForm.controlForm.totalFrameText.text = mainForm.pagView.totalFrame;
297300
}
@@ -312,7 +315,31 @@ PAGWindow {
312315
if (mainForm.controlForm.panelsButton.checked !== willOpen) {
313316
mainForm.controlForm.panelsButton.checked = willOpen;
314317
}
318+
319+
if (willOpen) {
320+
let widthChange = (mainForm.rightItem.width === 0) ? mainForm.minPanelWidth : mainForm.rightItem.width;
321+
widthChange += mainForm.splitHandleWidth;
322+
if (viewWindow.visibility === Window.FullScreen) {
323+
mainForm.centerItem.width = viewWindow.width - widthChange;
324+
} else {
325+
viewWindow.width = viewWindow.width + widthChange;
326+
}
327+
mainForm.rightItem.width = widthChange;
328+
if (viewWindow.height < minWindowHeightWithEditPanel) {
329+
viewWindow.height = minWindowHeightWithEditPanel;
330+
}
331+
} else {
332+
let widthChange = -1 * mainForm.rightItem.width;
333+
if ((viewWindow.width + widthChange) < viewWindow.minimumWidth) {
334+
viewWindow.width = viewWindow.minimumWidth;
335+
} else {
336+
viewWindow.width = viewWindow.width + widthChange;
337+
}
338+
mainForm.rightItem.width = 0;
339+
}
340+
315341
settings.isEditPanelOpen = willOpen;
342+
mainForm.isEditPanelOpen = willOpen;
316343
}
317344

318345
function onCommand(command) {
@@ -325,14 +352,17 @@ PAGWindow {
325352
} else {
326353
openFileDialog.currentFolder = StandardPaths.writableLocation(StandardPaths.DocumentsLocation);
327354
}
328-
openFileDialog.accepted.disconnect();
355+
if (openFileDialog.currentAcceptHandler) {
356+
openFileDialog.accepted.disconnect(openFileDialog.currentAcceptHandler);
357+
}
329358
openFileDialog.fileMode = FileDialog.OpenFile;
330359
openFileDialog.title = qsTr("Open PAG File");
331360
openFileDialog.nameFilters = ["PAG files(*.pag)"];
332-
openFileDialog.accepted.connect(function () {
361+
openFileDialog.currentAcceptHandler = function () {
333362
let filePath = openFileDialog.selectedFile;
334363
mainForm.pagView.setFile(filePath);
335-
});
364+
};
365+
openFileDialog.accepted.connect(openFileDialog.currentAcceptHandler);
336366
openFileDialog.open();
337367
break;
338368
case "close-window":

viewer/qml/MainForm.qml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ SplitView {
1414

1515
property int minPlayerWidth: 360
1616

17+
property int minPanelWidth: 300
18+
1719
property int splitHandleWidth: 0
1820

1921
property int splitHandleHeight: 0
@@ -26,6 +28,8 @@ SplitView {
2628

2729
property alias centerItem: centerItem
2830

31+
property alias rightItem: rightItem
32+
2933
property alias controlForm: controlForm
3034
anchors.fill: parent
3135
orientation: Qt.Horizontal
@@ -112,4 +116,39 @@ SplitView {
112116
}
113117
}
114118
}
119+
120+
PAGRectangle {
121+
id: rightItem
122+
visible: isEditPanelOpen
123+
SplitView.minimumWidth: minPanelWidth
124+
SplitView.preferredWidth: minPanelWidth
125+
color: "#16161d"
126+
radius: 5
127+
leftTopRadius: false
128+
rightTopRadius: false
129+
rightBottomRadius: false
130+
131+
PAGRectangle {
132+
id: performance
133+
color: "#16161D"
134+
clip: true
135+
anchors.top: parent.top
136+
anchors.topMargin: 0
137+
anchors.right: parent.right
138+
anchors.rightMargin: 0
139+
anchors.left: parent.left
140+
anchors.leftMargin: 0
141+
anchors.bottom: parent.bottom
142+
anchors.bottomMargin: 0
143+
radius: 5
144+
leftTopRadius: false
145+
rightTopRadius: false
146+
leftBottomRadius: false
147+
148+
Profiler {
149+
id: profilerForm
150+
anchors.fill: parent
151+
}
152+
}
153+
}
115154
}

0 commit comments

Comments
 (0)