@ -18,7 +18,6 @@
# include <kurldrag.h>
# include <kurldrag.h>
# include <twin.h>
# include <twin.h>
# include <tqcstring.h>
# include <tqcstring.h>
# include <tqdesktopwidget.h>
# include <tqevent.h> //::stateChanged()
# include <tqevent.h> //::stateChanged()
# include <tqlayout.h> //ctor
# include <tqlayout.h> //ctor
# include <tqpopupmenu.h> //because XMLGUI is poorly designed
# include <tqpopupmenu.h> //because XMLGUI is poorly designed
@ -48,6 +47,9 @@ extern "C"
}
}
# endif
# endif
constexpr auto kAspectSelectActionName = " aspect_ratio_select " ;
constexpr auto kAudioSelectActionName = " audio_channels_select " ;
constexpr auto kSubtitleSelectActionName = " subtitle_channels_select " ;
namespace Codeine {
namespace Codeine {
@ -116,27 +118,27 @@ MainWindow::MainWindow()
}
}
{
{
TQPopupMenu * menu = nullptr ;
/* Disable aspect/channel menus until the stream has loaded;
TQPopupMenu * settings = static_cast < TQPopupMenu * > ( factory ( ) - > container ( " settings " , this ) ) ;
* Make sure they have the same default item selected . */
int id = SubtitleChannelsMenuItemId , index = 0 ;
TQStringList defaultItems ( " &Determine Automatically " ) ;
if ( const auto aspectAction = dynamic_cast < TDESelectAction * > ( action ( kAspectSelectActionName ) ) )
# define make_menu( name, text ) \
{
menu = new TQPopupMenu ( this , name ) ; \
aspectAction - > setToolTip ( i18n ( " Aspect Ratio " ) ) ;
menu - > setCheckable ( true ) ; \
insertAspectRatioMenuItems ( aspectAction ) ;
connect ( menu , TQ_SIGNAL ( activated ( int ) ) , engine ( ) , TQ_SLOT ( setStreamParameter ( int ) ) ) ; \
aspectAction - > setEnabled ( false ) ;
connect ( menu , TQ_SIGNAL ( aboutToShow ( ) ) , TQ_SLOT ( aboutToShowMenu ( ) ) ) ; \
}
settings - > insertItem ( text , menu , id , index ) ; \
if ( const auto audioChannelAction = dynamic_cast < TDESelectAction * > ( action ( kAudioSelectActionName ) ) )
settings - > setItemEnabled ( id , false ) ; \
{
id + + , index + + ;
audioChannelAction - > setToolTip ( i18n ( " Audio Channels " ) ) ;
audioChannelAction - > setItems ( defaultItems ) ;
make_menu ( " subtitle_channels_menu " , i18n ( " &Subtitles " ) ) ;
audioChannelAction - > setEnabled ( false ) ;
make_menu ( " audio_channels_menu " , i18n ( " A&udio Channels " ) ) ;
}
make_menu ( " aspect_ratio_menu " , i18n ( " Aspect &Ratio " ) ) ;
if ( const auto subChannelAction = dynamic_cast < TDESelectAction * > ( action ( kSubtitleSelectActionName ) ) )
# undef make_menu
{
subChannelAction - > setToolTip ( i18n ( " Subtitles " ) ) ;
Codeine : : insertAspectRatioMenuItems ( menu ) ; //so we don't have to include xine.h here
subChannelAction - > setItems ( defaultItems ) ;
subChannelAction - > setEnabled ( false ) ;
settings - > insertSeparator ( index ) ;
}
}
}
TQObjectList * list = toolBar ( ) - > queryList ( " TDEToolBarButton " ) ;
TQObjectList * list = toolBar ( ) - > queryList ( " TDEToolBarButton " ) ;
@ -171,10 +173,14 @@ MainWindow::init()
connect ( engine ( ) , TQ_SIGNAL ( statusMessage ( const TQString & ) ) , this , TQ_SLOT ( engineMessage ( const TQString & ) ) ) ;
connect ( engine ( ) , TQ_SIGNAL ( statusMessage ( const TQString & ) ) , this , TQ_SLOT ( engineMessage ( const TQString & ) ) ) ;
connect ( engine ( ) , TQ_SIGNAL ( stateChanged ( Engine : : State ) ) , this , TQ_SLOT ( engineStateChanged ( Engine : : State ) ) ) ;
connect ( engine ( ) , TQ_SIGNAL ( stateChanged ( Engine : : State ) ) , this , TQ_SLOT ( engineStateChanged ( Engine : : State ) ) ) ;
connect ( engine ( ) , TQ_SIGNAL ( channelsChanged ( const TQStringList & ) ) , this , TQ_SLOT ( setChannels ( const TQStringList & ) ) ) ;
connect ( engine ( ) , TQ_SIGNAL ( titleChanged ( const TQString & ) ) , m_titleLabel , TQ_SLOT ( setText ( const TQString & ) ) ) ;
connect ( engine ( ) , TQ_SIGNAL ( titleChanged ( const TQString & ) ) , m_titleLabel , TQ_SLOT ( setText ( const TQString & ) ) ) ;
connect ( m_positionSlider , TQ_SIGNAL ( valueChanged ( int ) ) , this , TQ_SLOT ( showTime ( int ) ) ) ;
connect ( m_positionSlider , TQ_SIGNAL ( valueChanged ( int ) ) , this , TQ_SLOT ( showTime ( int ) ) ) ;
connect ( engine ( ) , TQ_SIGNAL ( audioChannelsChanged ( const TQStringList & ) ) ,
this , TQ_SLOT ( setAudioChannels ( const TQStringList & ) ) ) ;
connect ( engine ( ) , TQ_SIGNAL ( subtitleChannelsChanged ( const TQStringList & ) ) ,
this , TQ_SLOT ( setSubtitleChannels ( const TQStringList & ) ) ) ;
if ( ! engine ( ) - > init ( ) ) {
if ( ! engine ( ) - > init ( ) ) {
KMessageBox : : error ( this , i18n (
KMessageBox : : error ( this , i18n (
" <qt>xine could not be successfully initialised. " PRETTY_NAME " will now exit. "
" <qt>xine could not be successfully initialised. " PRETTY_NAME " will now exit. "
@ -266,6 +272,15 @@ MainWindow::setupActions()
( new KWidgetAction ( m_positionSlider , i18n ( " Position Slider " ) , nullptr , nullptr , nullptr , ac , " position_slider " ) ) - > setAutoSized ( true ) ;
( new KWidgetAction ( m_positionSlider , i18n ( " Position Slider " ) , nullptr , nullptr , nullptr , ac , " position_slider " ) ) - > setAutoSized ( true ) ;
const auto audioSelectAction = new TDESelectAction ( i18n ( " A&udio Channels " ) , 0 , ac , kAudioSelectActionName ) ;
connect ( audioSelectAction , TQ_SIGNAL ( activated ( int ) ) , engine ( ) , TQ_SLOT ( setStreamParameter ( int ) ) ) ;
const auto subSelectAction = new TDESelectAction ( i18n ( " &Subtitles " ) , 0 , ac , kSubtitleSelectActionName ) ;
connect ( subSelectAction , TQ_SIGNAL ( activated ( int ) ) , engine ( ) , TQ_SLOT ( setStreamParameter ( int ) ) ) ;
const auto aspectSelectAction = new TDESelectAction ( i18n ( " Aspect &Ratio " ) , 0 , ac , kAspectSelectActionName ) ;
connect ( aspectSelectAction , TQ_SIGNAL ( activated ( int ) ) , engine ( ) , TQ_SLOT ( setStreamParameter ( int ) ) ) ;
m_volumeAction = new VolumeAction ( toolBar ( ) , ac ) ;
m_volumeAction = new VolumeAction ( toolBar ( ) , ac ) ;
}
}
@ -594,54 +609,49 @@ MainWindow::streamInformation()
}
}
void
void
MainWindow : : set Channels( const TQStringList & channels )
MainWindow : : set Audio Channels( const TQStringList & channels ) const
{
{
DEBUG_FUNC_INFO
DEBUG_FUNC_INFO
//TODO -1 = auto
/* Xine uses -1 and -2 to indicate that a channel should be determined automatically or
* turned off . TDESelectAction inserts items starting from index 0 , so we add 2 to the
TQStringList : : ConstIterator it = channels . begin ( ) ;
* channel returned from TheStream to match . */
TQPopupMenu * menu = ( TQPopupMenu * ) child ( ( * it ) . latin1 ( ) ) ;
menu - > clear ( ) ;
menu - > insertItem ( i18n ( " &Determine Automatically " ) , 1 ) ;
if ( const auto audioSelection = dynamic_cast < TDESelectAction * > ( action ( kAudioSelectActionName ) ) )
menu - > insertSeparator ( ) ;
{
TQStringList audioChannels ( channels ) ;
//the id is crucial, since the slot this menu is connected to requires
audioChannels . prepend ( " &Determine Automatically " ) ;
//that information to set the correct channel
audioChannels . prepend ( " &Off " ) ;
//NOTE we subtract 2 in xineEngine because TQMenuData doesn't allow negative id
audioSelection - > setItems ( audioChannels ) ;
int id = 2 ;
audioSelection - > popupMenu ( ) - > insertSeparator ( 2 ) ;
+ + it ;
audioSelection - > setCurrentItem ( TheStream : : audioChannel ( ) + 2 ) ;
for ( TQStringList : : ConstIterator const end = channels . end ( ) ; it ! = end ; + + it , + + id )
audioSelection - > setEnabled ( channels . count ( ) ) ;
menu - > insertItem ( * it , id ) ;
}
else
menu - > insertSeparator ( ) ;
{
menu - > insertItem ( i18n ( " &Off " ) , 0 ) ;
Debug : : error ( ) < < " Failed to update the audio channels (selection menu not found) " < < endl ;
}
id = channels . first ( ) = = " subtitle_channels_menu " ? SubtitleChannelsMenuItemId : AudioChannelsMenuItemId ;
MainWindow : : menu ( " settings " ) - > setItemEnabled ( id , channels . count ( ) > 1 ) ;
}
}
void
void
MainWindow : : aboutToShowMenu( )
MainWindow : : setSubtitleChannels( const TQStringList & channels ) const
{
{
TQPopupMenu * menu = ( TQPopupMenu * ) sender ( ) ;
DEBUG_FUNC_INFO
TQCString name ( sender ( ) ? sender ( ) - > name ( ) : nullptr ) ;
// uncheck all items first
for ( uint x = 0 ; x < menu - > count ( ) ; + + x )
menu - > setItemChecked ( menu - > idAt ( x ) , false ) ;
int id ;
if ( const auto subSelection = dynamic_cast < TDESelectAction * > ( action ( kSubtitleSelectActionName ) ) )
if ( name = = " subtitle_channels_menu " )
{
id = TheStream : : subtitleChannel ( ) + 2 ;
TQStringList subChannels ( channels ) ;
else if ( name = = " audio_channels_menu " )
subChannels . prepend ( " &Determine Automatically " ) ;
id = TheStream : : audioChannel ( ) + 2 ;
subChannels . prepend ( " &Off " ) ;
subSelection - > setItems ( subChannels ) ;
subSelection - > popupMenu ( ) - > insertSeparator ( 2 ) ;
subSelection - > setCurrentItem ( TheStream : : subtitleChannel ( ) + 2 ) ;
subSelection - > setEnabled ( channels . count ( ) ) ;
}
else
else
id = TheStream : : aspectRatio ( ) ;
{
Debug : : error ( ) < < " Failed to update the subtitle channels (selection menu not found) " < < endl ;
menu - > setItemChecked ( id , true ) ;
}
}
}
void
void
@ -682,10 +692,10 @@ MainWindow::keyPressEvent( TQKeyEvent *e )
}
}
TQPopupMenu *
TQPopupMenu *
MainWindow : : menu ( const char * name )
MainWindow : : menu ( const TQString & name )
{
{
// KXMLGUI is "really good".
// KXMLGUI is "really good".
return stat ic_cast< TQPopupMenu * > ( factory ( ) - > container ( name , this ) ) ;
return dynam ic_cast< TQPopupMenu * > ( factory ( ) - > container ( name , this ) ) ;
}
}