2010-03-24 00:11:46 +01:00
|
|
|
/* This file is part of Clementine.
|
|
|
|
|
|
|
|
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>
|
|
|
|
|
2010-04-04 19:50:11 +02:00
|
|
|
#include "engines/engine_fwd.h"
|
2010-05-10 23:50:31 +02:00
|
|
|
#include "core/albumcoverloader.h"
|
|
|
|
#include "core/backgroundthread.h"
|
|
|
|
#include "core/song.h"
|
2010-01-08 15:52:05 +01:00
|
|
|
|
2010-05-10 15:15:52 +02:00
|
|
|
class NetworkAccessManager;
|
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-01-08 16:16:59 +01:00
|
|
|
#ifdef Q_WS_X11
|
2010-03-29 22:08:32 +02:00
|
|
|
# include <QDBusArgument>
|
|
|
|
# include <boost/scoped_ptr.hpp>
|
2010-03-25 18:52:28 +01:00
|
|
|
|
2010-03-29 22:08:32 +02: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:
|
2010-06-22 13:52:55 +02:00
|
|
|
OSD(SystemTrayIcon* tray_icon, NetworkAccessManager* network, QObject* parent = 0);
|
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,
|
2010-03-25 20:30:10 +01:00
|
|
|
Pretty,
|
2010-02-03 18:21:25 +01:00
|
|
|
};
|
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();
|
|
|
|
|
2010-01-08 15:52:05 +01:00
|
|
|
public slots:
|
2010-02-03 18:21:25 +01:00
|
|
|
void ReloadSettings();
|
|
|
|
|
2010-04-13 22:45:40 +02:00
|
|
|
void ForceShowNextNotification() { force_show_next_ = true; }
|
2010-01-08 15:52:05 +01:00
|
|
|
void SongChanged(const Song& song);
|
|
|
|
void Paused();
|
|
|
|
void Stopped();
|
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);
|
2010-01-08 15:52:05 +01:00
|
|
|
|
2010-02-03 18:21:25 +01:00
|
|
|
private:
|
2010-05-10 15:15:52 +02:00
|
|
|
struct WaitingForAlbumArt {
|
|
|
|
QString summary;
|
|
|
|
QString message;
|
|
|
|
QString icon;
|
|
|
|
};
|
|
|
|
|
2010-02-03 18:21:25 +01:00
|
|
|
void ShowMessage(const QString& summary,
|
2010-02-24 22:44:14 +01:00
|
|
|
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();
|
2010-02-24 22:44:14 +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());
|
2010-02-03 18:21:25 +01:00
|
|
|
|
2010-04-13 22:45:40 +02:00
|
|
|
private slots:
|
|
|
|
void CallFinished(QDBusPendingCallWatcher* watcher);
|
2010-05-10 15:15:52 +02:00
|
|
|
void CoverLoaderInitialised();
|
|
|
|
void AlbumArtLoaded(quint64 id, const QImage& image);
|
|
|
|
void AlbumArtLoaded(const WaitingForAlbumArt info, 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_;
|
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_;
|
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_;
|
|
|
|
|
2010-05-10 15:15:52 +02:00
|
|
|
NetworkAccessManager* network_;
|
|
|
|
BackgroundThread<AlbumCoverLoader>* cover_loader_;
|
|
|
|
QMap<quint64, WaitingForAlbumArt> waiting_for_album_art_;
|
|
|
|
|
2010-02-24 22:44:14 +01:00
|
|
|
#ifdef Q_OS_DARWIN
|
|
|
|
class GrowlNotificationWrapper;
|
|
|
|
GrowlNotificationWrapper* wrapper_;
|
|
|
|
#endif // Q_OS_DARWIN
|
2010-03-25 18:52:28 +01:00
|
|
|
|
|
|
|
#ifdef Q_WS_X11
|
2010-06-25 21:04:10 +02:00
|
|
|
boost::scoped_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
|
|
|
};
|
|
|
|
|
|
|
|
#endif // OSD_H
|