Capitalize strawberry in osd and tooltip, change cdcase and remove some

unused code
This commit is contained in:
Jonas Kvinge
2019-02-10 21:25:36 +01:00
parent a831519b54
commit 333a0bc05a
12 changed files with 47 additions and 59 deletions

View File

@@ -6,7 +6,7 @@
<file>schema/schema-3.sql</file> <file>schema/schema-3.sql</file>
<file>schema/device-schema.sql</file> <file>schema/device-schema.sql</file>
<file>style/strawberry.css</file> <file>style/strawberry.css</file>
<file>misc/playing_tooltip.txt</file> <file>misc/playing-tooltip.html</file>
<file>misc/oauthsuccess.html</file> <file>misc/oauthsuccess.html</file>
<file>pictures/strawberry.png</file> <file>pictures/strawberry.png</file>
<file>pictures/strawberry-faded.png</file> <file>pictures/strawberry-faded.png</file>

View File

@@ -9,30 +9,22 @@
<td> <td>
<table cellspacing="1" cellpadding="1"> <table cellspacing="1" cellpadding="1">
<tr> <tr>
<td> <td>%titleKey</td>
<p align="right">%titleKey</p>
</td>
<td>%titleValue</td> <td>%titleValue</td>
</tr> </tr>
<tr> <tr>
<td> <td>%artistKey</td>
<p align="right">%artistKey</p>
</td>
<td>%artistValue</td> <td>%artistValue</td>
</tr> </tr>
<tr> <tr>
<td> <td>%albumKey</td>
<p align="right">%albumKey</p>
</td>
<td>%albumValue</td> <td>%albumValue</td>
</tr> </tr>
<tr> <tr>
<td colspan="2" height="20" /> <td colspan="2" height="20" />
</tr> </tr>
<tr> <tr>
<td> <td>%lengthKey</td>
<p align="right">%lengthKey</p>
</td>
<td>%lengthValue</td> <td>%lengthValue</td>
</tr> </tr>
</table> </table>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 61 KiB

After

Width:  |  Height:  |  Size: 62 KiB

View File

@@ -44,26 +44,27 @@ QtSystemTrayIcon::QtSystemTrayIcon(QObject *parent)
: SystemTrayIcon(parent), : SystemTrayIcon(parent),
tray_(new QSystemTrayIcon(this)), tray_(new QSystemTrayIcon(this)),
menu_(new QMenu), menu_(new QMenu),
app_name_(QCoreApplication::applicationName()),
icon_(":/icons/48x48/strawberry.png"),
normal_icon_(icon_.pixmap(48, QIcon::Normal)),
grey_icon_(icon_.pixmap(48, QIcon::Disabled)),
action_play_pause_(nullptr), action_play_pause_(nullptr),
action_stop_(nullptr), action_stop_(nullptr),
action_stop_after_this_track_(nullptr), action_stop_after_this_track_(nullptr),
action_mute_(nullptr) { action_mute_(nullptr) {
QIcon icon(":/icons/48x48/strawberry.png");
normal_icon_ = icon.pixmap(48, QIcon::Normal);
grey_icon_ = icon.pixmap(48, QIcon::Disabled);
tray_->setIcon(normal_icon_); tray_->setIcon(normal_icon_);
tray_->installEventFilter(this); tray_->installEventFilter(this);
ClearNowPlaying(); ClearNowPlaying();
QFile pattern_file(":/misc/playing_tooltip.txt"); QFile pattern_file(":/misc/playing-tooltip.html");
pattern_file.open(QIODevice::ReadOnly); pattern_file.open(QIODevice::ReadOnly);
pattern_ = QString::fromLatin1(pattern_file.readAll()); pattern_ = QString::fromLatin1(pattern_file.readAll());
connect(tray_, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), SLOT(Clicked(QSystemTrayIcon::ActivationReason))); connect(tray_, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), SLOT(Clicked(QSystemTrayIcon::ActivationReason)));
app_name_[0] = app_name_[0].toUpper();
} }
QtSystemTrayIcon::~QtSystemTrayIcon() { QtSystemTrayIcon::~QtSystemTrayIcon() {
@@ -230,7 +231,7 @@ void QtSystemTrayIcon::SetNowPlaying(const Song &song, const QString &image_path
QString clone = pattern_; QString clone = pattern_;
clone.replace("%columns" , QString::number(columns)); clone.replace("%columns" , QString::number(columns));
clone.replace("%appName" , QCoreApplication::applicationName()); clone.replace("%appName" , app_name_);
clone.replace("%titleKey" , tr("Title") % ":"); clone.replace("%titleKey" , tr("Title") % ":");
clone.replace("%titleValue" , song.PrettyTitle().toHtmlEscaped()); clone.replace("%titleValue" , song.PrettyTitle().toHtmlEscaped());
@@ -256,5 +257,5 @@ void QtSystemTrayIcon::SetNowPlaying(const Song &song, const QString &image_path
} }
void QtSystemTrayIcon::ClearNowPlaying() { void QtSystemTrayIcon::ClearNowPlaying() {
tray_->setToolTip(QCoreApplication::applicationName()); tray_->setToolTip(app_name_);
} }

View File

@@ -72,15 +72,17 @@ private slots:
private: private:
QSystemTrayIcon *tray_; QSystemTrayIcon *tray_;
QMenu *menu_; QMenu *menu_;
QString app_name_;
QIcon icon_;
QPixmap normal_icon_;
QPixmap grey_icon_;
QAction *action_play_pause_; QAction *action_play_pause_;
QAction *action_stop_; QAction *action_stop_;
QAction *action_stop_after_this_track_; QAction *action_stop_after_this_track_;
QAction *action_mute_; QAction *action_mute_;
QString pattern_; QString pattern_;
QPixmap normal_icon_;
QPixmap grey_icon_;
}; };
#endif // QTSYSTEMTRAYICON_H #endif // QTSYSTEMTRAYICON_H

