From 6dfdafe1f712caa50a796a2f2ae98352fc5e8fae Mon Sep 17 00:00:00 2001 From: Michael Gregorius Date: Sat, 7 Jan 2023 20:43:53 +0100 Subject: [PATCH 1/3] Improve readability of text floats Improve the readability of text floats by removing the hard coded pixel font size. The widget is now composed of three QLabels which are used to display the title, text and pixmap. Remove the methods paintEvent and updateSize because the widget is now updated automatically whenever the QLabels change state. Merge both versions of TextFloat::displayMessage because one of them was only called by the other. The default constructor of TextFloat now delegates to the "full" constructor. The latter is private because it is only used from within displayMessage. The methods setTitle, setText and setPixmap show/hide their corresponding labels depending on whether there is text or a pixmap to show. Adjust the class Fader so that the text float is shown to the right of the fader. Otherwise the new implementation would have covered the fader while it is being moved. --- include/TextFloat.h | 17 ++-- src/gui/widgets/Fader.cpp | 5 +- src/gui/widgets/TextFloat.cpp | 178 +++++++++++----------------------- 3 files changed, 63 insertions(+), 137 deletions(-) diff --git a/include/TextFloat.h b/include/TextFloat.h index 9fdabc06b..fccd10ae8 100644 --- a/include/TextFloat.h +++ b/include/TextFloat.h @@ -27,10 +27,11 @@ #define TEXT_FLOAT_H #include -#include #include "lmms_export.h" +class QLabel; + namespace lmms::gui { @@ -47,11 +48,6 @@ public: void setVisibilityTimeOut( int _msecs ); - - static TextFloat * displayMessage( const QString & _msg, - int _timeout = 2000, - QWidget * _parent = nullptr, - int _add_y_margin = 0 ); static TextFloat * displayMessage( const QString & _title, const QString & _msg, const QPixmap & _pixmap = @@ -66,16 +62,15 @@ public: protected: - void paintEvent( QPaintEvent * _me ) override; void mousePressEvent( QMouseEvent * _me ) override; private: - void updateSize(); + TextFloat(const QString & _title, const QString & _text, const QPixmap & _pixmap); - QString m_title; - QString m_text; - QPixmap m_pixmap; + QLabel * m_pixmapLabel; + QLabel * m_titleLabel; + QLabel * m_textLabel; }; diff --git a/src/gui/widgets/Fader.cpp b/src/gui/widgets/Fader.cpp index f853ff707..e2d6d8218 100644 --- a/src/gui/widgets/Fader.cpp +++ b/src/gui/widgets/Fader.cpp @@ -328,7 +328,8 @@ void Fader::updateTextFloat() { s_textFloat->setText( m_description + " " + QString("%1 ").arg( model()->value() * m_conversionFactor ) + " " + m_unit ); } - s_textFloat->moveGlobal( this, QPoint( width() - ( *m_knob ).width() - 5, knobPosY() - 46 ) ); + + s_textFloat->moveGlobal( this, QPoint( width() + 2, knobPosY() - s_textFloat->height() / 2 ) ); } @@ -483,4 +484,4 @@ void Fader::setPeakYellow( const QColor & c ) } -} // namespace lmms::gui \ No newline at end of file +} // namespace lmms::gui diff --git a/src/gui/widgets/TextFloat.cpp b/src/gui/widgets/TextFloat.cpp index 99eb5531f..6588902f9 100644 --- a/src/gui/widgets/TextFloat.cpp +++ b/src/gui/widgets/TextFloat.cpp @@ -22,12 +22,15 @@ * */ +#include "TextFloat.h" + #include #include #include +#include +#include +#include -#include "TextFloat.h" -#include "gui_templates.h" #include "GuiApplication.h" #include "MainWindow.h" @@ -36,170 +39,97 @@ namespace lmms::gui TextFloat::TextFloat() : - QWidget( getGUI()->mainWindow(), Qt::ToolTip ), - m_title(), - m_text(), - m_pixmap() + TextFloat("", "", QPixmap()) { - resize( 20, 20 ); - hide(); - - setAttribute( Qt::WA_TranslucentBackground, true ); - setStyle( QApplication::style() ); - setFont( pointSize<8>( font() ) ); } +TextFloat::TextFloat(const QString & _title, const QString & _text, const QPixmap & _pixmap) : + QWidget( getGUI()->mainWindow(), Qt::ToolTip ) +{ + QHBoxLayout * mainLayout = new QHBoxLayout(); + setLayout(mainLayout); + // Create the label that displays the pixmap + m_pixmapLabel = new QLabel(this); + mainLayout->addWidget(m_pixmapLabel); + // Create the widget that displays the title and the text + QWidget * titleAndTextWidget = new QWidget(this); + QVBoxLayout * titleAndTextLayout = new QVBoxLayout(); + titleAndTextWidget->setLayout(titleAndTextLayout); + + m_titleLabel = new QLabel(titleAndTextWidget); + m_titleLabel->setStyleSheet("font-weight: bold;"); + titleAndTextLayout->addWidget(m_titleLabel); + + m_textLabel = new QLabel(titleAndTextWidget); + titleAndTextLayout->addWidget(m_textLabel); + + mainLayout->addWidget(titleAndTextWidget); + + // Call the setters so that the hidden state is updated + setTitle(_title); + setText(_text); + setPixmap(_pixmap); +} void TextFloat::setTitle( const QString & _title ) { - m_title = _title; - updateSize(); + m_titleLabel->setText(_title); + m_titleLabel->setHidden(_title.isEmpty()); } - - - void TextFloat::setText( const QString & _text ) { - m_text = _text; - updateSize(); + m_textLabel->setText(_text); + m_textLabel->setHidden(_text.isEmpty()); } - - - void TextFloat::setPixmap( const QPixmap & _pixmap ) { - m_pixmap = _pixmap; - updateSize(); + m_pixmapLabel->setPixmap(_pixmap); + m_pixmapLabel->setHidden(_pixmap.isNull()); } - - - void TextFloat::setVisibilityTimeOut( int _msecs ) { QTimer::singleShot( _msecs, this, SLOT(hide())); show(); } - - - -TextFloat * TextFloat::displayMessage( const QString & _msg, int _timeout, - QWidget * _parent, int _add_y_margin ) +TextFloat * TextFloat::displayMessage( const QString & _title, + const QString & _msg, + const QPixmap & _pixmap, + int _timeout, QWidget * _parent ) { - QWidget * mw = getGUI()->mainWindow(); - auto tf = new TextFloat; + 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 ) { tf->moveGlobal( _parent, QPoint( _parent->width() + 2, 0 ) ); } else { - tf->moveGlobal( mw, QPoint( 32, mw->height() - tf->height() - 8 - _add_y_margin ) ); + // 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->setText( _msg ); - tf->show(); + if( _timeout > 0 ) { tf->setAttribute( Qt::WA_DeleteOnClose, true ); QTimer::singleShot( _timeout, tf, SLOT(close())); } - return( tf ); + + return tf; } - - - -TextFloat * TextFloat::displayMessage( const QString & _title, - const QString & _msg, - const QPixmap & _pixmap, - int _timeout, QWidget * _parent ) -{ - TextFloat * tf = displayMessage( _msg, _timeout, _parent, 16 ); - tf->setTitle( _title ); - tf->setPixmap( _pixmap ); - return( tf ); -} - - - - -void TextFloat::paintEvent( QPaintEvent * _pe ) -{ - QStyleOption opt; - opt.init( this ); - QPainter p( this ); - p.fillRect( 0, 0, width(), height(), QColor( 0, 0, 0, 0 ) ); - -/* p.setPen( p.pen().brush().color() ); - p.setBrush( p.background() );*/ - - p.setFont( pointSize<8>( p.font() ) ); - - style()->drawPrimitive( QStyle::PE_Widget, &opt, &p, this ); - -/* p.drawRect( 0, 0, rect().right(), rect().bottom() );*/ - - if( m_title.isEmpty() ) - { - p.drawText( opt.rect, Qt::AlignCenter, m_text ); - } - else - { - int text_x = opt.rect.left() + 2; - int text_y = opt.rect.top() + 12; - if( m_pixmap.isNull() == false ) - { - p.drawPixmap( opt.rect.topLeft() + QPoint( 5, 5 ), m_pixmap ); - text_x += m_pixmap.width() + 8; - } - p.drawText( text_x, text_y + 16, m_text ); - QFont f = p.font(); - f.setBold( true ); - p.setFont( f ); - p.drawText( text_x, text_y, m_title ); - } -} - - - - void TextFloat::mousePressEvent( QMouseEvent * ) { close(); } - - - -void TextFloat::updateSize() -{ - QFontMetrics metrics( pointSize<8>( font() ) ); - QRect textBound = metrics.boundingRect( m_text ); - if( !m_title.isEmpty() ) - { - QFont f = pointSize<8>( font() ); - f.setBold( true ); - int title_w = QFontMetrics( f ).boundingRect( m_title ).width(); - if( title_w > textBound.width() ) - { - textBound.setWidth( title_w ); - } - textBound.setHeight( textBound.height() * 2 + 8 ); - } - if( m_pixmap.isNull() == false ) - { - textBound.setWidth( textBound.width() + m_pixmap.width() + 10 ); - } - resize( textBound.width() + 5, textBound.height()+2 ); - //move( QPoint( parentWidget()->width() + 5, 5 ) ); - update(); -} - - - } // namespace lmms::gui From 17295a4f864dd474eea107e5b0ccc335e29f1da5 Mon Sep 17 00:00:00 2001 From: Michael Gregorius Date: Tue, 10 Jan 2023 19:20:26 +0100 Subject: [PATCH 2/3] Introduce SimpleTextFloat Introduce the new class SimpleTextFloat which simply shows a text and that works like a pseudo tool tip with a narrow margin. It was extracted from TextFloat to adhere to the single responsibility principle. The new class is used by: * Fader: display the current volume when moving the fader * Knob: display the current value when the knob is moved * PianoRoll: display the current value when setting the note volume and panning Add stylings for the new widget in style.css. --- data/themes/classic/style.css | 2 +- data/themes/default/style.css | 2 +- include/Fader.h | 5 ++- include/Knob.h | 4 +- include/PianoRoll.h | 4 +- include/SimpleTextFloat.h | 61 ++++++++++++++++++++++++++++ src/gui/CMakeLists.txt | 1 + src/gui/editors/PianoRoll.cpp | 5 ++- src/gui/widgets/Fader.cpp | 8 ++-- src/gui/widgets/Knob.cpp | 6 +-- src/gui/widgets/SimpleTextFloat.cpp | 62 +++++++++++++++++++++++++++++ 11 files changed, 143 insertions(+), 17 deletions(-) create mode 100644 include/SimpleTextFloat.h create mode 100644 src/gui/widgets/SimpleTextFloat.cpp diff --git a/data/themes/classic/style.css b/data/themes/classic/style.css index 58ec5dc09..2880fe661 100644 --- a/data/themes/classic/style.css +++ b/data/themes/classic/style.css @@ -70,7 +70,7 @@ QToolTip { color: #4afd85; } -lmms--gui--TextFloat { +lmms--gui--TextFloat, lmms--gui--SimpleTextFloat { border-radius: 4px; background: qlineargradient(spread:reflect, x1:0.5, y1:0.5, x2:0.5, y2:0, stop:0 rgba(0, 0, 0, 255), stop:1 rgba(50, 50, 50, 220)); opacity: 175; diff --git a/data/themes/default/style.css b/data/themes/default/style.css index f4c651c9e..a9646cfe4 100644 --- a/data/themes/default/style.css +++ b/data/themes/default/style.css @@ -100,7 +100,7 @@ QToolTip { color: #d1d8e4; } -lmms--gui--TextFloat { +lmms--gui--TextFloat, lmms--gui--SimpleTextFloat { background: #040506; color: #d1d8e4; } diff --git a/include/Fader.h b/include/Fader.h index 54acfc57d..d0ee302cb 100644 --- a/include/Fader.h +++ b/include/Fader.h @@ -55,10 +55,11 @@ #include "AutomatableModelView.h" + namespace lmms::gui { -class TextFloat; +class SimpleTextFloat; class LMMS_EXPORT Fader : public QWidget, public FloatModelView @@ -164,7 +165,7 @@ private: int m_moveStartPoint; float m_startValue; - static TextFloat * s_textFloat; + static SimpleTextFloat * s_textFloat; QColor m_peakGreen; QColor m_peakRed; diff --git a/include/Knob.h b/include/Knob.h index 16ac7ed01..8976dc9ca 100644 --- a/include/Knob.h +++ b/include/Knob.h @@ -41,7 +41,7 @@ namespace lmms::gui { -class TextFloat; +class SimpleTextFloat; enum knobTypes { @@ -175,7 +175,7 @@ private: } - static TextFloat * s_textFloat; + static SimpleTextFloat * s_textFloat; QString m_label; bool m_isHtmlLabel; diff --git a/include/PianoRoll.h b/include/PianoRoll.h index c1973f407..5469e70f9 100644 --- a/include/PianoRoll.h +++ b/include/PianoRoll.h @@ -60,7 +60,7 @@ namespace gui class ComboBox; class PositionLine; -class TextFloat; +class SimpleTextFloat; class TimeLineWidget; @@ -345,7 +345,7 @@ private: static std::array prKeyOrder; - static TextFloat * s_textFloat; + static SimpleTextFloat * s_textFloat; ComboBoxModel m_zoomingModel; ComboBoxModel m_zoomingYModel; diff --git a/include/SimpleTextFloat.h b/include/SimpleTextFloat.h new file mode 100644 index 000000000..1d029c189 --- /dev/null +++ b/include/SimpleTextFloat.h @@ -0,0 +1,61 @@ +/* + * TextFloat.h - class textFloat, a floating text-label + * + * Copyright (c) 2023 LMMS team + * + * 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 + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program (see COPYING); if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + */ + + +#ifndef SIMPLE_TEXT_FLOAT_H +#define SIMPLE_TEXT_FLOAT_H + +#include + +#include "lmms_export.h" + +class QLabel; + +namespace lmms::gui +{ + +class LMMS_EXPORT SimpleTextFloat : public QWidget +{ + Q_OBJECT +public: + SimpleTextFloat(); + ~SimpleTextFloat() override = default; + + void setText( const QString & _text ); + + void setVisibilityTimeOut( int _msecs ); + + void moveGlobal( QWidget * _w, const QPoint & _offset ) + { + move( _w->mapToGlobal( QPoint( 0, 0 ) ) + _offset ); + } + +private: + QLabel * m_textLabel; +}; + + +} // namespace lmms::gui + +#endif diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 1000ba51d..9f940c035 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -112,6 +112,7 @@ SET(LMMS_SRCS gui/widgets/NStateButton.cpp gui/widgets/Oscilloscope.cpp gui/widgets/PixmapButton.cpp + gui/widgets/SimpleTextFloat.cpp gui/widgets/TabBar.cpp gui/widgets/TabWidget.cpp gui/widgets/TempoSyncKnob.cpp diff --git a/src/gui/editors/PianoRoll.cpp b/src/gui/editors/PianoRoll.cpp index 5f294d6e8..0cf72e5cb 100644 --- a/src/gui/editors/PianoRoll.cpp +++ b/src/gui/editors/PianoRoll.cpp @@ -66,6 +66,7 @@ #include "PatternStore.h" #include "PianoView.h" #include "PositionLine.h" +#include "SimpleTextFloat.h" #include "SongEditor.h" #include "StepRecorderWidget.h" #include "TextFloat.h" @@ -127,7 +128,7 @@ QPixmap * PianoRoll::s_toolMove = nullptr; QPixmap * PianoRoll::s_toolOpen = nullptr; QPixmap* PianoRoll::s_toolKnife = nullptr; -TextFloat * PianoRoll::s_textFloat = nullptr; +SimpleTextFloat * PianoRoll::s_textFloat = nullptr; static std::array s_noteStrings {"C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"}; @@ -290,7 +291,7 @@ PianoRoll::PianoRoll() : // init text-float if( s_textFloat == nullptr ) { - s_textFloat = new TextFloat; + s_textFloat = new SimpleTextFloat; } setAttribute( Qt::WA_OpaquePaintEvent, true ); diff --git a/src/gui/widgets/Fader.cpp b/src/gui/widgets/Fader.cpp index e2d6d8218..4cc5802a4 100644 --- a/src/gui/widgets/Fader.cpp +++ b/src/gui/widgets/Fader.cpp @@ -54,13 +54,13 @@ #include "embed.h" #include "CaptionMenu.h" #include "ConfigManager.h" -#include "TextFloat.h" +#include "SimpleTextFloat.h" namespace lmms::gui { -TextFloat * Fader::s_textFloat = nullptr; +SimpleTextFloat * Fader::s_textFloat = nullptr; QPixmap * Fader::s_back = nullptr; QPixmap * Fader::s_leds = nullptr; QPixmap * Fader::s_knob = nullptr; @@ -83,7 +83,7 @@ Fader::Fader( FloatModel * _model, const QString & _name, QWidget * _parent ) : { if( s_textFloat == nullptr ) { - s_textFloat = new TextFloat; + s_textFloat = new SimpleTextFloat; } if( ! s_back ) { @@ -125,7 +125,7 @@ Fader::Fader( FloatModel * model, const QString & name, QWidget * parent, QPixma { if( s_textFloat == nullptr ) { - s_textFloat = new TextFloat; + s_textFloat = new SimpleTextFloat; } m_back = back; diff --git a/src/gui/widgets/Knob.cpp b/src/gui/widgets/Knob.cpp index 049a86be1..8640bb81d 100644 --- a/src/gui/widgets/Knob.cpp +++ b/src/gui/widgets/Knob.cpp @@ -45,14 +45,14 @@ #include "LocaleHelper.h" #include "MainWindow.h" #include "ProjectJournal.h" +#include "SimpleTextFloat.h" #include "StringPairDrag.h" -#include "TextFloat.h" namespace lmms::gui { -TextFloat * Knob::s_textFloat = nullptr; +SimpleTextFloat * Knob::s_textFloat = nullptr; @@ -86,7 +86,7 @@ void Knob::initUi( const QString & _name ) { if( s_textFloat == nullptr ) { - s_textFloat = new TextFloat; + s_textFloat = new SimpleTextFloat; } setWindowTitle( _name ); diff --git a/src/gui/widgets/SimpleTextFloat.cpp b/src/gui/widgets/SimpleTextFloat.cpp new file mode 100644 index 000000000..e6625063b --- /dev/null +++ b/src/gui/widgets/SimpleTextFloat.cpp @@ -0,0 +1,62 @@ +/* + * TextFloat.cpp - class textFloat, a floating text-label + * + * Copyright (c) LMMS team + * + * 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 + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program (see COPYING); if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + */ + +#include "SimpleTextFloat.h" + +#include +#include +#include +#include + +#include "GuiApplication.h" +#include "MainWindow.h" + +namespace lmms::gui +{ + + +SimpleTextFloat::SimpleTextFloat() : + QWidget(getGUI()->mainWindow(), Qt::ToolTip) +{ + QHBoxLayout * layout = new QHBoxLayout(this); + layout->setMargin(3); + setLayout(layout); + + m_textLabel = new QLabel(this); + layout->addWidget(m_textLabel); +} + +void SimpleTextFloat::setText( const QString & _text ) +{ + m_textLabel->setText(_text); +} + + +void SimpleTextFloat::setVisibilityTimeOut( int _msecs ) +{ + QTimer::singleShot( _msecs, this, SLOT(hide())); + show(); +} + +} // namespace lmms::gui From b90156bedd9ccd999a9954aa935877c58f706cbf Mon Sep 17 00:00:00 2001 From: Michael Gregorius Date: Sun, 9 Apr 2023 16:42:18 +0200 Subject: [PATCH 3/3] Coding conventions Adjust the code style of the adjusted and created classes according to the coding conventions. --- include/SimpleTextFloat.h | 14 ++++---- include/TextFloat.h | 27 +++++++------- src/gui/widgets/Fader.cpp | 2 +- src/gui/widgets/SimpleTextFloat.cpp | 8 ++--- src/gui/widgets/TextFloat.cpp | 56 ++++++++++++++--------------- 5 files changed, 53 insertions(+), 54 deletions(-) diff --git a/include/SimpleTextFloat.h b/include/SimpleTextFloat.h index 1d029c189..f720d0b3e 100644 --- a/include/SimpleTextFloat.h +++ b/include/SimpleTextFloat.h @@ -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: diff --git a/include/TextFloat.h b/include/TextFloat.h index fccd10ae8..4b97fa3fc 100644 --- a/include/TextFloat.h +++ b/include/TextFloat.h @@ -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; diff --git a/src/gui/widgets/Fader.cpp b/src/gui/widgets/Fader.cpp index 4cc5802a4..dcf648c37 100644 --- a/src/gui/widgets/Fader.cpp +++ b/src/gui/widgets/Fader.cpp @@ -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)); } diff --git a/src/gui/widgets/SimpleTextFloat.cpp b/src/gui/widgets/SimpleTextFloat.cpp index e6625063b..d1f490b5e 100644 --- a/src/gui/widgets/SimpleTextFloat.cpp +++ b/src/gui/widgets/SimpleTextFloat.cpp @@ -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(); } diff --git a/src/gui/widgets/TextFloat.cpp b/src/gui/widgets/TextFloat.cpp index 6588902f9..4eb14bd50 100644 --- a/src/gui/widgets/TextFloat.cpp +++ b/src/gui/widgets/TextFloat.cpp @@ -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(); }