Commit a3fdddc8 authored by Jonathan Marten's avatar Jonathan Marten

Align "Configure view" button correctly in mixer window

By using a QGridLayout for the main layout, which allows the stretch and
alignment of specific layout elements to be set.  Also fixes the
alignment of the empty view label.  Tidied up the code in ViewSliders.
parent ff0f302c
......@@ -50,7 +50,7 @@ public:
void addActionToPopup( QAction *action );
shared_ptr<MixDevice> mixDevice() { return (m_mixdevice); }
shared_ptr<MixDevice> mixDevice() const { return (m_mixdevice); }
virtual void setColors( QColor high, QColor low, QColor back );
virtual void setIcons( bool value );
......
......@@ -47,7 +47,7 @@
/**
* Creates an empty View. To populate it with MixDevice instances, you must implement
* _setMixSet() in your derived class.
* initLayout() in your derived class.
*/
ViewBase::ViewBase(QWidget* parent, QString id, Qt::WindowFlags f, ViewBase::ViewFlags vflags, QString guiProfileId, KActionCollection *actionColletion)
: QWidget(parent, f), _popMenu(NULL), _actions(actionColletion), _vflags(vflags), _guiProfileId(guiProfileId)
......@@ -56,6 +56,7 @@ ViewBase::ViewBase(QWidget* parent, QString id, Qt::WindowFlags f, ViewBase::Vie
setObjectName(id);
// When loading the View from the XML profile, guiLevel can get overridden
m_viewId = id;
// TODO: does not need to be a member
configureIcon = QIcon::fromTheme( QLatin1String( "configure" ));
......@@ -89,10 +90,6 @@ void ViewBase::addMixer(Mixer *mixer)
_mixers.append(mixer);
}
//void ViewBase::configurationUpdate() {
//}
QPushButton* ViewBase::createConfigureViewButton()
{
......@@ -158,7 +155,7 @@ void ViewBase::createDeviceWidgets()
const bool wasVisible = isVisible();
if (wasVisible) hide(); // hide if currently visible
_setMixSet();
initLayout();
foreach (const shared_ptr<MixDevice> md, _mixSet)
{
QWidget *mdw = add(md); // a) Let the implementation do its work
......@@ -281,9 +278,11 @@ bool ViewBase::pulseaudioPresent() const
void ViewBase::resetMdws()
{
// We need to delete the current MixDeviceWidgets so we can redraw them
while (!_mdws.isEmpty())
delete _mdws.takeFirst();
// We need to delete the current MixDeviceWidgets so we can recreate them
// while (!_mdws.isEmpty())
// delete _mdws.takeFirst();
qDeleteAll(_mdws);
_mdws.clear();
// _mixSet contains shared_ptr instances, so clear() should be enough to prevent mem leak
_mixSet.clear(); // Clean up our _mixSet so we can reapply our GUIProfile
......
......@@ -76,7 +76,7 @@ public:
/**
* Creates a suitable representation for the given MixDevice.
*/
virtual QWidget* add(shared_ptr<MixDevice>) = 0;
virtual QWidget* add(const shared_ptr<MixDevice>) = 0;
// This method is called after a configuration update (show/hide controls, split/unsplit).
virtual void configurationUpdate() = 0;
......@@ -138,7 +138,7 @@ protected:
QIcon configureIcon;
virtual void _setMixSet() = 0;
virtual void initLayout() = 0;
void resetMdws();
void updateGuiOptions();
QPushButton* createConfigureViewButton();
......
......@@ -82,7 +82,7 @@ ViewDockAreaPopup::ViewDockAreaPopup(QWidget* parent, QString id, ViewBase::View
{
// Adding all mixers, as we potentially want to show all master controls
addMixer(mixer);
// The list will be redone in _setMixSet() with the actual Mixer instances to use
// The list will be redone in initLayout() with the actual Mixer instances to use
}
restoreVolumeIcon = QIcon::fromTheme(QLatin1String("quickopen-file"));
......@@ -162,7 +162,7 @@ void ViewDockAreaPopup::resetRefs()
_layoutMDW = 0;
}
void ViewDockAreaPopup::_setMixSet()
void ViewDockAreaPopup::initLayout()
{
resetMdws();
......@@ -187,7 +187,7 @@ void ViewDockAreaPopup::_setMixSet()
Application: KMix (kmix), signal: Segmentation fault
[...]
#6 0x00007f9c9a282900 in QString::shared_null () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#7 0x00007f9c9d4286b0 in ViewDockAreaPopup::_setMixSet (this=0x1272b60) at /home/chris/workspace/kmix-git-trunk/gui/viewdockareapopup.cpp:164
#7 0x00007f9c9d4286b0 in ViewDockAreaPopup::initLayout (this=0x1272b60) at /home/chris/workspace/kmix-git-trunk/gui/viewdockareapopup.cpp:164
#8 0x00007f9c9d425700 in ViewBase::createDeviceWidgets (this=0x1272b60) at /home/chris/workspace/kmix-git-trunk/gui/viewbase.cpp:137
#9 0x00007f9c9d42845b in ViewDockAreaPopup::controlsChange (this=0x1272b60, changeType=2) at /home/chris/workspace/kmix-git-trunk/gui/viewdockareapopup.cpp:91
*/
......@@ -231,7 +231,7 @@ Application: KMix (kmix), signal: Segmentation fault
setLayout(_layoutMDW);
// Adding all mixers, as we potentially want to show all master controls. Due to hotplugging
// we have to redo the list on each _setMixSet() (instead of setting it once in the Constructor)
// we have to redo the list on each initLayout() (instead of setting it once in the Constructor)
_mixers.clear();
QSet<QString> preferredMixersForSoundmenu = GlobalConfig::instance().getMixersForSoundmenu();
......
......@@ -54,7 +54,7 @@ protected:
KMixWindow *_kmixMainWindow;
void wheelEvent ( QWheelEvent * e ) Q_DECL_OVERRIDE;
void _setMixSet() Q_DECL_OVERRIDE;
void initLayout() Q_DECL_OVERRIDE;
private:
QGridLayout* _layoutMDW;
......
This diff is collapsed.
......@@ -21,25 +21,28 @@
#ifndef ViewSliders_h
#define ViewSliders_h
#include "viewbase.h"
class QBoxLayout;
#include <QFrame>
#include <QHash>
class QGridLayout;
class QLabel;
#include <QPushButton>
class QWidget;
class QPushButton;
class Mixer;
#include "gui/viewbase.h"
#include "core/ControlManager.h"
class ViewSliders : public ViewBase
{
Q_OBJECT
public:
ViewSliders(QWidget* parent, QString id, Mixer* mixer, ViewBase::ViewFlags vflags, QString guiProfileId, KActionCollection *actColl);
ViewSliders(QWidget *parent, const QString &id, Mixer *mixer, ViewBase::ViewFlags vflags, const QString &guiProfileId, KActionCollection *actColl);
virtual ~ViewSliders();
QWidget* add(shared_ptr<MixDevice>) Q_DECL_OVERRIDE;
QWidget *add(const shared_ptr<MixDevice> md) Q_DECL_OVERRIDE;
void constructionFinished() Q_DECL_OVERRIDE;
void configurationUpdate() Q_DECL_OVERRIDE;
......@@ -47,18 +50,16 @@ public slots:
void controlsChange(ControlManager::ChangeType changeType);
protected:
void _setMixSet() Q_DECL_OVERRIDE;
void initLayout() Q_DECL_OVERRIDE;
private:
void refreshVolumeLevels() Q_DECL_OVERRIDE;
QBoxLayout* _layoutMDW;
QLayout* _layoutSliders;
QBoxLayout* _layoutEnum;
QHash<QString,QFrame*> _separators;
QPushButton* _configureViewButton;
QLabel* emptyStreamHint;
QGridLayout *m_layoutMDW;
QBoxLayout *m_layoutSliders;
QBoxLayout *m_layoutSwitches;
QPushButton *m_configureViewButton;
QLabel *m_emptyStreamHint;
};
#endif
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