Replace QDesktopWidget in OSDPretty

This commit is contained in:
Jonas Kvinge
2019-07-09 19:49:15 +02:00
parent aa8679dff5
commit 656130a739
3 changed files with 124 additions and 64 deletions

View File

@@ -2,6 +2,7 @@
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com>
* Copyright 2019, Jonas Kvinge <jonas@jkvinge.net>
*
* Strawberry is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -26,9 +27,9 @@
#include <stdbool.h>
#include <QtGlobal>
#include <QObject>
#include <QWidget>
#include <QTimer>
#include <QMap>
#include <QScreen>
#include <QString>
#include <QImage>
#include <QPixmap>
@@ -36,9 +37,10 @@
#include <QFont>
#include <QPoint>
#include <QRect>
#include <QTimeLine>
#include <QtEvents>
class QTimer;
class QTimeLine;
class QEvent;
class QMouseEvent;
class QPaintEvent;
@@ -89,14 +91,14 @@ class OSDPretty : public QWidget {
QRgb foreground_color() const { return foreground_color_.rgb(); }
QRgb background_color() const { return background_color_.rgb(); }
qreal background_opacity() const { return background_opacity_; }
int popup_display() const { return popup_display_; }
QString popup_screen() const { return popup_screen_name_; }
QPoint popup_pos() const { return popup_pos_; }
QFont font() const { return font_; }
bool disable_duration() const { return disable_duration_; }
// When the user has been moving the popup, use these to get its current position and screen.
// Note that these return invalid values if the popup is hidden.
int current_display() const;
QScreen *current_screen() const;
QPoint current_pos() const;
// QWidget
@@ -126,6 +128,8 @@ class OSDPretty : public QWidget {
private slots:
void FaderValueChanged(qreal value);
void FaderFinished();
void ScreenAdded(QScreen *screen);
void ScreenRemoved(QScreen *screen);
private:
Ui_OSDPretty *ui_;
@@ -136,8 +140,9 @@ class OSDPretty : public QWidget {
QColor foreground_color_;
QColor background_color_;
float background_opacity_;
int popup_display_; // -1 for default
QString popup_screen_name_;
QPoint popup_pos_;
QScreen *popup_screen_;
QFont font_;
// The OSD is kept always on top until you click (no timer)
bool disable_duration_;
@@ -160,6 +165,9 @@ class OSDPretty : public QWidget {
// Toggling requested, we have to show or hide the OSD
bool toggle_mode_;
QMap<QString, QScreen*> screens_;
};
#endif // OSDPRETTY_H