Commit 3773a4b2 authored by Jonathan Marten's avatar Jonathan Marten
Browse files

DialogChooseBackends: Use Mixer::iconName()

parent ebca1f84
...@@ -29,9 +29,6 @@ ...@@ -29,9 +29,6 @@
#include <klocalizedstring.h> #include <klocalizedstring.h>
#include <kmessagewidget.h> #include <kmessagewidget.h>
#include "core/ControlManager.h"
#include "core/GlobalConfig.h"
#include "core/mixdevice.h"
#include "core/mixer.h" #include "core/mixer.h"
/** /**
...@@ -39,18 +36,17 @@ ...@@ -39,18 +36,17 @@
* will be preselected. * will be preselected.
* *
* @param mixerIds A set of preselected mixer ID's * @param mixerIds A set of preselected mixer ID's
* @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) DialogChooseBackends::DialogChooseBackends(QWidget *parent, const QSet<QString> &mixerIds)
: QWidget(parent), modified(false) : QWidget(parent), modified(false)
{ {
createWidgets(mixerIds); createWidgets(mixerIds);
} }
/** /**
* Create basic widgets of the Dialog. * Create basic widgets of the dialogue.
*/ */
void DialogChooseBackends::createWidgets(const QSet<QString>& mixerIds) void DialogChooseBackends::createWidgets(const QSet<QString> &mixerIds)
{ {
QVBoxLayout *vLayout = new QVBoxLayout(this); QVBoxLayout *vLayout = new QVBoxLayout(this);
vLayout->setContentsMargins(0, 0, 0, 0); vLayout->setContentsMargins(0, 0, 0, 0);
...@@ -64,6 +60,7 @@ void DialogChooseBackends::createWidgets(const QSet<QString>& mixerIds) ...@@ -64,6 +60,7 @@ void DialogChooseBackends::createWidgets(const QSet<QString>& mixerIds)
if (Mixer::mixers().isEmpty()) if (Mixer::mixers().isEmpty())
{ {
// TODO: to KMixToolbox - used here, DialogSelectMaster, DialogAddView
KMessageWidget *noMixersWarning = new KMessageWidget(i18n("No sound cards are installed or are currently available."), this); KMessageWidget *noMixersWarning = new KMessageWidget(i18n("No sound cards are installed or are currently available."), this);
noMixersWarning->setIcon(QIcon::fromTheme("dialog-warning")); noMixersWarning->setIcon(QIcon::fromTheme("dialog-warning"));
noMixersWarning->setMessageType(KMessageWidget::Warning); noMixersWarning->setMessageType(KMessageWidget::Warning);
...@@ -77,10 +74,9 @@ void DialogChooseBackends::createWidgets(const QSet<QString>& mixerIds) ...@@ -77,10 +74,9 @@ void DialogChooseBackends::createWidgets(const QSet<QString>& mixerIds)
/** /**
* Create RadioButton's for the Mixer with number 'mixerId'. * Create selection list for the specified mixers.
* @par mixerId The Mixer, for which the RadioButton's should be created.
*/ */
void DialogChooseBackends::createPage(const QSet<QString>& mixerIds) void DialogChooseBackends::createPage(const QSet<QString> &mixerIds)
{ {
m_mixerList = new QListWidget(this); m_mixerList = new QListWidget(this);
m_mixerList->setUniformItemSizes(true); m_mixerList->setUniformItemSizes(true);
...@@ -92,21 +88,17 @@ void DialogChooseBackends::createPage(const QSet<QString>& mixerIds) ...@@ -92,21 +88,17 @@ void DialogChooseBackends::createPage(const QSet<QString>& mixerIds)
#endif #endif
bool hasMixerFilter = !mixerIds.isEmpty(); bool hasMixerFilter = !mixerIds.isEmpty();
qCDebug(KMIX_LOG) << "MixerIds=" << mixerIds; qCDebug(KMIX_LOG) << "MixerIds=" << mixerIds;
foreach (const Mixer *mixer, Mixer::mixers()) for (const Mixer *mixer : Mixer::mixers())
{ {
QListWidgetItem *item = new QListWidgetItem(m_mixerList); QListWidgetItem *item = new QListWidgetItem(m_mixerList);
item->setText(mixer->readableName(true)); item->setText(mixer->readableName(true));
item->setSizeHint(QSize(1, 16)); item->setSizeHint(QSize(1, 16));
item->setIcon(QIcon::fromTheme(mixer->iconName()));
// TODO: implement a Mixer::iconName()
const shared_ptr<MixDevice> md = mixer->getLocalMasterMD();
const QString iconName = (md!=nullptr) ? md->iconName() : "media-playback-start";
item->setIcon(QIcon::fromTheme(iconName));
item->setFlags(Qt::ItemIsEnabled|Qt::ItemIsUserCheckable|Qt::ItemNeverHasChildren); item->setFlags(Qt::ItemIsEnabled|Qt::ItemIsUserCheckable|Qt::ItemNeverHasChildren);
item->setData(Qt::UserRole, mixer->id());
const bool mixerShouldBeShown = !hasMixerFilter || mixerIds.contains(mixer->id()); const bool mixerShouldBeShown = !hasMixerFilter || mixerIds.contains(mixer->id());
item->setCheckState(mixerShouldBeShown ? Qt::Checked : Qt::Unchecked); item->setCheckState(mixerShouldBeShown ? Qt::Checked : Qt::Unchecked);
item->setData(Qt::UserRole, mixer->id());
} }
connect(m_mixerList, &QListWidget::itemChanged, this, &DialogChooseBackends::backendsModifiedSlot); connect(m_mixerList, &QListWidget::itemChanged, this, &DialogChooseBackends::backendsModifiedSlot);
......
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