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/>.
|
|
|
|
*/
|
|
|
|
|
2009-12-24 20:16:07 +01:00
|
|
|
#ifndef SYSTEMTRAYICON_H
|
|
|
|
#define SYSTEMTRAYICON_H
|
|
|
|
|
2010-06-22 13:52:55 +02:00
|
|
|
#include <QObject>
|
|
|
|
#include <QPixmap>
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2010-06-22 13:52:55 +02:00
|
|
|
class QAction;
|
2010-09-08 13:53:35 +02:00
|
|
|
class Song;
|
2010-06-22 13:52:55 +02:00
|
|
|
|
|
|
|
class SystemTrayIcon : public QObject {
|
2009-12-24 20:16:07 +01:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2014-02-10 16:03:54 +01:00
|
|
|
SystemTrayIcon(QObject* parent = nullptr);
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2010-06-22 13:52:55 +02:00
|
|
|
// Called once to create the icon's context menu
|
|
|
|
virtual void SetupMenu(QAction* previous, QAction* play, QAction* stop,
|
2010-11-21 22:36:27 +01:00
|
|
|
QAction* stop_after, QAction* next, QAction* mute,
|
2014-03-27 18:55:58 +01:00
|
|
|
QAction* love, QAction* quit) = 0;
|
2010-06-22 13:52:55 +02:00
|
|
|
|
|
|
|
virtual bool IsVisible() const { return true; }
|
|
|
|
virtual void SetVisible(bool visible) {}
|
|
|
|
|
|
|
|
// Called by the OSD
|
|
|
|
virtual void ShowPopup(const QString& summary, const QString& message,
|
|
|
|
int timeout) {}
|
2010-12-06 00:41:41 +01:00
|
|
|
/**
|
2014-02-21 17:24:49 +01:00
|
|
|
* If this get's invoked with image_path equal to nullptr, the tooltip should
|
2010-12-06 00:41:41 +01:00
|
|
|
* still be shown - just without the cover art.
|
|
|
|
*/
|
|
|
|
virtual void SetNowPlaying(const Song& song, const QString& image_path) {}
|
2010-09-08 13:53:35 +02:00
|
|
|
virtual void ClearNowPlaying() {}
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2014-02-10 16:03:54 +01:00
|
|
|
static SystemTrayIcon* CreateSystemTrayIcon(QObject* parent = nullptr);
|
2010-06-22 16:16:04 +02:00
|
|
|
|
2010-01-17 22:11:03 +01:00
|
|
|
public slots:
|
|
|
|
void SetProgress(int percentage);
|
2011-03-07 22:33:01 +01:00
|
|
|
virtual void SetPaused();
|
|
|
|
virtual void SetPlaying(bool enable_play_pause = false,
|
2014-03-27 18:55:58 +01:00
|
|
|
bool enable_love = false);
|
2011-03-07 22:33:01 +01:00
|
|
|
virtual void SetStopped();
|
2011-04-22 00:19:28 +02:00
|
|
|
virtual void LastFMButtonVisibilityChanged(bool value) {}
|
|
|
|
virtual void LastFMButtonLoveStateChanged(bool value) {}
|
2011-06-22 23:50:25 +02:00
|
|
|
virtual void MuteButtonStateChanged(bool value) {}
|
2010-01-17 22:11:03 +01:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
signals:
|
2010-06-22 13:52:55 +02:00
|
|
|
void ChangeVolume(int delta);
|
2011-03-21 16:15:17 +01:00
|
|
|
void SeekForward();
|
|
|
|
void SeekBackward();
|
|
|
|
void NextTrack();
|
|
|
|
void PreviousTrack();
|
2010-06-22 13:52:55 +02:00
|
|
|
void ShowHide();
|
|
|
|
void PlayPause();
|
2010-01-17 22:11:03 +01:00
|
|
|
|
2010-06-22 13:52:55 +02:00
|
|
|
protected:
|
|
|
|
virtual void UpdateIcon() = 0;
|
|
|
|
QPixmap CreateIcon(const QPixmap& icon, const QPixmap& grey_icon);
|
2010-04-19 15:53:26 +02:00
|
|
|
|
2010-06-22 13:52:55 +02:00
|
|
|
int song_progress() const { return percentage_; }
|
|
|
|
QPixmap current_state_icon() const { return current_state_icon_; }
|
2010-04-19 15:53:26 +02:00
|
|
|
|
2010-06-22 13:52:55 +02:00
|
|
|
private:
|
2010-04-19 15:53:26 +02:00
|
|
|
int percentage_;
|
2010-06-22 13:52:55 +02:00
|
|
|
QPixmap playing_icon_;
|
|
|
|
QPixmap paused_icon_;
|
2010-04-19 15:53:26 +02:00
|
|
|
QPixmap current_state_icon_;
|
2009-12-24 20:16:07 +01:00
|
|
|
};
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
#endif // SYSTEMTRAYICON_H
|