Adapt to changes in c++utilities
This commit is contained in:
parent
4896fc0342
commit
64473df5ba
|
@ -13,11 +13,11 @@
|
|||
|
||||
#include "resources/config.h"
|
||||
|
||||
#include <c++utilities/application/failure.h>
|
||||
#include <c++utilities/chrono/timespan.h>
|
||||
#include <c++utilities/conversion/stringbuilder.h>
|
||||
#include <c++utilities/conversion/stringconversion.h>
|
||||
#include <c++utilities/io/ansiescapecodes.h>
|
||||
#include <c++utilities/misc/parseerror.h>
|
||||
|
||||
#include <qtutilities/misc/conversion.h>
|
||||
|
||||
|
@ -35,10 +35,9 @@
|
|||
|
||||
using namespace std;
|
||||
using namespace std::placeholders;
|
||||
using namespace ApplicationUtilities;
|
||||
using namespace EscapeCodes;
|
||||
using namespace ChronoUtilities;
|
||||
using namespace ConversionUtilities;
|
||||
using namespace CppUtilities;
|
||||
using namespace CppUtilities::EscapeCodes;
|
||||
using namespace QtUtilities;
|
||||
using namespace Data;
|
||||
|
||||
namespace Cli {
|
||||
|
@ -118,7 +117,7 @@ int Application::exec(int argc, const char *const *argv)
|
|||
m_args.parser.checkConstraints();
|
||||
m_argsRead = true;
|
||||
|
||||
} catch (const Failure &failure) {
|
||||
} catch (const ParseError &failure) {
|
||||
cerr << failure;
|
||||
return 1;
|
||||
}
|
||||
|
@ -237,7 +236,6 @@ int Application::loadConfig()
|
|||
|
||||
bool Application::waitForConnected(int timeout)
|
||||
{
|
||||
using namespace TestUtilities;
|
||||
bool isConnected = m_connection.isConnected();
|
||||
const function<void(SyncthingStatus)> checkStatus([this, &isConnected](SyncthingStatus) { isConnected = m_connection.isConnected(); });
|
||||
return waitForSignalsOrFail(bind(static_cast<void (SyncthingConnection::*)(SyncthingConnectionSettings &)>(&SyncthingConnection::reconnect),
|
||||
|
@ -248,7 +246,6 @@ bool Application::waitForConnected(int timeout)
|
|||
|
||||
bool Application::waitForConfig(int timeout)
|
||||
{
|
||||
using namespace TestUtilities;
|
||||
m_connection.applySettings(m_settings);
|
||||
return waitForSignalsOrFail(bind(&SyncthingConnection::requestConfig, ref(m_connection)), timeout,
|
||||
signalInfo(&m_connection, &SyncthingConnection::error), signalInfo(&m_connection, &SyncthingConnection::newConfig),
|
||||
|
@ -257,7 +254,6 @@ bool Application::waitForConfig(int timeout)
|
|||
|
||||
bool Application::waitForConfigAndStatus(int timeout)
|
||||
{
|
||||
using namespace TestUtilities;
|
||||
m_connection.applySettings(m_settings);
|
||||
return waitForSignalsOrFail(bind(&SyncthingConnection::requestConfigAndStatus, ref(m_connection)), timeout,
|
||||
signalInfo(&m_connection, &SyncthingConnection::error), signalInfo(&m_connection, &SyncthingConnection::newConfig),
|
||||
|
@ -692,7 +688,6 @@ void Application::editConfig(const ArgumentOccurrence &)
|
|||
}
|
||||
|
||||
// post new config
|
||||
using namespace TestUtilities;
|
||||
cerr << Phrases::Info << "Posting new configuration ..." << TextAttribute::Reset << flush;
|
||||
if (!waitForSignalsOrFail(bind(&SyncthingConnection::postConfigFromByteArray, ref(m_connection), ref(newConfig)), 0,
|
||||
signalInfo(&m_connection, &SyncthingConnection::error), signalInfo(&m_connection, &SyncthingConnection::newConfigTriggered))) {
|
||||
|
@ -958,7 +953,6 @@ void Application::waitForIdle(const ArgumentOccurrence &)
|
|||
// invoke handler manually because Syncthing could already be idling
|
||||
handleNewDirsOrDevs();
|
||||
|
||||
using namespace TestUtilities;
|
||||
waitForSignals(&noop, m_idleTimeout, signalInfo(&m_connection, &SyncthingConnection::dirStatusChanged, handleStatusChange, &isLongEnoughIdle),
|
||||
signalInfo(&m_connection, &SyncthingConnection::devStatusChanged, handleStatusChange, &isLongEnoughIdle),
|
||||
signalInfo(&m_connection, &SyncthingConnection::newDirs, handleNewDirsOrDevs, &isLongEnoughIdle),
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
namespace Cli {
|
||||
|
||||
using namespace ApplicationUtilities;
|
||||
using namespace CppUtilities;
|
||||
|
||||
struct Args {
|
||||
Args();
|
||||
|
|
26
cli/helper.h
26
cli/helper.h
|
@ -15,10 +15,10 @@
|
|||
|
||||
namespace Cli {
|
||||
|
||||
inline void printProperty(const char *propName, const char *value, const char *suffix = nullptr, ApplicationUtilities::Indentation indentation = 3)
|
||||
inline void printProperty(const char *propName, const char *value, const char *suffix = nullptr, CppUtilities::Indentation indentation = 3)
|
||||
{
|
||||
if (*value) {
|
||||
std::cout << indentation << propName << ApplicationUtilities::Indentation(30 - strlen(propName)) << value;
|
||||
std::cout << indentation << propName << CppUtilities::Indentation(30 - strlen(propName)) << value;
|
||||
if (suffix) {
|
||||
std::cout << ' ' << suffix;
|
||||
}
|
||||
|
@ -26,19 +26,17 @@ inline void printProperty(const char *propName, const char *value, const char *s
|
|||
}
|
||||
}
|
||||
|
||||
inline void printProperty(const char *propName, const QString &value, const char *suffix = nullptr, ApplicationUtilities::Indentation indentation = 3)
|
||||
inline void printProperty(const char *propName, const QString &value, const char *suffix = nullptr, CppUtilities::Indentation indentation = 3)
|
||||
{
|
||||
printProperty(propName, value.toLocal8Bit().data(), suffix, indentation);
|
||||
}
|
||||
|
||||
inline void printProperty(
|
||||
const char *propName, const std::string &value, const char *suffix = nullptr, ApplicationUtilities::Indentation indentation = 3)
|
||||
inline void printProperty(const char *propName, const std::string &value, const char *suffix = nullptr, CppUtilities::Indentation indentation = 3)
|
||||
{
|
||||
printProperty(propName, value.data(), suffix, indentation);
|
||||
}
|
||||
|
||||
inline void printProperty(
|
||||
const char *propName, const QStringList &value, const char *suffix = nullptr, ApplicationUtilities::Indentation indentation = 3)
|
||||
inline void printProperty(const char *propName, const QStringList &value, const char *suffix = nullptr, CppUtilities::Indentation indentation = 3)
|
||||
{
|
||||
for (const QString &str : value) {
|
||||
printProperty(propName, str, suffix, indentation);
|
||||
|
@ -47,32 +45,32 @@ inline void printProperty(
|
|||
}
|
||||
|
||||
inline void printProperty(
|
||||
const char *propName, ChronoUtilities::TimeSpan timeSpan, const char *suffix = nullptr, ApplicationUtilities::Indentation indentation = 3)
|
||||
const char *propName, CppUtilities::TimeSpan timeSpan, const char *suffix = nullptr, CppUtilities::Indentation indentation = 3)
|
||||
{
|
||||
if (!timeSpan.isNull()) {
|
||||
printProperty(propName, timeSpan.toString(ChronoUtilities::TimeSpanOutputFormat::WithMeasures).data(), suffix, indentation);
|
||||
printProperty(propName, timeSpan.toString(CppUtilities::TimeSpanOutputFormat::WithMeasures).data(), suffix, indentation);
|
||||
}
|
||||
}
|
||||
|
||||
inline void printProperty(
|
||||
const char *propName, ChronoUtilities::DateTime dateTime, const char *suffix = nullptr, ApplicationUtilities::Indentation indentation = 3)
|
||||
const char *propName, CppUtilities::DateTime dateTime, const char *suffix = nullptr, CppUtilities::Indentation indentation = 3)
|
||||
{
|
||||
if (!dateTime.isNull()) {
|
||||
printProperty(propName, dateTime.toString().data(), suffix, indentation);
|
||||
}
|
||||
}
|
||||
|
||||
inline void printProperty(const char *propName, bool value, const char *suffix = nullptr, ApplicationUtilities::Indentation indentation = 3)
|
||||
inline void printProperty(const char *propName, bool value, const char *suffix = nullptr, CppUtilities::Indentation indentation = 3)
|
||||
{
|
||||
printProperty(propName, value ? "yes" : "no", suffix, indentation);
|
||||
}
|
||||
|
||||
template <typename NumberType, Traits::EnableIfAny<std::is_floating_point<NumberType>, std::is_integral<NumberType>> * = nullptr>
|
||||
template <typename NumberType, CppUtilities::Traits::EnableIfAny<std::is_floating_point<NumberType>, std::is_integral<NumberType>> * = nullptr>
|
||||
inline void printProperty(
|
||||
const char *propName, const NumberType value, const char *suffix = nullptr, bool force = false, ApplicationUtilities::Indentation indentation = 3)
|
||||
const char *propName, const NumberType value, const char *suffix = nullptr, bool force = false, CppUtilities::Indentation indentation = 3)
|
||||
{
|
||||
if (value >= 0 || force) {
|
||||
printProperty(propName, ConversionUtilities::numberToString<NumberType>(value).data(), suffix, indentation);
|
||||
printProperty(propName, CppUtilities::numberToString<NumberType>(value).data(), suffix, indentation);
|
||||
}
|
||||
}
|
||||
} // namespace Cli
|
||||
|
|
|
@ -16,10 +16,8 @@
|
|||
|
||||
using namespace std;
|
||||
using namespace Data;
|
||||
using namespace ChronoUtilities;
|
||||
using namespace IoUtilities;
|
||||
using namespace TestUtilities;
|
||||
using namespace TestUtilities::Literals;
|
||||
using namespace CppUtilities;
|
||||
using namespace CppUtilities::Literals;
|
||||
|
||||
using namespace CPPUNIT_NS;
|
||||
|
||||
|
|
|
@ -23,8 +23,7 @@
|
|||
#include <utility>
|
||||
|
||||
using namespace std;
|
||||
using namespace ChronoUtilities;
|
||||
using namespace ConversionUtilities;
|
||||
using namespace CppUtilities;
|
||||
|
||||
namespace Data {
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ class LIB_SYNCTHING_CONNECTOR_EXPORT SyncthingConnection : public QObject {
|
|||
Q_PROPERTY(double totalOutgoingRate READ totalOutgoingRate NOTIFY trafficChanged)
|
||||
Q_PROPERTY(QString lastSyncedFile READ lastSyncedFile)
|
||||
Q_PROPERTY(QString syncthingVersion READ syncthingVersion)
|
||||
Q_PROPERTY(ChronoUtilities::DateTime lastSyncTime READ lastSyncTime)
|
||||
Q_PROPERTY(CppUtilities::DateTime lastSyncTime READ lastSyncTime)
|
||||
Q_PROPERTY(QList<QSslError> expectedSslErrors READ expectedSslErrors)
|
||||
Q_PROPERTY(std::vector<const SyncthingDev *> connectedDevices READ connectedDevices)
|
||||
Q_PROPERTY(QStringList directoryIds READ directoryIds)
|
||||
|
@ -142,9 +142,9 @@ public:
|
|||
const std::vector<SyncthingDev> &devInfo() const;
|
||||
SyncthingOverallDirStatistics computeOverallDirStatistics() const;
|
||||
const QString &lastSyncedFile() const;
|
||||
ChronoUtilities::DateTime lastSyncTime() const;
|
||||
ChronoUtilities::DateTime startTime() const;
|
||||
ChronoUtilities::TimeSpan uptime() const;
|
||||
CppUtilities::DateTime lastSyncTime() const;
|
||||
CppUtilities::DateTime startTime() const;
|
||||
CppUtilities::TimeSpan uptime() const;
|
||||
const QString &syncthingVersion() const;
|
||||
QStringList directoryIds() const;
|
||||
QStringList deviceIds() const;
|
||||
|
@ -220,11 +220,10 @@ Q_SIGNALS:
|
|||
void devStatusChanged(const SyncthingDev &dev, int index);
|
||||
void downloadProgressChanged();
|
||||
void dirStatisticsChanged();
|
||||
void dirCompleted(ChronoUtilities::DateTime when, const SyncthingDir &dir, int index, const SyncthingDev *remoteDev = nullptr);
|
||||
void newNotification(ChronoUtilities::DateTime when, const QString &message);
|
||||
void newDevAvailable(ChronoUtilities::DateTime when, const QString &devId, const QString &address);
|
||||
void newDirAvailable(
|
||||
ChronoUtilities::DateTime when, const QString &devId, const SyncthingDev *dev, const QString &dirId, const QString &dirLabel);
|
||||
void dirCompleted(CppUtilities::DateTime when, const SyncthingDir &dir, int index, const SyncthingDev *remoteDev = nullptr);
|
||||
void newNotification(CppUtilities::DateTime when, const QString &message);
|
||||
void newDevAvailable(CppUtilities::DateTime when, const QString &devId, const QString &address);
|
||||
void newDirAvailable(CppUtilities::DateTime when, const QString &devId, const SyncthingDev *dev, const QString &dirId, const QString &dirLabel);
|
||||
void error(const QString &errorMessage, SyncthingErrorCategory category, int networkError, const QNetworkRequest &request = QNetworkRequest(),
|
||||
const QByteArray &response = QByteArray());
|
||||
void statusChanged(SyncthingStatus newStatus);
|
||||
|
@ -258,20 +257,19 @@ private Q_SLOTS:
|
|||
void readEvents();
|
||||
void readEventsFromJsonArray(const QJsonArray &events, int &idVariable);
|
||||
void readStartingEvent(const QJsonObject &eventData);
|
||||
void readStatusChangedEvent(ChronoUtilities::DateTime eventTime, const QJsonObject &eventData);
|
||||
void readDownloadProgressEvent(ChronoUtilities::DateTime eventTime, const QJsonObject &eventData);
|
||||
void readDirEvent(ChronoUtilities::DateTime eventTime, const QString &eventType, const QJsonObject &eventData);
|
||||
void readDeviceEvent(ChronoUtilities::DateTime eventTime, const QString &eventType, const QJsonObject &eventData);
|
||||
void readItemStarted(ChronoUtilities::DateTime eventTime, const QJsonObject &eventData);
|
||||
void readItemFinished(ChronoUtilities::DateTime eventTime, const QJsonObject &eventData);
|
||||
void readFolderErrors(ChronoUtilities::DateTime eventTime, const QJsonObject &eventData, SyncthingDir &dirInfo, int index);
|
||||
void readFolderCompletion(ChronoUtilities::DateTime eventTime, const QJsonObject &eventData, SyncthingDir &dirInfo, int index);
|
||||
void readFolderCompletion(
|
||||
ChronoUtilities::DateTime eventTime, const QJsonObject &eventData, SyncthingDir &dirInfo, int index, const QString &devId);
|
||||
void readLocalFolderCompletion(ChronoUtilities::DateTime eventTime, const QJsonObject &eventData, SyncthingDir &dirInfo, int index);
|
||||
void readStatusChangedEvent(CppUtilities::DateTime eventTime, const QJsonObject &eventData);
|
||||
void readDownloadProgressEvent(CppUtilities::DateTime eventTime, const QJsonObject &eventData);
|
||||
void readDirEvent(CppUtilities::DateTime eventTime, const QString &eventType, const QJsonObject &eventData);
|
||||
void readDeviceEvent(CppUtilities::DateTime eventTime, const QString &eventType, const QJsonObject &eventData);
|
||||
void readItemStarted(CppUtilities::DateTime eventTime, const QJsonObject &eventData);
|
||||
void readItemFinished(CppUtilities::DateTime eventTime, const QJsonObject &eventData);
|
||||
void readFolderErrors(CppUtilities::DateTime eventTime, const QJsonObject &eventData, SyncthingDir &dirInfo, int index);
|
||||
void readFolderCompletion(CppUtilities::DateTime eventTime, const QJsonObject &eventData, SyncthingDir &dirInfo, int index);
|
||||
void readFolderCompletion(CppUtilities::DateTime eventTime, const QJsonObject &eventData, SyncthingDir &dirInfo, int index, const QString &devId);
|
||||
void readLocalFolderCompletion(CppUtilities::DateTime eventTime, const QJsonObject &eventData, SyncthingDir &dirInfo, int index);
|
||||
void readRemoteFolderCompletion(
|
||||
ChronoUtilities::DateTime eventTime, const QJsonObject &eventData, SyncthingDir &dirInfo, int index, const QString &devId);
|
||||
void readRemoteIndexUpdated(ChronoUtilities::DateTime eventTime, const QJsonObject &eventData);
|
||||
CppUtilities::DateTime eventTime, const QJsonObject &eventData, SyncthingDir &dirInfo, int index, const QString &devId);
|
||||
void readRemoteIndexUpdated(CppUtilities::DateTime eventTime, const QJsonObject &eventData);
|
||||
void readPostConfig();
|
||||
void readRescan();
|
||||
void readDevPauseResume();
|
||||
|
@ -280,13 +278,13 @@ private Q_SLOTS:
|
|||
void readShutdown();
|
||||
void readDirStatus();
|
||||
void readDirPullErrors();
|
||||
void readDirSummary(ChronoUtilities::DateTime eventTime, const QJsonObject &summary, SyncthingDir &dirInfo, int index);
|
||||
void readDirRejected(ChronoUtilities::DateTime eventTime, const QString &dirId, const QJsonObject &eventData);
|
||||
void readDevRejected(ChronoUtilities::DateTime eventTime, const QString &devId, const QJsonObject &eventData);
|
||||
void readDirSummary(CppUtilities::DateTime eventTime, const QJsonObject &summary, SyncthingDir &dirInfo, int index);
|
||||
void readDirRejected(CppUtilities::DateTime eventTime, const QString &dirId, const QJsonObject &eventData);
|
||||
void readDevRejected(CppUtilities::DateTime eventTime, const QString &devId, const QJsonObject &eventData);
|
||||
void readCompletion();
|
||||
void readVersion();
|
||||
void readDiskEvents();
|
||||
void readChangeEvent(ChronoUtilities::DateTime eventTime, const QString &eventType, const QJsonObject &eventData);
|
||||
void readChangeEvent(CppUtilities::DateTime eventTime, const QString &eventType, const QJsonObject &eventData);
|
||||
void readLog();
|
||||
void readQrCode();
|
||||
|
||||
|
@ -295,7 +293,7 @@ private Q_SLOTS:
|
|||
void continueReconnecting();
|
||||
void autoReconnect();
|
||||
void setStatus(SyncthingStatus status);
|
||||
void emitNotification(ChronoUtilities::DateTime when, const QString &message);
|
||||
void emitNotification(CppUtilities::DateTime when, const QString &message);
|
||||
void emitError(const QString &message, const QJsonParseError &jsonError, QNetworkReply *reply, const QByteArray &response = QByteArray());
|
||||
void emitError(const QString &message, SyncthingErrorCategory category, QNetworkReply *reply);
|
||||
void emitMyIdChanged(const QString &newId);
|
||||
|
@ -357,10 +355,10 @@ private:
|
|||
bool m_hasDiskEvents;
|
||||
std::vector<SyncthingDir> m_dirs;
|
||||
std::vector<SyncthingDev> m_devs;
|
||||
ChronoUtilities::DateTime m_lastConnectionsUpdate;
|
||||
ChronoUtilities::DateTime m_lastFileTime;
|
||||
ChronoUtilities::DateTime m_lastErrorTime;
|
||||
ChronoUtilities::DateTime m_startTime;
|
||||
CppUtilities::DateTime m_lastConnectionsUpdate;
|
||||
CppUtilities::DateTime m_lastFileTime;
|
||||
CppUtilities::DateTime m_lastErrorTime;
|
||||
CppUtilities::DateTime m_startTime;
|
||||
QString m_lastFileName;
|
||||
QString m_syncthingVersion;
|
||||
bool m_lastFileDeleted;
|
||||
|
@ -684,7 +682,7 @@ inline const QString &SyncthingConnection::lastSyncedFile() const
|
|||
/*!
|
||||
* \brief Returns the time of the most recent sync.
|
||||
*/
|
||||
inline ChronoUtilities::DateTime SyncthingConnection::lastSyncTime() const
|
||||
inline CppUtilities::DateTime SyncthingConnection::lastSyncTime() const
|
||||
{
|
||||
return m_lastFileTime;
|
||||
}
|
||||
|
@ -692,7 +690,7 @@ inline ChronoUtilities::DateTime SyncthingConnection::lastSyncTime() const
|
|||
/*!
|
||||
* \brief Returns when Syncthing has been started.
|
||||
*/
|
||||
inline ChronoUtilities::DateTime SyncthingConnection::startTime() const
|
||||
inline CppUtilities::DateTime SyncthingConnection::startTime() const
|
||||
{
|
||||
return m_startTime;
|
||||
}
|
||||
|
@ -700,9 +698,9 @@ inline ChronoUtilities::DateTime SyncthingConnection::startTime() const
|
|||
/*!
|
||||
* \brief Returns how long Syncthing has been running.
|
||||
*/
|
||||
inline ChronoUtilities::TimeSpan SyncthingConnection::uptime() const
|
||||
inline CppUtilities::TimeSpan SyncthingConnection::uptime() const
|
||||
{
|
||||
return ChronoUtilities::DateTime::gmtNow() - m_startTime;
|
||||
return CppUtilities::DateTime::gmtNow() - m_startTime;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
|
@ -25,10 +25,9 @@
|
|||
#include <utility>
|
||||
|
||||
using namespace std;
|
||||
using namespace ChronoUtilities;
|
||||
using namespace ConversionUtilities;
|
||||
using namespace CppUtilities;
|
||||
#if defined(LIB_SYNCTHING_CONNECTOR_LOG_SYNCTHING_EVENTS) || defined(LIB_SYNCTHING_CONNECTOR_LOG_API_CALLS)
|
||||
using namespace EscapeCodes;
|
||||
using namespace CppUtilities::EscapeCodes;
|
||||
#endif
|
||||
|
||||
namespace Data {
|
||||
|
|
|
@ -14,10 +14,8 @@
|
|||
#include <string>
|
||||
|
||||
using namespace std;
|
||||
using namespace IoUtilities;
|
||||
using namespace EscapeCodes;
|
||||
using namespace ConversionUtilities;
|
||||
using namespace TestUtilities;
|
||||
using namespace CppUtilities;
|
||||
using namespace CppUtilities::EscapeCodes;
|
||||
|
||||
namespace Data {
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ struct LIB_SYNCTHING_CONNECTOR_EXPORT SyncthingDev {
|
|||
QString connectionAddress;
|
||||
QString connectionType;
|
||||
QString clientVersion;
|
||||
ChronoUtilities::DateTime lastSeen;
|
||||
CppUtilities::DateTime lastSeen;
|
||||
};
|
||||
|
||||
inline SyncthingDev::SyncthingDev(const QString &id, const QString &name)
|
||||
|
|
|
@ -6,8 +6,7 @@
|
|||
#include <QJsonObject>
|
||||
#include <QStringBuilder>
|
||||
|
||||
using namespace ChronoUtilities;
|
||||
using namespace ConversionUtilities;
|
||||
using namespace CppUtilities;
|
||||
|
||||
namespace Data {
|
||||
|
||||
|
@ -89,7 +88,7 @@ bool SyncthingDir::finalizeStatusUpdate(SyncthingDirStatus newStatus, DateTime t
|
|||
* \brief Assigns the status from the specified status string.
|
||||
* \returns Returns whether the status has actually changed.
|
||||
*/
|
||||
bool SyncthingDir::assignStatus(const QString &statusStr, ChronoUtilities::DateTime time)
|
||||
bool SyncthingDir::assignStatus(const QString &statusStr, CppUtilities::DateTime time)
|
||||
{
|
||||
if (!checkWhetherStatusUpdateRelevant(time)) {
|
||||
return false;
|
||||
|
|
|
@ -41,7 +41,7 @@ struct LIB_SYNCTHING_CONNECTOR_EXPORT SyncthingFileChange {
|
|||
QString type;
|
||||
QString modifiedBy;
|
||||
QString path;
|
||||
ChronoUtilities::DateTime eventTime;
|
||||
CppUtilities::DateTime eventTime;
|
||||
bool local = false;
|
||||
};
|
||||
|
||||
|
@ -60,12 +60,12 @@ struct LIB_SYNCTHING_CONNECTOR_EXPORT SyncthingItemDownloadProgress {
|
|||
int bytesAlreadyHandled;
|
||||
int totalNumberOfBytes = 0;
|
||||
QString label;
|
||||
ChronoUtilities::DateTime lastUpdate;
|
||||
CppUtilities::DateTime lastUpdate;
|
||||
static constexpr unsigned int syncthingBlockSize = 128 * 1024;
|
||||
};
|
||||
|
||||
struct LIB_SYNCTHING_CONNECTOR_EXPORT SyncthingCompletion {
|
||||
ChronoUtilities::DateTime lastUpdate;
|
||||
CppUtilities::DateTime lastUpdate;
|
||||
double percentage = 0;
|
||||
quint64 globalBytes = 0;
|
||||
struct Needed {
|
||||
|
@ -131,8 +131,8 @@ constexpr bool SyncthingStatistics::operator!=(const SyncthingStatistics &other)
|
|||
|
||||
struct LIB_SYNCTHING_CONNECTOR_EXPORT SyncthingDir {
|
||||
SyncthingDir(const QString &id = QString(), const QString &label = QString(), const QString &path = QString());
|
||||
bool assignStatus(const QString &statusStr, ChronoUtilities::DateTime time);
|
||||
bool assignStatus(SyncthingDirStatus newStatus, ChronoUtilities::DateTime time);
|
||||
bool assignStatus(const QString &statusStr, CppUtilities::DateTime time);
|
||||
bool assignStatus(SyncthingDirStatus newStatus, CppUtilities::DateTime time);
|
||||
bool assignDirType(const QString &dirType);
|
||||
const QString &displayName() const;
|
||||
QString statusString() const;
|
||||
|
@ -151,8 +151,8 @@ struct LIB_SYNCTHING_CONNECTOR_EXPORT SyncthingDir {
|
|||
int rescanInterval = 0;
|
||||
int minDiskFreePercentage = 0;
|
||||
SyncthingDirStatus status = SyncthingDirStatus::Unknown;
|
||||
ChronoUtilities::DateTime lastStatusUpdate;
|
||||
ChronoUtilities::DateTime lastSyncStarted;
|
||||
CppUtilities::DateTime lastStatusUpdate;
|
||||
CppUtilities::DateTime lastSyncStarted;
|
||||
int completionPercentage = 0;
|
||||
int scanningPercentage = 0;
|
||||
double scanningRate = 0;
|
||||
|
@ -163,9 +163,9 @@ struct LIB_SYNCTHING_CONNECTOR_EXPORT SyncthingDir {
|
|||
std::vector<SyncthingItemError> itemErrors;
|
||||
std::vector<SyncthingFileChange> recentChanges;
|
||||
SyncthingStatistics globalStats, localStats, neededStats;
|
||||
ChronoUtilities::DateTime lastStatisticsUpdate;
|
||||
ChronoUtilities::DateTime lastScanTime;
|
||||
ChronoUtilities::DateTime lastFileTime;
|
||||
CppUtilities::DateTime lastStatisticsUpdate;
|
||||
CppUtilities::DateTime lastScanTime;
|
||||
CppUtilities::DateTime lastFileTime;
|
||||
QString lastFileName;
|
||||
std::vector<SyncthingItemDownloadProgress> downloadingItems;
|
||||
int blocksAlreadyDownloaded = 0;
|
||||
|
@ -181,8 +181,8 @@ struct LIB_SYNCTHING_CONNECTOR_EXPORT SyncthingDir {
|
|||
bool paused = false;
|
||||
|
||||
private:
|
||||
bool checkWhetherStatusUpdateRelevant(ChronoUtilities::DateTime time);
|
||||
bool finalizeStatusUpdate(SyncthingDirStatus newStatus, ChronoUtilities::DateTime time);
|
||||
bool checkWhetherStatusUpdateRelevant(CppUtilities::DateTime time);
|
||||
bool finalizeStatusUpdate(SyncthingDirStatus newStatus, CppUtilities::DateTime time);
|
||||
};
|
||||
|
||||
inline SyncthingDir::SyncthingDir(const QString &id, const QString &label, const QString &path)
|
||||
|
@ -212,7 +212,7 @@ inline bool SyncthingDir::isUnshared() const
|
|||
return deviceIds.empty() && (status == SyncthingDirStatus::Idle || status == SyncthingDirStatus::Unknown);
|
||||
}
|
||||
|
||||
inline bool SyncthingDir::assignStatus(SyncthingDirStatus newStatus, ChronoUtilities::DateTime time)
|
||||
inline bool SyncthingDir::assignStatus(SyncthingDirStatus newStatus, CppUtilities::DateTime time)
|
||||
{
|
||||
return checkWhetherStatusUpdateRelevant(time) && finalizeStatusUpdate(newStatus, time);
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
#include <c++utilities/chrono/datetime.h>
|
||||
|
||||
using namespace ChronoUtilities;
|
||||
using namespace CppUtilities;
|
||||
|
||||
namespace Data {
|
||||
|
||||
|
@ -171,7 +171,7 @@ void SyncthingNotifier::emitConnectedAndDisconnected(SyncthingStatus newStatus)
|
|||
/*!
|
||||
* \brief Emits the syncComplete() signal.
|
||||
*/
|
||||
void SyncthingNotifier::emitSyncComplete(ChronoUtilities::DateTime when, const SyncthingDir &dir, int index, const SyncthingDev *remoteDev)
|
||||
void SyncthingNotifier::emitSyncComplete(CppUtilities::DateTime when, const SyncthingDir &dir, int index, const SyncthingDev *remoteDev)
|
||||
{
|
||||
VAR_UNUSED(when)
|
||||
VAR_UNUSED(index)
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
#include <QObject>
|
||||
|
||||
namespace ChronoUtilities {
|
||||
namespace CppUtilities {
|
||||
class DateTime;
|
||||
}
|
||||
|
||||
|
@ -93,14 +93,13 @@ Q_SIGNALS:
|
|||
|
||||
private Q_SLOTS:
|
||||
void handleStatusChangedEvent(SyncthingStatus newStatus);
|
||||
void handleNewDevEvent(ChronoUtilities::DateTime when, const QString &devId, const QString &address);
|
||||
void handleNewDirEvent(
|
||||
ChronoUtilities::DateTime when, const QString &devId, const SyncthingDev *dev, const QString &dirId, const QString &dirLabel);
|
||||
void handleNewDevEvent(CppUtilities::DateTime when, const QString &devId, const QString &address);
|
||||
void handleNewDirEvent(CppUtilities::DateTime when, const QString &devId, const SyncthingDev *dev, const QString &dirId, const QString &dirLabel);
|
||||
|
||||
private:
|
||||
bool isDisconnectRelevant() const;
|
||||
void emitConnectedAndDisconnected(SyncthingStatus newStatus);
|
||||
void emitSyncComplete(ChronoUtilities::DateTime when, const SyncthingDir &dir, int index, const SyncthingDev *remoteDev);
|
||||
void emitSyncComplete(CppUtilities::DateTime when, const SyncthingDir &dir, int index, const SyncthingDev *remoteDev);
|
||||
|
||||
const SyncthingConnection &m_connection;
|
||||
#ifdef LIB_SYNCTHING_CONNECTOR_SUPPORT_SYSTEMD
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include <QTimer>
|
||||
|
||||
using namespace ChronoUtilities;
|
||||
using namespace CppUtilities;
|
||||
|
||||
namespace Data {
|
||||
|
||||
|
|
|
@ -13,13 +13,13 @@ namespace Data {
|
|||
class LIB_SYNCTHING_CONNECTOR_EXPORT SyncthingProcess : public QProcess {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool running READ isRunning)
|
||||
Q_PROPERTY(ChronoUtilities::DateTime activeSince READ activeSince)
|
||||
Q_PROPERTY(CppUtilities::DateTime activeSince READ activeSince)
|
||||
Q_PROPERTY(bool manuallyStopped READ isManuallyStopped)
|
||||
|
||||
public:
|
||||
explicit SyncthingProcess(QObject *parent = nullptr);
|
||||
bool isRunning() const;
|
||||
ChronoUtilities::DateTime activeSince() const;
|
||||
CppUtilities::DateTime activeSince() const;
|
||||
bool isActiveFor(unsigned int atLeastSeconds) const;
|
||||
bool isManuallyStopped() const;
|
||||
static SyncthingProcess *mainInstance();
|
||||
|
@ -43,7 +43,7 @@ private Q_SLOTS:
|
|||
private:
|
||||
QString m_program;
|
||||
QStringList m_arguments;
|
||||
ChronoUtilities::DateTime m_activeSince;
|
||||
CppUtilities::DateTime m_activeSince;
|
||||
QTimer m_killTimer;
|
||||
bool m_manuallyStopped;
|
||||
static SyncthingProcess *s_mainInstance;
|
||||
|
@ -54,14 +54,14 @@ inline bool SyncthingProcess::isRunning() const
|
|||
return state() != QProcess::NotRunning;
|
||||
}
|
||||
|
||||
inline ChronoUtilities::DateTime SyncthingProcess::activeSince() const
|
||||
inline CppUtilities::DateTime SyncthingProcess::activeSince() const
|
||||
{
|
||||
return m_activeSince;
|
||||
}
|
||||
|
||||
inline bool SyncthingProcess::isActiveFor(unsigned int atLeastSeconds) const
|
||||
{
|
||||
return !m_activeSince.isNull() && (ChronoUtilities::DateTime::gmtNow() - m_activeSince).totalSeconds() > atLeastSeconds;
|
||||
return !m_activeSince.isNull() && (CppUtilities::DateTime::gmtNow() - m_activeSince).totalSeconds() > atLeastSeconds;
|
||||
}
|
||||
|
||||
inline bool SyncthingProcess::isManuallyStopped() const
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
using namespace std;
|
||||
using namespace std::placeholders;
|
||||
using namespace ChronoUtilities;
|
||||
using namespace CppUtilities;
|
||||
|
||||
namespace Data {
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ class SyncthingService : public QObject {
|
|||
Q_PROPERTY(bool unitAvailable READ isUnitAvailable NOTIFY unitAvailableChanged)
|
||||
Q_PROPERTY(QString activeState READ activeState NOTIFY activeStateChanged)
|
||||
Q_PROPERTY(QString subState READ subState NOTIFY subStateChanged)
|
||||
Q_PROPERTY(ChronoUtilities::DateTime activeSince READ activeSince NOTIFY activeStateChanged)
|
||||
Q_PROPERTY(CppUtilities::DateTime activeSince READ activeSince NOTIFY activeStateChanged)
|
||||
Q_PROPERTY(QString unitFileState READ unitFileState NOTIFY unitFileStateChanged)
|
||||
Q_PROPERTY(QString description READ description NOTIFY descriptionChanged)
|
||||
Q_PROPERTY(bool running READ isRunning WRITE setRunning NOTIFY runningChanged)
|
||||
|
@ -53,11 +53,11 @@ public:
|
|||
bool isUnitAvailable() const;
|
||||
const QString &activeState() const;
|
||||
const QString &subState() const;
|
||||
ChronoUtilities::DateTime activeSince() const;
|
||||
CppUtilities::DateTime activeSince() const;
|
||||
bool isActiveFor(unsigned int atLeastSeconds) const;
|
||||
bool isActiveWithoutSleepFor(unsigned int atLeastSeconds) const;
|
||||
static bool isActiveWithoutSleepFor(ChronoUtilities::DateTime activeSince, unsigned int atLeastSeconds);
|
||||
static ChronoUtilities::DateTime lastWakeUp();
|
||||
static bool isActiveWithoutSleepFor(CppUtilities::DateTime activeSince, unsigned int atLeastSeconds);
|
||||
static CppUtilities::DateTime lastWakeUp();
|
||||
const QString &unitFileState() const;
|
||||
const QString &description() const;
|
||||
bool isRunning() const;
|
||||
|
@ -80,7 +80,7 @@ Q_SIGNALS:
|
|||
void unitNameChanged(const QString &unitName);
|
||||
void systemdAvailableChanged(bool available);
|
||||
void unitAvailableChanged(bool available);
|
||||
void stateChanged(const QString &activeState, const QString &subState, ChronoUtilities::DateTime activeSince);
|
||||
void stateChanged(const QString &activeState, const QString &subState, CppUtilities::DateTime activeSince);
|
||||
void activeStateChanged(const QString &activeState);
|
||||
void subStateChanged(const QString &subState);
|
||||
void unitFileStateChanged(const QString &unitFileState);
|
||||
|
@ -104,14 +104,14 @@ private Q_SLOTS:
|
|||
private:
|
||||
bool handlePropertyChanged(QString &variable, void (SyncthingService::*signal)(const QString &), const QString &propertyName,
|
||||
const QVariantMap &changedProperties, const QStringList &invalidatedProperties);
|
||||
bool handlePropertyChanged(ChronoUtilities::DateTime &variable, const QString &propertyName, const QVariantMap &changedProperties,
|
||||
bool handlePropertyChanged(CppUtilities::DateTime &variable, const QString &propertyName, const QVariantMap &changedProperties,
|
||||
const QStringList &invalidatedProperties);
|
||||
void registerErrorHandler(const QDBusPendingCall &call, const char *context);
|
||||
|
||||
static OrgFreedesktopSystemd1ManagerInterface *s_manager;
|
||||
static OrgFreedesktopLogin1ManagerInterface *s_loginManager;
|
||||
static bool s_fallingAsleep;
|
||||
static ChronoUtilities::DateTime s_lastWakeUp;
|
||||
static CppUtilities::DateTime s_lastWakeUp;
|
||||
static SyncthingService *s_mainInstance;
|
||||
QString m_unitName;
|
||||
QDBusServiceWatcher *m_serviceWatcher;
|
||||
|
@ -122,7 +122,7 @@ private:
|
|||
QString m_activeState;
|
||||
QString m_subState;
|
||||
QString m_unitFileState;
|
||||
ChronoUtilities::DateTime m_activeSince;
|
||||
CppUtilities::DateTime m_activeSince;
|
||||
bool m_manuallyStopped;
|
||||
bool m_unitAvailable;
|
||||
};
|
||||
|
@ -182,14 +182,14 @@ inline bool SyncthingService::isManuallyStopped() const
|
|||
return m_manuallyStopped;
|
||||
}
|
||||
|
||||
inline ChronoUtilities::DateTime SyncthingService::activeSince() const
|
||||
inline CppUtilities::DateTime SyncthingService::activeSince() const
|
||||
{
|
||||
return m_activeSince;
|
||||
}
|
||||
|
||||
inline bool SyncthingService::isActiveFor(unsigned int atLeastSeconds) const
|
||||
{
|
||||
return !m_activeSince.isNull() && (ChronoUtilities::DateTime::gmtNow() - m_activeSince).totalSeconds() > atLeastSeconds;
|
||||
return !m_activeSince.isNull() && (CppUtilities::DateTime::gmtNow() - m_activeSince).totalSeconds() > atLeastSeconds;
|
||||
}
|
||||
|
||||
inline bool SyncthingService::isActiveWithoutSleepFor(unsigned int atLeastSeconds) const
|
||||
|
@ -197,7 +197,7 @@ inline bool SyncthingService::isActiveWithoutSleepFor(unsigned int atLeastSecond
|
|||
return isActiveWithoutSleepFor(m_activeSince, atLeastSeconds);
|
||||
}
|
||||
|
||||
inline ChronoUtilities::DateTime SyncthingService::lastWakeUp()
|
||||
inline CppUtilities::DateTime SyncthingService::lastWakeUp()
|
||||
{
|
||||
return s_lastWakeUp;
|
||||
}
|
||||
|
|
|
@ -15,9 +15,8 @@
|
|||
|
||||
using namespace std;
|
||||
using namespace Data;
|
||||
using namespace ChronoUtilities;
|
||||
using namespace TestUtilities;
|
||||
using namespace TestUtilities::Literals;
|
||||
using namespace CppUtilities;
|
||||
using namespace CppUtilities::Literals;
|
||||
|
||||
using namespace CPPUNIT_NS;
|
||||
|
||||
|
@ -415,10 +414,10 @@ void ConnectionTests::testInitialConnection()
|
|||
|
||||
void ConnectionTests::testSendingError()
|
||||
{
|
||||
bool newNotificationEmitted = false;
|
||||
const DateTime sentTime(DateTime::now());
|
||||
const QString sentMessage(QStringLiteral("test notification"));
|
||||
const auto newNotificationHandler = [&](ChronoUtilities::DateTime receivedTime, const QString &receivedMessage) {
|
||||
auto newNotificationEmitted = false;
|
||||
const auto sentTime(DateTime::now());
|
||||
const auto sentMessage(QStringLiteral("test notification"));
|
||||
const auto newNotificationHandler = [&](DateTime receivedTime, const QString &receivedMessage) {
|
||||
newNotificationEmitted |= receivedTime == sentTime && receivedMessage == sentMessage;
|
||||
};
|
||||
waitForSignals([this, sentTime, &sentMessage] { m_connection.emitNotification(sentTime, sentMessage); }, 500,
|
||||
|
|
|
@ -19,9 +19,8 @@
|
|||
|
||||
using namespace std;
|
||||
using namespace Data;
|
||||
using namespace ChronoUtilities;
|
||||
using namespace TestUtilities;
|
||||
using namespace TestUtilities::Literals;
|
||||
using namespace CppUtilities;
|
||||
using namespace CppUtilities::Literals;
|
||||
|
||||
using namespace CPPUNIT_NS;
|
||||
|
||||
|
|
|
@ -14,8 +14,7 @@
|
|||
#include <QStringBuilder>
|
||||
#include <QUrl>
|
||||
|
||||
using namespace ChronoUtilities;
|
||||
using namespace ConversionUtilities;
|
||||
using namespace CppUtilities;
|
||||
|
||||
namespace Data {
|
||||
|
||||
|
|
|
@ -15,17 +15,19 @@
|
|||
QT_FORWARD_DECLARE_CLASS(QJsonObject)
|
||||
QT_FORWARD_DECLARE_CLASS(QHostAddress)
|
||||
|
||||
namespace ChronoUtilities {
|
||||
namespace CppUtilities {
|
||||
class DateTime;
|
||||
}
|
||||
|
||||
namespace Data {
|
||||
|
||||
namespace Traits = CppUtilities::Traits;
|
||||
|
||||
struct SyncthingStatistics;
|
||||
struct SyncthingDir;
|
||||
struct SyncthingDev;
|
||||
|
||||
QString LIB_SYNCTHING_CONNECTOR_EXPORT agoString(ChronoUtilities::DateTime dateTime);
|
||||
QString LIB_SYNCTHING_CONNECTOR_EXPORT agoString(CppUtilities::DateTime dateTime);
|
||||
QString LIB_SYNCTHING_CONNECTOR_EXPORT trafficString(std::uint64_t total, double rate);
|
||||
QString LIB_SYNCTHING_CONNECTOR_EXPORT directoryStatusString(const Data::SyncthingStatistics &stats);
|
||||
QString LIB_SYNCTHING_CONNECTOR_EXPORT syncCompleteString(
|
||||
|
|
|
@ -23,9 +23,9 @@
|
|||
#include "resources/qtconfig.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace Dialogs;
|
||||
using namespace CppUtilities::EscapeCodes;
|
||||
using namespace QtUtilities;
|
||||
using namespace Data;
|
||||
using namespace EscapeCodes;
|
||||
|
||||
SyncthingFileItemActionStaticData::SyncthingFileItemActionStaticData()
|
||||
: m_initialized(false)
|
||||
|
@ -98,8 +98,8 @@ void SyncthingFileItemActionStaticData::showAboutDialog()
|
|||
{
|
||||
auto *const aboutDialog
|
||||
= new AboutDialog(nullptr, QStringLiteral(APP_NAME), QStringLiteral(APP_AUTHOR "\nSyncthing icons from Syncthing project"),
|
||||
QStringLiteral(APP_VERSION), ApplicationUtilities::applicationInfo.dependencyVersions, QStringLiteral(APP_URL),
|
||||
QStringLiteral(APP_DESCRIPTION), renderSvgImage(makeSyncthingIcon()).toImage());
|
||||
QStringLiteral(APP_VERSION), CppUtilities::applicationInfo.dependencyVersions, QStringLiteral(APP_URL), QStringLiteral(APP_DESCRIPTION),
|
||||
renderSvgImage(makeSyncthingIcon()).toImage());
|
||||
aboutDialog->setWindowTitle(tr("About") + QStringLiteral(" - " APP_NAME));
|
||||
aboutDialog->setWindowIcon(QIcon::fromTheme(QStringLiteral("syncthingtray")));
|
||||
aboutDialog->setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include <iostream>
|
||||
#endif
|
||||
|
||||
using namespace CppUtilities;
|
||||
using namespace Data;
|
||||
|
||||
SyncthingMenuAction::SyncthingMenuAction(const KFileItemListProperties &properties, const QList<QAction *> &actions, QObject *parent)
|
||||
|
|
|
@ -122,6 +122,9 @@ list(APPEND CMAKE_MODULE_PATH ${CPP_UTILITIES_MODULE_DIRS})
|
|||
list(APPEND PRIVATE_SHARED_INCLUDE_DIRS ${CPP_UTILITIES_INCLUDE_DIRS})
|
||||
list(APPEND PRIVATE_STATIC_INCLUDE_DIRS ${CPP_UTILITIES_INCLUDE_DIRS})
|
||||
|
||||
# use std::filesystem
|
||||
use_standard_filesystem()
|
||||
|
||||
# include modules to apply configuration
|
||||
include(BasicConfig)
|
||||
include(WindowsResources)
|
||||
|
|
|
@ -11,15 +11,13 @@
|
|||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
#include <cstdlib>
|
||||
#include <filesystem>
|
||||
#include <functional>
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace ChronoUtilities;
|
||||
using namespace ConversionUtilities;
|
||||
using namespace IoUtilities;
|
||||
using namespace TestUtilities;
|
||||
using namespace CppUtilities;
|
||||
using namespace LibSyncthing;
|
||||
|
||||
using namespace CPPUNIT_NS;
|
||||
|
@ -76,16 +74,28 @@ string InterfaceTests::setupConfigDir()
|
|||
if (configFilePath.empty()) {
|
||||
throw runtime_error("Unable to setup Syncthing config directory.");
|
||||
}
|
||||
|
||||
// clean database
|
||||
const auto configDir(directory(configFilePath));
|
||||
for (const auto &dir : directoryEntries(configDir.data(), DirectoryEntryType::Directory)) {
|
||||
if (dir == "." || dir == "..") {
|
||||
continue;
|
||||
}
|
||||
for (const auto &file : directoryEntries((configDir % '/' + dir).data(), DirectoryEntryType::File)) {
|
||||
const auto toRemove(configDir % '/' % dir % '/' + file);
|
||||
CPPUNIT_ASSERT_EQUAL_MESSAGE("removing " + toRemove, 0, remove(toRemove.data()));
|
||||
try {
|
||||
const auto dirIterator = filesystem::directory_iterator(configDir);
|
||||
for (const auto &dir : dirIterator) {
|
||||
if (!dir.is_directory() || dir == "." || dir == "..") {
|
||||
continue;
|
||||
}
|
||||
const auto dirPath = dir.path();
|
||||
const auto subdirIterator = filesystem::directory_iterator(configDir % '/' + dirPath);
|
||||
for (const auto &file : subdirIterator) {
|
||||
if (file.is_directory()) {
|
||||
continue;
|
||||
}
|
||||
const auto toRemove = configDir % '/' % dirPath % '/' + file.path();
|
||||
CPPUNIT_ASSERT_EQUAL_MESSAGE("removing " + toRemove, 0, remove(toRemove.data()));
|
||||
}
|
||||
}
|
||||
|
||||
} catch (const filesystem::filesystem_error &error) {
|
||||
CPPUNIT_FAIL(argsToString("Unable to clean config dir ", configDir, ": ", error.what()));
|
||||
}
|
||||
return configDir;
|
||||
}
|
||||
|
|
|
@ -10,8 +10,7 @@
|
|||
#include <QStringBuilder>
|
||||
|
||||
using namespace std;
|
||||
using namespace ChronoUtilities;
|
||||
using namespace ConversionUtilities;
|
||||
using namespace CppUtilities;
|
||||
|
||||
namespace Data {
|
||||
|
||||
|
|
|
@ -10,8 +10,7 @@
|
|||
#include <QStringBuilder>
|
||||
|
||||
using namespace std;
|
||||
using namespace ChronoUtilities;
|
||||
using namespace ConversionUtilities;
|
||||
using namespace CppUtilities;
|
||||
|
||||
namespace Data {
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include <QStringBuilder>
|
||||
|
||||
using namespace std;
|
||||
using namespace ChronoUtilities;
|
||||
using namespace CppUtilities;
|
||||
|
||||
namespace Data {
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include "../connector/syncthingconnection.h"
|
||||
|
||||
using namespace Models;
|
||||
using namespace QtUtilities;
|
||||
|
||||
namespace Data {
|
||||
|
||||
|
|
|
@ -7,14 +7,12 @@
|
|||
|
||||
namespace Data {
|
||||
|
||||
class LIB_SYNCTHING_MODEL_EXPORT SyncthingStatusSelectionModel : public Models::ChecklistModel {
|
||||
class LIB_SYNCTHING_MODEL_EXPORT SyncthingStatusSelectionModel : public QtUtilities::ChecklistModel {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SyncthingStatusSelectionModel(QObject *parent = nullptr);
|
||||
QString labelForId(const QVariant &id) const override;
|
||||
|
||||
protected:
|
||||
};
|
||||
|
||||
} // namespace Data
|
||||
|
|
|
@ -17,9 +17,9 @@
|
|||
#include <QKeySequenceEdit>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
using namespace Dialogs;
|
||||
using namespace Data;
|
||||
using namespace QtGui;
|
||||
using namespace QtUtilities;
|
||||
|
||||
namespace Plasmoid {
|
||||
|
||||
|
@ -118,15 +118,14 @@ QWidget *AppearanceOptionPage::setupWidget()
|
|||
SettingsDialog::SettingsDialog(Plasmoid::SyncthingApplet &applet)
|
||||
{
|
||||
// setup categories
|
||||
QList<Dialogs::OptionCategory *> categories;
|
||||
Dialogs::OptionCategory *category;
|
||||
QList<OptionCategory *> categories;
|
||||
OptionCategory *category;
|
||||
|
||||
category = new OptionCategory;
|
||||
m_appearanceOptionPage = new AppearanceOptionPage(applet);
|
||||
category->setDisplayName(QCoreApplication::translate("Plasmoid::SettingsDialog", "Plasmoid"));
|
||||
category->assignPages(QList<Dialogs::OptionPage *>()
|
||||
<< new ConnectionOptionPage(applet.connection()) << new NotificationsOptionPage(GuiType::Plasmoid) << m_appearanceOptionPage
|
||||
<< new IconsOptionPage << new ShortcutOptionPage(applet));
|
||||
category->assignPages(QList<OptionPage *>() << new ConnectionOptionPage(applet.connection()) << new NotificationsOptionPage(GuiType::Plasmoid)
|
||||
<< m_appearanceOptionPage << new IconsOptionPage << new ShortcutOptionPage(applet));
|
||||
category->setIcon(QIcon::fromTheme(QStringLiteral("plasma")));
|
||||
categories << category;
|
||||
|
||||
|
@ -143,9 +142,9 @@ SettingsDialog::SettingsDialog(Plasmoid::SyncthingApplet &applet)
|
|||
|
||||
category = new OptionCategory;
|
||||
category->setDisplayName(QCoreApplication::translate("Plasmoid::SettingsDialog", "Extras"));
|
||||
category->assignPages(QList<Dialogs::OptionPage *>() << webViewPage
|
||||
category->assignPages(QList<OptionPage *>() << webViewPage
|
||||
#ifdef LIB_SYNCTHING_CONNECTOR_SUPPORT_SYSTEMD
|
||||
<< systemdPage
|
||||
<< systemdPage
|
||||
#endif
|
||||
);
|
||||
category->setIcon(
|
||||
|
|
|
@ -41,10 +41,9 @@
|
|||
using namespace std;
|
||||
using namespace Data;
|
||||
using namespace Plasma;
|
||||
using namespace Dialogs;
|
||||
using namespace CppUtilities;
|
||||
using namespace QtUtilities;
|
||||
using namespace QtGui;
|
||||
using namespace ConversionUtilities;
|
||||
using namespace ChronoUtilities;
|
||||
|
||||
namespace Plasmoid {
|
||||
|
||||
|
@ -229,7 +228,7 @@ bool SyncthingApplet::areNotificationsAvailable() const
|
|||
return !m_notifications.empty();
|
||||
}
|
||||
|
||||
void SyncthingApplet::setPassiveStates(const QList<Models::ChecklistItem> &passiveStates)
|
||||
void SyncthingApplet::setPassiveStates(const QList<QtUtilities::ChecklistItem> &passiveStates)
|
||||
{
|
||||
m_passiveSelectionModel.setItems(passiveStates);
|
||||
const auto currentState = static_cast<int>(m_connection.status());
|
||||
|
@ -258,13 +257,13 @@ void SyncthingApplet::showSettingsDlg()
|
|||
if (!m_settingsDlg) {
|
||||
m_settingsDlg = new SettingsDialog(*this);
|
||||
// ensure settings take effect when applied
|
||||
connect(m_settingsDlg, &Dialogs::SettingsDialog::applied, this, &SyncthingApplet::handleSettingsChanged);
|
||||
connect(m_settingsDlg, &SettingsDialog::applied, this, &SyncthingApplet::handleSettingsChanged);
|
||||
// save plasmoid specific settings to disk when applied
|
||||
connect(m_settingsDlg, &Dialogs::SettingsDialog::applied, this, &SyncthingApplet::configChanged);
|
||||
connect(m_settingsDlg, &SettingsDialog::applied, this, &SyncthingApplet::configChanged);
|
||||
// save global/general settings to disk when applied
|
||||
connect(m_settingsDlg, &Dialogs::SettingsDialog::applied, &Settings::save);
|
||||
connect(m_settingsDlg, &SettingsDialog::applied, &Settings::save);
|
||||
}
|
||||
Dialogs::centerWidget(m_settingsDlg);
|
||||
centerWidget(m_settingsDlg);
|
||||
m_settingsDlg->show();
|
||||
m_settingsDlg->activateWindow();
|
||||
}
|
||||
|
@ -313,8 +312,8 @@ void SyncthingApplet::showAboutDialog()
|
|||
QStringLiteral("<p>Developed by " APP_AUTHOR "<br>Syncthing icons from <a href=\"https://syncthing.net\">Syncthing project</a><br>Using "
|
||||
"icons from <a href=\"https://fontawesome.com\">Font "
|
||||
"Awesome</a> (see <a href=\"https://fontawesome.com/license\">their license</a>)</p>"),
|
||||
QStringLiteral(APP_VERSION), ApplicationUtilities::applicationInfo.dependencyVersions, QStringLiteral(APP_URL),
|
||||
QStringLiteral(APP_DESCRIPTION), renderSvgImage(makeSyncthingIcon()).toImage());
|
||||
QStringLiteral(APP_VERSION), CppUtilities::applicationInfo.dependencyVersions, QStringLiteral(APP_URL), QStringLiteral(APP_DESCRIPTION),
|
||||
renderSvgImage(makeSyncthingIcon()).toImage());
|
||||
m_aboutDlg->setWindowTitle(tr("About") + QStringLiteral(" - " APP_NAME));
|
||||
m_aboutDlg->setWindowIcon(QIcon::fromTheme(QStringLiteral("syncthingtray")));
|
||||
m_aboutDlg->setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
|
|
@ -65,7 +65,7 @@ class SyncthingApplet : public Plasma::Applet {
|
|||
Q_PROPERTY(QSize size READ size WRITE setSize NOTIFY sizeChanged)
|
||||
Q_PROPERTY(bool notificationsAvailable READ areNotificationsAvailable NOTIFY notificationsAvailableChanged)
|
||||
Q_PROPERTY(bool passive READ isPassive NOTIFY passiveChanged)
|
||||
Q_PROPERTY(QList<Models::ChecklistItem> passiveStates READ passiveStates WRITE setPassiveStates)
|
||||
Q_PROPERTY(QList<QtUtilities::ChecklistItem> passiveStates READ passiveStates WRITE setPassiveStates)
|
||||
|
||||
public:
|
||||
SyncthingApplet(QObject *parent, const QVariantList &data);
|
||||
|
@ -99,8 +99,8 @@ public:
|
|||
void setSize(const QSize &size);
|
||||
bool areNotificationsAvailable() const;
|
||||
bool isPassive() const;
|
||||
const QList<Models::ChecklistItem> &passiveStates() const;
|
||||
void setPassiveStates(const QList<Models::ChecklistItem> &passiveStates);
|
||||
const QList<QtUtilities::ChecklistItem> &passiveStates() const;
|
||||
void setPassiveStates(const QList<QtUtilities::ChecklistItem> &passiveStates);
|
||||
|
||||
public Q_SLOTS:
|
||||
void init() override;
|
||||
|
@ -153,7 +153,7 @@ private Q_SLOTS:
|
|||
#ifndef SYNCTHINGWIDGETS_NO_WEBVIEW
|
||||
void handleWebViewDeleted();
|
||||
#endif
|
||||
void handleNewNotification(ChronoUtilities::DateTime when, const QString &msg);
|
||||
void handleNewNotification(CppUtilities::DateTime when, const QString &msg);
|
||||
void handleSystemdServiceError(const QString &context, const QString &name, const QString &message);
|
||||
#ifdef LIB_SYNCTHING_CONNECTOR_SUPPORT_SYSTEMD
|
||||
void handleSystemdStatusChanged();
|
||||
|
@ -161,7 +161,7 @@ private Q_SLOTS:
|
|||
void setPassive(bool passive);
|
||||
|
||||
private:
|
||||
Dialogs::AboutDialog *m_aboutDlg;
|
||||
QtUtilities::AboutDialog *m_aboutDlg;
|
||||
Data::SyncthingConnection m_connection;
|
||||
Data::SyncthingOverallDirStatistics m_overallStats;
|
||||
Data::SyncthingNotifier m_notifier;
|
||||
|
@ -260,7 +260,7 @@ inline bool SyncthingApplet::isPassive() const
|
|||
return status() == Plasma::Types::PassiveStatus;
|
||||
}
|
||||
|
||||
inline const QList<Models::ChecklistItem> &SyncthingApplet::passiveStates() const
|
||||
inline const QList<QtUtilities::ChecklistItem> &SyncthingApplet::passiveStates() const
|
||||
{
|
||||
return m_passiveSelectionModel.items();
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "./helper.h"
|
||||
|
||||
namespace TestUtilities {
|
||||
namespace CppUtilities {
|
||||
|
||||
/*!
|
||||
* \brief Specifies the factor for multiplying all timeouts passed to functions declared in helper.h.
|
||||
|
@ -8,4 +8,4 @@ namespace TestUtilities {
|
|||
* The default factor is 1.0.
|
||||
*/
|
||||
double timeoutFactor = 1.0;
|
||||
} // namespace TestUtilities
|
||||
} // namespace CppUtilities
|
||||
|
|
|
@ -17,12 +17,12 @@
|
|||
#include <ostream>
|
||||
|
||||
#ifndef SYNCTHINGTESTHELPER_FOR_CLI
|
||||
#define SYNCTHINGTESTHELPER_TIMEOUT(timeout) static_cast<int>(timeout * ::TestUtilities::timeoutFactor)
|
||||
#define SYNCTHINGTESTHELPER_TIMEOUT(timeout) static_cast<int>(timeout * ::CppUtilities::timeoutFactor)
|
||||
#else
|
||||
#define SYNCTHINGTESTHELPER_TIMEOUT(timeout) timeout
|
||||
#endif
|
||||
|
||||
using namespace ConversionUtilities;
|
||||
using namespace CppUtilities;
|
||||
|
||||
/*!
|
||||
* \brief Prints a QString; required to use QString with CPPUNIT_ASSERT_EQUAL_MESSAGE.
|
||||
|
@ -48,7 +48,7 @@ inline std::ostream &operator<<(std::ostream &o, const QSet<QString> &qstringset
|
|||
return o << qstringset.toList().join(QStringLiteral(", ")).toLocal8Bit().data();
|
||||
}
|
||||
|
||||
namespace TestUtilities {
|
||||
namespace CppUtilities {
|
||||
|
||||
extern double timeoutFactor;
|
||||
|
||||
|
@ -397,6 +397,6 @@ bool waitForSignalsOrFail(Action action, int timeout, const SignalInfo &failure,
|
|||
return !failureEmitted && !timeoutFailed;
|
||||
}
|
||||
|
||||
} // namespace TestUtilities
|
||||
} // namespace CppUtilities
|
||||
|
||||
#endif // SYNCTHINGTESTHELPER_H
|
||||
|
|
|
@ -9,9 +9,8 @@
|
|||
#include <QFileInfo>
|
||||
|
||||
using namespace std;
|
||||
using namespace ConversionUtilities;
|
||||
|
||||
namespace TestUtilities {
|
||||
namespace CppUtilities {
|
||||
|
||||
static int dummy1 = 0;
|
||||
static char *dummy2;
|
||||
|
@ -139,4 +138,4 @@ void SyncthingTestInstance::setInterleavedOutputEnabledFromEnv()
|
|||
setInterleavedOutputEnabled(true);
|
||||
}
|
||||
}
|
||||
} // namespace TestUtilities
|
||||
} // namespace CppUtilities
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
namespace TestUtilities {
|
||||
namespace CppUtilities {
|
||||
|
||||
/*!
|
||||
* \brief The SyncthingTestInstance class provides running a test instance of Syncthing.
|
||||
|
@ -69,6 +69,6 @@ inline bool SyncthingTestInstance::isInterleavedOutputEnabled() const
|
|||
{
|
||||
return m_interleavedOutput;
|
||||
}
|
||||
} // namespace TestUtilities
|
||||
} // namespace CppUtilities
|
||||
|
||||
#endif // SYNCTHINGTESTHELPER_SYNCTHINGTESTINSTANCE_H
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
using namespace TestUtilities;
|
||||
using namespace CppUtilities;
|
||||
|
||||
/*!
|
||||
* \brief Launches a Syncthing test instance for manual testing.
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
#include <c++utilities/application/argumentparser.h>
|
||||
#include <c++utilities/application/commandlineutils.h>
|
||||
#include <c++utilities/application/failure.h>
|
||||
#include <c++utilities/misc/parseerror.h>
|
||||
|
||||
#include <qtutilities/resources/importplugin.h>
|
||||
#include <qtutilities/resources/qtconfigarguments.h>
|
||||
|
@ -30,7 +30,7 @@
|
|||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
using namespace ApplicationUtilities;
|
||||
using namespace CppUtilities;
|
||||
using namespace QtGui;
|
||||
using namespace Data;
|
||||
|
||||
|
@ -140,7 +140,7 @@ int runApplication(int argc, const char *const *argv)
|
|||
widgetsGuiArg.addSubArgument(&connectionArg);
|
||||
|
||||
parser.setMainArguments({ &qtConfigArgs.qtWidgetsGuiArg(), &parser.noColorArg(), &parser.helpArg() });
|
||||
parser.parseArgsOrExit(argc, argv);
|
||||
parser.parseArgs(argc, argv);
|
||||
if (!qtConfigArgs.qtWidgetsGuiArg().isPresent()) {
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -12,8 +12,8 @@
|
|||
#include <memory>
|
||||
|
||||
using namespace std;
|
||||
using namespace ConversionUtilities;
|
||||
using namespace EscapeCodes;
|
||||
using namespace CppUtilities;
|
||||
using namespace CppUtilities::EscapeCodes;
|
||||
|
||||
namespace QtGui {
|
||||
|
||||
|
|
|
@ -25,11 +25,8 @@
|
|||
#endif
|
||||
|
||||
using namespace std;
|
||||
using namespace Dialogs;
|
||||
using namespace QtUtilities;
|
||||
using namespace Data;
|
||||
#ifdef QT_UTILITIES_SUPPORT_DBUS_NOTIFICATIONS
|
||||
using namespace MiscUtils;
|
||||
#endif
|
||||
|
||||
namespace QtGui {
|
||||
|
||||
|
@ -214,7 +211,7 @@ void TrayIcon::showInternalError(
|
|||
m_errorsAction->setVisible(true);
|
||||
}
|
||||
|
||||
void TrayIcon::showSyncthingNotification(ChronoUtilities::DateTime when, const QString &message)
|
||||
void TrayIcon::showSyncthingNotification(CppUtilities::DateTime when, const QString &message)
|
||||
{
|
||||
if (m_notifyOnSyncthingErrors) {
|
||||
#ifdef QT_UTILITIES_SUPPORT_DBUS_NOTIFICATIONS
|
||||
|
|
|
@ -34,7 +34,7 @@ public:
|
|||
public slots:
|
||||
void showInternalError(
|
||||
const QString &errorMsg, Data::SyncthingErrorCategory category, int networkError, const QNetworkRequest &request, const QByteArray &response);
|
||||
void showSyncthingNotification(ChronoUtilities::DateTime when, const QString &message);
|
||||
void showSyncthingNotification(CppUtilities::DateTime when, const QString &message);
|
||||
void showInternalErrorsDialog();
|
||||
void updateStatusIconAndText();
|
||||
void showNewDev(const QString &devId, const QString &message);
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
#include <QDesktopWidget>
|
||||
#include <QHBoxLayout>
|
||||
|
||||
using namespace QtUtilities;
|
||||
|
||||
namespace QtGui {
|
||||
|
||||
TrayMenu::TrayMenu(TrayIcon *trayIcon, QWidget *parent)
|
||||
|
@ -52,7 +54,7 @@ void TrayMenu::showAtCursor()
|
|||
{
|
||||
resize(sizeHint());
|
||||
QPoint pos(QCursor::pos());
|
||||
moveInside(pos, size(), Dialogs::availableScreenGeometryAtPoint(pos));
|
||||
moveInside(pos, size(), availableScreenGeometryAtPoint(pos));
|
||||
popup(pos);
|
||||
}
|
||||
} // namespace QtGui
|
||||
|
|
|
@ -44,17 +44,15 @@
|
|||
#include <algorithm>
|
||||
#include <functional>
|
||||
|
||||
using namespace ApplicationUtilities;
|
||||
using namespace ConversionUtilities;
|
||||
using namespace ChronoUtilities;
|
||||
using namespace Dialogs;
|
||||
using namespace CppUtilities;
|
||||
using namespace QtUtilities;
|
||||
using namespace Data;
|
||||
using namespace std;
|
||||
|
||||
namespace QtGui {
|
||||
|
||||
SettingsDialog *TrayWidget::m_settingsDlg = nullptr;
|
||||
Dialogs::AboutDialog *TrayWidget::m_aboutDlg = nullptr;
|
||||
QtUtilities::AboutDialog *TrayWidget::m_aboutDlg = nullptr;
|
||||
vector<TrayWidget *> TrayWidget::m_instances;
|
||||
|
||||
/*!
|
||||
|
@ -437,7 +435,7 @@ void TrayWidget::applySettingsOnAllInstances()
|
|||
void TrayWidget::openDir(const SyncthingDir &dir)
|
||||
{
|
||||
if (QDir(dir.path).exists()) {
|
||||
DesktopUtils::openLocalFileOrDir(dir.path);
|
||||
openLocalFileOrDir(dir.path);
|
||||
} else {
|
||||
QMessageBox::warning(
|
||||
this, QCoreApplication::applicationName(), tr("The directory <i>%1</i> does not exist on the local machine.").arg(dir.path));
|
||||
|
@ -448,7 +446,7 @@ void TrayWidget::openItemDir(const SyncthingItemDownloadProgress &item)
|
|||
{
|
||||
const QDir containingDir(item.fileInfo.absoluteDir());
|
||||
if (containingDir.exists()) {
|
||||
DesktopUtils::openLocalFileOrDir(containingDir.path());
|
||||
openLocalFileOrDir(containingDir.path());
|
||||
} else {
|
||||
QMessageBox::warning(this, QCoreApplication::applicationName(),
|
||||
tr("The containing directory <i>%1</i> does not exist on the local machine.").arg(item.fileInfo.filePath()));
|
||||
|
|
|
@ -20,11 +20,11 @@ QT_FORWARD_DECLARE_CLASS(QFrame)
|
|||
QT_FORWARD_DECLARE_CLASS(QMenu)
|
||||
QT_FORWARD_DECLARE_CLASS(QActionGroup)
|
||||
|
||||
namespace ApplicationUtilities {
|
||||
namespace CppUtilities {
|
||||
class QtConfigArguments;
|
||||
}
|
||||
|
||||
namespace Dialogs {
|
||||
namespace QtUtilities {
|
||||
class AboutDialog;
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ private slots:
|
|||
#ifndef SYNCTHINGWIDGETS_NO_WEBVIEW
|
||||
void handleWebViewDeleted();
|
||||
#endif
|
||||
void handleNewNotification(ChronoUtilities::DateTime when, const QString &msg);
|
||||
void handleNewNotification(CppUtilities::DateTime when, const QString &msg);
|
||||
void handleConnectionSelected(QAction *connectionAction);
|
||||
void showDialog(QWidget *dlg);
|
||||
|
||||
|
@ -91,7 +91,7 @@ private:
|
|||
TrayMenu *m_menu;
|
||||
std::unique_ptr<Ui::TrayWidget> m_ui;
|
||||
static SettingsDialog *m_settingsDlg;
|
||||
static Dialogs::AboutDialog *m_aboutDlg;
|
||||
static QtUtilities::AboutDialog *m_aboutDlg;
|
||||
#ifndef SYNCTHINGWIDGETS_NO_WEBVIEW
|
||||
WebViewDialog *m_webViewDlg;
|
||||
#endif
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include <QPixmap>
|
||||
|
||||
using namespace Data;
|
||||
using namespace MiscUtils;
|
||||
using namespace QtUtilities;
|
||||
|
||||
namespace QtGui {
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ public Q_SLOTS:
|
|||
void showDisconnect();
|
||||
void hideDisconnect();
|
||||
void showInternalError(const InternalError &error);
|
||||
void showSyncthingNotification(ChronoUtilities::DateTime when, const QString &message);
|
||||
void showSyncthingNotification(CppUtilities::DateTime when, const QString &message);
|
||||
void showSyncComplete(const QString &message);
|
||||
void showNewDev(const QString &devId, const QString &message);
|
||||
void showNewDir(const QString &devId, const QString &dirId, const QString &message);
|
||||
|
@ -43,12 +43,12 @@ private Q_SLOTS:
|
|||
void handleSyncthingNotificationAction(const QString &action);
|
||||
|
||||
private:
|
||||
MiscUtils::DBusNotification m_disconnectedNotification;
|
||||
MiscUtils::DBusNotification m_internalErrorNotification;
|
||||
MiscUtils::DBusNotification m_syncthingNotification;
|
||||
MiscUtils::DBusNotification m_syncCompleteNotification;
|
||||
MiscUtils::DBusNotification m_newDevNotification;
|
||||
MiscUtils::DBusNotification m_newDirNotification;
|
||||
QtUtilities::DBusNotification m_disconnectedNotification;
|
||||
QtUtilities::DBusNotification m_internalErrorNotification;
|
||||
QtUtilities::DBusNotification m_syncthingNotification;
|
||||
QtUtilities::DBusNotification m_syncCompleteNotification;
|
||||
QtUtilities::DBusNotification m_newDevNotification;
|
||||
QtUtilities::DBusNotification m_newDirNotification;
|
||||
};
|
||||
|
||||
inline void DBusStatusNotifier::showDisconnect()
|
||||
|
@ -66,7 +66,7 @@ inline void DBusStatusNotifier::showInternalError(const InternalError &error)
|
|||
m_internalErrorNotification.update(error.message);
|
||||
}
|
||||
|
||||
inline void DBusStatusNotifier::showSyncthingNotification(ChronoUtilities::DateTime when, const QString &message)
|
||||
inline void DBusStatusNotifier::showSyncthingNotification(CppUtilities::DateTime when, const QString &message)
|
||||
{
|
||||
Q_UNUSED(when)
|
||||
m_syncthingNotification.update(message);
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include <limits>
|
||||
|
||||
using namespace std;
|
||||
using namespace ChronoUtilities;
|
||||
using namespace CppUtilities;
|
||||
using namespace Data;
|
||||
|
||||
namespace QtGui {
|
||||
|
|
|
@ -24,14 +24,14 @@ struct SYNCTHINGWIDGETS_EXPORT InternalError {
|
|||
QString message;
|
||||
QUrl url;
|
||||
QByteArray response;
|
||||
ChronoUtilities::DateTime when;
|
||||
CppUtilities::DateTime when;
|
||||
};
|
||||
|
||||
inline InternalError::InternalError(const QString &message, const QUrl &url, const QByteArray &response)
|
||||
: message(message)
|
||||
, url(url)
|
||||
, response(response)
|
||||
, when(ChronoUtilities::DateTime::now())
|
||||
, when(CppUtilities::DateTime::now())
|
||||
{
|
||||
}
|
||||
} // namespace QtGui
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include <limits>
|
||||
|
||||
using namespace std;
|
||||
using namespace ChronoUtilities;
|
||||
using namespace CppUtilities;
|
||||
using namespace Data;
|
||||
|
||||
namespace QtGui {
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
using namespace std;
|
||||
using namespace Data;
|
||||
using namespace TestUtilities;
|
||||
using namespace CppUtilities;
|
||||
|
||||
namespace QtGui {
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
using namespace std;
|
||||
using namespace std::placeholders;
|
||||
using namespace ChronoUtilities;
|
||||
using namespace CppUtilities;
|
||||
|
||||
namespace Data {
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace Data {
|
|||
class SYNCTHINGWIDGETS_EXPORT SyncthingLauncher : public QObject {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool running READ isRunning NOTIFY runningChanged)
|
||||
Q_PROPERTY(ChronoUtilities::DateTime activeSince READ activeSince)
|
||||
Q_PROPERTY(CppUtilities::DateTime activeSince READ activeSince)
|
||||
Q_PROPERTY(bool manuallyStopped READ isManuallyStopped)
|
||||
Q_PROPERTY(bool useLibSyncthing READ isUseLibSyncthing WRITE setUseLibSyncthing)
|
||||
|
||||
|
@ -25,7 +25,7 @@ public:
|
|||
explicit SyncthingLauncher(QObject *parent = nullptr);
|
||||
|
||||
bool isRunning() const;
|
||||
ChronoUtilities::DateTime activeSince() const;
|
||||
CppUtilities::DateTime activeSince() const;
|
||||
bool isActiveFor(unsigned int atLeastSeconds) const;
|
||||
bool isManuallyStopped() const;
|
||||
bool isUseLibSyncthing() const;
|
||||
|
@ -56,7 +56,7 @@ private Q_SLOTS:
|
|||
private:
|
||||
SyncthingProcess m_process;
|
||||
QFuture<void> m_future;
|
||||
ChronoUtilities::DateTime m_futureStarted;
|
||||
CppUtilities::DateTime m_futureStarted;
|
||||
bool m_manuallyStopped;
|
||||
bool m_useLibSyncthing;
|
||||
static SyncthingLauncher *s_mainInstance;
|
||||
|
@ -67,20 +67,20 @@ inline bool SyncthingLauncher::isRunning() const
|
|||
return m_process.isRunning() || m_future.isRunning();
|
||||
}
|
||||
|
||||
inline ChronoUtilities::DateTime SyncthingLauncher::activeSince() const
|
||||
inline CppUtilities::DateTime SyncthingLauncher::activeSince() const
|
||||
{
|
||||
if (m_process.isRunning()) {
|
||||
return m_process.activeSince();
|
||||
} else if (m_future.isRunning()) {
|
||||
return m_futureStarted;
|
||||
}
|
||||
return ChronoUtilities::DateTime();
|
||||
return CppUtilities::DateTime();
|
||||
}
|
||||
|
||||
inline bool SyncthingLauncher::isActiveFor(unsigned int atLeastSeconds) const
|
||||
{
|
||||
const auto activeSince(this->activeSince());
|
||||
return !activeSince.isNull() && (ChronoUtilities::DateTime::gmtNow() - activeSince).totalSeconds() > atLeastSeconds;
|
||||
return !activeSince.isNull() && (CppUtilities::DateTime::gmtNow() - activeSince).totalSeconds() > atLeastSeconds;
|
||||
}
|
||||
|
||||
inline bool SyncthingLauncher::isManuallyStopped() const
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
using namespace std;
|
||||
using namespace std::placeholders;
|
||||
using namespace Dialogs;
|
||||
using namespace QtUtilities;
|
||||
using namespace Data;
|
||||
|
||||
namespace QtGui {
|
||||
|
|
|
@ -179,7 +179,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="Widgets::ClearLineEdit" name="urlLineEdit"/>
|
||||
<widget class="QtUtilities::ClearLineEdit" name="urlLineEdit"/>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="authLabel">
|
||||
|
@ -202,7 +202,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="Widgets::ClearLineEdit" name="userNameLineEdit">
|
||||
<widget class="QtUtilities::ClearLineEdit" name="userNameLineEdit">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
|
@ -219,7 +219,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="Widgets::ClearLineEdit" name="passwordLineEdit">
|
||||
<widget class="QtUtilities::ClearLineEdit" name="passwordLineEdit">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
|
@ -236,7 +236,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="8" column="1">
|
||||
<widget class="Widgets::ClearLineEdit" name="apiKeyLineEdit"/>
|
||||
<widget class="QtUtilities::ClearLineEdit" name="apiKeyLineEdit"/>
|
||||
</item>
|
||||
<item row="9" column="0">
|
||||
<widget class="QLabel" name="certificateLabel">
|
||||
|
@ -246,7 +246,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="9" column="1">
|
||||
<widget class="Widgets::PathSelection" name="certPathSelection" native="true">
|
||||
<widget class="QtUtilities::PathSelection" name="certPathSelection" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
|
@ -449,13 +449,13 @@
|
|||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>Widgets::PathSelection</class>
|
||||
<class>QtUtilities::PathSelection</class>
|
||||
<extends>QWidget</extends>
|
||||
<header location="global">qtutilities/widgets/pathselection.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Widgets::ClearLineEdit</class>
|
||||
<class>QtUtilities::ClearLineEdit</class>
|
||||
<extends>QLineEdit</extends>
|
||||
<header location="global">qtutilities/widgets/clearlineedit.h</header>
|
||||
</customwidget>
|
||||
|
|
|
@ -53,7 +53,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="Widgets::PathSelection" name="syncthingPathSelection" native="true"/>
|
||||
<widget class="QtUtilities::PathSelection" name="syncthingPathSelection" native="true"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="argumentsLabel">
|
||||
|
@ -63,7 +63,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="Widgets::ClearLineEdit" name="argumentsLineEdit"/>
|
||||
<widget class="QtUtilities::ClearLineEdit" name="argumentsLineEdit"/>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QCheckBox" name="useBuiltInVersionCheckBox">
|
||||
|
@ -152,7 +152,7 @@
|
|||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Widgets::ClearPlainTextEdit" name="logTextEdit">
|
||||
<widget class="QtUtilities::ClearPlainTextEdit" name="logTextEdit">
|
||||
<property name="undoRedoEnabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
|
@ -178,18 +178,18 @@
|
|||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>Widgets::PathSelection</class>
|
||||
<class>QtUtilities::PathSelection</class>
|
||||
<extends>QWidget</extends>
|
||||
<header location="global">qtutilities/widgets/pathselection.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Widgets::ClearLineEdit</class>
|
||||
<class>QtUtilities::ClearLineEdit</class>
|
||||
<extends>QLineEdit</extends>
|
||||
<header location="global">qtutilities/widgets/clearlineedit.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Widgets::ClearPlainTextEdit</class>
|
||||
<class>QtUtilities::ClearPlainTextEdit</class>
|
||||
<extends>QPlainTextEdit</extends>
|
||||
<header location="global">qtutilities/widgets/clearplaintextedit.h</header>
|
||||
</customwidget>
|
||||
|
|
|
@ -30,9 +30,7 @@
|
|||
|
||||
using namespace std;
|
||||
using namespace Data;
|
||||
#ifdef QT_UTILITIES_SUPPORT_DBUS_NOTIFICATIONS
|
||||
using namespace MiscUtils;
|
||||
#endif
|
||||
using namespace QtUtilities;
|
||||
|
||||
namespace std {
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include <tuple>
|
||||
#include <vector>
|
||||
|
||||
namespace Dialogs {
|
||||
namespace QtUtilities {
|
||||
class QtSettings;
|
||||
}
|
||||
|
||||
|
@ -115,7 +115,7 @@ struct SYNCTHINGWIDGETS_EXPORT Settings {
|
|||
#if defined(SYNCTHINGWIDGETS_USE_WEBENGINE) || defined(SYNCTHINGWIDGETS_USE_WEBKIT)
|
||||
WebView webView;
|
||||
#endif
|
||||
Dialogs::QtSettings qt;
|
||||
QtUtilities::QtSettings qt;
|
||||
|
||||
void apply(Data::SyncthingNotifier ¬ifier) const;
|
||||
};
|
||||
|
|
|
@ -57,11 +57,9 @@
|
|||
using namespace std;
|
||||
using namespace std::placeholders;
|
||||
using namespace Settings;
|
||||
using namespace Dialogs;
|
||||
using namespace Data;
|
||||
#ifdef QT_UTILITIES_SUPPORT_DBUS_NOTIFICATIONS
|
||||
using namespace MiscUtils;
|
||||
#endif
|
||||
using namespace CppUtilities;
|
||||
using namespace QtUtilities;
|
||||
|
||||
namespace QtGui {
|
||||
|
||||
|
@ -514,9 +512,9 @@ QWidget *IconsOptionPage::setupWidget()
|
|||
// populate widgets array
|
||||
auto &widgetsForColor = m_widgets[index++] = {
|
||||
{
|
||||
new Widgets::ColorButton(statusIconsGroupBox),
|
||||
new Widgets::ColorButton(statusIconsGroupBox),
|
||||
new Widgets::ColorButton(statusIconsGroupBox),
|
||||
new ColorButton(statusIconsGroupBox),
|
||||
new ColorButton(statusIconsGroupBox),
|
||||
new ColorButton(statusIconsGroupBox),
|
||||
},
|
||||
new QLabel(statusIconsGroupBox),
|
||||
&colorMapping.setting,
|
||||
|
@ -539,7 +537,7 @@ QWidget *IconsOptionPage::setupWidget()
|
|||
QSize(32, 32)));
|
||||
};
|
||||
for (const auto &colorButton : widgetsForColor.colorButtons) {
|
||||
QObject::connect(colorButton, &Widgets::ColorButton::colorChanged, updatePreview);
|
||||
QObject::connect(colorButton, &ColorButton::colorChanged, updatePreview);
|
||||
}
|
||||
|
||||
// setup color buttons
|
||||
|
@ -980,7 +978,7 @@ void setIndicatorColor(QWidget *indicator, const QColor &color)
|
|||
indicator->setStyleSheet(QStringLiteral("border-radius:8px;background-color:") + color.name());
|
||||
}
|
||||
|
||||
void SystemdOptionPage::handleStatusChanged(const QString &activeState, const QString &subState, ChronoUtilities::DateTime activeSince)
|
||||
void SystemdOptionPage::handleStatusChanged(const QString &activeState, const QString &subState, DateTime activeSince)
|
||||
{
|
||||
QStringList status;
|
||||
if (!activeState.isEmpty()) {
|
||||
|
@ -994,7 +992,7 @@ void SystemdOptionPage::handleStatusChanged(const QString &activeState, const QS
|
|||
QString timeStamp;
|
||||
if (isRunning && !activeSince.isNull()) {
|
||||
timeStamp = QLatin1Char('\n') % QCoreApplication::translate("QtGui::SystemdOptionPage", "since ")
|
||||
% QString::fromUtf8(activeSince.toString(ChronoUtilities::DateTimeOutputFormat::DateAndTime).data());
|
||||
% QString::fromUtf8(activeSince.toString(DateTimeOutputFormat::DateAndTime).data());
|
||||
}
|
||||
|
||||
ui()->statusValueLabel->setText(
|
||||
|
@ -1063,35 +1061,35 @@ void WebViewOptionPage::reset()
|
|||
}
|
||||
|
||||
SettingsDialog::SettingsDialog(const QList<OptionCategory *> &categories, QWidget *parent)
|
||||
: Dialogs::SettingsDialog(parent)
|
||||
: QtUtilities::SettingsDialog(parent)
|
||||
{
|
||||
categoryModel()->setCategories(categories);
|
||||
init();
|
||||
}
|
||||
|
||||
SettingsDialog::SettingsDialog(QWidget *parent)
|
||||
: Dialogs::SettingsDialog(parent)
|
||||
: QtUtilities::SettingsDialog(parent)
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
SettingsDialog::SettingsDialog(Data::SyncthingConnection *connection, QWidget *parent)
|
||||
: Dialogs::SettingsDialog(parent)
|
||||
: QtUtilities::SettingsDialog(parent)
|
||||
{
|
||||
// setup categories
|
||||
QList<Dialogs::OptionCategory *> categories;
|
||||
Dialogs::OptionCategory *category;
|
||||
QList<OptionCategory *> categories;
|
||||
OptionCategory *category;
|
||||
|
||||
category = new OptionCategory(this);
|
||||
category->setDisplayName(tr("Tray"));
|
||||
category->assignPages(QList<Dialogs::OptionPage *>()
|
||||
<< new ConnectionOptionPage(connection) << new NotificationsOptionPage << new AppearanceOptionPage << new IconsOptionPage);
|
||||
category->assignPages(QList<OptionPage *>() << new ConnectionOptionPage(connection) << new NotificationsOptionPage << new AppearanceOptionPage
|
||||
<< new IconsOptionPage);
|
||||
category->setIcon(QIcon(QStringLiteral(":/icons/hicolor/scalable/app/syncthingtray.svg")));
|
||||
categories << category;
|
||||
|
||||
category = new OptionCategory(this);
|
||||
category->setDisplayName(tr("Web view"));
|
||||
category->assignPages(QList<Dialogs::OptionPage *>() << new WebViewOptionPage);
|
||||
category->assignPages(QList<OptionPage *>() << new WebViewOptionPage);
|
||||
category->setIcon(
|
||||
QIcon::fromTheme(QStringLiteral("internet-web-browser"), QIcon(QStringLiteral(":/icons/hicolor/scalable/apps/internet-web-browser.svg"))));
|
||||
categories << category;
|
||||
|
@ -1099,9 +1097,9 @@ SettingsDialog::SettingsDialog(Data::SyncthingConnection *connection, QWidget *p
|
|||
category = new OptionCategory(this);
|
||||
category->setDisplayName(tr("Startup"));
|
||||
category->assignPages(
|
||||
QList<Dialogs::OptionPage *>() << new AutostartOptionPage << new LauncherOptionPage << new LauncherOptionPage(QStringLiteral("Inotify"))
|
||||
QList<OptionPage *>() << new AutostartOptionPage << new LauncherOptionPage << new LauncherOptionPage(QStringLiteral("Inotify"))
|
||||
#ifdef LIB_SYNCTHING_CONNECTOR_SUPPORT_SYSTEMD
|
||||
<< new SystemdOptionPage
|
||||
<< new SystemdOptionPage
|
||||
#endif
|
||||
);
|
||||
category->setIcon(QIcon::fromTheme(QStringLiteral("system-run"), QIcon(QStringLiteral(":/icons/hicolor/scalable/apps/system-run.svg"))));
|
||||
|
|
|
@ -16,10 +16,14 @@
|
|||
|
||||
QT_FORWARD_DECLARE_CLASS(QLabel)
|
||||
|
||||
namespace ChronoUtilities {
|
||||
namespace CppUtilities {
|
||||
class DateTime;
|
||||
}
|
||||
|
||||
namespace QtUtilities {
|
||||
class ColorButton;
|
||||
}
|
||||
|
||||
namespace Data {
|
||||
class SyncthingConnection;
|
||||
class SyncthingService;
|
||||
|
@ -27,10 +31,6 @@ class SyncthingProcess;
|
|||
class SyncthingLauncher;
|
||||
} // namespace Data
|
||||
|
||||
namespace Widgets {
|
||||
class ColorButton;
|
||||
}
|
||||
|
||||
namespace QtGui {
|
||||
|
||||
/*!
|
||||
|
@ -84,7 +84,7 @@ private:
|
|||
void update();
|
||||
Data::StatusIconSettings m_settings;
|
||||
struct {
|
||||
Widgets::ColorButton *colorButtons[3] = {};
|
||||
QtUtilities::ColorButton *colorButtons[3] = {};
|
||||
QLabel *previewLabel = nullptr;
|
||||
Data::StatusIconColorSet *setting = nullptr;
|
||||
Data::StatusEmblem statusEmblem = Data::StatusEmblem::None;
|
||||
|
@ -118,7 +118,7 @@ BEGIN_DECLARE_UI_FILE_BASED_OPTION_PAGE(SystemdOptionPage)
|
|||
private:
|
||||
DECLARE_SETUP_WIDGETS
|
||||
void handleDescriptionChanged(const QString &description);
|
||||
void handleStatusChanged(const QString &activeState, const QString &subState, ChronoUtilities::DateTime activeSince);
|
||||
void handleStatusChanged(const QString &activeState, const QString &subState, CppUtilities::DateTime activeSince);
|
||||
void handleEnabledChanged(const QString &unitFileState);
|
||||
Data::SyncthingService *const m_service;
|
||||
END_DECLARE_OPTION_PAGE
|
||||
|
@ -130,11 +130,11 @@ DECLARE_UI_FILE_BASED_OPTION_PAGE(WebViewOptionPage)
|
|||
DECLARE_OPTION_PAGE(WebViewOptionPage)
|
||||
#endif
|
||||
|
||||
class SYNCTHINGWIDGETS_EXPORT SettingsDialog : public Dialogs::SettingsDialog {
|
||||
class SYNCTHINGWIDGETS_EXPORT SettingsDialog : public QtUtilities::SettingsDialog {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SettingsDialog(Data::SyncthingConnection *connection, QWidget *parent = nullptr);
|
||||
explicit SettingsDialog(const QList<Dialogs::OptionCategory *> &categories, QWidget *parent = nullptr);
|
||||
explicit SettingsDialog(const QList<QtUtilities::OptionCategory *> &categories, QWidget *parent = nullptr);
|
||||
explicit SettingsDialog(QWidget *parent = nullptr);
|
||||
~SettingsDialog() override;
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="Widgets::ClearLineEdit" name="syncthingUnitLineEdit"/>
|
||||
<widget class="QtUtilities::ClearLineEdit" name="syncthingUnitLineEdit"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="descriptionLabel">
|
||||
|
@ -263,7 +263,7 @@
|
|||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>Widgets::ClearLineEdit</class>
|
||||
<class>QtUtilities::ClearLineEdit</class>
|
||||
<extends>QLineEdit</extends>
|
||||
<header location="global">qtutilities/widgets/clearlineedit.h</header>
|
||||
</customwidget>
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include <QWebEngineProfile>
|
||||
#endif
|
||||
|
||||
using namespace Dialogs;
|
||||
using namespace QtUtilities;
|
||||
|
||||
namespace QtGui {
|
||||
|
||||
|
|
Loading…
Reference in New Issue