1 /*****************************************************************************
2 * GotoTime.cpp : GotoTime and About dialogs
3 ****************************************************************************
4 * Copyright (C) 2007 the VideoLAN team
7 * Authors: Jean-Baptiste Kempf <jb (at) 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 *****************************************************************************/
27 #include "dialogs/gototime.hpp"
29 #include "input_manager.hpp"
35 #include <QDialogButtonBox>
37 GotoTimeDialog *GotoTimeDialog::instance = NULL;
39 GotoTimeDialog::GotoTimeDialog( QWidget *parent, intf_thread_t *_p_intf)
40 : QVLCDialog( parent, _p_intf )
42 setWindowFlags( Qt::Tool );
43 setWindowTitle( qtr( "Go to Time" ) );
45 QGridLayout *mainLayout = new QGridLayout( this );
46 mainLayout->setSizeConstraint( QLayout::SetFixedSize );
48 QPushButton *gotoButton = new QPushButton( qtr( "&Go" ) );
49 QPushButton *cancelButton = new QPushButton( qtr( "&Cancel" ) );
50 QDialogButtonBox *buttonBox = new QDialogButtonBox;
52 gotoButton->setDefault( true );
53 buttonBox->addButton( gotoButton, QDialogButtonBox::AcceptRole );
54 buttonBox->addButton( cancelButton, QDialogButtonBox::RejectRole );
56 QGroupBox *timeGroupBox = new QGroupBox;
57 QGridLayout *boxLayout = new QGridLayout( timeGroupBox );
59 QLabel *timeIntro = new QLabel( qtr( "Go to time" ) + ":" );
60 timeIntro->setWordWrap( true );
61 timeIntro->setAlignment( Qt::AlignCenter );
63 timeEdit = new QTimeEdit();
64 timeEdit->setDisplayFormat( "hh : mm : ss" );
65 timeEdit->setAlignment( Qt::AlignRight );
66 timeEdit->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum );
68 QLabel *helpFormat = new QLabel( timeEdit->displayFormat() );
69 helpFormat->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Preferred );
71 QSpacerItem *spacerBox = new QSpacerItem( 20, 10, QSizePolicy::Minimum,
74 QSpacerItem *spacerItem = new QSpacerItem( 20, 3, QSizePolicy::Minimum,
75 QSizePolicy::Expanding );
77 boxLayout->addWidget( timeIntro, 0, 0, 1, 2 );
78 boxLayout->addItem( spacerBox, 1, 0, 1, 2 );
79 boxLayout->addWidget( timeEdit, 2, 0, 1, 1 );
80 boxLayout->addWidget( helpFormat, 2, 1, 1, 1 );
82 mainLayout->addWidget( timeGroupBox, 0, 0, 1, 4 );
83 mainLayout->addItem( spacerItem, 1, 0 );
84 mainLayout->addWidget( buttonBox, 2, 3 );
86 BUTTONACT( gotoButton, close() );
87 BUTTONACT( cancelButton, cancel() );
90 GotoTimeDialog::~GotoTimeDialog()
94 void GotoTimeDialog::cancel()
96 timeEdit->setTime( QTime( 0, 0, 0) );
100 void GotoTimeDialog::close()
102 if ( THEMIM->getIM()->hasInput() )
104 int64_t i_time = (int64_t)
105 ( QTime( 0, 0, 0 ).msecsTo( timeEdit->time() ) ) * 1000;
106 var_SetTime( THEMIM->getInput(), "time", i_time );
109 timeEdit->setTime( QTime( 0, 0, 0) );