Coding conventions
Adjust the code style of the adjusted and created classes according to the coding conventions.
This commit is contained in:
@@ -2,8 +2,8 @@
|
||||
* TextFloat.h - class textFloat, a floating text-label
|
||||
*
|
||||
* Copyright (c) 2023 LMMS team
|
||||
*
|
||||
* This file is part of LMMS - https://lmms.io
|
||||
*
|
||||
* This file is part of LMMS - https://lmms.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public
|
||||
@@ -20,7 +20,7 @@
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA.
|
||||
*
|
||||
*/
|
||||
*/
|
||||
|
||||
|
||||
#ifndef SIMPLE_TEXT_FLOAT_H
|
||||
@@ -42,13 +42,13 @@ public:
|
||||
SimpleTextFloat();
|
||||
~SimpleTextFloat() override = default;
|
||||
|
||||
void setText( const QString & _text );
|
||||
void setText(const QString & text);
|
||||
|
||||
void setVisibilityTimeOut( int _msecs );
|
||||
void setVisibilityTimeOut(int msecs);
|
||||
|
||||
void moveGlobal( QWidget * _w, const QPoint & _offset )
|
||||
void moveGlobal(QWidget * w, const QPoint & offset)
|
||||
{
|
||||
move( _w->mapToGlobal( QPoint( 0, 0 ) ) + _offset );
|
||||
move(w->mapToGlobal(QPoint(0, 0)) + offset);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -42,31 +42,30 @@ public:
|
||||
TextFloat();
|
||||
~TextFloat() override = default;
|
||||
|
||||
void setTitle( const QString & _title );
|
||||
void setText( const QString & _text );
|
||||
void setPixmap( const QPixmap & _pixmap );
|
||||
void setTitle(const QString & title);
|
||||
void setText(const QString & text);
|
||||
void setPixmap(const QPixmap & pixmap);
|
||||
|
||||
void setVisibilityTimeOut( int _msecs );
|
||||
void setVisibilityTimeOut(int msecs);
|
||||
|
||||
static TextFloat * displayMessage( const QString & _title,
|
||||
const QString & _msg,
|
||||
const QPixmap & _pixmap =
|
||||
QPixmap(),
|
||||
int _timeout = 2000,
|
||||
QWidget * _parent = nullptr );
|
||||
static TextFloat * displayMessage(const QString & title,
|
||||
const QString & msg,
|
||||
const QPixmap & pixmap = QPixmap(),
|
||||
int timeout = 2000,
|
||||
QWidget * parent = nullptr);
|
||||
|
||||
void moveGlobal( QWidget * _w, const QPoint & _offset )
|
||||
void moveGlobal(QWidget * w, const QPoint & offset)
|
||||
{
|
||||
move( _w->mapToGlobal( QPoint( 0, 0 ) )+_offset );
|
||||
move(w->mapToGlobal(QPoint(0, 0)) + offset);
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
void mousePressEvent( QMouseEvent * _me ) override;
|
||||
void mousePressEvent(QMouseEvent * me) override;
|
||||
|
||||
|
||||
private:
|
||||
TextFloat(const QString & _title, const QString & _text, const QPixmap & _pixmap);
|
||||
TextFloat(const QString & title, const QString & text, const QPixmap & pixmap);
|
||||
|
||||
QLabel * m_pixmapLabel;
|
||||
QLabel * m_titleLabel;
|
||||
|
||||
@@ -329,7 +329,7 @@ void Fader::updateTextFloat()
|
||||
s_textFloat->setText( m_description + " " + QString("%1 ").arg( model()->value() * m_conversionFactor ) + " " + m_unit );
|
||||
}
|
||||
|
||||
s_textFloat->moveGlobal( this, QPoint( width() + 2, knobPosY() - s_textFloat->height() / 2 ) );
|
||||
s_textFloat->moveGlobal(this, QPoint(width() + 2, knobPosY() - s_textFloat->height() / 2));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -47,15 +47,15 @@ SimpleTextFloat::SimpleTextFloat() :
|
||||
layout->addWidget(m_textLabel);
|
||||
}
|
||||
|
||||
void SimpleTextFloat::setText( const QString & _text )
|
||||
void SimpleTextFloat::setText(const QString & text)
|
||||
{
|
||||
m_textLabel->setText(_text);
|
||||
m_textLabel->setText(text);
|
||||
}
|
||||
|
||||
|
||||
void SimpleTextFloat::setVisibilityTimeOut( int _msecs )
|
||||
void SimpleTextFloat::setVisibilityTimeOut(int msecs)
|
||||
{
|
||||
QTimer::singleShot( _msecs, this, SLOT(hide()));
|
||||
QTimer::singleShot(msecs, this, SLOT(hide()));
|
||||
show();
|
||||
}
|
||||
|
||||
|
||||
@@ -43,8 +43,8 @@ TextFloat::TextFloat() :
|
||||
{
|
||||
}
|
||||
|
||||
TextFloat::TextFloat(const QString & _title, const QString & _text, const QPixmap & _pixmap) :
|
||||
QWidget( getGUI()->mainWindow(), Qt::ToolTip )
|
||||
TextFloat::TextFloat(const QString & title, const QString & text, const QPixmap & pixmap) :
|
||||
QWidget(getGUI()->mainWindow(), Qt::ToolTip)
|
||||
{
|
||||
QHBoxLayout * mainLayout = new QHBoxLayout();
|
||||
setLayout(mainLayout);
|
||||
@@ -68,66 +68,66 @@ TextFloat::TextFloat(const QString & _title, const QString & _text, const QPixma
|
||||
mainLayout->addWidget(titleAndTextWidget);
|
||||
|
||||
// Call the setters so that the hidden state is updated
|
||||
setTitle(_title);
|
||||
setText(_text);
|
||||
setPixmap(_pixmap);
|
||||
setTitle(title);
|
||||
setText(text);
|
||||
setPixmap(pixmap);
|
||||
}
|
||||
|
||||
void TextFloat::setTitle( const QString & _title )
|
||||
void TextFloat::setTitle(const QString & title)
|
||||
{
|
||||
m_titleLabel->setText(_title);
|
||||
m_titleLabel->setHidden(_title.isEmpty());
|
||||
m_titleLabel->setText(title);
|
||||
m_titleLabel->setHidden(title.isEmpty());
|
||||
}
|
||||
|
||||
void TextFloat::setText( const QString & _text )
|
||||
void TextFloat::setText(const QString & text)
|
||||
{
|
||||
m_textLabel->setText(_text);
|
||||
m_textLabel->setHidden(_text.isEmpty());
|
||||
m_textLabel->setText(text);
|
||||
m_textLabel->setHidden(text.isEmpty());
|
||||
}
|
||||
|
||||
void TextFloat::setPixmap( const QPixmap & _pixmap )
|
||||
void TextFloat::setPixmap(const QPixmap & pixmap)
|
||||
{
|
||||
m_pixmapLabel->setPixmap(_pixmap);
|
||||
m_pixmapLabel->setHidden(_pixmap.isNull());
|
||||
m_pixmapLabel->setPixmap(pixmap);
|
||||
m_pixmapLabel->setHidden(pixmap.isNull());
|
||||
}
|
||||
|
||||
void TextFloat::setVisibilityTimeOut( int _msecs )
|
||||
void TextFloat::setVisibilityTimeOut(int msecs)
|
||||
{
|
||||
QTimer::singleShot( _msecs, this, SLOT(hide()));
|
||||
QTimer::singleShot(msecs, this, SLOT(hide()));
|
||||
show();
|
||||
}
|
||||
|
||||
TextFloat * TextFloat::displayMessage( const QString & _title,
|
||||
const QString & _msg,
|
||||
const QPixmap & _pixmap,
|
||||
int _timeout, QWidget * _parent )
|
||||
TextFloat * TextFloat::displayMessage(const QString & title,
|
||||
const QString & msg,
|
||||
const QPixmap & pixmap,
|
||||
int timeout, QWidget * parent)
|
||||
{
|
||||
auto tf = new TextFloat(_title, _msg, _pixmap);
|
||||
auto tf = new TextFloat(title, msg, pixmap);
|
||||
|
||||
// Show the widget so that the correct height is calculated in the code that follows
|
||||
tf->show();
|
||||
|
||||
if( _parent != nullptr )
|
||||
if(parent != nullptr)
|
||||
{
|
||||
tf->moveGlobal( _parent, QPoint( _parent->width() + 2, 0 ) );
|
||||
tf->moveGlobal(parent, QPoint(parent->width() + 2, 0));
|
||||
}
|
||||
else
|
||||
{
|
||||
// If no parent is given move the window to the lower left area of the main window
|
||||
QWidget * mw = getGUI()->mainWindow();
|
||||
tf->moveGlobal( mw, QPoint( 32, mw->height() - tf->height() - 8 ) );
|
||||
tf->moveGlobal(mw, QPoint(32, mw->height() - tf->height() - 8));
|
||||
}
|
||||
|
||||
if( _timeout > 0 )
|
||||
if (timeout > 0)
|
||||
{
|
||||
tf->setAttribute( Qt::WA_DeleteOnClose, true );
|
||||
QTimer::singleShot( _timeout, tf, SLOT(close()));
|
||||
tf->setAttribute(Qt::WA_DeleteOnClose, true);
|
||||
QTimer::singleShot(timeout, tf, SLOT(close()));
|
||||
}
|
||||
|
||||
return tf;
|
||||
}
|
||||
|
||||
void TextFloat::mousePressEvent( QMouseEvent * )
|
||||
void TextFloat::mousePressEvent(QMouseEvent *)
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user