diff --git a/src/config/osd_config.cpp b/src/config/osd_config.cpp index cf264091..2bd62043 100644 --- a/src/config/osd_config.cpp +++ b/src/config/osd_config.cpp @@ -1,197 +1,198 @@ /* 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. */ /* Copyright (C) 2005 Ivor Hewitt Copyright (C) 2005 Ismail Donmez Copyright (C) 2006 Dario Abatianni Copyright (C) 2006 John Tapsell Copyright (C) 2006 Peter Simonsson */ #include "osd_config.h" #include "preferences.h" #include "osd.h" #include "application.h" #include #include #include #include #include +#include #include OSD_Config::OSD_Config( QWidget* parent, const char* name, Qt::WindowFlags fl ) : QWidget(parent, fl) { setObjectName(QString::fromLatin1(name)); setupUi(this); bool enableScreenChooser = false; QRect screenRect; - for(int i = 0; i < QApplication::desktop()->numScreens(); ++i) { + for(int i = 0; i < QApplication::screens().count(); ++i) { kcfg_OSDScreen->addItem(QString::number(i)); - screenRect = QApplication::desktop()->screenGeometry(i); + screenRect = QApplication::screens()[i]->geometry(); //Check if we're using xinerama or not if(screenRect.left() != 0 || screenRect.top() != 0) { enableScreenChooser = true; } } kcfg_OSDScreen->setEnabled(enableScreenChooser); m_pOSDPreview = new OSDPreviewWidget(QStringLiteral("Konversation")); connect(m_pOSDPreview, &OSDPreviewWidget::positionChanged, this, &OSD_Config::slotPositionChanged); connect(kcfg_OSDFont, &KFontRequester::fontSelected, this, &OSD_Config::slotUpdateFont); slotOSDEnabledChanged(kcfg_UseOSD->isChecked()); slotCustomColorsChanged(kcfg_OSDUseCustomColors->isChecked()); slotScreenChanged(Preferences::self()->oSDScreen()); slotDrawShadowChanged( kcfg_OSDDrawShadow->isChecked()); slotUpdateFont(Preferences::self()->oSDFont()); kcfg_OSDOffsetX->hide(); kcfg_OSDOffsetY->hide(); kcfg_OSDAlignment->hide(); //Connect config page entries to control the OSDPreview connect(kcfg_UseOSD, &QCheckBox::toggled, this, &OSD_Config::slotOSDEnabledChanged); connect(kcfg_OSDUseCustomColors, &QGroupBox::toggled, this, &OSD_Config::slotCustomColorsChanged); connect(kcfg_OSDTextColor, &KColorButton::changed, this, &OSD_Config::slotTextColorChanged); connect(kcfg_OSDBackgroundColor, &KColorButton::changed, this, &OSD_Config::slotBackgroundColorChanged); connect(kcfg_OSDScreen, static_cast(&KComboBox::activated), this, &OSD_Config::slotScreenChanged); connect(kcfg_OSDDrawShadow, &QCheckBox::toggled, this, &OSD_Config::slotDrawShadowChanged); } OSD_Config::~OSD_Config() { delete m_pOSDPreview; } void OSD_Config::loadSettings() { } void OSD_Config::restorePageToDefaults() { } void OSD_Config::saveSettings() { //Update the current OSD. Application *konvApp=Application::instance(); konvApp->osd->setEnabled(kcfg_UseOSD->isChecked()); if (kcfg_UseOSD->isChecked()) { konvApp->osd->setFont(Preferences::self()->oSDFont()); if(kcfg_OSDUseCustomColors->isChecked()) { konvApp->osd->setTextColor(kcfg_OSDTextColor->color()); QPalette p = konvApp->osd->palette(); p.setColor(konvApp->osd->backgroundRole(), kcfg_OSDBackgroundColor->color()); konvApp->osd->setPalette(p); } else { konvApp->osd->unsetColors(); } konvApp->osd->setDuration(kcfg_OSDDuration->value()); konvApp->osd->setScreen(kcfg_OSDScreen->currentIndex()); konvApp->osd->setShadow(kcfg_OSDDrawShadow->isChecked()); //x is ignored anyway, but leave incase we use in future konvApp->osd->setOffset(kcfg_OSDOffsetX->value(), kcfg_OSDOffsetY->value()); konvApp->osd->setAlignment((OSDWidget::Alignment)kcfg_OSDAlignment->value()); } } void OSD_Config::showEvent(QShowEvent*) { //Update the preview m_pOSDPreview->setAlignment((OSDWidget::Alignment)( kcfg_OSDAlignment->value() ) ); m_pOSDPreview->setOffset(kcfg_OSDOffsetX->value(),kcfg_OSDOffsetY->value()); if (kcfg_UseOSD->isChecked()) m_pOSDPreview->show(); } void OSD_Config::hideEvent(QHideEvent*) { m_pOSDPreview->setVisible(false); } bool OSD_Config::hasChanged() { // follow the interface, no Non-KConfigXT settings here, so none have changed return false; } void OSD_Config::slotOSDEnabledChanged(bool on) { if ( isVisible() ) on ? m_pOSDPreview->show() : m_pOSDPreview->setVisible(false); } void OSD_Config::slotPositionChanged() { kcfg_OSDScreen->setCurrentIndex(m_pOSDPreview->screen()); kcfg_OSDAlignment->setValue( m_pOSDPreview->alignment() ); kcfg_OSDOffsetX->setValue( m_pOSDPreview->x()); kcfg_OSDOffsetY->setValue( m_pOSDPreview->y()); } void OSD_Config::slotCustomColorsChanged(bool on) { if(on) { m_pOSDPreview->setTextColor(kcfg_OSDTextColor->color()); QPalette p = m_pOSDPreview->palette(); p.setColor(m_pOSDPreview->backgroundRole(), kcfg_OSDBackgroundColor->color()); m_pOSDPreview->setPalette(p); } else m_pOSDPreview->unsetColors(); } void OSD_Config::slotTextColorChanged(const QColor& color) { if(kcfg_OSDUseCustomColors->isChecked()) m_pOSDPreview->setTextColor(color); } void OSD_Config::slotBackgroundColorChanged(const QColor& color) { if(kcfg_OSDUseCustomColors->isChecked()) { QPalette p = m_pOSDPreview->palette(); p.setColor(m_pOSDPreview->backgroundRole(), color); m_pOSDPreview->setPalette(p); } } void OSD_Config::slotScreenChanged(int index) { m_pOSDPreview->setScreen(index); } void OSD_Config::slotDrawShadowChanged(bool on) { m_pOSDPreview->setShadow(on); } void OSD_Config::slotUpdateFont(const QFont& font) { m_pOSDPreview->setFont(font); } diff --git a/src/viewer/osd.cpp b/src/viewer/osd.cpp index 8b0e093d..a6945d4c 100644 --- a/src/viewer/osd.cpp +++ b/src/viewer/osd.cpp @@ -1,508 +1,509 @@ /* 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. */ /* Copyright (C) 2004 Christian Muehlhaeuser Copyright (C) 2004-2006 Seb Ruiz Copyright (C) 2004-2005 Max Howell Copyright (C) 2005 Gábor Lehel Copyright (C) 2008 Mark Kretschmann */ #include "osd.h" #include "common.h" #include #include #include #include #include #include #include #include +#include #include #include namespace ShadowEngine { QImage makeShadow( const QPixmap &textPixmap, const QColor &bgColor ); } OSDWidget::OSDWidget(const QString &appName, QWidget *parent, const char *name ) : QWidget( parent ) , m_appName( appName ) , m_duration( 5000 ) , m_timer( new QTimer( this ) ) , m_timerMin( new QTimer( this ) ) , m_alignment( Middle ) , m_screen( 0 ) , m_y( MARGIN ) , m_drawShadow( true ) { Qt::WindowFlags flags; flags = Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint; // The best of both worlds. On Windows, setting the widget as a popup avoids a task manager entry. On linux, a popup steals focus. // Therefore we go need to do it platform specific :( #ifdef Q_OS_WIN flags |= Qt::Tool; #else flags |= Qt::Window | Qt::X11BypassWindowManagerHint; #endif setWindowFlags( flags ); setObjectName( name ); setFocusPolicy( Qt::NoFocus ); unsetColors(); m_timer->setSingleShot( true ); connect(m_timer, &QTimer::timeout, this, &OSDWidget::hide); connect(m_timerMin, &QTimer::timeout, this, &OSDWidget::minReached); } OSDWidget::~OSDWidget() { delete m_timer; delete m_timerMin; } void OSDWidget::show( const QString &text, bool preemptive ) { if ( preemptive || !m_timerMin->isActive() ) { m_currentText = Konversation::removeIrcMarkup(text); show(); } else textBuffer.append( Konversation::removeIrcMarkup(text) ); //queue } void OSDWidget::show() //virtual { if ( !isEnabled() || m_currentText.isEmpty() ) return; const int M = fontMetrics().horizontalAdvance( 'x' ); const QRect newGeometry = determineMetrics( M ); if( newGeometry.width() > 0 && newGeometry.height() > 0 ) { m_m = M; m_size = newGeometry.size(); setGeometry( newGeometry ); QWidget::show(); if ( m_duration ) //duration 0 -> stay forever { m_timer->start( m_duration ); //calls hide() m_timerMin->start( 1500 ); //calls minReached() } } else qWarning() << "Attempted to make an invalid sized OSD"; update(); } void OSDWidget::minReached() //SLOT { if ( !textBuffer.isEmpty() ) { show( textBuffer.first(), true ); textBuffer.removeFirst(); if( m_duration ) //timerMin is still running m_timer->start( m_duration ); } else m_timerMin->stop(); } void OSDWidget::setDuration( int ms ) { m_duration = ms; if( !m_duration ) m_timer->stop(); } QRect OSDWidget::determineMetrics( const int M ) { // determine a sensible maximum size, don't cover the whole desktop or cross the screen const QSize margin( ( M + MARGIN ) * 2, ( M + MARGIN ) * 2 ); //margins - const QSize max = QApplication::desktop()->screen( m_screen )->size() - margin; + const QSize max = QApplication::screens()[m_screen]->size() - margin; // If we don't do that, the boundingRect() might not be suitable for drawText() (Qt issue N67674) m_currentText.replace( QRegExp( " +\n" ), QStringLiteral("\n") ); // remove consecutive line breaks m_currentText.replace( QRegExp( "\n+" ), QStringLiteral("\n") ); QFont titleFont = font(); titleFont.setBold(true); QFontMetrics titleFm( titleFont ); // The osd cannot be larger than the screen QRect titleRect = titleFm.boundingRect( 0, 0, max.width() - M, titleFm.height(), Qt::AlignLeft, m_appName ); QRect textRect = fontMetrics().boundingRect( 0, 0, max.width(), max.height(), Qt::AlignCenter | Qt::TextWordWrap, m_currentText ); textRect.setHeight( textRect.height() + M + M ); if ( textRect.width() < titleRect.width() ) textRect.setWidth( titleRect.width() ); textRect.adjust( 0, 0, M*2, titleRect.height() + M ); // expand in all directions by M textRect.adjust( -M, -M, M, M ); const QSize newSize = textRect.size(); - const QRect screen = QApplication::desktop()->screenGeometry( m_screen ); + const QRect screen = QApplication::screens()[m_screen]->geometry(); QPoint newPos( MARGIN, m_y ); switch( m_alignment ) { case Left: break; case Right: newPos.rx() = screen.width() - MARGIN - newSize.width(); break; case Center: newPos.ry() = ( screen.height() - newSize.height() ) / 2; //FALL THROUGH case Middle: newPos.rx() = ( screen.width() - newSize.width() ) / 2; break; } //ensure we don't dip below the screen if ( newPos.y() + newSize.height() > screen.height() - MARGIN ) newPos.ry() = screen.height() - MARGIN - newSize.height(); // correct for screen position newPos += screen.topLeft(); return QRect( newPos, textRect.size() ); } void OSDWidget::paintEvent( QPaintEvent *e ) { int M = m_m; QSize size = m_size; QFont titleFont = font(); titleFont.setBold(true); QPoint point; QRect rect( point, size ); rect.adjust( 0, 0, -1, -1 ); QColor shadowColor; { int h, s, v; palette().color( QPalette::Normal, QPalette::WindowText ).getHsv( &h, &s, &v ); shadowColor = v > 128 ? Qt::black : Qt::white; } int align = Qt::AlignCenter | Qt::TextWordWrap; QPainter p( this ); QBitmap mask( e->rect().size() ); QPainter maskPainter( &mask ); p.setRenderHints( QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform | QPainter::HighQualityAntialiasing ); p.setClipRect( e->rect() ); // Masking for transparency mask.fill( Qt::color0 ); maskPainter.setBrush( Qt::color1 ); maskPainter.drawRect( e->rect() ); setMask( mask ); p.drawRect( e->rect() ); p.setPen( Qt::white ); // Revert this when the background can be colorized again. rect.adjust( M, M, -M, -M ); int graphicsHeight = 0; rect.setBottom( rect.bottom() - graphicsHeight ); // Draw "shadow" text effect (black outline) if( m_drawShadow ) { QPixmap pixmap( rect.size() + QSize( 10, 10 ) ); pixmap.fill( Qt::black ); QPainter p2( &pixmap ); p2.setFont( font() ); p2.setPen( Qt::white ); p2.setBrush( Qt::white ); p2.drawText( QRect( QPoint( 5, 5 ), rect.size() ), align, m_currentText ); p2.end(); p.drawImage( rect.topLeft() - QPoint( 5, 5 ), ShadowEngine::makeShadow( pixmap, shadowColor ) ); pixmap.fill( Qt::black ); pixmap.scaled( QSize(e->rect().width()-1, e->rect().height()-1) + QSize( 10, 10 ) ); p2.begin( &pixmap ); p2.setFont( titleFont ); p2.setPen( Qt::white ); p2.setBrush( Qt::white ); p2.drawText( QRect( QPoint( 5, 5 ), QSize(e->rect().width()-1, e->rect().height()-1) ), Qt::AlignLeft, m_appName ); p2.end(); p.drawImage( QPoint(M*2, M/2) - QPoint( 5, 5 ), ShadowEngine::makeShadow( pixmap, shadowColor ) ); } p.setPen( palette().color( QPalette::Active, QPalette::WindowText ) ); //p.setPen( Qt::white ); // This too. p.setFont( font() ); p.drawText( rect, align, m_currentText ); p.setFont( titleFont ); p.drawText( M * 2, (M/2), e->rect().width()-1, e->rect().height()-1, Qt::AlignLeft, m_appName ); } void OSDWidget::resizeEvent(QResizeEvent *e) { //setMask(m_background->mask()); QWidget::resizeEvent( e ); } bool OSDWidget::event( QEvent *e ) { switch( e->type() ) { case QEvent::ApplicationPaletteChange: //if( !AmarokConfig::osdUseCustomColors() ) // unsetColors(); //use new palette's colours return true; default: return QWidget::event( e ); } } void OSDWidget::mousePressEvent( QMouseEvent* ) { hide(); } void OSDWidget::unsetColors() { QPalette p = QApplication::palette(); QPalette newPal = palette(); newPal.setColor( QPalette::Active, QPalette::WindowText, p.color( QPalette::Active, QPalette::WindowText ) ); newPal.setColor( QPalette::Active, QPalette::Window , p.color( QPalette::Active, QPalette::Window ) ); setPalette( newPal ); } void OSDWidget::setOffset( int /*x*/, int y ) { //m_offset = QPoint( x, y ); m_y = y; } void OSDWidget::setScreen( int screen ) { - const int n = QApplication::desktop()->numScreens(); + const int n = QApplication::screens().count(); m_screen = ( screen >= n ) ? n - 1 : screen; } ///////////////////////////////////////////////////////////////////////////////////////// // Class OSDPreviewWidget ///////////////////////////////////////////////////////////////////////////////////////// OSDPreviewWidget::OSDPreviewWidget( const QString &appName, QWidget *parent, const char *name ) : OSDWidget( appName, parent, name ) , m_dragging( false ) { setObjectName( QStringLiteral("osdpreview") ); m_currentText = i18n( "OSD Preview - drag to reposition" ); m_duration = 0; //m_alignment = static_cast( AmarokConfig::osdAlignment() ); //m_y = AmarokConfig::osdYOffset(); QFont f = font(); f.setPointSize( 16 ); setFont( f ); //setTranslucent( AmarokConfig::osdUseTranslucency() ); } void OSDPreviewWidget::mousePressEvent( QMouseEvent *event ) { m_dragOffset = event->pos(); if( event->button() == Qt::LeftButton && !m_dragging ) { grabMouse( Qt::SizeAllCursor ); m_dragging = true; } } void OSDPreviewWidget::mouseReleaseEvent( QMouseEvent * /*event*/ ) { if( m_dragging ) { m_dragging = false; releaseMouse(); // compute current Position && offset - QDesktopWidget *desktop = QApplication::desktop(); - int currentScreen = desktop->screenNumber( pos() ); + QScreen *screen = QApplication::screenAt( pos() ); + int currentScreen = QApplication::screens().indexOf(screen); if( currentScreen != -1 ) { // set new data m_screen = currentScreen; m_y = QWidget::y(); emit positionChanged(); } } } void OSDPreviewWidget::mouseMoveEvent( QMouseEvent *e ) { if( m_dragging && this == mouseGrabber() ) { // Here we implement a "snap-to-grid" like positioning system for the preview widget - const QRect screen = QApplication::desktop()->screenGeometry( m_screen ); - const uint hcenter = screen.width() / 2; - const uint eGlobalPosX = e->globalPos().x() - screen.left(); - const uint snapZone = screen.width() / 24; + const QRect screen = QApplication::screens()[m_screen]->geometry(); + const int hcenter = screen.width() / 2; + const int eGlobalPosX = e->globalPos().x() - screen.left(); + const int snapZone = screen.width() / 24; QPoint destination = e->globalPos() - m_dragOffset - screen.topLeft(); int maxY = screen.height() - height() - MARGIN; if( destination.y() < MARGIN ) destination.ry() = MARGIN; if( destination.y() > maxY ) destination.ry() = maxY; if( eGlobalPosX < ( hcenter - snapZone ) ) { m_alignment = Left; destination.rx() = MARGIN; } else if( eGlobalPosX > ( hcenter + snapZone ) ) { m_alignment = Right; destination.rx() = screen.width() - MARGIN - width(); } else { - const uint eGlobalPosY = e->globalPos().y() - screen.top(); - const uint vcenter = screen.height() / 2; + const int eGlobalPosY = e->globalPos().y() - screen.top(); + const int vcenter = screen.height() / 2; destination.rx() = hcenter - width() / 2; if( eGlobalPosY >= ( vcenter - snapZone ) && eGlobalPosY <= ( vcenter + snapZone ) ) { m_alignment = Center; destination.ry() = vcenter - height() / 2; } else m_alignment = Middle; } destination += screen.topLeft(); move( destination ); } } /* Code copied from kshadowengine.cpp * * Copyright (C) 2003 Laur Ivan * * Many thanks to: * - Bernardo Hung for the enhanced shadow * algorithm (currently used) * - Tim Jansen for the API updates and fixes. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License version 2 as published by the Free Software Foundation. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ namespace ShadowEngine { // Not sure, doesn't work above 10 static const int MULTIPLICATION_FACTOR = 3; // Multiplication factor for pixels directly above, under, or next to the text static const double AXIS_FACTOR = 2.0; // Multiplication factor for pixels diagonal to the text static const double DIAGONAL_FACTOR = 0.1; // Self explanatory static const int MAX_OPACITY = 200; double decay( QImage&, int, int ); QImage makeShadow( const QPixmap& textPixmap, const QColor &bgColor ) { const int w = textPixmap.width(); const int h = textPixmap.height(); const int bgr = bgColor.red(); const int bgg = bgColor.green(); const int bgb = bgColor.blue(); int alphaShadow; // This is the source pixmap QImage img = textPixmap.toImage(); QImage result( w, h, QImage::Format_ARGB32 ); result.fill( 0 ); // fill with black static const int M = 5; for( int i = M; i < w - M; i++) { for( int j = M; j < h - M; j++ ) { alphaShadow = (int) decay( img, i, j ); result.setPixel( i,j, qRgba( bgr, bgg , bgb, qMin( MAX_OPACITY, alphaShadow ) ) ); } } return result; } double decay( QImage& source, int i, int j ) { //if ((i < 1) || (j < 1) || (i > source.width() - 2) || (j > source.height() - 2)) // return 0; double alphaShadow; alphaShadow =(qGray(source.pixel(i-1,j-1)) * DIAGONAL_FACTOR + qGray(source.pixel(i-1,j )) * AXIS_FACTOR + qGray(source.pixel(i-1,j+1)) * DIAGONAL_FACTOR + qGray(source.pixel(i ,j-1)) * AXIS_FACTOR + 0 + qGray(source.pixel(i ,j+1)) * AXIS_FACTOR + qGray(source.pixel(i+1,j-1)) * DIAGONAL_FACTOR + qGray(source.pixel(i+1,j )) * AXIS_FACTOR + qGray(source.pixel(i+1,j+1)) * DIAGONAL_FACTOR) / MULTIPLICATION_FACTOR; return alphaShadow; } } diff --git a/src/viewer/osd.h b/src/viewer/osd.h index 0beb09a7..a44aaf5f 100644 --- a/src/viewer/osd.h +++ b/src/viewer/osd.h @@ -1,136 +1,136 @@ /* 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. */ /* Copyright (C) 2003 Christian Muehlhaeuser Copyright (C) 2008 Mark Kretschmann */ #ifndef OSD_H #define OSD_H #include #include #include //baseclass #define OSD_WINDOW_OPACITY 0.8 class OSDWidget : public QWidget { Q_OBJECT public: enum Alignment { Left, Middle, Center, Right }; explicit OSDWidget(const QString &appName, QWidget *parent = nullptr, const char *name = "osd" ); virtual ~OSDWidget(); /** resets the colours to defaults */ void unsetColors(); void setShadow( bool shadow ) { m_drawShadow = shadow; } void setOffset( int x, int y ); public Q_SLOTS: /** calls setText() then show() */ void show( const QString &text, bool preemptive=false ); /** reimplemented, shows the OSD */ virtual void show(); /** * For the sake of simplicity, when these settings are * changed they do not take effect until the next time * the OSD is shown! * * To force an update call show(); */ void setDuration( int ms ); void setTextColor( const QColor &color ) { QPalette palette = this->palette(); palette.setColor( QPalette::Active, QPalette::WindowText, color ); setPalette(palette); } void setOffset( int y ) { m_y = y; } void setAlignment( Alignment alignment ) { m_alignment = alignment; } void setScreen( int screen ); void setText( const QString &text ) { m_currentText = text; } void setTranslucent( bool enabled ) { setWindowOpacity( enabled ? OSD_WINDOW_OPACITY : 1.0 ); } protected Q_SLOTS: void minReached(); protected: /** determine new size and position */ QRect determineMetrics( const int M ); // Reimplemented from QWidget void paintEvent( QPaintEvent* ) Q_DECL_OVERRIDE; void mousePressEvent( QMouseEvent* ) Q_DECL_OVERRIDE; void resizeEvent( QResizeEvent *e ) Q_DECL_OVERRIDE; bool event( QEvent* ) Q_DECL_OVERRIDE; /** distance from screen edge */ static const int MARGIN = 15; QString m_appName; - uint m_m; + int m_m; QSize m_size; int m_duration; QTimer *m_timer; QTimer *m_timerMin; QStringList textBuffer; Alignment m_alignment; int m_screen; - uint m_y; + int m_y; bool m_drawShadow; QString m_currentText; }; class OSDPreviewWidget : public OSDWidget { Q_OBJECT public: explicit OSDPreviewWidget( const QString &appName, QWidget *parent = nullptr, const char *name = "osdpreview" ); int screen() const { return m_screen; } int alignment() const { return m_alignment; } int y() const { return m_y; } public Q_SLOTS: void setTextColor( const QColor &color ) { OSDWidget::setTextColor( color ); doUpdate(); } void setFont( const QFont &font ) { OSDWidget::setFont( font ); doUpdate(); } void setScreen( int screen ) { OSDWidget::setScreen( screen ); doUpdate(); } void setUseCustomColors( const bool use, const QColor &fg ) { if( use ) OSDWidget::setTextColor( fg ); else unsetColors(); doUpdate(); } void setTranslucent( bool enabled ) { setWindowOpacity( enabled ? OSD_WINDOW_OPACITY : 1.0 ); doUpdate(); } private: inline void doUpdate() { if( !isHidden() ) show(); } Q_SIGNALS: void positionChanged(); protected: void mousePressEvent( QMouseEvent * ) Q_DECL_OVERRIDE; void mouseReleaseEvent( QMouseEvent * ) Q_DECL_OVERRIDE; void mouseMoveEvent( QMouseEvent * ) Q_DECL_OVERRIDE; private: bool m_dragging; QPoint m_dragOffset; }; #endif /* OSD_H*/