save current primary backend

This commit is contained in:
Patrick von Reth 2015-02-03 16:52:30 +01:00
parent 5b4229224e
commit 8cf88a448d
9 changed files with 46 additions and 29 deletions

View File

@ -161,12 +161,16 @@ bool SnoreCore::setPrimaryNotificationBackend(const QString &backend)
}
d->m_notificationBackend = b;
settings()->setValue("PrimaryBackend", backend);
return true;
}
bool SnoreCore::setPrimaryNotificationBackend()
{
Q_D(SnoreCore);
if (d->setBackendIfAvailible(settings()->value("PrimaryBackend").toString())) {
return true;
}
#ifdef Q_OS_WIN
if (QSysInfo::windowsVersion() >= QSysInfo::WV_WINDOWS8 && d->setBackendIfAvailible("Windows 8")) {
return true;

View File

@ -31,6 +31,10 @@ SettingsDialog::SettingsDialog(SnoreCore *snore, QWidget *parent) :
m_snore(snore)
{
ui->setupUi(this);
QStringList list = snore->pluginNames(SnorePlugin::BACKEND);
ui->primaryBackendComboBox->addItems(list);
ui->primaryBackendComboBox->setCurrentIndex(list.indexOf(snore->primaryNotificationBackend()));
for (auto widget : snore->settingWidgets()) {
ui->tabWidget->addTab(widget, widget->name());
widget->loadSettings();
@ -45,6 +49,7 @@ SettingsDialog::~SettingsDialog()
void SettingsDialog::on_buttonBox_accepted()
{
m_snore->setPrimaryNotificationBackend(ui->primaryBackendComboBox->currentText());
for (auto w : m_tabs) {
w->saveSettings();
}

View File

@ -21,8 +21,29 @@
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>-1</number>
<number>0</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>Page</string>
</attribute>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="primaryBackendLabel">
<property name="text">
<string>Primary Backend:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="primaryBackendComboBox"/>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
<item>

View File

@ -49,24 +49,13 @@ void TrayIcon::initConextMenu(SnoreCore *snore)
m_trayMenu = new QMenu("SnoreNotify");
QString version = QString("SnoreNotify %1").arg(Version::version());
if (Version::revision() != "") {
if (!Version::revision().isEmpty()) {
version += QString("-%1").arg(Version::revision());
}
m_trayMenu->addAction(version);
m_trayMenu->addSeparator();
m_trayMenu->addAction("Test Notification", this, SLOT(slotTestNotification()));
m_trayMenu->addSeparator();
m_backendActions = new QActionGroup(m_trayMenu);
m_backendActions->setExclusive(true);
for (const QString &back : m_snore->pluginNames(SnorePlugin::BACKEND)) {
QAction *b = m_trayMenu->addAction(back, this, SLOT(setPrimaryBackend()));
b->setCheckable(true);
if (back == m_snore->primaryNotificationBackend()) {
b->setChecked(true);
}
m_backendActions->addAction(b);
}
m_trayMenu->addSeparator();
m_trayMenu->addAction("Settings", this, SLOT(slotSettings()));
m_trayMenu->addSeparator();
m_trayMenu->addAction("Exit", qApp, SLOT(quit()));

View File

@ -23,8 +23,8 @@ bool FreedesktopBackend::initialize(SnoreCore *snore)
reply.waitForFinished();
QStringList caps = reply.value();
setSupportsRichtext(caps.contains("body-markup"));
connect(m_interface, SIGNAL(ActionInvoked(uint, QString)), this, SLOT(slotActionInvoked(uint, QString)));
connect(m_interface, SIGNAL(NotificationClosed(uint, uint)), this , SLOT(slotNotificationClosed(uint, uint)));
connect(m_interface, SIGNAL(ActionInvoked(uint,QString)), this, SLOT(slotActionInvoked(uint,QString)));
connect(m_interface, SIGNAL(NotificationClosed(uint,uint)), this , SLOT(slotNotificationClosed(uint,uint)));
return SnoreBackend::initialize(snore);
}
@ -32,8 +32,8 @@ bool FreedesktopBackend::initialize(SnoreCore *snore)
bool FreedesktopBackend::deinitialize()
{
if (SnoreBackend::deinitialize()) {
disconnect(m_interface, SIGNAL(ActionInvoked(uint, QString)), this, SLOT(slotActionInvoked(uint, QString)));
disconnect(m_interface, SIGNAL(NotificationClosed(uint, uint)), this , SLOT(slotNotificationClosed(uint, uint)));
disconnect(m_interface, SIGNAL(ActionInvoked(uint,QString)), this, SLOT(slotActionInvoked(uint,QString)));
disconnect(m_interface, SIGNAL(NotificationClosed(uint,uint)), this , SLOT(slotNotificationClosed(uint,uint)));
m_interface->deleteLater();
m_interface = NULL;
return true;

View File

@ -36,7 +36,7 @@ void SnoreToast::slotNotify(Notification notification)
QProcess *p = new QProcess(this);
p->setReadChannelMode(QProcess::MergedChannels);
connect(p, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(slotToastNotificationClosed(int, QProcess::ExitStatus)));
connect(p, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(slotToastNotificationClosed(int,QProcess::ExitStatus)));
connect(qApp, SIGNAL(aboutToQuit()), p, SLOT(kill()));
QStringList arguements;
@ -77,7 +77,7 @@ void SnoreToast::slotRegisterApplication(const Application &application)
snoreDebug(SNORE_DEBUG) << "SnoreToast" << arguements;
p->start("SnoreToast", arguements);
connect(p, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(slotPrintExitStatus(int, QProcess::ExitStatus)));
connect(p, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(slotPrintExitStatus(int,QProcess::ExitStatus)));
connect(qApp, SIGNAL(aboutToQuit()), p, SLOT(kill()));
}
}
@ -93,7 +93,7 @@ void SnoreToast::slotCloseNotification(Notification notification)
snoreDebug(SNORE_DEBUG) << "SnoreToast" << arguements;
p->start("SnoreToast", arguements);
connect(p, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(slotPrintExitStatus(int, QProcess::ExitStatus)));
connect(p, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(slotPrintExitStatus(int,QProcess::ExitStatus)));
connect(qApp, SIGNAL(aboutToQuit()), p, SLOT(kill()));
}

View File

@ -30,9 +30,9 @@ Sound::Sound():
// connect(m_player,QMediaPlayer::positionChanged,[](qint64 pos){
// snoreDebug(SNORE_DEBUG) << "Player: " << pos;
// });
// connect(m_player,QMediaPlayer::stateChanged,[](QMediaPlayer::State state){
// snoreDebug(SNORE_DEBUG) << "Player: " << state;
// });
connect(m_player, &QMediaPlayer::stateChanged, [](QMediaPlayer::State state) {
snoreDebug(SNORE_DEBUG) << "Player: " << state;
});
}
Sound::~Sound()
@ -47,6 +47,10 @@ PluginSettingsWidget *Sound::settingsWidget()
void Sound::slotNotify(Snore::Notification notification)
{
if (notification.hints().value("silent", false).toBool()) {
return;
}
QString sound = notification.hints().value("sound").toString();
if (sound.isEmpty()) {
sound = value("Sound").toString();

View File

@ -95,11 +95,6 @@ bool Toasty::initialize()
return false;
}
bool Toasty::deinitialize()
{
return SnoreSecondaryBackend::deinitialize();
}
PluginSettingsWidget *Toasty::settingsWidget()
{
return new ToastySettings(this);

View File

@ -31,7 +31,6 @@ public:
Toasty();
~Toasty();
bool initialize() override;
bool deinitialize() override;
Snore::PluginSettingsWidget *settingsWidget() override;