[vlc-commits] [Git][videolan/vlc][master] qt: fix entries in CheckableListMenu cannot be de-selected
Steve Lhomme (@robUx4)
gitlab at videolan.org
Wed Sep 28 14:39:11 UTC 2022
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
65b96ee7 by Pierre Lamot at 2022-09-28T13:55:40+00:00
qt: fix entries in CheckableListMenu cannot be de-selected
introduce a third grouping mode (GROUPED_OPTIONAL) for models that have at most
one active state but the state can be disabled (video/audio tracks for instance)
- - - - -
3 changed files:
- modules/gui/qt/menus/custom_menus.cpp
- modules/gui/qt/menus/custom_menus.hpp
- modules/gui/qt/menus/menus.cpp
Changes:
=====================================
modules/gui/qt/menus/custom_menus.cpp
=====================================
@@ -216,9 +216,17 @@ CheckableListMenu::CheckableListMenu(QString title, QAbstractListModel* model ,
, m_grouping(grouping)
{
this->setTitle(title);
- if (m_grouping == GROUPED)
+ if (m_grouping != UNGROUPED)
{
m_actionGroup = new QActionGroup(this);
+ if (m_grouping == GROUPED_OPTIONAL)
+ {
+#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
+ m_actionGroup->setExclusionPolicy(QActionGroup::ExclusionPolicy::ExclusiveOptional);
+#else
+ m_actionGroup->setExclusive(false);
+#endif
+ }
}
connect(m_model, &QAbstractListModel::rowsAboutToBeRemoved, this, &CheckableListMenu::onRowsAboutToBeRemoved);
=====================================
modules/gui/qt/menus/custom_menus.hpp
=====================================
@@ -75,7 +75,8 @@ class CheckableListMenu : public QMenu
Q_OBJECT
public:
enum GroupingMode {
- GROUPED,
+ GROUPED_EXLUSIVE,
+ GROUPED_OPTIONAL,
UNGROUPED
};
=====================================
modules/gui/qt/menus/menus.cpp
=====================================
@@ -332,7 +332,7 @@ void VLCMenuBar::ViewMenu( qt_intf_t *p_intf, QMenu *menu )
action->setCheckable( true );
action->setChecked( mi->hasGridView() );
- menu->addMenu( new CheckableListMenu(qtr( "&Color Scheme" ), mi->getColorScheme(), CheckableListMenu::GROUPED, menu) );
+ menu->addMenu( new CheckableListMenu(qtr( "&Color Scheme" ), mi->getColorScheme(), CheckableListMenu::GROUPED_EXLUSIVE, menu) );
menu->addSeparator();
@@ -394,7 +394,7 @@ void VLCMenuBar::AudioMenu( qt_intf_t *p_intf, QMenu * current )
{
if( current->isEmpty() )
{
- current->addMenu(new CheckableListMenu(qtr( "Audio &Track" ), THEMIM->getAudioTracks(), CheckableListMenu::GROUPED, current));
+ current->addMenu(new CheckableListMenu(qtr( "Audio &Track" ), THEMIM->getAudioTracks(), CheckableListMenu::GROUPED_OPTIONAL, current));
QAction *audioDeviceAction = new QAction( qtr( "Audio &Device" ), current );
QMenu *audioDeviceSubmenu = new QMenu( current );
@@ -406,12 +406,12 @@ void VLCMenuBar::AudioMenu( qt_intf_t *p_intf, QMenu * current )
VLCVarChoiceModel *mix_mode = THEMIM->getAudioMixMode();
if (mix_mode->rowCount() == 0)
- current->addMenu( new CheckableListMenu(qtr( "&Stereo Mode" ), THEMIM->getAudioStereoMode(), CheckableListMenu::GROUPED, current) );
+ current->addMenu( new CheckableListMenu(qtr( "&Stereo Mode" ), THEMIM->getAudioStereoMode(), CheckableListMenu::GROUPED_EXLUSIVE, current) );
else
- current->addMenu( new CheckableListMenu(qtr( "&Mix Mode" ), mix_mode, CheckableListMenu::GROUPED, current) );
+ current->addMenu( new CheckableListMenu(qtr( "&Mix Mode" ), mix_mode, CheckableListMenu::GROUPED_EXLUSIVE, current) );
current->addSeparator();
- current->addMenu( new CheckableListMenu(qtr( "&Visualizations" ), THEMIM->getAudioVisualizations(), CheckableListMenu::GROUPED, current) );
+ current->addMenu( new CheckableListMenu(qtr( "&Visualizations" ), THEMIM->getAudioVisualizations(), CheckableListMenu::GROUPED_EXLUSIVE, current) );
VolumeEntries( p_intf, current );
}
}
@@ -423,7 +423,7 @@ void VLCMenuBar::SubtitleMenu( qt_intf_t *p_intf, QMenu *current, bool b_popup )
{
addDPStaticEntry( current, qtr( "Add &Subtitle File..." ), "",
&DialogsProvider::loadSubtitlesFile);
- current->addMenu(new CheckableListMenu(qtr( "Sub &Track" ), THEMIM->getSubtitleTracks(), CheckableListMenu::GROUPED, current));
+ current->addMenu(new CheckableListMenu(qtr( "Sub &Track" ), THEMIM->getSubtitleTracks(), CheckableListMenu::GROUPED_OPTIONAL, current));
current->addSeparator();
}
}
@@ -436,7 +436,7 @@ void VLCMenuBar::VideoMenu( qt_intf_t *p_intf, QMenu *current )
{
if( current->isEmpty() )
{
- current->addMenu(new CheckableListMenu(qtr( "Video &Track" ), THEMIM->getVideoTracks(), CheckableListMenu::GROUPED, current));
+ current->addMenu(new CheckableListMenu(qtr( "Video &Track" ), THEMIM->getVideoTracks(), CheckableListMenu::GROUPED_OPTIONAL, current));
current->addSeparator();
/* Surface modifiers */
@@ -449,14 +449,14 @@ void VLCMenuBar::VideoMenu( qt_intf_t *p_intf, QMenu *current )
current->addSeparator();
/* Size modifiers */
- current->addMenu( new CheckableListMenu(qtr( "&Zoom" ), THEMIM->getZoom(), CheckableListMenu::GROUPED, current) );
- current->addMenu( new CheckableListMenu(qtr( "&Aspect Ratio" ), THEMIM->getAspectRatio(), CheckableListMenu::GROUPED, current) );
- current->addMenu( new CheckableListMenu(qtr( "&Crop" ), THEMIM->getCrop(), CheckableListMenu::GROUPED, current) );
+ current->addMenu( new CheckableListMenu(qtr( "&Zoom" ), THEMIM->getZoom(), CheckableListMenu::GROUPED_EXLUSIVE, current) );
+ current->addMenu( new CheckableListMenu(qtr( "&Aspect Ratio" ), THEMIM->getAspectRatio(), CheckableListMenu::GROUPED_EXLUSIVE, current) );
+ current->addMenu( new CheckableListMenu(qtr( "&Crop" ), THEMIM->getCrop(), CheckableListMenu::GROUPED_EXLUSIVE, current) );
current->addSeparator();
/* Rendering modifiers */
- current->addMenu( new CheckableListMenu(qtr( "&Deinterlace" ), THEMIM->getDeinterlace(), CheckableListMenu::GROUPED, current) );
- current->addMenu( new CheckableListMenu(qtr( "&Deinterlace mode" ), THEMIM->getDeinterlaceMode(), CheckableListMenu::GROUPED, current) );
+ current->addMenu( new CheckableListMenu(qtr( "&Deinterlace" ), THEMIM->getDeinterlace(), CheckableListMenu::GROUPED_EXLUSIVE, current) );
+ current->addMenu( new CheckableListMenu(qtr( "&Deinterlace mode" ), THEMIM->getDeinterlaceMode(), CheckableListMenu::GROUPED_EXLUSIVE, current) );
current->addSeparator();
/* Other actions */
@@ -475,11 +475,11 @@ void VLCMenuBar::NavigMenu( qt_intf_t *p_intf, QMenu *menu )
QAction *action;
QMenu *submenu;
- menu->addMenu( new CheckableListMenu( qtr( "T&itle" ), THEMIM->getTitles(), CheckableListMenu::GROUPED, menu) );
- submenu = new CheckableListMenu( qtr( "&Chapter" ), THEMIM->getChapters(), CheckableListMenu::GROUPED, menu );
+ menu->addMenu( new CheckableListMenu( qtr( "T&itle" ), THEMIM->getTitles(), CheckableListMenu::GROUPED_EXLUSIVE, menu) );
+ submenu = new CheckableListMenu( qtr( "&Chapter" ), THEMIM->getChapters(), CheckableListMenu::GROUPED_EXLUSIVE, menu );
submenu->setTearOffEnabled( true );
menu->addMenu( submenu );
- menu->addMenu( new CheckableListMenu( qtr("&Program") , THEMIM->getPrograms(), CheckableListMenu::GROUPED , menu) );
+ menu->addMenu( new CheckableListMenu( qtr("&Program") , THEMIM->getPrograms(), CheckableListMenu::GROUPED_EXLUSIVE, menu) );
MainCtx * mi = p_intf->p_mi;
@@ -805,7 +805,7 @@ QMenu* VLCMenuBar::PopupMenu( qt_intf_t *p_intf, bool show )
}
VLCVarChoiceModel* skinmodel = new VLCVarChoiceModel(p_object, "intf-skins", submenu);
- CheckableListMenu* skinsubmenu = new CheckableListMenu(qtr("Interface"), skinmodel, CheckableListMenu::GROUPED, submenu);
+ CheckableListMenu* skinsubmenu = new CheckableListMenu(qtr("Interface"), skinmodel, CheckableListMenu::GROUPED_OPTIONAL, submenu);
submenu->addMenu(skinsubmenu);
submenu->addSeparator();
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/65b96ee7dcc16c9373adf022aafe6dc67c3db2b4
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/65b96ee7dcc16c9373adf022aafe6dc67c3db2b4
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