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