]> git.sesse.net Git - vlc/blob - modules/gui/qt4/dialogs/gototime.cpp
Qt4 - Set a higher score to qt4 than wx. Ref [19766]
[vlc] / modules / gui / qt4 / dialogs / gototime.cpp
1 /*****************************************************************************
2  * GotoTime.cpp : GotoTime and About dialogs
3  ****************************************************************************
4  * Copyright (C) 2006-2007 the VideoLAN team
5  * $Id: Messages.cpp 16024 2006-07-13 13:51:05Z xtophe $
6  *
7  * Authors: Jean-Baptiste Kempf <jb (at) videolan.org>
8  *
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.
13  *
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.
18  *
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  *****************************************************************************/
23
24 #include "dialogs/gototime.hpp"
25
26 #include "dialogs_provider.hpp"
27 #include "main_interface.hpp"
28 #include "util/qvlcframe.hpp"
29 #include "qt4.hpp"
30 #include "input_manager.hpp"
31
32 #include <QTabWidget>
33 #include <QFile>
34 #include <QLabel>
35 #include <QTimeEdit>
36 #include <QGroupBox>
37 #include <QDialogButtonBox>
38
39 GotoTimeDialog *GotoTimeDialog::instance = NULL;
40
41 GotoTimeDialog::GotoTimeDialog( intf_thread_t *_p_intf) :  QVLCFrame( _p_intf )
42 {
43     setWindowTitle( qtr( "Go to Time" ) );
44     resize( 250, 180 );
45
46     QGridLayout *mainLayout = new QGridLayout( this );
47
48     QPushButton *gotoButton = new QPushButton( qtr( "&Go" ) );
49     QPushButton *cancelButton = new QPushButton( qtr( "&Cancel" ) );
50     QDialogButtonBox *buttonBox = new QDialogButtonBox;
51
52     gotoButton->setDefault( true );
53     buttonBox->addButton( gotoButton, QDialogButtonBox::AcceptRole );
54     buttonBox->addButton( cancelButton, QDialogButtonBox::RejectRole );
55
56     QGroupBox *timeGroupBox = new QGroupBox( "Time" );
57     QGridLayout *boxLayout = new QGridLayout( timeGroupBox );
58
59     QLabel *timeIntro = new
60         QLabel( "Enter below the desired time you want to go in the media." );
61     timeIntro->setWordWrap( true );
62     timeIntro->setAlignment( Qt::AlignCenter );
63
64     timeEdit = new QTimeEdit();
65     timeEdit->setDisplayFormat( "hh : mm : ss" );
66     timeEdit->setAlignment( Qt::AlignRight );
67     timeEdit->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum );
68
69     QLabel *helpFormat = new QLabel( timeEdit->displayFormat() );
70     helpFormat->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Preferred );
71
72     QSpacerItem *spacerBox = new QSpacerItem(20, 10, QSizePolicy::Minimum,
73                                         QSizePolicy::Fixed);
74
75     QSpacerItem *spacerItem = new QSpacerItem(20, 5, QSizePolicy::Minimum,
76                                         QSizePolicy::Expanding);
77
78     boxLayout->addWidget( timeIntro, 0, 0, 1, 2 );
79     boxLayout->addItem( spacerBox, 1, 0, 1, 2 );
80     boxLayout->addWidget( timeEdit, 2, 0, 1, 1 );
81     boxLayout->addWidget( helpFormat, 2, 1, 1, 1 );
82
83     mainLayout->addWidget( timeGroupBox, 0, 0, 1, 4 );
84     mainLayout->addItem( spacerItem, 1, 0 );
85     mainLayout->addWidget( buttonBox, 2, 3 );
86
87     BUTTONACT( gotoButton, close() );
88     BUTTONACT( cancelButton, cancel() );
89 }
90
91 GotoTimeDialog::~GotoTimeDialog()
92 {
93 }
94
95 void GotoTimeDialog::cancel()
96 {
97     timeEdit->setTime( QTime( 0, 0, 0) );
98     this->toggleVisible();
99 }
100
101 void GotoTimeDialog::close()
102 {
103     if ( THEMIM->getIM()->hasInput() )
104     {
105         int64_t i_time = (int64_t)
106             ( QTime( 0, 0, 0 ).msecsTo( timeEdit->time() ) ) * 1000;
107         var_SetTime( THEMIM->getInput(), "time", i_time );
108     }
109     this->toggleVisible();
110 }