2010-03-25 20:30:10 +01:00
|
|
|
/* This file is part of Clementine.
|
2010-11-20 14:27:10 +01:00
|
|
|
Copyright 2010, David Sansome <me@davidsansome.com>
|
2010-03-25 20:30:10 +01:00
|
|
|
|
|
|
|
Clementine 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 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Clementine 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 Clementine. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef OSDPRETTY_H
|
|
|
|
#define OSDPRETTY_H
|
|
|
|
|
|
|
|
#include <QWidget>
|
|
|
|
|
2010-05-10 23:50:31 +02:00
|
|
|
class Ui_OSDPretty;
|
2010-03-25 20:30:10 +01:00
|
|
|
|
2010-03-25 22:24:19 +01:00
|
|
|
class QTimeLine;
|
|
|
|
|
2010-03-25 20:30:10 +01:00
|
|
|
class OSDPretty : public QWidget {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2014-02-07 16:34:20 +01:00
|
|
|
enum Mode { Mode_Popup, Mode_Draggable, };
|
2010-04-20 21:43:56 +02:00
|
|
|
|
2014-02-10 16:03:54 +01:00
|
|
|
OSDPretty(Mode mode, QWidget* parent = nullptr);
|
2010-05-10 23:50:31 +02:00
|
|
|
~OSDPretty();
|
2010-03-25 20:30:10 +01:00
|
|
|
|
|
|
|
static const char* kSettingsGroup;
|
|
|
|
|
|
|
|
static const int kDropShadowSize;
|
|
|
|
static const int kBorderRadius;
|
|
|
|
static const int kMaxIconSize;
|
|
|
|
|
2010-12-19 15:06:51 +01:00
|
|
|
static const int kSnapProximity;
|
|
|
|
|
2010-03-25 20:30:10 +01:00
|
|
|
static const QRgb kPresetBlue;
|
|
|
|
static const QRgb kPresetOrange;
|
|
|
|
|
2010-03-25 20:57:52 +01:00
|
|
|
static bool IsTransparencyAvailable();
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
void SetMessage(const QString& summary, const QString& message,
|
2010-03-25 20:30:10 +01:00
|
|
|
const QImage& image);
|
2014-02-07 16:34:20 +01:00
|
|
|
void ShowMessage(const QString& summary, const QString& message,
|
2011-08-27 00:32:28 +02:00
|
|
|
const QImage& image);
|
2010-03-25 20:30:10 +01:00
|
|
|
|
2010-03-25 22:24:19 +01:00
|
|
|
// Controls the fader. This is enabled by default on Windows.
|
|
|
|
void set_fading_enabled(bool enabled) { fading_enabled_ = enabled; }
|
|
|
|
|
2010-03-25 20:30:10 +01:00
|
|
|
// Popup duration in seconds. Only used in Mode_Popup.
|
|
|
|
void set_popup_duration(int msec);
|
|
|
|
|
|
|
|
// These will get overwritten when ReloadSettings() is called
|
|
|
|
void set_foreground_color(QRgb color);
|
|
|
|
void set_background_color(QRgb color);
|
|
|
|
void set_background_opacity(qreal opacity);
|
2011-05-28 10:50:29 +02:00
|
|
|
void set_font(QFont font);
|
2010-03-25 20:30:10 +01:00
|
|
|
|
|
|
|
QRgb foreground_color() const { return foreground_color_.rgb(); }
|
|
|
|
QRgb background_color() const { return background_color_.rgb(); }
|
|
|
|
qreal background_opacity() const { return background_opacity_; }
|
2010-04-11 19:19:25 +02:00
|
|
|
int popup_display() const { return popup_display_; }
|
|
|
|
QPoint popup_pos() const { return popup_pos_; }
|
2011-05-28 10:50:29 +02:00
|
|
|
QFont font() const { return font_; }
|
2011-05-29 14:44:38 +02:00
|
|
|
bool disable_duration() const { return disable_duration_; }
|
2010-03-25 20:30:10 +01:00
|
|
|
|
|
|
|
// When the user has been moving the popup, use these to get its current
|
2010-04-11 19:19:25 +02:00
|
|
|
// position and screen. Note that these return invalid values if the popup
|
|
|
|
// is hidden.
|
2010-03-25 20:30:10 +01:00
|
|
|
int current_display() const;
|
|
|
|
QPoint current_pos() const;
|
|
|
|
|
2010-03-25 22:24:19 +01:00
|
|
|
// QWidget
|
|
|
|
void setVisible(bool visible);
|
|
|
|
|
2011-06-05 10:21:17 +02:00
|
|
|
bool toggle_mode() const { return toggle_mode_; }
|
|
|
|
void set_toggle_mode(bool toggle_mode) { toggle_mode_ = toggle_mode; }
|
|
|
|
|
2010-03-25 20:30:10 +01:00
|
|
|
public slots:
|
|
|
|
void ReloadSettings();
|
|
|
|
|
|
|
|
protected:
|
2014-02-07 16:34:20 +01:00
|
|
|
void paintEvent(QPaintEvent*);
|
|
|
|
void enterEvent(QEvent*);
|
|
|
|
void leaveEvent(QEvent*);
|
|
|
|
void mousePressEvent(QMouseEvent*);
|
|
|
|
void showEvent(QShowEvent*);
|
|
|
|
void mouseMoveEvent(QMouseEvent*);
|
|
|
|
void mouseReleaseEvent(QMouseEvent*);
|
2010-03-25 20:30:10 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
void Reposition();
|
|
|
|
void Load();
|
|
|
|
|
2010-03-25 20:57:52 +01:00
|
|
|
QRect BoxBorder() const;
|
|
|
|
|
2010-03-25 22:24:19 +01:00
|
|
|
private slots:
|
|
|
|
void FaderValueChanged(qreal value);
|
|
|
|
void FaderFinished();
|
|
|
|
|
2010-03-25 20:30:10 +01:00
|
|
|
private:
|
2010-05-10 23:50:31 +02:00
|
|
|
Ui_OSDPretty* ui_;
|
2010-03-25 20:30:10 +01:00
|
|
|
|
|
|
|
Mode mode_;
|
|
|
|
|
|
|
|
// Settings loaded from QSettings
|
|
|
|
QColor foreground_color_;
|
|
|
|
QColor background_color_;
|
|
|
|
float background_opacity_;
|
2014-02-07 16:34:20 +01:00
|
|
|
int popup_display_; // -1 for default
|
2010-03-25 20:30:10 +01:00
|
|
|
QPoint popup_pos_;
|
2011-05-28 10:50:29 +02:00
|
|
|
QFont font_;
|
2011-05-29 14:44:38 +02:00
|
|
|
// The OSD is kept always on top until you click (no timer)
|
|
|
|
bool disable_duration_;
|
2010-03-25 20:30:10 +01:00
|
|
|
|
|
|
|
// Cached pixmaps
|
|
|
|
QPixmap shadow_edge_[4];
|
|
|
|
QPixmap shadow_corner_[4];
|
2010-06-02 21:19:30 +02:00
|
|
|
QPixmap background_;
|
2010-03-25 20:30:10 +01:00
|
|
|
|
|
|
|
// For dragging the OSD
|
|
|
|
QPoint original_window_pos_;
|
|
|
|
QPoint drag_start_pos_;
|
|
|
|
|
|
|
|
// For timeout of notification
|
|
|
|
QTimer* timeout_;
|
2010-03-25 22:24:19 +01:00
|
|
|
|
|
|
|
// For fading
|
|
|
|
bool fading_enabled_;
|
|
|
|
QTimeLine* fader_;
|
2011-06-05 10:21:17 +02:00
|
|
|
|
|
|
|
// Toggling requested, we have to show or hide the OSD
|
|
|
|
bool toggle_mode_;
|
2010-03-25 20:30:10 +01:00
|
|
|
};
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
#endif // OSDPRETTY_H
|