2018-02-27 18:06:05 +01:00
|
|
|
/*
|
|
|
|
* Strawberry Music Player
|
|
|
|
* This file was part of Clementine.
|
|
|
|
* Copyright 2010, David Sansome <me@davidsansome.com>
|
2021-03-20 21:14:47 +01:00
|
|
|
* Copyright 2019-2021, Jonas Kvinge <jonas@jkvinge.net>
|
2018-02-27 18:06:05 +01:00
|
|
|
*
|
|
|
|
* 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
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2018-05-01 00:41:33 +02:00
|
|
|
#include <QtGlobal>
|
|
|
|
#include <QAction>
|
|
|
|
#include <QVariant>
|
|
|
|
#include <QImage>
|
|
|
|
#include <QColor>
|
2020-02-09 02:29:35 +01:00
|
|
|
#include <QRgb>
|
2018-05-01 00:41:33 +02:00
|
|
|
#include <QMenu>
|
|
|
|
#include <QFont>
|
|
|
|
#include <QFontDialog>
|
|
|
|
#include <QCursor>
|
|
|
|
#include <QGroupBox>
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QLineEdit>
|
|
|
|
#include <QColorDialog>
|
|
|
|
#include <QComboBox>
|
|
|
|
#include <QCheckBox>
|
|
|
|
#include <QPushButton>
|
|
|
|
#include <QRadioButton>
|
|
|
|
#include <QSlider>
|
|
|
|
#include <QSpinBox>
|
|
|
|
#include <QToolButton>
|
|
|
|
#include <QToolTip>
|
|
|
|
#include <QtEvents>
|
|
|
|
#include <QSettings>
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
#include "core/iconloader.h"
|
2020-08-09 01:37:00 +02:00
|
|
|
#include "osd/osdbase.h"
|
|
|
|
#include "osd/osdpretty.h"
|
2018-05-01 00:41:33 +02:00
|
|
|
#include "settingspage.h"
|
|
|
|
#include "settingsdialog.h"
|
|
|
|
#include "notificationssettingspage.h"
|
|
|
|
#include "ui_notificationssettingspage.h"
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2018-05-01 00:41:33 +02:00
|
|
|
class QHideEvent;
|
|
|
|
class QShowEvent;
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2021-06-20 19:04:08 +02:00
|
|
|
NotificationsSettingsPage::NotificationsSettingsPage(SettingsDialog *dialog, QWidget *parent)
|
2021-07-11 07:40:57 +02:00
|
|
|
: SettingsPage(dialog, parent),
|
|
|
|
ui_(new Ui_NotificationsSettingsPage),
|
|
|
|
pretty_popup_(new OSDPretty(OSDPretty::Mode_Draggable)) {
|
2020-06-05 23:46:07 +02:00
|
|
|
|
2018-02-27 18:06:05 +01:00
|
|
|
ui_->setupUi(this);
|
|
|
|
setWindowIcon(IconLoader::Load("help-hint"));
|
|
|
|
|
2019-09-25 19:01:55 +02:00
|
|
|
pretty_popup_->SetMessage(tr("OSD Preview"), tr("Drag to reposition"), QImage(":/pictures/cdcase.png"));
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
ui_->notifications_bg_preset->setItemData(0, QColor(OSDPretty::kPresetBlue), Qt::DecorationRole);
|
2018-09-20 17:44:31 +02:00
|
|
|
ui_->notifications_bg_preset->setItemData(1, QColor(OSDPretty::kPresetRed), Qt::DecorationRole);
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
// Create and populate the helper menus
|
2018-05-01 00:41:33 +02:00
|
|
|
QMenu *menu = new QMenu(this);
|
2018-02-27 18:06:05 +01:00
|
|
|
menu->addAction(ui_->action_title);
|
2020-12-11 23:59:38 +01:00
|
|
|
menu->addAction(ui_->action_album);
|
|
|
|
menu->addAction(ui_->action_artist);
|
2018-02-27 18:06:05 +01:00
|
|
|
menu->addAction(ui_->action_albumartist);
|
2020-12-11 23:59:38 +01:00
|
|
|
menu->addAction(ui_->action_disc);
|
|
|
|
menu->addAction(ui_->action_track);
|
2018-02-27 18:06:05 +01:00
|
|
|
menu->addAction(ui_->action_year);
|
2020-12-11 23:59:38 +01:00
|
|
|
menu->addAction(ui_->action_originalyear);
|
|
|
|
menu->addAction(ui_->action_genre);
|
2018-02-27 18:06:05 +01:00
|
|
|
menu->addAction(ui_->action_composer);
|
|
|
|
menu->addAction(ui_->action_performer);
|
|
|
|
menu->addAction(ui_->action_grouping);
|
|
|
|
menu->addAction(ui_->action_length);
|
2020-12-11 23:59:38 +01:00
|
|
|
menu->addAction(ui_->action_filename);
|
|
|
|
menu->addAction(ui_->action_url);
|
2018-02-27 18:06:05 +01:00
|
|
|
menu->addAction(ui_->action_playcount);
|
|
|
|
menu->addAction(ui_->action_skipcount);
|
|
|
|
menu->addAction(ui_->action_rating);
|
|
|
|
menu->addSeparator();
|
|
|
|
menu->addAction(ui_->action_newline);
|
|
|
|
ui_->notifications_exp_chooser1->setMenu(menu);
|
|
|
|
ui_->notifications_exp_chooser2->setMenu(menu);
|
|
|
|
ui_->notifications_exp_chooser1->setPopupMode(QToolButton::InstantPopup);
|
|
|
|
ui_->notifications_exp_chooser2->setPopupMode(QToolButton::InstantPopup);
|
|
|
|
// We need this because by default menus don't show tooltips
|
2021-01-26 16:48:04 +01:00
|
|
|
QObject::connect(menu, &QMenu::hovered, this, &NotificationsSettingsPage::ShowMenuTooltip);
|
|
|
|
|
|
|
|
QObject::connect(ui_->notifications_none, &QRadioButton::toggled, this, &NotificationsSettingsPage::NotificationTypeChanged);
|
|
|
|
QObject::connect(ui_->notifications_native, &QRadioButton::toggled, this, &NotificationsSettingsPage::NotificationTypeChanged);
|
|
|
|
QObject::connect(ui_->notifications_tray, &QRadioButton::toggled, this, &NotificationsSettingsPage::NotificationTypeChanged);
|
|
|
|
QObject::connect(ui_->notifications_pretty, &QRadioButton::toggled, this, &NotificationsSettingsPage::NotificationTypeChanged);
|
|
|
|
QObject::connect(ui_->notifications_opacity, &QSlider::valueChanged, this, &NotificationsSettingsPage::PrettyOpacityChanged);
|
|
|
|
QObject::connect(ui_->notifications_bg_preset, QOverload<int>::of(&QComboBox::activated), this, &NotificationsSettingsPage::PrettyColorPresetChanged);
|
|
|
|
QObject::connect(ui_->notifications_fg_choose, &QPushButton::clicked, this, &NotificationsSettingsPage::ChooseFgColor);
|
|
|
|
QObject::connect(ui_->notifications_font_choose, &QPushButton::clicked, this, &NotificationsSettingsPage::ChooseFont);
|
|
|
|
QObject::connect(ui_->notifications_exp_chooser1, &QToolButton::triggered, this, &NotificationsSettingsPage::InsertVariableFirstLine);
|
|
|
|
QObject::connect(ui_->notifications_exp_chooser2, &QToolButton::triggered, this, &NotificationsSettingsPage::InsertVariableSecondLine);
|
|
|
|
QObject::connect(ui_->notifications_disable_duration, &QCheckBox::toggled, ui_->notifications_duration, &NotificationsSettingsPage::setDisabled);
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2021-10-24 23:09:20 +02:00
|
|
|
#ifdef Q_OS_WIN32
|
|
|
|
if (!dialog->osd()->SupportsNativeNotifications() && !dialog->osd()->SupportsTrayPopups()) {
|
|
|
|
ui_->notifications_native->setEnabled(false);
|
|
|
|
}
|
|
|
|
#else
|
2021-08-23 21:21:08 +02:00
|
|
|
if (!dialog->osd()->SupportsNativeNotifications()) {
|
2018-02-27 18:06:05 +01:00
|
|
|
ui_->notifications_native->setEnabled(false);
|
2021-08-23 21:21:08 +02:00
|
|
|
}
|
2021-10-24 23:09:20 +02:00
|
|
|
#endif
|
|
|
|
if (!dialog->osd()->SupportsTrayPopups()) {
|
|
|
|
ui_->notifications_tray->setEnabled(false);
|
|
|
|
}
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2021-01-26 16:48:04 +01:00
|
|
|
QObject::connect(ui_->notifications_pretty, &QRadioButton::toggled, this, &NotificationsSettingsPage::UpdatePopupVisible);
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2021-01-26 16:48:04 +01:00
|
|
|
QObject::connect(ui_->notifications_custom_text_enabled, &QCheckBox::toggled, this, &NotificationsSettingsPage::NotificationCustomTextChanged);
|
|
|
|
QObject::connect(ui_->notifications_preview, &QPushButton::clicked, this, &NotificationsSettingsPage::PrepareNotificationPreview);
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
// Icons
|
|
|
|
ui_->notifications_exp_chooser1->setIcon(IconLoader::Load("list-add"));
|
|
|
|
ui_->notifications_exp_chooser2->setIcon(IconLoader::Load("list-add"));
|
|
|
|
|
2021-01-26 16:48:04 +01:00
|
|
|
QObject::connect(pretty_popup_, &OSDPretty::PositionChanged, this, &NotificationsSettingsPage::PrettyOSDChanged);
|
2020-06-05 23:46:07 +02:00
|
|
|
|
2018-02-27 18:06:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
NotificationsSettingsPage::~NotificationsSettingsPage() {
|
|
|
|
delete pretty_popup_;
|
|
|
|
delete ui_;
|
|
|
|
}
|
|
|
|
|
|
|
|
void NotificationsSettingsPage::showEvent(QShowEvent*) {
|
|
|
|
UpdatePopupVisible();
|
|
|
|
}
|
|
|
|
|
|
|
|
void NotificationsSettingsPage::hideEvent(QHideEvent*) {
|
|
|
|
UpdatePopupVisible();
|
|
|
|
}
|
|
|
|
|
|
|
|
void NotificationsSettingsPage::Load() {
|
|
|
|
|
|
|
|
QSettings s;
|
|
|
|
|
2020-08-09 01:37:00 +02:00
|
|
|
s.beginGroup(OSDBase::kSettingsGroup);
|
|
|
|
OSDBase::Behaviour osd_behaviour = OSDBase::Behaviour(s.value("Behaviour", OSDBase::Native).toInt());
|
2018-02-27 18:06:05 +01:00
|
|
|
switch (osd_behaviour) {
|
2020-08-09 01:37:00 +02:00
|
|
|
case OSDBase::Native:
|
2021-10-24 23:09:20 +02:00
|
|
|
#ifdef Q_OS_WIN32
|
|
|
|
if (dialog()->osd()->SupportsNativeNotifications() || dialog()->osd()->SupportsTrayPopups()) {
|
|
|
|
#else
|
2020-08-09 01:37:00 +02:00
|
|
|
if (dialog()->osd()->SupportsNativeNotifications()) {
|
2021-10-24 23:09:20 +02:00
|
|
|
#endif
|
2018-02-27 18:06:05 +01:00
|
|
|
ui_->notifications_native->setChecked(true);
|
|
|
|
break;
|
|
|
|
}
|
2021-07-11 09:49:38 +02:00
|
|
|
// Fallthrough
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2020-08-09 01:37:00 +02:00
|
|
|
case OSDBase::Pretty:
|
2018-02-27 18:06:05 +01:00
|
|
|
ui_->notifications_pretty->setChecked(true);
|
|
|
|
break;
|
|
|
|
|
2020-08-09 01:37:00 +02:00
|
|
|
case OSDBase::TrayPopup:
|
|
|
|
if (dialog()->osd()->SupportsTrayPopups()) {
|
2018-02-27 18:06:05 +01:00
|
|
|
ui_->notifications_tray->setChecked(true);
|
|
|
|
break;
|
|
|
|
}
|
2021-07-11 09:49:38 +02:00
|
|
|
// Fallthrough
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2020-08-09 01:37:00 +02:00
|
|
|
case OSDBase::Disabled:
|
2018-02-27 18:06:05 +01:00
|
|
|
default:
|
|
|
|
ui_->notifications_none->setChecked(true);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
ui_->notifications_duration->setValue(s.value("Timeout", 5000).toInt() / 1000);
|
2022-03-22 21:09:05 +01:00
|
|
|
ui_->notifications_volume->setChecked(s.value("ShowOnVolumeChange", false).toBool());
|
|
|
|
ui_->notifications_play_mode->setChecked(s.value("ShowOnPlayModeChange", true).toBool());
|
2018-02-27 18:06:05 +01:00
|
|
|
ui_->notifications_pause->setChecked(s.value("ShowOnPausePlayback", true).toBool());
|
2019-06-29 19:54:27 +02:00
|
|
|
ui_->notifications_resume->setChecked(s.value("ShowOnResumePlayback", false).toBool());
|
2018-02-27 18:06:05 +01:00
|
|
|
ui_->notifications_art->setChecked(s.value("ShowArt", true).toBool());
|
|
|
|
ui_->notifications_custom_text_enabled->setChecked(s.value("CustomTextEnabled", false).toBool());
|
|
|
|
ui_->notifications_custom_text1->setText(s.value("CustomText1").toString());
|
|
|
|
ui_->notifications_custom_text2->setText(s.value("CustomText2").toString());
|
|
|
|
s.endGroup();
|
|
|
|
|
2018-07-01 22:26:46 +02:00
|
|
|
#ifdef Q_OS_MACOS
|
2018-02-27 18:06:05 +01:00
|
|
|
ui_->notifications_options->setEnabled(ui_->notifications_pretty->isChecked());
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Pretty OSD
|
|
|
|
pretty_popup_->ReloadSettings();
|
2021-03-21 18:53:02 +01:00
|
|
|
ui_->notifications_opacity->setValue(static_cast<int>(pretty_popup_->background_opacity() * 100));
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
QRgb color = pretty_popup_->background_color();
|
2021-08-23 21:21:08 +02:00
|
|
|
if (color == OSDPretty::kPresetBlue) {
|
2018-02-27 18:06:05 +01:00
|
|
|
ui_->notifications_bg_preset->setCurrentIndex(0);
|
2021-08-23 21:21:08 +02:00
|
|
|
}
|
|
|
|
else if (color == OSDPretty::kPresetRed) {
|
2018-02-27 18:06:05 +01:00
|
|
|
ui_->notifications_bg_preset->setCurrentIndex(1);
|
2021-08-23 21:21:08 +02:00
|
|
|
}
|
|
|
|
else {
|
2018-02-27 18:06:05 +01:00
|
|
|
ui_->notifications_bg_preset->setCurrentIndex(2);
|
2021-08-23 21:21:08 +02:00
|
|
|
}
|
2018-02-27 18:06:05 +01:00
|
|
|
ui_->notifications_bg_preset->setItemData(2, QColor(color), Qt::DecorationRole);
|
|
|
|
ui_->notifications_disable_duration->setChecked(pretty_popup_->disable_duration());
|
2021-04-13 17:26:54 +02:00
|
|
|
|
|
|
|
ui_->notifications_fading->setChecked(pretty_popup_->fading());
|
|
|
|
|
2018-02-27 18:06:05 +01:00
|
|
|
UpdatePopupVisible();
|
2019-07-09 19:49:15 +02:00
|
|
|
|
2020-05-25 23:56:54 +02:00
|
|
|
Init(ui_->layout_notificationssettingspage->parentWidget());
|
|
|
|
|
2020-10-12 17:20:18 +02:00
|
|
|
if (!QSettings().childGroups().contains(OSDBase::kSettingsGroup)) set_changed();
|
|
|
|
|
2018-02-27 18:06:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void NotificationsSettingsPage::Save() {
|
|
|
|
|
|
|
|
QSettings s;
|
|
|
|
|
2020-08-09 01:37:00 +02:00
|
|
|
OSDBase::Behaviour osd_behaviour = OSDBase::Disabled;
|
|
|
|
if (ui_->notifications_none->isChecked()) osd_behaviour = OSDBase::Disabled;
|
|
|
|
else if (ui_->notifications_native->isChecked()) osd_behaviour = OSDBase::Native;
|
|
|
|
else if (ui_->notifications_tray->isChecked()) osd_behaviour = OSDBase::TrayPopup;
|
|
|
|
else if (ui_->notifications_pretty->isChecked()) osd_behaviour = OSDBase::Pretty;
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2020-08-09 01:37:00 +02:00
|
|
|
s.beginGroup(OSDBase::kSettingsGroup);
|
2021-10-11 22:28:28 +02:00
|
|
|
s.setValue("Behaviour", static_cast<int>(osd_behaviour));
|
2018-02-27 18:06:05 +01:00
|
|
|
s.setValue("Timeout", ui_->notifications_duration->value() * 1000);
|
|
|
|
s.setValue("ShowOnVolumeChange", ui_->notifications_volume->isChecked());
|
|
|
|
s.setValue("ShowOnPlayModeChange", ui_->notifications_play_mode->isChecked());
|
|
|
|
s.setValue("ShowOnPausePlayback", ui_->notifications_pause->isChecked());
|
2019-06-29 19:54:27 +02:00
|
|
|
s.setValue("ShowOnResumePlayback", ui_->notifications_resume->isChecked());
|
2018-02-27 18:06:05 +01:00
|
|
|
s.setValue("ShowArt", ui_->notifications_art->isChecked());
|
|
|
|
s.setValue("CustomTextEnabled", ui_->notifications_custom_text_enabled->isChecked());
|
|
|
|
s.setValue("CustomText1", ui_->notifications_custom_text1->text());
|
|
|
|
s.setValue("CustomText2", ui_->notifications_custom_text2->text());
|
|
|
|
s.endGroup();
|
|
|
|
|
|
|
|
s.beginGroup(OSDPretty::kSettingsGroup);
|
|
|
|
s.setValue("foreground_color", pretty_popup_->foreground_color());
|
|
|
|
s.setValue("background_color", pretty_popup_->background_color());
|
|
|
|
s.setValue("background_opacity", pretty_popup_->background_opacity());
|
2019-07-09 19:49:15 +02:00
|
|
|
s.setValue("popup_screen", pretty_popup_->popup_screen());
|
2018-02-27 18:06:05 +01:00
|
|
|
s.setValue("popup_pos", pretty_popup_->popup_pos());
|
|
|
|
s.setValue("font", pretty_popup_->font().toString());
|
|
|
|
s.setValue("disable_duration", ui_->notifications_disable_duration->isChecked());
|
2021-04-13 17:26:54 +02:00
|
|
|
s.setValue("fading", ui_->notifications_fading->isChecked());
|
2018-02-27 18:06:05 +01:00
|
|
|
s.endGroup();
|
2019-07-09 19:49:15 +02:00
|
|
|
|
2018-02-27 18:06:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void NotificationsSettingsPage::PrettyOpacityChanged(int value) {
|
2020-06-05 23:46:07 +02:00
|
|
|
|
2022-06-13 00:23:42 +02:00
|
|
|
pretty_popup_->set_background_opacity(static_cast<qreal>(value) / 100.0);
|
2020-06-05 23:46:07 +02:00
|
|
|
set_changed();
|
|
|
|
|
2018-02-27 18:06:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void NotificationsSettingsPage::UpdatePopupVisible() {
|
2020-06-05 23:46:07 +02:00
|
|
|
|
2018-02-27 18:06:05 +01:00
|
|
|
pretty_popup_->setVisible(isVisible() && ui_->notifications_pretty->isChecked());
|
2020-06-05 23:46:07 +02:00
|
|
|
|
2018-02-27 18:06:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void NotificationsSettingsPage::PrettyColorPresetChanged(int index) {
|
|
|
|
|
|
|
|
if (dialog()->is_loading_settings()) return;
|
|
|
|
|
|
|
|
switch (index) {
|
|
|
|
case 0:
|
|
|
|
pretty_popup_->set_background_color(OSDPretty::kPresetBlue);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
2018-09-20 17:44:31 +02:00
|
|
|
pretty_popup_->set_background_color(OSDPretty::kPresetRed);
|
2018-02-27 18:06:05 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
default:
|
|
|
|
ChooseBgColor();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-06-05 23:46:07 +02:00
|
|
|
set_changed();
|
|
|
|
|
2018-02-27 18:06:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void NotificationsSettingsPage::ChooseBgColor() {
|
|
|
|
|
|
|
|
QColor color = QColorDialog::getColor(pretty_popup_->background_color(), this);
|
2021-08-23 21:21:08 +02:00
|
|
|
if (!color.isValid()) return;
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
pretty_popup_->set_background_color(color.rgb());
|
|
|
|
ui_->notifications_bg_preset->setItemData(2, color, Qt::DecorationRole);
|
|
|
|
|
2020-06-05 23:46:07 +02:00
|
|
|
set_changed();
|
|
|
|
|
2018-02-27 18:06:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void NotificationsSettingsPage::ChooseFgColor() {
|
|
|
|
|
|
|
|
QColor color = QColorDialog::getColor(pretty_popup_->foreground_color(), this);
|
2021-08-23 21:21:08 +02:00
|
|
|
if (!color.isValid()) return;
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
pretty_popup_->set_foreground_color(color.rgb());
|
|
|
|
|
2020-06-05 23:46:07 +02:00
|
|
|
set_changed();
|
|
|
|
|
2018-02-27 18:06:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void NotificationsSettingsPage::ChooseFont() {
|
|
|
|
|
2021-03-26 21:30:13 +01:00
|
|
|
bool ok = false;
|
2018-02-27 18:06:05 +01:00
|
|
|
QFont font = QFontDialog::getFont(&ok, pretty_popup_->font(), this);
|
2020-06-05 23:46:07 +02:00
|
|
|
if (ok) {
|
|
|
|
pretty_popup_->set_font(font);
|
|
|
|
set_changed();
|
|
|
|
}
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void NotificationsSettingsPage::NotificationCustomTextChanged(bool enabled) {
|
|
|
|
|
|
|
|
ui_->notifications_custom_text1->setEnabled(enabled);
|
|
|
|
ui_->notifications_custom_text2->setEnabled(enabled);
|
|
|
|
ui_->notifications_exp_chooser1->setEnabled(enabled);
|
|
|
|
ui_->notifications_exp_chooser2->setEnabled(enabled);
|
|
|
|
ui_->notifications_preview->setEnabled(enabled);
|
2019-03-27 01:23:15 +01:00
|
|
|
ui_->label_summary->setEnabled(enabled);
|
|
|
|
ui_->label_body->setEnabled(enabled);
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void NotificationsSettingsPage::PrepareNotificationPreview() {
|
|
|
|
|
2020-08-09 01:37:00 +02:00
|
|
|
OSDBase::Behaviour notificationType = OSDBase::Disabled;
|
2018-02-27 18:06:05 +01:00
|
|
|
if (ui_->notifications_native->isChecked()) {
|
2020-08-09 01:37:00 +02:00
|
|
|
notificationType = OSDBase::Native;
|
2018-02-27 18:06:05 +01:00
|
|
|
}
|
|
|
|
else if (ui_->notifications_pretty->isChecked()) {
|
2020-08-09 01:37:00 +02:00
|
|
|
notificationType = OSDBase::Pretty;
|
2018-02-27 18:06:05 +01:00
|
|
|
}
|
|
|
|
else if (ui_->notifications_tray->isChecked()) {
|
2020-08-09 01:37:00 +02:00
|
|
|
notificationType = OSDBase::TrayPopup;
|
2018-02-27 18:06:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// If user changes timeout or other options, that won't be reflected in the preview
|
|
|
|
emit NotificationPreview(notificationType, ui_->notifications_custom_text1->text(), ui_->notifications_custom_text2->text());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-06-12 20:53:23 +02:00
|
|
|
void NotificationsSettingsPage::InsertVariableFirstLine(QAction *action) {
|
2018-02-27 18:06:05 +01:00
|
|
|
// We use action name, therefore those shouldn't be translatable
|
|
|
|
ui_->notifications_custom_text1->insert(action->text());
|
|
|
|
}
|
|
|
|
|
2021-06-12 20:53:23 +02:00
|
|
|
void NotificationsSettingsPage::InsertVariableSecondLine(QAction *action) {
|
2018-02-27 18:06:05 +01:00
|
|
|
// We use action name, therefore those shouldn't be translatable
|
|
|
|
ui_->notifications_custom_text2->insert(action->text());
|
|
|
|
}
|
|
|
|
|
2021-06-12 20:53:23 +02:00
|
|
|
void NotificationsSettingsPage::ShowMenuTooltip(QAction *action) {
|
2018-02-27 18:06:05 +01:00
|
|
|
QToolTip::showText(QCursor::pos(), action->toolTip());
|
|
|
|
}
|
|
|
|
|
|
|
|
void NotificationsSettingsPage::NotificationTypeChanged() {
|
|
|
|
|
|
|
|
bool enabled = !ui_->notifications_none->isChecked();
|
|
|
|
bool pretty = ui_->notifications_pretty->isChecked();
|
2019-04-20 23:15:34 +02:00
|
|
|
bool tray = ui_->notifications_tray->isChecked();
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
ui_->notifications_general->setEnabled(enabled);
|
|
|
|
ui_->notifications_pretty_group->setEnabled(pretty);
|
|
|
|
ui_->notifications_custom_text_group->setEnabled(enabled);
|
2019-04-20 23:15:34 +02:00
|
|
|
ui_->notifications_art->setEnabled(!tray);
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2018-07-01 22:26:46 +02:00
|
|
|
#ifdef Q_OS_MACOS
|
2018-02-27 18:06:05 +01:00
|
|
|
ui_->notifications_options->setEnabled(pretty);
|
|
|
|
#endif
|
2019-04-08 18:46:11 +02:00
|
|
|
ui_->notifications_duration->setEnabled(!pretty || !ui_->notifications_disable_duration->isChecked());
|
2018-02-27 18:06:05 +01:00
|
|
|
ui_->notifications_disable_duration->setEnabled(pretty);
|
|
|
|
|
|
|
|
}
|
2020-06-05 23:46:07 +02:00
|
|
|
|
|
|
|
void NotificationsSettingsPage::PrettyOSDChanged() {
|
|
|
|
set_changed();
|
|
|
|
}
|