summaryrefslogtreecommitdiffstats
path: root/krec/krecconfigure.cpp
blob: 633409f5e07143a1eab57261a9a85d3751465401 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
/***************************************************************************
    copyright            : (C) 2003 by Arnold Krille
    email                : arnold@arnoldarts.de
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; version 2 of the License.               *
 *                                                                         *
 ***************************************************************************/

#include "krecconfigure.h"
#include "krecconfigure.moc"

#include "krecglobal.h"

#include <kgenericfactory.h>
#include <kdebug.h>
#include <tqlayout.h>
#include <tqbuttongroup.h>
#include <tqradiobutton.h>
#include <tqcheckbox.h>
#include <tqlineedit.h>
#include <tqhbox.h>
#include <tqlabel.h>
#include <kapplication.h>
#include <kconfig.h>
#include <klocale.h>
#include <kmessagebox.h>
#include <kpushbutton.h>

typedef KGenericFactory<KRecConfigGeneral, TQWidget> KRecConfigGeneralFactory;
K_EXPORT_COMPONENT_FACTORY( kcm_krec, KRecConfigGeneralFactory( "krec" ) )

KRecConfigGeneral::KRecConfigGeneral( TQWidget* p, const char*, const TQStringList& s )
 : TDECModule( KRecConfigGeneralFactory::instance(), p, s )
 , _layout( 0 ), _layout_display( 0 )
 , _display_title( 0 )
 , _displaybox( 0 ), _framebasebox( 0 )
 , _display0( 0 ), _display1( 0 ), _display2( 0 ), _display3( 0 )
 , _framebase30( 0 ), _framebase25( 0 ), _framebase75( 0 ), _framebaseother( 0 )
 , _framebaseotherbox( 0 ), _framebaseotherlabel( 0 ), _framebaseotherline( 0 )
 , _displaymode( 0 ), _framebase( 25 )
{
	_layout = new TQBoxLayout( this, TQBoxLayout::TopToBottom );

	_layout->addSpacing( 10 );
	_display_title = new TQLabel( i18n( "<qt><b>Timedisplay Related Settings</b></qt>" ), this );
	_layout->addWidget( _display_title, -100 );

	_layout_display = new TQBoxLayout( _layout, TQBoxLayout::LeftToRight );
	_layout->setStretchFactor( _layout_display, -100 );

	_displaybox = new TQButtonGroup( 1, Qt::Horizontal, i18n( "Timedisplay Style" ), this );
	_layout_display->addWidget( _displaybox, 100 );
	connect( _displaybox, TQT_SIGNAL( clicked( int ) ), this, TQT_SLOT( displaychanged( int ) ) );
	_display0 = new TQRadioButton( i18n( "Plain samples" ), _displaybox );
	_display1 = new TQRadioButton( i18n( "[hours:]mins:secs:samples" ), _displaybox );
	_display2 = new TQRadioButton( i18n( "[hours:]mins:secs:frames" ), _displaybox );
	_display3 = new TQRadioButton( i18n( "MByte.KByte" ), _displaybox );
	_framebasebox = new TQButtonGroup( 1, Qt::Horizontal, i18n( "Framebase" ), this );
	_layout_display->addWidget( _framebasebox, 100 );
	connect( _framebasebox, TQT_SIGNAL( clicked( int ) ), this, TQT_SLOT( framebasechanged( int ) ) );
	_framebase30 = new TQRadioButton( i18n( "30 frames per second (American TV)" ), _framebasebox );
	_framebase25 = new TQRadioButton( i18n( "25 frames per second (European TV)" ), _framebasebox );
	_framebase75 = new TQRadioButton( i18n( "75 frames per second (CD)" ), _framebasebox );
	_framebaseother = new TQRadioButton( i18n( "Other" ), _framebasebox );
	_framebaseotherbox = new TQHBox( _framebasebox );
	_framebaseotherbox->setSpacing( 2 );
	_framebaseotherlabel = new TQLabel( i18n( "Other" ), _framebaseotherbox );
	_framebaseotherline = new TQLineEdit( _framebaseotherbox );
	_framebaseotherline->setMaxLength( 10 );
	_framebaseotherbox->setEnabled( false );
	connect( _framebaseotherline, TQT_SIGNAL( textChanged( const TQString& ) ), this, TQT_SLOT( framebaseotherchanged( const TQString& ) ) );

	_layout->addSpacing( 5 );
	_verboseDisplayMode = new TQCheckBox( i18n( "Show verbose times ( XXmins:XXsecs:XXframes instead of XX:XX::XX )" ), this );
	connect( _verboseDisplayMode, TQT_SIGNAL( toggled( bool ) ), this, TQT_SLOT( verboseDisplayChanged( bool ) ) );
	_layout->addWidget( _verboseDisplayMode );

	_layout->addSpacing( 10 );
	_other_title = new TQLabel( i18n( "<qt><b>Miscellaneous Settings</b></qt>" ), this );
	_layout->addWidget( _other_title );

	_tipofday = new TQCheckBox( i18n( "Show tip of the day at startup" ), this );
	connect( _tipofday, TQT_SIGNAL( toggled( bool ) ), this, TQT_SLOT( tipofdaychanged( bool ) ) );
	_layout->addWidget( _tipofday );
	TQBoxLayout* _tmplayout = new TQBoxLayout( this, TQBoxLayout::LeftToRight );
	_enableAllMessages = new KPushButton( i18n( "Enable All Hidden Messages" ), this );
	connect( _enableAllMessages, TQT_SIGNAL( clicked() ), this, TQT_SLOT( enableallmessagesclicked() ) );
	_tmplayout->addWidget( _enableAllMessages );
	TQLabel* _tmplbl = new TQLabel( i18n( "<qt><i>All messages with the \"Don't show this message again\" option are shown again after selecting this button.</i></qt>" ), this );
	_tmplayout->addWidget( _tmplbl );
	_layout->addLayout( _tmplayout );

	_layout->addStretch( 100 );

	load();
}

