Add font choice for pretty OSD and fixed bugs in the notification
preview
This commit is contained in:
parent
516c9a8da5
commit
61092899c9
@ -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());
|
||||
|
@ -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())
|
||||
|
@ -115,6 +115,7 @@ class SettingsDialog : public QDialog {
|
||||
void PrettyColorPresetChanged(int index);
|
||||
void ChooseBgColor();
|
||||
void ChooseFgColor();
|
||||
void ChooseFont();
|
||||
|
||||
void UpdatePopupVisible();
|
||||
void ShowTrayIconToggled(bool on);
|
||||
|
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>746</width>
|
||||
<height>642</height>
|
||||
<width>744</width>
|
||||
<height>640</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -975,7 +975,7 @@
|
||||
<property name="title">
|
||||
<string>Pretty OSD options</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout_2">
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
@ -983,7 +983,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<item row="0" column="1" colspan="2">
|
||||
<widget class="QSlider" name="notifications_opacity">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
@ -1019,7 +1019,7 @@
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Text color</string>
|
||||
<string>Text options</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -1030,6 +1030,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QPushButton" name="notifications_font_choose">
|
||||
<property name="text">
|
||||
<string>Choose font...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -63,6 +63,8 @@ class OSD : public QObject {
|
||||
static bool SupportsNativeNotifications();
|
||||
static bool SupportsTrayPopups();
|
||||
|
||||
void ReloadPrettyOSDSettings();
|
||||
|
||||
public slots:
|
||||
void ReloadSettings();
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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];
|
||||
|
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>410</width>
|
||||
<height>94</height>
|
||||
<width>396</width>
|
||||
<height>80</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
@ -31,6 +31,12 @@
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="summary">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>300</width>
|
||||
@ -39,7 +45,7 @@
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>300</width>
|
||||
<width>400</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
@ -50,6 +56,12 @@
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="message">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>400</width>
|
||||
|
Loading…
x
Reference in New Issue
Block a user