From bc01f89575b94140e2d59a4b1167320ea954d222 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Kempf Date: Sat, 1 Nov 2008 23:16:53 +0100 Subject: [PATCH] [Qt] Implement a kind of rememberance in Open Network Dialog. The code is suboptimal since it does save more often than when accept() is called. This will be fixed in the future. --- modules/gui/qt4/components/open_panels.cpp | 32 ++++++++++++++++++++-- modules/gui/qt4/components/open_panels.hpp | 3 ++ 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/modules/gui/qt4/components/open_panels.cpp b/modules/gui/qt4/components/open_panels.cpp index 47eedfb805..3376c42a74 100644 --- a/modules/gui/qt4/components/open_panels.cpp +++ b/modules/gui/qt4/components/open_panels.cpp @@ -44,6 +44,7 @@ #include #include #include +#include #define I_DEVICE_TOOLTIP N_("Select the device or the VIDEO_TS directory") @@ -447,10 +448,29 @@ NetOpenPanel::NetOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) : ui.protocolCombo->addItem("RTMP", QVariant("rtmp")); updateProtocol( ui.protocolCombo->currentIndex() ); + + if( config_GetInt( p_intf, "qt-recentplay" ) ) + { + mrlList = new QStringListModel( + getSettings()->value( "Open/netMRL" ).toStringList() ); + QCompleter *completer = new QCompleter( mrlList, this ); + ui.addressText->setCompleter( completer ); + + CONNECT( ui.addressText, editingFinished(), this, updateCompleter() ); + } + else + mrlList = NULL; } NetOpenPanel::~NetOpenPanel() -{} +{ + if( !mrlList ) return; + + QStringList tempL = mrlList->stringList(); + while( tempL.size() > 8 ) tempL.removeFirst(); + + getSettings()->setValue( "Open/netMRL", tempL ); +} void NetOpenPanel::clear() {} @@ -557,14 +577,20 @@ void NetOpenPanel::updateMRL() { } } - // Encode the boring stuffs - if( ui.timeShift->isEnabled() && ui.timeShift->isChecked() ) { mrl += " :access-filter=timeshift"; } emit mrlUpdated( mrl ); } +void NetOpenPanel::updateCompleter() +{ + assert( mrlList ); + QStringList tempL = mrlList->stringList(); + tempL.append( ui.addressText->text() ); + mrlList->setStringList( tempL ); +} + /************************************************************************** * Open Capture device ( DVB, PVR, V4L, and similar ) * **************************************************************************/ diff --git a/modules/gui/qt4/components/open_panels.hpp b/modules/gui/qt4/components/open_panels.hpp index fb59a965d1..95a9b93ed5 100644 --- a/modules/gui/qt4/components/open_panels.hpp +++ b/modules/gui/qt4/components/open_panels.hpp @@ -81,6 +81,7 @@ static const char *psz_devModule[] = { "v4l", "v4l2", "pvr", "dvb", "bda", class QWidget; class QLineEdit; class QString; +class QStringListModel; class OpenPanel: public QWidget { @@ -143,10 +144,12 @@ public: virtual void clear() ; private: Ui::OpenNetwork ui; + QStringListModel *mrlList; public slots: virtual void updateMRL(); private slots: void updateProtocol( int ); + void updateCompleter(); }; class DiscOpenPanel: public OpenPanel -- 2.39.2