[vlc-commits] [Git][videolan/vlc][master] 6 commits: libvlc-module: add 'save-recentplay' option

Hugo Beauzée-Luyssen (@chouquette) gitlab at videolan.org
Fri Dec 10 14:20:58 UTC 2021



Hugo Beauzée-Luyssen pushed to branch master at VideoLAN / VLC


Commits:
f49d3582 by Prince Gupta at 2021-12-10T13:45:04+00:00
libvlc-module: add 'save-recentplay' option

- - - - -
3871e4c2 by Prince Gupta at 2021-12-10T13:45:04+00:00
qt: use 'save-recentplay' for 'qt-recentplay'

qt/open_panels: use 'save-recentplay'

qt/preferences: use 'save-recentplay'

qt/MainInterface: use 'save-recentplay'

qt/recent_menu: use 'save-recentplay'

- - - - -
c15b9606 by Prince Gupta at 2021-12-10T13:45:04+00:00
qt: mark 'qt-recentplay' and 'qt-recentplay-filter' obsolete

- - - - -
45501cae by Prince Gupta at 2021-12-10T13:45:04+00:00
qt/preferences: remove recently played filters

- - - - -
646d31bc by Prince Gupta at 2021-12-10T13:45:04+00:00
qt/preferences: add option to clear history

- - - - -
736213df by Prince Gupta at 2021-12-10T13:45:04+00:00
qt/preferences: hide recently played option if medialibrary is not available

- - - - -


9 changed files:

- modules/gui/qt/dialogs/open/open_panels.cpp
- modules/gui/qt/dialogs/preferences/simple_preferences.cpp
- modules/gui/qt/dialogs/preferences/sprefs_interface.ui
- modules/gui/qt/maininterface/mainctx.cpp
- modules/gui/qt/menus/menus.cpp
- modules/gui/qt/qt.cpp
- src/input/var.c
- src/libvlc-module.c
- src/player/medialib.c


Changes:

=====================================
modules/gui/qt/dialogs/open/open_panels.cpp
=====================================
@@ -681,9 +681,10 @@ NetOpenPanel::NetOpenPanel( QWidget *_parent, qt_intf_t *_p_intf ) :
     CONNECT( ui.urlComboBox, editTextChanged( const QString& ), this, updateMRL());
 
     /* */
-    if( var_InheritBool( p_intf, "qt-recentplay" ) )
+    if( var_InheritBool( p_intf, "save-recentplay" ) )
     {
         b_recentList = true;
+        // FIXME: use MLUrlModel
         ui.urlComboBox->addItems( getSettings()->value( "OpenDialog/netMRL" ).toStringList() );
         ui.urlComboBox->setMaxCount( 10 );
     }


=====================================
modules/gui/qt/dialogs/preferences/simple_preferences.cpp
=====================================
@@ -32,6 +32,7 @@
 #include "util/color_scheme_model.hpp"
 #include "util/qvlcapp.hpp"
 #include "util/proxycolumnmodel.hpp"
+#include "medialibrary/mlrecentsmodel.hpp"
 
 #include <vlc_config_cat.h>
 #include <vlc_configuration.h>
@@ -52,6 +53,7 @@
 #include <QtAlgorithms>
 #include <QDir>
 
+#include <QSpacerItem>
 #include <QSpinBox>
 #include <QCheckBox>
 #include <QLabel>
@@ -921,16 +923,30 @@ SPrefsPanel::SPrefsPanel( qt_intf_t *_p_intf, QWidget *_parent,
                 CONFIG_BOOL( "one-instance-when-started-from-file", oneInstanceFromFile );
             }
 
-            /* RECENTLY PLAYED options */
-            CONNECT( ui.saveRecentlyPlayed, toggled( bool ),
-                     ui.recentlyPlayedFilters, setEnabled( bool ) );
-            ui.recentlyPlayedFilters->setEnabled( false );
-            CONFIG_BOOL( "qt-recentplay", saveRecentlyPlayed );
-            CONFIG_GENERIC( "restore-playback-pos", IntegerList, ui.continuePlaybackLabel, continuePlaybackComboBox );
-            CONFIG_GENERIC( "qt-recentplay-filter", String, ui.filterLabel,
-                    recentlyPlayedFilters );
             CONFIG_GENERIC( "qt-auto-raise", IntegerList, ui.autoRaiseLabel, autoRaiseComboBox );
 
