Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit c827054d authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle

Audiomixer: Move channels in a scrollbox, make it collapsible to allow showing only master

parent 79f54000
Pipeline #10019 passed with stage
in 17 minutes and 40 seconds
......@@ -29,6 +29,8 @@
#include <klocalizedstring.h>
#include <QHBoxLayout>
#include <QModelIndex>
#include <QScrollArea>
#include <QTimer>
const double log_factor = 1.0 / log10(1.0 / 127);
......@@ -44,10 +46,27 @@ MixerManager::MixerManager(QWidget *parent)
: QWidget(parent)
, m_masterMixer(nullptr)
, m_connectedWidgets(false)
, m_expandedWidth(-1)
{
m_masterBox = new QHBoxLayout;
m_channelsBox = new QScrollArea(this);
m_box = new QHBoxLayout;
m_box->addStretch(10);
m_box->setSpacing(0);
auto *channelsBoxContainer = new QWidget;
channelsBoxContainer->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
m_channelsBox->setWidget(channelsBoxContainer);
m_channelsBox->setWidgetResizable(true);
m_channelsBox->setFrameShape(QFrame::NoFrame);
m_box->addWidget(m_channelsBox);
m_channelsLayout = new QHBoxLayout;
m_channelsLayout->setContentsMargins(0, 0, 0, 0);
m_channelsLayout->setSpacing(0);
channelsBoxContainer->setLayout(m_channelsLayout);
m_channelsLayout->addStretch(10);
m_line = new QFrame(this);
m_line->setFrameShape(QFrame::VLine);
m_line->setFrameShadow(QFrame::Sunken);
m_box->addWidget(m_line);
m_box->addLayout(m_masterBox);
setLayout(m_box);
}
......@@ -95,7 +114,7 @@ void MixerManager::registerTrack(int tid, std::shared_ptr<Mlt::Tractor> service,
}
});
m_mixers[tid] = mixer;
m_box->insertWidget(0, mixer.get());
m_channelsLayout->insertWidget(0, mixer.get());
}
void MixerManager::deregisterTrack(int tid)
......@@ -118,7 +137,7 @@ void MixerManager::resetAudioValues()
void MixerManager::cleanup()
{
for (auto item : m_mixers) {
m_box->removeWidget(item.second.get());
m_channelsLayout->removeWidget(item.second.get());
}
m_mixers.clear();
if (m_masterMixer) {
......@@ -174,3 +193,27 @@ void MixerManager::connectMixer(bool doConnect)
m_masterMixer->connectMixer(m_connectedWidgets);
}
}
void MixerManager::collapseMixers(bool collapse)
{
if (collapse) {
m_expandedWidth = width();
m_channelsBox->setMaximumWidth(0);
m_line->setMaximumWidth(0);
setFixedWidth(m_masterMixer->width() + 2 * m_box->contentsMargins().left());
} else {
m_line->setMaximumWidth(QWIDGETSIZE_MAX);
m_channelsBox->setMaximumWidth(QWIDGETSIZE_MAX);
setMaximumWidth(QWIDGETSIZE_MAX);
if (m_expandedWidth > 0) {
setFixedWidth(m_expandedWidth);
}
QTimer::singleShot(500, this, &MixerManager::resetSizePolicy);
}
}
void MixerManager::resetSizePolicy()
{
setMaximumWidth(QWIDGETSIZE_MAX);
setMinimumWidth(0);
}
......@@ -35,6 +35,8 @@ namespace Mlt {
class MixerWidget;
class QHBoxLayout;
class TimelineItemModel;
class QScrollArea;
class QFrame;
class MixerManager : public QWidget
{
......@@ -49,11 +51,15 @@ public:
void cleanup();
/** @brief Connect the mixer widgets to the correspondant filters */
void connectMixer(bool doConnect);
void collapseMixers(bool collapse);
public slots:
void resetAudioValues();
void recordStateChanged(int tid, bool recording);
private slots:
void resetSizePolicy();
signals:
void updateLevels(int);
void recordAudio(int tid);
......@@ -68,8 +74,12 @@ private:
std::shared_ptr<TimelineItemModel> m_model;
QHBoxLayout *m_box;
QHBoxLayout *m_masterBox;
QHBoxLayout *m_channelsLayout;
QScrollArea *m_channelsBox;
QFrame *m_line;
int m_lastFrame;
bool m_connectedWidgets;
int m_expandedWidth;
QVector <int> m_soloMuted;
};
......
......@@ -100,12 +100,13 @@ MixerWidget::MixerWidget(int tid, std::shared_ptr<Mlt::Tractor> service, const Q
, m_levelFilter(nullptr)
, m_monitorFilter(nullptr)
, m_balanceFilter(nullptr)
, m_maxLevels(qMax(30, (int)(service->get_fps() * 1.5)))
, m_solo(nullptr)
, m_record(nullptr)
, m_collapse(nullptr)
, m_lastVolume(0)
, m_listener(nullptr)
, m_recording(false)
, m_maxLevels(qMax(30, (int)(service->get_fps() * 1.5)))
{
buildUI(service.get(), trackTag);
}
......@@ -117,12 +118,13 @@ MixerWidget::MixerWidget(int tid, Mlt::Tractor *service, const QString &trackTag
, m_levelFilter(nullptr)
, m_monitorFilter(nullptr)
, m_balanceFilter(nullptr)
, m_maxLevels(qMax(30, (int)(service->get_fps() * 1.5)))
, m_solo(nullptr)
, m_record(nullptr)
, m_collapse(nullptr)
, m_lastVolume(0)
, m_listener(nullptr)
, m_recording(false)
, m_maxLevels(qMax(30, (int)(service->get_fps() * 1.5)))
{
buildUI(service, trackTag);
}
......@@ -249,7 +251,7 @@ void MixerWidget::buildUI(Mlt::Tractor *service, const QString &trackTag)
// Setup default width
QFontMetrics fm(font());
setMaximumWidth(3 * mute->sizeHint().width());
setFixedWidth(3 * mute->sizeHint().width());
if (m_tid > -1) {
// No solo / rec button on master
......@@ -270,6 +272,15 @@ void MixerWidget::buildUI(Mlt::Tractor *service, const QString &trackTag)
connect(m_record, &QToolButton::clicked, [&]() {
m_manager->recordAudio(m_tid);
});
} else {
m_collapse = new QToolButton(this);
m_collapse->setIcon(QIcon::fromTheme("arrow-left"));
m_collapse->setToolTip(i18n("Show Channels"));
m_collapse->setCheckable(true);
m_collapse->setAutoRaise(true);
connect(m_collapse, &QToolButton::clicked, [&]() {
m_manager->collapseMixers(m_collapse->isChecked());
});
}
connect(m_volumeSlider, &QSlider::valueChanged, [&](int value) {
......@@ -310,6 +321,9 @@ void MixerWidget::buildUI(Mlt::Tractor *service, const QString &trackTag)
QHBoxLayout *buttonslay = new QHBoxLayout;
buttonslay->setSpacing(0);
buttonslay->setContentsMargins(0, 0, 0, 0);
if (m_collapse) {
buttonslay->addWidget(m_collapse);
}
buttonslay->addWidget(mute);
if (m_solo) {
buttonslay->addWidget(m_solo);
......
......@@ -95,6 +95,7 @@ private:
QSlider *m_volumeSlider;
QToolButton *m_solo;
QToolButton *m_record;
QToolButton *m_collapse;
QLabel *m_trackLabel;
QMutex m_storeMutex;
int m_lastVolume;
......
  • I can move the the channel window but on the end it looks like this:
    image

  • Can we change the "arrow" to the other side for collapse and with the tip "Show master only"?
    image

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