mirror of
https://github.com/LMMS/lmms.git
synced 2026-03-12 11:07:13 -04:00
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.
81 lines
1.9 KiB
C++
81 lines
1.9 KiB
C++
/*
|
|
* TextFloat.h - class textFloat, a floating text-label
|
|
*
|
|
* Copyright (c) 2005-2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
|
*
|
|
* 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 TEXT_FLOAT_H
|
|
#define TEXT_FLOAT_H
|
|
|
|
#include <QWidget>
|
|
|
|
#include "lmms_export.h"
|
|
|
|
class QLabel;
|
|
|
|
namespace lmms::gui
|
|
{
|
|
|
|
class LMMS_EXPORT TextFloat : public QWidget
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
TextFloat();
|
|
~TextFloat() override = default;
|
|
|
|
void setTitle( const QString & _title );
|
|
void setText( const QString & _text );
|
|
void setPixmap( const QPixmap & _pixmap );
|
|
|
|
void setVisibilityTimeOut( int _msecs );
|
|
|
|
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 )
|
|
{
|
|
move( _w->mapToGlobal( QPoint( 0, 0 ) )+_offset );
|
|
}
|
|
|
|
|
|
protected:
|
|
void mousePressEvent( QMouseEvent * _me ) override;
|
|
|
|
|
|
private:
|
|
TextFloat(const QString & _title, const QString & _text, const QPixmap & _pixmap);
|
|
|
|
QLabel * m_pixmapLabel;
|
|
QLabel * m_titleLabel;
|
|
QLabel * m_textLabel;
|
|
|
|
};
|
|
|
|
|
|
} // namespace lmms::gui
|
|
|
|
#endif
|