View File

@@ -66,11 +66,11 @@ QSet<QString> *AlbumCoverChoiceController::sImageExtensions = nullptr;
AlbumCoverChoiceController::AlbumCoverChoiceController(QWidget *parent) : AlbumCoverChoiceController::AlbumCoverChoiceController(QWidget *parent) :
QWidget(parent), QWidget(parent),
app_(nullptr), app_(nullptr),
cover_searcher_(nullptr), cover_searcher_(nullptr),
cover_fetcher_(nullptr), cover_fetcher_(nullptr),
save_file_dialog_(nullptr), save_file_dialog_(nullptr),
cover_from_url_dialog_(nullptr) { cover_from_url_dialog_(nullptr) {
cover_from_file_ = new QAction(IconLoader::Load("document-open"), tr("Load cover from disk..."), this); cover_from_file_ = new QAction(IconLoader::Load("document-open"), tr("Load cover from disk..."), this);
cover_to_file_ = new QAction(IconLoader::Load("document-save"), tr("Save cover to disk..."), this); cover_to_file_ = new QAction(IconLoader::Load("document-save"), tr("Save cover to disk..."), this);

View File

@@ -119,17 +119,6 @@ AlbumCoverManager::AlbumCoverManager(Application *app, CollectionBackend *collec
album_cover_choice_controller_->SetApplication(app_); album_cover_choice_controller_->SetApplication(app_);
// Get a square version of cdcase.png
QImage nocover(":/pictures/cdcase.png");
nocover = nocover.scaled(120, 120, Qt::KeepAspectRatio, Qt::SmoothTransformation);
QImage square_nocover(120, 120, QImage::Format_ARGB32);
square_nocover.fill(0);
QPainter p(&square_nocover);
p.setOpacity(0.4);
p.drawImage((120 - nocover.width()) / 2, (120 - nocover.height()) / 2, nocover);
p.end();
// no_cover_item_icon_ = QPixmap::fromImage(square_nocover);
cover_searcher_ = new AlbumCoverSearcher(no_cover_item_icon_, app_, this); cover_searcher_ = new AlbumCoverSearcher(no_cover_item_icon_, app_, this);
cover_export_ = new AlbumCoverExport(this); cover_export_ = new AlbumCoverExport(this);

View File

@@ -44,12 +44,9 @@ CurrentArtLoader::CurrentArtLoader(Application *app, QObject *parent)
options_.scale_output_image_ = false; options_.scale_output_image_ = false;
options_.pad_output_image_ = false; options_.pad_output_image_ = false;
// QIcon nocover = IconLoader::Load("cdcase");
// options_.default_output_image_ = nocover.pixmap(nocover.availableSizes().last()).toImage();
options_.default_output_image_ = QImage(":/pictures/cdcase.png"); options_.default_output_image_ = QImage(":/pictures/cdcase.png");
connect(app_->album_cover_loader(), SIGNAL(ImageLoaded(quint64, QImage)), SLOT(TempArtLoaded(quint64, QImage))); connect(app_->album_cover_loader(), SIGNAL(ImageLoaded(quint64, QImage)), SLOT(TempArtLoaded(quint64, QImage)));
connect(app_->playlist_manager(), SIGNAL(CurrentSongChanged(Song)), SLOT(LoadArt(Song))); connect(app_->playlist_manager(), SIGNAL(CurrentSongChanged(Song)), SLOT(LoadArt(Song)));
} }

View File

@@ -104,8 +104,6 @@ EditTagDialog::EditTagDialog(Application *app, QWidget *parent)
results_dialog_(new TrackSelectionDialog(this)) results_dialog_(new TrackSelectionDialog(this))
{ {
// QIcon nocover = IconLoader::Load("cdcase");
// cover_options_.default_output_image_ = AlbumCoverLoader::ScaleAndPad(cover_options_, nocover.pixmap(nocover.availableSizes().last()).toImage());
cover_options_.default_output_image_ = AlbumCoverLoader::ScaleAndPad(cover_options_, QImage(":/pictures/cdcase.png")); cover_options_.default_output_image_ = AlbumCoverLoader::ScaleAndPad(cover_options_, QImage(":/pictures/cdcase.png"));
connect(app_->album_cover_loader(), SIGNAL(ImageLoaded(quint64,QImage,QImage)), SLOT(ArtLoaded(quint64,QImage,QImage))); connect(app_->album_cover_loader(), SIGNAL(ImageLoaded(quint64,QImage,QImage)), SLOT(ArtLoaded(quint64,QImage,QImage)));

View File

@@ -49,8 +49,9 @@ const char *OSD::kSettingsGroup = "OSD";
OSD::OSD(SystemTrayIcon *tray_icon, Application *app, QObject *parent) OSD::OSD(SystemTrayIcon *tray_icon, Application *app, QObject *parent)
: QObject(parent), : QObject(parent),
tray_icon_(tray_icon),
app_(app), app_(app),
tray_icon_(tray_icon),
app_name_(QCoreApplication::applicationName()),
timeout_msec_(5000), timeout_msec_(5000),
behaviour_(Native), behaviour_(Native),
show_on_volume_change_(false), show_on_volume_change_(false),
@@ -63,13 +64,16 @@ OSD::OSD(SystemTrayIcon *tray_icon, Application *app, QObject *parent)
preview_mode_(false), preview_mode_(false),
force_show_next_(false), force_show_next_(false),
ignore_next_stopped_(false), ignore_next_stopped_(false),
pretty_popup_(new OSDPretty(OSDPretty::Mode_Popup)) { pretty_popup_(new OSDPretty(OSDPretty::Mode_Popup))
{
connect(app_->current_art_loader(), SIGNAL(ThumbnailLoaded(Song, QString, QImage)), SLOT(AlbumArtLoaded(Song, QString, QImage))); connect(app_->current_art_loader(), SIGNAL(ThumbnailLoaded(Song, QString, QImage)), SLOT(AlbumArtLoaded(Song, QString, QImage)));
ReloadSettings(); ReloadSettings();
Init(); Init();
app_name_[0] = app_name_[0].toUpper();
} }
OSD::~OSD() { OSD::~OSD() {
@@ -89,10 +93,12 @@ void OSD::ReloadSettings() {
use_custom_text_ = s.value(("CustomTextEnabled"), false).toBool(); use_custom_text_ = s.value(("CustomTextEnabled"), false).toBool();
custom_text1_ = s.value("CustomText1").toString(); custom_text1_ = s.value("CustomText1").toString();
custom_text2_ = s.value("CustomText2").toString(); custom_text2_ = s.value("CustomText2").toString();
s.endGroup();
if (!SupportsNativeNotifications() && behaviour_ == Native) if (!SupportsNativeNotifications() && behaviour_ == Native)
behaviour_ = Pretty; behaviour_ = Pretty;
if (!SupportsTrayPopups() && behaviour_ == TrayPopup) behaviour_ = Disabled; if (!SupportsTrayPopups() && behaviour_ == TrayPopup)
behaviour_ = Disabled;
ReloadPrettyOSDSettings(); ReloadPrettyOSDSettings();
@@ -112,7 +118,8 @@ void OSD::ReshowCurrentSong() {
void OSD::AlbumArtLoaded(const Song &song, const QString &uri, const QImage &image) { void OSD::AlbumArtLoaded(const Song &song, const QString &uri, const QImage &image) {
// Don't change tray icon details if it's a preview // Don't change tray icon details if it's a preview
if (!preview_mode_ && tray_icon_) tray_icon_->SetNowPlaying(song, uri); if (!preview_mode_ && tray_icon_)
tray_icon_->SetNowPlaying(song, uri);
last_song_ = song; last_song_ = song;
last_image_ = image; last_image_ = image;
@@ -172,7 +179,7 @@ void OSD::AlbumArtLoaded(const Song &song, const QString &uri, const QImage &ima
void OSD::Paused() { void OSD::Paused() {
if (show_on_pause_) { if (show_on_pause_) {
ShowMessage(QCoreApplication::applicationName(), tr("Paused")); ShowMessage(app_name_, tr("Paused"));
} }
} }
@@ -183,24 +190,24 @@ void OSD::Stopped() {
return; return;
} }
ShowMessage(QCoreApplication::applicationName(), tr("Stopped")); ShowMessage(app_name_, tr("Stopped"));
} }
void OSD::StopAfterToggle(bool stop) { void OSD::StopAfterToggle(bool stop) {
ShowMessage(QCoreApplication::applicationName(), tr("Stop playing after track: %1").arg(stop ? tr("On") : tr("Off"))); ShowMessage(app_name_, tr("Stop playing after track: %1").arg(stop ? tr("On") : tr("Off")));
} }
void OSD::PlaylistFinished() { void OSD::PlaylistFinished() {
// We get a PlaylistFinished followed by a Stopped from the player // We get a PlaylistFinished followed by a Stopped from the player
ignore_next_stopped_ = true; ignore_next_stopped_ = true;
ShowMessage(QCoreApplication::applicationName(), tr("Playlist finished")); ShowMessage(app_name_, tr("Playlist finished"));
} }
void OSD::VolumeChanged(int value) { void OSD::VolumeChanged(int value) {
if (!show_on_volume_change_) return; if (!show_on_volume_change_) return;
ShowMessage(QCoreApplication::applicationName(), tr("Volume %1%").arg(value)); ShowMessage(app_name_, tr("Volume %1%").arg(value));
} }
void OSD::ShowMessage(const QString &summary, const QString &message, const QString &icon, const QImage &image) { void OSD::ShowMessage(const QString &summary, const QString &message, const QString &icon, const QImage &image) {
@@ -251,7 +258,7 @@ void OSD::ShuffleModeChanged(PlaylistSequence::ShuffleMode mode) {
case PlaylistSequence::Shuffle_InsideAlbum: current_mode = tr("Shuffle tracks in this album"); break; case PlaylistSequence::Shuffle_InsideAlbum: current_mode = tr("Shuffle tracks in this album"); break;
case PlaylistSequence::Shuffle_Albums: current_mode = tr("Shuffle albums"); break; case PlaylistSequence::Shuffle_Albums: current_mode = tr("Shuffle albums"); break;
} }
ShowMessage(QCoreApplication::applicationName(), current_mode); ShowMessage(app_name_, current_mode);
} }
} }
@@ -266,7 +273,7 @@ void OSD::RepeatModeChanged(PlaylistSequence::RepeatMode mode) {
case PlaylistSequence::Repeat_OneByOne: current_mode = tr("Stop after every track"); break; case PlaylistSequence::Repeat_OneByOne: current_mode = tr("Stop after every track"); break;
case PlaylistSequence::Repeat_Intro: current_mode = tr("Intro tracks"); break; case PlaylistSequence::Repeat_Intro: current_mode = tr("Intro tracks"); break;
} }
ShowMessage(QCoreApplication::applicationName(), current_mode); ShowMessage(app_name_, current_mode);
} }
} }

