diff options
author | 2023-05-20 21:22:01 +0530 | |
---|---|---|
committer | 2023-05-20 21:22:01 +0530 | |
commit | 906ca7eb436dc9944d43f5b7f6ae7b44afc2a3e7 (patch) | |
tree | 6ed4722299faf46726938c9eaa0d0689115d169e | |
parent | 41225b19f36e34bcbf9d08095b4e9b3b497be060 (diff) | |
download | whatsie-4.14.1.tar.gz whatsie-4.14.1.zip |
fix: fix unread message parsingv4.14.1upstream/4.14.1
- fixes #116
-rw-r--r-- | src/mainwindow.cpp | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 1ba43f1..c4098f5 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -978,25 +978,33 @@ void MainWindow::fullScreenRequested(QWebEngineFullScreenRequest request) { void MainWindow::handleWebViewTitleChanged(const QString &title) { setWindowTitle(QApplication::applicationName() + ": " + title); - QRegularExpressionMatch match = m_notificationsTitleRegExp.match(title); - if (match.hasMatch()) { - QString capturedTitle = match.captured(0); - m_unreadMessageCountRegExp.setPatternOptions( - QRegularExpression::DontCaptureOption); - QRegularExpressionMatch countMatch = + QRegularExpressionMatch notificationsTitleMatch = + m_notificationsTitleRegExp.match(title); + + if (notificationsTitleMatch.hasMatch()) { + + QString capturedTitle = notificationsTitleMatch.captured(0); + + QRegularExpressionMatch unreadMessageCountMatch = m_unreadMessageCountRegExp.match(capturedTitle); - if (countMatch.hasMatch()) { - QString unreadMessageCountStr = countMatch.captured(0); + + if (unreadMessageCountMatch.hasMatch()) { + + QString unreadMessageCountStr = unreadMessageCountMatch.captured(1); + int unreadMessageCount = unreadMessageCountStr.toInt(); m_restoreAction->setText( tr("Restore") + " | " + unreadMessageCountStr + " " + (unreadMessageCount > 1 ? tr("messages") : tr("message"))); + m_systemTrayIcon->setIcon(getTrayIcon(unreadMessageCount)); + setWindowIcon(getTrayIcon(unreadMessageCount)); } } else { m_systemTrayIcon->setIcon(m_trayIconNormal); + setWindowIcon(m_trayIconNormal); } } |