diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp index 89b130f5b..1dd136108 100644 --- a/src/ui/mainwindow.cpp +++ b/src/ui/mainwindow.cpp @@ -712,6 +712,9 @@ MainWindow::MainWindow( ReloadSettings(); + // Reload pretty OSD to avoid issues with fonts + osd_->ReloadPrettyOSDSettings(); + #ifndef Q_OS_DARWIN StartupBehaviour behaviour = StartupBehaviour(settings_.value("startupbehaviour", Startup_Remember).toInt()); diff --git a/src/ui/settingsdialog.cpp b/src/ui/settingsdialog.cpp index fc7a6a81e..b47319bb0 100644 --- a/src/ui/settingsdialog.cpp +++ b/src/ui/settingsdialog.cpp @@ -284,6 +284,7 @@ SettingsDialog::SettingsDialog(BackgroundStreams* streams, QWidget* parent) connect(ui_->notifications_opacity, SIGNAL(valueChanged(int)), SLOT(PrettyOpacityChanged(int))); connect(ui_->notifications_bg_preset, SIGNAL(activated(int)), SLOT(PrettyColorPresetChanged(int))); connect(ui_->notifications_fg_choose, SIGNAL(clicked()), SLOT(ChooseFgColor())); + connect(ui_->notifications_font_choose, SIGNAL(clicked()), SLOT(ChooseFont())); connect(ui_->notifications_exp_chooser1, SIGNAL(triggered(QAction*)), SLOT(InsertVariableFirstLine(QAction*))); connect(ui_->notifications_exp_chooser2, SIGNAL(triggered(QAction*)), SLOT(InsertVariableSecondLine(QAction*))); @@ -434,6 +435,7 @@ void SettingsDialog::accept() { s.setValue("background_opacity", pretty_popup_->background_opacity()); s.setValue("popup_display", pretty_popup_->popup_display()); s.setValue("popup_pos", pretty_popup_->popup_pos()); + s.setValue("font", pretty_popup_->font().toString()); s.endGroup(); // Network proxy @@ -739,6 +741,13 @@ void SettingsDialog::ChooseFgColor() { pretty_popup_->set_foreground_color(color.rgb()); } +void SettingsDialog::ChooseFont() { + bool ok; + QFont font = QFontDialog::getFont(&ok, pretty_popup_->font(), this); + if (ok) + pretty_popup_->set_font(font); +} + void SettingsDialog::ShowTrayIconToggled(bool on) { ui_->b_always_hide_->setEnabled(on); if (!on && ui_->b_always_hide_->isChecked()) diff --git a/src/ui/settingsdialog.h b/src/ui/settingsdialog.h index b4ea6e042..509e90982 100644 --- a/src/ui/settingsdialog.h +++ b/src/ui/settingsdialog.h @@ -115,6 +115,7 @@ class SettingsDialog : public QDialog { void PrettyColorPresetChanged(int index); void ChooseBgColor(); void ChooseFgColor(); + void ChooseFont(); void UpdatePopupVisible(); void ShowTrayIconToggled(bool on); diff --git a/src/ui/settingsdialog.ui b/src/ui/settingsdialog.ui index 86cf19d96..d75f99aaa 100644 --- a/src/ui/settingsdialog.ui +++ b/src/ui/settingsdialog.ui @@ -6,8 +6,8 @@ 0 0 - 746 - 642 + 744 + 640 @@ -975,7 +975,7 @@ Pretty OSD options - + @@ -983,7 +983,7 @@ - + Qt::Horizontal @@ -1019,7 +1019,7 @@ - Text color + Text options @@ -1030,6 +1030,13 @@ + + + + Choose font... + + + diff --git a/src/widgets/osd.cpp b/src/widgets/osd.cpp index 7e640560c..89618b42a 100644 --- a/src/widgets/osd.cpp +++ b/src/widgets/osd.cpp @@ -84,13 +84,21 @@ void OSD::ReloadSettings() { if (!SupportsTrayPopups() && behaviour_ == TrayPopup) behaviour_ = Disabled; + ReloadPrettyOSDSettings(); +} + +// Reload just Pretty OSD settings, not everything +void OSD::ReloadPrettyOSDSettings() { pretty_popup_->set_popup_duration(timeout_msec_); pretty_popup_->ReloadSettings(); } void OSD::SongChanged(const Song &song) { - // no cover art yet - tray_icon_->SetNowPlaying(song, NULL); + // Don't change tray icon details if it's a preview + if (!preview_mode_) { + // no cover art yet + tray_icon_->SetNowPlaying(song, NULL); + } QStringList message_parts; QString summary; @@ -145,7 +153,9 @@ void OSD::SongChanged(const Song &song) { } void OSD::CoverArtPathReady(const Song& song, const QString& image_path) { - tray_icon_->SetNowPlaying(song, image_path); + // Don't change tray icon details if it's a preview + if (!preview_mode_) + tray_icon_->SetNowPlaying(song, image_path); } void OSD::AlbumArtLoaded(quint64 id, const QImage& image) { @@ -354,8 +364,8 @@ void OSD::ShowPreview(const Behaviour type, const QString& line1, const QString& custom_text2_ = line2; if (!use_custom_text_) use_custom_text_ = true; - SongChanged(song); // We want to reload the settings, but we can't do this here because the cover art loading is asynch preview_mode_ = true; + SongChanged(song); } diff --git a/src/widgets/osd.h b/src/widgets/osd.h index 05d12d1ce..cb6577068 100644 --- a/src/widgets/osd.h +++ b/src/widgets/osd.h @@ -63,6 +63,8 @@ class OSD : public QObject { static bool SupportsNativeNotifications(); static bool SupportsTrayPopups(); + void ReloadPrettyOSDSettings(); + public slots: void ReloadSettings(); diff --git a/src/widgets/osdpretty.cpp b/src/widgets/osdpretty.cpp index f130dde0f..99ee3a9de 100644 --- a/src/widgets/osdpretty.cpp +++ b/src/widgets/osdpretty.cpp @@ -59,6 +59,7 @@ OSDPretty::OSDPretty(Mode mode, QWidget *parent) background_color_(kPresetBlue), background_opacity_(0.85), popup_display_(0), + font_(QFont()), timeout_(new QTimer(this)), fading_enabled_(false), fader_(new QTimeLine(300, this)) @@ -115,7 +116,7 @@ OSDPretty::OSDPretty(Mode mode, QWidget *parent) int margin = l->margin() + kDropShadowSize; l->setMargin(margin); - Load(); + // Don't load settings here, they will be reloaded anyway on creation } OSDPretty::~OSDPretty() { @@ -138,7 +139,9 @@ void OSDPretty::Load() { background_opacity_ = s.value("background_opacity", 0.85).toDouble(); popup_display_ = s.value("popup_display", -1).toInt(); 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()); + set_font(font()); set_foreground_color(foreground_color()); } @@ -243,8 +246,11 @@ void OSDPretty::showEvent(QShowEvent* e) { fader_->setDirection(QTimeLine::Forward); fader_->start(); // Timeout will be started in FaderFinished } - else if (mode_ == Mode_Popup) + else if (mode_ == Mode_Popup) { timeout_->start(); + // Ensures it is above when showing the preview + raise(); + } } void OSDPretty::setVisible(bool visible) { @@ -401,3 +407,16 @@ void OSDPretty::mouseReleaseEvent(QMouseEvent *) { popup_pos_ = current_pos(); } } + +void OSDPretty::set_font(QFont font) { + font_ = font; + + // Update the UI + ui_->summary->setFont(font); + ui_->message->setFont(font); + // Now adjust OSD size so everything fits + ui_->verticalLayout->activate(); + resize(sizeHint()); + // Update the position after font change + Reposition(); +} diff --git a/src/widgets/osdpretty.h b/src/widgets/osdpretty.h index fa734b526..afcc1e214 100644 --- a/src/widgets/osdpretty.h +++ b/src/widgets/osdpretty.h @@ -63,12 +63,14 @@ class OSDPretty : public QWidget { void set_foreground_color(QRgb color); void set_background_color(QRgb color); void set_background_opacity(qreal opacity); + void set_font(QFont font); QRgb foreground_color() const { return foreground_color_.rgb(); } QRgb background_color() const { return background_color_.rgb(); } qreal background_opacity() const { return background_opacity_; } int popup_display() const { return popup_display_; } QPoint popup_pos() const { return popup_pos_; } + QFont font() const { return font_; } // When the user has been moving the popup, use these to get its current // position and screen. Note that these return invalid values if the popup @@ -112,6 +114,7 @@ class OSDPretty : public QWidget { float background_opacity_; int popup_display_; // -1 for default QPoint popup_pos_; + QFont font_; // Cached pixmaps QPixmap shadow_edge_[4]; diff --git a/src/widgets/osdpretty.ui b/src/widgets/osdpretty.ui index ebea30d76..91fafeb54 100644 --- a/src/widgets/osdpretty.ui +++ b/src/widgets/osdpretty.ui @@ -6,8 +6,8 @@ 0 0 - 410 - 94 + 396 + 80 @@ -31,6 +31,12 @@ + + + 0 + 0 + + 300 @@ -39,7 +45,7 @@ - 300 + 400 16777215 @@ -50,6 +56,12 @@ + + + 0 + 0 + + 400