better code flow when app starts + correctly show number badge when tray icon is active on windows startup + correctly show tray messages on app startup + remove some redundant code
This commit is contained in:
parent
81f4b1102b
commit
c76320fbcd
@ -19,7 +19,7 @@
|
|||||||
#include <QPlainTextEdit>
|
#include <QPlainTextEdit>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
|
|
||||||
FormAbout::FormAbout(QWidget* parent) : QDialog(parent) {
|
FormAbout::FormAbout(bool go_to_changelog, QWidget* parent) : QDialog(parent) {
|
||||||
m_ui.setupUi(this);
|
m_ui.setupUi(this);
|
||||||
m_ui.m_lblIcon->setPixmap(QPixmap(APP_ICON_PATH));
|
m_ui.m_lblIcon->setPixmap(QPixmap(APP_ICON_PATH));
|
||||||
GuiUtilities::applyDialogProperties(*this,
|
GuiUtilities::applyDialogProperties(*this,
|
||||||
@ -27,6 +27,10 @@ FormAbout::FormAbout(QWidget* parent) : QDialog(parent) {
|
|||||||
tr("About %1").arg(QSL(APP_NAME)));
|
tr("About %1").arg(QSL(APP_NAME)));
|
||||||
loadLicenseAndInformation();
|
loadLicenseAndInformation();
|
||||||
loadSettingsAndPaths();
|
loadSettingsAndPaths();
|
||||||
|
|
||||||
|
if (go_to_changelog) {
|
||||||
|
m_ui.m_tabAbout->setCurrentWidget(m_ui.m_tabChangelog);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FormAbout::~FormAbout() {}
|
FormAbout::~FormAbout() {}
|
||||||
|
@ -8,10 +8,10 @@
|
|||||||
#include "ui_formabout.h"
|
#include "ui_formabout.h"
|
||||||
|
|
||||||
class RSSGUARD_DLLSPEC FormAbout : public QDialog {
|
class RSSGUARD_DLLSPEC FormAbout : public QDialog {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit FormAbout(QWidget* parent);
|
explicit FormAbout(bool go_to_changelog, QWidget* parent);
|
||||||
virtual ~FormAbout();
|
virtual ~FormAbout();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
@ -768,7 +768,7 @@ void FormMain::createConnections() {
|
|||||||
|
|
||||||
// Menu "Help" connections.
|
// Menu "Help" connections.
|
||||||
connect(m_ui->m_actionAboutGuard, &QAction::triggered, this, [this]() {
|
connect(m_ui->m_actionAboutGuard, &QAction::triggered, this, [this]() {
|
||||||
FormAbout(this).exec();
|
FormAbout(false, this).exec();
|
||||||
});
|
});
|
||||||
connect(m_ui->m_actionCheckForUpdates, &QAction::triggered, this, [this]() {
|
connect(m_ui->m_actionCheckForUpdates, &QAction::triggered, this, [this]() {
|
||||||
FormUpdate(this).exec();
|
FormUpdate(this).exec();
|
||||||
|
@ -710,15 +710,6 @@ void MessagesView::selectItemWithCursorAction(CursorAction act) {
|
|||||||
|
|
||||||
if (index_previous.isValid()) {
|
if (index_previous.isValid()) {
|
||||||
setCurrentIndex(index_previous);
|
setCurrentIndex(index_previous);
|
||||||
|
|
||||||
scrollTo(index_previous,
|
|
||||||
!m_processingAnyMouseButton &&
|
|
||||||
qApp->settings()->value(GROUP(Messages), SETTING(Messages::KeepCursorInCenter)).toBool()
|
|
||||||
? QAbstractItemView::ScrollHint::PositionAtCenter
|
|
||||||
: QAbstractItemView::ScrollHint::PositionAtTop);
|
|
||||||
|
|
||||||
selectionModel()->select(index_previous,
|
|
||||||
QItemSelectionModel::SelectionFlag::Select | QItemSelectionModel::SelectionFlag::Rows);
|
|
||||||
setFocus();
|
setFocus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -738,21 +729,7 @@ void MessagesView::selectNextUnreadItem() {
|
|||||||
const QModelIndex next_unread = m_proxyModel->getNextPreviousUnreadItemIndex(active_row);
|
const QModelIndex next_unread = m_proxyModel->getNextPreviousUnreadItemIndex(active_row);
|
||||||
|
|
||||||
if (next_unread.isValid()) {
|
if (next_unread.isValid()) {
|
||||||
// We found unread message, mark it.
|
|
||||||
setCurrentIndex(next_unread);
|
setCurrentIndex(next_unread);
|
||||||
|
|
||||||
// Make sure that item is properly visible even if
|
|
||||||
// message previewer was hidden and shows up.
|
|
||||||
qApp->processEvents();
|
|
||||||
|
|
||||||
scrollTo(next_unread,
|
|
||||||
!m_processingAnyMouseButton &&
|
|
||||||
qApp->settings()->value(GROUP(Messages), SETTING(Messages::KeepCursorInCenter)).toBool()
|
|
||||||
? QAbstractItemView::ScrollHint::PositionAtCenter
|
|
||||||
: QAbstractItemView::ScrollHint::PositionAtTop);
|
|
||||||
|
|
||||||
selectionModel()->select(next_unread,
|
|
||||||
QItemSelectionModel::SelectionFlag::Select | QItemSelectionModel::SelectionFlag::Rows);
|
|
||||||
setFocus();
|
setFocus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -299,8 +299,10 @@ void Application::showPolls() const {
|
|||||||
{QSL("%1 survey").arg(QSL(APP_NAME)),
|
{QSL("%1 survey").arg(QSL(APP_NAME)),
|
||||||
QSL("Please, fill the survey."),
|
QSL("Please, fill the survey."),
|
||||||
QSystemTrayIcon::MessageIcon::Warning},
|
QSystemTrayIcon::MessageIcon::Warning},
|
||||||
{false, true, false});
|
{false, true, false},
|
||||||
qApp->web()->openUrlInExternalBrowser(QSL("https://forms.gle/FdzrwFGozCGViK8QA"));
|
{tr("Go to survey"), [] {
|
||||||
|
qApp->web()->openUrlInExternalBrowser(QSL("https://forms.gle/FdzrwFGozCGViK8QA"));
|
||||||
|
}});
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
@ -312,10 +314,10 @@ void Application::offerChanges() const {
|
|||||||
tr("Welcome to %1.\n\nPlease, check NEW stuff included in this\n"
|
tr("Welcome to %1.\n\nPlease, check NEW stuff included in this\n"
|
||||||
"version by clicking this popup notification.")
|
"version by clicking this popup notification.")
|
||||||
.arg(QSL(APP_LONG_NAME)),
|
.arg(QSL(APP_LONG_NAME)),
|
||||||
QSystemTrayIcon::MessageIcon::NoIcon},
|
QSystemTrayIcon::MessageIcon::Information},
|
||||||
{},
|
{},
|
||||||
{tr("Go to changelog"), [] {
|
{tr("Go to changelog"), [] {
|
||||||
FormAbout(qApp->mainForm()).exec();
|
FormAbout(true, qApp->mainForm()).exec();
|
||||||
}});
|
}});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -607,27 +609,28 @@ void Application::showTrayIcon() {
|
|||||||
if (SystemTrayIcon::isSystemTrayDesired()) {
|
if (SystemTrayIcon::isSystemTrayDesired()) {
|
||||||
qDebugNN << LOGSEC_GUI << "User wants to have tray icon.";
|
qDebugNN << LOGSEC_GUI << "User wants to have tray icon.";
|
||||||
|
|
||||||
#if defined(Q_OS_WIN)
|
|
||||||
if (SystemTrayIcon::isSystemTrayAreaAvailable()) {
|
|
||||||
qDebugNN << LOGSEC_GUI << "Tray icon is available, showing now.";
|
|
||||||
trayIcon()->show();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
m_feedReader->feedsModel()->notifyWithCounts();
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
// Delay avoids race conditions and tray icon is properly displayed.
|
// Delay avoids race conditions and tray icon is properly displayed.
|
||||||
qWarningNN << LOGSEC_GUI << "Showing tray icon with 3000 ms delay.";
|
qWarningNN << LOGSEC_GUI << "Showing tray icon with little delay.";
|
||||||
QTimer::singleShot(3000, this, [=]() {
|
|
||||||
if (SystemTrayIcon::isSystemTrayAreaAvailable()) {
|
QTimer::singleShot(
|
||||||
qWarningNN << LOGSEC_GUI << "Tray icon is available, showing now.";
|
#if defined(Q_OS_WIN)
|
||||||
trayIcon()->show();
|
500,
|
||||||
}
|
#else
|
||||||
else {
|
3000,
|
||||||
m_feedReader->feedsModel()->notifyWithCounts();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
#endif
|
#endif
|
||||||
|
this,
|
||||||
|
[=]() {
|
||||||
|
if (SystemTrayIcon::isSystemTrayAreaAvailable()) {
|
||||||
|
qWarningNN << LOGSEC_GUI << "Tray icon is available, showing now.";
|
||||||
|
trayIcon()->show();
|
||||||
|
|
||||||
|
offerChanges();
|
||||||
|
showPolls();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
m_feedReader->feedsModel()->notifyWithCounts();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_feedReader->feedsModel()->notifyWithCounts();
|
m_feedReader->feedsModel()->notifyWithCounts();
|
||||||
@ -651,7 +654,6 @@ void Application::showGuiMessage(Notification::Event event,
|
|||||||
const GuiMessageDestination& dest,
|
const GuiMessageDestination& dest,
|
||||||
const GuiAction& action,
|
const GuiAction& action,
|
||||||
QWidget* parent) {
|
QWidget* parent) {
|
||||||
|
|
||||||
if (SystemTrayIcon::areNotificationsEnabled()) {
|
if (SystemTrayIcon::areNotificationsEnabled()) {
|
||||||
auto notification = m_notifications->notificationForEvent(event);
|
auto notification = m_notifications->notificationForEvent(event);
|
||||||
|
|
||||||
@ -796,25 +798,34 @@ void Application::showMessagesNumber(int unread_messages, bool any_feed_has_new_
|
|||||||
bool task_bar_count_enabled = settings()->value(GROUP(GUI), SETTING(GUI::UnreadNumbersOnTaskBar)).toBool();
|
bool task_bar_count_enabled = settings()->value(GROUP(GUI), SETTING(GUI::UnreadNumbersOnTaskBar)).toBool();
|
||||||
|
|
||||||
if (m_mainForm != nullptr) {
|
if (m_mainForm != nullptr) {
|
||||||
QImage overlay_icon = generateOverlayIcon(unread_messages);
|
bool any_count = task_bar_count_enabled && unread_messages > 0;
|
||||||
|
HRESULT overlay_result;
|
||||||
|
|
||||||
|
if (any_count) {
|
||||||
|
QImage overlay_icon = generateOverlayIcon(unread_messages);
|
||||||
|
|
||||||
#if QT_VERSION_MAJOR == 5
|
#if QT_VERSION_MAJOR == 5
|
||||||
HICON overlay_hicon = QtWin::toHICON(QPixmap::fromImage(overlay_icon));
|
HICON overlay_hicon = QtWin::toHICON(QPixmap::fromImage(overlay_icon));
|
||||||
#else
|
#else
|
||||||
HICON overlay_hicon = overlay_icon.toHICON();
|
HICON overlay_hicon = overlay_icon.toHICON();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
HRESULT overlay_result =
|
overlay_result =
|
||||||
m_windowsTaskBar->SetOverlayIcon(reinterpret_cast<HWND>(m_mainForm->winId()),
|
m_windowsTaskBar->SetOverlayIcon(reinterpret_cast<HWND>(m_mainForm->winId()), overlay_hicon, nullptr);
|
||||||
(task_bar_count_enabled && unread_messages > 0) ? overlay_hicon : nullptr,
|
|
||||||
nullptr);
|
|
||||||
|
|
||||||
DestroyIcon(overlay_hicon);
|
DestroyIcon(overlay_hicon);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
overlay_result = m_windowsTaskBar->SetOverlayIcon(reinterpret_cast<HWND>(m_mainForm->winId()), nullptr, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
if (FAILED(overlay_result)) {
|
if (FAILED(overlay_result)) {
|
||||||
qCriticalNN << LOGSEC_CORE << "Failed to set overlay icon with HRESULT:" << QUOTE_W_SPACE_DOT(overlay_result);
|
qCriticalNN << LOGSEC_GUI << "Failed to set overlay icon with HRESULT:" << QUOTE_W_SPACE_DOT(overlay_result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
qCriticalNN << LOGSEC_GUI << "Main form not set for setting numbers.";
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (m_mainForm != nullptr) {
|
if (m_mainForm != nullptr) {
|
||||||
|
@ -111,8 +111,6 @@ int main(int argc, char* argv[]) {
|
|||||||
qApp->feedReader()->loadSavedMessageFilters();
|
qApp->feedReader()->loadSavedMessageFilters();
|
||||||
qApp->feedReader()->feedsModel()->loadActivatedServiceAccounts();
|
qApp->feedReader()->feedsModel()->loadActivatedServiceAccounts();
|
||||||
qApp->showTrayIcon();
|
qApp->showTrayIcon();
|
||||||
qApp->offerChanges();
|
|
||||||
qApp->showPolls();
|
|
||||||
|
|
||||||
main_window.tabWidget()->feedMessageViewer()->respondToMainWindowResizes();
|
main_window.tabWidget()->feedMessageViewer()->respondToMainWindowResizes();
|
||||||
main_window.tabWidget()->feedMessageViewer()->feedsView()->loadAllExpandStates();
|
main_window.tabWidget()->feedMessageViewer()->feedsView()->loadAllExpandStates();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user