2010-03-24 00:11:46 +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-24 00:11:46 +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/>.
|
|
|
|
*/
|
|
|
|
|
2010-01-08 15:52:05 +01:00
|
|
|
#ifndef OSD_H
|
|
|
|
#define OSD_H
|
|
|
|
|
2010-06-25 21:04:10 +02:00
|
|
|
#include <QDateTime>
|
2010-02-24 22:44:14 +01:00
|
|
|
#include <QImage>
|
2010-01-08 15:52:05 +01:00
|
|
|
#include <QObject>
|
2020-09-18 16:15:19 +02:00
|
|
|
#include <memory>
|
2010-01-08 15:52:05 +01:00
|
|
|
|
2010-12-26 18:24:44 +01:00
|
|
|
#include "config.h"
|
2010-05-10 23:50:31 +02:00
|
|
|
#include "core/song.h"
|
2020-09-18 16:15:19 +02:00
|
|
|
#include "engines/engine_fwd.h"
|
2011-03-17 09:21:05 +01:00
|
|
|
#include "playlist/playlistsequence.h"
|
2010-01-08 15:52:05 +01:00
|
|
|
|
2012-02-12 14:41:50 +01:00
|
|
|
class Application;
|
2010-06-25 21:04:10 +02:00
|
|
|
class OrgFreedesktopNotificationsInterface;
|
2010-06-22 13:52:55 +02:00
|
|
|
class OSDPretty;
|
|
|
|
class SystemTrayIcon;
|
2010-03-25 20:30:10 +01:00
|
|
|
|
2010-03-26 00:03:28 +01:00
|
|
|
class QDBusPendingCallWatcher;
|
|
|
|
|
2010-12-26 14:38:35 +01:00
|
|
|
#ifdef HAVE_DBUS
|
2014-02-07 16:34:20 +01:00
|
|
|
#include <QDBusArgument>
|
2018-11-17 15:08:37 +01:00
|
|
|
#include <QDBusPendingCall>
|
2010-03-25 18:52:28 +01:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
QDBusArgument& operator<<(QDBusArgument& arg, const QImage& image);
|
|
|
|
const QDBusArgument& operator>>(const QDBusArgument& arg, QImage& image);
|
2010-01-08 16:16:59 +01:00
|
|
|
#endif
|
|
|
|
|
2010-01-08 15:52:05 +01:00
|
|
|
class OSD : public QObject {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2014-02-10 16:03:54 +01:00
|
|
|
OSD(SystemTrayIcon* tray_icon, Application* app, QObject* parent = nullptr);
|
2010-03-25 20:30:10 +01:00
|
|
|
~OSD();
|
2010-01-08 15:52:05 +01:00
|
|
|
|
2010-02-03 18:21:25 +01:00
|
|
|
static const char* kSettingsGroup;
|
|
|
|
|
2014-09-16 12:54:35 +02:00
|
|
|
enum Behaviour {
|
|
|
|
Disabled = 0,
|
|
|
|
Native,
|
|
|
|
TrayPopup,
|
|
|
|
Pretty,
|
|
|
|
};
|
2010-01-08 15:52:05 +01:00
|
|
|
|
2010-02-26 23:37:48 +01:00
|
|
|
// Implemented in the OS-specific files
|
|
|
|
static bool SupportsNativeNotifications();
|
|
|
|
static bool SupportsTrayPopups();
|
|
|
|
|
2011-05-28 10:50:29 +02:00
|
|
|
void ReloadPrettyOSDSettings();
|
|
|
|
|
2011-06-05 10:21:17 +02:00
|
|
|
void SetPrettyOSDToggleMode(bool toggle);
|
|
|
|
|
2010-01-08 15:52:05 +01:00
|
|
|
public slots:
|
2010-02-03 18:21:25 +01:00
|
|
|
void ReloadSettings();
|
|
|
|
|
2010-01-08 15:52:05 +01:00
|
|
|
void Paused();
|
|
|
|
void Stopped();
|
2014-01-06 14:25:04 +01:00
|
|
|
void StopAfterToggle(bool stop);
|
2010-04-19 15:01:57 +02:00
|
|
|
void PlaylistFinished();
|
2010-01-08 17:40:34 +01:00
|
|
|
void VolumeChanged(int value);
|
2010-06-12 22:43:07 +02:00
|
|
|
void MagnatuneDownloadFinished(const QStringList& albums);
|
2011-03-17 09:21:05 +01:00
|
|
|
void RepeatModeChanged(PlaylistSequence::RepeatMode mode);
|
|
|
|
void ShuffleModeChanged(PlaylistSequence::ShuffleMode mode);
|
2010-01-08 15:52:05 +01:00
|
|
|
|
2012-02-13 21:44:04 +01:00
|
|
|
void ReshowCurrentSong();
|
|
|
|
|
2010-09-01 17:37:09 +02:00
|
|
|
void WiiremoteActived(int id);
|
|
|
|
void WiiremoteDeactived(int id);
|
2010-09-01 16:46:15 +02:00
|
|
|
void WiiremoteConnected(int id);
|
|
|
|
void WiiremoteDisconnected(int id);
|
|
|
|
void WiiremoteLowBattery(int id, int live);
|
|
|
|
void WiiremoteCriticalBattery(int id, int live);
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
void ShowPreview(const Behaviour type, const QString& line1,
|
|
|
|
const QString& line2, const Song& song);
|
2011-05-22 23:15:11 +02:00
|
|
|
|
2010-02-03 18:21:25 +01:00
|
|
|
private:
|
2014-02-07 16:34:20 +01:00
|
|
|
void ShowMessage(const QString& summary, const QString& message = QString(),
|
2010-02-25 01:18:32 +01:00
|
|
|
const QString& icon = QString(),
|
|
|
|
const QImage& image = QImage());
|
2010-02-03 18:21:25 +01:00
|
|
|
|
|
|
|
// These are implemented in the OS-specific files
|
|
|
|
void Init();
|
2014-02-07 16:34:20 +01:00
|
|
|
void ShowMessageNative(const QString& summary, const QString& message,
|
2010-03-30 02:08:16 +02:00
|
|
|
const QString& icon = QString(),
|
|
|
|
const QImage& image = QImage());
|
2011-05-22 23:15:11 +02:00
|
|
|
QString ReplaceVariable(const QString& variable, const Song& song);
|
2010-02-03 18:21:25 +01:00
|
|
|
|
2010-04-13 22:45:40 +02:00
|
|
|
private slots:
|
2018-11-17 15:08:37 +01:00
|
|
|
#if defined(HAVE_DBUS)
|
2010-04-13 22:45:40 +02:00
|
|
|
void CallFinished(QDBusPendingCallWatcher* watcher);
|
2018-11-17 15:08:37 +01:00
|
|
|
#endif
|
2014-02-07 16:34:20 +01:00
|
|
|
void AlbumArtLoaded(const Song& song, const QString& uri,
|
|
|
|
const QImage& image);
|
2010-04-13 22:45:40 +02:00
|
|
|
|
2010-01-08 15:52:05 +01:00
|
|
|
private:
|
2010-06-22 13:52:55 +02:00
|
|
|
SystemTrayIcon* tray_icon_;
|
2012-02-12 14:41:50 +01:00
|
|
|
Application* app_;
|
2010-03-30 02:08:16 +02:00
|
|
|
int timeout_msec_;
|
2010-02-03 18:21:25 +01:00
|
|
|
Behaviour behaviour_;
|
2010-02-27 01:48:27 +01:00
|
|
|
bool show_on_volume_change_;
|
2010-02-28 02:08:18 +01:00
|
|
|
bool show_art_;
|
2011-03-17 09:21:05 +01:00
|
|
|
bool show_on_play_mode_change_;
|
2014-09-16 12:54:35 +02:00
|
|
|
bool show_on_pause_;
|
2011-05-22 23:15:11 +02:00
|
|
|
bool use_custom_text_;
|
|
|
|
QString custom_text1_;
|
|
|
|
QString custom_text2_;
|
|
|
|
bool preview_mode_;
|
2010-01-08 16:16:59 +01:00
|
|
|
|
2010-04-13 22:45:40 +02:00
|
|
|
bool force_show_next_;
|
2010-04-19 15:01:57 +02:00
|
|
|
bool ignore_next_stopped_;
|
2010-04-13 22:45:40 +02:00
|
|
|
|
2010-03-25 20:30:10 +01:00
|
|
|
OSDPretty* pretty_popup_;
|
|
|
|
|
2012-02-13 21:44:04 +01:00
|
|
|
Song last_song_;
|
|
|
|
QString last_image_uri_;
|
|
|
|
QImage last_image_;
|
2010-05-10 15:15:52 +02:00
|
|
|
|
2010-12-26 14:38:35 +01:00
|
|
|
#ifdef HAVE_DBUS
|
2014-02-06 14:48:00 +01:00
|
|
|
std::unique_ptr<OrgFreedesktopNotificationsInterface> interface_;
|
2010-03-29 22:08:32 +02:00
|
|
|
uint notification_id_;
|
2010-03-30 02:08:16 +02:00
|
|
|
QDateTime last_notification_time_;
|
2010-03-26 00:03:28 +01:00
|
|
|
#endif
|
2010-01-08 15:52:05 +01:00
|
|
|
};
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
#endif // OSD_H
|