Commit 873ddac9 authored by Jonathan Marten's avatar Jonathan Marten

ViewBase: Make protected data private, use access functions

parent 1658f158
......@@ -85,7 +85,11 @@ public:
ProfControl *findMdw(const QString &mdwId, GuiVisibility visibility = GuiVisibility::Default) const;
KActionCollection *actionCollection() const { return (_actions); }
const QList<Mixer*> &getMixers() const { return (_mixers); }
const QList<Mixer *> &getMixers() const { return (_mixers); }
void clearMixers() { _mixers.clear(); }
const MixSet &getMixSet() const { return (_mixSet); }
void addToMixSet(shared_ptr<MixDevice> md) { _mixSet.append(md); }
int mixDeviceCount() const { return (_mdws.count()); }
QWidget *mixDeviceAt(int i) const { return (_mdws.at(i)); }
......@@ -117,9 +121,9 @@ private:
void updateMediaPlaybackIcons();
void popupReset();
protected:
private:
MixSet _mixSet;
QList<Mixer*> _mixers;
QList<Mixer *> _mixers;
protected:
void resetMdws();
......
......@@ -296,11 +296,11 @@ Application: KMix (kmix), signal: Segmentation fault
// Adding all mixers, as we potentially want to show all master controls.
// Due to hotplugging we have to redo the list on each initLayout() instead of
// setting it once in the constructor.
_mixers.clear();
clearMixers();
QSet<QString> preferredMixersForSoundmenu = GlobalConfig::instance().getMixersForSoundmenu();
//qCDebug(KMIX_LOG) << "Launch with " << preferredMixersForSoundmenu;
foreach ( Mixer* mixer, Mixer::mixers() )
for (Mixer *mixer : qAsConst(Mixer::mixers()))
{
bool useMixer = preferredMixersForSoundmenu.isEmpty() || preferredMixersForSoundmenu.contains(mixer->id());
if (useMixer) addMixer(mixer);
......@@ -309,9 +309,9 @@ Application: KMix (kmix), signal: Segmentation fault
// The following loop is for the case when everything gets filtered out. We "reset" to show everything then.
// Hint: Filtering everything out can only be an "accident", e.g. when restarting KMix with changed hardware or
// backends.
if ( _mixers.isEmpty() )
if (getMixers().isEmpty())
{
foreach ( Mixer* mixer, Mixer::mixers() )
for (Mixer *mixer : qAsConst(Mixer::mixers()))
{
addMixer(mixer);
}
......@@ -334,7 +334,7 @@ Application: KMix (kmix), signal: Segmentation fault
//
// Maybe need a configuration option?
foreach (const Mixer *mixer, _mixers)
for (const Mixer *mixer : qAsConst(getMixers()))
{
//qCDebug(KMIX_LOG) << "ADD? mixerId=" << mixer->id();
// Get the configured master control for the mixer.
......@@ -355,17 +355,17 @@ Application: KMix (kmix), signal: Segmentation fault
if (dockMD->playbackVolume().hasVolume() || dockMD->captureVolume().hasVolume())
{
//qCDebug(KMIX_LOG) << "ADD? mixerId=" << mixer->id() << ", md=" << dockMD->id() << ": YES";
_mixSet.append(dockMD);
addToMixSet(dockMD);
}
}
} // loop over all cards
// Finally add all application streams
foreach (const Mixer *mixer, _mixers)
for (const Mixer *mixer : qAsConst(getMixers()))
{
foreach (shared_ptr<MixDevice> md, mixer->getMixSet())
for (shared_ptr<MixDevice> md : qAsConst(mixer->getMixSet()))
{
if (md->isApplicationStream()) _mixSet.append(md);
if (md->isApplicationStream()) addToMixSet(md);
}
}
}
......@@ -493,16 +493,7 @@ void ViewDockAreaPopup::refreshVolumeLevels()
void ViewDockAreaPopup::configureView()
{
// Q_ASSERT( !pulseaudioPresent() );
// QSet<QString> currentlyActiveMixersInDockArea;
// foreach ( Mixer* mixer, _mixers )
// {
// currentlyActiveMixersInDockArea.insert(mixer->id());
// }
KMixPrefDlg* prefDlg = KMixPrefDlg::getInstance();
//prefDlg->setActiveMixersInDock(currentlyActiveMixersInDockArea);
KMixPrefDlg *prefDlg = KMixPrefDlg::getInstance();
prefDlg->switchToPage(KMixPrefDlg::PrefSoundMenu);
}
......
......@@ -189,6 +189,8 @@ void ViewSliders::initLayout()
m_emptyStreamHint->setIcon(QIcon::fromTheme("dialog-information"));
m_emptyStreamHint->setMessageType(KMessageWidget::Information);
m_emptyStreamHint->setCloseButtonVisible(false);
m_emptyStreamHint->setMaximumWidth(200);
m_emptyStreamHint->setWordWrap(true);
m_layoutSliders->addWidget(m_emptyStreamHint);
if (orientation()==Qt::Horizontal) // horizontal sliders
......@@ -217,7 +219,7 @@ void ViewSliders::initLayout()
const GUIProfile *guiprof = guiProfile();
if (guiprof!=nullptr)
{
foreach (Mixer *mixer, _mixers)
for (const Mixer *mixer : getMixers())
{
const MixSet &mixset = mixer->getMixSet();
......@@ -232,7 +234,7 @@ void ViewSliders::initLayout()
if (md->id().contains(idRegexp))
{ // match found (by name)
if (_mixSet.contains(md))
if (getMixSet().contains(md))
{ // check for duplicate already
continue;
}
......@@ -259,7 +261,7 @@ void ViewSliders::initLayout()
else if (control->getSwitchtype()=="Off")
md->playbackVolume().setSwitchType(Volume::OffSwitch);
}
_mixSet.append(md);
addToMixSet(md);
#ifdef TEST_MIXDEVICE_COMPOSITE
if ( md->id() == "Front:0" || md->id() == "Surround:0")
......@@ -277,7 +279,7 @@ void ViewSliders::initLayout()
// Show a hint why a tab is empty (dynamic controls!)
// TODO: 'visibleControls()==0' could be used for the !isDynamic() case
m_emptyStreamHint->setVisible(_mixSet.isEmpty() && isDynamic());
m_emptyStreamHint->setVisible(getMixSet().isEmpty() && isDynamic());
#ifdef TEST_MIXDEVICE_COMPOSITE
// @todo: This is currently hardcoded, and instead must be read as usual from the Profile
......
Markdown is supported
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