[vlc-commits] [Git][videolan/vlc][master] qt: make `AboutModel` a qml singleton and get rid of `aboutmodel.cpp`
Steve Lhomme (@robUx4)
gitlab at videolan.org
Wed Jun 24 09:59:48 UTC 2026
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
eee33158 by Fatih Uzunoglu at 2026-06-24T09:33:38+00:00
qt: make `AboutModel` a qml singleton and get rid of `aboutmodel.cpp`
Also makes the getters `static`, and makes the type available in
`VLC.MainInterface` module rather than `VLC.Dialogs`.
- - - - -
5 changed files:
- modules/gui/qt/Makefile.am
- − modules/gui/qt/dialogs/help/aboutmodel.cpp
- modules/gui/qt/dialogs/help/aboutmodel.hpp
- modules/gui/qt/maininterface/mainui.cpp
- modules/gui/qt/meson.build
Changes:
=====================================
modules/gui/qt/Makefile.am
=====================================
@@ -125,7 +125,6 @@ libqt_plugin_la_SOURCES = \
dialogs/fingerprint/fingerprintdialog.hpp \
dialogs/firstrun/firstrunwizard.cpp dialogs/firstrun/firstrunwizard.hpp \
dialogs/gototime/gototime.cpp dialogs/gototime/gototime.hpp \
- dialogs/help/aboutmodel.cpp \
dialogs/help/aboutmodel.hpp \
dialogs/help/help.cpp dialogs/help/help.hpp \
dialogs/mediainfo/info_panels.cpp dialogs/mediainfo/info_panels.hpp \
=====================================
modules/gui/qt/dialogs/help/aboutmodel.cpp deleted
=====================================
@@ -1,50 +0,0 @@
-/*****************************************************************************
- * Copyright (C) 2019 VLC authors and VideoLAN
- *
- * 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.
- *****************************************************************************/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include "aboutmodel.hpp"
-
-#include <vlc_about.h>
-
-
-AboutModel::AboutModel(QObject *parent) : QObject(parent)
-{
-}
-
-QString AboutModel::getLicense() const
-{
- return QString::fromUtf8(psz_license);
-}
-
-QString AboutModel::getAuthors() const
-{
- return QString::fromUtf8(psz_authors);
-}
-
-QString AboutModel::getThanks() const
-{
- return QString::fromUtf8(psz_thanks);
-}
-
-QString AboutModel::getVersion() const
-{
- return QString::fromUtf8(VERSION_MESSAGE);
-
-}
=====================================
modules/gui/qt/dialogs/help/aboutmodel.hpp
=====================================
@@ -19,6 +19,10 @@
#define ABOUTMODEL_HPP
#include <QObject>
+#include <QtQml>
+
+#include <vlc_about.h>
+#include "config.h"
class AboutModel : public QObject
{
@@ -28,13 +32,40 @@ class AboutModel : public QObject
Q_PROPERTY(QString authors READ getAuthors CONSTANT FINAL)
Q_PROPERTY(QString thanks READ getThanks CONSTANT FINAL)
Q_PROPERTY(QString version READ getVersion CONSTANT FINAL)
+
+ QML_ELEMENT
+ QML_UNCREATABLE("AboutModel is meant to be a singleton.")
+ QML_SINGLETON
+
public:
- explicit AboutModel(QObject *parent = nullptr);
+ explicit AboutModel(QObject *parent = nullptr)
+ : QObject(parent)
+ { }
+
+ static AboutModel *create(class QQmlEngine *, class QJSEngine *)
+ {
+ return new AboutModel;
+ }
+
+ static QString getLicense()
+ {
+ return QString::fromUtf8(psz_license);
+ }
+
+ static QString getAuthors()
+ {
+ return QString::fromUtf8(psz_authors);
+ }
+
+ static QString getThanks()
+ {
+ return QString::fromUtf8(psz_thanks);
+ }
- QString getLicense() const;
- QString getAuthors() const;
- QString getThanks() const;
- QString getVersion() const;
+ static QString getVersion()
+ {
+ return QString::fromUtf8(VERSION_MESSAGE);
+ }
};
#endif // ABOUTMODEL_HPP
=====================================
modules/gui/qt/maininterface/mainui.cpp
=====================================
@@ -237,6 +237,7 @@ void MainUI::registerQMLTypes()
qmlRegisterUncreatableType<CSDButtonModel>(uri, versionMajor, versionMinor, "CSDButtonModel", "has CSD buttons and provides for communicating CSD events between UI and backend");
qmlRegisterTypesAndRevisions<CSDMenu>( uri, versionMajor);
qmlRegisterUncreatableType<NavigationAttached>( uri, versionMajor, versionMinor, "Navigation", "Navigation is only available via attached properties");
+ qmlRegisterTypesAndRevisions<AboutModel>( uri, versionMajor );
#ifdef UPDATE_CHECK
qmlRegisterSingletonInstance<UpdateModel>( uri, versionMajor, versionMinor, "UpdateModel", m_mainCtx->getUpdateModel() );
#endif
@@ -251,7 +252,6 @@ void MainUI::registerQMLTypes()
const int versionMinor = 0;
// @uri VLC.Dialogs
- qmlRegisterType<AboutModel>( uri, versionMajor, versionMinor, "AboutModel" );
qmlRegisterType<VLCDialog>( uri, versionMajor, versionMinor, "VLCDialog" );
assert(VLCDialogModel::getInstance<false>());
qmlRegisterSingletonInstance<VLCDialogModel>(uri, versionMajor, versionMinor, "VLCDialogModel", VLCDialogModel::getInstance<false>());
=====================================
modules/gui/qt/meson.build
=====================================
@@ -232,7 +232,6 @@ qt_plugin_sources = files(
'dialogs/firstrun/firstrunwizard.hpp',
'dialogs/gototime/gototime.cpp',
'dialogs/gototime/gototime.hpp',
- 'dialogs/help/aboutmodel.cpp',
'dialogs/help/aboutmodel.hpp',
'dialogs/help/help.cpp',
'dialogs/help/help.hpp',
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/eee3315898eeb1c8917c1ca267a53161e246396f
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/eee3315898eeb1c8917c1ca267a53161e246396f
You're receiving this email because of your account on code.videolan.org. Manage all notifications: https://code.videolan.org/-/profile/notifications | Help: https://code.videolan.org/help
More information about the vlc-commits
mailing list