Commit ac06083d authored by Christian Esken's avatar Christian Esken
Browse files

Add enabling/disablign of configuration dialog "apply" button

CCBUGS:328599
parent 4369fda4
......@@ -425,7 +425,7 @@ QString Mixer::readableName(bool ampersandQuoted)
if ( getCardInstance() > 1)
finalName = finalName.append(" %1").arg(getCardInstance());
kDebug() << "name=" << _mixerBackend->getName() << "instance=" << getCardInstance() << ", finalName" << finalName;
// kDebug() << "name=" << _mixerBackend->getName() << "instance=" << getCardInstance() << ", finalName" << finalName;
return finalName;
}
......
......@@ -46,7 +46,7 @@
* @param noButtons is a migration option. When DialogChooseBackends has been integrated as a Tab, it will be removed.
*/
DialogChooseBackends::DialogChooseBackends(QWidget* parent, const QSet<QString>& mixerIds)
: QWidget(parent)
: QWidget(parent), modified(false)
{
// setCaption( i18n( "Select Mixers" ) );
// setButtons( None );
......@@ -114,6 +114,7 @@ void DialogChooseBackends::createPage(const QSet<QString>& mixerIds)
{
QCheckBox* qrb = new QCheckBox(mixer->readableName(true), m_vboxForScrollView);
qrb->setObjectName(mixer->id());// The object name is used as ID here: see getChosenBackends()
connect(qrb, SIGNAL(stateChanged(int)), SLOT(backendsModifiedSlot()));
checkboxes.append(qrb);
bool mixerShouldBeShown = !hasMixerFilter || mixerIds.contains(mixer->id());
qrb->setChecked(mixerShouldBeShown);
......@@ -138,5 +139,27 @@ QSet<QString> DialogChooseBackends::getChosenBackends()
return newMixerList;
}
/**
* Returns whether there were any modifications (activation/deactivation) and resets the flag.
* @return
*/
bool DialogChooseBackends::getAndResetModifyFlag()
{
bool modifiedOld = modified;
modified = false;
return modifiedOld;
}
bool DialogChooseBackends::getModifyFlag()
{
return modified;
}
void DialogChooseBackends::backendsModifiedSlot()
{
modified = true;
emit backendsModified();
}
#include "dialogchoosebackends.moc"
......@@ -34,24 +34,33 @@ class KComboBox;
class Mixer;
class DialogChooseBackends : public QWidget
class DialogChooseBackends: public QWidget
{
Q_OBJECT
public:
DialogChooseBackends(QWidget* parent, const QSet<QString>& backends);
~DialogChooseBackends();
QSet<QString> getChosenBackends();
private:
void createWidgets(const QSet<QString>& backends);
void createPage(const QSet<QString>& backends);
QVBoxLayout* _layout;
QScrollArea* m_scrollableChannelSelector;
KVBox *m_vboxForScrollView;
QButtonGroup *m_buttonGroupForScrollView;
QList<QCheckBox*> checkboxes;
QWidget *m_mainFrame;
Q_OBJECT
public:
DialogChooseBackends(QWidget* parent, const QSet<QString>& backends);
~DialogChooseBackends();
QSet<QString> getChosenBackends();
bool getAndResetModifyFlag();
bool getModifyFlag();
signals:
void backendsModified();
private:
void createWidgets(const QSet<QString>& backends);
void createPage(const QSet<QString>& backends);
QVBoxLayout* _layout;
QScrollArea* m_scrollableChannelSelector;
KVBox *m_vboxForScrollView;
QButtonGroup *m_buttonGroupForScrollView;
QList<QCheckBox*> checkboxes;
QWidget *m_mainFrame;
bool modified;
private slots:
void backendsModifiedSlot();
};
#endif
......@@ -111,11 +111,6 @@ void KMixPrefDlg::switchToPage(KMixPrefPage page)
show();
}
void KMixPrefDlg::setActiveMixersInDock(QSet<QString>& mixerIds)
{
replaceBackendsInTab(mixerIds);
}
// --- TABS --------------------------------------------------------------------------------------------------
void KMixPrefDlg::createStartupTab()
......@@ -244,14 +239,6 @@ void KMixPrefDlg::createGeneralTab()
layout->addStretch();
}
void KMixPrefDlg::todoRemoveThisMethodAndInitBackendsCorrectly()
{
replaceBackendsInTab(GlobalConfig::instance().getMixersForSoundmenu());
// GlobalConfig::instance().getMixersForSoundmenu();
// QSet<QString> emptyBackendList;
// replaceBackendsInTab(emptyBackendList);
}
void KMixPrefDlg::createControlsTab()
{
layoutControlsTab = new QVBoxLayout(m_controlsTab);
......@@ -262,7 +249,7 @@ void KMixPrefDlg::createControlsTab()
addWidgetToLayout(m_dockingChk, layoutControlsTab, 10, i18n("Docks the mixer into the KDE system tray"),
"AllowDocking");
todoRemoveThisMethodAndInitBackendsCorrectly();
replaceBackendsInTab();
}
......@@ -335,10 +322,12 @@ void KMixPrefDlg::updateSettings()
// Announcing MasterChanged, as the sound menu (aka ViewDockAreaPopup) primarily shows master volume(s).
// In any case, ViewDockAreaPopup treats MasterChanged and ControlList the same, so it is better to announce
// the "smaller" change.
GlobalConfig::instance().setMixersForSoundmenu(dvc->getChosenBackends());
ControlManager::instance().announce(QString(), ControlChangeType::MasterChanged, QString("Select Backends Dialog"));
// emit(kmixConfigHasChanged());
bool modified = dvc->getAndResetModifyFlag();
if (modified)
{
GlobalConfig::instance().setMixersForSoundmenu(dvc->getChosenBackends());
ControlManager::instance().announce(QString(), ControlChangeType::MasterChanged, QString("Select Backends Dialog"));
}
}
void KMixPrefDlg::kmixConfigHasChangedEmitter()
......@@ -349,18 +338,31 @@ void KMixPrefDlg::kmixConfigHasChangedEmitter()
/**
* Returns whether the custom widgets (orientation checkboxes) have changed.
* Returns whether the custom widgets (orientation checkboxes) has changed.
* <p>
* Hint: this get internally called by KConfigDialog from updateButtons().
* @return
*/
bool KMixPrefDlg::hasChanged()
{
bool changed = ((dialogConfig.data.getToplevelOrientation() == Qt::Vertical) ^ _rbHorizontal->isChecked());
bool orientationFromConfigIsHor = dialogConfig.data.getToplevelOrientation() == Qt::Horizontal;
bool orientationFromWidgetIsHor = _rbHorizontal->isChecked();
kDebug() << "Orientation MAIN fromConfig=" << (orientationFromConfigIsHor ? "Hor" : "Vert") << ", fromWidget=" << (orientationFromWidgetIsHor ? "Hor" : "Vert");
bool changed = orientationFromConfigIsHor ^ orientationFromWidgetIsHor;
if (!changed)
{
changed = ((dialogConfig.data.getTraypopupOrientation() == Qt::Vertical) ^ _rbTraypopupHorizontal->isChecked());
bool orientationFromConfigIsHor = dialogConfig.data.getTraypopupOrientation() == Qt::Horizontal;
orientationFromWidgetIsHor = _rbTraypopupHorizontal->isChecked();
kDebug() << "Orientation TRAY fromConfig=" << (orientationFromConfigIsHor ? "Hor" : "Vert") << ", fromWidget=" << (orientationFromWidgetIsHor ? "Hor" : "Vert");
changed = orientationFromConfigIsHor ^ orientationFromWidgetIsHor;
}
if (!changed)
{
changed = dvc->getModifyFlag();
}
kDebug() << "hasChanged=" << changed;
return changed;
......@@ -371,7 +373,7 @@ void KMixPrefDlg::showEvent(QShowEvent * event)
{
// -1- Replace widgets ------------------------------------------------------------
// Hotplug can change mixers or backends => recreate tab
todoRemoveThisMethodAndInitBackendsCorrectly();
replaceBackendsInTab();
// -2- Change visibility and enable status (of the new widgets) ----------------------
......@@ -401,7 +403,7 @@ void KMixPrefDlg::showEvent(QShowEvent * event)
}
void KMixPrefDlg::replaceBackendsInTab(const QSet<QString>& backends)
void KMixPrefDlg::replaceBackendsInTab()
{
if (dvc != 0)
{
......@@ -411,6 +413,8 @@ void KMixPrefDlg::replaceBackendsInTab(const QSet<QString>& backends)
QSet<QString> backendsFromConfig = GlobalConfig::instance().getMixersForSoundmenu();
dvc = new DialogChooseBackends(0, backendsFromConfig);
connect(dvc, SIGNAL(backendsModified()), SLOT(updateButtons()));
dvc->show();
layoutControlsTab->addWidget(dvc);
......
......@@ -53,7 +53,6 @@ public:
static KMixPrefDlg* createInstance(QWidget *parent, GlobalConfig& config);
static KMixPrefDlg* getInstance();
void switchToPage(KMixPrefPage page);
void setActiveMixersInDock(QSet<QString>& mixerIds);
signals:
void kmixConfigHasChanged();
......@@ -92,11 +91,10 @@ private:
void addWidgetToLayout(QWidget* widget, QBoxLayout* layout, int spacingBefore, QString tooltip, QString kconfigName);
void createStartupTab();
void replaceBackendsInTab(const QSet<QString>& backends);
void replaceBackendsInTab();
void createGeneralTab();
void createControlsTab();
void createOrientationGroup(const QString& labelSliderOrientation, QGridLayout* orientationLayout, int row, KMixPrefDlgPrefOrientationType type);
void todoRemoveThisMethodAndInitBackendsCorrectly();
QFrame *m_generalTab;
QFrame *m_startupTab;
......
......@@ -390,14 +390,14 @@ void ViewDockAreaPopup::configureView()
{
// Q_ASSERT( !pulseaudioPresent() );
QSet<QString> currentlyActiveMixersInDockArea;
foreach ( Mixer* mixer, _mixers )
{
currentlyActiveMixersInDockArea.insert(mixer->id());
}
// QSet<QString> currentlyActiveMixersInDockArea;
// foreach ( Mixer* mixer, _mixers )
// {
// currentlyActiveMixersInDockArea.insert(mixer->id());
// }
KMixPrefDlg* prefDlg = KMixPrefDlg::getInstance();
prefDlg->setActiveMixersInDock(currentlyActiveMixersInDockArea);
//prefDlg->setActiveMixersInDock(currentlyActiveMixersInDockArea);
prefDlg->switchToPage(KMixPrefDlg::PrefSoundMenu);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment