summaryrefslogtreecommitdiffstats
path: root/arts/tools/main.cpp
blob: 0037be6eac44b1f503ce3353299f9cc03f461cd2 (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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
/*

    Copyright (C) 2000-2001 Stefan Westerfeld
                            <stefan@space.twc.de>
                       2003 Arnold Krille <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; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

    */

#include "main.h"
#include "environmentview.h"
#include "main.moc"
#include "levelmeters.h"
#include "midimanagerview.h"
#include "audiomanager.h"
#include "fftscopeview.h"
#include "mediatypesview.h"
#include "statusview.h"

#include <objectmanager.h>
#include <debug.h>
#include <artsversion.h>
#include <kartsfloatwatch.h>

#include <tqlabel.h>
#include <tqslider.h>
#include <tqpushbutton.h>
#include <kaction.h>
#include <kled.h>
#include <kmessagebox.h>
#include <kdebug.h>
#include <kartsserver.h>

#include <kstdaction.h>

#include "kartswidget.h"

using namespace std;
using namespace Arts;

void FreeVerbView::closeEvent(TQCloseEvent *e) {
	e->accept();
	emit closed();
}

FreeVerbView::FreeVerbView(SimpleSoundServer server) : server(server) {
	freeverb = DynamicCast(server.createObject("Arts::Synth_FREEVERB"));
	arts_assert(!freeverb.isNull());
	freeverb.start();

	// put it into the effect chain
	effectID = server.outstack().insertTop(freeverb,"FreeVerb");

	GenericGuiFactory factory;
	Widget gui = factory.createGui(freeverb);

	TQBoxLayout * l = new TQHBoxLayout( this );
	if(!gui.isNull())
		l->add(new KArtsWidget(gui, this));
	else
		l->add(new TQLabel(i18n("No GUI found for this effect."), this));
	l->freeze();
	show();
}

FreeVerbView::~FreeVerbView() {
	// remove effect
	server.outstack().remove(effectID);
}


VControl::VControl( KArtsServer* artsserver, TQWidget *parent) : TQFrame(parent)
	, freeVerbView(0)
	, server( artsserver )
{

	connect( server, TQT_SIGNAL( restartedServer() ), this, TQT_SLOT( initaRtsConnections() ) );
/*   	if(server.isNull())
   	{
		KMessageBox::error( 0, i18n("Connection to the soundserver failed - make sure that artsd is really running and that your tdelibs version is not older than tdemultimedia."));
		exit(1);
	}*/
	boxLayout = new TQHBoxLayout( this );

	// 0   => 4.0
	// 200 => 2.0
	// 400 => 1.0
	// 600 => 0.5
	// 800 => 0.25
	// 1000 => 0.125
	// 1200 => 0.0 (forced)

	svcguiw = new KArtsWidget( this );
	boxLayout->addWidget( svcguiw );

	boxLayout->activate();
	show();

	initaRtsConnections();
}
VControl::~VControl() {
	if ( freeVerbView ) showFreeVerbView();
}

void VControl::useOldVolumeBar(int old) {
/*	delete stereoMeter;
	if (old) {
		stereoMeter= new StereoLedMeters(this);
	} else {
		stereoMeter= new PeakLevelMeters(this);
	}
	boxLayout->insertWidget(0, stereoMeter);
	stereoMeter->show();*/
	if ( old ) {
		svcgui.left().substyle( 3 );
		svcgui.right().substyle( 3 );
	} else {
		svcgui.left().substyle( 2 );
		svcgui.right().substyle( 2 );
	}
}

void VControl::showFreeVerbView() {
	if(!freeVerbView) {
		freeVerbView = new FreeVerbView(server->server());
		connect(freeVerbView,TQT_SIGNAL(closed()),this,TQT_SLOT(showFreeVerbView()));
	} else {
		delete freeVerbView;
		freeVerbView = 0;
	}
}

void VControl::initaRtsConnections() {
kdDebug() << k_funcinfo << endl;
	svcgui = Arts::StereoVolumeControlGui::null();
	svcgui = Arts::StereoVolumeControlGui( server->server().outVolume() );
	svcgui.title( i18n( "aRts Master Volume" ).utf8().data() );
	svcguiw->setContent( Arts::Widget() );
	svcguiw->setContent( svcgui );
	useOldVolumeBar( false );
kdDebug() << k_funcinfo << "done." << endl;
}

void MainWindow::toggleVolumeBar() {
	vc->useOldVolumeBar(showOldVolumeDisplay->isChecked());
}

MainWindow::MainWindow() : KMainWindow(0), kartsserver( new KArtsServer( TQT_TQOBJECT(this) ) ) {
kdDebug() << k_funcinfo << endl;
	connect( kartsserver, TQT_SIGNAL( restartedServer() ), this, TQT_SLOT( serverRestarted() ) );

	vc = new VControl( kartsserver, this );
	setCentralWidget( vc );
	artsactions = new ArtsActions( kartsserver, actionCollection(), this );

	( void ) artsactions->actionScopeView();
	( void ) artsactions->actionAudioManager();
	( void ) artsactions->actionArtsStatusView();
	( void ) artsactions->actionMidiManagerView();
	( void ) artsactions->actionEnvironmentView();
	( void ) artsactions->actionMediaTypesView();
	( void ) new KAction( i18n("Toggle Free&Verb"), 0, TQT_TQOBJECT(vc), TQT_SLOT( showFreeVerbView() ), actionCollection(), "view_freeverb" );
	showOldVolumeDisplay=
		new KToggleAction( i18n( "Old aRts-Control-Style for VU-Meter" /*"&LED-Style Volume Display"*/ ), 0, TQT_TQOBJECT(this),
		TQT_SLOT( toggleVolumeBar() ), actionCollection(), "old_volume_display" );
	( void ) KStdAction::quit( TQT_TQOBJECT(this), TQT_SLOT( close() ), actionCollection(), "quit_artscontrol" );

	createGUI("artscontrol.rc");
	resize(20,300);
	show();
}

void MainWindow::serverRestarted() {
kdDebug() << k_funcinfo << endl;
	KMessageBox::sorry( this, "aRts had to restart!" );
}

int main(int argc, char **argv) {
	TDEAboutData aboutData( "artscontrol", I18N_NOOP("aRts control"),
		ARTS_VERSION, I18N_NOOP("Control tool for the aRts server"),
			TDEAboutData::License_GPL, I18N_NOOP("(c) 2000 Stefan Westerfeld\n(c) 2003 Arnold Krille") );
	aboutData.addAuthor( "Stefan Westerfeld", I18N_NOOP( "Author and aRts maintainer" ), "stefan@space.twc.de" );
	aboutData.addAuthor( "Arnold Krille", I18N_NOOP( "Some improvements" ), "arnold@arnoldarts.de" );

	TDECmdLineArgs::init( argc, argv, &aboutData );

	TDEApplication app(argc, argv);

	// setup mcop communication
	QIOManager qiomanager;
	Dispatcher dispatcher(&qiomanager);

	ObjectManager::the()->provideCapability("kdegui");

	app.setMainWidget(new MainWindow);
	app.setName("artsbuilder");
	return app.exec();
}