[vlc-commits] [Git][videolan/vlc][master] qml/ResumeDialog: wrap text and buttons
Steve Lhomme (@robUx4)
gitlab at videolan.org
Mon Jan 30 06:46:14 UTC 2023
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
6a742c90 by Yann Lochet at 2023-01-30T06:29:59+00:00
qml/ResumeDialog: wrap text and buttons
- - - - -
2 changed files:
- modules/gui/qt/player/qml/ResumeDialog.qml
- modules/gui/qt/player/qml/TopBar.qml
Changes:
=====================================
modules/gui/qt/player/qml/ResumeDialog.qml
=====================================
@@ -31,9 +31,10 @@ FocusScope {
id: resumePanel
property VLCColors colors: VLCStyle.colors
+ property int maxWidth
- implicitWidth: layout.implicitWidth
- implicitHeight: layout.implicitHeight
+ implicitHeight: continueBtn.y + continueBtn.implicitHeight
+ implicitWidth: maxWidth
visible: false
@@ -83,60 +84,101 @@ FocusScope {
hideResumePanel()
}
- RowLayout {
- id: layout
+ TextMetrics {
+ id: textMetrics
- anchors.fill: parent
+ font: label.font
+ text: label.text
+ }
+
+ //FIXME use the right xxxLabel class
+ Label {
+ id: label
- spacing: VLCStyle.margin_small
+ anchors.topMargin: VLCStyle.margin_small
+ anchors.top: parent.top
+ anchors.left: parent.left
- //FIXME use the right xxxLabel class
- T.Label {
- Layout.preferredHeight: implicitHeight
- Layout.preferredWidth: implicitWidth
- Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter
+ color: resumePanel.colors.playerFg
+ font.pixelSize: VLCStyle.fontSize_normal
+ font.bold: true
+ wrapMode: Text.Wrap
+
+ text: I18n.qtr("Do you want to restart the playback where you left off?")
+ }
+ Widgets.ButtonExt {
+ id: continueBtn
- color: resumePanel.colors.playerFg
- font.pixelSize: VLCStyle.fontSize_normal
- font.bold: true
+ anchors.verticalCenter: label.verticalCenter
+ anchors.left: label.right
+ anchors.leftMargin: VLCStyle.margin_xsmall
- text: I18n.qtr("Do you want to restart the playback where you left off?")
+ text: I18n.qtr("Continue")
+ font.bold: true
+ color: resumePanel.colors.playerFg
+ focus: true
+ onClicked: {
+ Player.restorePlaybackPos()
+ hideResumePanel()
}
- Widgets.ButtonExt {
- id: continueBtn
- Layout.preferredHeight: implicitHeight
- Layout.preferredWidth: implicitWidth
- text: I18n.qtr("Continue")
- font.bold: true
- color: resumePanel.colors.playerFg
- focus: true
- onClicked: {
- Player.restorePlaybackPos()
- hideResumePanel()
+ Navigation.parentItem: resumePanel
+ Navigation.rightItem: closeBtn
+ Keys.priority: Keys.AfterItem
+ Keys.onPressed: continueBtn.Navigation.defaultKeyAction(event)
+ }
+
+ Widgets.ButtonExt {
+ id: closeBtn
+
+ anchors.verticalCenter: label.verticalCenter
+ anchors.left: continueBtn.right
+
+ text: I18n.qtr("Dismiss")
+ font.bold: true
+ color: resumePanel.colors.playerFg
+ onClicked: hideResumePanel()
+
+ Navigation.parentItem: resumePanel
+ Navigation.leftItem: continueBtn
+ Keys.priority: Keys.AfterItem
+ Keys.onPressed: closeBtn.Navigation.defaultKeyAction(event)
+ }
+
+ states: [
+ State {
+ name: "small"
+
+ PropertyChanges {
+ target: label
+
+ width: resumePanel.maxWidth
}
- Navigation.parentItem: resumePanel
- Navigation.rightItem: closeBtn
- Keys.priority: Keys.AfterItem
- Keys.onPressed: continueBtn.Navigation.defaultKeyAction(event)
- }
+ PropertyChanges {
+ target: continueBtn
+
+ anchors.leftMargin: -VLCStyle.margin_xsmall
+ }
+
+ AnchorChanges {
+ target: continueBtn
+
+ anchors.top: label.bottom
+ anchors.verticalCenter: undefined
+ anchors.left: parent.left
+ }
+
+ AnchorChanges {
+ target: closeBtn
- Widgets.ButtonExt {
- id: closeBtn
- Layout.preferredHeight: implicitHeight
- Layout.preferredWidth: implicitWidth
- text: I18n.qtr("Dismiss")
- font.bold: true
- color: resumePanel.colors.playerFg
- onClicked: hideResumePanel()
-
- Navigation.parentItem: resumePanel
- Navigation.leftItem: continueBtn
- Keys.priority: Keys.AfterItem
- Keys.onPressed: closeBtn.Navigation.defaultKeyAction(event)
+ anchors.top: label.bottom
+ anchors.verticalCenter: undefined
+ }
}
- }
-}
+ ]
+ state: (textMetrics.width + VLCStyle.margin_xsmall + continueBtn.width + closeBtn.width
+ > maxWidth) ? "small" : ""
+}
=====================================
modules/gui/qt/player/qml/TopBar.qml
=====================================
@@ -61,7 +61,16 @@ FocusScope{
function _layoutLine(c1, c2, offset)
{
- var lineHeight = Math.max(c1 !== undefined ? c1.implicitHeight : 0, c2 !== undefined ? c2.implicitHeight : 0)
+ var c1Height = c1 !== undefined ? c1.implicitHeight : 0
+ var c2Height = c2 !== undefined ? c2.implicitHeight : 0
+
+ if (c2 === csdDecorations) {
+ //csdDecorations.implicitHeight gets overwritten when the height is set,
+ //VLCStyle.icon_normal is its initial value
+ c2Height = VLCStyle.icon_normal
+ }
+
+ var lineHeight = Math.max(c1Height, c2Height)
if (c1) {
c1.height = lineHeight
@@ -82,7 +91,9 @@ FocusScope{
if (root.pinControls && !root.showToolbar && root.showCSD) {
//place everything on one line
- var lineHeight = Math.max(logoOrResume.implicitHeight, playlistGroup.implicitHeight, csdDecorations.implicitHeight)
+ //csdDecorations.implicitHeight gets overwritten when the height is set,
+ //VLCStyle.icon_normal is its initial value
+ var lineHeight = Math.max(logoOrResume.implicitHeight, playlistGroup.implicitHeight, VLCStyle.icon_normal)
centerTitleText.y = 0
centerTitleText.height = lineHeight
@@ -196,6 +207,8 @@ FocusScope{
implicitHeight: resumeDialog.visible ? resumeDialog.implicitHeight
: logoGroup.implicitHeight
+ onImplicitHeightChanged: root._layout()
+
Item {
id: logoGroup
@@ -252,6 +265,9 @@ FocusScope{
anchors.leftMargin: VLCStyle.margin_xsmall
colors: root.colors
+ maxWidth: ((root.showCSD && !root.pinControls) ? csdDecorations : playlistGroup).x
+ - VLCStyle.applicationHorizontalMargin
+ - VLCStyle.margin_large
Navigation.parentItem: rootPlayer
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/6a742c904046e216d6190740b385cf980f0eff41
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/6a742c904046e216d6190740b385cf980f0eff41
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list