2
* KMix -- KDE's full featured mini mixer
5
* Copyright (C) 2000 Stefan Schimanski <1Stein@gmx.de>
6
* Copyright (C) 2001 Preston Brown <pbrown@kde.org>
8
* This program is free software; you can redistribute it and/or
9
* modify it under the terms of the GNU Library General Public
10
* License as published by the Free Software Foundation; either
11
* version 2 of the License, or (at your option) any later version.
13
* This program is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
* Library General Public License for more details.
18
* You should have received a copy of the GNU Library General Public
19
* License along with this program; if not, write to the Free
20
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25
#include <kpanelapplet.h>
26
#include <kpopupmenu.h>
27
#include <kiconloader.h>
35
#include "mixdevicewidget.h"
36
#include "kmixdockwidget.h"
39
KMixDockWidget::KMixDockWidget( Mixer *mixer,
40
QWidget *parent, const char *name )
41
: KSystemTray( parent, name ), m_mixer(mixer), masterVol(0L)
43
createMasterVolWidget();
46
KMixDockWidget::~KMixDockWidget()
51
void KMixDockWidget::createMasterVolWidget()
57
MixDevice *masterDevice = (*m_mixer)[m_mixer->masterDevice()];
58
// MixDevice *masterDevice = m_mixer->getMixer(m_mixer->masterDevice();
60
masterVol = new QVBox(0L, "masterVol", WStyle_Customize |
62
masterVol->setFrameStyle(QFrame::PopupPanel);
63
masterVol->setMargin(KDialog::marginHint());
65
MixDeviceWidget *mdw =
66
new MixDeviceWidget( m_mixer, masterDevice, false, false,
67
false, KPanelApplet::Up, masterVol,
68
masterDevice->name().latin1() );
69
connect(mdw, SIGNAL(newVolume(int, Volume)),
70
this, SLOT(setVolumeTip(int, Volume)));
71
setVolumeTip(0, masterDevice->getVolume());
72
masterVol->resize(masterVol->sizeHint());
75
void KMixDockWidget::setVolumeTip(int, Volume vol)
77
QToolTip::remove(this);
78
QToolTip::add(this, i18n("Volume at %1%").arg(vol.getVolume(0)));
81
void KMixDockWidget::mousePressEvent(QMouseEvent *me)
83
KConfig *config = kapp->config();
85
if( config->readBoolEntry("TrayVolumeControl", true ) )
86
QWidget::mousePressEvent(me);
88
KSystemTray::mousePressEvent(me);
91
void KMixDockWidget::mouseReleaseEvent(QMouseEvent *me)
94
KSystemTray::mouseReleaseEvent(me);
97
KConfig *config = kapp->config();
99
if( config->readBoolEntry("TrayVolumeControl", true ) ) {
100
if (me->button() == QMouseEvent::LeftButton &&
101
!masterVol->isVisible()) {
102
QWidget *desktop = QApplication::desktop();
103
int sw = desktop->width();
104
int sh = desktop->height();
105
int sx = desktop->x();
106
int sy = desktop->y();
107
int x = me->globalPos().x();
108
int y = me->globalPos().y();
109
y -= masterVol->geometry().height();
110
int w = masterVol->width();
111
int h = masterVol->height();
114
x = me->globalPos().x()-w;
116
y = me->globalPos().y()-h;
118
x = me->globalPos().x();
120
y = me->globalPos().y();
122
masterVol->move(x, y);
124
} else if (me->button() == QMouseEvent::LeftButton &&
125
masterVol->isVisible()) {
129
KSystemTray::mousePressEvent(me);
132
KSystemTray::mouseReleaseEvent(me);
136
void KMixDockWidget::mouseDoubleClickEvent(QMouseEvent *me)
138
KSystemTray::mousePressEvent(me);
141
void KMixDockWidget::contextMenuAboutToShow( KPopupMenu* menu )
143
for ( unsigned n=0; n<menu->count(); n++ )
145
if ( QString( menu->text( menu->idAt(n) ) )==i18n("&Quit") )
146
menu->removeItemAt( n );
149
menu->insertItem( SmallIcon("exit"), i18n("&Quit" ), kapp, SLOT(quit()) );
152
#include "kmixdockwidget.moc"