[vlc-commits] [Git][videolan/vlc][master] 5 commits: qt: add method to set attached tooltip instance in MainCtx
Hugo Beauzée-Luyssen (@chouquette)
gitlab at videolan.org
Fri May 6 09:30:54 UTC 2022
Hugo Beauzée-Luyssen pushed to branch master at VideoLAN / VLC
Commits:
06c57117 by Fatih Uzunoglu at 2022-05-06T07:57:51+00:00
qt: add method to set attached tooltip instance in MainCtx
- - - - -
f68a07cb by Fatih Uzunoglu at 2022-05-06T07:57:51+00:00
qml: add global attached tooltip instance to MainInterface
- - - - -
97302527 by Fatih Uzunoglu at 2022-05-06T07:57:51+00:00
qml: use attached tooltip in ArtworkInfoWidget
- - - - -
7533e914 by Fatih Uzunoglu at 2022-05-06T07:57:51+00:00
qml: use attached tooltip in IconToolButton
- - - - -
bee28a31 by Fatih Uzunoglu at 2022-05-06T07:57:51+00:00
qml: use attached tooltip in playlist
- - - - -
11 changed files:
- modules/gui/qt/dialogs/toolbar/qml/ToolbarEditorDialog.qml
- modules/gui/qt/maininterface/mainctx.cpp
- modules/gui/qt/maininterface/mainctx.hpp
- modules/gui/qt/maininterface/qml/MainInterface.qml
- modules/gui/qt/player/qml/LanguageMenu.qml
- modules/gui/qt/player/qml/controlbarcontrols/ArtworkInfoWidget.qml
- modules/gui/qt/player/qml/controlbarcontrols/TeletextWidget.qml
- modules/gui/qt/playlist/qml/PlaylistDelegate.qml
- modules/gui/qt/playlist/qml/PlaylistListView.qml
- modules/gui/qt/widgets/qml/IconControlButton.qml
- modules/gui/qt/widgets/qml/IconToolButton.qml
Changes:
=====================================
modules/gui/qt/dialogs/toolbar/qml/ToolbarEditorDialog.qml
=====================================
@@ -17,6 +17,7 @@
*****************************************************************************/
import QtQuick 2.11
import QtQuick.Controls 2.4
+import QtQuick.Templates 2.4 as T
import QtQuick.Layouts 1.11
import "qrc:///widgets/" as Widgets
@@ -143,7 +144,7 @@ WindowDialog {
MainCtx.controlbarProfileModel.selectedProfile = (MainCtx.controlbarProfileModel.rowCount() - 1)
}
- toolTip.visible: hovered
+ T.ToolTip.visible: hovered
}
Widgets.IconToolButton {
@@ -156,7 +157,7 @@ WindowDialog {
MainCtx.controlbarProfileModel.currentModel.injectDefaults(false)
}
- toolTip.visible: hovered
+ T.ToolTip.visible: hovered
}
Widgets.IconToolButton {
@@ -167,7 +168,7 @@ WindowDialog {
MainCtx.controlbarProfileModel.deleteSelectedProfile()
}
- toolTip.visible: hovered
+ T.ToolTip.visible: hovered
}
}
=====================================
modules/gui/qt/maininterface/mainctx.cpp
=====================================
@@ -53,6 +53,9 @@
#include <QDate>
#include <QMimeData>
+#include <QQmlProperty>
+#include <QQmlContext>
+
#include <QWindow>
#include <QScreen>
#ifdef _WIN32
@@ -863,3 +866,42 @@ void MainCtx::setSettingValue(const QString &key, const QVariant &value)
{
settings->setValue(key, value);
}
+
+void MainCtx::setAttachedToolTip(QObject *toolTip)
+{
+ // See QQuickToolTipAttachedPrivate::instance(bool create)
+ assert(toolTip);
+
+ // Prevent possible invalid down-casting:
+ assert(toolTip->inherits("QQuickToolTip"));
+
+ QQmlEngine* const engine = qmlEngine(toolTip);
+ assert(engine);
+ assert(engine->objectOwnership(toolTip) == QQmlEngine::ObjectOwnership::JavaScriptOwnership);
+
+ // Dynamic internal property:
+ static const char* const name = "_q_QQuickToolTip";
+
+ if (const auto obj = engine->property(name).value<QObject *>())
+ {
+ if (engine->objectOwnership(obj) == QQmlEngine::ObjectOwnership::CppOwnership)
+ obj->deleteLater();
+ }
+
+ // setProperty() will return false, so there is no
+ // need to check the return value:
+ engine->setProperty(name, QVariant::fromValue(toolTip));
+
+ // Check if the attached tooltip is actually the
+ // one that is set
+#ifndef NDEBUG
+ QQmlComponent component(engine);
+ component.setData(QByteArrayLiteral("import QtQuick 2.11; import QtQuick.Controls 2.4; Item { }"), {});
+ QObject* const obj = component.create();
+ assert(obj);
+ // Consider disabling setting of custom attached
+ // tooltip if the following assertion fails:
+ assert(QQmlProperty::read(obj, QStringLiteral("ToolTip.toolTip"), qmlContext(obj)).value<QObject*>() == toolTip);
+ obj->deleteLater();
+#endif
+}
=====================================
modules/gui/qt/maininterface/mainctx.hpp
=====================================
@@ -289,6 +289,8 @@ public:
Q_INVOKABLE QVariant settingValue(const QString &key, const QVariant &defaultValue) const;
Q_INVOKABLE void setSettingValue(const QString &key, const QVariant &value);
+ Q_INVOKABLE static void setAttachedToolTip(QObject* toolTip);
+
protected:
/* Systray */
void createSystray();
=====================================
modules/gui/qt/maininterface/qml/MainInterface.qml
=====================================
@@ -51,6 +51,19 @@ Item {
value: root.height
}
+ Widgets.ToolTipExt {
+ id: attachedToolTip
+
+ parent: null
+ z: 99
+ colors: parent && parent.colors ? parent.colors
+ : VLCStyle.colors
+
+ Component.onCompleted: {
+ MainCtx.setAttachedToolTip(this)
+ }
+ }
+
Loader {
id: playlistWindowLoader
asynchronous: true
=====================================
modules/gui/qt/player/qml/LanguageMenu.qml
=====================================
@@ -153,10 +153,9 @@ T.Popup {
highlighted: index === 3
&& Player.subtitleTracks.multiSelect
- toolTip.visible: (hovered || activeFocus)
- toolTip.text: modelData.tooltip
- toolTip.delay: 1000
- toolTip.z: 2
+ T.ToolTip.visible: (hovered || activeFocus)
+ T.ToolTip.text: modelData.tooltip
+ T.ToolTip.delay: 1000
Navigation.parentItem: btnsCol
=====================================
modules/gui/qt/player/qml/controlbarcontrols/ArtworkInfoWidget.qml
=====================================
@@ -106,18 +106,14 @@ AbstractButton {
mipmap: true
- Widgets.ToolTipExt {
- x: parent.x
-
- visible: artworkInfoItem.visible
- && infoColumn.width < infoColumn.implicitWidth
- && (artworkInfoItem.hovered || artworkInfoItem.visualFocus)
- delay: 500
-
- text: I18n.qtr("%1\n%2\n%3").arg(titleLabel.text).arg(artistLabel.text).arg(progressIndicator.text)
-
- colors: artworkInfoItem.colors
- }
+ ToolTip.visible: infoColumn.width < infoColumn.implicitWidth
+ && (artworkInfoItem.hovered || artworkInfoItem.visualFocus)
+ ToolTip.delay: VLCStyle.delayToolTipAppear
+ ToolTip.text: I18n.qtr("%1\n%2\n%3").arg(titleLabel.text)
+ .arg(artistLabel.text)
+ .arg(progressIndicator.text)
+
+ property alias colors: artworkInfoItem.colors
}
}
=====================================
modules/gui/qt/player/qml/controlbarcontrols/TeletextWidget.qml
=====================================
@@ -63,7 +63,7 @@ T.Pane {
colors: root.colors
color: colors.text
- toolTip.visible: hovered || visualFocus
+ T.ToolTip.visible: hovered || visualFocus
Navigation.parentItem: root
Navigation.rightItem: teleTransparencyBtn
@@ -88,7 +88,7 @@ T.Pane {
colors: root.colors
color: colors.text
- toolTip.visible: hovered || visualFocus
+ T.ToolTip.visible: hovered || visualFocus
Navigation.parentItem: root
Navigation.leftItem: teleActivateBtn
@@ -161,7 +161,7 @@ T.Pane {
color: "grey"
colorDisabled: "grey"
- toolTip.visible: hovered || visualFocus
+ T.ToolTip.visible: hovered || visualFocus
Navigation.parentItem: root
Navigation.leftItem: telePageNumber
@@ -186,7 +186,7 @@ T.Pane {
color: "red"
colorDisabled: "grey"
- toolTip.visible: hovered || visualFocus
+ T.ToolTip.visible: hovered || visualFocus
Navigation.parentItem: root
Navigation.leftItem: indexKeyBtn
@@ -211,7 +211,7 @@ T.Pane {
color: "green"
colorDisabled: "grey"
- toolTip.visible: hovered || visualFocus
+ T.ToolTip.visible: hovered || visualFocus
Navigation.parentItem: root
Navigation.leftItem: redKeyBtn
@@ -236,7 +236,7 @@ T.Pane {
color: "yellow"
colorDisabled: "grey"
- toolTip.visible: hovered || visualFocus
+ T.ToolTip.visible: hovered || visualFocus
Navigation.parentItem: root
Navigation.leftItem: greenKeyBtn
@@ -261,7 +261,7 @@ T.Pane {
color: "blue"
colorDisabled: "grey"
- toolTip.visible: hovered || visualFocus
+ T.ToolTip.visible: hovered || visualFocus
Navigation.parentItem: root
Navigation.leftItem: yellowKeyBtn
=====================================
modules/gui/qt/playlist/qml/PlaylistDelegate.qml
=====================================
@@ -43,6 +43,8 @@ T.Control {
readonly property bool containsDrag: (topContainsDrag || bottomContainsDrag)
+ readonly property VLCColors colors: root.colors
+
// Settings
topPadding: VLCStyle.margin_xxsmall
@@ -61,32 +63,19 @@ T.Control {
ListView.delayRemove: mouseArea.drag.active
- // Events
+ T.ToolTip.visible: ( (visualFocus || hovered) &&
+ !overlayMenu.shown && MainCtx.playlistVisible &&
+ (textInfoColumn.implicitWidth > textInfoColumn.width) )
- onHoveredChanged: {
- if (hovered)
- adjustTooltip()
- }
+ T.ToolTip.timeout: (hovered ? 0 : VLCStyle.ms2000)
- onVisualFocusChanged: {
- if (visualFocus)
- adjustTooltip()
- }
+ T.ToolTip.text: (textInfo.text + '\n' + textArtist.text)
- // Functions
+ T.ToolTip.delay: VLCStyle.delayToolTipAppear
- function adjustTooltip() {
- plInfoTooltip.close()
- plInfoTooltip.text = Qt.binding(function() { return (textInfo.text + '\n' + textArtist.text); })
- plInfoTooltip.parent = textInfoColumn
- if (hovered)
- plInfoTooltip.timeout = 0
- else
- plInfoTooltip.timeout = 2000
- plInfoTooltip.visible = Qt.binding(function() { return ( (visualFocus || hovered) && !mouseArea.drag.active &&
- !overlayMenu.shown && MainCtx.playlistVisible &&
- (textInfo.implicitWidth > textInfo.width || textArtist.implicitWidth > textArtist.width) ) })
- }
+ // Events
+
+ // Functions
// Childs
=====================================
modules/gui/qt/playlist/qml/PlaylistListView.qml
=====================================
@@ -392,13 +392,6 @@ Control {
}
}
- Widgets.ToolTipExt {
- id: plInfoTooltip
- delay: 750
-
- colors: root.colors
- }
-
Rectangle {
id: dropIndicator
=====================================
modules/gui/qt/widgets/qml/IconControlButton.qml
=====================================
@@ -34,6 +34,4 @@ IconToolButton {
: colors.blendColors(colors.playerBg, colors.playerControlBarFg, 0.75)
colorFocus: colors.bgFocus
-
- toolTip.colors: colors
}
=====================================
modules/gui/qt/widgets/qml/IconToolButton.qml
=====================================
@@ -50,7 +50,6 @@ T.ToolButton {
// Aliases
- property alias toolTip: toolTip
// active border color
property alias colorFocus: background.activeBorderColor
@@ -75,11 +74,8 @@ T.ToolButton {
// Childs
- Widgets.ToolTipExt {
- id: toolTip
- text: control.text
- delay: 500
- }
+ T.ToolTip.text: control.text
+ T.ToolTip.delay: VLCStyle.delayToolTipAppear
background: AnimatedBackground {
id: background
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/dc83b0a2b99f4c536d6a83e06cd1404102416959...bee28a3179100db7bc3473fcd5b2a78e7c18b436
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/dc83b0a2b99f4c536d6a83e06cd1404102416959...bee28a3179100db7bc3473fcd5b2a78e7c18b436
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