mirror of
https://code.videolan.org/videolan/vlc
synced 2024-09-28 23:09:59 +02:00
qt: Create control_list_filter
This commit is contained in:
parent
b5923a21d6
commit
026b9db3a9
@ -228,6 +228,8 @@ libqt_plugin_la_SOURCES = \
|
|||||||
gui/qt/player/player_controller.cpp gui/qt/player/player_controller.hpp gui/qt/player/player_controller_p.hpp \
|
gui/qt/player/player_controller.cpp gui/qt/player/player_controller.hpp gui/qt/player/player_controller_p.hpp \
|
||||||
gui/qt/player/player_controlbar_model.cpp gui/qt/player/player_controlbar_model.hpp \
|
gui/qt/player/player_controlbar_model.cpp gui/qt/player/player_controlbar_model.hpp \
|
||||||
gui/qt/player/control_list_model.cpp gui/qt/player/control_list_model.hpp \
|
gui/qt/player/control_list_model.cpp gui/qt/player/control_list_model.hpp \
|
||||||
|
gui/qt/player/control_list_filter.cpp \
|
||||||
|
gui/qt/player/control_list_filter.hpp \
|
||||||
gui/qt/playlist/media.hpp \
|
gui/qt/playlist/media.hpp \
|
||||||
gui/qt/playlist/playlist_common.cpp \
|
gui/qt/playlist/playlist_common.cpp \
|
||||||
gui/qt/playlist/playlist_common.hpp \
|
gui/qt/playlist/playlist_common.hpp \
|
||||||
@ -424,6 +426,7 @@ nodist_libqt_plugin_la_SOURCES = \
|
|||||||
gui/qt/player/player_controller.moc.cpp \
|
gui/qt/player/player_controller.moc.cpp \
|
||||||
gui/qt/player/player_controlbar_model.moc.cpp \
|
gui/qt/player/player_controlbar_model.moc.cpp \
|
||||||
gui/qt/player/control_list_model.moc.cpp \
|
gui/qt/player/control_list_model.moc.cpp \
|
||||||
|
gui/qt/player/control_list_filter.moc.cpp \
|
||||||
gui/qt/playlist/playlist_common.moc.cpp \
|
gui/qt/playlist/playlist_common.moc.cpp \
|
||||||
gui/qt/playlist/playlist_controller.moc.cpp \
|
gui/qt/playlist/playlist_controller.moc.cpp \
|
||||||
gui/qt/playlist/playlist_item.moc.cpp \
|
gui/qt/playlist/playlist_item.moc.cpp \
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include "player/player_controller.hpp"
|
#include "player/player_controller.hpp"
|
||||||
#include "player/player_controlbar_model.hpp"
|
#include "player/player_controlbar_model.hpp"
|
||||||
#include "player/control_list_model.hpp"
|
#include "player/control_list_model.hpp"
|
||||||
|
#include "player/control_list_filter.hpp"
|
||||||
|
|
||||||
#include "dialogs/toolbar/controlbar_profile_model.hpp"
|
#include "dialogs/toolbar/controlbar_profile_model.hpp"
|
||||||
#include "dialogs/toolbar/controlbar_profile.hpp"
|
#include "dialogs/toolbar/controlbar_profile.hpp"
|
||||||
@ -255,6 +256,7 @@ void MainUI::registerQMLTypes()
|
|||||||
qmlRegisterUncreatableType<ControlbarProfile>(uri, versionMajor, versionMinor, "ControlbarProfile", "");
|
qmlRegisterUncreatableType<ControlbarProfile>(uri, versionMajor, versionMinor, "ControlbarProfile", "");
|
||||||
qmlRegisterUncreatableType<PlayerControlbarModel>(uri, versionMajor, versionMinor, "PlayerControlbarModel", "");
|
qmlRegisterUncreatableType<PlayerControlbarModel>(uri, versionMajor, versionMinor, "PlayerControlbarModel", "");
|
||||||
qmlRegisterUncreatableType<ControlListModel>( uri, versionMajor, versionMinor, "ControlListModel", "" );
|
qmlRegisterUncreatableType<ControlListModel>( uri, versionMajor, versionMinor, "ControlListModel", "" );
|
||||||
|
qmlRegisterType<ControlListFilter>(uri, versionMajor, versionMinor, "ControlListFilter");
|
||||||
qmlRegisterSingletonType(uri, versionMajor, versionMinor, "PlayerListModel", PlayerControlbarModel::getPlaylistIdentifierListModel);
|
qmlRegisterSingletonType(uri, versionMajor, versionMinor, "PlayerListModel", PlayerControlbarModel::getPlaylistIdentifierListModel);
|
||||||
|
|
||||||
qmlRegisterType<StringListMenu>( uri, versionMajor, versionMinor, "StringListMenu" );
|
qmlRegisterType<StringListMenu>( uri, versionMajor, versionMinor, "StringListMenu" );
|
||||||
|
93
modules/gui/qt/player/control_list_filter.cpp
Normal file
93
modules/gui/qt/player/control_list_filter.cpp
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* Copyright (C) 2022 VLC authors and VideoLAN
|
||||||
|
*
|
||||||
|
* Authors: Benjamin Arnaud <bunjee@omega.gg>
|
||||||
|
*
|
||||||
|
* 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 "control_list_filter.hpp"
|
||||||
|
|
||||||
|
// Player includes
|
||||||
|
#include "player_controller.hpp"
|
||||||
|
#include "control_list_model.hpp"
|
||||||
|
|
||||||
|
// Ctor / dtor
|
||||||
|
|
||||||
|
/* explicit */ ControlListFilter::ControlListFilter(QObject * parent)
|
||||||
|
: QSortFilterProxyModel(parent) {}
|
||||||
|
|
||||||
|
// QAbstractProxyModel reimplementation
|
||||||
|
|
||||||
|
void ControlListFilter::setSourceModel(QAbstractItemModel * sourceModel) /* override */
|
||||||
|
{
|
||||||
|
assert(sourceModel->inherits("ControlListModel"));
|
||||||
|
|
||||||
|
QSortFilterProxyModel::setSourceModel(sourceModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Protected QSortFilterProxyModel reimplementation
|
||||||
|
|
||||||
|
bool ControlListFilter::filterAcceptsRow(int source_row, const QModelIndex &) const /* override */
|
||||||
|
{
|
||||||
|
QAbstractItemModel * model = sourceModel();
|
||||||
|
|
||||||
|
if (model == nullptr || m_player == nullptr)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
QVariant variant = model->data(model->index(source_row, 0), ControlListModel::ID_ROLE);
|
||||||
|
|
||||||
|
if (variant.isValid() == false)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
ControlListModel::ControlType type
|
||||||
|
= static_cast<ControlListModel::ControlType> (variant.toInt());
|
||||||
|
|
||||||
|
// NOTE: These controls are completely hidden when the current media does not support them.
|
||||||
|
if (type == ControlListModel::TELETEXT_BUTTONS)
|
||||||
|
{
|
||||||
|
return m_player->isTeletextAvailable();
|
||||||
|
}
|
||||||
|
else if (type == ControlListModel::DVD_MENUS_BUTTON)
|
||||||
|
{
|
||||||
|
return m_player->hasMenu();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Properties
|
||||||
|
|
||||||
|
PlayerController * ControlListFilter::player()
|
||||||
|
{
|
||||||
|
return m_player;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ControlListFilter::setPlayer(PlayerController * player)
|
||||||
|
{
|
||||||
|
if (m_player == player) return;
|
||||||
|
|
||||||
|
if (m_player)
|
||||||
|
disconnect(m_player, nullptr, this, nullptr);
|
||||||
|
|
||||||
|
m_player = player;
|
||||||
|
|
||||||
|
connect(player, &PlayerController::teletextAvailableChanged, this, &ControlListFilter::invalidate);
|
||||||
|
connect(player, &PlayerController::hasMenuChanged, this, &ControlListFilter::invalidate);
|
||||||
|
|
||||||
|
invalidate();
|
||||||
|
|
||||||
|
emit playerChanged();
|
||||||
|
}
|
56
modules/gui/qt/player/control_list_filter.hpp
Normal file
56
modules/gui/qt/player/control_list_filter.hpp
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* Copyright (C) 2022 VLC authors and VideoLAN
|
||||||
|
*
|
||||||
|
* Authors: Benjamin Arnaud <bunjee@omega.gg>
|
||||||
|
*
|
||||||
|
* 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 CONTROLLISTFILTER_HPP
|
||||||
|
#define CONTROLLISTFILTER_HPP
|
||||||
|
|
||||||
|
// Qt includes
|
||||||
|
#include <QSortFilterProxyModel>
|
||||||
|
|
||||||
|
// Forward declarations
|
||||||
|
class PlayerController;
|
||||||
|
|
||||||
|
class ControlListFilter : public QSortFilterProxyModel
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
Q_PROPERTY(PlayerController * player READ player WRITE setPlayer NOTIFY playerChanged)
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit ControlListFilter(QObject * parent = nullptr);
|
||||||
|
|
||||||
|
public: // QAbstractProxyModel reimplementation
|
||||||
|
void setSourceModel(QAbstractItemModel * sourceModel) override;
|
||||||
|
|
||||||
|
protected: // QSortFilterProxyModel reimplementation
|
||||||
|
bool filterAcceptsRow(int source_row, const QModelIndex & source_parent) const override;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void playerChanged();
|
||||||
|
|
||||||
|
public: // Properties
|
||||||
|
PlayerController * player();
|
||||||
|
void setPlayer(PlayerController * player);
|
||||||
|
|
||||||
|
private: // Variables
|
||||||
|
PlayerController * m_player = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CONTROLLISTFILTER_HPP
|
@ -817,6 +817,8 @@ modules/gui/qt/util/validators.cpp
|
|||||||
modules/gui/qt/util/validators.hpp
|
modules/gui/qt/util/validators.hpp
|
||||||
modules/gui/qt/player/player_controlbar_model.cpp
|
modules/gui/qt/player/player_controlbar_model.cpp
|
||||||
modules/gui/qt/player/player_controlbar_model.hpp
|
modules/gui/qt/player/player_controlbar_model.hpp
|
||||||
|
modules/gui/qt/player/control_list_filter.cpp
|
||||||
|
modules/gui/qt/player/control_list_filter.hpp
|
||||||
modules/gui/qt/dialogs/dialogs/qml/CustomDialog.qml
|
modules/gui/qt/dialogs/dialogs/qml/CustomDialog.qml
|
||||||
modules/gui/qt/dialogs/dialogs/qml/Dialogs.qml
|
modules/gui/qt/dialogs/dialogs/qml/Dialogs.qml
|
||||||
modules/gui/qt/dialogs/dialogs/qml/WindowDialog.qml
|
modules/gui/qt/dialogs/dialogs/qml/WindowDialog.qml
|
||||||
|
Loading…
Reference in New Issue
Block a user