summaryrefslogtreecommitdiffstats
path: root/arts/tools/artscontrolapplet.cpp
blob: dc4953221a8f32f0ebb8b1e310d2b798f215452f (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
/***************************************************************************
                          artscontrolapplet.cpp  -  description
                             -------------------
    begin                : Don Jan 30 20:42:53 CET 2003
    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; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#include <kglobal.h>
#include <klocale.h>
#include <kconfig.h>
#include <kapplication.h>
#include <kmessagebox.h>
#include <kdebug.h>
#include <tqcursor.h>
#include <tqtimer.h>

#include "artscontrolapplet.h"
#include "artscontrolapplet_private.h"

extern "C"
{
  KDE_EXPORT KPanelApplet* init( TQWidget *parent, const TQString configFile)
  {
    TDEGlobal::locale()->insertCatalogue("artscontrol");
    return new ArtsControlApplet(configFile, KPanelApplet::Normal,
                      KPanelApplet::About /*| KPanelApplet::Help | KPanelApplet::Preferences*/,
                      parent, "artscontrolapplet");
  }
}

ArtsControlApplet::ArtsControlApplet(const TQString& configFile, Type type, int actions, TQWidget *parent, const char *name) : KPanelApplet(configFile, type, actions, parent, name)
{
	//kdDebug()<<"ArtsControlApplet::ArtsControlApplet( const TQString& "<<configFile<<", Type "<<type<<", int "<<actions<<", TQWidget* "<<parent<<", const char* "<<name<<" )"<<endl;
	// Get the current application configuration handle
	ksConfig = config();

	p = new ArtsControlAppletPrivate( this );
	if( !p->barts ) KMessageBox::information(0, i18n("Something with the ArtsServer went wrong. You probably need to restart aRts and then reload this applet."));
	setCustomMenu(p->menu);

	p->layout = new TQBoxLayout( this, TQBoxLayout::LeftToRight );
	p->layout->setSpacing( 2 );

	if( p->barts ) {
		p->vu = Arts::StereoVolumeControlGui( p->volume );
		p->vu.label().fontsize( 8 );
		p->vuw = new KArtsWidget( p->vu, this );
		p->vuw->setMinimumSize( 16,16 );
		p->layout->addWidget( p->vuw );
	}

	p->layout->activate();

	TQTimer::singleShot( 100, this, TQT_SLOT( supdatelayout() ) );

kdDebug()<<"ArtsControlApplet::ArtsControlApplet() finished."<<endl;
}

ArtsControlApplet::~ArtsControlApplet() {
kdDebug()<<k_funcinfo<<endl;
}

#include <kaboutdata.h>
#include <kaboutapplication.h>

void ArtsControlApplet::about() {
	TDEAboutData about( "artscontrolapplet", I18N_NOOP( "aRts Control Applet" ), "0.5",
		I18N_NOOP( "A kickerapplet to control aRts." ),
		TDEAboutData::License_GPL, I18N_NOOP( "(c) 2003 by Arnold Krille" ) );
	about.addAuthor( "Arnold Krille", I18N_NOOP( "Author of the Applet" ), "arnold@arnoldarts.de" );
	about.addCredit( "Stefan Westerfeld", I18N_NOOP( "Thanks for creating aRts!" ) );
	KAboutApplication a( &about, this );
	a.exec();
}

void ArtsControlApplet::help() {
kdDebug()<<k_funcinfo<<endl;
}

void ArtsControlApplet::preferences() {
kdDebug()<<k_funcinfo<<endl;
}

int ArtsControlApplet::widthForHeight( int h ) const {
kdDebug()<<"ArtsControlApplet::widthForHeight( int "<<h<<" )"<<endl;
	return p->layout->sizeHint().width();
}

int ArtsControlApplet::heightForWidth( int w ) const {
kdDebug()<<"ArtsControlApplet::heightForWidth( int "<<w<<" )"<<endl;
	return p->layout->sizeHint().height();
}

void ArtsControlApplet::resizeEvent( TQResizeEvent * /*_Event*/ ) {
	kdDebug()<<"ArtsControlApplet::resizeEvent( TQResizeEvent * )"<<endl;
}

void ArtsControlApplet::mousePressEvent( TQMouseEvent* ev ) {
	//kdDebug()<<"ArtsControlApplet::mousePressEvent( TQMouseEvent* "<<ev<<" )"<<endl;
	if ( Qt::RightButton == ev->button() /*|| Qt::LeftButton == ev->button()*/ )
		p->menu->exec( TQCursor::pos() );
}

void ArtsControlApplet::positionChange( Position ) {
	kdDebug() << k_funcinfo << endl;
	resetLayout();
}

void ArtsControlApplet::resetLayout() {
kdDebug()<<k_funcinfo<<" position()="<<position()<<endl;
	switch ( position() )
	{
		case pTop:
		case pBottom:
			p->layout->setDirection( TQBoxLayout::LeftToRight );
			if ( p->barts ) p->vu.direction( Arts::LeftToRight );
			break;
		case pRight:
		case pLeft:
			p->layout->setDirection( TQBoxLayout::TopToBottom );
			if ( p->barts ) p->vu.direction( Arts::TopToBottom );
			break;
		default: break;
	}
}

void ArtsControlAppletPrivate::SVinline() {
kdDebug() << k_funcinfo << endl;
	if ( !svinline ) {
		svinline = new FFTScopeView( arts->server(), _parent );
		svinline->setMargin( 2 ); svinline->setLineWidth( 2 ); svinline->setFrameStyle( TQFrame::Panel|TQFrame::Sunken );
		connect( svinline, TQT_SIGNAL( closed() ), this, TQT_SLOT( SVinline() ) );
		layout->addWidget( svinline );
	} else {
		delete svinline;
		svinline = 0;
	}
	_parent->supdatelayout();
}

void ArtsControlAppletPrivate::moreBars() { vu.left().count( vu.left().count()+10 ); vu.right().count( vu.right().count()+10 ); }
void ArtsControlAppletPrivate::lessBars() { vu.left().count( vu.left().count()-10 ); vu.right().count( vu.right().count()-10 ); }

void ArtsControlAppletPrivate::styleNormalBars() { vu.left().style( Arts::lmNormalBars ); vu.right().style( Arts::lmNormalBars ); _parent->supdatelayout(); }
void ArtsControlAppletPrivate::styleFireBars()   { vu.left().style( Arts::lmFireBars   ); vu.right().style( Arts::lmFireBars   ); _parent->supdatelayout(); }
void ArtsControlAppletPrivate::styleLineBars()   { vu.left().style( Arts::lmLineBars   ); vu.right().style( Arts::lmLineBars   ); _parent->supdatelayout(); }
void ArtsControlAppletPrivate::styleLEDs()       { vu.left().style( Arts::lmLEDs       ); vu.right().style( Arts::lmLEDs       ); _parent->supdatelayout(); }
void ArtsControlAppletPrivate::styleAnalog()     { vu.left().style( Arts::lmAnalog     ); vu.right().style( Arts::lmAnalog     ); _parent->supdatelayout(); }
void ArtsControlAppletPrivate::styleSmall()      { vu.left().style( Arts::lmSmall      ); vu.right().style( Arts::lmSmall      ); _parent->supdatelayout(); }

// vim: sw=4 ts=4
#include "artscontrolapplet.moc"
#include "artscontrolapplet_private.moc"