View File

@@ -106,8 +106,9 @@ class OSD : public QObject {
void AlbumArtLoaded(const Song &song, const QString &uri, const QImage &image); void AlbumArtLoaded(const Song &song, const QString &uri, const QImage &image);
private: private:
SystemTrayIcon *tray_icon_;
Application *app_; Application *app_;
SystemTrayIcon *tray_icon_;
QString app_name_;
int timeout_msec_; int timeout_msec_;
Behaviour behaviour_; Behaviour behaviour_;
bool show_on_volume_change_; bool show_on_volume_change_;

View File

@@ -87,8 +87,8 @@ OSDPretty::OSDPretty(Mode mode, QWidget *parent)
timeout_(new QTimer(this)), timeout_(new QTimer(this)),
fading_enabled_(false), fading_enabled_(false),
fader_(new QTimeLine(300, this)), fader_(new QTimeLine(300, this)),
toggle_mode_(false) toggle_mode_(false) {
{
Qt::WindowFlags flags = Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint; Qt::WindowFlags flags = Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint;
setWindowFlags(flags); setWindowFlags(flags);
@@ -180,6 +180,7 @@ void OSDPretty::Load() {
popup_pos_ = s.value("popup_pos", QPoint(0, 0)).toPoint(); popup_pos_ = s.value("popup_pos", QPoint(0, 0)).toPoint();
font_.fromString(s.value("font", "Verdana,9,-1,5,50,0,0,0,0,0").toString()); font_.fromString(s.value("font", "Verdana,9,-1,5,50,0,0,0,0,0").toString());
disable_duration_ = s.value("disable_duration", false).toBool(); disable_duration_ = s.value("disable_duration", false).toBool();
s.endGroup();
set_font(font()); set_font(font());
set_foreground_color(foreground_color()); set_foreground_color(foreground_color());