Commit 160fc6e5 authored by Jonathan Marten's avatar Jonathan Marten

MixDeviceWidget: Simplify the constructor calls

The 'parent' is always the same as the 'view', so only one is needed.

The 'pctl' can normally be obtained from the MixDevice;  only the
ViewDockAreaPopup needs a special one.  This is managed by the
MixDeviceWidget.
parent 48d04964
......@@ -43,10 +43,10 @@
* Class that represents an Enum element (a select one-from-many selector)
* The orientation (horizontal, vertical) is ignored
*/
MDWEnum::MDWEnum( shared_ptr<MixDevice> md,
QWidget* parent, ViewBase* view, ProfControl* par_pctl) :
MixDeviceWidget(md, false, parent, view, par_pctl),
_label(0), _enumCombo(0)
MDWEnum::MDWEnum(shared_ptr<MixDevice> md, ViewBase *view)
: MixDeviceWidget(md, false, view),
_label(nullptr),
_enumCombo(nullptr)
{
// create actions (on _mdwActions, see MixDeviceWidget)
......
......@@ -38,8 +38,7 @@ class MDWEnum : public MixDeviceWidget
Q_OBJECT
public:
MDWEnum( shared_ptr<MixDevice> md,
QWidget* parent, ViewBase* view, ProfControl* pctl);
MDWEnum(shared_ptr<MixDevice> md, ViewBase *view);
virtual ~MDWEnum() = default;
void addActionToPopup( QAction *action );
......
......@@ -59,22 +59,23 @@ bool MDWSlider::debugMe = false;
*
* Due to the many options, this is the most complicated MixDeviceWidget subclass.
*/
MDWSlider::MDWSlider(shared_ptr<MixDevice> md, bool showMuteLED, bool showCaptureLED
, bool includeMixerName, bool small, QWidget* parent
, ViewBase* view
, ProfControl* par_ctl
) :
MixDeviceWidget(md,small,parent,view, par_ctl),
m_linked(true),
m_controlGrid(nullptr),
m_controlIcon(nullptr),
m_controlLabel(nullptr),
m_muteButton(nullptr),
m_captureButton(nullptr),
m_mediaPlayButton(nullptr),
m_controlButtonSize(QSize()),
_mdwMoveActions(new KActionCollection(this)), m_moveMenu(0),
m_sliderInWork(false), m_waitForSoundSetComplete(0)
MDWSlider::MDWSlider(shared_ptr<MixDevice> md,
bool showMuteLED, bool showCaptureLED,
bool includeMixerName, bool small,
ViewBase *view)
: MixDeviceWidget(md,small,view),
m_linked(true),
m_controlGrid(nullptr),
m_controlIcon(nullptr),
m_controlLabel(nullptr),
m_muteButton(nullptr),
m_captureButton(nullptr),
m_mediaPlayButton(nullptr),
m_controlButtonSize(QSize()),
_mdwMoveActions(new KActionCollection(this)),
m_moveMenu(nullptr),
m_sliderInWork(false),
m_waitForSoundSetComplete(0)
{
qCDebug(KMIX_LOG) << "for" << m_mixdevice->readableName() << "name?" << includeMixerName << "small?" << m_small;
......@@ -326,8 +327,8 @@ QSize MDWSlider::controlButtonSize()
*/
void MDWSlider::createWidgets( bool showMuteButton, bool showCaptureLED, bool includeMixerName )
{
const bool includePlayback = _pctl->useSubcontrolPlayback();
const bool includeCapture = _pctl->useSubcontrolCapture();
const bool includePlayback = profileControl()->useSubcontrolPlayback();
const bool includeCapture = profileControl()->useSubcontrolCapture();
const bool wantsPlaybackSliders = includePlayback && m_mixdevice->playbackVolume().count()>0;
const bool wantsCaptureSliders = includeCapture && ( m_mixdevice->captureVolume().count() > 0 );
const bool wantsCaptureLED = showCaptureLED && includeCapture;
......@@ -491,7 +492,7 @@ void MDWSlider::createWidgets( bool showMuteButton, bool showCaptureLED, bool in
if (buttonSpacer!=nullptr) m_controlGrid->addWidget(buttonSpacer, 0, 3);
}
const bool stereoLinked = !_pctl->isSplit();
const bool stereoLinked = !profileControl()->isSplit();
setStereoLinked( stereoLinked );
// Activate it explicitly in KDE3 because of PanelApplet/Kicker issues.
......@@ -663,8 +664,8 @@ void MDWSlider::addSliders( QBoxLayout *volLayout, char type, Volume& vol,
if (orientation()==Qt::Vertical) slider->setMinimumHeight(minSliderSize);
else slider->setMinimumWidth(minSliderSize);
if ( ! _pctl->getBackgroundColor().isEmpty() ) {
slider->setStyleSheet("QSlider { background-color: " + _pctl->getBackgroundColor() + " }");
if ( !profileControl()->getBackgroundColor().isEmpty() ) {
slider->setStyleSheet("QSlider { background-color: " + profileControl()->getBackgroundColor() + " }");
}
} // not small
......
......@@ -52,7 +52,7 @@ public:
MDWSlider( shared_ptr<MixDevice> md,
bool includePlayback, bool includeCapture,
bool includeMixerName, bool small,
QWidget* parent, ViewBase* view, ProfControl *pctl);
ViewBase *view);
virtual ~MDWSlider();
enum LabelType { LT_ALL, LT_FIRST_CAPTURE, LT_NONE };
......
......@@ -47,15 +47,19 @@
* SHOULD honor these values - those who do not might not be suitable for placing in
* the panel applet or any other smallish settings.
*/
MixDeviceWidget::MixDeviceWidget(shared_ptr<MixDevice> md,
bool small,
QWidget* parent, ViewBase* view, ProfControl* par_pctl) :
QWidget( parent ), m_mixdevice( md ), m_view( view ), _pctl(par_pctl),
m_small( small ),
m_shortcutsDialog(nullptr)
MixDeviceWidget::MixDeviceWidget(shared_ptr<MixDevice> md, bool small, ViewBase *view)
: QWidget(view),
m_mixdevice(md),
m_view(view),
m_small(small),
m_shortcutsDialog(nullptr)
{
setContextMenuPolicy(Qt::DefaultContextMenu);
// The default control profile.
// ViewDockAreaPopup sets this later using setProfileControl().
m_pctl = md->controlProfile();
_mdwActions = new KActionCollection( this );
_mdwPopupActions = new KActionCollection( this );
......
......@@ -40,14 +40,14 @@ class MixDeviceWidget : public QWidget
Q_OBJECT
public:
MixDeviceWidget( shared_ptr<MixDevice> md,
bool small,
QWidget* parent, ViewBase*, ProfControl * );
MixDeviceWidget(shared_ptr<MixDevice> md, bool small, ViewBase *view);
virtual ~MixDeviceWidget() = default;
void addActionToPopup( QAction *action );
shared_ptr<MixDevice> mixDevice() const { return (m_mixdevice); }
ProfControl *profileControl() const { return (m_pctl); }
void setProfileControl(ProfControl *pctl) { m_pctl = pctl; }
virtual void setColors( QColor high, QColor low, QColor back );
virtual void setIcons( bool value );
......@@ -87,9 +87,11 @@ protected:
KActionCollection* _mdwActions;
KActionCollection* _mdwPopupActions;
ViewBase* m_view;
ProfControl* _pctl;
bool m_small;
KShortcutsDialog* m_shortcutsDialog;
private:
ProfControl* m_pctl;
};
#endif
......@@ -325,20 +325,20 @@ _layoutMDW->addWidget( seperatorBetweenMastersAndStreams, row, col );
if (MatchAllForSoundMenu == 0)
{
// Lazy init of static member on first use
// TODO: why do the strings have to be interned? This is a once only init.
MatchAllForSoundMenu = new ProfControl(ViewDockAreaPopup::InternedString_Star, ViewDockAreaPopup::InternedString_Subcontrols);
}
ProfControl *pctl = MatchAllForSoundMenu;
MixDeviceWidget *mdw = new MDWSlider(
md, // only 1 device.
true, // Show Mute LE
true, // Show Mute LED
true, // Show Record LED
true, // Include Mixer Name
false, // Small
this, // parent
this, // view
pctl // par_ctl
this // view
);
mdw->setProfileControl(MatchAllForSoundMenu);
mdw->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
int sliderColumn = vertical ? _layoutMDW->columnCount() : _layoutMDW->rowCount();
//if (sliderColumn == 1 ) sliderColumn =0;
......
......@@ -115,9 +115,7 @@ QWidget *ViewSliders::add(const shared_ptr<MixDevice> md)
if (md->isEnum()) // control is a switch
{
mdw = new MDWEnum(md, // MixDevice (parameter)
this, // parent
this, // View widget
md->controlProfile()); // profile
this); // view
m_layoutSwitches->addWidget(mdw);
}
else // control is a slider
......@@ -127,9 +125,7 @@ QWidget *ViewSliders::add(const shared_ptr<MixDevice> md)
true, // Show Record LED
false, // Include Mixer Name
false, // Small
this, // parent
this, // View widget
md->controlProfile()); // profile
this); // view
m_layoutSliders->addWidget(mdw);
}
......
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