From 6cd47c0c574ba95ecb427008a972aa3e4602e5d0 Mon Sep 17 00:00:00 2001 From: Sigmund Augdal Helberg <sigmunau@videolan.org> Date: Sun, 27 Oct 2002 23:10:19 +0000 Subject: [PATCH] * added a simple dialog to show id3-tags and other info * finally added languages/subtitles selections menus, found and got fixed two bugs in kdelibs in the process, but only one of them will get into kde 3.1. * made the location of the ui.rc file configureable, usefull for testing. --- modules/gui/kde/Modules.am | 20 ++- modules/gui/kde/info.cpp | 43 +++++++ modules/gui/kde/info.h | 11 ++ modules/gui/kde/interface.cpp | 211 ++++++++++++++++++++++++++----- modules/gui/kde/interface.h | 21 ++- modules/gui/kde/kde.cpp | 4 +- modules/gui/kde/languagemenu.cpp | 19 +++ modules/gui/kde/languagemenu.h | 16 +++ modules/gui/kde/ui.rc | 18 ++- 9 files changed, 317 insertions(+), 46 deletions(-) create mode 100644 modules/gui/kde/info.cpp create mode 100644 modules/gui/kde/info.h create mode 100644 modules/gui/kde/languagemenu.cpp create mode 100644 modules/gui/kde/languagemenu.h diff --git a/modules/gui/kde/Modules.am b/modules/gui/kde/Modules.am index a690d01bde..dfa5866fbe 100644 --- a/modules/gui/kde/Modules.am +++ b/modules/gui/kde/Modules.am @@ -8,7 +8,9 @@ SOURCES_kde = \ modules/gui/kde/preferences.cpp \ modules/gui/kde/pluginsbox.cpp \ modules/gui/kde/QConfigItem.cpp \ - modules/gui/kde/messages.cpp + modules/gui/kde/messages.cpp \ + modules/gui/kde/info.cpp \ + modules/gui/kde/languagemenu.cpp nodist_SOURCES_kde = \ modules/gui/kde/interface.moc.cpp \ @@ -19,7 +21,9 @@ nodist_SOURCES_kde = \ modules/gui/kde/preferences.moc.cpp \ modules/gui/kde/pluginsbox.moc.cpp \ modules/gui/kde/QConfigItem.moc.cpp \ - modules/gui/kde/messages.moc.cpp + modules/gui/kde/messages.moc.cpp \ + modules/gui/kde/info.moc.cpp \ + modules/gui/kde/languagemenu.moc.cpp noinst_HEADERS += \ modules/gui/kde/common.h \ @@ -31,7 +35,9 @@ noinst_HEADERS += \ modules/gui/kde/pluginsbox.h \ modules/gui/kde/preferences.h \ modules/gui/kde/slider.h \ - modules/gui/kde/messages.h + modules/gui/kde/messages.h \ + modules/gui/kde/info.h \ + modules/gui/kde/languagemenu.h modules/gui/kde/interface.moc.cpp: modules/gui/kde/interface.h $(MOC) $< -o $@ @@ -51,5 +57,11 @@ modules/gui/kde/QConfigItem.moc.cpp: modules/gui/kde/QConfigItem.h $(MOC) $< -o $@ modules/gui/kde/messages.moc.cpp: modules/gui/kde/messages.h $(MOC) $< -o $@ +modules/gui/kde/info.moc.cpp: modules/gui/kde/info.h + $(MOC) $< -o $@ +modules/gui/kde/languagemenu.moc.cpp: modules/gui/kde/languagemenu.h + $(MOC) $< -o $@ + +kdedatadir = $(datadir)\vlc -EXTRA_DIST += modules/gui/kde/ui.rc +dist_kdedata_DATA = modules/gui/kde/ui.rc \ No newline at end of file diff --git a/modules/gui/kde/info.cpp b/modules/gui/kde/info.cpp new file mode 100644 index 0000000000..0bb5ce7aeb --- /dev/null +++ b/modules/gui/kde/info.cpp @@ -0,0 +1,43 @@ +#include "info.h" +#include "common.h" +#include <qtextview.h> +#include <qlayout.h> +#include <qlabel.h> +#include <qvbox.h> + +KInfoWindow::KInfoWindow( intf_thread_t * p_intf, input_thread_t *p_input ) : + KDialogBase( Tabbed, _( "Messages" ), Ok, Ok, 0, 0, false) +{ +// clearWFlags(~0); +// setWFlags(WType_TopLevel); + setSizeGripEnabled(true); + vlc_mutex_lock( &p_input->stream.stream_lock ); + input_info_category_t *p_category = p_input->stream.p_info; + while ( p_category ) + { + QFrame *page = addPage( QString(p_category->psz_name) ); + QVBoxLayout *toplayout = new QVBoxLayout( page); + QVBox *category_table = new QVBox(page); + toplayout->addWidget(category_table); + toplayout->setResizeMode(QLayout::FreeResize); + toplayout->addStretch(10); + category_table->setSpacing(spacingHint()); + input_info_t *p_info = p_category->p_info; + while ( p_info ) + { + QHBox *hb = new QHBox( category_table ); + new QLabel( QString(p_info->psz_name) + ":", hb ); + new QLabel( p_info->psz_value, hb ); + p_info = p_info->p_next; + } + p_category = p_category->p_next; + } + vlc_mutex_unlock( &p_input->stream.stream_lock ); + resize(300,400); + show(); +} + +KInfoWindow::~KInfoWindow() +{ + ; +} diff --git a/modules/gui/kde/info.h b/modules/gui/kde/info.h new file mode 100644 index 0000000000..bacb0a83ea --- /dev/null +++ b/modules/gui/kde/info.h @@ -0,0 +1,11 @@ +#include <kdialogbase.h> +#include "common.h" + +class KInfoWindow : public KDialogBase +{ + Q_OBJECT +public: + KInfoWindow( intf_thread_t*, input_thread_t * ); + ~KInfoWindow(); + +}; diff --git a/modules/gui/kde/interface.cpp b/modules/gui/kde/interface.cpp index 9c65085609..a6767b1b8b 100644 --- a/modules/gui/kde/interface.cpp +++ b/modules/gui/kde/interface.cpp @@ -7,11 +7,13 @@ ***************************************************************************/ #include "disc.h" +#include "info.h" #include "interface.h" #include "net.h" #include "menu.h" #include "slider.h" #include "preferences.h" +#include "languagemenu.h" #include <iostream.h> @@ -38,7 +40,6 @@ KInterface::KInterface( intf_thread_t *p_intf, QWidget *parent, this->p_intf = p_intf; p_messagesWindow = new KMessagesWindow( p_intf, p_intf->p_sys->p_msg ); - p_messagesWindow->show(); fDiskDialog = new KDiskDialog( this ); fNetDialog = new KNetDialog( this ); fTitleMenu = new KTitleMenu( p_intf, this ); @@ -47,14 +48,14 @@ KInterface::KInterface( intf_thread_t *p_intf, QWidget *parent, fSlider->setMaxValue(10000); connect( fSlider, SIGNAL( userChanged( int ) ), this, SLOT( slotSliderMoved( int ) ) ); connect( fSlider, SIGNAL( valueChanged( int ) ), this, SLOT( slotSliderChanged( int ) ) ); + connect( fSlider, SIGNAL( sliderMoved( int ) ), this, SLOT( slotSliderChanged( int ) ) ); setCentralWidget(fSlider); fTimer = new QTimer( this ); connect( fTimer, SIGNAL( timeout() ), this, SLOT( slotManage() ) ); - fTimer->start( 100 ); resize( 400, 30 ); - + msg_Dbg(p_intf, KStdAction::stdName(KStdAction::Preferences)); /////////////////////////////////////////////////////////////////// // call inits to invoke all other construction parts // XXX could we move this up ? @@ -70,8 +71,9 @@ KInterface::KInterface( intf_thread_t *p_intf, QWidget *parent, pause->plug( fTitleMenu ); slow->plug( fTitleMenu ); fast->plug( fTitleMenu ); - fileClose->plug( fTitleMenu ); fileQuit->plug( fTitleMenu ); + fTimer->start( 0, FALSE ); + } KInterface::~KInterface() @@ -81,9 +83,14 @@ KInterface::~KInterface() void KInterface::initActions() { + languages = new KActionMenu( _( "Languages" ), actionCollection(), "language" ); + languages->setEnabled( false ); + languageCollection = new KActionCollection( this ); + subtitleCollection = new KActionCollection( this ); + subtitles = new KActionMenu( _( "Subtitles" ), actionCollection(), "subtitles" ); + subtitles->setEnabled( false ); fileOpen = KStdAction::open(this, SLOT(slotFileOpen()), actionCollection()); fileOpenRecent = KStdAction::openRecent(this, SLOT(slotFileOpenRecent(const KURL&)), actionCollection()); - fileClose = KStdAction::close(this, SLOT(slotFileClose()), actionCollection()); preferences = KStdAction::preferences(this, SLOT(slotShowPreferences()), actionCollection()); fileQuit = KStdAction::quit(this, SLOT(slotFileQuit()), actionCollection()); viewToolBar = KStdAction::showToolbar(this, SLOT(slotViewToolBar()), actionCollection()); @@ -101,9 +108,16 @@ void KInterface::initActions() next = new KAction( i18n( "Next" ), 0, 0, this, SLOT( slotNext() ), actionCollection(), "next" ); messages = new KAction( _( "Messages..." ), 0, 0, this, SLOT( slotShowMessages() ), actionCollection(), "view_messages"); + info = new KAction( _( "Stream info..." ), 0, 0, this, SLOT( slotShowInfo() ), actionCollection(), "view_stream_info"); + + program = new KActionMenu( _( "Program" ), actionCollection(), "program" ); + program->setEnabled( false ); + title = new KActionMenu( _( "Title" ), actionCollection(), "title" ); + title->setEnabled( false ); + chapter = new KActionMenu( _( "Chapter" ), actionCollection(), "chapter" ); + chapter->setEnabled( false ); fileOpen->setStatusText(i18n("Opens an existing document")); fileOpenRecent->setStatusText(i18n("Opens a recently used file")); - fileClose->setStatusText(i18n("Closes the actual document")); fileQuit->setStatusText(i18n("Quits the application")); viewToolBar->setStatusText(i18n("Enables/disables the toolbar")); viewStatusBar->setStatusText(i18n("Enables/disables the statusbar")); @@ -119,8 +133,8 @@ void KInterface::initActions() prev->setStatusText( i18n( "Prev" ) ); next->setStatusText( i18n( "Next" ) ); // use the absolute path to your ktestui.rc file for testing purpose in createGUI(); - - createGUI( DATA_PATH "/ui.rc" ); + char *uifile = config_GetPsz( p_intf, "kdeuirc" ); + createGUI( uifile ); // createGUI( "./modules/gui/kde/ui.rc" ); } @@ -142,6 +156,14 @@ void KInterface::slotShowMessages() p_messagesWindow->show(); } +void KInterface::slotShowInfo() +{ + if ( p_intf->p_sys->p_input ) + { + new KInfoWindow(p_intf, p_intf->p_sys->p_input); + } +} + void KInterface::slotFileOpen() { playlist_t *p_playlist; @@ -172,15 +194,6 @@ void KInterface::slotFileOpenRecent(const KURL& url) slotStatusMsg(i18n("Ready.")); } -void KInterface::slotFileClose() -{ - slotStatusMsg(i18n("Closing file...")); - - close(); - - slotStatusMsg(i18n("Ready.")); -} - void KInterface::slotFileQuit() { slotStatusMsg(i18n("Exiting...")); @@ -239,7 +252,7 @@ void KInterface::slotStatusMsg(const QString &text) void KInterface::slotManage() { p_messagesWindow->update(); - p_intf->p_sys->p_app->processEvents(); +// p_intf->p_sys->p_app->processEvents(); vlc_mutex_lock( &p_intf->change_lock ); /* Update the input */ @@ -261,22 +274,51 @@ void KInterface::slotManage() p_intf->b_menu_change = 0; } - /* Update language/chapter menus after user request */ -#if 0 - if( p_intf->p_sys->p_input != NULL && p_intf->p_sys->p_window != NULL && - p_intf->p_sys->b_menus_update ) + if( p_intf->p_sys->p_input ) { -// GnomeSetupMenu( p_intf ); - } -#endif + input_thread_t *p_input = p_intf->p_sys->p_input; + + vlc_mutex_lock( &p_input->stream.stream_lock ); + if( !p_input->b_die ) + { + /* New input or stream map change */ + if( p_input->stream.b_changed ) + { + // E_(GtkModeManage)( p_intf ); + //GtkSetupMenus( p_intf ); + slotUpdateLanguages(); - /* Manage the slider */ -#define p_area p_intf->p_sys->p_input->stream.p_selected_area - if( p_intf->p_sys->p_input && p_area->i_size ) + p_intf->p_sys->b_playing = 1; + p_input->stream.b_changed = 0; + } + + /* Manage the slider. fSlider->setValue triggers + * slotSliderChanged which needs to grab the stream lock*/ +#define p_area p_input->stream.p_selected_area + if( p_area->i_size ) { + vlc_mutex_unlock( &p_input->stream.stream_lock ); + fSlider->setValue( ( 10000 * p_area->i_tell ) / p_area->i_size ); + vlc_mutex_lock( &p_input->stream.stream_lock ); + + } +#undef p_area + + // if( p_intf->p_sys->i_part != + // p_input->stream.p_selected_area->i_part ) + //{ + // p_intf->p_sys->b_chapter_update = 1; + //GtkSetupMenus( p_intf ); + //} + } + vlc_mutex_unlock( &p_input->stream.stream_lock ); + + } + + else if( p_intf->p_sys->b_playing && !p_intf->b_die ) { - fSlider->setValue( ( 10000. * p_area->i_tell ) / p_area->i_size ); + //E_(GtkModeManage)( p_intf ); + p_intf->p_sys->b_playing = 0; } -#undef p_area if( p_intf->b_die ) { @@ -284,6 +326,7 @@ void KInterface::slotManage() } vlc_mutex_unlock( &p_intf->change_lock ); + msleep( 100 ); } @@ -301,6 +344,114 @@ void KInterface::slotSliderMoved( int position ) } } +void KInterface::slotUpdateLanguages() +{ + + es_descriptor_t * p_spu_es; + es_descriptor_t * p_audio_es; + /* look for selected ES */ + p_audio_es = NULL; + p_spu_es = NULL; + + for( int i = 0 ; i < p_intf->p_sys->p_input->stream.i_selected_es_number ; i++ ) + { + if( p_intf->p_sys->p_input->stream.pp_selected_es[i]->i_cat == AUDIO_ES ) + { + p_audio_es = p_intf->p_sys->p_input->stream.pp_selected_es[i]; + } + + if( p_intf->p_sys->p_input->stream.pp_selected_es[i]->i_cat == SPU_ES ) + { + p_spu_es = p_intf->p_sys->p_input->stream.pp_selected_es[i]; + } + } + languages->setEnabled( false ); + subtitles->setEnabled( false ); + languageCollection->clear(); + subtitleCollection->clear(); + languages->popupMenu()->clear(); + subtitles->popupMenu()->clear(); + /* audio menus */ + /* find audio root menu */ + languageMenus( languages, p_audio_es, AUDIO_ES ); + + /* sub picture menus */ + /* find spu root menu */ + languageMenus( subtitles, p_spu_es, SPU_ES ); + +} + + +/* + * called with stream lock + */ +void KInterface::languageMenus(KActionMenu *root, es_descriptor_t *p_es, + int i_cat) +{ + int i_item = 0; + if ( i_cat != AUDIO_ES ) + { + KLanguageMenuAction *p_item = + new KLanguageMenuAction( p_intf, _( "Off" ), 0, this ); + subtitleCollection->insert( p_item ); + root->insert( p_item ); + root->insert( new KActionSeparator( this ) ); + p_item->setExclusiveGroup( QString().sprintf( "%d", i_cat ) ); + p_item->setChecked( p_es == 0 ); + } + +#define ES p_intf->p_sys->p_input->stream.pp_es[i] + /* create a set of language buttons and append them to the container */ + for( int i = 0 ; i < p_intf->p_sys->p_input->stream.i_es_number ; i++ ) + { + if( ( ES->i_cat == i_cat ) && + ( !ES->p_pgrm || + ES->p_pgrm == + p_intf->p_sys->p_input->stream.p_selected_program ) ) + { + i_item++; + QString name = p_intf->p_sys->p_input->stream.pp_es[i]->psz_desc; + if( name.isEmpty() ) + { + name.sprintf( "Language %d", i_item ); + } + KLanguageMenuAction *p_item; + if ( i_cat == AUDIO_ES ) + { + p_item = new KLanguageMenuAction( p_intf, name, ES, + this ); + languageCollection->insert(p_item); + } + else + { + p_item = new KLanguageMenuAction( p_intf, name, ES, + this ); + subtitleCollection->insert(p_item); + } + p_item->setExclusiveGroup( QString().sprintf( "%d", i_cat ) ); + root->insert( p_item ); + + if( p_es == p_intf->p_sys->p_input->stream.pp_es[i] ) + { + /* don't lose p_item when we append into menu */ + //p_item_active = p_item; + p_item->setChecked( true ); + } + connect( p_item, SIGNAL( toggled( bool, es_descriptor_t * ) ), + this, SLOT( slotSetLanguage( bool, es_descriptor_t * ) )); + + } + } + + root->setEnabled( true ); +} + + +void KInterface::slotSetLanguage( bool on, es_descriptor_t *p_es ) +{ + input_ToggleES( p_intf->p_sys->p_input, p_es, on ); +} + void KInterface::slotSliderChanged( int position ) { if( p_intf->p_sys->p_input != NULL ) diff --git a/modules/gui/kde/interface.h b/modules/gui/kde/interface.h index 66e1568454..1756999558 100644 --- a/modules/gui/kde/interface.h +++ b/modules/gui/kde/interface.h @@ -11,6 +11,7 @@ #include "common.h" +#include <kaction.h> #include <kmainwindow.h> #include <kapplication.h> #include <kurl.h> @@ -44,9 +45,6 @@ class KInterface : public KMainWindow void slotFileOpen(); /** opens a file from the recent files menu */ void slotFileOpenRecent(const KURL& url); - /** asks for saving if the file is modified, then closes the - * actual file and window*/ - void slotFileClose(); /** closes all open windows by calling close() on each * memberList item until the list is empty, then quits the * application. If queryClose() returns false because the @@ -68,6 +66,8 @@ class KInterface : public KMainWindow */ void slotStatusMsg( const QString &text ); void slotShowMessages(); + void slotShowInfo(); + void slotSetLanguage( bool, es_descriptor_t * ); protected: /** initializes the KActions of the application */ @@ -84,11 +84,13 @@ class KInterface : public KMainWindow void slotManage(); /** this slot is called when we drag the position seek bar */ - void slotSliderMoved( int position ); + void slotSliderMoved( int ); /** called every time the slider changes values */ void slotSliderChanged( int position ); + void slotUpdateLanguages(); + void slotOpenDisk(); void slotOpenStream(); @@ -102,6 +104,7 @@ class KInterface : public KMainWindow void slotNext(); private: + void languageMenus( KActionMenu *, es_descriptor_t *, int ); intf_thread_t *p_intf; KMessagesWindow *p_messagesWindow; @@ -125,7 +128,6 @@ class KInterface : public KMainWindow KAction *diskOpen; KAction *streamOpen; KRecentFilesAction *fileOpenRecent; - KAction *fileClose; KAction *fileQuit; KToggleAction *viewToolBar; KToggleAction *viewStatusBar; @@ -139,6 +141,14 @@ class KInterface : public KMainWindow KAction *next; KAction *messages; KAction *preferences; + KAction *info; + KActionMenu *languages; + KActionMenu *subtitles; + KActionCollection *languageCollection; + KActionCollection *subtitleCollection; + KActionMenu *program; + KActionMenu *title; + KActionMenu *chapter; }; /***************************************************************************** @@ -149,6 +159,7 @@ struct intf_sys_t KApplication *p_app; KInterface *p_window; KAboutData *p_about; + int b_playing; input_thread_t *p_input; msg_subscription_t *p_msg; diff --git a/modules/gui/kde/kde.cpp b/modules/gui/kde/kde.cpp index 69aa3271e6..7e1420bbbb 100644 --- a/modules/gui/kde/kde.cpp +++ b/modules/gui/kde/kde.cpp @@ -2,7 +2,7 @@ * kde.cpp : KDE plugin for vlc ***************************************************************************** * Copyright (C) 2001 VideoLAN - * $Id: kde.cpp,v 1.3 2002/10/03 10:15:01 sigmunau Exp $ + * $Id: kde.cpp,v 1.4 2002/10/27 23:10:19 sigmunau Exp $ * * Authors: Andres Krapf <dae@chez.com> Sun Mar 25 2001 * @@ -55,6 +55,8 @@ vlc_module_begin(); #else int i = getenv( "DISPLAY" ) == NULL ? 8 : 85; #endif + add_category_hint( "kde", NULL ); + add_file( "kdeuirc", "", NULL, N_( "Path to ui.rc file" ), NULL ); set_description( _("KDE interface module") ); set_capability( "interface", i ); set_program( "kvlc" ); diff --git a/modules/gui/kde/languagemenu.cpp b/modules/gui/kde/languagemenu.cpp new file mode 100644 index 0000000000..8d05adb582 --- /dev/null +++ b/modules/gui/kde/languagemenu.cpp @@ -0,0 +1,19 @@ +#include "languagemenu.h" + +KLanguageMenuAction::KLanguageMenuAction( intf_thread_t *p_intf, const QString &text, es_descriptor_t * p_es, QObject *parent) : KRadioAction( text,0,parent), p_es(p_es), p_intf(p_intf) +{ + ; +} + +void KLanguageMenuAction::setChecked( bool on ) +{ + if ( on != isChecked() ) + { + emit toggled( on, p_es ); + KRadioAction::setChecked( on ); + } +} + +KLanguageMenuAction::~KLanguageMenuAction() +{ +} diff --git a/modules/gui/kde/languagemenu.h b/modules/gui/kde/languagemenu.h new file mode 100644 index 0000000000..e3ec932db9 --- /dev/null +++ b/modules/gui/kde/languagemenu.h @@ -0,0 +1,16 @@ +#include <kaction.h> +#include "common.h" +class KLanguageMenuAction : public KRadioAction +{ + Q_OBJECT +public: + KLanguageMenuAction(intf_thread_t*, const QString&, es_descriptor_t *, QObject *); + ~KLanguageMenuAction(); +signals: + void toggled( bool, es_descriptor_t *); +public slots: + void setChecked( bool ); +private: + es_descriptor_t *p_es; + intf_thread_t *p_intf; +}; diff --git a/modules/gui/kde/ui.rc b/modules/gui/kde/ui.rc index 6098346cab..a5f8e651c4 100644 --- a/modules/gui/kde/ui.rc +++ b/modules/gui/kde/ui.rc @@ -15,18 +15,24 @@ </ActionProperties> <MenuBar> - <Menu name="file" noMerge="1"> + <Menu name="file"> <text>&File</text> - <Action name="file_open"/> - <Action name="file_open_recent"/> <Action name="open_disk"/> <Action name="open_stream"/> - <Separator lineSeparator="true"/> - <Action name="file_quit"/> </Menu> - <Menu name="view" noMerge="1"> + <Menu name="view"> <text>&View</text> + <Action name="program"/> + <Action name="title"/> + <Action name="chapter"/> + <Separator lineSeparator="true"/> <Action name="view_messages"/> + <Action name="view_stream_info"/> + </Menu> + <Menu name="settings"> + <text>&Settings</text> + <Action name="language"/> + <Action name="subtitles"/> </Menu> </MenuBar> -- 2.25.4