Remove recording button

Remove the recording button that was added to the sample clip view with
commit 48c4dce96f.

This commit simply reverts the aforementioned one.
This commit is contained in:
Michael Gregorius
2024-06-14 20:16:57 +02:00
parent 14c16bea68
commit d8c271650c
3 changed files with 30 additions and 53 deletions

View File

@@ -81,8 +81,6 @@ public:
void setIsPlaying(bool isPlaying);
void setSampleBuffer(std::shared_ptr<const SampleBuffer> sb);
BoolModel& recordModel() { return m_recordModel; }
public slots:
void setSampleFile(const QString& sf);
void updateLength();

View File

@@ -27,13 +27,10 @@
#include "ClipView.h"
class QWidget;
namespace lmms
{
class SampleClip;
class BoolModel;
namespace gui
{
@@ -62,19 +59,13 @@ protected:
void dropEvent( QDropEvent * _de ) override;
void mouseDoubleClickEvent( QMouseEvent * ) override;
void paintEvent( QPaintEvent * ) override;
void resizeEvent(QResizeEvent *event) override;
private:
QWidget* buildRecordWidget(BoolModel& recordModel);
void adjustRecordWidget();
bool recordingCapabilitiesAvailable() const;
private:
SampleClip * m_clip;
QPixmap m_paintPixmap;
bool splitClip( const TimePos pos ) override;
QWidget* m_recordWidget;
} ;

View File

@@ -25,8 +25,6 @@
#include "SampleClipView.h"
#include <QApplication>
#include <QHBoxLayout>
#include <QLabel>
#include <QMenu>
#include <QPainter>
@@ -36,7 +34,6 @@
#include "embed.h"
#include "gui_templates.h"
#include "PathUtil.h"
#include "PixmapButton.h"
#include "SampleClip.h"
#include "SampleLoader.h"
#include "SampleWaveform.h"
@@ -61,12 +58,6 @@ SampleClipView::SampleClipView( SampleClip * _clip, TrackView * _tv ) :
connect(m_clip, SIGNAL(wasReversed()), this, SLOT(update()));
setStyle( QApplication::style() );
// To simplify the code we always create the widget but we do not always show it
m_recordWidget = buildRecordWidget(_clip->recordModel());
m_recordWidget->setVisible(recordingCapabilitiesAvailable());
adjustRecordWidget();
}
void SampleClipView::updateSample()
@@ -318,6 +309,36 @@ void SampleClipView::paintEvent( QPaintEvent * pe )
{
p.drawLine(m_markerPos, rect().bottom(), m_markerPos, rect().top());
}
// recording sample tracks is not possible at the moment
if (m_clip->isRecord())
{
p.setFont(adjustedToPixelSize(p.font(), 10));
const auto fontHeight = p.fontMetrics().height();
const auto baseLine = height() - 3;
const int recordSymbolRadius = 3;
const int recordSymbolCenterX = recordSymbolRadius + 4;
const int recordSymbolCenterY = baseLine - fontHeight / 2 + 1;
const int textStartX = recordSymbolCenterX + recordSymbolRadius + 4;
auto textPos = QPoint(textStartX, baseLine);
const auto rec = tr("Rec");
p.setPen(textShadowColor());
p.drawText(textPos + QPoint(1, 1), rec);
p.setPen(textColor());
p.drawText(textPos, rec);
p.setBrush(QBrush(textColor()));
p.drawEllipse(QPoint(recordSymbolCenterX, recordSymbolCenterY), recordSymbolRadius, recordSymbolRadius);
}
p.end();
@@ -325,11 +346,6 @@ void SampleClipView::paintEvent( QPaintEvent * pe )
}
void SampleClipView::resizeEvent(QResizeEvent *event)
{
adjustRecordWidget();
ClipView::resizeEvent(event);
}
void SampleClipView::reverseSample()
@@ -380,34 +396,6 @@ bool SampleClipView::splitClip( const TimePos pos )
else { return false; }
}
QWidget* SampleClipView::buildRecordWidget(BoolModel& recordModel)
{
auto recordWidget = new QWidget(this);
auto recordButton = new PixmapButton(recordWidget);
recordButton->setActiveGraphic(embed::getIconPixmap("led_red"));
recordButton->setToolTip(tr("Enable/disable recording"));
recordButton->setCheckable(true);
recordButton->setModel(&recordModel);
auto recordLabel = new QLabel(tr("Rec"), recordWidget);
recordLabel->setFont(adjustedToPixelSize(recordLabel->font(), 10));
// Now layout everything
QHBoxLayout* recordLayout = new QHBoxLayout(recordWidget);
recordLayout->setContentsMargins(0, 0, 0, 0);
recordLayout->addWidget(recordButton);
recordLayout->addWidget(recordLabel);
return recordWidget;
}
void SampleClipView::adjustRecordWidget()
{
m_recordWidget->move(1, height() - m_recordWidget->height() - 1);
}
bool SampleClipView::recordingCapabilitiesAvailable() const
{
return Engine::audioEngine()->captureDeviceAvailable();