KRecConfigGeneral::~KRecConfigGeneral() {
}

void KRecConfigGeneral::load() {
kdDebug( 60005 ) << k_funcinfo << endl;
	defaults();
	_displaymode = KRecGlobal::the()->timeFormatMode();
	switch ( _displaymode % 100 ) {
		default:
		case 0: _display0->setChecked( true ); break;
		case 1: _display1->setChecked( true ); break;
		case 2: _display2->setChecked( true ); break;
		case 3: _display3->setChecked( true ); break;
	};
	_verboseDisplayMode->setChecked( ( _displaymode / 100 == 1 ) );

	_framebase = KRecGlobal::the()->frameBase();
	switch ( _framebase ) {
		case 30: _framebase30->setChecked( true ); break;
		case 25: _framebase25->setChecked( true ); break;
		case 75: _framebase75->setChecked( true ); break;
		default:
			_framebaseother->setChecked( true );
			_framebaseotherbox->setEnabled( true );
			_framebaseotherline->setText( TQString::number( _framebase ) );
			break;
	};
	kapp->config()->setGroup( "TipOfDay" );
	_tip = kapp->config()->readBoolEntry( "RunOnStart", true );
	_tipofday->setChecked( _tip );
}

void KRecConfigGeneral::save() {
	KRecGlobal::the()->setTimeFormatMode( _displaymode );
	KRecGlobal::the()->setFrameBase( _framebase );
kdDebug(60005) << k_funcinfo << "Framebase=" << _framebase << endl;

	kapp->config()->setGroup( "TipOfDay" );
	kapp->config()->writeEntry( "RunOnStart", _tip );

	kapp->config()->sync();
	emit changed( false );
}

void KRecConfigGeneral::defaults() {
	_display0->setChecked( true );
	_framebase25->setChecked( true );
}

void KRecConfigGeneral::displaychanged( int index ) {
	int verbose = _displaymode / 100;
	if ( _displaybox->find( index ) == _display0 ) _displaymode = 0 + verbose * 100;
	if ( _displaybox->find( index ) == _display1 ) _displaymode = 1 + verbose * 100;
	if ( _displaybox->find( index ) == _display2 ) _displaymode = 2 + verbose * 100;
	if ( _displaybox->find( index ) == _display3 ) _displaymode = 3 + verbose * 100;
	emit changed( true );
}
void KRecConfigGeneral::framebasechanged( int index ) {
	if ( _framebasebox->find( index ) == _framebase30 ) _framebase = 30;
	if ( _framebasebox->find( index ) == _framebase25 ) _framebase = 25;
	if ( _framebasebox->find( index ) == _framebase75 ) _framebase = 75;
	if ( _framebasebox->find( index ) == _framebaseother ) {
		_framebaseotherbox->setEnabled( true );
		_framebase = _framebaseotherline->text().toInt();
kdDebug(60005) << k_funcinfo << "Framebase=" << _framebase << endl;
	} else
		_framebaseotherbox->setEnabled( false );
	emit changed( true );
}
void KRecConfigGeneral::framebaseotherchanged( const TQString& text ) {
	_framebase = text.toInt();
kdDebug(60005) << k_funcinfo << "Framebase=" << _framebase << endl;
	emit changed( true );
}
void KRecConfigGeneral::verboseDisplayChanged( bool n ) {
	if ( n && _displaymode < 100 ) _displaymode += 100;
	if ( !n && _displaymode >= 100 ) _displaymode -= 100;
	emit changed( true );
}

void KRecConfigGeneral::tipofdaychanged( bool n ) {
	_tip = n;
	emit changed( true );
}

void KRecConfigGeneral::enableallmessagesclicked() {
kdDebug(60005) << k_funcinfo << endl;
	KMessageBox::enableAllMessages();
}