[vlc-commits] [Git][videolan/vlc][master] 5 commits: qt: factorize action handling in mlfolderseditor
Steve Lhomme (@robUx4)
gitlab at videolan.org
Sat Jul 27 07:06:48 UTC 2024
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
2da9851e by Prince Gupta at 2024-07-27T06:35:12+00:00
qt: factorize action handling in mlfolderseditor
- - - - -
00944830 by Prince Gupta at 2024-07-27T06:35:12+00:00
qt: allow reload url from MLFoldersModel
- - - - -
03573e3e by Prince Gupta at 2024-07-27T06:35:12+00:00
qt/pref: ability to reload individual medialibrary folders
- - - - -
7bc35025 by Prince Gupta at 2024-07-27T06:35:12+00:00
qt/pref: add option to reload medialibrary
- - - - -
a5cdb414 by Prince Gupta at 2024-07-27T06:35:12+00:00
qt: add accessible name to mlfoldereditor buttons
- - - - -
6 changed files:
- modules/gui/qt/dialogs/preferences/simple_preferences.cpp
- modules/gui/qt/dialogs/preferences/sprefs_medialibrary.ui
- modules/gui/qt/medialibrary/mlfoldersmodel.cpp
- modules/gui/qt/medialibrary/mlfoldersmodel.hpp
- modules/gui/qt/widgets/native/mlfolderseditor.cpp
- modules/gui/qt/widgets/native/mlfolderseditor.hpp
Changes:
=====================================
modules/gui/qt/dialogs/preferences/simple_preferences.cpp
=====================================
@@ -1048,6 +1048,9 @@ SPrefsPanel::SPrefsPanel( qt_intf_t *_p_intf, QWidget *_parent,
BUTTONACT( ui.addButton, &SPrefsPanel::MLaddNewFolder );
BUTTONACT( ui.banButton, &SPrefsPanel::MLBanFolder );
+
+ connect( ui.reloadButton, &QPushButton::clicked
+ , p_intf->p_mi->getMediaLibrary(), &MediaLib::reload);
}
else
{
=====================================
modules/gui/qt/dialogs/preferences/sprefs_medialibrary.ui
=====================================
@@ -8,7 +8,7 @@
<x>0</x>
<y>0</y>
<width>700</width>
- <height>507</height>
+ <height>535</height>
</rect>
</property>
<property name="sizePolicy">
@@ -27,36 +27,27 @@
<string>Folders</string>
</property>
<layout class="QGridLayout" name="gridLayout">
- <item row="0" column="1" colspan="2">
- <spacer name="horizontalSpacer_2">
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>Folders scanned by the Media Library:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1" rowspan="2">
+ <spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
- <width>627</width>
- <height>17</height>
+ <width>40</width>
+ <height>20</height>
</size>
</property>
</spacer>
</item>
- <item row="0" column="3">
- <widget class="QPushButton" name="addButton">
- <property name="maximumSize">
- <size>
- <width>16</width>
- <height>16</height>
- </size>
- </property>
- <property name="toolTip">
- <string>Add scanned folder</string>
- </property>
- <property name="text">
- <string>+</string>
- </property>
- </widget>
- </item>
- <item row="3" column="3">
+ <item row="4" column="3">
<widget class="QPushButton" name="banButton">
<property name="maximumSize">
<size>
@@ -72,34 +63,36 @@
</property>
</widget>
</item>
- <item row="0" column="0">
- <widget class="QLabel" name="label_2">
- <property name="text">
- <string>Folders scanned by the Media Library:</string>
- </property>
- </widget>
- </item>
- <item row="2" column="1" rowspan="2">
- <spacer name="horizontalSpacer">
+ <item row="1" column="1" colspan="2">
+ <spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
- <width>40</width>
- <height>20</height>
+ <width>627</width>
+ <height>17</height>
</size>
</property>
</spacer>
</item>
- <item row="2" column="0" rowspan="2">
- <widget class="QLabel" name="label">
+ <item row="1" column="3">
+ <widget class="QPushButton" name="addButton">
+ <property name="maximumSize">
+ <size>
+ <width>16</width>
+ <height>16</height>
+ </size>
+ </property>
+ <property name="toolTip">
+ <string>Add scanned folder</string>
+ </property>
<property name="text">
- <string>Banned folders:</string>
+ <string>+</string>
</property>
</widget>
</item>
- <item row="4" column="0" colspan="4">
+ <item row="5" column="0" colspan="4">
<widget class="MLFoldersEditor" name="bannedEntryPoints">
<property name="editTriggers">
<set>QAbstractItemView::AllEditTriggers</set>
@@ -119,7 +112,7 @@
<row/>
</widget>
</item>
- <item row="1" column="0" colspan="4">
+ <item row="2" column="0" colspan="4">
<widget class="MLFoldersEditor" name="entryPoints">
<property name="editTriggers">
<set>QAbstractItemView::AllEditTriggers</set>
@@ -139,6 +132,49 @@
<row/>
</widget>
</item>
+ <item row="3" column="0" rowspan="2">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Banned folders:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0">
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>Reload All Folders</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="3">
+ <widget class="QPushButton" name="reloadButton">
+ <property name="maximumSize">
+ <size>
+ <width>18</width>
+ <height>18</height>
+ </size>
+ </property>
+ <property name="accessibleName">
+ <string>Reload</string>
+ </property>
+ <property name="text">
+ <string>⟳</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <spacer name="horizontalSpacer_3">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
</layout>
</widget>
</item>
=====================================
modules/gui/qt/medialibrary/mlfoldersmodel.cpp
=====================================
@@ -96,6 +96,15 @@ QHash<int, QByteArray> MLFoldersBaseModel::roleNames() const
};
}
+void MLFoldersBaseModel::reload(const int row)
+{
+ const QString mrl = m_mrls.at(row).mrl;
+ m_mediaLib->runOnMLThread(this, [mrl](vlc_medialibrary_t *ml)
+ {
+ vlc_ml_reload_folder( ml, qtu(mrl) );
+ });
+}
+
void MLFoldersBaseModel::removeAt(int index)
{
assert(index < rowCount());
=====================================
modules/gui/qt/medialibrary/mlfoldersmodel.hpp
=====================================
@@ -72,6 +72,8 @@ public:
public slots:
virtual void remove( const QUrl &mrl ) = 0;
virtual void add( const QUrl &mrl ) = 0;
+ virtual void reload( const int row );
+
void removeAt( int index );
signals:
=====================================
modules/gui/qt/widgets/native/mlfolderseditor.cpp
=====================================
@@ -34,9 +34,9 @@
#include <QPushButton>
MLFoldersEditor::MLFoldersEditor(QWidget *parent)
- : QTableWidget(0, 2, parent)
+ : QTableWidget(0, 3, parent)
{
- setHorizontalHeaderLabels({ qtr("Path"), qtr("Remove") });
+ setHorizontalHeaderLabels({ qtr("Path"), qtr("Remove"), qtr("Reload") });
horizontalHeader()->setMinimumSectionSize( 100 );
horizontalHeader()->setSectionResizeMode( 0 , QHeaderView::Stretch );
horizontalHeader()->setFixedHeight( 24 );
@@ -129,28 +129,55 @@ void MLFoldersEditor::newRow(const QUrl &mrl)
col1->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable );
setItem( row, 0, col1 );
- QWidget *wid = new QWidget( this );
- QBoxLayout* layout = new QBoxLayout( QBoxLayout::LeftToRight , wid );
- QPushButton *pb = new QPushButton( "-" , wid );
- pb->setFixedSize( 16 , 16 );
+ auto buttonCol = [&, this] (const int col, const QString &icon, const QString &accessibleName
+ , std::function<void (MLFoldersEditor *editor, int row)> action)
+ {
+ QWidget *wid = new QWidget( this );
+ QBoxLayout* layout = new QBoxLayout( QBoxLayout::LeftToRight , wid );
- layout->addWidget( pb , Qt::AlignCenter );
- wid->setLayout( layout );
+ QPushButton *pb = new QPushButton( icon , wid );
+ pb->setFixedSize( 18 , 18 );
+ pb->setAccessibleName(accessibleName);
- connect( pb , &QPushButton::clicked , this, [this, col1]()
- {
- int row = col1->row();
- vlc_assert( row >= 0 );
+ layout->addWidget( pb , Qt::AlignCenter );
+ wid->setLayout( layout );
+ connect( pb, &QPushButton::clicked, this, [=, this]()
+ {
+ action(this, col1->row());
+ });
+
+ setCellWidget( row, col, wid );
+ };
+
+ buttonCol( 1, "-", qtr("Remove"), &MLFoldersEditor::markRemoved );
+
+ buttonCol( 2, "⟳", qtr("Reload"), &MLFoldersEditor::reloadUrl );
+}
- const QUrl mrl = col1->data( Qt::UserRole ).toUrl();
- const auto index = m_newEntries.indexOf( mrl );
- if ( index == -1 )
- m_removeEntries.push_back( mrl );
- else
- m_newEntries.remove( index );
+QUrl MLFoldersEditor::url(int row)
+{
+ const QTableWidgetItem *col1 = item(row, 0);
+ return col1->data( Qt::UserRole ).toUrl();
+}
+
+void MLFoldersEditor::markRemoved(int row)
+{
+ const QUrl mrl = url( row );
+ const auto index = m_newEntries.indexOf( mrl );
+ if ( index == -1 )
+ m_removeEntries.push_back( mrl );
+ else
+ m_newEntries.remove( index );
+
+ removeRow( row );
+}
- removeRow( row );
- });
+void MLFoldersEditor::reloadUrl(int row)
+{
+ const QUrl mrl = url( row );
+ if ( m_newEntries.contains(mrl)
+ || m_removeEntries.contains(mrl) )
+ return;
- setCellWidget( row, 1, wid );
+ m_foldersModel->reload( row );
}
=====================================
modules/gui/qt/widgets/native/mlfolderseditor.hpp
=====================================
@@ -52,6 +52,10 @@ private:
void newRow(const QUrl &mrl);
void removeMrlEntry(const QUrl &mrl);
+ QUrl url(int row);
+ void markRemoved(int row);
+ void reloadUrl(int row);
+
MLFoldersBaseModel *m_foldersModel = nullptr;
// new entries to add/remove on 'commit' call
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/fde6755330b12d558e08751cbf5030432e645a3a...a5cdb4142a68e36231a30dd4b441da832c672703
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/fde6755330b12d558e08751cbf5030432e645a3a...a5cdb4142a68e36231a30dd4b441da832c672703
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