2018-02-27 18:06:05 +01:00
|
|
|
/*
|
|
|
|
* Strawberry Music Player
|
|
|
|
* This file was part of Clementine.
|
|
|
|
* Copyright 2010, David Sansome <me@davidsansome.com>
|
2021-03-20 21:14:47 +01:00
|
|
|
* Copyright 2018-2021, Jonas Kvinge <jonas@jkvinge.net>
|
2018-02-27 18:06:05 +01:00
|
|
|
*
|
|
|
|
* Strawberry 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.
|
|
|
|
*
|
|
|
|
* Strawberry 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 Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
2018-08-09 18:39:44 +02:00
|
|
|
*
|
2018-02-27 18:06:05 +01:00
|
|
|
*/
|
|
|
|
|
2020-08-09 01:37:00 +02:00
|
|
|
#ifndef OSDBASE_H
|
|
|
|
#define OSDBASE_H
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
2018-05-01 00:41:33 +02:00
|
|
|
#include <QtGlobal>
|
|
|
|
#include <QObject>
|
|
|
|
#include <QString>
|
2020-02-09 02:29:35 +01:00
|
|
|
#include <QUrl>
|
2018-02-27 18:06:05 +01:00
|
|
|
#include <QDateTime>
|
|
|
|
#include <QImage>
|
|
|
|
|
|
|
|
#include "core/song.h"
|
|
|
|
#include "playlist/playlistsequence.h"
|
|
|
|
|
|
|
|
class Application;
|
|
|
|
class OSDPretty;
|
|
|
|
class SystemTrayIcon;
|
|
|
|
|
2020-08-09 01:37:00 +02:00
|
|
|
class OSDBase : public QObject {
|
2018-02-27 18:06:05 +01:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2021-05-20 21:40:08 +02:00
|
|
|
explicit OSDBase(std::shared_ptr<SystemTrayIcon> tray_icon, Application *app, QObject *parent = nullptr);
|
2020-08-09 01:37:00 +02:00
|
|
|
~OSDBase() override;
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
static const char *kSettingsGroup;
|
|
|
|
|
|
|
|
enum Behaviour {
|
|
|
|
Disabled = 0,
|
|
|
|
Native,
|
|
|
|
TrayPopup,
|
|
|
|
Pretty,
|
|
|
|
};
|
|
|
|
|
2020-08-09 01:37:00 +02:00
|
|
|
int timeout_msec() const { return timeout_msec_; }
|
2018-02-27 18:06:05 +01:00
|
|
|
void ReloadPrettyOSDSettings();
|
|
|
|
void SetPrettyOSDToggleMode(bool toggle);
|
|
|
|
|
2020-08-09 01:37:00 +02:00
|
|
|
virtual bool SupportsNativeNotifications();
|
|
|
|
virtual bool SupportsTrayPopups();
|
|
|
|
|
2020-10-01 19:39:49 +02:00
|
|
|
QString app_name() { return app_name_; }
|
|
|
|
|
2018-02-27 18:06:05 +01:00
|
|
|
public slots:
|
|
|
|
void ReloadSettings();
|
|
|
|
|
2020-09-29 19:27:35 +02:00
|
|
|
void SongChanged(const Song &song);
|
2018-02-27 18:06:05 +01:00
|
|
|
void Paused();
|
2019-06-29 19:54:27 +02:00
|
|
|
void Resumed();
|
2018-02-27 18:06:05 +01:00
|
|
|
void Stopped();
|
|
|
|
void StopAfterToggle(bool stop);
|
|
|
|
void PlaylistFinished();
|
|
|
|
void VolumeChanged(int value);
|
|
|
|
void RepeatModeChanged(PlaylistSequence::RepeatMode mode);
|
|
|
|
void ShuffleModeChanged(PlaylistSequence::ShuffleMode mode);
|
|
|
|
|
|
|
|
void ReshowCurrentSong();
|
|
|
|
|
2021-03-21 04:47:11 +01:00
|
|
|
void ShowPreview(const OSDBase::Behaviour type, const QString &line1, const QString &line2, const Song &song);
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
private:
|
2020-12-11 23:59:38 +01:00
|
|
|
enum MessageType {
|
|
|
|
Type_Summary,
|
|
|
|
Type_Message,
|
|
|
|
};
|
2020-09-29 19:27:35 +02:00
|
|
|
void ShowPlaying(const Song &song, const QUrl &cover_url, const QImage &image, const bool preview = false);
|
2021-06-20 19:04:08 +02:00
|
|
|
void ShowMessage(const QString &summary, const QString &message = QString(), const QString &icon = "strawberry", const QImage &image = QImage());
|
2020-12-11 23:59:38 +01:00
|
|
|
QString ReplaceMessage(const MessageType type, const QString &message, const Song &song);
|
2020-08-09 01:37:00 +02:00
|
|
|
virtual void ShowMessageNative(const QString &summary, const QString &message, const QString &icon = QString(), const QImage &image = QImage());
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
private slots:
|
2019-07-07 21:14:24 +02:00
|
|
|
void AlbumCoverLoaded(const Song &song, const QUrl &cover_url, const QImage &image);
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
Application *app_;
|
2021-05-20 21:40:08 +02:00
|
|
|
std::shared_ptr<SystemTrayIcon> tray_icon_;
|
2020-08-09 01:37:00 +02:00
|
|
|
OSDPretty *pretty_popup_;
|
|
|
|
|
2019-02-10 21:25:36 +01:00
|
|
|
QString app_name_;
|
2018-02-27 18:06:05 +01:00
|
|
|
int timeout_msec_;
|
|
|
|
Behaviour behaviour_;
|
|
|
|
bool show_on_volume_change_;
|
|
|
|
bool show_art_;
|
|
|
|
bool show_on_play_mode_change_;
|
|
|
|
bool show_on_pause_;
|
2019-06-29 19:54:27 +02:00
|
|
|
bool show_on_resume_;
|
2018-02-27 18:06:05 +01:00
|
|
|
bool use_custom_text_;
|
|
|
|
QString custom_text1_;
|
|
|
|
QString custom_text2_;
|
|
|
|
|
|
|
|
bool force_show_next_;
|
|
|
|
bool ignore_next_stopped_;
|
2020-09-29 19:27:35 +02:00
|
|
|
bool playing_;
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2020-09-29 19:27:35 +02:00
|
|
|
Song song_playing_;
|
2018-02-27 18:06:05 +01:00
|
|
|
Song last_song_;
|
2019-07-07 21:14:24 +02:00
|
|
|
QUrl last_image_uri_;
|
2018-02-27 18:06:05 +01:00
|
|
|
QImage last_image_;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2020-08-09 01:37:00 +02:00
|
|
|
#endif // OSDBASE_H
|