Support Qt 6 (commit 174154b)
This commit is contained in:
parent
f952ca6ba1
commit
3b49e9e312
|
@ -208,7 +208,7 @@ int Application::loadConfig()
|
||||||
if (apiKeyArgValue) {
|
if (apiKeyArgValue) {
|
||||||
m_settings.apiKey.append(apiKeyArgValue);
|
m_settings.apiKey.append(apiKeyArgValue);
|
||||||
} else {
|
} else {
|
||||||
m_settings.apiKey.append(config.guiApiKey);
|
m_settings.apiKey.append(config.guiApiKey.toUtf8());
|
||||||
}
|
}
|
||||||
if (const char *certArgValue = m_args.certificate.firstValue()) {
|
if (const char *certArgValue = m_args.certificate.firstValue()) {
|
||||||
m_settings.httpsCertPath = argToQString(certArgValue);
|
m_settings.httpsCertPath = argToQString(certArgValue);
|
||||||
|
|
|
@ -45,9 +45,9 @@ find_package(c++utilities${CONFIGURATION_PACKAGE_SUFFIX} 5.0.0 REQUIRED)
|
||||||
use_cpp_utilities(VISIBILITY PUBLIC)
|
use_cpp_utilities(VISIBILITY PUBLIC)
|
||||||
|
|
||||||
# find qtutilities (only headers and CMake modules used)
|
# find qtutilities (only headers and CMake modules used)
|
||||||
find_package(qtutilities${CONFIGURATION_PACKAGE_SUFFIX} 6.0.0 REQUIRED)
|
find_package(qtutilities${CONFIGURATION_PACKAGE_SUFFIX} 6.3.0 REQUIRED)
|
||||||
list(APPEND CMAKE_MODULE_PATH ${QT_UTILITIES_MODULE_DIRS})
|
list(APPEND CMAKE_MODULE_PATH ${QT_UTILITIES_MODULE_DIRS})
|
||||||
list(APPEND PRIVATE_INCLUDE_DIRS ${QT_UTILITIES_INCLUDE_DIRS})
|
list(APPEND PUBLIC_INCLUDE_DIRS ${QT_UTILITIES_INCLUDE_DIRS})
|
||||||
|
|
||||||
# link also explicitely against the following Qt 5 modules
|
# link also explicitely against the following Qt 5 modules
|
||||||
list(APPEND ADDITIONAL_QT_MODULES Network)
|
list(APPEND ADDITIONAL_QT_MODULES Network)
|
||||||
|
|
|
@ -159,11 +159,11 @@ QString SyncthingDir::statusString() const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringRef SyncthingDir::pathWithoutTrailingSlash() const
|
QtUtilities::StringView SyncthingDir::pathWithoutTrailingSlash() const
|
||||||
{
|
{
|
||||||
QStringRef dirPath(&path);
|
auto dirPath = QtUtilities::makeStringView(path);
|
||||||
while (dirPath.endsWith(QChar('/'))) {
|
while (dirPath.endsWith(QChar('/'))) {
|
||||||
#if QT_VERSION_MAJOR >= 5 && QT_VERSION_MINOR >= 8
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 8, 0))
|
||||||
dirPath.chop(1);
|
dirPath.chop(1);
|
||||||
#else
|
#else
|
||||||
dirPath = dirPath.left(dirPath.size() - 1);
|
dirPath = dirPath.left(dirPath.size() - 1);
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
#include "./qstringhash.h"
|
#include "./qstringhash.h"
|
||||||
#include "./syncthingcompletion.h"
|
#include "./syncthingcompletion.h"
|
||||||
|
|
||||||
|
#include <qtutilities/misc/compat.h>
|
||||||
|
|
||||||
#include <c++utilities/chrono/datetime.h>
|
#include <c++utilities/chrono/datetime.h>
|
||||||
|
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
|
@ -114,7 +116,7 @@ struct LIB_SYNCTHING_CONNECTOR_EXPORT SyncthingDir {
|
||||||
const QString &displayName() const;
|
const QString &displayName() const;
|
||||||
QString statusString() const;
|
QString statusString() const;
|
||||||
QString dirTypeString() const;
|
QString dirTypeString() const;
|
||||||
QStringRef pathWithoutTrailingSlash() const;
|
QtUtilities::StringView pathWithoutTrailingSlash() const;
|
||||||
bool isLocallyUpToDate() const;
|
bool isLocallyUpToDate() const;
|
||||||
bool areRemotesUpToDate() const;
|
bool areRemotesUpToDate() const;
|
||||||
bool isUnshared() const;
|
bool isUnshared() const;
|
||||||
|
|
|
@ -444,7 +444,7 @@ void ConnectionTests::checkDevices()
|
||||||
CPPUNIT_ASSERT_EQUAL_MESSAGE("paused device", QStringLiteral("paused"), dev.statusString());
|
CPPUNIT_ASSERT_EQUAL_MESSAGE("paused device", QStringLiteral("paused"), dev.statusString());
|
||||||
CPPUNIT_ASSERT_EQUAL_MESSAGE("name", QStringLiteral("Test dev 2"), dev.name);
|
CPPUNIT_ASSERT_EQUAL_MESSAGE("name", QStringLiteral("Test dev 2"), dev.name);
|
||||||
CPPUNIT_ASSERT_MESSAGE("no introducer", !dev.introducer);
|
CPPUNIT_ASSERT_MESSAGE("no introducer", !dev.introducer);
|
||||||
CPPUNIT_ASSERT_EQUAL(1, dev.addresses.size());
|
CPPUNIT_ASSERT_EQUAL(static_cast<decltype(dev.addresses.size())>(1), dev.addresses.size());
|
||||||
CPPUNIT_ASSERT_EQUAL(QStringLiteral("tcp://192.168.2.2:22001"), dev.addresses.front());
|
CPPUNIT_ASSERT_EQUAL(QStringLiteral("tcp://192.168.2.2:22001"), dev.addresses.front());
|
||||||
dev2 = &dev;
|
dev2 = &dev;
|
||||||
dev2Index = index;
|
dev2Index = index;
|
||||||
|
@ -452,7 +452,7 @@ void ConnectionTests::checkDevices()
|
||||||
CPPUNIT_ASSERT_EQUAL_MESSAGE("disconnected device", QStringLiteral("disconnected"), dev.statusString());
|
CPPUNIT_ASSERT_EQUAL_MESSAGE("disconnected device", QStringLiteral("disconnected"), dev.statusString());
|
||||||
CPPUNIT_ASSERT_EQUAL_MESSAGE("name", QStringLiteral("Test dev 1"), dev.name);
|
CPPUNIT_ASSERT_EQUAL_MESSAGE("name", QStringLiteral("Test dev 1"), dev.name);
|
||||||
CPPUNIT_ASSERT_MESSAGE("introducer", dev.introducer);
|
CPPUNIT_ASSERT_MESSAGE("introducer", dev.introducer);
|
||||||
CPPUNIT_ASSERT_EQUAL(1, dev.addresses.size());
|
CPPUNIT_ASSERT_EQUAL(static_cast<decltype(dev.addresses.size())>(1), dev.addresses.size());
|
||||||
CPPUNIT_ASSERT_EQUAL(QStringLiteral("dynamic"), dev.addresses.front());
|
CPPUNIT_ASSERT_EQUAL(QStringLiteral("dynamic"), dev.addresses.front());
|
||||||
dev1 = &dev;
|
dev1 = &dev;
|
||||||
dev1Index = index;
|
dev1Index = index;
|
||||||
|
|
|
@ -166,9 +166,9 @@ void MiscTests::testConnectionSettingsAndLoadingSelfSignedCert()
|
||||||
settings.apiKey = QByteArray("foo");
|
settings.apiKey = QByteArray("foo");
|
||||||
settings.httpsCertPath = SyncthingConfig::locateHttpsCertificate();
|
settings.httpsCertPath = SyncthingConfig::locateHttpsCertificate();
|
||||||
if (!settings.httpsCertPath.isEmpty() && settings.loadHttpsCert()) {
|
if (!settings.httpsCertPath.isEmpty() && settings.loadHttpsCert()) {
|
||||||
CPPUNIT_ASSERT_EQUAL(4, settings.expectedSslErrors.size());
|
CPPUNIT_ASSERT_EQUAL(static_cast<decltype(settings.expectedSslErrors.size())>(4), settings.expectedSslErrors.size());
|
||||||
} else {
|
} else {
|
||||||
CPPUNIT_ASSERT_EQUAL(0, settings.expectedSslErrors.size());
|
CPPUNIT_ASSERT_EQUAL(static_cast<decltype(settings.expectedSslErrors.size())>(0), settings.expectedSslErrors.size());
|
||||||
}
|
}
|
||||||
SyncthingConnection connection;
|
SyncthingConnection connection;
|
||||||
CPPUNIT_ASSERT(connection.applySettings(settings));
|
CPPUNIT_ASSERT(connection.applySettings(settings));
|
||||||
|
|
|
@ -36,7 +36,7 @@ find_package(c++utilities${CONFIGURATION_PACKAGE_SUFFIX} 5.0.0 REQUIRED)
|
||||||
use_cpp_utilities()
|
use_cpp_utilities()
|
||||||
|
|
||||||
# find qtutilities (only CMake modules used)
|
# find qtutilities (only CMake modules used)
|
||||||
find_package(qtutilities${CONFIGURATION_PACKAGE_SUFFIX} 6.0.0 REQUIRED)
|
find_package(qtutilities${CONFIGURATION_PACKAGE_SUFFIX} 6.3.0 REQUIRED)
|
||||||
use_qt_utilities()
|
use_qt_utilities()
|
||||||
|
|
||||||
# find backend libraries
|
# find backend libraries
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#include "./syncthingicons.h"
|
#include "./syncthingicons.h"
|
||||||
|
|
||||||
|
#include <qtutilities/misc/compat.h>
|
||||||
|
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QGuiApplication>
|
#include <QGuiApplication>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
@ -165,15 +167,15 @@ QPixmap renderSvgImage(const QByteArray &contents, const QSize &size, int margin
|
||||||
QByteArray loadFontAwesomeIcon(const QString &iconName, const QColor &color, bool solid)
|
QByteArray loadFontAwesomeIcon(const QString &iconName, const QColor &color, bool solid)
|
||||||
{
|
{
|
||||||
QByteArray result;
|
QByteArray result;
|
||||||
QFile icon((solid ? QStringLiteral(":/icons/hicolor/scalable/fa/") : QStringLiteral(":/icons/hicolor/scalable/fa-non-solid/")) % iconName
|
QFile icon((solid ? QStringLiteral(":/icons/hicolor/scalable/fa/")
|
||||||
% QStringLiteral(".svg"));
|
: QString(QStringLiteral(":/icons/hicolor/scalable/fa-non-solid/")) % iconName % QStringLiteral(".svg")));
|
||||||
if (!icon.open(QFile::ReadOnly)) {
|
if (!icon.open(QFile::ReadOnly)) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
result = icon.readAll();
|
result = icon.readAll();
|
||||||
const auto pathBegin = result.indexOf("<path ");
|
const auto pathBegin = result.indexOf("<path ");
|
||||||
if (pathBegin > 0) {
|
if (pathBegin > 0) {
|
||||||
result.insert(pathBegin + 6, QStringLiteral("fill=\"") % color.name(QColor::HexRgb) % QStringLiteral("\" "));
|
result.insert(pathBegin + 6, (QStringLiteral("fill=\"") % color.name(QColor::HexRgb) % QStringLiteral("\" ")).toUtf8());
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -231,7 +233,7 @@ std::vector<StatusIconSettings::ColorMapping> StatusIconSettings::colorMapping()
|
||||||
StatusIconSettings::StatusIconSettings(const QString &str)
|
StatusIconSettings::StatusIconSettings(const QString &str)
|
||||||
: StatusIconSettings()
|
: StatusIconSettings()
|
||||||
{
|
{
|
||||||
const auto parts = str.splitRef(QChar(';'));
|
const auto parts = QtUtilities::splitRef(str, QChar(';'));
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for (auto *field :
|
for (auto *field :
|
||||||
{ &defaultColor, &errorColor, &warningColor, &idleColor, &scanningColor, &synchronizingColor, &pausedColor, &disconnectedColor }) {
|
{ &defaultColor, &errorColor, &warningColor, &idleColor, &scanningColor, &synchronizingColor, &pausedColor, &disconnectedColor }) {
|
||||||
|
|
|
@ -5,6 +5,10 @@
|
||||||
|
|
||||||
#include <QAbstractItemModel>
|
#include <QAbstractItemModel>
|
||||||
|
|
||||||
|
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||||
|
Q_MOC_INCLUDE("../connector/syncthingconnection.h")
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace Data {
|
namespace Data {
|
||||||
|
|
||||||
class SyncthingConnection;
|
class SyncthingConnection;
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
#include <qtutilities/misc/dialogutils.h>
|
#include <qtutilities/misc/dialogutils.h>
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QDesktopWidget>
|
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
|
|
||||||
using namespace QtUtilities;
|
using namespace QtUtilities;
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
#include <c++utilities/application/argumentparser.h>
|
#include <c++utilities/application/argumentparser.h>
|
||||||
#include <c++utilities/conversion/stringconversion.h>
|
#include <c++utilities/conversion/stringconversion.h>
|
||||||
|
|
||||||
|
#include <QActionGroup>
|
||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
|
|
|
@ -76,7 +76,7 @@ find_package(c++utilities${CONFIGURATION_PACKAGE_SUFFIX} 5.0.0 REQUIRED)
|
||||||
use_cpp_utilities()
|
use_cpp_utilities()
|
||||||
|
|
||||||
# find qtutilities
|
# find qtutilities
|
||||||
find_package(qtutilities${CONFIGURATION_PACKAGE_SUFFIX} 6.1.0 REQUIRED)
|
find_package(qtutilities${CONFIGURATION_PACKAGE_SUFFIX} 6.3.0 REQUIRED)
|
||||||
use_qt_utilities()
|
use_qt_utilities()
|
||||||
|
|
||||||
# find backend libraries
|
# find backend libraries
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include <QtConcurrentRun>
|
#include <QtConcurrentRun>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <functional>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
@ -88,7 +89,7 @@ QString SyncthingLauncher::libSyncthingVersionInfo()
|
||||||
*/
|
*/
|
||||||
void SyncthingLauncher::launch(const QString &program, const QStringList &arguments)
|
void SyncthingLauncher::launch(const QString &program, const QStringList &arguments)
|
||||||
{
|
{
|
||||||
if (isRunning()) {
|
if (isRunning() || m_stopFuture.isRunning()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_manuallyStopped = false;
|
m_manuallyStopped = false;
|
||||||
|
@ -100,7 +101,7 @@ void SyncthingLauncher::launch(const QString &program, const QStringList &argume
|
||||||
}
|
}
|
||||||
|
|
||||||
// use libsyncthing
|
// use libsyncthing
|
||||||
m_future = QtConcurrent::run(this, &SyncthingLauncher::runLibSyncthing, LibSyncthing::RuntimeOptions{});
|
m_startFuture = QtConcurrent::run(std::bind(&SyncthingLauncher::runLibSyncthing, this, LibSyncthing::RuntimeOptions{}));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -133,11 +134,11 @@ void SyncthingLauncher::launch(const Settings::Launcher &launcherSettings)
|
||||||
*/
|
*/
|
||||||
void SyncthingLauncher::launch(const LibSyncthing::RuntimeOptions &runtimeOptions)
|
void SyncthingLauncher::launch(const LibSyncthing::RuntimeOptions &runtimeOptions)
|
||||||
{
|
{
|
||||||
if (isRunning()) {
|
if (isRunning() || m_stopFuture.isRunning()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_manuallyStopped = false;
|
m_manuallyStopped = false;
|
||||||
m_future = QtConcurrent::run(this, &SyncthingLauncher::runLibSyncthing, runtimeOptions);
|
m_startFuture = QtConcurrent::run(std::bind(&SyncthingLauncher::runLibSyncthing, this, runtimeOptions));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SyncthingLauncher::terminate()
|
void SyncthingLauncher::terminate()
|
||||||
|
@ -163,11 +164,11 @@ void SyncthingLauncher::kill()
|
||||||
void SyncthingLauncher::tearDownLibSyncthing()
|
void SyncthingLauncher::tearDownLibSyncthing()
|
||||||
{
|
{
|
||||||
#ifdef SYNCTHINGWIDGETS_USE_LIBSYNCTHING
|
#ifdef SYNCTHINGWIDGETS_USE_LIBSYNCTHING
|
||||||
if (!m_future.isRunning()) {
|
if (!m_startFuture.isRunning() || m_stopFuture.isRunning()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_manuallyStopped = true;
|
m_manuallyStopped = true;
|
||||||
QtConcurrent::run(this, &SyncthingLauncher::stopLibSyncthing);
|
m_stopFuture = QtConcurrent::run(std::bind(&SyncthingLauncher::stopLibSyncthing, this));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,8 @@ private:
|
||||||
void handleOutputAvailable(QByteArray &&data);
|
void handleOutputAvailable(QByteArray &&data);
|
||||||
|
|
||||||
SyncthingProcess m_process;
|
SyncthingProcess m_process;
|
||||||
QFuture<void> m_future;
|
QFuture<void> m_startFuture;
|
||||||
|
QFuture<void> m_stopFuture;
|
||||||
QByteArray m_outputBuffer;
|
QByteArray m_outputBuffer;
|
||||||
CppUtilities::DateTime m_futureStarted;
|
CppUtilities::DateTime m_futureStarted;
|
||||||
LibSyncthing::LogLevel m_libsyncthingLogLevel;
|
LibSyncthing::LogLevel m_libsyncthingLogLevel;
|
||||||
|
@ -82,7 +83,7 @@ private:
|
||||||
/// \brief Returns whether Syncthing is running.
|
/// \brief Returns whether Syncthing is running.
|
||||||
inline bool SyncthingLauncher::isRunning() const
|
inline bool SyncthingLauncher::isRunning() const
|
||||||
{
|
{
|
||||||
return m_process.isRunning() || m_future.isRunning();
|
return m_process.isRunning() || m_startFuture.isRunning();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \brief Returns when the Syncthing instance has been started.
|
/// \brief Returns when the Syncthing instance has been started.
|
||||||
|
@ -90,7 +91,7 @@ inline CppUtilities::DateTime SyncthingLauncher::activeSince() const
|
||||||
{
|
{
|
||||||
if (m_process.isRunning()) {
|
if (m_process.isRunning()) {
|
||||||
return m_process.activeSince();
|
return m_process.activeSince();
|
||||||
} else if (m_future.isRunning()) {
|
} else if (m_startFuture.isRunning()) {
|
||||||
return m_futureStarted;
|
return m_futureStarted;
|
||||||
}
|
}
|
||||||
return CppUtilities::DateTime();
|
return CppUtilities::DateTime();
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
// use meta-data of syncthingtray application here
|
// use meta-data of syncthingtray application here
|
||||||
#include "resources/../../tray/resources/config.h"
|
#include "resources/../../tray/resources/config.h"
|
||||||
|
|
||||||
|
#include <qtutilities/misc/compat.h>
|
||||||
#include <qtutilities/paletteeditor/colorbutton.h>
|
#include <qtutilities/paletteeditor/colorbutton.h>
|
||||||
#include <qtutilities/settingsdialog/optioncategory.h>
|
#include <qtutilities/settingsdialog/optioncategory.h>
|
||||||
#include <qtutilities/settingsdialog/optioncategorymodel.h>
|
#include <qtutilities/settingsdialog/optioncategorymodel.h>
|
||||||
|
@ -127,8 +128,8 @@ void ConnectionOptionPage::insertFromConfigFile(bool forceFileSelection)
|
||||||
|
|
||||||
if (!config.guiAddress.isEmpty()) {
|
if (!config.guiAddress.isEmpty()) {
|
||||||
const auto portStart(config.guiAddress.indexOf(QChar(':')));
|
const auto portStart(config.guiAddress.indexOf(QChar(':')));
|
||||||
QString guiHost(config.guiAddress.mid(0, portStart));
|
auto guiHost(config.guiAddress.mid(0, portStart));
|
||||||
const QStringRef guiPort(portStart > 0 ? config.guiAddress.midRef(portStart) : QStringRef());
|
const auto guiPort = portStart > 0 ? QtUtilities::midRef(config.guiAddress, portStart) : QtUtilities::StringView();
|
||||||
const QHostAddress guiAddress(guiHost);
|
const QHostAddress guiAddress(guiHost);
|
||||||
// assume local connection if address is eg. 0.0.0.0
|
// assume local connection if address is eg. 0.0.0.0
|
||||||
auto localConnection = true;
|
auto localConnection = true;
|
||||||
|
|
Loading…
Reference in New Issue