summaryrefslogtreecommitdiffstats
path: root/knights/setpageaudio.cpp
blob: f9aac94492ba068b231a259552fcaa8cd87a047b (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
/***************************************************************************
                          setpageaudio.cpp  -  description
                             -------------------
    begin                : Thu Jan 10 2002
    copyright            : (C) 2003 by Troy Corbin Jr.
    email                : tcorbin@users.sourceforge.net
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#include <tqregexp.h>
#include "setpageaudio.moc"

setPageAudio::setPageAudio(TQWidget *tqparent, resource *Rsrc ) : TQVBoxLayout(tqparent)
{
	Parent = tqparent;
	Resource = Rsrc;
	NewSounds = 0;
	changeTheme = FALSE;

	BUTTON_enableAudio = new TQCheckBox( i18n( "Enable Audio" ), tqparent );
	BUTTON_enableAudio->setChecked( Resource->OPTION_Audio );
	addWidget( BUTTON_enableAudio );
	connect(	BUTTON_enableAudio, TQT_SIGNAL( toggled(bool) ),
						this, TQT_SLOT( slot_enableAudio(bool) ) );

	GROUP_Theme = new TQGroupBox( 1,
																Qt::Vertical,
																i18n( "Audio Themes" ),
																tqparent );
	addWidget( GROUP_Theme );
	Current_Theme = new KComboBox ( GROUP_Theme );
	buildThemeList();
	connect(	Current_Theme, TQT_SIGNAL( activated(int) ),
						this, TQT_SLOT( slot_currentTheme(int) ) );

	BOX_Main = new TQHBox( tqparent );
	addWidget( BOX_Main );

	GROUP_Volume = new TQGroupBox( 3, Qt::Vertical, i18n( "Volume" ), BOX_Main );
	Vol_Max = new TQLabel( i18n( "Maximum" ), GROUP_Volume );
	Current_Volume = new TQSlider ( 0, 100, 10, Resource->Audio_Volume, 	Qt::Vertical, GROUP_Volume );
	connect(	Current_Volume, TQT_SIGNAL( valueChanged(int) ), this, TQT_SLOT( slot_currentVolume(int) ) );
	Current_Volume->setTickmarks( TQSlider::Right );
	Vol_Min = new TQLabel( i18n( "Minimum" ), GROUP_Volume );

	BOX_Options = new TQVBox( BOX_Main );
	BUTTON_AudioCurrentOnly = new TQCheckBox( i18n( "For Current Match Only" ), BOX_Options );
	BUTTON_AudioCurrentOnly->setChecked( Resource->OPTION_Audio_Current_Only );
	connect(	BUTTON_AudioCurrentOnly, TQT_SIGNAL( toggled(bool) ),
						this, TQT_SLOT( slot_AudioCurrentOnly(bool) ) );
}
setPageAudio::~setPageAudio()
{
}
///////////////////////////////////////
//
//	setPageAudio::slot_enableAudio
//
///////////////////////////////////////
void setPageAudio::slot_enableAudio( bool state )
{
	Resource->OPTION_Audio = state;
	emit enableApply();
}
///////////////////////////////////////
//
//	setPageAudio::slot_currentTheme
//
///////////////////////////////////////
void setPageAudio::slot_currentTheme( int Index )
{
	NewSounds = Index;
	changeTheme = TRUE;
	emit enableApply();
}
///////////////////////////////////////
//
//	setPageAudio::slot_currentVolume
//
///////////////////////////////////////
void setPageAudio::slot_currentVolume( int Level )
{
	Resource->Audio_Volume = Level;
	emit enableApply();
}
///////////////////////////////////////
//
//	setPageAudio::slot_AudioCurrentOnly
//
///////////////////////////////////////
void setPageAudio::slot_AudioCurrentOnly( bool state )
{
	Resource->OPTION_Audio_Current_Only = state;
	emit enableApply();
}
///////////////////////////////////////
//
//	setPageAudio::buildThemeList
//
///////////////////////////////////////
void setPageAudio::buildThemeList( void )
{
	TQString buffer;
	int tmp(0);

	Current_Theme->clear();
	Resource->readThemeDir();
	while(1)
	{
		buffer = Resource->getSounds( tmp );
		if( buffer.isEmpty() ) break;
		buffer.remove( 0, 2 );
		buffer.replace( TQRegExp("_"), " " );
		buffer.replace( TQRegExp(".tar"), "" );
		buffer.replace( TQRegExp(".gz"), "" );
		buffer.replace( TQRegExp(".bz2"), "" );
		Current_Theme->insertItem( buffer, tmp );
		if( Resource->getSounds() == Resource->getSounds( tmp ) )
		{
			Current_Theme->setCurrentItem( tmp );
			NewSounds = tmp;
		}
		tmp++;
	}
}