Fix memory leaks (#6879)

* Replace knobFModel with std::vector

* Create QPixmap's on the stack

* Assign parent for QGraphicsScene
A call to QGraphicsView::setScene does not make
the view take ownership of the scene.

* Do not allocate QList on the heap

* Use static QPixmap's
The QPixmap's need to be created within the constructor, and not outside
where they are defined, since it can't find them otherwise.
I'm not too sure why.

* Clear m_vi2->knobFModel in destructor

* Use local static QPixmap's

* Do not allocate QPixmap with new in AudioFileProcessor

* Do not allocate QPixmap with new in Nes

* Do not allocate QPixmap with new in Organic

* Do not allocate QPixmap with new in SaControlsDialog

* Do not allocate QPixmap with new in Vestige

* Do not allocate QPixmap with new for FileBrowser

* Do not allocate QPixmap with new in MixerLine

* Do not allocate QPixmap with new in SendButtonIndicator

* Do not allocate QPixmap with new in AutomationClipView

* Do not allocate QPixmap with new in MidiClipView

* Do not allocate QPixmap with new in AutomationEditor

* Do not allocate QPixmap with new in PianoRoll

* Do not allocate QPixmap with new in TimeLineWidget

* Do not allocate QPixmap with new in EnvelopeAndLfoView

* Do not allocate QPixmap with new in PianoView

* Do not allocate QPixmap with new in ComboBox

* Do not allocate QPixmap with new in Fader

* Do not allocate QPixmap with new for LcdWidget

* Do not allocate QPixmap with new for LedCheckbox

* Use m_ as prefix for members

* Use uniform initialization
I already started using uniform initialization for the QPixmap changes
for some reason, so I'm finishing that up.

* Uniform initiaization

* And then he realized he was making copies...

* Do not call QPixmap copy constructor

* Do not call QPixmap copy constructor in SaControlsDialog

* Do not make pixmap's static for Lcd's and Led's

* Initialize pixmaps in-class

* Fix few mistakes and formatting
This commit is contained in:
saker
2023-11-19 00:44:15 -05:00
committed by GitHub
parent fad0011508
commit aa050ae0b7
43 changed files with 289 additions and 729 deletions

View File

@@ -1011,11 +1011,6 @@ void FileBrowserTreeWidget::updateDirectory(QTreeWidgetItem * item )
}
}
QPixmap * Directory::s_folderPixmap = nullptr;
QPixmap * Directory::s_folderOpenedPixmap = nullptr;
QPixmap * Directory::s_folderLockedPixmap = nullptr;
Directory::Directory(const QString& filename, const QString& path, const QString& filter, bool disableEntryPopulation)
: QTreeWidgetItem(QStringList(filename), TypeDirectoryItem)
, m_directories(path)
@@ -1023,56 +1018,19 @@ Directory::Directory(const QString& filename, const QString& path, const QString
, m_dirCount(0)
, m_disableEntryPopulation(disableEntryPopulation)
{
initPixmaps();
setIcon(0, !QDir{fullName()}.isReadable() ? m_folderLockedPixmap : m_folderPixmap);
setChildIndicatorPolicy( QTreeWidgetItem::ShowIndicator );
if( !QDir( fullName() ).isReadable() )
{
setIcon( 0, *s_folderLockedPixmap );
}
else
{
setIcon( 0, *s_folderPixmap );
}
}
void Directory::initPixmaps()
{
if( s_folderPixmap == nullptr )
{
s_folderPixmap = new QPixmap(
embed::getIconPixmap( "folder" ) );
}
if( s_folderOpenedPixmap == nullptr )
{
s_folderOpenedPixmap = new QPixmap(
embed::getIconPixmap( "folder_opened" ) );
}
if( s_folderLockedPixmap == nullptr )
{
s_folderLockedPixmap = new QPixmap(
embed::getIconPixmap( "folder_locked" ) );
}
}
void Directory::update()
{
if( !isExpanded() )
{
setIcon( 0, *s_folderPixmap );
setIcon(0, m_folderPixmap);
return;
}
setIcon( 0, *s_folderOpenedPixmap );
setIcon(0, m_folderOpenedPixmap);
if (!m_disableEntryPopulation && !childCount())
{
m_dirCount = 0;
@@ -1142,15 +1100,6 @@ bool Directory::addItems(const QString& path)
QPixmap * FileItem::s_projectFilePixmap = nullptr;
QPixmap * FileItem::s_presetFilePixmap = nullptr;
QPixmap * FileItem::s_sampleFilePixmap = nullptr;
QPixmap * FileItem::s_soundfontFilePixmap = nullptr;
QPixmap * FileItem::s_vstPluginFilePixmap = nullptr;
QPixmap * FileItem::s_midiFilePixmap = nullptr;
QPixmap * FileItem::s_unknownFilePixmap = nullptr;
FileItem::FileItem(QTreeWidget * parent, const QString & name,
const QString & path ) :
QTreeWidgetItem( parent, QStringList( name) , TypeFileItem ),
@@ -1176,72 +1125,38 @@ FileItem::FileItem(const QString & name, const QString & path ) :
void FileItem::initPixmaps()
{
if( s_projectFilePixmap == nullptr )
{
s_projectFilePixmap = new QPixmap( embed::getIconPixmap(
"project_file", 16, 16 ) );
}
if( s_presetFilePixmap == nullptr )
{
s_presetFilePixmap = new QPixmap( embed::getIconPixmap(
"preset_file", 16, 16 ) );
}
if( s_sampleFilePixmap == nullptr )
{
s_sampleFilePixmap = new QPixmap( embed::getIconPixmap(
"sample_file", 16, 16 ) );
}
if ( s_soundfontFilePixmap == nullptr )
{
s_soundfontFilePixmap = new QPixmap( embed::getIconPixmap(
"soundfont_file", 16, 16 ) );
}
if ( s_vstPluginFilePixmap == nullptr )
{
s_vstPluginFilePixmap = new QPixmap( embed::getIconPixmap(
"vst_plugin_file", 16, 16 ) );
}
if( s_midiFilePixmap == nullptr )
{
s_midiFilePixmap = new QPixmap( embed::getIconPixmap(
"midi_file", 16, 16 ) );
}
if( s_unknownFilePixmap == nullptr )
{
s_unknownFilePixmap = new QPixmap( embed::getIconPixmap(
"unknown_file" ) );
}
static auto s_projectFilePixmap = embed::getIconPixmap("project_file", 16, 16);
static auto s_presetFilePixmap = embed::getIconPixmap("preset_file", 16, 16);
static auto s_sampleFilePixmap = embed::getIconPixmap("sample_file", 16, 16);
static auto s_soundfontFilePixmap = embed::getIconPixmap("soundfont_file", 16, 16);
static auto s_vstPluginFilePixmap = embed::getIconPixmap("vst_plugin_file", 16, 16);
static auto s_midiFilePixmap = embed::getIconPixmap("midi_file", 16, 16);
static auto s_unknownFilePixmap = embed::getIconPixmap("unknown_file");
switch( m_type )
{
case FileType::Project:
setIcon( 0, *s_projectFilePixmap );
setIcon(0, s_projectFilePixmap);
break;
case FileType::Preset:
setIcon( 0, *s_presetFilePixmap );
setIcon(0, s_presetFilePixmap);
break;
case FileType::SoundFont:
setIcon( 0, *s_soundfontFilePixmap );
setIcon(0, s_soundfontFilePixmap);
break;
case FileType::VstPlugin:
setIcon( 0, *s_vstPluginFilePixmap );
setIcon(0, s_vstPluginFilePixmap);
break;
case FileType::Sample:
case FileType::Patch: // TODO
setIcon( 0, *s_sampleFilePixmap );
setIcon(0, s_sampleFilePixmap);
break;
case FileType::Midi:
setIcon( 0, *s_midiFilePixmap );
setIcon(0, s_midiFilePixmap);
break;
case FileType::Unknown:
default:
setIcon( 0, *s_unknownFilePixmap );
setIcon(0, s_unknownFilePixmap);
break;
}
}

View File

@@ -68,8 +68,6 @@ bool MixerLine::eventFilter( QObject *dist, QEvent *event )
}
const int MixerLine::MixerLineHeight = 287;
QPixmap * MixerLine::s_sendBgArrow = nullptr;
QPixmap * MixerLine::s_receiveBgArrow = nullptr;
MixerLine::MixerLine( QWidget * _parent, MixerView * _mv, int _channelIndex ) :
QWidget( _parent ),
@@ -82,15 +80,6 @@ MixerLine::MixerLine( QWidget * _parent, MixerView * _mv, int _channelIndex ) :
m_strokeInnerInactive( 0, 0, 0 ),
m_inRename( false )
{
if( !s_sendBgArrow )
{
s_sendBgArrow = new QPixmap( embed::getIconPixmap( "send_bg_arrow", 29, 56 ) );
}
if( !s_receiveBgArrow )
{
s_receiveBgArrow = new QPixmap( embed::getIconPixmap( "receive_bg_arrow", 29, 56 ) );
}
setFixedSize( 33, MixerLineHeight );
setAttribute( Qt::WA_OpaquePaintEvent, true );
setCursor( QCursor( embed::getIconPixmap( "hand" ), 3, 3 ) );
@@ -193,14 +182,10 @@ void MixerLine::drawMixerLine( QPainter* p, const MixerLine *mixerLine, bool isA
p->drawRect( 0, 0, width-1, height-1 );
// draw the mixer send background
if( sendToThis )
{
p->drawPixmap( 2, 0, 29, 56, *s_sendBgArrow );
}
else if( receiveFromThis )
{
p->drawPixmap( 2, 0, 29, 56, *s_receiveBgArrow );
}
static auto s_sendBgArrow = embed::getIconPixmap("send_bg_arrow", 29, 56);
static auto s_receiveBgArrow = embed::getIconPixmap("receive_bg_arrow", 29, 56);
p->drawPixmap(2, 0, 29, 56, sendToThis ? s_sendBgArrow : s_receiveBgArrow);
}

View File

@@ -8,30 +8,17 @@
namespace lmms::gui
{
QPixmap * SendButtonIndicator::s_qpmOff = nullptr;
QPixmap * SendButtonIndicator::s_qpmOn = nullptr;
SendButtonIndicator:: SendButtonIndicator( QWidget * _parent, MixerLine * _owner,
MixerView * _mv) :
QLabel( _parent ),
m_parent( _owner ),
m_mv( _mv )
{
if( ! s_qpmOff )
{
s_qpmOff = new QPixmap( embed::getIconPixmap( "mixer_send_off", 29, 20 ) );
}
if( ! s_qpmOn )
{
s_qpmOn = new QPixmap( embed::getIconPixmap( "mixer_send_on", 29, 20 ) );
}
// don't do any initializing yet, because the MixerView and MixerLine
// that were passed to this constructor are not done with their constructors
// yet.
setPixmap( *s_qpmOff );
setPixmap(m_qpmOff);
}
void SendButtonIndicator::mousePressEvent( QMouseEvent * e )
@@ -64,7 +51,7 @@ FloatModel * SendButtonIndicator::getSendModel()
void SendButtonIndicator::updateLightStatus()
{
setPixmap( getSendModel() == nullptr ? *s_qpmOff : *s_qpmOn );
setPixmap(!getSendModel() ? m_qpmOff : m_qpmOn);
}

View File

@@ -44,8 +44,6 @@
namespace lmms::gui
{
QPixmap * AutomationClipView::s_clip_rec = nullptr;
AutomationClipView::AutomationClipView( AutomationClip * _clip,
TrackView * _parent ) :
ClipView( _clip, _parent ),
@@ -61,10 +59,6 @@ AutomationClipView::AutomationClipView( AutomationClip * _clip,
setToolTip(m_clip->name());
setStyle( QApplication::style() );
if( s_clip_rec == nullptr ) { s_clip_rec = new QPixmap( embed::getIconPixmap(
"clip_rec" ) ); }
update();
}
@@ -379,7 +373,8 @@ void AutomationClipView::paintEvent( QPaintEvent * )
// recording icon for when recording automation
if( m_clip->isRecording() )
{
p.drawPixmap( 1, rect().bottom() - s_clip_rec->height(), *s_clip_rec );
static auto s_clipRec = embed::getIconPixmap("clip_rec");
p.drawPixmap(1, rect().bottom() - s_clipRec.height(), s_clipRec);
}
// clip name

View File

@@ -57,31 +57,6 @@ MidiClipView::MidiClipView( MidiClip* clip, TrackView* parent ) :
{
connect( getGUI()->pianoRoll(), SIGNAL(currentMidiClipChanged()),
this, SLOT(update()));
if( s_stepBtnOn0 == nullptr )
{
s_stepBtnOn0 = new QPixmap( embed::getIconPixmap(
"step_btn_on_0" ) );
}
if( s_stepBtnOn200 == nullptr )
{
s_stepBtnOn200 = new QPixmap( embed::getIconPixmap(
"step_btn_on_200" ) );
}
if( s_stepBtnOff == nullptr )
{
s_stepBtnOff = new QPixmap( embed::getIconPixmap(
"step_btn_off" ) );
}
if( s_stepBtnOffLight == nullptr )
{
s_stepBtnOffLight = new QPixmap( embed::getIconPixmap(
"step_btn_off_light" ) );
}
update();
setStyle( QApplication::style() );
@@ -253,9 +228,8 @@ void MidiClipView::constructContextMenu( QMenu * _cm )
void MidiClipView::mousePressEvent( QMouseEvent * _me )
{
bool displayPattern = fixedClips() || (pixelsPerBar() >= 96 && m_legacySEPattern);
if( _me->button() == Qt::LeftButton &&
m_clip->m_clipType == MidiClip::Type::BeatClip &&
displayPattern && _me->y() > height() - s_stepBtnOff->height() )
if (_me->button() == Qt::LeftButton && m_clip->m_clipType == MidiClip::Type::BeatClip && displayPattern
&& _me->y() > height() - m_stepBtnOff.height())
// when mouse button is pressed in pattern mode
@@ -325,7 +299,7 @@ void MidiClipView::wheelEvent(QWheelEvent * we)
{
if(m_clip->m_clipType == MidiClip::Type::BeatClip &&
(fixedClips() || pixelsPerBar() >= 96) &&
position(we).y() > height() - s_stepBtnOff->height())
position(we).y() > height() - m_stepBtnOff.height())
{
// get the step number that was wheeled on and
// do calculations in floats to prevent rounding errors...
@@ -472,22 +446,14 @@ void MidiClipView::paintEvent( QPaintEvent * )
const int w = width() - 2 * BORDER_WIDTH;
// scale step graphics to fit the beat clip length
stepon0 = s_stepBtnOn0->scaled(w / steps,
s_stepBtnOn0->height(),
Qt::IgnoreAspectRatio,
Qt::SmoothTransformation);
stepon200 = s_stepBtnOn200->scaled(w / steps,
s_stepBtnOn200->height(),
Qt::IgnoreAspectRatio,
Qt::SmoothTransformation);
stepoff = s_stepBtnOff->scaled(w / steps,
s_stepBtnOff->height(),
Qt::IgnoreAspectRatio,
Qt::SmoothTransformation);
stepoffl = s_stepBtnOffLight->scaled(w / steps,
s_stepBtnOffLight->height(),
Qt::IgnoreAspectRatio,
Qt::SmoothTransformation);
stepon0
= m_stepBtnOn0.scaled(w / steps, m_stepBtnOn0.height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
stepon200 = m_stepBtnOn200.scaled(
w / steps, m_stepBtnOn200.height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
stepoff
= m_stepBtnOff.scaled(w / steps, m_stepBtnOff.height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
stepoffl = m_stepBtnOffLight.scaled(
w / steps, m_stepBtnOffLight.height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
for (int it = 0; it < steps; it++) // go through all the steps in the beat clip
{
@@ -495,7 +461,7 @@ void MidiClipView::paintEvent( QPaintEvent * )
// figure out x and y coordinates for step graphic
const int x = BORDER_WIDTH + static_cast<int>(it * w / steps);
const int y = height() - s_stepBtnOff->height() - 1;
const int y = height() - m_stepBtnOff.height() - 1;
if (n)
{

View File

@@ -64,15 +64,6 @@
namespace lmms::gui
{
QPixmap * AutomationEditor::s_toolDraw = nullptr;
QPixmap * AutomationEditor::s_toolErase = nullptr;
QPixmap * AutomationEditor::s_toolDrawOut = nullptr;
QPixmap * AutomationEditor::s_toolEditTangents = nullptr;
QPixmap * AutomationEditor::s_toolMove = nullptr;
QPixmap * AutomationEditor::s_toolYFlip = nullptr;
QPixmap * AutomationEditor::s_toolXFlip = nullptr;
const std::array<float, 7> AutomationEditor::m_zoomXLevels =
{ 0.125f, 0.25f, 0.5f, 1.0f, 2.0f, 4.0f, 8.0f };
@@ -135,17 +126,6 @@ AutomationEditor::AutomationEditor() :
this, SLOT(setQuantization()));
m_quantizeModel.setValue( m_quantizeModel.findText( "1/8" ) );
if (s_toolYFlip == nullptr)
{
s_toolYFlip = new QPixmap( embed::getIconPixmap(
"flip_y" ) );
}
if (s_toolXFlip == nullptr)
{
s_toolXFlip = new QPixmap( embed::getIconPixmap(
"flip_x" ) );
}
// add time-line
m_timeLine = new TimeLineWidget( VALUES_WIDTH, 0, m_ppb,
Engine::getSong()->getPlayPos(
@@ -169,28 +149,6 @@ AutomationEditor::AutomationEditor() :
connect( m_topBottomScroll, SIGNAL(valueChanged(int)), this,
SLOT(verScrolled(int)));
// init pixmaps
if (s_toolDraw == nullptr)
{
s_toolDraw = new QPixmap(embed::getIconPixmap("edit_draw"));
}
if (s_toolErase == nullptr)
{
s_toolErase= new QPixmap(embed::getIconPixmap("edit_erase"));
}
if (s_toolDrawOut == nullptr)
{
s_toolDrawOut = new QPixmap(embed::getIconPixmap("edit_draw_outvalue"));
}
if (s_toolEditTangents == nullptr)
{
s_toolEditTangents = new QPixmap(embed::getIconPixmap("edit_tangent"));
}
if (s_toolMove == nullptr)
{
s_toolMove = new QPixmap(embed::getIconPixmap("edit_move"));
}
setCurrentClip(nullptr);
setMouseTracking( true );
@@ -1400,26 +1358,26 @@ void AutomationEditor::paintEvent(QPaintEvent * pe )
{
case EditMode::Draw:
{
if (m_action == Action::EraseValues) { cursor = s_toolErase; }
else if (m_action == Action::MoveValue) { cursor = s_toolMove; }
else { cursor = s_toolDraw; }
if (m_action == Action::EraseValues) { cursor = &m_toolErase; }
else if (m_action == Action::MoveValue) { cursor = &m_toolMove; }
else { cursor = &m_toolDraw; }
break;
}
case EditMode::Erase:
{
cursor = s_toolErase;
cursor = &m_toolErase;
break;
}
case EditMode::DrawOutValues:
{
if (m_action == Action::ResetOutValues) { cursor = s_toolErase; }
else if (m_action == Action::MoveOutValue) { cursor = s_toolMove; }
else { cursor = s_toolDrawOut; }
if (m_action == Action::ResetOutValues) { cursor = &m_toolErase; }
else if (m_action == Action::MoveOutValue) { cursor = &m_toolMove; }
else { cursor = &m_toolDrawOut; }
break;
}
case EditMode::EditTangents:
{
cursor = m_action == Action::MoveTangent ? s_toolMove : s_toolEditTangents;
cursor = m_action == Action::MoveTangent ? &m_toolMove : &m_toolEditTangents;
break;
}
}

View File

@@ -119,15 +119,6 @@ const int INITIAL_START_KEY = Octave::Octave_4 + Key::C;
const int NUM_EVEN_LENGTHS = 6;
const int NUM_TRIPLET_LENGTHS = 5;
QPixmap * PianoRoll::s_toolDraw = nullptr;
QPixmap * PianoRoll::s_toolErase = nullptr;
QPixmap * PianoRoll::s_toolSelect = nullptr;
QPixmap * PianoRoll::s_toolMove = nullptr;
QPixmap * PianoRoll::s_toolOpen = nullptr;
QPixmap* PianoRoll::s_toolKnife = nullptr;
SimpleTextFloat * PianoRoll::s_textFloat = nullptr;
static std::array<QString, 12> s_noteStrings {
@@ -264,32 +255,6 @@ PianoRoll::PianoRoll() :
m_semiToneMarkerMenu->addAction( unmarkAllAction );
m_semiToneMarkerMenu->addAction( copyAllNotesAction );
// init pixmaps
if( s_toolDraw == nullptr )
{
s_toolDraw = new QPixmap( embed::getIconPixmap( "edit_draw" ) );
}
if( s_toolErase == nullptr )
{
s_toolErase= new QPixmap( embed::getIconPixmap( "edit_erase" ) );
}
if( s_toolSelect == nullptr )
{
s_toolSelect = new QPixmap( embed::getIconPixmap( "edit_select" ) );
}
if( s_toolMove == nullptr )
{
s_toolMove = new QPixmap( embed::getIconPixmap( "edit_move" ) );
}
if( s_toolOpen == nullptr )
{
s_toolOpen = new QPixmap( embed::getIconPixmap( "automation" ) );
}
if (s_toolKnife == nullptr)
{
s_toolKnife = new QPixmap(embed::getIconPixmap("edit_knife"));
}
// init text-float
if( s_textFloat == nullptr )
{
@@ -3703,21 +3668,29 @@ void PianoRoll::paintEvent(QPaintEvent * pe )
case EditMode::Draw:
if( m_mouseDownRight )
{
cursor = s_toolErase;
cursor = &m_toolErase;
}
else if( m_action == Action::MoveNote )
{
cursor = s_toolMove;
cursor = &m_toolMove;
}
else
{
cursor = s_toolDraw;
cursor = &m_toolDraw;
}
break;
case EditMode::Erase: cursor = s_toolErase; break;
case EditMode::Select: cursor = s_toolSelect; break;
case EditMode::Detuning: cursor = s_toolOpen; break;
case EditMode::Knife: cursor = s_toolKnife; break;
case EditMode::Erase:
cursor = &m_toolErase;
break;
case EditMode::Select:
cursor = &m_toolSelect;
break;
case EditMode::Detuning:
cursor = &m_toolOpen;
break;
case EditMode::Knife:
cursor = &m_toolKnife;
break;
}
QPoint mousePosition = mapFromGlobal( QCursor::pos() );
if( cursor != nullptr && mousePosition.y() > keyAreaTop() && mousePosition.x() > noteEditLeft())

View File

@@ -45,9 +45,6 @@ namespace
constexpr int MIN_BAR_LABEL_DISTANCE = 35;
}
QPixmap * TimeLineWidget::s_posMarkerPixmap = nullptr;
TimeLineWidget::TimeLineWidget( const int xoff, const int yoff, const float ppb,
Song::PlayPos & pos, const TimePos & begin, Song::PlayMode mode,
QWidget * parent ) :
@@ -80,16 +77,10 @@ TimeLineWidget::TimeLineWidget( const int xoff, const int yoff, const float ppb,
m_loopPos[0] = 0;
m_loopPos[1] = DefaultTicksPerBar;
if( s_posMarkerPixmap == nullptr )
{
s_posMarkerPixmap = new QPixmap( embed::getIconPixmap(
"playpos_marker" ) );
}
setAttribute( Qt::WA_OpaquePaintEvent, true );
move( 0, yoff );
m_xOffset -= s_posMarkerPixmap->width() / 2;
m_xOffset -= m_posMarkerPixmap.width() / 2;
setMouseTracking(true);
m_pos.m_timeLine = this;
@@ -119,7 +110,7 @@ TimeLineWidget::~TimeLineWidget()
void TimeLineWidget::setXOffset(const int x)
{
m_xOffset = x;
if (s_posMarkerPixmap != nullptr) { m_xOffset -= s_posMarkerPixmap->width() / 2; }
m_xOffset -= m_posMarkerPixmap.width() / 2;
}
@@ -245,7 +236,7 @@ void TimeLineWidget::paintEvent( QPaintEvent * )
p.fillRect( 0, 0, width(), height(), p.background() );
// Clip so that we only draw everything starting from the offset
const int leftMargin = m_xOffset + s_posMarkerPixmap->width() / 2;
const int leftMargin = m_xOffset + m_posMarkerPixmap.width() / 2;
p.setClipRect(leftMargin, 0, width() - leftMargin, height() );
// Draw the loop rectangle
@@ -273,8 +264,8 @@ void TimeLineWidget::paintEvent( QPaintEvent * )
QColor const & barNumberColor = getBarNumberColor();
bar_t barNumber = m_begin.getBar();
int const x = m_xOffset + s_posMarkerPixmap->width() / 2 -
( ( static_cast<int>( m_begin * m_ppb ) / TimePos::ticksPerBar() ) % static_cast<int>( m_ppb ) );
int const x = m_xOffset + m_posMarkerPixmap.width() / 2
- ((static_cast<int>(m_begin * m_ppb) / TimePos::ticksPerBar()) % static_cast<int>(m_ppb));
// Double the interval between bar numbers until they are far enough appart
int barLabelInterval = 1;
@@ -307,12 +298,12 @@ void TimeLineWidget::paintEvent( QPaintEvent * )
p.drawRect( innerRectangle );
// Only draw the position marker if the position line is in view
if (m_posMarkerX >= m_xOffset && m_posMarkerX < width() - s_posMarkerPixmap->width() / 2)
if (m_posMarkerX >= m_xOffset && m_posMarkerX < width() - m_posMarkerPixmap.width() / 2)
{
// Let the position marker extrude to the left
p.setClipping(false);
p.setOpacity(0.6);
p.drawPixmap(m_posMarkerX, height() - s_posMarkerPixmap->height(), *s_posMarkerPixmap);
p.drawPixmap(m_posMarkerX, height() - m_posMarkerPixmap.height(), m_posMarkerPixmap);
}
}
@@ -328,13 +319,13 @@ void TimeLineWidget::mousePressEvent( QMouseEvent* event )
if( event->button() == Qt::LeftButton && !(event->modifiers() & Qt::ShiftModifier) )
{
m_action = Action::MovePositionMarker;
if( event->x() - m_xOffset < s_posMarkerPixmap->width() )
if (event->x() - m_xOffset < m_posMarkerPixmap.width())
{
m_moveXOff = event->x() - m_xOffset;
}
else
{
m_moveXOff = s_posMarkerPixmap->width() / 2;
m_moveXOff = m_posMarkerPixmap.width() / 2;
}
}
else if( event->button() == Qt::LeftButton && (event->modifiers() & Qt::ShiftModifier) )
@@ -344,7 +335,7 @@ void TimeLineWidget::mousePressEvent( QMouseEvent* event )
}
else if( event->button() == Qt::RightButton )
{
m_moveXOff = s_posMarkerPixmap->width() / 2;
m_moveXOff = m_posMarkerPixmap.width() / 2;
const TimePos t = m_begin + static_cast<int>( qMax( event->x() - m_xOffset - m_moveXOff, 0 ) * TimePos::ticksPerBar() / m_ppb );
const TimePos loopMid = ( m_loopPos[0] + m_loopPos[1] ) / 2;

View File

@@ -79,25 +79,11 @@ const int LFO_AMOUNT_KNOB_X = LFO_SPEED_KNOB_X+KNOB_X_SPACING;
const int LFO_SHAPES_X = LFO_GRAPH_X;//PREDELAY_KNOB_X;
const int LFO_SHAPES_Y = LFO_GRAPH_Y + 50;
QPixmap * EnvelopeAndLfoView::s_envGraph = nullptr;
QPixmap * EnvelopeAndLfoView::s_lfoGraph = nullptr;
EnvelopeAndLfoView::EnvelopeAndLfoView( QWidget * _parent ) :
QWidget( _parent ),
ModelView( nullptr, this ),
m_params( nullptr )
{
if( s_envGraph == nullptr )
{
s_envGraph = new QPixmap( embed::getIconPixmap( "envelope_graph" ) );
}
if( s_lfoGraph == nullptr )
{
s_lfoGraph = new QPixmap( embed::getIconPixmap( "lfo_graph" ) );
}
m_predelayKnob = new Knob( KnobType::Bright26, this );
m_predelayKnob->setLabel( tr( "DEL" ) );
@@ -277,8 +263,7 @@ void EnvelopeAndLfoView::mousePressEvent( QMouseEvent * _me )
return;
}
if( QRect( ENV_GRAPH_X, ENV_GRAPH_Y, s_envGraph->width(),
s_envGraph->height() ).contains( _me->pos() ) == true )
if (QRect(ENV_GRAPH_X, ENV_GRAPH_Y, m_envGraph.width(), m_envGraph.height()).contains(_me->pos()))
{
if( m_params->m_amountModel.value() < 1.0f )
{
@@ -289,8 +274,7 @@ void EnvelopeAndLfoView::mousePressEvent( QMouseEvent * _me )
m_params->m_amountModel.setValue( 0.0f );
}
}
else if( QRect( LFO_GRAPH_X, LFO_GRAPH_Y, s_lfoGraph->width(),
s_lfoGraph->height() ).contains( _me->pos() ) == true )
else if (QRect(LFO_GRAPH_X, LFO_GRAPH_Y, m_lfoGraph.width(), m_lfoGraph.height()).contains(_me->pos()))
{
if( m_params->m_lfoAmountModel.value() < 1.0f )
{
@@ -351,10 +335,9 @@ void EnvelopeAndLfoView::paintEvent( QPaintEvent * )
p.setRenderHint( QPainter::Antialiasing );
// draw envelope-graph
p.drawPixmap( ENV_GRAPH_X, ENV_GRAPH_Y, *s_envGraph );
p.drawPixmap(ENV_GRAPH_X, ENV_GRAPH_Y, m_envGraph);
// draw LFO-graph
p.drawPixmap( LFO_GRAPH_X, LFO_GRAPH_Y, *s_lfoGraph );
p.drawPixmap(LFO_GRAPH_X, LFO_GRAPH_Y, m_lfoGraph);
p.setFont( pointSize<8>( p.font() ) );
@@ -368,8 +351,8 @@ void EnvelopeAndLfoView::paintEvent( QPaintEvent * )
const QColor end_points_color( 0x99, 0xAF, 0xFF );
const QColor end_points_bg_color( 0, 0, 2 );
const int y_base = ENV_GRAPH_Y + s_envGraph->height() - 3;
const int avail_height = s_envGraph->height() - 6;
const int y_base = ENV_GRAPH_Y + m_envGraph.height() - 3;
const int avail_height = m_envGraph.height() - 6;
int x1 = static_cast<int>( m_predelayKnob->value<float>() * TIME_UNIT_WIDTH );
int x2 = x1 + static_cast<int>( m_attackKnob->value<float>() * TIME_UNIT_WIDTH );
@@ -422,9 +405,8 @@ void EnvelopeAndLfoView::paintEvent( QPaintEvent * )
p.fillRect( x5 - 1, y_base - 2, 4, 4, end_points_bg_color );
p.fillRect( x5, y_base - 1, 2, 2, end_points_color );
int LFO_GRAPH_W = s_lfoGraph->width() - 3; // subtract border
int LFO_GRAPH_H = s_lfoGraph->height() - 6; // subtract border
int LFO_GRAPH_W = m_lfoGraph.width() - 3; // subtract border
int LFO_GRAPH_H = m_lfoGraph.height() - 6; // subtract border
int graph_x_base = LFO_GRAPH_X + 2;
int graph_y_base = LFO_GRAPH_Y + 3 + LFO_GRAPH_H / 2;
@@ -505,11 +487,8 @@ void EnvelopeAndLfoView::paintEvent( QPaintEvent * )
int ms_per_osc = static_cast<int>( SECS_PER_LFO_OSCILLATION *
m_lfoSpeedKnob->value<float>() *
1000.0f );
p.drawText( LFO_GRAPH_X + 4, LFO_GRAPH_Y + s_lfoGraph->height() - 6,
tr( "ms/LFO:" ) );
p.drawText( LFO_GRAPH_X + 52, LFO_GRAPH_Y + s_lfoGraph->height() - 6,
QString::number( ms_per_osc ) );
p.drawText(LFO_GRAPH_X + 4, LFO_GRAPH_Y + m_lfoGraph.height() - 6, tr("ms/LFO:"));
p.drawText(LFO_GRAPH_X + 52, LFO_GRAPH_Y + m_lfoGraph.height() - 6, QString::number(ms_per_osc));
}
@@ -536,4 +515,4 @@ void EnvelopeAndLfoView::lfoUserWaveChanged()
} // namespace gui
} // namespace lmms
} // namespace lmms

View File

@@ -67,15 +67,6 @@ auto WhiteKeys = std::array
Key::C, Key::D, Key::E, Key::F, Key::G, Key::A, Key::H
} ;
QPixmap * PianoView::s_whiteKeyPm = nullptr; /*!< A white key released */
QPixmap * PianoView::s_blackKeyPm = nullptr; /*!< A black key released */
QPixmap * PianoView::s_whiteKeyPressedPm = nullptr; /*!< A white key pressed */
QPixmap * PianoView::s_blackKeyPressedPm = nullptr; /*!< A black key pressed */
QPixmap * PianoView::s_whiteKeyDisabledPm = nullptr; /*!< A white key disabled */
QPixmap * PianoView::s_blackKeyDisabledPm = nullptr; /*!< A black key disabled */
const int PIANO_BASE = 11; /*!< The height of the root note display */
const int PW_WHITE_KEY_WIDTH = 10; /*!< The width of a white key */
const int PW_BLACK_KEY_WIDTH = 8; /*!< The width of a black key */
@@ -99,31 +90,6 @@ PianoView::PianoView(QWidget *parent) :
m_lastKey(-1), /*!< The last key displayed? */
m_movedNoteModel(nullptr) /*!< Key marker which is being moved */
{
if (s_whiteKeyPm == nullptr)
{
s_whiteKeyPm = new QPixmap(embed::getIconPixmap("white_key"));
}
if (s_blackKeyPm == nullptr)
{
s_blackKeyPm = new QPixmap(embed::getIconPixmap("black_key"));
}
if (s_whiteKeyPressedPm == nullptr)
{
s_whiteKeyPressedPm = new QPixmap(embed::getIconPixmap("white_key_pressed"));
}
if (s_blackKeyPressedPm == nullptr)
{
s_blackKeyPressedPm = new QPixmap(embed::getIconPixmap("black_key_pressed"));
}
if (s_whiteKeyDisabledPm == nullptr)
{
s_whiteKeyDisabledPm = new QPixmap(embed::getIconPixmap("white_key_disabled"));
}
if (s_blackKeyDisabledPm == nullptr)
{
s_blackKeyDisabledPm = new QPixmap(embed::getIconPixmap("black_key_disabled"));
}
setAttribute(Qt::WA_OpaquePaintEvent, true);
setFocusPolicy(Qt::StrongFocus);
@@ -894,16 +860,16 @@ void PianoView::paintEvent( QPaintEvent * )
{
if (m_piano && m_piano->isKeyPressed(cur_key))
{
p.drawPixmap(x, PIANO_BASE, *s_whiteKeyPressedPm);
p.drawPixmap(x, PIANO_BASE, m_whiteKeyPressedPm);
}
else
{
p.drawPixmap(x, PIANO_BASE, *s_whiteKeyPm);
p.drawPixmap(x, PIANO_BASE, m_whiteKeyPm);
}
}
else
{
p.drawPixmap(x, PIANO_BASE, *s_whiteKeyDisabledPm);
p.drawPixmap(x, PIANO_BASE, m_whiteKeyDisabledPm);
}
x += PW_WHITE_KEY_WIDTH;
@@ -928,16 +894,16 @@ void PianoView::paintEvent( QPaintEvent * )
{
if (m_piano && m_piano->isKeyPressed(startKey))
{
p.drawPixmap(0 - PW_WHITE_KEY_WIDTH / 2, PIANO_BASE, *s_blackKeyPressedPm);
p.drawPixmap(0 - PW_WHITE_KEY_WIDTH / 2, PIANO_BASE, m_blackKeyPressedPm);
}
else
{
p.drawPixmap(0 - PW_WHITE_KEY_WIDTH / 2, PIANO_BASE, *s_blackKeyPm);
p.drawPixmap(0 - PW_WHITE_KEY_WIDTH / 2, PIANO_BASE, m_blackKeyPm);
}
}
else
{
p.drawPixmap(0 - PW_WHITE_KEY_WIDTH / 2, PIANO_BASE, *s_blackKeyDisabledPm);
p.drawPixmap(0 - PW_WHITE_KEY_WIDTH / 2, PIANO_BASE, m_blackKeyDisabledPm);
}
}
@@ -951,16 +917,16 @@ void PianoView::paintEvent( QPaintEvent * )
{
if (m_piano && m_piano->isKeyPressed(cur_key))
{
p.drawPixmap(x + PW_WHITE_KEY_WIDTH / 2, PIANO_BASE, *s_blackKeyPressedPm);
p.drawPixmap(x + PW_WHITE_KEY_WIDTH / 2, PIANO_BASE, m_blackKeyPressedPm);
}
else
{
p.drawPixmap(x + PW_WHITE_KEY_WIDTH / 2, PIANO_BASE, *s_blackKeyPm);
p.drawPixmap(x + PW_WHITE_KEY_WIDTH / 2, PIANO_BASE, m_blackKeyPm);
}
}
else
{
p.drawPixmap(x + PW_WHITE_KEY_WIDTH / 2, PIANO_BASE, *s_blackKeyDisabledPm);
p.drawPixmap(x + PW_WHITE_KEY_WIDTH / 2, PIANO_BASE, m_blackKeyDisabledPm);
}
x += PW_WHITE_KEY_WIDTH;
white_cnt = 0;

View File

@@ -38,11 +38,6 @@
namespace lmms::gui
{
QPixmap * ComboBox::s_background = nullptr;
QPixmap * ComboBox::s_arrow = nullptr;
QPixmap * ComboBox::s_arrowSelected = nullptr;
const int CB_ARROW_BTN_WIDTH = 18;
@@ -54,21 +49,6 @@ ComboBox::ComboBox( QWidget * _parent, const QString & _name ) :
{
setFixedHeight( ComboBox::DEFAULT_HEIGHT );
if( s_background == nullptr )
{
s_background = new QPixmap( embed::getIconPixmap( "combobox_bg" ) );
}
if( s_arrow == nullptr )
{
s_arrow = new QPixmap( embed::getIconPixmap( "combobox_arrow" ) );
}
if( s_arrowSelected == nullptr )
{
s_arrowSelected = new QPixmap( embed::getIconPixmap( "combobox_arrow_selected" ) );
}
setFont( pointSize<9>( font() ) );
connect( &m_menu, SIGNAL(triggered(QAction*)),
@@ -172,7 +152,7 @@ void ComboBox::paintEvent( QPaintEvent * _pe )
{
QPainter p( this );
p.fillRect( 2, 2, width()-2, height()-4, *s_background );
p.fillRect(2, 2, width() - 2, height() - 4, m_background);
QColor shadow = palette().shadow().color();
QColor highlight = palette().highlight().color();
@@ -194,9 +174,9 @@ void ComboBox::paintEvent( QPaintEvent * _pe )
style()->drawPrimitive( QStyle::PE_Frame, &opt, &p, this );
QPixmap * arrow = m_pressed ? s_arrowSelected : s_arrow;
auto arrow = m_pressed ? m_arrowSelected : m_arrow;
p.drawPixmap( width() - CB_ARROW_BTN_WIDTH + 3, 4, *arrow );
p.drawPixmap(width() - CB_ARROW_BTN_WIDTH + 3, 4, arrow);
if( model() && model()->size() > 0 )
{

View File

@@ -59,11 +59,7 @@
namespace lmms::gui
{
SimpleTextFloat * Fader::s_textFloat = nullptr;
QPixmap * Fader::s_back = nullptr;
QPixmap * Fader::s_leds = nullptr;
QPixmap * Fader::s_knob = nullptr;
Fader::Fader( FloatModel * _model, const QString & _name, QWidget * _parent ) :
QWidget( _parent ),
@@ -85,22 +81,6 @@ Fader::Fader( FloatModel * _model, const QString & _name, QWidget * _parent ) :
{
s_textFloat = new SimpleTextFloat;
}
if( ! s_back )
{
s_back = new QPixmap( embed::getIconPixmap( "fader_background" ) );
}
if( ! s_leds )
{
s_leds = new QPixmap( embed::getIconPixmap( "fader_leds" ) );
}
if( ! s_knob )
{
s_knob = new QPixmap( embed::getIconPixmap( "fader_knob" ) );
}
m_back = s_back;
m_leds = s_leds;
m_knob = s_knob;
init(_model, _name);
@@ -128,10 +108,6 @@ Fader::Fader( FloatModel * model, const QString & name, QWidget * parent, QPixma
s_textFloat = new SimpleTextFloat;
}
m_back = back;
m_leds = leds;
m_knob = knob;
init(model, name);
}
@@ -139,7 +115,7 @@ void Fader::init(FloatModel * model, QString const & name)
{
setWindowTitle( name );
setAttribute( Qt::WA_OpaquePaintEvent, false );
QSize backgroundSize = m_back->size();
QSize backgroundSize = m_back.size();
setMinimumSize( backgroundSize );
setMaximumSize( backgroundSize );
resize( backgroundSize );
@@ -166,7 +142,7 @@ void Fader::mouseMoveEvent( QMouseEvent *mouseEvent )
{
int dy = m_moveStartPoint - mouseEvent->globalY();
float delta = dy * ( model()->maxValue() - model()->minValue() ) / (float) ( height() - ( *m_knob ).height() );
float delta = dy * (model()->maxValue() - model()->minValue()) / (float)(height() - (m_knob).height());
const auto step = model()->step<float>();
float newValue = static_cast<float>( static_cast<int>( ( m_startValue + delta ) / step + 0.5 ) ) * step;
@@ -191,7 +167,7 @@ void Fader::mousePressEvent( QMouseEvent* mouseEvent )
thisModel->saveJournallingState( false );
}
if( mouseEvent->y() >= knobPosY() - ( *m_knob ).height() && mouseEvent->y() < knobPosY() )
if (mouseEvent->y() >= knobPosY() - (m_knob).height() && mouseEvent->y() < knobPosY())
{
updateTextFloat();
s_textFloat->show();
@@ -335,9 +311,9 @@ void Fader::updateTextFloat()
inline int Fader::calculateDisplayPeak( float fPeak )
{
int peak = (int)( m_back->height() - ( fPeak / ( m_fMaxPeak - m_fMinPeak ) ) * m_back->height() );
int peak = static_cast<int>(m_back.height() - (fPeak / (m_fMaxPeak - m_fMinPeak)) * m_back.height());
return qMin( peak, m_back->height() );
return qMin(peak, m_back.height());
}
@@ -346,7 +322,7 @@ void Fader::paintEvent( QPaintEvent * ev)
QPainter painter(this);
// Draw the background
painter.drawPixmap( ev->rect(), *m_back, ev->rect() );
painter.drawPixmap(ev->rect(), m_back, ev->rect());
// Draw the levels with peaks
if (getLevelsDisplayedInDBFS())
@@ -359,14 +335,14 @@ void Fader::paintEvent( QPaintEvent * ev)
}
// Draw the knob
painter.drawPixmap( 0, knobPosY() - m_knob->height(), *m_knob );
painter.drawPixmap(0, knobPosY() - m_knob.height(), m_knob);
}
void Fader::paintDBFSLevels(QPaintEvent * ev, QPainter & painter)
{
int height = m_back->height();
int width = m_back->width() / 2;
int center = m_back->width() - width;
int height = m_back.height();
int width = m_back.width() / 2;
int center = m_back.width() - width;
float const maxDB(ampToDbfs(m_fMaxPeak));
float const minDB(ampToDbfs(m_fMinPeak));
@@ -380,7 +356,7 @@ void Fader::paintDBFSLevels(QPaintEvent * ev, QPainter & painter)
float const leftSpan = ampToDbfs(qMax<float>(0.0001, m_fPeakValue_L)) - minDB;
int peak_L = height * leftSpan * fullSpanReciprocal;
QRect drawRectL( 0, height - peak_L, width, peak_L ); // Source and target are identical
painter.drawPixmap( drawRectL, *m_leds, drawRectL );
painter.drawPixmap(drawRectL, m_leds, drawRectL);
float const persistentLeftPeakDBFS = ampToDbfs(qMax<float>(0.0001, m_persistentPeak_L));
int persistentPeak_L = height * (1 - (persistentLeftPeakDBFS - minDB) * fullSpanReciprocal);
@@ -402,7 +378,7 @@ void Fader::paintDBFSLevels(QPaintEvent * ev, QPainter & painter)
float const rightSpan = ampToDbfs(qMax<float>(0.0001, m_fPeakValue_R)) - minDB;
int peak_R = height * rightSpan * fullSpanReciprocal;
QRect const drawRectR( center, height - peak_R, width, peak_R ); // Source and target are identical
painter.drawPixmap( drawRectR, *m_leds, drawRectR );
painter.drawPixmap(drawRectR, m_leds, drawRectR);
float const persistentRightPeakDBFS = ampToDbfs(qMax<float>(0.0001, m_persistentPeak_R));
int persistentPeak_R = height * (1 - (persistentRightPeakDBFS - minDB) * fullSpanReciprocal);
@@ -425,13 +401,13 @@ void Fader::paintLinearLevels(QPaintEvent * ev, QPainter & painter)
// peak leds
//float fRange = abs( m_fMaxPeak ) + abs( m_fMinPeak );
int height = m_back->height();
int width = m_back->width() / 2;
int center = m_back->width() - width;
int height = m_back.height();
int width = m_back.width() / 2;
int center = m_back.width() - width;
int peak_L = calculateDisplayPeak( m_fPeakValue_L - m_fMinPeak );
int persistentPeak_L = qMax<int>( 3, calculateDisplayPeak( m_persistentPeak_L - m_fMinPeak ) );
painter.drawPixmap( QRect( 0, peak_L, width, height - peak_L ), *m_leds, QRect( 0, peak_L, width, height - peak_L ) );
painter.drawPixmap(QRect(0, peak_L, width, height - peak_L), m_leds, QRect(0, peak_L, width, height - peak_L));
if( m_persistentPeak_L > 0.05 )
{
@@ -442,7 +418,7 @@ void Fader::paintLinearLevels(QPaintEvent * ev, QPainter & painter)
int peak_R = calculateDisplayPeak( m_fPeakValue_R - m_fMinPeak );
int persistentPeak_R = qMax<int>( 3, calculateDisplayPeak( m_persistentPeak_R - m_fMinPeak ) );
painter.drawPixmap( QRect( center, peak_R, width, height - peak_R ), *m_leds, QRect( center, peak_R, width, height - peak_R ) );
painter.drawPixmap(QRect(center, peak_R, width, height - peak_R), m_leds, QRect(center, peak_R, width, height - peak_R));
if( m_persistentPeak_R > 0.05 )
{

View File

@@ -66,17 +66,6 @@ LcdWidget::LcdWidget(int numDigits, const QString& style, QWidget* parent, const
initUi( name, style );
}
LcdWidget::~LcdWidget()
{
delete m_lcdPixmap;
}
void LcdWidget::setValue(int value)
{
QString s = m_textForValue[value];
@@ -162,11 +151,8 @@ void LcdWidget::paintEvent( QPaintEvent* )
{
p.translate(margin, margin);
// Left Margin
p.drawPixmap(
cellRect,
*m_lcdPixmap,
QRect(QPoint(charsPerPixmap * m_cellWidth, isEnabled() ? 0 : m_cellHeight), cellSize)
);
p.drawPixmap(cellRect, m_lcdPixmap,
QRect(QPoint(charsPerPixmap * m_cellWidth, isEnabled() ? 0 : m_cellHeight), cellSize));
p.translate(m_marginWidth, 0);
}
@@ -174,8 +160,7 @@ void LcdWidget::paintEvent( QPaintEvent* )
// Padding
for( int i=0; i < m_numDigits - m_display.length(); i++ )
{
p.drawPixmap( cellRect, *m_lcdPixmap,
QRect( QPoint( 10 * m_cellWidth, isEnabled()?0:m_cellHeight) , cellSize ) );
p.drawPixmap(cellRect, m_lcdPixmap, QRect(QPoint(10 * m_cellWidth, isEnabled() ? 0 : m_cellHeight), cellSize));
p.translate( m_cellWidth, 0 );
}
@@ -189,19 +174,14 @@ void LcdWidget::paintEvent( QPaintEvent* )
else
val = 10;
}
p.drawPixmap( cellRect, *m_lcdPixmap,
QRect( QPoint( val*m_cellWidth,
isEnabled()?0:m_cellHeight ),
cellSize ) );
p.drawPixmap(cellRect, m_lcdPixmap, QRect(QPoint(val * m_cellWidth, isEnabled() ? 0 : m_cellHeight), cellSize));
p.translate( m_cellWidth, 0 );
}
// Right Margin
p.drawPixmap(QRect(0, 0, m_seamlessRight ? 0 : m_marginWidth - 1, m_cellHeight),
*m_lcdPixmap,
p.drawPixmap(QRect(0, 0, m_seamlessRight ? 0 : m_marginWidth - 1, m_cellHeight), m_lcdPixmap,
QRect(charsPerPixmap * m_cellWidth, isEnabled() ? 0 : m_cellHeight, m_cellWidth / 2, m_cellHeight));
p.restore();
// Border
@@ -294,12 +274,12 @@ void LcdWidget::initUi(const QString& name , const QString& style)
setWindowTitle( name );
// We should make a factory for these or something.
//m_lcdPixmap = new QPixmap( embed::getIconPixmap( QString( "lcd_" + style ).toUtf8().constData() ) );
//m_lcdPixmap = new QPixmap( embed::getIconPixmap( "lcd_19green" ) ); // TODO!!
m_lcdPixmap = new QPixmap( embed::getIconPixmap( QString( "lcd_" + style ).toUtf8().constData() ) );
//m_lcdPixmap = embed::getIconPixmap(QString("lcd_" + style).toUtf8().constData());
//m_lcdPixmap = embed::getIconPixmap("lcd_19green"); // TODO!!
m_cellWidth = m_lcdPixmap->size().width() / LcdWidget::charsPerPixmap;
m_cellHeight = m_lcdPixmap->size().height() / 2;
m_lcdPixmap = embed::getIconPixmap(QString("lcd_" + style).toUtf8().constData());
m_cellWidth = m_lcdPixmap.size().width() / LcdWidget::charsPerPixmap;
m_cellHeight = m_lcdPixmap.size().height() / 2;
m_marginWidth = m_cellWidth / 2;

View File

@@ -61,17 +61,6 @@ LedCheckBox::LedCheckBox( QWidget * _parent,
{
}
LedCheckBox::~LedCheckBox()
{
delete m_ledOnPixmap;
delete m_ledOffPixmap;
}
void LedCheckBox::setText( const QString &s )
{
m_text = s;
@@ -100,9 +89,8 @@ void LedCheckBox::initUi( LedColor _color )
{
setCheckable( true );
m_ledOnPixmap = new QPixmap( embed::getIconPixmap(
names[static_cast<std::size_t>(_color)].toUtf8().constData() ) );
m_ledOffPixmap = new QPixmap( embed::getIconPixmap( "led_off" ) );
m_ledOnPixmap = embed::getIconPixmap(names[static_cast<std::size_t>(_color)].toUtf8().constData());
m_ledOffPixmap = embed::getIconPixmap("led_off");
if (m_legacyMode)
{
@@ -119,8 +107,8 @@ void LedCheckBox::onTextUpdated()
{
QFontMetrics const fm = fontMetrics();
int const width = m_ledOffPixmap->width() + 5 + horizontalAdvance(fm, text());
int const height = m_legacyMode ? m_ledOffPixmap->height() : qMax(m_ledOffPixmap->height(), fm.height());
int const width = m_ledOffPixmap.width() + 5 + horizontalAdvance(fm, text());
int const height = m_legacyMode ? m_ledOffPixmap.height() : qMax(m_ledOffPixmap.height(), fm.height());
setFixedSize(width, height);
}
@@ -130,31 +118,24 @@ void LedCheckBox::paintLegacy(QPaintEvent * pe)
QPainter p( this );
p.setFont( pointSize<7>( font() ) );
if( model()->value() == true )
{
p.drawPixmap( 0, 0, *m_ledOnPixmap );
}
else
{
p.drawPixmap( 0, 0, *m_ledOffPixmap );
}
p.drawPixmap(0, 0, model()->value() ? m_ledOnPixmap : m_ledOffPixmap);
p.setPen( QColor( 64, 64, 64 ) );
p.drawText( m_ledOffPixmap->width() + 4, 11, text() );
p.drawText(m_ledOffPixmap.width() + 4, 11, text());
p.setPen( QColor( 255, 255, 255 ) );
p.drawText( m_ledOffPixmap->width() + 3, 10, text() );
p.drawText(m_ledOffPixmap.width() + 3, 10, text());
}
void LedCheckBox::paintNonLegacy(QPaintEvent * pe)
{
QPainter p(this);
QPixmap * drawnPixmap = model()->value() ? m_ledOnPixmap : m_ledOffPixmap;
auto drawnPixmap = model()->value() ? m_ledOnPixmap : m_ledOffPixmap;
p.drawPixmap( 0, rect().height() / 2 - drawnPixmap->height() / 2, *drawnPixmap);
p.drawPixmap(0, rect().height() / 2 - drawnPixmap.height() / 2, drawnPixmap);
QRect r = rect();
r -= QMargins(m_ledOffPixmap->width() + 5, 0, 0, 0);
r -= QMargins(m_ledOffPixmap.width() + 5, 0, 0, 0);
p.drawText(r, text());
}

View File

@@ -39,13 +39,6 @@
namespace lmms
{
QPixmap * gui::MidiClipView::s_stepBtnOn0 = nullptr;
QPixmap * gui::MidiClipView::s_stepBtnOn200 = nullptr;
QPixmap * gui::MidiClipView::s_stepBtnOff = nullptr;
QPixmap * gui::MidiClipView::s_stepBtnOffLight = nullptr;
MidiClip::MidiClip( InstrumentTrack * _instrument_track ) :
Clip( _instrument_track ),
m_instrumentTrack( _instrument_track ),