1
/***************************************************************************
2
copyright : (C) 2003 by Arnold Krille
3
email : arnold@arnoldarts.de
4
***************************************************************************/
6
/***************************************************************************
8
* This program is free software; you can redistribute it and/or modify *
9
* it under the terms of the GNU General Public License as published by *
10
* the Free Software Foundation; version 2 of the License. *
12
***************************************************************************/
14
#include "krecconfigure.h"
15
#include "krecconfigure.moc"
17
#include "krecglobal.h"
19
#include <kgenericfactory.h>
22
#include <qbuttongroup.h>
23
#include <qradiobutton.h>
24
#include <qcheckbox.h>
25
#include <qlineedit.h>
28
#include <kapplication.h>
31
#include <kmessagebox.h>
32
#include <kpushbutton.h>
34
typedef KGenericFactory<KRecConfigGeneral, QWidget> KRecConfigGeneralFactory;
35
K_EXPORT_COMPONENT_FACTORY( kcm_krec, KRecConfigGeneralFactory( "krec" ) )
37
KRecConfigGeneral::KRecConfigGeneral( QWidget* p, const char*, const QStringList& s )
38
: KCModule( KRecConfigGeneralFactory::instance(), p, s )
39
, _layout( 0 ), _layout_display( 0 )
41
, _displaybox( 0 ), _framebasebox( 0 )
42
, _display0( 0 ), _display1( 0 ), _display2( 0 ), _display3( 0 )
43
, _framebase30( 0 ), _framebase25( 0 ), _framebase75( 0 ), _framebaseother( 0 )
44
, _framebaseotherbox( 0 ), _framebaseotherlabel( 0 ), _framebaseotherline( 0 )
45
, _displaymode( 0 ), _framebase( 25 )
47
_layout = new QBoxLayout( this, QBoxLayout::TopToBottom );
49
_layout->addSpacing( 10 );
50
_display_title = new QLabel( i18n( "<qt><b>Timedisplay Related Settings</b></qt>" ), this );
51
_layout->addWidget( _display_title, -100 );
53
_layout_display = new QBoxLayout( _layout, QBoxLayout::LeftToRight );
54
_layout->setStretchFactor( _layout_display, -100 );
56
_displaybox = new QButtonGroup( 1, Qt::Horizontal, i18n( "Timedisplay Style" ), this );
57
_layout_display->addWidget( _displaybox, 100 );
58
connect( _displaybox, SIGNAL( clicked( int ) ), this, SLOT( displaychanged( int ) ) );
59
_display0 = new QRadioButton( i18n( "Plain samples" ), _displaybox );
60
_display1 = new QRadioButton( i18n( "[hours:]mins:secs:samples" ), _displaybox );
61
_display2 = new QRadioButton( i18n( "[hours:]mins:secs:frames" ), _displaybox );
62
_display3 = new QRadioButton( i18n( "MByte.KByte" ), _displaybox );
63
_framebasebox = new QButtonGroup( 1, Qt::Horizontal, i18n( "Framebase" ), this );
64
_layout_display->addWidget( _framebasebox, 100 );
65
connect( _framebasebox, SIGNAL( clicked( int ) ), this, SLOT( framebasechanged( int ) ) );
66
_framebase30 = new QRadioButton( i18n( "30 frames per second (American TV)" ), _framebasebox );
67
_framebase25 = new QRadioButton( i18n( "25 frames per second (European TV)" ), _framebasebox );
68
_framebase75 = new QRadioButton( i18n( "75 frames per second (CD)" ), _framebasebox );
69
_framebaseother = new QRadioButton( i18n( "Other" ), _framebasebox );
70
_framebaseotherbox = new QHBox( _framebasebox );
71
_framebaseotherbox->setSpacing( 2 );
72
_framebaseotherlabel = new QLabel( i18n( "Other" ), _framebaseotherbox );
73
_framebaseotherline = new QLineEdit( _framebaseotherbox );
74
_framebaseotherline->setMaxLength( 10 );
75
_framebaseotherbox->setEnabled( false );
76
connect( _framebaseotherline, SIGNAL( textChanged( const QString& ) ), this, SLOT( framebaseotherchanged( const QString& ) ) );
78
_layout->addSpacing( 5 );
79
_verboseDisplayMode = new QCheckBox( i18n( "Show verbose times ( XXmins:XXsecs:XXframes instead of XX:XX::XX )" ), this );
80
connect( _verboseDisplayMode, SIGNAL( toggled( bool ) ), this, SLOT( verboseDisplayChanged( bool ) ) );
81
_layout->addWidget( _verboseDisplayMode );
83
_layout->addSpacing( 10 );
84
_other_title = new QLabel( i18n( "<qt><b>Miscellaneous Settings</b></qt>" ), this );
85
_layout->addWidget( _other_title );
87
_tipofday = new QCheckBox( i18n( "Show tip of the day at startup" ), this );
88
connect( _tipofday, SIGNAL( toggled( bool ) ), this, SLOT( tipofdaychanged( bool ) ) );
89
_layout->addWidget( _tipofday );
90
QBoxLayout* _tmplayout = new QBoxLayout( this, QBoxLayout::LeftToRight );
91
_enableAllMessages = new KPushButton( i18n( "Enable All Hidden Messages" ), this );
92
connect( _enableAllMessages, SIGNAL( clicked() ), this, SLOT( enableallmessagesclicked() ) );
93
_tmplayout->addWidget( _enableAllMessages );
94
QLabel* _tmplbl = new QLabel( i18n( "<qt><i>All messages with the \"Don't show this message again\" option are shown again after selecting this button.</i></qt>" ), this );
95
_tmplayout->addWidget( _tmplbl );
96
_layout->addLayout( _tmplayout );
98
_layout->addStretch( 100 );
103
KRecConfigGeneral::~KRecConfigGeneral() {
106
void KRecConfigGeneral::load() {
107
kdDebug( 60005 ) << k_funcinfo << endl;
109
_displaymode = KRecGlobal::the()->timeFormatMode();
110
switch ( _displaymode % 100 ) {
112
case 0: _display0->setChecked( true ); break;
113
case 1: _display1->setChecked( true ); break;
114
case 2: _display2->setChecked( true ); break;
115
case 3: _display3->setChecked( true ); break;
117
_verboseDisplayMode->setChecked( ( _displaymode / 100 == 1 ) );
119
_framebase = KRecGlobal::the()->frameBase();
120
switch ( _framebase ) {
121
case 30: _framebase30->setChecked( true ); break;
122
case 25: _framebase25->setChecked( true ); break;
123
case 75: _framebase75->setChecked( true ); break;
125
_framebaseother->setChecked( true );
126
_framebaseotherbox->setEnabled( true );
127
_framebaseotherline->setText( QString::number( _framebase ) );
130
kapp->config()->setGroup( "TipOfDay" );
131
_tip = kapp->config()->readBoolEntry( "RunOnStart", true );
132
_tipofday->setChecked( _tip );
135
void KRecConfigGeneral::save() {
136
KRecGlobal::the()->setTimeFormatMode( _displaymode );
137
KRecGlobal::the()->setFrameBase( _framebase );
138
kdDebug(60005) << k_funcinfo << "Framebase=" << _framebase << endl;
140
kapp->config()->setGroup( "TipOfDay" );
141
kapp->config()->writeEntry( "RunOnStart", _tip );
143
kapp->config()->sync();
144
emit changed( false );
147
void KRecConfigGeneral::defaults() {
148
_display0->setChecked( true );
149
_framebase25->setChecked( true );
152
void KRecConfigGeneral::displaychanged( int index ) {
153
int verbose = _displaymode / 100;
154
if ( _displaybox->find( index ) == _display0 ) _displaymode = 0 + verbose * 100;
155
if ( _displaybox->find( index ) == _display1 ) _displaymode = 1 + verbose * 100;
156
if ( _displaybox->find( index ) == _display2 ) _displaymode = 2 + verbose * 100;
157
if ( _displaybox->find( index ) == _display3 ) _displaymode = 3 + verbose * 100;
158
emit changed( true );
160
void KRecConfigGeneral::framebasechanged( int index ) {
161
if ( _framebasebox->find( index ) == _framebase30 ) _framebase = 30;
162
if ( _framebasebox->find( index ) == _framebase25 ) _framebase = 25;
163
if ( _framebasebox->find( index ) == _framebase75 ) _framebase = 75;
164
if ( _framebasebox->find( index ) == _framebaseother ) {
165
_framebaseotherbox->setEnabled( true );
166
_framebase = _framebaseotherline->text().toInt();
167
kdDebug(60005) << k_funcinfo << "Framebase=" << _framebase << endl;
169
_framebaseotherbox->setEnabled( false );
170
emit changed( true );
172
void KRecConfigGeneral::framebaseotherchanged( const QString& text ) {
173
_framebase = text.toInt();
174
kdDebug(60005) << k_funcinfo << "Framebase=" << _framebase << endl;
175
emit changed( true );
177
void KRecConfigGeneral::verboseDisplayChanged( bool n ) {
178
if ( n && _displaymode < 100 ) _displaymode += 100;
179
if ( !n && _displaymode >= 100 ) _displaymode -= 100;
180
emit changed( true );
183
void KRecConfigGeneral::tipofdaychanged( bool n ) {
185
emit changed( true );
188
void KRecConfigGeneral::enableallmessagesclicked() {
189
kdDebug(60005) << k_funcinfo << endl;
190
KMessageBox::enableAllMessages();