File indexing completed on 2024-05-05 04:49:29
0001 /**************************************************************************************** 0002 * Copyright (c) 2005 Max Howell <max.howell@methylblue.com> * 0003 * Copyright (c) 2011 Kevin Funk <krf@electrostorm.net> * 0004 * * 0005 * This program is free software; you can redistribute it and/or modify it under * 0006 * the terms of the GNU General Public License as published by the Free Software * 0007 * Foundation; either version 2 of the License, or (at your option) any later * 0008 * version. * 0009 * * 0010 * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 0011 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 0012 * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 0013 * * 0014 * You should have received a copy of the GNU General Public License along with * 0015 * this program. If not, see <http://www.gnu.org/licenses/>. * 0016 ****************************************************************************************/ 0017 0018 0019 #include "TimeLabel.h" 0020 0021 #include "amarokconfig.h" 0022 #include "EngineController.h" 0023 0024 #include <KLocalizedString> 0025 0026 #include <QFontDatabase> 0027 #include <QFontMetrics> 0028 #include <QLabel> 0029 #include <QLocale> 0030 #include <QMouseEvent> 0031 0032 TimeLabel::TimeLabel(QWidget* parent) 0033 : QLabel( " 0:00:00 ", parent ) 0034 { 0035 setFont( QFontDatabase::systemFont( QFontDatabase::FixedFont ) ); 0036 setSizePolicy( QSizePolicy::Maximum, QSizePolicy::Fixed ); 0037 } 0038 0039 QSize 0040 TimeLabel::sizeHint() const 0041 { 0042 return fontMetrics().boundingRect( QLocale().negativeSign() + QLocale().toString( QTime( 0, 0, 0 ) ) ).size(); 0043 } 0044 0045 void 0046 TimeLabel::setShowTime(bool showTime) { 0047 m_showTime = showTime; 0048 if( !showTime ) 0049 { 0050 QLabel::setText( "" ); 0051 } 0052 } 0053 0054 bool TimeLabel::showTime() const 0055 { 0056 return m_showTime; 0057 } 0058 0059 void 0060 TimeLabel::setText(const QString& text) 0061 { 0062 if( m_showTime ) 0063 QLabel::setText( text ); 0064 } 0065