Clementine-audio-player-Mac.../src/widgets/osd.h

144 lines
3.8 KiB
C
Raw Normal View History

/* This file is part of Clementine.
Copyright 2010, David Sansome <me@davidsansome.com>
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
#include <QDateTime>
#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"
#include "core/song.h"
2020-09-18 16:15:19 +02:00
#include "engines/engine_fwd.h"
#include "playlist/playlistsequence.h"
2010-01-08 15:52:05 +01:00
class Application;
class OrgFreedesktopNotificationsInterface;
class OSDPretty;
class SystemTrayIcon;
2010-03-25 20:30:10 +01:00
2010-03-26 00:03:28 +01:00
class QDBusPendingCallWatcher;
#ifdef HAVE_DBUS
#include <QDBusArgument>
2018-11-17 15:08:37 +01:00
#include <QDBusPendingCall>
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:
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;
enum Behaviour {
Disabled = 0,
Native,
TrayPopup,
Pretty,
};
2010-01-08 15:52:05 +01:00
// Implemented in the OS-specific files
static bool SupportsNativeNotifications();
static bool SupportsTrayPopups();
void ReloadPrettyOSDSettings();
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();
void StopAfterToggle(bool stop);
void PlaylistFinished();
2010-01-08 17:40:34 +01:00
void VolumeChanged(int value);
void MagnatuneDownloadFinished(const QStringList& albums);
void RepeatModeChanged(PlaylistSequence::RepeatMode mode);
void ShuffleModeChanged(PlaylistSequence::ShuffleMode mode);
2010-01-08 15:52:05 +01:00
void ReshowCurrentSong();
void WiiremoteActived(int id);
void WiiremoteDeactived(int id);
void WiiremoteConnected(int id);
void WiiremoteDisconnected(int id);
void WiiremoteLowBattery(int id, int live);
void WiiremoteCriticalBattery(int id, int live);
void ShowPreview(const Behaviour type, const QString& line1,
const QString& line2, const Song& song);
2010-02-03 18:21:25 +01:00
private:
void ShowMessage(const QString& summary, const QString& message = QString(),
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();
void ShowMessageNative(const QString& summary, const QString& message,
const QString& icon = QString(),
const QImage& image = QImage());
QString ReplaceVariable(const QString& variable, const Song& song);
2010-02-03 18:21:25 +01:00
private slots:
2018-11-17 15:08:37 +01:00
#if defined(HAVE_DBUS)
void CallFinished(QDBusPendingCallWatcher* watcher);
2018-11-17 15:08:37 +01:00
#endif
void AlbumArtLoaded(const Song& song, const QString& uri,
const QImage& image);
2010-01-08 15:52:05 +01:00
private:
SystemTrayIcon* tray_icon_;
Application* app_;
int timeout_msec_;
2010-02-03 18:21:25 +01:00
Behaviour behaviour_;
bool show_on_volume_change_;
bool show_art_;
bool show_on_play_mode_change_;
bool show_on_pause_;
bool use_custom_text_;
QString custom_text1_;
QString custom_text2_;
bool preview_mode_;
2010-01-08 16:16:59 +01:00
bool force_show_next_;
bool ignore_next_stopped_;
2010-03-25 20:30:10 +01:00
OSDPretty* pretty_popup_;
Song last_song_;
QString last_image_uri_;
QImage last_image_;
#ifdef HAVE_DBUS
std::unique_ptr<OrgFreedesktopNotificationsInterface> interface_;
uint notification_id_;
QDateTime last_notification_time_;
2010-03-26 00:03:28 +01:00
#endif
2010-01-08 15:52:05 +01:00
};
#endif // OSD_H