]> git.sesse.net Git - vlc/blob - modules/gui/qt4/dialogs/gototime.cpp
String updates ( some are meant to match the macosx interface and simplify translator...
[vlc] / modules / gui / qt4 / dialogs / gototime.cpp
1 /*****************************************************************************
2  * GotoTime.cpp : GotoTime and About dialogs
3  ****************************************************************************
4  * Copyright (C) 2007 the VideoLAN team
5  * $Id$
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 #ifdef HAVE_CONFIG_H
24 # include "config.h"
25 #endif
26
27 #include "dialogs/gototime.hpp"
28
29 #include "dialogs_provider.hpp"
30 #include "main_interface.hpp"
31 #include "input_manager.hpp"
32
33 #include <QTabWidget>
34 #include <QFile>
35 #include <QLabel>
36 #include <QTimeEdit>
37 #include <QGroupBox>
38 #include <QDialogButtonBox>
39
40 GotoTimeDialog *GotoTimeDialog::instance = NULL;
41
42 GotoTimeDialog::GotoTimeDialog( QWidget *parent, intf_thread_t *_p_intf)
43                : QVLCDialog( parent, _p_intf )
44 {
45     setWindowFlags( Qt::Tool );
46     setWindowTitle( qtr( "Go to time" ) );
47
48     QGridLayout *mainLayout = new QGridLayout( this );
49     mainLayout->setSizeConstraint( QLayout::SetFixedSize );
50
51     QPushButton *gotoButton = new QPushButton( qtr( "&Go" ) );
52     QPushButton *cancelButton = new QPushButton( qtr( "&Cancel" ) );
53     QDialogButtonBox *buttonBox = new QDialogButtonBox;
54
55     gotoButton->setDefault( true );
56     buttonBox->addButton( gotoButton, QDialogButtonBox::AcceptRole );
57     buttonBox->addButton( cancelButton, QDialogButtonBox::RejectRole );
58
59     QGroupBox *timeGroupBox = new QGroupBox;
60     QGridLayout *boxLayout = new QGridLayout( timeGroupBox );
61
62     QLabel *timeIntro = new QLabel( qtr( "Go to time" ) + ":" );
63     timeIntro->setWordWrap( true );
64     timeIntro->setAlignment( Qt::AlignCenter );
65
66     timeEdit = new QTimeEdit();
67     timeEdit->setDisplayFormat( "hh : mm : ss" );
68     timeEdit->setAlignment( Qt::AlignRight );
69     timeEdit->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum );
70
71     QLabel *helpFormat = new QLabel( timeEdit->displayFormat() );
72     helpFormat->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Preferred );
73
74     QSpacerItem *spacerBox = new QSpacerItem( 20, 10, QSizePolicy::Minimum,
75                                         QSizePolicy::Fixed );
76
77     QSpacerItem *spacerItem = new QSpacerItem( 20, 3, QSizePolicy::Minimum,
78                                         QSizePolicy::Expanding );
79
80     boxLayout->addWidget( timeIntro, 0, 0, 1, 2 );
81     boxLayout->addItem( spacerBox, 1, 0, 1, 2 );
82     boxLayout->addWidget( timeEdit, 2, 0, 1, 1 );
83     boxLayout->addWidget( helpFormat, 2, 1, 1, 1 );
84
85     mainLayout->addWidget( timeGroupBox, 0, 0, 1, 4 );
86     mainLayout->addItem( spacerItem, 1, 0 );
87     mainLayout->addWidget( buttonBox, 2, 3 );
88
89     BUTTONACT( gotoButton, close() );
90     BUTTONACT( cancelButton, cancel() );
91 }
92
93 GotoTimeDialog::~GotoTimeDialog()
94 {
95 }
96
97 void GotoTimeDialog::cancel()
98 {
99     timeEdit->setTime( QTime( 0, 0, 0) );
100     toggleVisible();
101 }
102
103 void GotoTimeDialog::close()
104 {
105     if ( THEMIM->getIM()->hasInput() )
106     {
107         int64_t i_time = (int64_t)
108             ( QTime( 0, 0, 0 ).msecsTo( timeEdit->time() ) ) * 1000;
109         var_SetTime( THEMIM->getInput(), "time", i_time );
110     }
111     toggleVisible();
112     timeEdit->setTime( QTime( 0, 0, 0) );
113 }