[vlc-commits] [Git][videolan/vlc][master] 6 commits: qt: implement UINotifier
Felix Paul Kühne (@fkuehne)
gitlab at videolan.org
Sun Feb 16 11:23:17 UTC 2025
Felix Paul Kühne pushed to branch master at VideoLAN / VLC
Commits:
d6c65af2 by Prince Gupta at 2025-02-16T11:09:38+00:00
qt: implement UINotifier
- - - - -
17c4eee8 by Prince Gupta at 2025-02-16T11:09:38+00:00
qt: add UINotifier to qml system
- - - - -
429bb821 by Prince Gupta at 2025-02-16T11:09:38+00:00
qml: implement FloatingNotification widget
- - - - -
730c48f9 by Prince Gupta at 2025-02-16T11:09:38+00:00
qml: add FloatingNotifcation to MainInterface
- - - - -
ee628f42 by Prince Gupta at 2025-02-16T11:09:38+00:00
qml: add FloatingNotification to Player
- - - - -
4f3aac42 by Prince Gupta at 2025-02-16T11:09:38+00:00
qml: add FloatingNotification to MinimalView
- - - - -
10 changed files:
- modules/gui/qt/Makefile.am
- modules/gui/qt/maininterface/mainui.cpp
- modules/gui/qt/maininterface/qml/MainDisplay.qml
- modules/gui/qt/meson.build
- modules/gui/qt/player/qml/MinimalView.qml
- modules/gui/qt/player/qml/Player.qml
- + modules/gui/qt/util/ui_notifier.cpp
- + modules/gui/qt/util/ui_notifier.hpp
- + modules/gui/qt/widgets/qml/FloatingNotification.qml
- po/POTFILES.in
Changes:
=====================================
modules/gui/qt/Makefile.am
=====================================
@@ -286,6 +286,7 @@ libqt_plugin_la_SOURCES = \
util/workerthreadset.hpp util/workerthreadset.cpp \
util/base_model.hpp util/base_model_p.hpp util/base_model.cpp \
util/color_scheme_model.cpp util/color_scheme_model.hpp \
+ util/ui_notifier.cpp util/ui_notifier.hpp \
util/color_svg_image_provider.cpp util/color_svg_image_provider.hpp \
util/vlcaccess_image_provider.cpp util/vlcaccess_image_provider.hpp \
util/covergenerator.cpp \
@@ -469,6 +470,7 @@ nodist_libqt_plugin_la_SOURCES = \
util/workerthreadset.moc.cpp \
util/base_model.moc.cpp \
util/color_scheme_model.moc.cpp \
+ util/ui_notifier.moc.cpp \
util/color_svg_image_provider.moc.cpp \
util/vlcaccess_image_provider.moc.cpp \
util/imageluminanceextractor.moc.cpp \
@@ -1222,6 +1224,7 @@ libqml_module_widgets_a_QML = \
widgets/qml/CheckedDelegate.qml \
widgets/qml/ComboBoxExt.qml \
widgets/qml/AcrylicBackground.qml \
+ widgets/qml/FloatingNotification.qml \
widgets/qml/AnimatedBackground.qml \
widgets/qml/CSDThemeButton.qml \
widgets/qml/CSDThemeButtonSet.qml \
=====================================
modules/gui/qt/maininterface/mainui.cpp
=====================================
@@ -46,6 +46,7 @@
#include "util/csdbuttonmodel.hpp"
#include "util/vlctick.hpp"
#include "util/list_selection_model.hpp"
+#include "util/ui_notifier.hpp"
#include "dialogs/help/aboutmodel.hpp"
#include "dialogs/dialogs_provider.hpp"
@@ -171,6 +172,8 @@ void MainUI::registerQMLTypes()
qmlRegisterSingletonInstance<MainCtx>(uri, versionMajor, versionMinor, "MainCtx", m_mainCtx);
qmlRegisterUncreatableType<SearchCtx>(uri, versionMajor, versionMinor, "SearchCtx", "");
qmlRegisterUncreatableType<SortCtx>(uri, versionMajor, versionMinor, "SortCtx", "");
+ qmlRegisterUncreatableType<UINotifier>(uri, versionMajor, versionMinor, "UINotifier", "");
+ qmlRegisterSingletonInstance<UINotifier>(uri, versionMajor, versionMinor, "UINotifier", new UINotifier(m_mainCtx, m_mainCtx));
qmlRegisterSingletonInstance<NavigationHistory>(uri, versionMajor, versionMinor, "History", new NavigationHistory(this));
qmlRegisterUncreatableType<QAbstractItemModel>(uri, versionMajor, versionMinor, "QtAbstractItemModel", "");
qmlRegisterUncreatableType<QWindow>(uri, versionMajor, versionMinor, "QtWindow", "");
=====================================
modules/gui/qt/maininterface/qml/MainDisplay.qml
=====================================
@@ -530,6 +530,17 @@ FocusScope {
}
}
+ Widgets.FloatingNotification {
+ id: notif
+
+ anchors {
+ bottom: miniPlayer.top
+ left: parent.left
+ right: parent.right
+ margins: VLCStyle.margin_large
+ }
+ }
+
MiniPlayer {
id: miniPlayer
=====================================
modules/gui/qt/meson.build
=====================================
@@ -124,6 +124,7 @@ moc_headers = files(
'util/workerthreadset.hpp',
'util/base_model.hpp',
'util/color_scheme_model.hpp',
+ 'util/ui_notifier.hpp',
'util/color_svg_image_provider.hpp',
'util/vlcaccess_image_provider.hpp',
'util/csdbuttonmodel.hpp',
@@ -419,6 +420,8 @@ qt_plugin_sources = files(
'util/base_model_p.hpp',
'util/color_scheme_model.cpp',
'util/color_scheme_model.hpp',
+ 'util/ui_notifier.cpp',
+ 'util/ui_notifier.hpp',
'util/color_svg_image_provider.cpp',
'util/color_svg_image_provider.hpp',
'util/vlcaccess_image_provider.cpp',
@@ -825,6 +828,7 @@ qml_modules += {
'widgets/qml/CheckedDelegate.qml',
'widgets/qml/ComboBoxExt.qml',
'widgets/qml/AcrylicBackground.qml',
+ 'widgets/qml/FloatingNotification.qml',
'widgets/qml/AnimatedBackground.qml',
'widgets/qml/CSDThemeButton.qml',
'widgets/qml/CSDThemeButtonSet.qml',
=====================================
modules/gui/qt/player/qml/MinimalView.qml
=====================================
@@ -156,6 +156,15 @@ FocusScope {
}
}
+ Widgets.FloatingNotification {
+ anchors {
+ bottom: parent.bottom
+ left: parent.left
+ right: parent.right
+ margins: VLCStyle.margin_large
+ }
+ }
+
Keys.onPressed: (event) => {
if (event.accepted)
return
=====================================
modules/gui/qt/player/qml/Player.qml
=====================================
@@ -821,6 +821,17 @@ FocusScope {
}
}
+ Widgets.FloatingNotification {
+ id: notif
+
+ anchors {
+ bottom: controlBar.top
+ left: parent.left
+ right: parent.right
+ margins: VLCStyle.margin_large
+ }
+ }
+
ControlBar {
id: controlBar
=====================================
modules/gui/qt/util/ui_notifier.cpp
=====================================
@@ -0,0 +1,45 @@
+/*****************************************************************************
+ * Copyright (C) 2025 the VideoLAN team
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#include "ui_notifier.hpp"
+
+#include "maininterface/mainctx.hpp"
+
+UINotifier::UINotifier(MainCtx *ctx, QObject *parent)
+ : QObject {parent}
+ , m_ctx {ctx}
+{
+ setupNotifications();
+}
+
+void UINotifier::setupNotifications()
+{
+ connect(m_ctx, &MainCtx::intfScaleFactorChanged, this, [this]()
+ {
+ const QString scale = QString::number(m_ctx->getIntfScaleFactor() * 100);
+ emit showNotification(Scale
+ , qtr("Scale: %1%").arg(scale));
+ });
+
+ connect(m_ctx, &MainCtx::minimalViewChanged, this, [this]()
+ {
+ if (m_ctx->isMinimalView())
+ emit showNotification(MinimalView
+ , qtr("Minimal View"));
+ });
+}
=====================================
modules/gui/qt/util/ui_notifier.hpp
=====================================
@@ -0,0 +1,49 @@
+/*****************************************************************************
+ * Copyright (C) 2025 the VideoLAN team
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#ifndef UI_NOTIFIER_HPP
+#define UI_NOTIFIER_HPP
+
+#include <QObject>
+
+class MainCtx;
+
+class UINotifier : public QObject
+{
+ Q_OBJECT
+public:
+ UINotifier(MainCtx *ctx, QObject *parent = nullptr);
+
+ enum ID
+ {
+ Scale,
+ MinimalView
+ };
+
+ Q_ENUM(ID)
+
+signals:
+ void showNotification(ID id, const QString &text);
+
+private:
+ void setupNotifications();
+
+ MainCtx *m_ctx;
+};
+
+#endif // UI_NOTIFIER_HPP
=====================================
modules/gui/qt/widgets/qml/FloatingNotification.qml
=====================================
@@ -0,0 +1,200 @@
+/*****************************************************************************
+ * Copyright (C) 2025 VLC authors and VideoLAN
+ *
+ * Authors: Prince Gupta <guptaprince8832 at gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * ( at your option ) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+import QtQuick
+
+import VLC.MainInterface
+import VLC.Style
+
+Column {
+ id: root
+
+ signal removeNotification(int index)
+
+ onRemoveNotification: function (index) {
+ model.remove(index, 1)
+ }
+
+ spacing: VLCStyle.margin_normal
+
+ Behavior on y {
+ NumberAnimation {
+ duration: VLCStyle.duration_short
+ easing.type: Easing.InOutQuad
+ }
+ }
+
+ Repeater {
+ id: repeater
+
+ model: ListModel {
+ id: model
+ }
+
+ delegate: Rectangle {
+ id: delegate
+
+ required property int index
+ required property string text
+
+ readonly property ColorContext colorContext: ColorContext {
+ id: theme
+
+ colorSet: ColorContext.Window
+ }
+
+ function resetLifetime() {
+ lifetime.restart()
+ state = "VISIBLE"
+ }
+
+ anchors.horizontalCenter: parent.horizontalCenter
+
+ color: theme.bg.primary
+
+ focus: false
+
+ width: notifText.implicitWidth
+ height: notifText.implicitHeight
+
+ radius: VLCStyle.dp(3, VLCStyle.scale)
+
+ scale: 0
+
+ state: "HIDDEN"
+
+ Component.onCompleted: state = "VISIBLE"
+
+ states: [
+ State {
+ name: "VISIBLE"
+ PropertyChanges {
+ target: delegate
+ visible: true
+ scale: 1
+ }
+ },
+ State {
+ name: "HIDDEN"
+ PropertyChanges {
+ target: delegate
+ visible: false
+ scale: 0
+ }
+ }
+ ]
+
+ transitions: [
+ Transition {
+ from: "VISIBLE"
+ to: "HIDDEN"
+
+ SequentialAnimation {
+ NumberAnimation {
+ target: delegate
+ property: "scale"
+ duration: VLCStyle.duration_short
+ easing.type: Easing.InOutQuad
+ }
+
+ PropertyAction {
+ target: delegate
+ property: "visible"
+ }
+
+ ScriptAction {
+ script: if (!lifetime.running) root.removeNotification(delegate.index)
+ }
+ }
+ },
+
+ Transition {
+ from: "HIDDEN"
+ to: "VISIBLE"
+
+ SequentialAnimation {
+ PropertyAction {
+ target: delegate
+ property: "visible"
+ }
+
+ NumberAnimation {
+ target: delegate
+ property: "scale"
+ duration: VLCStyle.duration_short
+ easing.type: Easing.InOutQuad
+ }
+ }
+ }
+ ]
+
+ Timer {
+ id: lifetime
+
+ interval: VLCStyle.duration_humanMoment
+
+ running: true
+
+ onTriggered: delegate.state = "HIDDEN"
+ }
+
+ DefaultShadow {
+ anchors.centerIn: parent
+
+ sourceItem: parent
+ }
+
+ SubtitleLabel {
+ id: notifText
+
+ padding: VLCStyle.margin_small
+
+ color: theme.fg.primary
+
+ text: delegate.text
+ }
+ }
+ }
+
+ Connections {
+ target: UINotifier
+
+ function onShowNotification(id, text) {
+ let found = false
+ for (let i = 0; i < model.count; ++i) {
+ if (model.get(i).id === id) {
+ found = true
+
+ const del = repeater.itemAt(i)
+ if (del.text !== text) {
+ del.text = text
+ del.resetLifetime()
+ }
+
+ break
+ }
+ }
+
+ if (!found) {
+ model.append({"id": id, "text": text})
+ }
+ }
+ }
+}
=====================================
po/POTFILES.in
=====================================
@@ -889,6 +889,7 @@ modules/gui/qt/util/qt_dirs.hpp
modules/gui/qt/util/registry.cpp
modules/gui/qt/util/registry.hpp
modules/gui/qt/util/singleton.hpp
+modules/gui/qt/util/ui_notifier.cpp
modules/gui/qt/util/validators.cpp
modules/gui/qt/util/validators.hpp
modules/gui/qt/util/vlctick.cpp
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/906aa9940a4a5c27764cb1ac11f07b74a775a6ca...4f3aac42bcdf0da26cbbb21207a608bf205592df
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/906aa9940a4a5c27764cb1ac11f07b74a775a6ca...4f3aac42bcdf0da26cbbb21207a608bf205592df
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