[vlc-devel] [PATCH] URL box is now focussed when "Open Network Stream" dialog box opens.

Daniel Marth danielmarth at gmx.at
Wed Dec 15 19:19:49 CET 2010


Here is a more elegant version of the patch i submitted. I replaced the access 
of the combobox from the dialog with a virtual function in the panel .
---
 modules/gui/qt4/components/open_panels.cpp |    6 ++++++
 modules/gui/qt4/components/open_panels.hpp |    2 ++
 modules/gui/qt4/dialogs/open.cpp           |   14 ++++++++++++--
 3 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/modules/gui/qt4/components/open_panels.cpp 
b/modules/gui/qt4/components/open_panels.cpp
index ce95924..0ce49dd 100644
--- a/modules/gui/qt4/components/open_panels.cpp
+++ b/modules/gui/qt4/components/open_panels.cpp
@@ -594,6 +594,12 @@ NetOpenPanel::~NetOpenPanel()
 void NetOpenPanel::clear()
 {}
 
+void NetOpenPanel::onFocus()
+{
+    ui.urlComboBox->setFocus();
+    ui.urlComboBox->lineEdit()->selectAll();
+}
+
 static int strcmp_void( const void *k, const void *e )
 {
     return strcmp( (const char *)k, (const char *)e );
diff --git a/modules/gui/qt4/components/open_panels.hpp 
b/modules/gui/qt4/components/open_panels.hpp
index 0160972..8d6f00c 100644
--- a/modules/gui/qt4/components/open_panels.hpp
+++ b/modules/gui/qt4/components/open_panels.hpp
@@ -74,6 +74,7 @@ public:
     }
     virtual ~OpenPanel() {};
     virtual void clear() = 0;
+    virtual void onFocus() {}
 protected:
     intf_thread_t *p_intf;
 public slots:
@@ -140,6 +141,7 @@ public:
     NetOpenPanel( QWidget *, intf_thread_t * );
     virtual ~NetOpenPanel();
     virtual void clear() ;
+    void onFocus();
 private:
     Ui::OpenNetwork ui;
     QStringListModel *mrlList;
diff --git a/modules/gui/qt4/dialogs/open.cpp 
b/modules/gui/qt4/dialogs/open.cpp
index 6cd52e3..24d0653 100644
--- a/modules/gui/qt4/dialogs/open.cpp
+++ b/modules/gui/qt4/dialogs/open.cpp
@@ -240,15 +240,25 @@ void OpenDialog::showTab( int i_tab )
     if( i_tab == OPEN_CAPTURE_TAB ) captureOpenPanel->initialize();
     ui.Tab->setCurrentIndex( i_tab );
     show();
+    if( ui.Tab->currentWidget() != NULL )
+    {
+        OpenPanel *panel = dynamic_cast<OpenPanel *>( ui.Tab->currentWidget() 
);
+        assert( panel );
+        panel->onFocus();
+    }
 }
 
 /* Function called on signal currentChanged triggered */
 void OpenDialog::signalCurrent( int i_tab )
 {
     if( i_tab == OPEN_CAPTURE_TAB ) captureOpenPanel->initialize();
-
     if( ui.Tab->currentWidget() != NULL )
-        ( dynamic_cast<OpenPanel *>( ui.Tab->currentWidget() ) )-
>updateMRL();
+    {
+        OpenPanel *panel = dynamic_cast<OpenPanel *>( ui.Tab->currentWidget() 
);
+        assert( panel );
+        panel->onFocus();
+        panel->updateMRL();
+    }
 }
 
 void OpenDialog::toggleAdvancedPanel()
-- 
1.7.1




More information about the vlc-devel mailing list