summaryrefslogtreecommitdiffstats
path: root/kmix/kmix.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'kmix/kmix.cpp')
-rw-r--r--kmix/kmix.cpp293
1 files changed, 103 insertions, 190 deletions
diff --git a/kmix/kmix.cpp b/kmix/kmix.cpp
index 1ac09d85..20e9c58f 100644
--- a/kmix/kmix.cpp
+++ b/kmix/kmix.cpp
@@ -19,11 +19,16 @@
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
// include files for QT
#include <tqmap.h>
#include <tqhbox.h>
#include <tqcheckbox.h>
#include <tqradiobutton.h>
+#include <tqpushbutton.h>
#include <tqwidgetstack.h>
#include <tqlayout.h>
#include <tqtooltip.h>
@@ -46,51 +51,51 @@
#include <tdeaccel.h>
#include <kglobalaccel.h>
#include <kkeydialog.h>
+#include <tdeconfigdialog.h>
// application specific includes
#include "mixertoolbox.h"
#include "kmix.h"
#include "kmixerwidget.h"
-#include "kmixprefdlg.h"
#include "kmixdockwidget.h"
#include "kmixtoolbox.h"
+#include "kmixsettings.h"
+#include "behaviorconfig.h"
+#include "appearanceconfig.h"
+
+#ifdef WITH_KMIX_EXPERIMENTAL
+#include "experimental.h"
+#endif
/**
* Constructs a mixer window (KMix main window)
*/
KMixWindow::KMixWindow()
- : DCOPObject("kmix"), TDEMainWindow(0, 0, 0, 0), m_showTicks( true ),
- m_dockWidget( 0L )
+ : DCOPObject("kmix"), TDEMainWindow(0, 0, 0, 0), m_dockWidget( 0L )
{
m_visibilityUpdateAllowed = true;
- m_multiDriverMode = false; // -<- I never-ever want the multi-drivermode to be activated by accident
- m_surroundView = false; // -<- Also the experimental surround View (3D)
- m_gridView = false; // -<- Also the experimental Grid View
- // As long as we do not know better, we assume to start hidden. We need
- // to initialize this variable here, as we don't trigger a hideEvent().
- m_isVisible = false;
m_mixerWidgets.setAutoDelete(true);
- loadConfig(); // Need to load config before initMixer(), due to "MultiDriver" keyword
- MixerToolBox::initMixer(Mixer::mixers(), m_multiDriverMode, m_hwInfoString);
+
+#ifdef WITH_KMIX_EXPERIMENTAL
+ MixerToolBox::initMixer(Mixer::mixers(), KMixSettings::multiDriver(), m_hwInfoString);
+#else
+ MixerToolBox::initMixer(Mixer::mixers(), false, m_hwInfoString);
+#endif
+
+ loadConfig();
initActions();
initWidgets();
initMixerWidgets();
-
- initPrefDlg();
updateDocking();
- if ( m_startVisible )
+ if ( KMixSettings::visible() )
{
- /* Started visible: We should do probably do:
- * m_isVisible = true;
- * But as a showEvent() is triggered by show() we don't need it.
- */
- show();
+ show();
}
else
{
- hide();
+ hide();
}
connect( kapp, TQT_SIGNAL( aboutToQuit()), TQT_SLOT( saveSettings()) );
}
@@ -110,7 +115,7 @@ KMixWindow::initActions()
// settings menu
KStdAction::showMenubar( TQT_TQOBJECT(this), TQT_SLOT(toggleMenuBar()), actionCollection());
- KStdAction::preferences( TQT_TQOBJECT(this), TQT_SLOT(showSettings()), actionCollection());
+ KStdAction::preferences( TQT_TQOBJECT(this), TQT_SLOT(showSettings()), actionCollection());
new TDEAction( i18n( "Configure &Global Shortcuts..." ), "configure_shortcuts", 0, TQT_TQOBJECT(this),
TQT_SLOT( configureGlobalShortcuts() ), actionCollection(), "settings_global" );
KStdAction::keyBindings( guiFactory(), TQT_SLOT(configureShortcuts()), actionCollection());
@@ -131,16 +136,6 @@ KMixWindow::initActions()
createGUI( "kmixui.rc" );
}
-
-void
-KMixWindow::initPrefDlg()
-{
- m_prefDlg = new KMixPrefDlg( this );
- connect( m_prefDlg, TQT_SIGNAL(signalApplied(KMixPrefDlg *)),
- this, TQT_SLOT(applyPrefs(KMixPrefDlg *)) );
-}
-
-
void
KMixWindow::initWidgets()
{
@@ -172,7 +167,7 @@ KMixWindow::initWidgets()
widgetsLayout->setStretchFactor( m_wsMixers, 10 );
widgetsLayout->addWidget( m_wsMixers );
- if ( m_showMenubar )
+ if ( KMixSettings::menubar() )
menuBar()->show();
else
menuBar()->hide();
@@ -191,10 +186,10 @@ KMixWindow::updateDocking()
m_dockWidget = 0L;
}
- if (m_showDockWidget)
+ if ( KMixSettings::allowDocking() )
{
// create dock widget
- m_dockWidget = new KMixDockWidget( Mixer::mixers().first(), this, "mainDockWidget", m_volumeWidget, m_dockIconMuting );
+ m_dockWidget = new KMixDockWidget( Mixer::mixers().first(), this, "mainDockWidget", KMixSettings::trayVolumeControl(), KMixSettings::dockIconMuting() );
m_dockWidget->show();
}
}
@@ -209,49 +204,28 @@ KMixWindow::saveSettings()
void
KMixWindow::saveConfig()
{
- TDEConfig *config = kapp->config();
- config->setGroup(0);
-
- // make sure we don't start without any UI
- // can happen e.g. when not docked and kmix closed via 'X' button
- bool startVisible = m_isVisible;
- if ( !m_showDockWidget )
+ // make sure we don't start without any UI (in case the tray icon is disabled)
+ bool startVisible = KMixSettings::visible();
+ if ( !KMixSettings::allowDocking() )
+ {
startVisible = true;
+ }
+
+ KMixSettings::setSize(size());
+ KMixSettings::setPosition(pos());
+ KMixSettings::setVisible(startVisible);
- config->writeEntry( "Size", size() );
- config->writeEntry( "Position", pos() );
- // Cannot use isVisible() here, as in the "aboutToQuit()" case this widget is already hidden.
- // (Please note that the problem was only there when quitting via Systray - esken).
- config->writeEntry( "Visible", startVisible );
- config->writeEntry( "Menubar", m_showMenubar );
- config->writeEntry( "AllowDocking", m_showDockWidget );
- config->writeEntry( "TrayVolumeControl", m_volumeWidget );
- config->writeEntry( "Tickmarks", m_showTicks );
- config->writeEntry( "Labels", m_showLabels );
- config->writeEntry( "starttdeRestore", m_onLogin );
- config->writeEntry( "DockIconMuting", m_dockIconMuting );
Mixer* mixerMasterCard = Mixer::masterCard();
- if ( mixerMasterCard != 0 ) {
- config->writeEntry( "MasterMixer", mixerMasterCard->id() );
+ if ( mixerMasterCard != 0 )
+ {
+ KMixSettings::setMasterMixer(mixerMasterCard->id());
}
MixDevice* mdMaster = Mixer::masterCardDevice();
- if ( mdMaster != 0 ) {
- config->writeEntry( "MasterMixerDevice", mdMaster->getPK() );
+ if ( mdMaster != 0 )
+ {
+ KMixSettings::setMasterMixerDevice(mdMaster->getPK());
}
- if ( m_valueStyle == MixDeviceWidget::NABSOLUTE )
- config->writeEntry( "ValueStyle", "Absolute");
- else if ( m_valueStyle == MixDeviceWidget::NRELATIVE )
- config->writeEntry( "ValueStyle", "Relative");
- else
- config->writeEntry( "ValueStyle", "None" );
-
- if ( m_toplevelOrientation == Qt::Vertical )
- config->writeEntry( "Orientation","Vertical" );
- else
- config->writeEntry( "Orientation","Horizontal" );
- config->writeEntry( "Autostart", m_autoStart );
-
// save mixer widgets
for ( KMixerWidget *mw = m_mixerWidgets.first(); mw != 0; mw = m_mixerWidgets.next() )
{
@@ -259,72 +233,37 @@ KMixWindow::saveConfig()
{ // protect from unplugged devices (better do *not* save them)
TQString grp;
grp.sprintf( "%i", mw->id() );
- mw->saveConfig( config, grp );
+ mw->saveConfig( TDESharedConfig::openConfig("kmixrc"), grp );
}
}
- config->setGroup(0);
+ KMixSettings::writeConfig();
}
void
KMixWindow::loadConfig()
{
- TDEConfig *config = kapp->config();
- config->setGroup(0);
-
- m_showDockWidget = config->readBoolEntry("AllowDocking", true);
- m_volumeWidget = config->readBoolEntry("TrayVolumeControl", true);
- //hide on close has to stay true for usability. KMixPrefDlg option commented out. nolden
- m_hideOnClose = config->readBoolEntry("HideOnClose", true);
- m_showTicks = config->readBoolEntry("Tickmarks", true);
- m_showLabels = config->readBoolEntry("Labels", true);
- const TQString& valueStyleString = config->readEntry("ValueStyle", "None");
- m_onLogin = config->readBoolEntry("starttdeRestore", true );
- m_dockIconMuting = config->readBoolEntry( "DockIconMuting", false);
- m_startVisible = config->readBoolEntry("Visible", false);
- m_multiDriverMode = config->readBoolEntry("MultiDriver", false);
- m_surroundView = config->readBoolEntry("Experimental-ViewSurround", false );
- m_gridView = config->readBoolEntry("Experimental-ViewGrid", false );
- const TQString& orientationString = config->readEntry("Orientation", "Horizontal");
- bool useDefaultMaster = config->readBoolEntry( "UseDefaultMaster", true );
- if (!useDefaultMaster)
+ if (!KMixSettings::useDefaultMaster())
{
- TQString mixerMasterCard = config->readEntry( "MasterMixer", "" );
- Mixer::setMasterCard(mixerMasterCard);
- TQString masterDev = config->readEntry( "MasterMixerDevice", "" );
- Mixer::setMasterCardDevice(masterDev);
+ Mixer::setMasterCard(KMixSettings::masterMixer());
+ Mixer::setMasterCardDevice(KMixSettings::masterMixerDevice());
}
- if ( valueStyleString == "Absolute" )
- m_valueStyle = MixDeviceWidget::NABSOLUTE;
- else if ( valueStyleString == "Relative" )
- m_valueStyle = MixDeviceWidget::NRELATIVE;
- else
- m_valueStyle = MixDeviceWidget::NNONE;
-
- if ( orientationString == "Vertical" )
- m_toplevelOrientation = Qt::Vertical;
- else
- m_toplevelOrientation = Qt::Horizontal;
- m_autoStart = config->readBoolEntry("Autostart", true);
-
- // show/hide menu bar
- m_showMenubar = config->readBoolEntry("Menubar", true);
+ m_toplevelOrientation = static_cast<TQt::Orientation>(KMixSettings::orientation());
TDEToggleAction *a = static_cast<TDEToggleAction*>(actionCollection()->action("options_show_menubar"));
- if (a) a->setChecked( m_showMenubar );
+ if (a) a->setChecked( KMixSettings::menubar() );
// restore window size and position
if ( !kapp->isRestored() ) // done by the session manager otherwise
{
- TQSize defSize( minimumWidth(), height() );
- TQSize size = config->readSizeEntry("Size", &defSize );
- if(!size.isEmpty()) resize(size);
-
- TQPoint defPos = pos();
- TQPoint pos = config->readPointEntry("Position", &defPos);
- move(pos);
- }
+ TQSize size = KMixSettings::size();
+ if(!size.isEmpty())
+ {
+ resize(size);
+ }
+ move(KMixSettings::position());
+ }
}
@@ -342,19 +281,23 @@ KMixWindow::initMixerWidgets()
{
//kdDebug(67100) << "Mixer number: " << id << " Name: " << mixer->mixerName() << endl ;
ViewBase::ViewFlags vflags = ViewBase::HasMenuBar;
- if ( m_showMenubar ) {
+ if (KMixSettings::menubar()) {
vflags |= ViewBase::MenuBarVisible;
}
- if ( m_surroundView ) {
+
+#ifdef WITH_KMIX_EXPERIMENTAL
+ if (KMixSettings::experimental_ViewSurround()) {
vflags |= ViewBase::Experimental_SurroundView;
}
- if ( m_gridView ) {
+ if (KMixSettings::experimental_ViewGrid()) {
vflags |= ViewBase::Experimental_GridView;
}
- if ( m_toplevelOrientation == Qt::Vertical ) {
+#endif
+
+ if ( m_toplevelOrientation == TQt::Vertical ) {
vflags |= ViewBase::Vertical;
}
- else {
+ else {
vflags |= ViewBase::Horizontal;
}
@@ -369,11 +312,11 @@ KMixWindow::initMixerWidgets()
TQString grp;
grp.sprintf( "%i", mw->id() );
- mw->loadConfig( kapp->config(), grp );
+ mw->loadConfig( TDESharedConfig::openConfig("kmixrc"), grp );
- mw->setTicks( m_showTicks );
- mw->setLabels( m_showLabels );
- mw->setValueStyle ( m_valueStyle );
+ mw->setTicks(KMixSettings::tickmarks());
+ mw->setLabels(KMixSettings::labels());
+ mw->setValueStyle(KMixSettings::valueStyle());
// !! I am still not sure whether this works 100% reliably - chris
mw->show();
}
@@ -390,7 +333,7 @@ KMixWindow::initMixerWidgets()
bool
KMixWindow::queryClose ( )
{
- if ( m_showDockWidget && !kapp->sessionSaving() )
+ if ( KMixSettings::allowDocking() && !kapp->sessionSaving() )
{
hide();
return false;
@@ -409,25 +352,28 @@ KMixWindow::quit()
void
KMixWindow::showSettings()
{
- if (!m_prefDlg->isVisible())
+ if (TDEConfigDialog::showDialog("KMixConfigDialog"))
{
- m_prefDlg->m_dockingChk->setChecked( m_showDockWidget );
- m_prefDlg->m_volumeChk->setChecked(m_volumeWidget);
- m_prefDlg->m_showTicks->setChecked( m_showTicks );
- m_prefDlg->m_showLabels->setChecked( m_showLabels );
- m_prefDlg->m_onLogin->setChecked( m_onLogin );
- m_prefDlg->m_dockIconMuting->setChecked( m_dockIconMuting );
- m_prefDlg->_rbVertical ->setChecked( m_toplevelOrientation == Qt::Vertical );
- m_prefDlg->_rbHorizontal->setChecked( m_toplevelOrientation == Qt::Horizontal );
- m_prefDlg->_rbNone->setChecked( m_valueStyle == MixDeviceWidget::NNONE );
- m_prefDlg->_rbAbsolute->setChecked( m_valueStyle == MixDeviceWidget::NABSOLUTE );
- m_prefDlg->_rbRelative->setChecked( m_valueStyle == MixDeviceWidget::NRELATIVE );
- m_prefDlg->m_autoStartChk->setChecked( m_autoStart );
-
- m_prefDlg->show();
+ return;
}
-}
+ TDEConfigDialog *cfg = new TDEConfigDialog(this, "KMixConfigDialog", KMixSettings::self());
+
+ KMixBehaviorConfig *cfgb = new KMixBehaviorConfig(0, "Behavior");
+ cfg->addPage(cfgb, i18n("Behavior"), "configure");
+
+ KMixAppearanceConfig *cfga = new KMixAppearanceConfig(0, "Appearance");
+ cfg->addPage(cfga, i18n("Appearance"), "kmix");
+
+#ifdef WITH_KMIX_EXPERIMENTAL
+ KMixExperimental *cfgx = new KMixExperimental(0, "Experimental");
+ cfg->addPage(cfgx, i18n("Experimental"), "bug");
+#endif
+
+ connect(cfg, TQT_SIGNAL(settingsChanged()), this, TQT_SLOT(applyPrefs()));
+
+ cfg->show();
+}
void
KMixWindow::showHelp()
@@ -480,60 +426,28 @@ KMixWindow::saveVolumes()
void
-KMixWindow::applyPrefs( KMixPrefDlg *prefDlg )
-{
- m_showDockWidget = prefDlg->m_dockingChk->isChecked();
- m_volumeWidget = prefDlg->m_volumeChk->isChecked();
- m_showTicks = prefDlg->m_showTicks->isChecked();
- m_showLabels = prefDlg->m_showLabels->isChecked();
- m_onLogin = prefDlg->m_onLogin->isChecked();
- m_dockIconMuting = prefDlg->m_dockIconMuting->isChecked();
-
- if ( prefDlg->_rbNone->isChecked() ) {
- m_valueStyle = MixDeviceWidget::NNONE;
- } else if ( prefDlg->_rbAbsolute->isChecked() ) {
- m_valueStyle = MixDeviceWidget::NABSOLUTE;
- } else if ( prefDlg->_rbRelative->isChecked() ) {
- m_valueStyle = MixDeviceWidget::NRELATIVE;
- }
-
- bool toplevelOrientationHasChanged =
- ( prefDlg->_rbVertical->isChecked() && m_toplevelOrientation == Qt::Horizontal )
- || ( prefDlg->_rbHorizontal->isChecked() && m_toplevelOrientation == Qt::Vertical );
- if ( toplevelOrientationHasChanged ) {
+KMixWindow::applyPrefs()
+{
+ auto old = static_cast<TQt::Orientation>(KMixSettings::orientation());
+ if (m_toplevelOrientation != old)
+ {
TQString msg = i18n("The change of orientation will be adopted on the next start of KMix.");
- KMessageBox::information(0,msg);
- }
- if ( prefDlg->_rbVertical->isChecked() ) {
- //kdDebug(67100) << "KMix should change to Vertical layout\n";
- m_toplevelOrientation = Qt::Vertical;
+ KMessageBox::information(0, msg);
}
- else if ( prefDlg->_rbHorizontal->isChecked() ) {
- //kdDebug(67100) << "KMix should change to Horizontal layout\n";
- m_toplevelOrientation = Qt::Horizontal;
- }
- m_autoStart = prefDlg->m_autoStartChk->isChecked();
-
this->setUpdatesEnabled(false);
updateDocking();
for (KMixerWidget *mw=m_mixerWidgets.first(); mw!=0; mw=m_mixerWidgets.next())
{
- mw->setTicks( m_showTicks );
- mw->setLabels( m_showLabels );
- mw->setValueStyle ( m_valueStyle );
+ mw->setTicks( KMixSettings::tickmarks() );
+ mw->setLabels( KMixSettings::labels() );
+ mw->setValueStyle( KMixSettings::valueStyle() );
mw->mixer()->readSetFromHWforceUpdate(); // needed, as updateDocking() has reconstructed the DockWidget
}
this->setUpdatesEnabled(true);
- // avoid invisible and unaccessible main window
- if( !m_showDockWidget && !isVisible() )
- {
- show();
- }
-
this->repaint(); // make KMix look fast (saveConfig() often uses several seconds)
kapp->processEvents();
saveConfig();
@@ -543,14 +457,13 @@ KMixWindow::applyPrefs( KMixPrefDlg *prefDlg )
void
KMixWindow::toggleMenuBar()
{
- m_showMenubar = !m_showMenubar;
- if( m_showMenubar )
+ if( menuBar()->isShown() )
{
- menuBar()->show();
+ menuBar()->hide();
}
else
{
- menuBar()->hide();
+ menuBar()->show();
}
}