Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Qt 5.15.1 compatibility #434

Closed
wants to merge 10 commits into from
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ jobs:
matrix:
os: [windows-latest, ubuntu-latest]
arch: [x86, x64]
qt_version: [5.9.9, 5.14.1]
qt_version: [5.9.9, 5.15.1]
include:
- os: windows-latest
arch: x86
qt_compile_suite: win32_msvc2017
qt_compile_suite: win32_msvc2019
- os: windows-latest
arch: x64
qt_compile_suite: win64_msvc2017_64
qt_compile_suite: win64_msvc2019_64
exclude:
# We only want to test for the latest version of Qt on Windows
- os: windows-latest
Expand Down
2 changes: 1 addition & 1 deletion src/autoupdater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ void AutoUpdater::onInstallerDownloadFinished(QNetworkReply* result) {
if (downloadProcessDialog->exec() == QDialog::Rejected
|| downloadProcessDialog->wasCanceled()) {
installerFile.remove();
} else if (!QProcess::startDetached(installerFile.fileName())) {
} else if (!QProcess::startDetached(installerFile.fileName(), {})) {
QMessageBox::critical(
nullptr, tr("Update failed"),
tr("Failed to start the Birdtray installer."),
Expand Down
7 changes: 6 additions & 1 deletion src/autoupdater.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
#ifndef AUTO_UPDATER_H
#define AUTO_UPDATER_H

#include <QNetworkAccessManager>
#include <QRegularExpression>
#include <QtWidgets/QProgressDialog>
#include <QUrl>
#include <QFile>
QT_WARNING_PUSH
#ifdef QT_WARNING_DISABLE_DEPRECATED
QT_WARNING_DISABLE_DEPRECATED
#endif
#include <QNetworkAccessManager>
QT_WARNING_POP
#include "updatedialog.h"
#include "updatedownloaddialog.h"

Expand Down
4 changes: 2 additions & 2 deletions src/morkparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ void MorkParser::parseGroup()
QString endAbort = "@$$}~abort~" + id + "}@";

// Find the end of this group
int ofst = morkData_.indexOf( endAbort, morkPos_ );
int ofst = morkData_.indexOf( endAbort.toUtf8(), morkPos_ );

if ( ofst != -1 )
{
Expand All @@ -660,7 +660,7 @@ void MorkParser::parseGroup()
}

// Now look up for success
ofst = morkData_.indexOf( endCommit, morkPos_ );
ofst = morkData_.indexOf( endCommit.toUtf8(), morkPos_ );

if (ofst == -1) {
throw MorkParserException(QCoreApplication::translate(
Expand Down
15 changes: 13 additions & 2 deletions src/setting_newemail.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
#include <QJsonArray>
#include <QJsonDocument>
#include <QTemporaryFile>
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
# include <QCborValue>
#endif

#include "setting_newemail.h"
#include "dialogaddeditnewemail.h"
Expand Down Expand Up @@ -50,12 +53,20 @@ QJsonObject Setting_NewEmail::toJSON() const

Setting_NewEmail Setting_NewEmail::fromByteArray(const QByteArray &str)
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
QCborParserError parserError;
QCborValue object = QCborValue::fromCbor(str, &parserError);
if (parserError.error != QCborError::NoError) {
return Setting_NewEmail();
}
return fromJSON(object.toJsonValue().toObject());
#else
// QJsonDocument is deprecated since Qt 5.15
QJsonDocument doc = QJsonDocument::fromBinaryData( str );

if ( !doc.isObject() )
return Setting_NewEmail();

return fromJSON( doc.object() );
#endif
}

bool Setting_NewEmail::edit()
Expand Down
41 changes: 13 additions & 28 deletions src/trayicon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
#include "birdtrayapp.h"
#include "log.h"

TrayIcon::TrayIcon(bool showSettings)
#define UPDATE_RETRY_MS 3600000


TrayIcon::TrayIcon(bool showSettings) : updateRetryTimer(this)
{
mBlinkingIconOpacity = 1.0;
mBlinkingDelta = 0.0;
Expand All @@ -39,7 +42,11 @@ TrayIcon::TrayIcon(bool showSettings)
mThunderbirdWindowExisted = false;
mThunderbirdWindowHide = false;
connect(QApplication::instance(), &QApplication::aboutToQuit, this, &TrayIcon::onQuit);

updateRetryTimer.setInterval(UPDATE_RETRY_MS);
updateRetryTimer.setSingleShot(true);
connect(&updateRetryTimer, &QTimer::timeout,
BirdtrayApp::get()->getAutoUpdater(), &AutoUpdater::checkForUpdates);

Settings* settings = BirdtrayApp::get()->getSettings();
mThunderbirdStartTime = QDateTime::currentDateTime().addSecs(settings->mLaunchThunderbirdDelay);

Expand Down Expand Up @@ -94,10 +101,6 @@ TrayIcon::~TrayIcon() {
#ifdef Q_OS_WIN
mThunderbirdUpdaterProcess->deleteLater();
#endif /* Q_OS_WIN */
if (networkConnectivityManager != nullptr) {
networkConnectivityManager->deleteLater();
networkConnectivityManager = nullptr;
}
if (mUnreadMonitor != nullptr) {
if (mUnreadMonitor->isRunning()) {
mUnreadMonitor->quit();
Expand Down Expand Up @@ -139,7 +142,7 @@ void TrayIcon::unreadCounterUpdate( unsigned int total, QColor color )
// Replace the %OLD% with the old unread count
cmdline.replace( "%OLD%", QString::number( mUnreadCounter ) );

if ( !QProcess::startDetached( cmdline ) )
if ( !QProcess::startDetached( cmdline, {} ) ) // FIXME: Arguments
Log::debug( "Failed to execute hook command %s", qPrintable( cmdline ) );
else
Log::debug( "Executing hook command %s", qPrintable( cmdline ) );
Expand Down Expand Up @@ -689,10 +692,7 @@ void TrayIcon::startThunderbird()

mThunderbirdProcess = new QProcess();
connect( mThunderbirdProcess, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(tbProcessFinished(int,QProcess::ExitStatus)) );

#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
connect( mThunderbirdProcess, &QProcess::errorOccurred, this, &TrayIcon::tbProcessError );
#endif

mThunderbirdProcess->start(executable, args);
}
Expand Down Expand Up @@ -760,26 +760,11 @@ void TrayIcon::onQuit() {

void TrayIcon::onAutoUpdateCheckFinished(bool foundUpdate, const QString &errorMessage) {
Q_UNUSED(foundUpdate)
AutoUpdater* autoUpdater = BirdtrayApp::get()->getAutoUpdater();
if (errorMessage.isNull()) {
disconnect(autoUpdater, &AutoUpdater::onCheckUpdateFinished,
disconnect(BirdtrayApp::get()->getAutoUpdater(), &AutoUpdater::onCheckUpdateFinished,
this, &TrayIcon::onAutoUpdateCheckFinished);
} else if (networkConnectivityManager == nullptr) {
networkConnectivityManager = new QNetworkConfigurationManager();
networkConnectivityManager->updateConfigurations();
auto callback = [=](const QNetworkConfiguration &config) {
if (config.state() == QNetworkConfiguration::Active) {
if (networkConnectivityManager != nullptr) {
networkConnectivityManager->deleteLater();
networkConnectivityManager = nullptr;
}
autoUpdater->checkForUpdates();
}
};
connect(networkConnectivityManager, &QNetworkConfigurationManager::configurationChanged,
this, callback);
connect(networkConnectivityManager, &QNetworkConfigurationManager::configurationAdded,
this, callback);
} else if (!updateRetryTimer.isActive()) {
updateRetryTimer.start();
}
}

Expand Down
8 changes: 2 additions & 6 deletions src/trayicon.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include <QImage>
#include <QProcess>
#include <QSystemTrayIcon>
#include <QtNetwork/QNetworkConfigurationManager>
#ifdef Q_OS_WIN
# include "processhandle.h"
#endif /* Q_OS_WIN */
Expand Down Expand Up @@ -220,11 +219,8 @@ class TrayIcon : public QSystemTrayIcon
// A reference to a Thunderbird updater process.
ProcessHandle* mThunderbirdUpdaterProcess;
#endif /* Q_OS_WIN */

/**
* A manager to check for network connectivity.
*/
QNetworkConfigurationManager* networkConnectivityManager = nullptr;
// A timer that is used to retry for automatic update checks if they fail.
QTimer updateRetryTimer;

/**
* Whether we have received data about unread emails yet.
Expand Down