Commit 5debe510 authored by Jonathan Marten's avatar Jonathan Marten

Start to tidy up the code and layout of the mixer window and sliders

Work in progress, so far only supporting vertical sliders.

Use a QGridLayout instead of multiple nested layouts needing
various spacer widgets scattered about to get the layout
consistent over a set of sliders.

Remove a lot of event filtering for context menu and mouse
wheel handling, Qt can now manage most of that itself.  Handle
mouse wheel events by simply redirecting them to the slider.

Remove some questionable installEventFilter(widgetIHaveCreated)
constructs, what was probably meant instead was
widgetIHaveCreated->installEventFilter(this).

Start to introduce QSignalBlocker where appropriate.
parent ac0c8862
......@@ -80,7 +80,7 @@ MDWEnum::~MDWEnum()
void MDWEnum::createWidgets()
{
if ( _orientation == Qt::Vertical ) {
if ( m_orientation == Qt::Vertical ) {
_layout = new QVBoxLayout( this );
_layout->setAlignment(Qt::AlignLeft);
}
......
This diff is collapsed.
......@@ -31,6 +31,7 @@
#include <qpixmap.h>
class QBoxLayout;
class QGridLayout;
class QToolButton;
class QLabel;
class QMenu;
......@@ -67,14 +68,14 @@ public:
void setLabeled( bool value ) Q_DECL_OVERRIDE;
void setTicks( bool ticks ) Q_DECL_OVERRIDE;
void setIcons( bool value ) Q_DECL_OVERRIDE;
// void setIcon( QString filename, QLabel** label );
void setIcon( QString filename, QWidget* label );
QToolButton* addMediaButton(QString iconName, QLayout* layout, QWidget *parent);
void updateMediaButton();
void setColors( QColor high, QColor low, QColor back ) Q_DECL_OVERRIDE;
void setMutedColors( QColor high, QColor low, QColor back ) Q_DECL_OVERRIDE;
bool eventFilter( QObject* obj, QEvent* e ) Q_DECL_OVERRIDE;
bool eventFilter(QObject *obj, QEvent *ev) Q_DECL_OVERRIDE;
QString iconName();
// Layout
QSizePolicy sizePolicy() const;
......@@ -82,8 +83,8 @@ public:
int labelExtentHint() const;
void setLabelExtent(int extent);
bool hasMuteButton() const;
void setMuteButtonSpace(bool);
void setCaptureLEDSpace(bool);
// void setMuteButtonSpace(bool);
// void setCaptureLEDSpace(bool);
bool hasCaptureLED() const;
static VolumeSliderExtraData DummVolumeSliderExtraData;
......@@ -103,9 +104,8 @@ public slots:
VolumeSliderExtraData& extraData(QAbstractSlider *slider);
void addMediaControls(QBoxLayout* arg1);
private slots:
void setRecsrc( bool value );
void setRecsrc(bool value);
void setMuted(bool value);
void volumeChange( int );
void sliderPressed();
......@@ -122,7 +122,8 @@ private slots:
void mediaPrev(bool);
private:
QPixmap loadIcon( QString filename, KIconLoader::Group group );
void setIcon(const QString &filename, QWidget *label);
// QPixmap loadIcon( QString filename, KIconLoader::Group group );
void createWidgets( bool showMuteLED, bool showCaptureLED, bool includeMixer );
void addSliders( QBoxLayout *volLayout, char type, Volume& vol,
QList<QAbstractSlider *>& ref_sliders, QString tooltipText );
......@@ -137,35 +138,36 @@ private:
void updateAccesability();
#endif
QWidget* createLabel(QWidget* parent, QString& label, QBoxLayout *layout, bool);
// QWidget* createLabel(QWidget* parent, QString& label, QBoxLayout *layout, bool);
QString calculatePlaybackIcon(MediaController::PlayState playState);
void guiAddSlidersAndMediacontrols(bool playSliders, bool capSliders, bool mediaControls, QBoxLayout* layout, const QString& tooltipText, const QString& captureTooltipText);
void guiAddCaptureCheckbox(bool wantsCaptureLED, const Qt::Alignment& alignmentForCapture,
QBoxLayout* layoutForCapture, const QString& captureTooltipText);
void guiAddMuteButton(bool wantsMuteButton, Qt::Alignment alignment, QBoxLayout* layoutForMuteButton, const QString& muteTooltipText);
void guiAddControlIcon(Qt::Alignment alignment, QBoxLayout* layout, const QString& tooltipText);
void guiAddCaptureButton(const QString &captureTooltipText);
void guiAddMuteButton(const QString& muteTooltipText);
// void guiAddControlIcon(Qt::Alignment alignment, QBoxLayout* layout, const QString& tooltipText);
void addGlobalShortcut(QAction* action, const QString& label, bool dynamicControl);
int controlButtonSize();
bool m_linked;
QWidget *muteButtonSpacer;
QWidget *captureSpacer;
QWidget *labelSpacer;
// QWidget *muteButtonSpacer;
// QWidget *captureSpacer;
// QWidget *labelSpacer;
QGridLayout *m_controlGrid;
// GUI: Top portion ( Icon + Mute)
QLabel *m_iconLabelSimple;
QToolButton* m_qcb;
QLabel* m_muteText;
QLabel *m_label; // is either QLabel or VerticalText
QToolButton *mediaButton;
QLabel *m_controlIcon;
// QLabel* m_muteText;
QLabel *m_controlLabel; // is either QLabel or VerticalText
QCheckBox* m_captureCheckbox;
QLabel* m_captureText;
QToolButton* m_muteButton;
QCheckBox* m_captureButton;
QToolButton *m_mediaPlayButton;
int m_controlButtonSize;
// QLabel* m_captureText;
int labelSpacing;
bool muteButtonSpacing;
bool captureLEDSpacing;
// int labelSpacing;
// bool muteButtonSpacing;
// bool captureLEDSpacing;
KActionCollection* _mdwMoveActions;
QMenu *m_moveMenu;
......
......@@ -51,9 +51,11 @@ MixDeviceWidget::MixDeviceWidget(shared_ptr<MixDevice> md,
bool small, Qt::Orientation orientation,
QWidget* parent, ViewBase* view, ProfControl* par_pctl) :
QWidget( parent ), m_mixdevice( md ), m_view( view ), _pctl(par_pctl),
_orientation( orientation ), m_small( small )
m_orientation( orientation ), m_small( small )
, m_shortcutsDialog(0)
{
setContextMenuPolicy(Qt::DefaultContextMenu);
_mdwActions = new KActionCollection( this );
_mdwPopupActions = new KActionCollection( this );
......@@ -69,10 +71,6 @@ MixDeviceWidget::MixDeviceWidget(shared_ptr<MixDevice> md,
}
}
MixDeviceWidget::~MixDeviceWidget()
{
}
void MixDeviceWidget::addActionToPopup( QAction *action )
{
_mdwActions->addAction( action->objectName(), action );
......@@ -88,6 +86,11 @@ void MixDeviceWidget::defineKeys()
m_shortcutsDialog->configure();
}
void MixDeviceWidget::contextMenuEvent(QContextMenuEvent *ev)
{
showContextMenu(ev->globalPos());
}
void MixDeviceWidget::volumeChange( int ) { /* is virtual */ }
//void MixDeviceWidget::setDisabled( bool ) { /* is virtual */ }
//void MixDeviceWidget::setVolume( int /*channel*/, int /*vol*/ ) { /* is virtual */ }
......@@ -98,16 +101,3 @@ void MixDeviceWidget::setColors( QColor , QColor , QColor ) { /* is virtual */ }
void MixDeviceWidget::setIcons( bool ) { /* is virtual */ }
void MixDeviceWidget::setLabeled( bool ) { /* is virtual */ }
void MixDeviceWidget::setMutedColors( QColor , QColor , QColor ) { /* is virtual */ }
void MixDeviceWidget::mousePressEvent( QMouseEvent *e )
{
if ( e->button() == Qt::RightButton )
showContextMenu();
else {
QWidget::mousePressEvent(e);
}
}
......@@ -38,59 +38,57 @@ class MixDevice;
class ProfControl;
class ViewBase;
class MixDeviceWidget
: public QWidget
class MixDeviceWidget : public QWidget
{
Q_OBJECT
Q_OBJECT
public:
MixDeviceWidget( shared_ptr<MixDevice> md,
bool small, Qt::Orientation orientation,
QWidget* parent, ViewBase*, ProfControl * );
virtual ~MixDeviceWidget();
virtual ~MixDeviceWidget() = default;
void addActionToPopup( QAction *action );
shared_ptr<MixDevice> mixDevice() { return m_mixdevice; }
shared_ptr<MixDevice> mixDevice() { return (m_mixdevice); }
virtual void setColors( QColor high, QColor low, QColor back );
virtual void setIcons( bool value );
virtual void setMutedColors( QColor high, QColor low, QColor back );
virtual bool isStereoLinked() const { return false; }
virtual void setStereoLinked( bool ) {}
virtual void setLabeled( bool );
virtual void setTicks( bool ) {}
virtual bool isStereoLinked() const { return (false); }
virtual void setStereoLinked(bool) {}
virtual void setLabeled(bool);
virtual void setTicks(bool) {}
public slots:
virtual void defineKeys();
virtual void showContextMenu( const QPoint &pos = QCursor::pos() ) = 0;
/**
* update() is called whenever there are volume updates pending from the hardware for this MDW.
*/
virtual void showContextMenu(const QPoint &pos = QCursor::pos()) = 0;
/**
* Called whenever there are volume updates pending from the hardware for this MDW.
*/
virtual void update() = 0;
signals:
void guiVisibilityChange(MixDeviceWidget* source, bool enable);
protected slots:
virtual void setDisabled( bool value ) = 0;
void volumeChange( int );
virtual void setDisabled(bool value) = 0;
void volumeChange(int);
protected:
void contextMenuEvent(QContextMenuEvent *ev) Q_DECL_OVERRIDE;
protected:
shared_ptr<MixDevice> m_mixdevice;
KActionCollection* _mdwActions;
KActionCollection* _mdwPopupActions;
ViewBase* m_view;
ProfControl* _pctl;
Qt::Orientation _orientation;
Qt::Orientation m_orientation;
bool m_small;
KShortcutsDialog* m_shortcutsDialog;
private:
void mousePressEvent( QMouseEvent *e ) Q_DECL_OVERRIDE;
};
#endif
......@@ -384,8 +384,8 @@ void ViewSliders::configurationUpdate()
{
// additional options for sliders
mdwSlider->setLabelExtent(labelExtent);
mdwSlider->setMuteButtonSpace(haveMuteButtons);
mdwSlider->setCaptureLEDSpace(haveCaptureLEDs);
// mdwSlider->setMuteButtonSpace(haveMuteButtons);
// mdwSlider->setCaptureLEDSpace(haveCaptureLEDs);
}
bool thisControlIsVisible = mdw->isVisibleTo(this);
bool showSeparator = ( firstVisibleControlFound && thisControlIsVisible);
......
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