1 /*****************************************************************************
2 * mediainfo.cpp : Information about an item
3 ****************************************************************************
4 * Copyright (C) 2006-2008 the VideoLAN team
6 * Authors: Clément Stenac <zorglub@videolan.org>
7 * Jean-Baptiste Kempf <jb@videolan.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 ******************************************************************************/
28 #include "mediainfo.hpp"
29 #include "player/player_controller.hpp"
34 #include <QGridLayout>
37 #include <QPushButton>
39 /* This Dialog has two main modes:
40 - General Mode that shows the current Played item, and the stats
41 - Single mode that shows the info on ONE SINGLE Item on the playlist
42 Please be Careful of not breaking one the modes behaviour... */
44 MediaInfoDialog::MediaInfoDialog( intf_thread_t
*_p_intf
,
45 input_item_t
*p_item
) :
48 isMainInputInfo
= ( p_item
== NULL
);
50 if ( isMainInputInfo
)
51 setWindowTitle( qtr( "Current Media Information" ) );
53 setWindowTitle( qtr( "Media Information" ) );
54 setWindowRole( "vlc-media-info" );
56 setWindowFlags( Qt::Window
| Qt::CustomizeWindowHint
|
57 Qt::WindowCloseButtonHint
| Qt::WindowMinimizeButtonHint
);
59 /* TabWidgets and Tabs creation */
60 infoTabW
= new QTabWidget
;
62 MP
= new MetaPanel( infoTabW
, p_intf
);
63 infoTabW
->insertTab( META_PANEL
, MP
, qtr( "&General" ) );
64 EMP
= new ExtraMetaPanel( infoTabW
);
65 infoTabW
->insertTab( EXTRAMETA_PANEL
, EMP
, qtr( "&Metadata" ) );
66 IP
= new InfoPanel( infoTabW
);
67 infoTabW
->insertTab( INFO_PANEL
, IP
, qtr( "Co&dec" ) );
70 ISP
= new InputStatsPanel( infoTabW
);
71 infoTabW
->insertTab( INPUTSTATS_PANEL
, ISP
, qtr( "S&tatistics" ) );
74 QGridLayout
*layout
= new QGridLayout( this );
76 /* No need to use a QDialogButtonBox here */
77 saveMetaButton
= new QPushButton( qtr( "&Save Metadata" ) );
78 saveMetaButton
->hide();
79 QPushButton
*closeButton
= new QPushButton( qtr( "&Close" ) );
80 closeButton
->setDefault( true );
82 QLabel
*uriLabel
= new QLabel( qtr( "Location:" ) );
83 uriLine
= new QLineEdit
;
84 uriLine
->setReadOnly( true );
86 layout
->addWidget( infoTabW
, 0, 0, 1, 8 );
87 layout
->addWidget( uriLabel
, 1, 0, 1, 1 );
88 layout
->addWidget( uriLine
, 1, 1, 1, 7 );
89 layout
->addWidget( saveMetaButton
, 2, 6 );
90 layout
->addWidget( closeButton
, 2, 7 );
92 BUTTONACT( closeButton
, close() );
94 /* The tabs buttons are shown in the main dialog for space and cosmetics */
95 BUTTONACT( saveMetaButton
, saveMeta() );
97 /* Let the MetaData Panel update the URI */
98 CONNECT( MP
, uriSet( const QString
& ), this, updateURI( const QString
& ) );
99 CONNECT( MP
, editing(), saveMetaButton
, show() );
101 /* Display the buttonBar according to the Tab selected */
102 CONNECT( infoTabW
, currentChanged( int ), this, updateButtons( int ) );
104 /* If using the General Mode */
105 if( isMainInputInfo
)
107 msg_Dbg( p_intf
, "Using a general info windows" );
109 * Connects on the various signals of input_Manager
110 * For the currently playing element
112 connect( THEMIM
, &PlayerController::infoChanged
,
113 IP
, &InfoPanel::update
, Qt::DirectConnection
);
114 connect( THEMIM
, &PlayerController::currentMetaChanged
,
115 MP
, &MetaPanel::update
, Qt::DirectConnection
);
116 connect( THEMIM
, &PlayerController::currentMetaChanged
,
117 EMP
, &ExtraMetaPanel::update
, Qt::DirectConnection
);
118 connect( THEMIM
, &PlayerController::statisticsUpdated
,
119 ISP
, &InputStatsPanel::update
, Qt::DirectConnection
);
121 p_item
= THEMIM
->getInput();
124 msg_Dbg( p_intf
, "Using an item specific info windows" );
126 /* Call update at start, so info is filled up at begginning */
128 updateAllTabs( p_item
);
130 restoreWidgetPosition( "Mediainfo", QSize( 600 , 480 ) );
133 MediaInfoDialog::~MediaInfoDialog()
135 saveWidgetPosition( "Mediainfo" );
138 void MediaInfoDialog::showTab( panel i_tab
= META_PANEL
)
140 infoTabW
->setCurrentIndex( i_tab
);
144 int MediaInfoDialog::currentTab()
146 return infoTabW
->currentIndex();
149 void MediaInfoDialog::saveMeta()
152 saveMetaButton
->hide();
155 void MediaInfoDialog::updateAllTabs( input_item_t
*p_item
)
160 IP
->update( p_item
);
161 MP
->update( p_item
);
162 EMP
->update( p_item
);
164 if( isMainInputInfo
&& p_item
->p_stats
) ISP
->update( *p_item
->p_stats
);
167 void MediaInfoDialog::clearAllTabs()
173 if( isMainInputInfo
) ISP
->clear();
176 void MediaInfoDialog::close()
180 /* if dialog is closed, revert editing if not saved */
181 if( MP
->isInEditMode() )
183 MP
->setEditMode( false );
187 if( !isMainInputInfo
)
191 void MediaInfoDialog::updateButtons( int i_tab
)
193 if( MP
->isInEditMode() && i_tab
== 0 )
194 saveMetaButton
->show();
196 saveMetaButton
->hide();
199 void MediaInfoDialog::updateURI( const QString
& uri
)
203 /* If URI points to a local file, show the path instead of the URI */
204 char *path
= vlc_uri2path( qtu( uri
) );
207 location
= qfu( path
);
213 uriLine
->setText( location
);