fix regression in new version testing upon startup, enhance notifications
This commit is contained in:
parent
52017bbeb9
commit
5f339db411
@ -30,7 +30,7 @@
|
||||
<url type="donation">https://martinrotter.github.io/donate/</url>
|
||||
<content_rating type="oars-1.1" />
|
||||
<releases>
|
||||
<release version="3.9.2" date="2021-06-18"/>
|
||||
<release version="3.9.2" date="2021-06-21"/>
|
||||
</releases>
|
||||
<content_rating type="oars-1.0">
|
||||
<content_attribute id="violence-cartoon">none</content_attribute>
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 9c10723bfbaf6cb85107d6ee16e0324e9e487749
|
||||
Subproject commit 47f4125753452eff8800dbd6600c5a05540b15d9
|
@ -39,7 +39,7 @@ void NotificationsEditor::loadNotifications(const QList<Notification>& notificat
|
||||
}
|
||||
}
|
||||
|
||||
m_layout->addSpacerItem(new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding));
|
||||
m_layout->addSpacerItem(new QSpacerItem(20, 40, QSizePolicy::Policy::Minimum, QSizePolicy::Policy::Expanding));
|
||||
}
|
||||
|
||||
QList<Notification> NotificationsEditor::allNotifications() const {
|
||||
|
@ -5,16 +5,21 @@
|
||||
#include "miscellaneous/application.h"
|
||||
#include "miscellaneous/iconfactory.h"
|
||||
|
||||
#include <QFileDialog>
|
||||
|
||||
SingleNotificationEditor::SingleNotificationEditor(const Notification& notification, QWidget* parent)
|
||||
: QWidget(parent), m_notificationEvent(Notification::Event::NoEvent) {
|
||||
: QGroupBox(parent), m_notificationEvent(Notification::Event::NoEvent) {
|
||||
m_ui.setupUi(this);
|
||||
|
||||
m_ui.m_btnBrowseSound->setIcon(qApp->icons()->fromTheme(QSL("document-open")));
|
||||
m_ui.m_btnClearSound->setIcon(qApp->icons()->fromTheme(QSL("edit-clear")));
|
||||
m_ui.m_btnPlaySound->setIcon(qApp->icons()->fromTheme(QSL("media-playback-start")));
|
||||
|
||||
loadNotification(notification);
|
||||
|
||||
connect(m_ui.m_btnPlaySound, &QPushButton::clicked, this, &SingleNotificationEditor::playSound);
|
||||
connect(m_ui.m_btnBrowseSound, &QPushButton::clicked, this, &SingleNotificationEditor::selectSoundFile);
|
||||
connect(m_ui.m_btnClearSound, &QPushButton::clicked, m_ui.m_txtSound, &QLineEdit::clear);
|
||||
connect(m_ui.m_txtSound, &QLineEdit::textChanged, this, &SingleNotificationEditor::notificationChanged);
|
||||
connect(m_ui.m_cbBalloon, &QCheckBox::toggled, this, &SingleNotificationEditor::notificationChanged);
|
||||
}
|
||||
@ -23,6 +28,16 @@ Notification SingleNotificationEditor::notification() const {
|
||||
return Notification(m_notificationEvent, m_ui.m_cbBalloon->isChecked(), m_ui.m_txtSound->text());
|
||||
}
|
||||
|
||||
void SingleNotificationEditor::selectSoundFile() {
|
||||
auto fil = QFileDialog::getOpenFileName(window(), tr("Select sound file"),
|
||||
qApp->homeFolder(),
|
||||
tr("WAV files (*.wav)"));
|
||||
|
||||
if (!fil.isEmpty()) {
|
||||
m_ui.m_txtSound->setText(fil);
|
||||
}
|
||||
}
|
||||
|
||||
void SingleNotificationEditor::playSound() {
|
||||
Notification({}, {}, m_ui.m_txtSound->text()).playSound(qApp);
|
||||
}
|
||||
@ -30,7 +45,7 @@ void SingleNotificationEditor::playSound() {
|
||||
void SingleNotificationEditor::loadNotification(const Notification& notification) {
|
||||
m_ui.m_txtSound->setText(notification.soundPath());
|
||||
m_ui.m_cbBalloon->setChecked(notification.balloonEnabled());
|
||||
m_ui.m_gbNotification->setTitle(Notification::nameForEvent(notification.event()));
|
||||
setTitle(Notification::nameForEvent(notification.event()));
|
||||
|
||||
m_notificationEvent = notification.event();
|
||||
}
|
||||
|
@ -3,13 +3,13 @@
|
||||
#ifndef SINGLENOTIFICATIONEDITOR_H
|
||||
#define SINGLENOTIFICATIONEDITOR_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QGroupBox>
|
||||
|
||||
#include "ui_singlenotificationeditor.h"
|
||||
|
||||
#include "miscellaneous/notification.h"
|
||||
|
||||
class SingleNotificationEditor : public QWidget {
|
||||
class SingleNotificationEditor : public QGroupBox {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
@ -21,6 +21,7 @@ class SingleNotificationEditor : public QWidget {
|
||||
void notificationChanged();
|
||||
|
||||
private slots:
|
||||
void selectSoundFile();
|
||||
void playSound();
|
||||
|
||||
private:
|
||||
|
@ -1,13 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>SingleNotificationEditor</class>
|
||||
<widget class="QWidget" name="SingleNotificationEditor">
|
||||
<widget class="QGroupBox" name="SingleNotificationEditor">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>125</height>
|
||||
<width>353</width>
|
||||
<height>65</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
@ -16,74 +16,66 @@
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="m_gbNotification">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Sound</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>m_txtSound</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="m_txtSound">
|
||||
<property name="placeholderText">
|
||||
<string>Full path to your WAV sound file</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="m_btnClearSound">
|
||||
<property name="text">
|
||||
<string>&Clear</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="m_btnBrowseSound">
|
||||
<property name="text">
|
||||
<string>&Browse</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="m_btnPlaySound">
|
||||
<property name="text">
|
||||
<string>&Play</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="m_cbBalloon">
|
||||
<property name="text">
|
||||
<string>Balloon notification</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Sound</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>m_txtSound</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="m_txtSound">
|
||||
<property name="placeholderText">
|
||||
<string>Full path to your WAV sound file</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="m_btnBrowseSound">
|
||||
<property name="text">
|
||||
<string>&Browse</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="m_btnPlaySound">
|
||||
<property name="text">
|
||||
<string>&Play</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="m_cbBalloon">
|
||||
<property name="text">
|
||||
<string>Balloon notification</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
@ -91,6 +83,7 @@
|
||||
<tabstops>
|
||||
<tabstop>m_cbBalloon</tabstop>
|
||||
<tabstop>m_txtSound</tabstop>
|
||||
<tabstop>m_btnClearSound</tabstop>
|
||||
<tabstop>m_btnBrowseSound</tabstop>
|
||||
<tabstop>m_btnPlaySound</tabstop>
|
||||
</tabstops>
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include <QProcess>
|
||||
#include <QSessionManager>
|
||||
#include <QSslSocket>
|
||||
#include <QtConcurrent/QtConcurrentRun>
|
||||
#include <QTimer>
|
||||
|
||||
#if defined(USE_WEBENGINE)
|
||||
@ -91,13 +92,17 @@ Application::Application(const QString& id, int& argc, char** argv)
|
||||
m_notifications->save({
|
||||
Notification(Notification::Event::NewArticlesFetched,
|
||||
true,
|
||||
QSL("%1/rooster.wav").arg(SOUNDS_BUILTIN_DIRECTORY))
|
||||
QSL("%1/rooster.wav").arg(SOUNDS_BUILTIN_DIRECTORY)),
|
||||
Notification(Notification::Event::NewAppVersionAvailable,
|
||||
true)
|
||||
}, settings());
|
||||
}
|
||||
else {
|
||||
m_notifications->load(settings());
|
||||
}
|
||||
|
||||
QTimer::singleShot(1000, system(), &SystemFactory::checkForUpdatesOnStartup);
|
||||
|
||||
qDebugNN << LOGSEC_CORE
|
||||
<< "OpenSSL version:"
|
||||
<< QUOTE_W_SPACE_DOT(QSslSocket::sslLibraryVersionString());
|
||||
|
@ -71,8 +71,8 @@ QList<ServiceEntryPoint*> FeedReader::feedServices() {
|
||||
void FeedReader::updateFeeds(const QList<Feed*>& feeds) {
|
||||
if (!qApp->feedUpdateLock()->tryLock()) {
|
||||
qApp->showGuiMessage(Notification::Event::GeneralEvent,
|
||||
tr("Cannot update all items"),
|
||||
tr("You cannot download new messages for your items "
|
||||
tr("Cannot fetch articles for all items"),
|
||||
tr("You cannot fetch new articles for your items "
|
||||
"because another critical operation is ongoing."),
|
||||
QSystemTrayIcon::MessageIcon::Warning,
|
||||
true);
|
||||
|
@ -34,9 +34,11 @@ void Notification::playSound(Application* app) const {
|
||||
|
||||
QList<Notification::Event> Notification::allEvents() {
|
||||
return {
|
||||
Event::GeneralEvent,
|
||||
Event::NewArticlesFetched,
|
||||
Event::ArticlesFetchingStarted,
|
||||
Event::LoginDataRefreshed
|
||||
Event::LoginDataRefreshed,
|
||||
Event::NewAppVersionAvailable,
|
||||
};
|
||||
}
|
||||
|
||||
@ -51,12 +53,17 @@ QString Notification::nameForEvent(Notification::Event event) {
|
||||
case Notification::Event::LoginDataRefreshed:
|
||||
return QObject::tr("Login data refreshed");
|
||||
|
||||
case Notification::Event::NewAppVersionAvailable:
|
||||
return QObject::tr("New %1 version is available").arg(APP_NAME);
|
||||
|
||||
case Notification::Event::GeneralEvent:
|
||||
return QObject::tr("Miscellaneous events");
|
||||
|
||||
default:
|
||||
return QObject::tr("Unknown event");
|
||||
}
|
||||
}
|
||||
|
||||
bool Notification::balloonEnabled() const
|
||||
{
|
||||
bool Notification::balloonEnabled() const {
|
||||
return m_balloonEnabled;
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ class Notification {
|
||||
// OAuth or similar mechanism.
|
||||
LoginDataRefreshed = 4,
|
||||
|
||||
// TODO: app update is available
|
||||
NewAppVersionAvailable = 5
|
||||
};
|
||||
|
||||
explicit Notification(Event event = Event::NoEvent, bool balloon = {}, const QString& sound_path = {});
|
||||
|
@ -224,9 +224,10 @@ void SystemFactory::checkForUpdatesOnStartup() {
|
||||
this, [&](QPair<QList<UpdateInfo>, QNetworkReply::NetworkError> updates) {
|
||||
QObject::disconnect(qApp->system(), &SystemFactory::updatesChecked, this, nullptr);
|
||||
|
||||
if (!updates.first.isEmpty() && updates.second == QNetworkReply::NetworkError::NoError &&
|
||||
if (!updates.first.isEmpty() &&
|
||||
updates.second == QNetworkReply::NetworkError::NoError &&
|
||||
SystemFactory::isVersionNewer(updates.first.at(0).m_availableVersion, APP_VERSION)) {
|
||||
qApp->showGuiMessage(Notification::Event::GeneralEvent,
|
||||
qApp->showGuiMessage(Notification::Event::NewAppVersionAvailable,
|
||||
QObject::tr("New version available"),
|
||||
QObject::tr("Click the bubble for more information."),
|
||||
QSystemTrayIcon::Information, {}, {},
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include <QMetaType>
|
||||
#include <QNetworkReply>
|
||||
#include <QPair>
|
||||
#include <QRegularExpression>
|
||||
|
||||
class UpdateUrl {
|
||||
public:
|
||||
@ -26,7 +27,6 @@ class UpdateInfo {
|
||||
QString m_availableVersion;
|
||||
QString m_changes;
|
||||
QDateTime m_date;
|
||||
|
||||
QList<UpdateUrl> m_urls;
|
||||
};
|
||||
|
||||
@ -60,7 +60,6 @@ class SystemFactory : public QObject {
|
||||
#endif
|
||||
|
||||
#if defined(Q_OS_LINUX)
|
||||
|
||||
// Returns standard location where auto-start .desktop files
|
||||
// should be placed.
|
||||
QString autostartDesktopFileLocation() const;
|
||||
@ -72,6 +71,7 @@ class SystemFactory : public QObject {
|
||||
// Tries to download list with new updates.
|
||||
void checkForUpdates() const;
|
||||
|
||||
public slots:
|
||||
void checkForUpdatesOnStartup();
|
||||
|
||||
static QRegularExpression supportedUpdateFiles();
|
||||
|
Loading…
x
Reference in New Issue
Block a user