strawberry-audio-player-win.../src/core/systemtrayicon.h

91 lines
2.9 KiB
C
Raw Normal View History

2018-02-27 18:06:05 +01:00
/*
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com>
*
* 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
*/
#ifndef SYSTEMTRAYICON_H
#define SYSTEMTRAYICON_H
#include "config.h"
2020-02-08 03:40:30 +01:00
#include <QtGlobal>
2018-02-27 18:06:05 +01:00
#include <QObject>
#include <QString>
2018-02-27 18:06:05 +01:00
#include <QPixmap>
2020-02-08 03:40:30 +01:00
class QAction;
2018-02-27 18:06:05 +01:00
class Song;
class SystemTrayIcon : public QObject {
Q_OBJECT
public:
2020-04-07 16:49:15 +02:00
explicit SystemTrayIcon(QObject *parent = nullptr);
2018-02-27 18:06:05 +01:00
// Called once to create the icon's context menu
2019-06-12 00:38:52 +02:00
virtual void SetupMenu(QAction *previous, QAction *play, QAction *stop, QAction *stop_after, QAction *next, QAction *mute, QAction *love, QAction *quit) = 0;
2018-02-27 18:06:05 +01:00
virtual bool IsVisible() const { return true; }
2019-09-15 20:27:32 +02:00
virtual void SetVisible(bool visible) { Q_UNUSED(visible); }
2018-02-27 18:06:05 +01:00
// Called by the OSD
2019-09-15 20:27:32 +02:00
virtual void ShowPopup(const QString &summary, const QString &message, int timeout) { Q_UNUSED(summary); Q_UNUSED(message); Q_UNUSED(timeout); }
2019-08-22 18:45:32 +02:00
// If this gets invoked with image_path equal to nullptr, the tooltip should still be shown - just without the cover art.
2019-09-15 20:27:32 +02:00
virtual void SetNowPlaying(const Song &song, const QUrl &cover_url) { Q_UNUSED(song); Q_UNUSED(cover_url); }
2018-02-27 18:06:05 +01:00
virtual void ClearNowPlaying() {}
2020-06-15 21:55:05 +02:00
virtual bool MuteEnabled() const { return false; }
2019-09-15 20:27:32 +02:00
virtual void SetMuteEnabled(bool enabled) { Q_UNUSED(enabled); }
2019-03-09 16:48:45 +01:00
2018-02-27 18:06:05 +01:00
static SystemTrayIcon *CreateSystemTrayIcon(QObject *parent = nullptr);
public slots:
void SetProgress(int percentage);
virtual void SetPaused();
virtual void SetPlaying(bool enable_play_pause = false);
virtual void SetStopped();
2019-09-15 20:27:32 +02:00
virtual void LoveVisibilityChanged(bool value) { Q_UNUSED(value); }
virtual void LoveStateChanged(bool value) { Q_UNUSED(value); }
virtual void MuteButtonStateChanged(bool value) { Q_UNUSED(value); }
2018-02-27 18:06:05 +01:00
signals:
void ChangeVolume(int delta);
void SeekForward();
void SeekBackward();
void NextTrack();
void PreviousTrack();
void ShowHide();
void PlayPause();
protected:
virtual void UpdateIcon() = 0;
QPixmap CreateIcon(const QPixmap &icon, const QPixmap &grey_icon);
int song_progress() const { return percentage_; }
QPixmap current_state_icon() const { return current_state_icon_; }
private:
int percentage_;
QPixmap playing_icon_;
QPixmap paused_icon_;
QPixmap current_state_icon_;
};
#endif // SYSTEMTRAYICON_H