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();
|
ReloadSettings();
|
||||||
|
|
||||||
|
// Reload pretty OSD to avoid issues with fonts
|
||||||
|
osd_->ReloadPrettyOSDSettings();
|
||||||
|
|
||||||
#ifndef Q_OS_DARWIN
|
#ifndef Q_OS_DARWIN
|
||||||
StartupBehaviour behaviour =
|
StartupBehaviour behaviour =
|
||||||
StartupBehaviour(settings_.value("startupbehaviour", Startup_Remember).toInt());
|
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_opacity, SIGNAL(valueChanged(int)), SLOT(PrettyOpacityChanged(int)));
|
||||||
connect(ui_->notifications_bg_preset, SIGNAL(activated(int)), SLOT(PrettyColorPresetChanged(int)));
|
connect(ui_->notifications_bg_preset, SIGNAL(activated(int)), SLOT(PrettyColorPresetChanged(int)));
|
||||||
connect(ui_->notifications_fg_choose, SIGNAL(clicked()), SLOT(ChooseFgColor()));
|
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_chooser1, SIGNAL(triggered(QAction*)), SLOT(InsertVariableFirstLine(QAction*)));
|
||||||
connect(ui_->notifications_exp_chooser2, SIGNAL(triggered(QAction*)), SLOT(InsertVariableSecondLine(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("background_opacity", pretty_popup_->background_opacity());
|
||||||
s.setValue("popup_display", pretty_popup_->popup_display());
|
s.setValue("popup_display", pretty_popup_->popup_display());
|
||||||
s.setValue("popup_pos", pretty_popup_->popup_pos());
|
s.setValue("popup_pos", pretty_popup_->popup_pos());
|
||||||
|
s.setValue("font", pretty_popup_->font().toString());
|
||||||
s.endGroup();
|
s.endGroup();
|
||||||
|
|
||||||
// Network proxy
|
// Network proxy
|
||||||
|
@ -739,6 +741,13 @@ void SettingsDialog::ChooseFgColor() {
|
||||||
pretty_popup_->set_foreground_color(color.rgb());
|
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) {
|
void SettingsDialog::ShowTrayIconToggled(bool on) {
|
||||||
ui_->b_always_hide_->setEnabled(on);
|
ui_->b_always_hide_->setEnabled(on);
|
||||||
if (!on && ui_->b_always_hide_->isChecked())
|
if (!on && ui_->b_always_hide_->isChecked())
|
||||||
|
|
|
@ -115,6 +115,7 @@ class SettingsDialog : public QDialog {
|
||||||
void PrettyColorPresetChanged(int index);
|
void PrettyColorPresetChanged(int index);
|
||||||
void ChooseBgColor();
|
void ChooseBgColor();
|
||||||
void ChooseFgColor();
|
void ChooseFgColor();
|
||||||
|
void ChooseFont();
|
||||||
|
|
||||||
void UpdatePopupVisible();
|
void UpdatePopupVisible();
|
||||||
void ShowTrayIconToggled(bool on);
|
void ShowTrayIconToggled(bool on);
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>746</width>
|
<width>744</width>
|
||||||
<height>642</height>
|
<height>640</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -975,7 +975,7 @@
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Pretty OSD options</string>
|
<string>Pretty OSD options</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QFormLayout" name="formLayout_2">
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QLabel" name="label_4">
|
<widget class="QLabel" name="label_4">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@ -983,7 +983,7 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="0" column="1" colspan="2">
|
||||||
<widget class="QSlider" name="notifications_opacity">
|
<widget class="QSlider" name="notifications_opacity">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
|
@ -1019,7 +1019,7 @@
|
||||||
<item row="2" column="0">
|
<item row="2" column="0">
|
||||||
<widget class="QLabel" name="label_6">
|
<widget class="QLabel" name="label_6">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Text color</string>
|
<string>Text options</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -1030,6 +1030,13 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="2" column="2">
|
||||||
|
<widget class="QPushButton" name="notifications_font_choose">
|
||||||
|
<property name="text">
|
||||||
|
<string>Choose font...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
|
@ -84,13 +84,21 @@ void OSD::ReloadSettings() {
|
||||||
if (!SupportsTrayPopups() && behaviour_ == TrayPopup)
|
if (!SupportsTrayPopups() && behaviour_ == TrayPopup)
|
||||||
behaviour_ = Disabled;
|
behaviour_ = Disabled;
|
||||||
|
|
||||||
|
ReloadPrettyOSDSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reload just Pretty OSD settings, not everything
|
||||||
|
void OSD::ReloadPrettyOSDSettings() {
|
||||||
pretty_popup_->set_popup_duration(timeout_msec_);
|
pretty_popup_->set_popup_duration(timeout_msec_);
|
||||||
pretty_popup_->ReloadSettings();
|
pretty_popup_->ReloadSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OSD::SongChanged(const Song &song) {
|
void OSD::SongChanged(const Song &song) {
|
||||||
// no cover art yet
|
// Don't change tray icon details if it's a preview
|
||||||
tray_icon_->SetNowPlaying(song, NULL);
|
if (!preview_mode_) {
|
||||||
|
// no cover art yet
|
||||||
|
tray_icon_->SetNowPlaying(song, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
QStringList message_parts;
|
QStringList message_parts;
|
||||||
QString summary;
|
QString summary;
|
||||||
|
@ -145,7 +153,9 @@ void OSD::SongChanged(const Song &song) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void OSD::CoverArtPathReady(const Song& song, const QString& image_path) {
|
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) {
|
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;
|
custom_text2_ = line2;
|
||||||
if (!use_custom_text_)
|
if (!use_custom_text_)
|
||||||
use_custom_text_ = true;
|
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
|
// We want to reload the settings, but we can't do this here because the cover art loading is asynch
|
||||||
preview_mode_ = true;
|
preview_mode_ = true;
|
||||||
|
SongChanged(song);
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,8 @@ class OSD : public QObject {
|
||||||
static bool SupportsNativeNotifications();
|
static bool SupportsNativeNotifications();
|
||||||
static bool SupportsTrayPopups();
|
static bool SupportsTrayPopups();
|
||||||
|
|
||||||
|
void ReloadPrettyOSDSettings();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void ReloadSettings();
|
void ReloadSettings();
|
||||||
|
|
||||||
|
|
|
@ -59,6 +59,7 @@ OSDPretty::OSDPretty(Mode mode, QWidget *parent)
|
||||||
background_color_(kPresetBlue),
|
background_color_(kPresetBlue),
|
||||||
background_opacity_(0.85),
|
background_opacity_(0.85),
|
||||||
popup_display_(0),
|
popup_display_(0),
|
||||||
|
font_(QFont()),
|
||||||
timeout_(new QTimer(this)),
|
timeout_(new QTimer(this)),
|
||||||
fading_enabled_(false),
|
fading_enabled_(false),
|
||||||
fader_(new QTimeLine(300, this))
|
fader_(new QTimeLine(300, this))
|
||||||
|
@ -115,7 +116,7 @@ OSDPretty::OSDPretty(Mode mode, QWidget *parent)
|
||||||
int margin = l->margin() + kDropShadowSize;
|
int margin = l->margin() + kDropShadowSize;
|
||||||
l->setMargin(margin);
|
l->setMargin(margin);
|
||||||
|
|
||||||
Load();
|
// Don't load settings here, they will be reloaded anyway on creation
|
||||||
}
|
}
|
||||||
|
|
||||||
OSDPretty::~OSDPretty() {
|
OSDPretty::~OSDPretty() {
|
||||||
|
@ -138,7 +139,9 @@ void OSDPretty::Load() {
|
||||||
background_opacity_ = s.value("background_opacity", 0.85).toDouble();
|
background_opacity_ = s.value("background_opacity", 0.85).toDouble();
|
||||||
popup_display_ = s.value("popup_display", -1).toInt();
|
popup_display_ = s.value("popup_display", -1).toInt();
|
||||||
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());
|
||||||
|
|
||||||
|
set_font(font());
|
||||||
set_foreground_color(foreground_color());
|
set_foreground_color(foreground_color());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,8 +246,11 @@ void OSDPretty::showEvent(QShowEvent* e) {
|
||||||
fader_->setDirection(QTimeLine::Forward);
|
fader_->setDirection(QTimeLine::Forward);
|
||||||
fader_->start(); // Timeout will be started in FaderFinished
|
fader_->start(); // Timeout will be started in FaderFinished
|
||||||
}
|
}
|
||||||
else if (mode_ == Mode_Popup)
|
else if (mode_ == Mode_Popup) {
|
||||||
timeout_->start();
|
timeout_->start();
|
||||||
|
// Ensures it is above when showing the preview
|
||||||
|
raise();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OSDPretty::setVisible(bool visible) {
|
void OSDPretty::setVisible(bool visible) {
|
||||||
|
@ -401,3 +407,16 @@ void OSDPretty::mouseReleaseEvent(QMouseEvent *) {
|
||||||
popup_pos_ = current_pos();
|
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_foreground_color(QRgb color);
|
||||||
void set_background_color(QRgb color);
|
void set_background_color(QRgb color);
|
||||||
void set_background_opacity(qreal opacity);
|
void set_background_opacity(qreal opacity);
|
||||||
|
void set_font(QFont font);
|
||||||
|
|
||||||
QRgb foreground_color() const { return foreground_color_.rgb(); }
|
QRgb foreground_color() const { return foreground_color_.rgb(); }
|
||||||
QRgb background_color() const { return background_color_.rgb(); }
|
QRgb background_color() const { return background_color_.rgb(); }
|
||||||
qreal background_opacity() const { return background_opacity_; }
|
qreal background_opacity() const { return background_opacity_; }
|
||||||
int popup_display() const { return popup_display_; }
|
int popup_display() const { return popup_display_; }
|
||||||
QPoint popup_pos() const { return popup_pos_; }
|
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
|
// 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
|
// position and screen. Note that these return invalid values if the popup
|
||||||
|
@ -112,6 +114,7 @@ class OSDPretty : public QWidget {
|
||||||
float background_opacity_;
|
float background_opacity_;
|
||||||
int popup_display_; // -1 for default
|
int popup_display_; // -1 for default
|
||||||
QPoint popup_pos_;
|
QPoint popup_pos_;
|
||||||
|
QFont font_;
|
||||||
|
|
||||||
// Cached pixmaps
|
// Cached pixmaps
|
||||||
QPixmap shadow_edge_[4];
|
QPixmap shadow_edge_[4];
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>410</width>
|
<width>396</width>
|
||||||
<height>94</height>
|
<height>80</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="styleSheet">
|
<property name="styleSheet">
|
||||||
|
@ -31,6 +31,12 @@
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="summary">
|
<widget class="QLabel" name="summary">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>300</width>
|
<width>300</width>
|
||||||
|
@ -39,7 +45,7 @@
|
||||||
</property>
|
</property>
|
||||||
<property name="maximumSize">
|
<property name="maximumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>300</width>
|
<width>400</width>
|
||||||
<height>16777215</height>
|
<height>16777215</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
|
@ -50,6 +56,12 @@
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="message">
|
<widget class="QLabel" name="message">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
<property name="maximumSize">
|
<property name="maximumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>400</width>
|
<width>400</width>
|
||||||
|
|
Loading…
Reference in New Issue