3
* KMix -- KDE's full featured mini mixer
5
* Copyright 1996-2000 Christian Esken <esken@kde.org>
6
* Copyright 2000-2003 Christian Esken <esken@kde.org>, Stefan Schimanski <1Stein@gmx.de>
7
* Copyright 2002-2007 Christian Esken <esken@kde.org>, Helio Chissini de Castro <helio@conectiva.com.br>
9
* This program is free software; you can redistribute it and/or
10
* modify it under the terms of the GNU Library General Public
11
* License as published by the Free Software Foundation; either
12
* version 2 of the License, or (at your option) any later version.
14
* This program is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
* Library General Public License for more details.
19
* You should have received a copy of the GNU Library General Public
20
* License along with this program; if not, write to the Free
21
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25
// include files for QT
28
#include <QDesktopWidget>
29
#include <qradiobutton.h>
33
// include files for KDE
34
#include <kcombobox.h>
35
#include <kiconloader.h>
36
#include <kmessagebox.h>
41
#include <kapplication.h>
42
#include <kstandardaction.h>
44
#include <khelpmenu.h>
46
#include <kxmlguifactory.h>
48
#include <kactioncollection.h>
49
#include <ktoggleaction.h>
52
#include "mixertoolbox.h"
54
#include "kmixdevicemanager.h"
55
#include "kmixerwidget.h"
56
#include "kmixprefdlg.h"
57
#include "kmixdockwidget.h"
58
#include "kmixtoolbox.h"
60
#include "viewdockareapopup.h"
61
#include "dialogselectmaster.h"
63
#include "osdwidget.h"
67
* Constructs a mixer window (KMix main window)
69
KMixWindow::KMixWindow(bool invisible)
70
: KXmlGuiWindow(0, Qt::WindowFlags( KDE_DEFAULT_WINDOWFLAGS | Qt::WindowContextHelpButtonHint) ),
72
// m_isVisible (false), // initialize, as we don't trigger a hideEvent()
73
// m_visibilityUpdateAllowed( true ),
74
m_multiDriverMode (false), // -<- I never-ever want the multi-drivermode to be activated by accident
76
m_dontSetDefaultCardOnStart (false),
79
setObjectName("KMixWindow");
80
// disable delete-on-close because KMix might just sit in the background waiting for cards to be plugged in
81
setAttribute(Qt::WA_DeleteOnClose, false);
83
initActions(); // init actions first, so we can use them in the loadConfig() already
84
loadConfig(); // Load config before initMixer(), e.g. due to "MultiDriver" keyword
85
KGlobal::locale()->insertCatalog("kmix-controls");
88
MixerToolBox::instance()->initMixer(m_multiDriverMode, m_hwInfoString);
89
KMixDeviceManager *theKMixDeviceManager = KMixDeviceManager::instance();
92
theKMixDeviceManager->initHotplug();
93
connect(theKMixDeviceManager, SIGNAL( plugged( const char*, const QString&, QString&)), SLOT (plugged( const char*, const QString&, QString&) ) );
94
connect(theKMixDeviceManager, SIGNAL( unplugged( const QString&)), SLOT (unplugged( const QString&) ) );
95
if ( m_startVisible && ! invisible)
96
show(); // Started visible: We don't do "m_isVisible = true;", as the showEvent() already does it
98
connect( kapp, SIGNAL( aboutToQuit()), SLOT( saveConfig()) );
102
KMixWindow::~KMixWindow()
105
MixerToolBox::instance()->deinitMixer();
109
void KMixWindow::initActions()
112
KStandardAction::quit( this, SLOT(quit()), actionCollection());
115
_actionShowMenubar = KStandardAction::showMenubar( this, SLOT(toggleMenuBar()), actionCollection());
116
//actionCollection()->addAction( a->objectName(), a );
117
KStandardAction::preferences( this, SLOT(showSettings()), actionCollection());
118
KStandardAction::keyBindings( guiFactory(), SLOT(configureShortcuts()), actionCollection());
120
KAction *action = actionCollection()->addAction( "hwinfo" );
121
action->setText( i18n( "Hardware &Information" ) );
122
connect(action, SIGNAL(triggered(bool) ), SLOT( slotHWInfo() ));
123
action = actionCollection()->addAction( "hide_kmixwindow" );
124
action->setText( i18n( "Hide Mixer Window" ) );
125
connect(action, SIGNAL(triggered(bool) ), SLOT(hideOrClose()));
126
action->setShortcut(QKeySequence(Qt::Key_Escape));
127
action = actionCollection()->addAction("toggle_channels_currentview");
128
action->setText(i18n("Configure &Channels..."));
129
connect(action, SIGNAL(triggered(bool) ), SLOT(slotConfigureCurrentView()));
130
action = actionCollection()->addAction( "select_master" );
131
action->setText( i18n("Select Master Channel...") );
132
connect(action, SIGNAL(triggered(bool) ), SLOT(slotSelectMaster()));
134
KAction* globalAction = actionCollection()->addAction("increase_volume");
135
globalAction->setText(i18n("Increase Volume"));
136
globalAction->setGlobalShortcut(KShortcut(Qt::Key_VolumeUp));
137
connect(globalAction, SIGNAL(triggered(bool) ), SLOT(slotIncreaseVolume()));
139
globalAction = actionCollection()->addAction("decrease_volume");
140
globalAction->setText(i18n("Decrease Volume"));
141
globalAction->setGlobalShortcut(KShortcut(Qt::Key_VolumeDown));
142
connect(globalAction, SIGNAL(triggered(bool) ), SLOT(slotDecreaseVolume()));
144
globalAction = actionCollection()->addAction("mute");
145
globalAction->setText(i18n("Mute"));
146
globalAction->setGlobalShortcut(KShortcut(Qt::Key_VolumeMute));
147
connect(globalAction, SIGNAL(triggered(bool) ), SLOT(slotMute()));
149
osdWidget = new OSDWidget();
151
createGUI( "kmixui.rc" );
155
void KMixWindow::initPrefDlg()
157
m_prefDlg = new KMixPrefDlg( this );
158
connect( m_prefDlg, SIGNAL(signalApplied(KMixPrefDlg *)), SLOT(applyPrefs(KMixPrefDlg *)) );
164
void KMixWindow::initWidgets()
166
// Main widget and layout
167
setCentralWidget( new QWidget( this ) );
170
m_widgetsLayout = new QVBoxLayout( centralWidget() );
171
m_widgetsLayout->setObjectName( "m_widgetsLayout" );
172
m_widgetsLayout->setSpacing( 0 );
173
m_widgetsLayout->setMargin ( 0 );
176
m_wsMixers = new KTabWidget( centralWidget() );
177
connect( m_wsMixers, SIGNAL( currentChanged ( int ) ), SLOT( newMixerShown(int)) );
179
m_widgetsLayout->addWidget(m_wsMixers);
181
// show menubar if the actions says so (or if the action does not exist)
182
menuBar()->setVisible( (_actionShowMenubar==0) || _actionShowMenubar->isChecked());
184
m_widgetsLayout->activate();
189
* Updates the docking icon by recreating it.
190
* @returns Whether the docking succeeded. Failure usually means that there
191
* was no suitable mixer control selected.
193
bool KMixWindow::updateDocking()
195
// delete old dock widget
198
// If this is called during a master control change, the dock widget is currently active, so we use deleteLater().
199
m_dockWidget->deleteLater();
202
if ( _dockAreaPopup ) {
203
// If this is called during a master control change, we rather play safe by using deleteLater().
204
_dockAreaPopup->deleteLater();
208
if ( m_showDockWidget == false || Mixer::mixers().count() == 0 ) {
212
// create dock widget and the corresponding popup
213
/* A GUIProfile does not make sense for the DockAreaPopup => Using (GUIProfile*)0 */
214
QWidget* referenceWidgetForSystray = this;
215
if ( m_volumeWidget ) {
216
KMenu *volMenu = new KMenu(this);
217
_dockAreaPopup = new ViewDockAreaPopup(volMenu, "dockArea", Mixer::getGlobalMasterMixer(), 0, (GUIProfile*)0, this);
218
_dockAreaPopup->createDeviceWidgets();
220
QWidgetAction *volWA = new QWidgetAction(volMenu);
221
volWA->setDefaultWidget(_dockAreaPopup);
222
volMenu->addAction(volWA);
223
referenceWidgetForSystray = volMenu;
225
m_dockWidget = new KMixDockWidget( this, referenceWidgetForSystray, _dockAreaPopup );
226
//m_dockWidget->show();
227
connect(m_dockWidget, SIGNAL(newMasterSelected()), SLOT(saveConfig()) );
231
void KMixWindow::saveConfig()
237
#warn We must Sync here, or we will lose configuration data. The reson for that is unknown.
239
KGlobal::config()->sync();
242
void KMixWindow::saveBaseConfig()
244
KConfigGroup config(KGlobal::config(), "Global");
246
config.writeEntry( "Size", size() );
247
config.writeEntry( "Position", pos() );
248
// Cannot use isVisible() here, as in the "aboutToQuit()" case this widget is already hidden.
249
// (Please note that the problem was only there when quitting via Systray - esken).
250
// Using it again, as internal behaviour has changed with KDE4
251
config.writeEntry( "Visible", isVisible() );
252
config.writeEntry( "Menubar", _actionShowMenubar->isChecked() );
253
config.writeEntry( "AllowDocking", m_showDockWidget );
254
config.writeEntry( "TrayVolumeControl", m_volumeWidget );
255
config.writeEntry( "Tickmarks", m_showTicks );
256
config.writeEntry( "Labels", m_showLabels );
257
config.writeEntry( "startkdeRestore", m_onLogin );
258
config.writeEntry( "DefaultCardOnStart", m_defaultCardOnStart );
259
config.writeEntry( "ConfigVersion", KMIX_CONFIG_VERSION );
260
Mixer* mixerMasterCard = Mixer::getGlobalMasterMixer();
261
if ( mixerMasterCard != 0 ) {
262
config.writeEntry( "MasterMixer", mixerMasterCard->id() );
264
MixDevice* mdMaster = Mixer::getGlobalMasterMD();
265
if ( mdMaster != 0 ) {
266
config.writeEntry( "MasterMixerDevice", mdMaster->id() );
268
QString mixerIgnoreExpression = MixerToolBox::instance()->mixerIgnoreExpression();
269
config.writeEntry( "MixerIgnoreExpression", mixerIgnoreExpression );
271
// @todo basically this should be moved in the views later (e.g. KDE4.2 ?)
272
if ( m_toplevelOrientation == Qt::Horizontal )
273
config.writeEntry( "Orientation","Horizontal" );
275
config.writeEntry( "Orientation","Vertical" );
278
void KMixWindow::saveViewConfig()
281
for ( int i=0; i<m_wsMixers->count() ; ++i )
283
QWidget *w = m_wsMixers->widget(i);
284
if ( w->inherits("KMixerWidget") ) {
285
KMixerWidget* mw = (KMixerWidget*)w;
286
// Here also Views are saved. even for Mixers that are closed. This is necessary when unplugging cards.
287
// Otherwise the user will be confused afer re-plugging the card (as the config was not saved).
288
mw->saveConfig( KGlobal::config().data() );
295
* Stores the volumes of all mixers Can be restored via loadVolumes() or
296
* the kmixctrl application.
298
void KMixWindow::saveVolumes()
300
KConfig *cfg = new KConfig( "kmixctrlrc" );
301
for ( int i=0; i<Mixer::mixers().count(); ++i)
303
Mixer *mixer = (Mixer::mixers())[i];
304
if ( mixer->isOpen() ) { // protect from unplugged devices (better do *not* save them)
305
mixer->volumeSave( cfg );
313
void KMixWindow::loadConfig()
316
//loadViewConfig(); // mw->loadConfig() explicitly called always after creating mw.
317
//loadVolumes(); // not in use
320
void KMixWindow::loadBaseConfig()
322
KConfigGroup config(KGlobal::config(), "Global");
324
m_showDockWidget = config.readEntry("AllowDocking", true);
325
m_volumeWidget = config.readEntry("TrayVolumeControl", true);
326
m_showTicks = config.readEntry("Tickmarks", true);
327
m_showLabels = config.readEntry("Labels", true);
328
m_onLogin = config.readEntry("startkdeRestore", true );
329
m_startVisible = config.readEntry("Visible", false);
330
m_multiDriverMode = config.readEntry("MultiDriver", false);
331
const QString& orientationString = config.readEntry("Orientation", "Vertical");
332
m_defaultCardOnStart = config.readEntry( "DefaultCardOnStart", "" );
333
m_configVersion = config.readEntry( "ConfigVersion", 0 );
334
// WARNING Don't overwrite m_configVersion with the "correct" value, before having it
335
// evaluated. Better only write that in saveBaseConfig()
336
QString mixerMasterCard = config.readEntry( "MasterMixer", "" );
337
QString masterDev = config.readEntry( "MasterMixerDevice", "" );
338
//if ( ! mixerMasterCard.isEmpty() && ! masterDev.isEmpty() ) {
339
Mixer::setGlobalMaster(mixerMasterCard, masterDev);
341
QString mixerIgnoreExpression = config.readEntry( "MixerIgnoreExpression", "Modem" );
342
MixerToolBox::instance()->setMixerIgnoreExpression(mixerIgnoreExpression);
344
if ( orientationString == "Horizontal" )
345
m_toplevelOrientation = Qt::Horizontal;
347
m_toplevelOrientation = Qt::Vertical;
349
// show/hide menu bar
350
bool showMenubar = config.readEntry("Menubar", true);
352
if (_actionShowMenubar) _actionShowMenubar->setChecked( showMenubar );
354
// restore window size and position
355
if ( !kapp->isSessionRestored() ) // done by the session manager otherwise
357
QSize defSize( minimumWidth(), height() );
358
QSize size = config.readEntry("Size", defSize );
359
if(!size.isEmpty()) resize(size);
361
QPoint defPos = pos();
362
QPoint pos = config.readEntry("Position", defPos);
368
* Loads the volumes of all mixers from kmixctrlrc.
370
* Restores the default voumes as stored via saveVolumes() or the
371
* execution of "kmixctrl --save"
373
/* Currently this is not in use
375
KMixWindow::loadVolumes()
377
KConfig *cfg = new KConfig( "kmixctrlrc", true );
378
for ( int i=0; i<Mixer::mixers().count(); ++i)
380
Mixer *mixer = (Mixer::mixers())[i];
381
mixer->volumeLoad( cfg );
390
void KMixWindow::recreateGUIwithoutSavingView()
397
* Create or recreate the Mixer GUI elements
399
void KMixWindow::recreateGUI(bool saveConfig)
401
saveViewConfig(); // save the state before recreating
403
if ( Mixer::mixers().count() > 0 ) {
404
for (int i=0; i<Mixer::mixers().count(); ++i) {
405
Mixer *mixer = (Mixer::mixers())[i];
406
addMixerWidget(mixer->id());
408
bool dockingSucceded = updateDocking();
409
if( !dockingSucceded && Mixer::mixers().count() > 0 )
410
show(); // avoid invisible and unaccessible main window
413
// No soundcard found. Do not complain, but sit in the background, and wait for newly plugged soundcards.
414
updateDocking(); // -<- removes the DockIcon
420
void KMixWindow::fixConfigAfterRead()
422
KConfigGroup grp(KGlobal::config(), "Global");
423
unsigned int configVersion = grp.readEntry( "ConfigVersion", 0 );
424
if ( configVersion < 3 ) {
425
// Fix the "double Base" bug, by deleting all groups starting with "View.Base.Base.".
426
// The group has been copied over by KMixToolBox::loadView() for all soundcards, so
427
// we should be fine now
428
QStringList cfgGroups = KGlobal::config()->groupList();
429
QStringListIterator it(cfgGroups);
430
while ( it.hasNext() ) {
431
QString groupName = it.next();
432
if ( groupName.indexOf("View.Base.Base" ) == 0 ) {
433
kDebug(67100) << "Fixing group " << groupName;
434
KConfigGroup buggyDevgrpCG = KGlobal::config()->group( groupName );
435
buggyDevgrpCG.deleteGroup();
436
} // remove buggy group
438
} // if config version < 3
441
void KMixWindow::plugged( const char* driverName, const QString& /*udi*/, QString& dev)
443
// kDebug(67100) << "Plugged: dev=" << dev << "(" << driverName << ") udi=" << udi << "\n";
444
QString driverNameString;
445
driverNameString = driverName;
446
int devNum = dev.toInt();
447
Mixer *mixer = new Mixer( driverNameString, devNum );
449
kDebug(67100) << "Plugged: dev=" << dev << "\n";
450
MixerToolBox::instance()->possiblyAddMixer(mixer);
454
// Test code for OSD. But OSD is postponed to KDE4.1
455
// OSDWidget* osd = new OSDWidget(0);
456
// osd->volChanged(70, true);
460
void KMixWindow::unplugged( const QString& udi)
462
// kDebug(67100) << "Unplugged: udi=" <<udi << "\n";
463
for (int i=0; i<Mixer::mixers().count(); ++i) {
464
Mixer *mixer = (Mixer::mixers())[i];
465
// kDebug(67100) << "Try Match with:" << mixer->udi() << "\n";
466
if (mixer->udi() == udi ) {
467
kDebug(67100) << "Unplugged Match: Removing udi=" <<udi << "\n";
468
//KMixToolBox::notification("MasterFallback", "aaa");
469
bool globalMasterMixerDestroyed = ( mixer == Mixer::getGlobalMasterMixer() );
470
// Part 1) Remove Tab
471
for ( int i=0; i<m_wsMixers->count() ; ++i )
473
QWidget *w = m_wsMixers->widget(i);
474
KMixerWidget* kmw = ::qobject_cast<KMixerWidget*>(w);
475
if ( kmw && kmw->mixer() == mixer ) {
476
kmw->saveConfig( KGlobal::config().data() );
477
m_wsMixers->removeTab(i);
479
i= -1; // Restart loop from scratch (indices are most likeliy invalidated at removeTab() )
482
MixerToolBox::instance()->removeMixer(mixer);
483
// Check whether the Global Master disappeared, and select a new one if necessary
484
MixDevice* md = Mixer::getGlobalMasterMD();
485
if ( globalMasterMixerDestroyed || md == 0 ) {
486
// We don't know what the global master should be now.
487
// So lets play stupid, and just select the recommendended master of the first device
488
if ( Mixer::mixers().count() > 0 ) {
489
QString localMaster = ((Mixer::mixers())[0])->getLocalMasterMD()->id();
490
Mixer::setGlobalMaster( ((Mixer::mixers())[0])->id(), localMaster);
493
text = i18n("The soundcard containing the master device was unplugged. Changing to control %1 on card %2.",
494
((Mixer::mixers())[0])->getLocalMasterMD()->readableName(),
495
((Mixer::mixers())[0])->readableName()
497
KMixToolBox::notification("MasterFallback", text);
500
if ( Mixer::mixers().count() == 0 ) {
502
text = i18n("The last soundcard was unplugged.");
503
KMixToolBox::notification("MasterFallback", text);
514
* Create a widget with an error message
515
* This widget shows an error message like "no mixers detected.
516
void KMixWindow::setErrorMixerWidget()
518
QString s = i18n("Please plug in your soundcard.No soundcard found. Probably you have not set it up or are missing soundcard drivers. Please check your operating system manual for installing your soundcard."); // !! better text
519
m_errorLabel = new QLabel( s,this );
520
m_errorLabel->setAlignment( Qt::AlignCenter );
521
m_errorLabel->setWordWrap(true);
522
m_errorLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
523
m_wsMixers->addTab( m_errorLabel, i18n("No soundcard found") );
527
void KMixWindow::clearMixerWidgets()
529
while ( m_wsMixers->count() != 0 )
531
QWidget *mw = m_wsMixers->widget(0);
532
m_wsMixers->removeTab(0);
539
void KMixWindow::addMixerWidget(const QString& mixer_ID)
541
// kDebug(67100) << "KMixWindow::addMixerWidget() " << mixer_ID;
542
Mixer *mixer = MixerToolBox::instance()->find(mixer_ID);
545
// kDebug(67100) << "KMixWindow::addMixerWidget() " << mixer_ID << " is being added";
546
ViewBase::ViewFlags vflags = ViewBase::HasMenuBar;
547
if ( (_actionShowMenubar==0) || _actionShowMenubar->isChecked() ) {
548
vflags |= ViewBase::MenuBarVisible;
550
if ( m_toplevelOrientation == Qt::Vertical ) {
551
vflags |= ViewBase::Horizontal;
554
vflags |= ViewBase::Vertical;
558
KMixerWidget *kmw = new KMixerWidget( mixer, this, "KMixerWidget", vflags, actionCollection() );
560
/* A newly added mixer will automatically added at the top
561
* and thus the window title is also set appropriately */
562
bool isFirstTab = m_wsMixers->count() == 0;
563
m_wsMixers->addTab( kmw, kmw->mixer()->readableName() );
564
if (isFirstTab || kmw->mixer()->id() == m_defaultCardOnStart ) {
565
m_dontSetDefaultCardOnStart = true; // inhipbit implicit stting of m_defaultCardOnStart
566
m_wsMixers->setCurrentWidget(kmw);
567
m_dontSetDefaultCardOnStart = false;
568
if ( m_defaultCardOnStart.isEmpty() )
569
m_defaultCardOnStart = kmw->mixer()->id(); // If there was noc configuration file entry
572
kmw->loadConfig( KGlobal::config().data() );
574
kmw->setTicks( m_showTicks );
575
kmw->setLabels( m_showLabels );
576
kmw->mixer()->readSetFromHWforceUpdate();
577
} // given mixer exist really
582
bool KMixWindow::queryClose ( )
584
// kDebug(67100) << "queryClose ";
585
if ( m_showDockWidget && !kapp->sessionSaving() )
587
// kDebug(67100) << "don't close";
588
// Hide (don't close and destroy), if docking is enabled. Except when session saving (shutdown) is in process.
593
// Accept the close, if:
594
// The user has disabled docking
595
// or SessionSaving() is running
596
// kDebug(67100) << "close";
601
void KMixWindow::hideOrClose ( )
603
if ( m_showDockWidget && m_dockWidget != 0) {
604
// we can hide if there is a dock widget
608
// if there is no dock widget, we will quit
613
// internal helper to prevent code duplication in slotIncreaseVolume and slotDecreaseVolume
614
void KMixWindow::increaseOrDecreaseVolume(bool increase)
616
Mixer* mixer = Mixer::getGlobalMasterMixer(); // only needed for the awkward construct below
617
if ( mixer == 0 ) return; // e.g. when no soundcard is available
618
MixDevice *md = Mixer::getGlobalMasterMD();
619
if ( md == 0 ) return; // shouldn't happen, but lets play safe
622
mixer->increaseVolume(md->id()); // this is awkward. Better move the increaseVolume impl to the Volume class.
624
mixer->decreaseVolume(md->id());
625
// md->playbackVolume().increase(); // not yet implemented
629
void KMixWindow::slotIncreaseVolume()
631
increaseOrDecreaseVolume(true);
634
void KMixWindow::slotDecreaseVolume()
636
increaseOrDecreaseVolume(false);
639
void KMixWindow::showVolumeDisplay()
641
Mixer* mixer = Mixer::getGlobalMasterMixer();
642
if ( mixer == 0 ) return; // e.g. when no soundcard is available
643
MixDevice *md = Mixer::getGlobalMasterMD();
644
if ( md == 0 ) return; // shouldn't happen, but lets play safe
645
int currentVolume = mixer->volume(md->id());
647
osdWidget->setCurrentVolume(currentVolume, md->isMuted());
649
osdWidget->activateOSD(); //Enable the hide timer
652
QRect rect = KApplication::kApplication()->desktop()->screenGeometry(QCursor::pos());
653
QSize size = osdWidget->sizeHint();
654
int posX = rect.x() + (rect.width() - size.width()) / 2;
655
int posY = rect.y() + 4 * rect.height() / 5;
656
osdWidget->setGeometry(posX, posY, size.width(), size.height());
659
void KMixWindow::slotMute()
661
Mixer* mixer = Mixer::getGlobalMasterMixer();
662
if ( mixer == 0 ) return; // e.g. when no soundcard is available
663
MixDevice *md = Mixer::getGlobalMasterMD();
664
if ( md == 0 ) return; // shouldn't happen, but lets play safe
665
mixer->toggleMute(md->id());
669
void KMixWindow::quit()
671
// kDebug(67100) << "quit";
676
void KMixWindow::showSettings()
678
if (!m_prefDlg->isVisible())
680
// copy actual values to dialog
681
m_prefDlg->m_dockingChk->setChecked( m_showDockWidget );
682
m_prefDlg->m_volumeChk->setChecked(m_volumeWidget);
683
m_prefDlg->m_volumeChk->setEnabled( m_showDockWidget );
684
m_prefDlg->m_onLogin->setChecked( m_onLogin );
686
m_prefDlg->m_showTicks->setChecked( m_showTicks );
687
m_prefDlg->m_showLabels->setChecked( m_showLabels );
688
m_prefDlg->_rbVertical ->setChecked( m_toplevelOrientation == Qt::Vertical );
689
m_prefDlg->_rbHorizontal->setChecked( m_toplevelOrientation == Qt::Horizontal );
697
void KMixWindow::showHelp()
699
actionCollection()->action( "help_contents" )->trigger();
704
KMixWindow::showAbout()
706
actionCollection()->action( "help_about_app" )->trigger();
711
void KMixWindow::applyPrefs( KMixPrefDlg *prefDlg )
713
bool labelsHasChanged = m_showLabels ^ prefDlg->m_showLabels->isChecked();
714
bool ticksHasChanged = m_showTicks ^ prefDlg->m_showTicks->isChecked();
715
bool dockwidgetHasChanged = m_showDockWidget ^ prefDlg->m_dockingChk->isChecked();
716
bool systrayPopupHasChanged = m_volumeWidget ^ prefDlg->m_volumeChk->isChecked();
717
bool toplevelOrientationHasChanged =
718
( prefDlg->_rbVertical->isChecked() && m_toplevelOrientation == Qt::Horizontal )
719
|| ( prefDlg->_rbHorizontal->isChecked() && m_toplevelOrientation == Qt::Vertical );
721
m_showLabels = prefDlg->m_showLabels->isChecked();
722
m_showTicks = prefDlg->m_showTicks->isChecked();
723
m_showDockWidget = prefDlg->m_dockingChk->isChecked();
724
m_volumeWidget = prefDlg->m_volumeChk->isChecked();
725
m_onLogin = prefDlg->m_onLogin->isChecked();
726
if ( prefDlg->_rbVertical->isChecked() ) {
727
m_toplevelOrientation = Qt::Vertical;
729
else if ( prefDlg->_rbHorizontal->isChecked() ) {
730
m_toplevelOrientation = Qt::Horizontal;
733
if ( labelsHasChanged || ticksHasChanged || dockwidgetHasChanged || toplevelOrientationHasChanged || systrayPopupHasChanged) {
737
this->repaint(); // make KMix look fast (saveConfig() often uses several seconds)
738
kapp->processEvents();
743
void KMixWindow::toggleMenuBar()
745
menuBar()->setVisible(_actionShowMenubar->isChecked());
749
void KMixWindow::showEvent( QShowEvent * )
751
if ( m_visibilityUpdateAllowed )
752
m_isVisible = isVisible();
755
void KMixWindow::hideEvent( QHideEvent * )
757
if ( m_visibilityUpdateAllowed )
759
m_isVisible = isVisible();
763
void KMixWindow::stopVisibilityUpdates()
765
m_visibilityUpdateAllowed = false;
769
void KMixWindow::slotHWInfo()
771
KMessageBox::information( 0, m_hwInfoString, i18n("Mixer Hardware Information") );
774
void KMixWindow::slotConfigureCurrentView()
776
KMixerWidget* mw = (KMixerWidget*)m_wsMixers->currentWidget();
778
if (mw) view = mw->currentView();
779
if (view) view->configureView();
782
void KMixWindow::slotSelectMaster()
784
DialogSelectMaster* dsm = new DialogSelectMaster(Mixer::getGlobalMasterMixer());
785
if (dsm) dsm->show();
788
void KMixWindow::newMixerShown(int /*tabIndex*/ ) {
789
KMixerWidget* mw = (KMixerWidget*)m_wsMixers->currentWidget();
791
setWindowTitle( mw->mixer()->readableName() );
792
if ( ! m_dontSetDefaultCardOnStart )
793
m_defaultCardOnStart = mw->mixer()->id();
794
// As switching the tab does NOT mean switching the master card, we do not need to update dock icon here.
795
// It would lead to unnecesary flickering of the (complete) dock area.