KMix: fixed 'select channel' dialog cancel logic.

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
pull/24/head
Michele Calgaro 5 years ago
parent 729d966302
commit 31e8d7b973
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -38,7 +38,7 @@
#include "mixdevice.h" #include "mixdevice.h"
#include "mixer.h" #include "mixer.h"
DialogSelectMaster::DialogSelectMaster( Mixer *mixer ) DialogSelectMaster::DialogSelectMaster(Mixer *mixer)
: KDialogBase( Plain, i18n( "Select Master Channel" ), Ok|Cancel, Ok ) : KDialogBase( Plain, i18n( "Select Master Channel" ), Ok|Cancel, Ok )
{ {
_layout = 0; _layout = 0;
@ -69,8 +69,8 @@ void DialogSelectMaster::createWidgets(Mixer *ptr_mixer)
m_vboxChannels = new TQVBox(m_mainFrame); m_vboxChannels = new TQVBox(m_mainFrame);
_layout->add(m_vboxChannels); _layout->add(m_vboxChannels);
if ( Mixer::mixers().count() > 1 ) { if (Mixer::mixers().count() > 1) {
//kdDebug(67100) << "DialogSelectMaster::createPage count()>1" << "\n"; //kdDebug(67100) << "DialogSelectMaster::createWidgets count()>1" << "\n";
// More than one Mixer => show Combo-Box to select Mixer // More than one Mixer => show Combo-Box to select Mixer
// Mixer widget line // Mixer widget line
TQHBox *hboxMixerName = new TQHBox(m_vboxChannels); TQHBox *hboxMixerName = new TQHBox(m_vboxChannels);
@ -84,19 +84,12 @@ void DialogSelectMaster::createWidgets(Mixer *ptr_mixer)
TQToolTip::add(m_cMixer, i18n("Current mixer")); TQToolTip::add(m_cMixer, i18n("Current mixer"));
connect(m_cMixer, TQT_SIGNAL(activated(int)), this, TQT_SLOT(createPageByID(int))); connect(m_cMixer, TQT_SIGNAL(activated(int)), this, TQT_SLOT(createPageByID(int)));
//int id=1;
for ( Mixer *mixer = Mixer::mixers().first(); mixer !=0; mixer = Mixer::mixers().next() ) { for ( Mixer *mixer = Mixer::mixers().first(); mixer !=0; mixer = Mixer::mixers().next() ) {
m_cMixer->insertItem( mixer->mixerName() ); m_cMixer->insertItem(mixer->mixerName());
if ( ptr_mixer == mixer ) { }
// Make the current Mixer the current item in the ComboBos }
m_cMixer->setCurrentItem( m_cMixer->count()-1 );
}
//id++;
} // end for all_Mixers
} // end if (more_than_1_Mixer)
TQLabel *qlbl = new TQLabel( i18n("Select the channel representing the master volume:"), m_vboxChannels ); TQLabel *qlbl = new TQLabel( i18n("Select the channel representing the master volume:"), m_vboxChannels );
_layout->addWidget(qlbl);
m_scrollableChannelSelector = new TQScrollView(m_vboxChannels, "scrollableChannelSelector"); m_scrollableChannelSelector = new TQScrollView(m_vboxChannels, "scrollableChannelSelector");
m_scrollableChannelSelector->viewport()->setBackgroundMode(TQt::PaletteBackground); m_scrollableChannelSelector->viewport()->setBackgroundMode(TQt::PaletteBackground);
@ -104,8 +97,11 @@ void DialogSelectMaster::createWidgets(Mixer *ptr_mixer)
m_buttonGroupForScrollView = new TQButtonGroup(this); // invisible TQButtonGroup m_buttonGroupForScrollView = new TQButtonGroup(this); // invisible TQButtonGroup
m_buttonGroupForScrollView->hide(); m_buttonGroupForScrollView->hide();
createPage(ptr_mixer); connect( this, TQT_SIGNAL(okClicked()) , this, TQT_SLOT(apply()) );
}
void DialogSelectMaster::show(Mixer *curr_mixer)
{
kapp->config()->setGroup(0); kapp->config()->setGroup(0);
bool useDefaultMaster = kapp->config()->readBoolEntry("UseDefaultMaster", true); bool useDefaultMaster = kapp->config()->readBoolEntry("UseDefaultMaster", true);
if (useDefaultMaster) if (useDefaultMaster)
@ -118,7 +114,16 @@ void DialogSelectMaster::createWidgets(Mixer *ptr_mixer)
} }
masterSelectionChanged(0); masterSelectionChanged(0);
connect( this, TQT_SIGNAL(okClicked()) , this, TQT_SLOT(apply()) ); for (Mixer *mixer = Mixer::mixers().first(); mixer; mixer = Mixer::mixers().next())
{
if (curr_mixer == mixer)
{
m_cMixer->setCurrentItem(mixer->mixerName());
}
}
createPage(curr_mixer);
KDialog::show();
} }
void DialogSelectMaster::masterSelectionChanged(int _unused) void DialogSelectMaster::masterSelectionChanged(int _unused)
@ -132,9 +137,10 @@ void DialogSelectMaster::masterSelectionChanged(int _unused)
*/ */
void DialogSelectMaster::createPageByID(int mixerId) void DialogSelectMaster::createPageByID(int mixerId)
{ {
//kdDebug(67100) << "DialogSelectMaster::createPage()" << endl; //kdDebug(67100) << "DialogSelectMaster::createPageByID()" << endl;
Mixer *mixer = Mixer::mixers().at(mixerId); Mixer *mixer = Mixer::mixers().at(mixerId);
if ( mixer == 0 ) { if (!mixer)
{
kdError(67100) << "DialogSelectMaster::createPage(): Invalid Mixer (mixerID=" << mixerId << ")" << endl; kdError(67100) << "DialogSelectMaster::createPage(): Invalid Mixer (mixerID=" << mixerId << ")" << endl;
return; // can not happen return; // can not happen
} }
@ -145,7 +151,7 @@ void DialogSelectMaster::createPageByID(int mixerId)
* Create RadioButton's for the Mixer with number 'mixerId'. * Create RadioButton's for the Mixer with number 'mixerId'.
* @par mixerId The Mixer, for which the RadioButton's should be created. * @par mixerId The Mixer, for which the RadioButton's should be created.
*/ */
void DialogSelectMaster::createPage(Mixer* mixer) void DialogSelectMaster::createPage(Mixer *mixer)
{ {
/** --- Reset page ----------------------------------------------- /** --- Reset page -----------------------------------------------
@ -186,7 +192,7 @@ void DialogSelectMaster::createPage(Mixer* mixer)
} }
} }
m_vboxForScrollView->show(); // show() is neccesary starting with the second call to createPage() m_vboxForScrollView->show(); // show() is necessary starting with the second call to createPage()
} }
@ -202,7 +208,7 @@ void DialogSelectMaster::apply()
//kdDebug(67100) << "DialogSelectMaster::apply(): default master=" << m_defaultMaster->isChecked() << ", card=" << soundcard_id << ", channel=" << channel_id << endl; //kdDebug(67100) << "DialogSelectMaster::apply(): default master=" << m_defaultMaster->isChecked() << ", card=" << soundcard_id << ", channel=" << channel_id << endl;
Mixer *mixer = Mixer::mixers().at(soundcard_id); Mixer *mixer = Mixer::mixers().at(soundcard_id);
if ( mixer == 0 ) { if ( mixer == 0 ) {
kdError(67100) << "DialogSelectMaster::createPage(): Invalid Mixer (mixerID=" << soundcard_id << ")" << endl; kdError(67100) << "DialogSelectMaster::apply(): Invalid Mixer (mixerID=" << soundcard_id << ")" << endl;
return; // can not happen return; // can not happen
} }
else { else {

@ -18,8 +18,9 @@ class DialogSelectMaster : public KDialogBase
Q_OBJECT Q_OBJECT
public: public:
DialogSelectMaster(Mixer *); DialogSelectMaster(Mixer *mixer);
~DialogSelectMaster(); ~DialogSelectMaster();
void show(Mixer *curr_mixer);
signals: signals:
void newMasterSelected(bool defaultMaster, int soundcard_id, const TQString &channel_id); void newMasterSelected(bool defaultMaster, int soundcard_id, const TQString &channel_id);

@ -173,7 +173,7 @@ void KMixDockWidget::selectMaster()
_dsm = new DialogSelectMaster(m_mixer); _dsm = new DialogSelectMaster(m_mixer);
connect(_dsm, TQT_SIGNAL(newMasterSelected(bool, int, const TQString&)), TQT_SLOT( handleNewMaster(bool, int, const TQString&))); connect(_dsm, TQT_SIGNAL(newMasterSelected(bool, int, const TQString&)), TQT_SLOT( handleNewMaster(bool, int, const TQString&)));
} }
_dsm->show(); _dsm->show(m_mixer);
} }

Loading…
Cancel
Save