From 64e68cb4564b29b615fcdcbb60ee98cfa76083ac Mon Sep 17 00:00:00 2001 From: =?utf8?q?Cl=C3=A9ment=20Stenac?= Date: Tue, 18 Jul 2006 23:20:06 +0000 Subject: [PATCH] A bunch of various fixes (encoding, refcount, layout) --- modules/gui/qt4/Modules.am | 5 ++- .../gui/qt4/components/playlist/selector.cpp | 34 +++++++++++++++++++ .../gui/qt4/components/playlist/selector.hpp | 5 +-- .../qt4/components/playlist/standardpanel.cpp | 4 +-- modules/gui/qt4/components/preferences.cpp | 7 +++- .../qt4/components/preferences_widgets.cpp | 22 ++++++------ modules/gui/qt4/dialogs/playlist.cpp | 13 ++++++- modules/gui/qt4/dialogs/playlist.hpp | 6 ++++ modules/gui/qt4/dialogs/prefs_dialog.cpp | 4 +-- modules/gui/qt4/menus.cpp | 14 ++++---- modules/gui/qt4/qt4.hpp | 1 + 11 files changed, 84 insertions(+), 31 deletions(-) create mode 100644 modules/gui/qt4/components/playlist/selector.cpp diff --git a/modules/gui/qt4/Modules.am b/modules/gui/qt4/Modules.am index 125c765bc4..753195d797 100644 --- a/modules/gui/qt4/Modules.am +++ b/modules/gui/qt4/Modules.am @@ -30,6 +30,7 @@ TOMOC = main_interface \ components/open \ components/video_widget \ components/playlist/panels \ + components/playlist/selector \ util/input_slider MOCCPP = $(TOMOC:%=%.moc.cpp) @@ -49,6 +50,7 @@ nodist_SOURCES_qt4 = \ components/open.moc.cpp \ components/video_widget.moc.cpp \ components/playlist/panels.moc.cpp \ + components/playlist/selector.moc.cpp \ util/input_slider.moc.cpp \ resources.cpp @@ -87,6 +89,7 @@ SOURCES_qt4 = qt4.cpp \ components/open.cpp \ components/video_widget.cpp \ components/playlist/standardpanel.cpp \ + components/playlist/selector.cpp \ util/input_slider.cpp \ $(NULL) @@ -108,7 +111,7 @@ EXTRA_DIST += \ components/open.hpp \ components/video_widget.hpp \ components/playlist/panels.hpp \ - components/playlist/selector.hpp \ + components/playlist/selector.hpp \ util/input_slider.hpp \ util/directslider.hpp \ util/qvlcframe.hpp \ diff --git a/modules/gui/qt4/components/playlist/selector.cpp b/modules/gui/qt4/components/playlist/selector.cpp new file mode 100644 index 0000000000..3e6eee2dd5 --- /dev/null +++ b/modules/gui/qt4/components/playlist/selector.cpp @@ -0,0 +1,34 @@ +/***************************************************************************** + * selector.cpp : Playlist source selector + **************************************************************************** + * Copyright (C) 2000-2005 the VideoLAN team + * $Id: standardpanel.cpp 16024 2006-07-13 13:51:05Z xtophe $ + * + * Authors: Clément Stenac + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + *****************************************************************************/ + +#include "components/playlist/selector.hpp" + +PLSelector::PLSelector( QWidget *p, intf_thread_t *_p_intf ) : QWidget( p ) +{ + p_intf = _p_intf; +} + +PLSelector::~PLSelector() +{ +} + diff --git a/modules/gui/qt4/components/playlist/selector.hpp b/modules/gui/qt4/components/playlist/selector.hpp index 0e4e41de36..7a5931b4c5 100644 --- a/modules/gui/qt4/components/playlist/selector.hpp +++ b/modules/gui/qt4/components/playlist/selector.hpp @@ -32,10 +32,7 @@ class PLSelector: public QWidget { Q_OBJECT; public: - PLSelector( QWidget *p, intf_thread_t *_p_intf ) : QWidget( p ) - { - p_intf = _p_intf; - } + PLSelector( QWidget *p, intf_thread_t *_p_intf ); virtual ~PLSelector(); private: intf_thread_t *p_intf; diff --git a/modules/gui/qt4/components/playlist/standardpanel.cpp b/modules/gui/qt4/components/playlist/standardpanel.cpp index 5a8457b7f3..671f8bb99c 100644 --- a/modules/gui/qt4/components/playlist/standardpanel.cpp +++ b/modules/gui/qt4/components/playlist/standardpanel.cpp @@ -30,12 +30,10 @@ StandardPLPanel::StandardPLPanel( QWidget *_parent, intf_thread_t *_p_intf, playlist_item_t *p_root ): PLPanel( _parent, _p_intf ) { - PLModel *model = new PLModel( p_playlist, p_root, -1, this ); - QTreeView *view = new QTreeView( 0 ); + QTreeView *view = new QTreeView( this ); view->setModel(model); model->Rebuild(); - view->show(); } StandardPLPanel::~StandardPLPanel() diff --git a/modules/gui/qt4/components/preferences.cpp b/modules/gui/qt4/components/preferences.cpp index fc5c765e2f..e7de207241 100644 --- a/modules/gui/qt4/components/preferences.cpp +++ b/modules/gui/qt4/components/preferences.cpp @@ -23,6 +23,7 @@ #include "components/preferences.hpp" #include "components/preferences_widgets.hpp" +#include "qt4.hpp" #include #include @@ -351,6 +352,7 @@ PrefsPanel::PrefsPanel( intf_thread_t *_p_intf, QWidget *_parent, msg_Warn( p_intf, "unable to create preferences (main not found)"); return; } + if( p_module ) vlc_object_yield( p_module ); vlc_list_release( p_list ); } @@ -398,6 +400,7 @@ PrefsPanel::PrefsPanel( intf_thread_t *_p_intf, QWidget *_parent, QVBoxLayout *boxlayout = NULL; QScrollArea *scroller= new QScrollArea; + scroller->setFrameStyle( QFrame::NoFrame ); QWidget *scrolled_area = new QWidget; QVBoxLayout *layout = new QVBoxLayout(); @@ -420,7 +423,7 @@ PrefsPanel::PrefsPanel( intf_thread_t *_p_intf, QWidget *_parent, box->setLayout( boxlayout ); layout->addWidget( box, 1 ); } - box = new QGroupBox( p_item->psz_text ); + box = new QGroupBox( qfu(p_item->psz_text) ); boxlayout = new QVBoxLayout(); } @@ -450,6 +453,8 @@ PrefsPanel::PrefsPanel( intf_thread_t *_p_intf, QWidget *_parent, layout->addWidget( box, 1 ); } + vlc_object_release( p_module ); + scrolled_area->setSizePolicy( QSizePolicy::Preferred,QSizePolicy::Fixed ); scrolled_area->setLayout( layout ); scroller->setWidget( scrolled_area ); diff --git a/modules/gui/qt4/components/preferences_widgets.cpp b/modules/gui/qt4/components/preferences_widgets.cpp index 7818f0f18d..dc2960e698 100644 --- a/modules/gui/qt4/components/preferences_widgets.cpp +++ b/modules/gui/qt4/components/preferences_widgets.cpp @@ -31,7 +31,7 @@ */ #include "components/preferences_widgets.hpp" - +#include "qt4.hpp" #include #include #include @@ -82,10 +82,10 @@ StringConfigControl::StringConfigControl( vlc_object_t *_p_this, module_config_t *p_item, QWidget *_parent, bool pwd ) : VStringConfigControl( _p_this, p_item, _parent ) { - QLabel *label = new QLabel( p_item->psz_text ); - text = new QLineEdit( p_item->psz_value ); - text->setToolTip( p_item->psz_longtext ); - label->setToolTip( p_item->psz_longtext ); + QLabel *label = new QLabel( qfu(p_item->psz_text) ); + text = new QLineEdit( qfu(p_item->psz_value) ); + text->setToolTip( qfu(p_item->psz_longtext) ); + label->setToolTip( qfu(p_item->psz_longtext) ); QHBoxLayout *layout = new QHBoxLayout(); layout->addWidget( label, 0 ); layout->addWidget( text, 1 ); @@ -105,13 +105,13 @@ ModuleConfigControl::ModuleConfigControl( vlc_object_t *_p_this, vlc_list_t *p_list; module_t *p_parser; - QLabel *label = new QLabel( p_item->psz_text ); + QLabel *label = new QLabel( qfu(p_item->psz_text) ); combo = new QComboBox(); combo->setEditable( false ); /* build a list of available modules */ p_list = vlc_list_find( p_this, VLC_OBJECT_MODULE, FIND_ANYWHERE ); - combo->addItem( "Default" ); + combo->addItem( qtr("Default") ); for( int i_index = 0; i_index < p_list->i_count; i_index++ ) { p_parser = (module_t *)p_list->p_values[i_index].p_object ; @@ -126,7 +126,7 @@ ModuleConfigControl::ModuleConfigControl( vlc_object_t *_p_this, /* Hack: required subcategory is stored in i_min */ if( p_config->i_type == CONFIG_SUBCATEGORY && p_config->i_value == p_item->i_min ) - combo->addItem( p_parser->psz_longname, + combo->addItem( qfu(p_parser->psz_longname), QVariant( p_parser->psz_object_name ) ); if( p_item->psz_value && !strcmp( p_item->psz_value, p_parser->psz_object_name) ) @@ -135,7 +135,7 @@ ModuleConfigControl::ModuleConfigControl( vlc_object_t *_p_this, } else if( !strcmp( p_parser->psz_capability, p_item->psz_type ) ) { - combo->addItem( p_parser->psz_longname, + combo->addItem( qfu(p_parser->psz_longname), QVariant( p_parser->psz_object_name ) ); if( p_item->psz_value && !strcmp( p_item->psz_value, p_parser->psz_object_name) ) @@ -143,8 +143,8 @@ ModuleConfigControl::ModuleConfigControl( vlc_object_t *_p_this, } } vlc_list_release( p_list ); - combo->setToolTip( p_item->psz_longtext ); - label->setToolTip( p_item->psz_longtext ); + combo->setToolTip( qfu(p_item->psz_longtext) ); + label->setToolTip( qfu(p_item->psz_longtext) ); QHBoxLayout *layout = new QHBoxLayout(); layout->addWidget( label ); layout->addWidget( combo ); diff --git a/modules/gui/qt4/dialogs/playlist.cpp b/modules/gui/qt4/dialogs/playlist.cpp index f66ad2bff0..400d5e0d5c 100644 --- a/modules/gui/qt4/dialogs/playlist.cpp +++ b/modules/gui/qt4/dialogs/playlist.cpp @@ -24,15 +24,26 @@ #include "util/qvlcframe.hpp" #include "qt4.hpp" #include "components/playlist/panels.hpp" +#include "components/playlist/selector.hpp" +#include PlaylistDialog *PlaylistDialog::instance = NULL; PlaylistDialog::PlaylistDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf ) { + setWindowTitle( qtr( "Playlist" ) ); playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); - new StandardPLPanel( this, p_intf, p_playlist, p_playlist->p_root_category ); + + QHBoxLayout *layout = new QHBoxLayout(); + selector = new PLSelector( this, p_intf ); + layout->addWidget( selector, 1 ); + + rightPanel = qobject_cast(new StandardPLPanel( this, p_intf, + p_playlist, p_playlist->p_root_category ) ); + layout->addWidget( rightPanel, 3 ); readSettings( "playlist", QSize( 500,500 ) ); + setLayout( layout ); } PlaylistDialog::~PlaylistDialog() diff --git a/modules/gui/qt4/dialogs/playlist.hpp b/modules/gui/qt4/dialogs/playlist.hpp index 6c501f096c..db5c8f25d9 100644 --- a/modules/gui/qt4/dialogs/playlist.hpp +++ b/modules/gui/qt4/dialogs/playlist.hpp @@ -25,6 +25,9 @@ #include "util/qvlcframe.hpp" +class PLSelector; +class PLPanel; + class PlaylistDialog : public QVLCFrame { Q_OBJECT; @@ -38,6 +41,9 @@ public: private: PlaylistDialog( intf_thread_t * ); static PlaylistDialog *instance; + + PLSelector *selector; + PLPanel *rightPanel; public slots: }; diff --git a/modules/gui/qt4/dialogs/prefs_dialog.cpp b/modules/gui/qt4/dialogs/prefs_dialog.cpp index b91d0971a9..27b208eeb3 100644 --- a/modules/gui/qt4/dialogs/prefs_dialog.cpp +++ b/modules/gui/qt4/dialogs/prefs_dialog.cpp @@ -39,10 +39,10 @@ PrefsDialog::PrefsDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf ) { layout = new QHBoxLayout(); QVBoxLayout * main_layout = new QVBoxLayout(); - setWindowTitle( _("Preferences" ) ); + setWindowTitle( qtr("Preferences" ) ); resize( 800, 450 ); - advanced_tree = NULL; + advanced_tree = NULL; simple_tree = NULL; simple_panel = NULL; advanced_panel = NULL; diff --git a/modules/gui/qt4/menus.cpp b/modules/gui/qt4/menus.cpp index 3cf4f599a1..1c4520a426 100644 --- a/modules/gui/qt4/menus.cpp +++ b/modules/gui/qt4/menus.cpp @@ -541,7 +541,7 @@ void QVLCMenu::CreateItem( QMenu *menu, const char *psz_var, if( b_submenu ) { QMenu *submenu = new QMenu(); - submenu->setTitle( QString::fromUtf8( text.psz_string ? + submenu->setTitle( qfu( text.psz_string ? text.psz_string : psz_var ) ); if( CreateChoicesMenu( submenu, psz_var, p_object, true ) == 0) menu->addMenu( submenu ); @@ -552,8 +552,7 @@ void QVLCMenu::CreateItem( QMenu *menu, const char *psz_var, return; } -#define TEXT_OR_VAR QString::fromUtf8 ( text.psz_string ? text.psz_string : \ - psz_var ) +#define TEXT_OR_VAR qfu ( text.psz_string ? text.psz_string : psz_var ) switch( i_type & VLC_VAR_TYPE ) { @@ -620,8 +619,7 @@ int QVLCMenu::CreateChoicesMenu( QMenu *submenu, const char *psz_var, { case VLC_VAR_VARIABLE: CreateChoicesMenu( subsubmenu, CURVAL.psz_string, p_object, false ); - subsubmenu->setTitle( QString::fromUtf8( CURTEXT ? CURTEXT : - CURVAL.psz_string ) ); + subsubmenu->setTitle( qfu( CURTEXT ? CURTEXT :CURVAL.psz_string ) ); submenu->addMenu( subsubmenu ); break; @@ -629,7 +627,7 @@ int QVLCMenu::CreateChoicesMenu( QMenu *submenu, const char *psz_var, var_Get( p_object, psz_var, &val ); another_val.psz_string = strdup( CURVAL.psz_string ); - menutext = CURTEXT ? CURTEXT : another_val.psz_string; + menutext = qfu( CURTEXT ? CURTEXT : another_val.psz_string ); CreateAndConnect( submenu, psz_var, menutext, "", NORMAL_OR_RADIO, p_object->i_object_id, another_val, i_type, NOTCOMMAND && val.psz_string && @@ -640,7 +638,7 @@ int QVLCMenu::CreateChoicesMenu( QMenu *submenu, const char *psz_var, case VLC_VAR_INTEGER: var_Get( p_object, psz_var, &val ); - if( CURTEXT ) menutext = CURTEXT; + if( CURTEXT ) menutext = qfu( CURTEXT ); else menutext.sprintf( "%d", CURVAL.i_int); CreateAndConnect( submenu, psz_var, menutext, "", NORMAL_OR_RADIO, p_object->i_object_id, CURVAL, i_type, @@ -649,7 +647,7 @@ int QVLCMenu::CreateChoicesMenu( QMenu *submenu, const char *psz_var, case VLC_VAR_FLOAT: var_Get( p_object, psz_var, &val ); - if( CURTEXT ) menutext = CURTEXT ; + if( CURTEXT ) menutext = qfu( CURTEXT ); else menutext.sprintf( "%.2f", CURVAL.f_float ); CreateAndConnect( submenu, psz_var, menutext, "", NORMAL_OR_RADIO, p_object->i_object_id, CURVAL, i_type, diff --git a/modules/gui/qt4/qt4.hpp b/modules/gui/qt4/qt4.hpp index cb62bc9894..85d50c5206 100644 --- a/modules/gui/qt4/qt4.hpp +++ b/modules/gui/qt4/qt4.hpp @@ -50,6 +50,7 @@ struct intf_sys_t #define THEDP DialogsProvider::getInstance() #define THEMIM MainInputManager::getInstance( NULL ) +#define qfu( i ) QString::fromUtf8( i ) #define qtr( i ) QString::fromUtf8( _(i) ) static int DialogEvent_Type = QEvent::User + 1; -- 2.39.2