+            /* RECENTLY PLAYED options */
+
+            const auto hasMedialibrary = p_intf->p_mi->hasMediaLibrary();
+
+            ui.continuePlaybackLabel->setVisible( hasMedialibrary );
+            ui.continuePlaybackComboBox->setVisible( hasMedialibrary );
+            ui.saveRecentlyPlayed->setVisible( hasMedialibrary );
+            ui.clearRecent->setVisible( hasMedialibrary );
+            ui.clearRecentSpacer->changeSize( 0, 0 );
+
+            if ( hasMedialibrary )
+            {
+                CONFIG_GENERIC( "restore-playback-pos", IntegerList, ui.continuePlaybackLabel, continuePlaybackComboBox );
+                CONFIG_BOOL( "save-recentplay", saveRecentlyPlayed );
+
+                ui.clearRecentSpacer->changeSize( 1, 1, QSizePolicy::Expanding, QSizePolicy::Minimum );
+                MLRecentsModel *recentsModel = new MLRecentsModel( ui.clearRecent );
+                recentsModel->setMl( p_intf->p_mi->getMediaLibrary() );
+                connect( ui.clearRecent, &QPushButton::clicked, recentsModel, &MLRecentsModel::clearHistory );
+            }
+
+
         END_SPREFS_CAT;
 
         /**********************************


=====================================
modules/gui/qt/dialogs/preferences/sprefs_interface.ui
=====================================
@@ -557,23 +557,17 @@
       <string>Privacy / Network Interaction</string>
      </property>
      <layout class="QGridLayout" name="gridLayout_3">
-      <item row="0" column="0">
-       <widget class="QCheckBox" name="updatesBox">
+      <item row="2" column="0">
+       <widget class="QCheckBox" name="MetadataNetworkAccessMode">
         <property name="text">
-         <string>Activate updates notifier</string>
+         <string>Allow metadata network access</string>
         </property>
        </widget>
       </item>
-      <item row="0" column="1">
-       <widget class="QSpinBox" name="updatesDays">
-        <property name="alignment">
-         <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
-        </property>
-        <property name="suffix">
-         <string> days</string>
-        </property>
-        <property name="prefix">
-         <string>Every </string>
+      <item row="0" column="0">
+       <widget class="QCheckBox" name="updatesBox">
+        <property name="text">
+         <string>Activate updates notifier</string>
         </property>
        </widget>
       </item>
@@ -586,44 +580,41 @@
           </property>
          </widget>
         </item>
-        <item>
-         <widget class="QLabel" name="filterLabel">
-          <property name="text">
-           <string>Filter:</string>
-          </property>
-          <property name="alignment">
-           <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
-          </property>
-          <property name="margin">
-           <number>5</number>
-          </property>
-          <property name="buddy">
-           <cstring>recentlyPlayedFilters</cstring>
-          </property>
-         </widget>
-        </item>
        </layout>
       </item>
-      <item row="1" column="1">
-       <widget class="QLineEdit" name="recentlyPlayedFilters">
-        <property name="sizePolicy">
-         <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
-          <horstretch>0</horstretch>
-          <verstretch>0</verstretch>
-         </sizepolicy>
+      <item row="0" column="2">
+       <widget class="QSpinBox" name="updatesDays">
+        <property name="alignment">
+         <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
         </property>
-        <property name="toolTip">
-         <string>Separate words by | (without space)</string>
+        <property name="suffix">
+         <string> days</string>
+        </property>
+        <property name="prefix">
+         <string>Every </string>
         </property>
        </widget>
       </item>
-      <item row="2" column="0">
-       <widget class="QCheckBox" name="MetadataNetworkAccessMode">
+      <item row="1" column="2">
+       <widget class="QPushButton" name="clearRecent">
         <property name="text">
-         <string>Allow metadata network access</string>
+         <string>Clear Recently Played Items</string>
         </property>
        </widget>
       </item>
+      <item row="1" column="1">
+       <spacer name="clearRecentSpacer">
+        <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>
@@ -749,7 +740,6 @@
   <tabstop>updatesBox</tabstop>
   <tabstop>updatesDays</tabstop>
   <tabstop>saveRecentlyPlayed</tabstop>
-  <tabstop>recentlyPlayedFilters</tabstop>
   <tabstop>MetadataNetworkAccessMode</tabstop>
   <tabstop>assoButton</tabstop>
  </tabstops>


=====================================
modules/gui/qt/maininterface/mainctx.cpp
=====================================
@@ -221,7 +221,7 @@ MainCtx::~MainCtx()
     /* Save the stackCentralW sizes */
     settings->endGroup();
 
