~ubuntu-branches/ubuntu/breezy/kdemultimedia/breezy

« back to all changes in this revision

Viewing changes to krec/krecconfigure.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2005-03-24 04:48:58 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 sarge)
  • Revision ID: james.westby@ubuntu.com-20050324044858-8ff88o9jxej6ii3d
Tags: 4:3.4.0-0ubuntu3
Add kubuntu_02_hide_arts_menu_entries.diff to hide artsbuilder and artscontrol k-menu entries

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
    copyright            : (C) 2003 by Arnold Krille
 
3
    email                : arnold@arnoldarts.de
 
4
 ***************************************************************************/
 
5
 
 
6
/***************************************************************************
 
7
 *                                                                         *
 
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.               *
 
11
 *                                                                         *
 
12
 ***************************************************************************/
 
13
 
 
14
#include "krecconfigure.h"
 
15
#include "krecconfigure.moc"
 
16
 
 
17
#include "krecglobal.h"
 
18
 
 
19
#include <kgenericfactory.h>
 
20
#include <kdebug.h>
 
21
#include <qlayout.h>
 
22
#include <qbuttongroup.h>
 
23
#include <qradiobutton.h>
 
24
#include <qcheckbox.h>
 
25
#include <qlineedit.h>
 
26
#include <qhbox.h>
 
27
#include <qlabel.h>
 
28
#include <kapplication.h>
 
29
#include <kconfig.h>
 
30
#include <klocale.h>
 
31
#include <kmessagebox.h>
 
32
#include <kpushbutton.h>
 
33
 
 
34
typedef KGenericFactory<KRecConfigGeneral, QWidget> KRecConfigGeneralFactory;
 
35
K_EXPORT_COMPONENT_FACTORY( kcm_krec, KRecConfigGeneralFactory( "krec" ) )
 
36
 
 
37
KRecConfigGeneral::KRecConfigGeneral( QWidget* p, const char*, const QStringList& s )
 
38
 : KCModule( KRecConfigGeneralFactory::instance(), p, s )
 
39
 , _layout( 0 ), _layout_display( 0 )
 
40
 , _display_title( 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 )
 
46
{
 
47
        _layout = new QBoxLayout( this, QBoxLayout::TopToBottom );
 
48
 
 
49
        _layout->addSpacing( 10 );
 
50
        _display_title = new QLabel( i18n( "<qt><b>Timedisplay Related Settings</b></qt>" ), this );
 
51
        _layout->addWidget( _display_title, -100 );
 
52
 
 
53
        _layout_display = new QBoxLayout( _layout, QBoxLayout::LeftToRight );
 
54
        _layout->setStretchFactor( _layout_display, -100 );
 
55
 
 
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& ) ) );
 
77
 
 
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 );
 
82
 
 
83
        _layout->addSpacing( 10 );
 
84
        _other_title = new QLabel( i18n( "<qt><b>Miscellaneous Settings</b></qt>" ), this );
 
85
        _layout->addWidget( _other_title );
 
86
 
 
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 );
 
97
 
 
98
        _layout->addStretch( 100 );
 
99
 
 
100
        load();
 
101
}
 
102
 
 
103
KRecConfigGeneral::~KRecConfigGeneral() {
 
104
}
 
105
 
 
106
void KRecConfigGeneral::load() {
 
107
kdDebug( 60005 ) << k_funcinfo << endl;
 
108
        defaults();
 
109
        _displaymode = KRecGlobal::the()->timeFormatMode();
 
110
        switch ( _displaymode % 100 ) {
 
111
                default:
 
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;
 
116
        };
 
117
        _verboseDisplayMode->setChecked( ( _displaymode / 100 == 1 ) );
 
118
 
 
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;
 
124
                default:
 
125
                        _framebaseother->setChecked( true );
 
126
                        _framebaseotherbox->setEnabled( true );
 
127
                        _framebaseotherline->setText( QString::number( _framebase ) );
 
128
                        break;
 
129
        };
 
130
        kapp->config()->setGroup( "TipOfDay" );
 
131
        _tip = kapp->config()->readBoolEntry( "RunOnStart", true );
 
132
        _tipofday->setChecked( _tip );
 
133
}
 
134
 
 
135
void KRecConfigGeneral::save() {
 
136
        KRecGlobal::the()->setTimeFormatMode( _displaymode );
 
137
        KRecGlobal::the()->setFrameBase( _framebase );
 
138
kdDebug(60005) << k_funcinfo << "Framebase=" << _framebase << endl;
 
139
 
 
140
        kapp->config()->setGroup( "TipOfDay" );
 
141
        kapp->config()->writeEntry( "RunOnStart", _tip );
 
142
 
 
143
        kapp->config()->sync();
 
144
        emit changed( false );
 
145
}
 
146
 
 
147
void KRecConfigGeneral::defaults() {
 
148
        _display0->setChecked( true );
 
149
        _framebase25->setChecked( true );
 
150
}
 
151
 
 
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 );
 
159
}
 
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;
 
168
        } else
 
169
                _framebaseotherbox->setEnabled( false );
 
170
        emit changed( true );
 
171
}
 
172
void KRecConfigGeneral::framebaseotherchanged( const QString& text ) {
 
173
        _framebase = text.toInt();
 
174
kdDebug(60005) << k_funcinfo << "Framebase=" << _framebase << endl;
 
175
        emit changed( true );
 
176
}
 
177
void KRecConfigGeneral::verboseDisplayChanged( bool n ) {
 
178
        if ( n && _displaymode < 100 ) _displaymode += 100;
 
179
        if ( !n && _displaymode >= 100 ) _displaymode -= 100;
 
180
        emit changed( true );
 
181
}
 
182
 
 
183
void KRecConfigGeneral::tipofdaychanged( bool n ) {
 
184
        _tip = n;
 
185
        emit changed( true );
 
186
}
 
187
 
 
188
void KRecConfigGeneral::enableallmessagesclicked() {
 
189
kdDebug(60005) << k_funcinfo << endl;
 
190
        KMessageBox::enableAllMessages();
 
191
}
 
192