2 This program is free software; you can redistribute it and/or modify
3 it under the terms of the GNU General Public License as published by
4 the Free Software Foundation; either version 2 of the License, or
5 (at your option) any later version.
9 osd.h - Provides an interface to a plain QWidget, which is independent of KDE (bypassed to X11)
10 begin: Fre Sep 26 2003
11 copyright: (C) 2003 by Christian Muehlhaeuser
18 #include "metabundle.h"
22 #include <QWidget> //baseclass
25 class OSDWidget
: public QWidget
30 enum Alignment
{ Left
, Middle
, Center
, Right
};
32 explicit OSDWidget( QWidget
*parent
, const char *name
= "osd" );
34 /** resets the colours to defaults */
38 /** calls setText() then show(), after setting image if needed */
39 void show( const QString
&text
, QImage newImage
= QImage::QImage() );
40 void ratingChanged( const short rating
);
41 void ratingChanged( const QString
& path
, int rating
);
42 void volChanged( unsigned char volume
);
44 /** reimplemented, shows the OSD */
48 * For the sake of simplicity, when these settings are
49 * changed they do not take effect until the next time
52 * To force an update call show();
54 void setDuration( int ms
) { m_duration
= ms
; }
55 void setTextColor( const QColor
&color
) {
57 palette
.setColor(foregroundRole(), color
);
60 void setOffset( int y
) { m_y
= y
; }
61 void setAlignment( Alignment alignment
) { m_alignment
= alignment
; }
62 void setImage( const QImage
&image
) { m_cover
= image
; }
63 void setScreen( int screen
);
64 void setText( const QString
&text
) { m_text
= text
; }
65 void setDrawShadow( const bool b
) { m_drawShadow
= b
; }
66 void setRating( const short rating
) { if ( isEnabled() ) m_rating
= rating
; }
67 void setMoodbar( void ) { m_moodbarBundle
= MetaBundle(); }
68 void setMoodbar( const MetaBundle
&bundle
)
69 { m_moodbarBundle
= bundle
; m_moodbarBundle
.moodbar().load(); }
72 /** determine new size and position */
73 QRect
determineMetrics( const uint marginMetric
);
76 virtual void paintEvent( QPaintEvent
* );
77 virtual void mousePressEvent( QMouseEvent
* );
78 virtual bool event( QEvent
* );
80 bool useMoodbar( void );
82 /** distance from screen edge */
83 static const int MARGIN
= 15;
89 Alignment m_alignment
;
94 unsigned char m_newvolume
;
98 // need a whole MetaBundle to draw the moodbar on the fly
99 MetaBundle m_moodbarBundle
;
100 QPixmap m_scaledCover
;
105 class OSDPreviewWidget
: public OSDWidget
110 OSDPreviewWidget( QWidget
*parent
);
112 int screen() { return m_screen
; }
113 int alignment() { return m_alignment
; }
114 int y() { return m_y
; }
117 void setTextColor( const QColor
&color
) { OSDWidget::setTextColor( color
); doUpdate(); }
118 void setDrawShadow( bool b
) { OSDWidget::setDrawShadow( b
); doUpdate(); }
119 void setFont( const QFont
&font
) { OSDWidget::setFont( font
); doUpdate(); }
120 void setScreen( int screen
) { OSDWidget::setScreen( screen
); doUpdate(); }
121 void setUseCustomColors( const bool use
, const QColor
&fg
, const QColor
&/*bg*/ )
124 OSDWidget::setTextColor( fg
);
131 inline void doUpdate() { if( !isHidden() ) show(); }
134 void positionChanged();
137 void mousePressEvent( QMouseEvent
* );
138 void mouseReleaseEvent( QMouseEvent
* );
139 void mouseMoveEvent( QMouseEvent
* );
150 class OSD
: public OSDWidget
155 static OSD
*instance()
157 static OSD
*s_instance
= new OSD
;
161 void applySettings();
162 void show( const MetaBundle
&bundle
);
166 * When user pushs global shortcut or uses DCOP OSD is toggle
167 * even if it is disabled()
169 void forceToggleOSD();
175 void slotCoverChanged( const QString
&artist
, const QString
&album
);
176 void slotImageChanged( const QString
&remoteURL
);
180 #endif /*AMAROK_OSD_H*/