-    if( var_InheritBool( p_intf, "qt-recentplay" ) )
+    if( var_InheritBool( p_intf, "save-recentplay" ) )
         getSettings()->setValue( "filedialog-path", m_dialogFilepath );
     else
         getSettings()->remove( "filedialog-path" );


=====================================
modules/gui/qt/menus/menus.cpp
=====================================
@@ -193,7 +193,7 @@ void VLCMenuBar::FileMenu(qt_intf_t *p_intf, QMenu *menu)
     addDPStaticEntry( menu, qtr( "Open &Location from clipboard" ),
                       NULL, &DialogsProvider::openUrlDialog, "Ctrl+V" );
 
-    if( mi && var_InheritBool( p_intf, "qt-recentplay" ) && mi->hasMediaLibrary() )
+    if( mi && var_InheritBool( p_intf, "save-recentplay" ) && mi->hasMediaLibrary() )
     {
         MLRecentsModel* recentModel = new MLRecentsModel(nullptr);
         recentModel->setMl(mi->getMediaLibrary());


=====================================
modules/gui/qt/qt.cpp
=====================================
@@ -333,10 +333,8 @@ vlc_module_begin ()
     add_string("qt-compositor", "auto", QT_COMPOSITOR_TEXT, QT_COMPOSITOR_LONGTEXT)
             change_string_list(compositor_vlc, compositor_user)
 
-    add_bool( "qt-recentplay", true, RECENTPLAY_TEXT,
-              nullptr )
-    add_string( "qt-recentplay-filter", "",
-                RECENTPLAY_FILTER_TEXT, RECENTPLAY_FILTER_LONGTEXT )
+    add_obsolete_bool( "qt-recentplay" )
+    add_obsolete_string( "qt-recentplay-filter" )
     add_obsolete_integer( "qt-continue" )
 
 #ifdef UPDATE_CHECK


=====================================
src/input/var.c
=====================================
@@ -123,4 +123,7 @@ void input_ConfigVarInit ( input_thread_t *p_input )
 
     /* Inherited by demux/subtitle.c */
     var_Create( p_input, "sub-original-fps", VLC_VAR_FLOAT );
+
+    /* used by Medialibrary */
+    var_Create( p_input, "save-recentplay", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
 }


=====================================
src/libvlc-module.c
=====================================
@@ -709,6 +709,8 @@ static const char *const ppsz_prefres[] = {
     "the form \"{name=bookmark-name,time=optional-time-offset," \
     "bytes=optional-byte-offset},{...}\"")
 
+#define SAVE_RECENTPLAY N_("Save recently played items")
+
 #define RESTORE_PLAYBACK_POS_TEXT N_("Continue playback")
 #define RESTORE_PLAYBACK_POS_LONGTEXT N_("Should the playback resume where " \
     "it was left off?")
@@ -1866,6 +1868,8 @@ vlc_module_begin ()
                  BOOKMARKS_TEXT, BOOKMARKS_LONGTEXT )
         change_safe ()
 
+    add_bool( "save-recentplay", true, SAVE_RECENTPLAY, NULL );
+
     add_integer( "restore-playback-pos", VLC_PLAYER_RESTORE_PLAYBACK_POS_ASK,
                  RESTORE_PLAYBACK_POS_TEXT, RESTORE_PLAYBACK_POS_LONGTEXT )
         change_integer_list( pi_restore_playback_values, ppsz_restore_playback_desc );


=====================================
src/player/medialib.c
=====================================
@@ -202,7 +202,8 @@ vlc_player_UpdateMLStates(vlc_player_t *player, struct vlc_player_input* input)
     }
     assert(media->i_type != VLC_ML_MEDIA_TYPE_UNKNOWN);
 
-    vlc_ml_media_update_progress( ml, media->i_id, input->position );
+    if ( var_GetBool( input->thread, "save-recentplay" ) )
+        vlc_ml_media_update_progress( ml, media->i_id, input->position );
 
     /* If the value changed during the playback, update it in the medialibrary.
      * If not, set each state to their "unset" values, so that they aren't saved



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/4427da15b5e14775ba72778f5f39f3af4ea0df5b...736213df13a9a2c91b1dbb77815a627bf1f80aaa

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/4427da15b5e14775ba72778f5f39f3af4ea0df5b...736213df13a9a2c91b1dbb77815a627bf1f80aaa
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list