Skip to content

Commit

Permalink
Apply clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
Martchus committed Jan 19, 2025
1 parent 264c308 commit be6c2b2
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 36 deletions.
4 changes: 3 additions & 1 deletion syncthing/tests/interfacetests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,9 @@ void InterfaceTests::testRun(const std::function<long long()> &runFunction, bool

// stop Syncthing again if the messages we've been looking for were logged or we've timed out
const auto timeout((DateTime::gmtNow() - startTime) > TimeSpan::fromSeconds(30));
if (!timeout && (!myIdAnnounced || !performanceAnnounced || !guiAnnounced || (assertTestConfig && (!testDir1Ready || !testDev1Ready || !testDev2Ready)))) {
if (!timeout
&& (!myIdAnnounced || !performanceAnnounced || !guiAnnounced
|| (assertTestConfig && (!testDir1Ready || !testDev1Ready || !testDev2Ready)))) {
// log status
cout << "still waiting for:";
if (!myIdAnnounced) {
Expand Down
5 changes: 4 additions & 1 deletion syncthingconnector/syncthingconnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1179,7 +1179,10 @@ bool SyncthingConnection::setStatus(SyncthingStatus status)
// check whether at least one device is synchronizing
// check whether at least one device is paused
// check whether at least one devices is connected
if (!synchronizing && (m_statusComputionFlags && (SyncthingStatusComputionFlags::RemoteSynchronizing | SyncthingStatusComputionFlags::NoRemoteConnected | SyncthingStatusComputionFlags::DevicePaused))) {
if (!synchronizing
&& (m_statusComputionFlags
&& (SyncthingStatusComputionFlags::RemoteSynchronizing | SyncthingStatusComputionFlags::NoRemoteConnected
| SyncthingStatusComputionFlags::DevicePaused))) {
for (const SyncthingDev &dev : m_devs) {
if (dev.status == SyncthingDevStatus::Synchronizing) {
remoteSynchronizing = true;
Expand Down
3 changes: 2 additions & 1 deletion syncthingconnector/syncthingconnectionsettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ enum class SyncthingStatusComputionFlags : quint64 {
<< 5), /**< the return value of SyncthingConnection::hasUnreadNotifications() is considered by further displaying-related computations such as StatusInfo::updateConnectionStatus() */
NoRemoteConnected = (1 << 6), /**< the status SyncthingStatus::NoRemoteConnected might be set (in addition) */
Default = SyncthingStatusComputionFlags::Scanning | SyncthingStatusComputionFlags::Synchronizing | SyncthingStatusComputionFlags::DevicePaused
| SyncthingStatusComputionFlags::OutOfSync | SyncthingStatusComputionFlags::UnreadNotifications | SyncthingStatusComputionFlags::NoRemoteConnected,
| SyncthingStatusComputionFlags::OutOfSync | SyncthingStatusComputionFlags::UnreadNotifications
| SyncthingStatusComputionFlags::NoRemoteConnected,
/**< the default flags used all over the place */
};

Expand Down
4 changes: 3 additions & 1 deletion syncthingmodel/syncthingdevicemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,9 @@ QVariant SyncthingDeviceModel::data(const QModelIndex &index, int role) const
if (dev.overallCompletion.needed.isNull()) {
return tr("none");
}
return tr("%1 item(s), ~ %2", nullptr, trQuandity(dev.overallCompletion.needed.items)).arg(dev.overallCompletion.needed.items).arg(dataSizeToString(dev.overallCompletion.needed.bytes).data());
return tr("%1 item(s), ~ %2", nullptr, trQuandity(dev.overallCompletion.needed.items))
.arg(dev.overallCompletion.needed.items)
.arg(dataSizeToString(dev.overallCompletion.needed.bytes).data());
case 2:
return QString::fromStdString(dataSizeToString(dev.totalIncomingTraffic));
case 3:
Expand Down
4 changes: 3 additions & 1 deletion syncthingmodel/syncthingdirectorymodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,9 @@ QVariant SyncthingDirectoryModel::data(const QModelIndex &index, int role) const
if (dir.neededStats.isNull()) {
return tr("none");
}
return tr("%1 item(s), ~ %2", nullptr, trQuandity(dir.neededStats.total)).arg(dir.neededStats.total).arg(dataSizeToString(dir.neededStats.bytes).data());
return tr("%1 item(s), ~ %2", nullptr, trQuandity(dir.neededStats.total))
.arg(dir.neededStats.total)
.arg(dataSizeToString(dir.neededStats.bytes).data());
case 10:
if (dir.globalError.isEmpty() && !dir.pullErrorCount) {
return tr("none");
Expand Down
3 changes: 2 additions & 1 deletion syncthingmodel/syncthingicons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,8 @@ StatusIcons::StatusIcons(const StatusIconSettings &settings)
, error(QIcon(renderSvgImage(makeSyncthingIcon(settings.errorColor, StatusEmblem::Alert, settings.strokeWidth), settings.renderSize)))
, errorSync(QIcon(renderSvgImage(makeSyncthingIcon(settings.errorColor, StatusEmblem::Synchronizing, settings.strokeWidth), settings.renderSize)))
, newItem(QIcon(renderSvgImage(makeSyncthingIcon(settings.defaultColor, StatusEmblem::Add, settings.strokeWidth), settings.renderSize)))
, noRemoteConnected(QIcon(renderSvgImage(makeSyncthingIcon(settings.disconnectedColor, StatusEmblem::Cross, settings.strokeWidth), settings.renderSize)))
, noRemoteConnected(
QIcon(renderSvgImage(makeSyncthingIcon(settings.disconnectedColor, StatusEmblem::Cross, settings.strokeWidth), settings.renderSize)))
, isValid(true)
{
}
Expand Down
10 changes: 6 additions & 4 deletions syncthingwidgets/misc/syncthinglauncher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

#include <c++utilities/io/ansiescapecodes.h>

#include <QtConcurrentRun>
#include <QMetaObject>
#include <QtConcurrentRun>

#ifdef SYNCTHINGCONNECTION_SUPPORT_METERED
#include <QNetworkInformation>
Expand Down Expand Up @@ -192,7 +192,7 @@ void SyncthingLauncher::setNetworkConnectionMetered(std::optional<bool> metered)
else
#endif
#if defined(SYNCTHINGWIDGETS_USE_LIBSYNCTHING)
if (m_lastRuntimeOptions) {
if (m_lastRuntimeOptions) {
launch(*m_lastRuntimeOptions);
}
#endif
Expand All @@ -207,7 +207,8 @@ void SyncthingLauncher::setNetworkConnectionMetered(std::optional<bool> metered)
*/
void SyncthingLauncher::setStoppingOnMeteredConnection(bool stopOnMeteredConnection)
{
if ((stopOnMeteredConnection != m_stopOnMeteredConnection) && (m_stopOnMeteredConnection = stopOnMeteredConnection) && m_metered.value_or(false)) {
if ((stopOnMeteredConnection != m_stopOnMeteredConnection) && (m_stopOnMeteredConnection = stopOnMeteredConnection)
&& m_metered.value_or(false)) {
terminateDueToMeteredConnection();
}
}
Expand Down Expand Up @@ -482,7 +483,8 @@ void SyncthingLauncher::handleLoggingCallback(LibSyncthing::LogLevel level, cons
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
QMetaObject::invokeMethod(this, &SyncthingLauncher::handleOutputAvailable, Qt::QueuedConnection, static_cast<int>(level), std::move(messageData));
#else
QMetaObject::invokeMethod(this, "handleOutputAvailable", Qt::QueuedConnection, Q_ARG(int, static_cast<int>(level)), Q_ARG(QByteArray, messageData));
QMetaObject::invokeMethod(
this, "handleOutputAvailable", Qt::QueuedConnection, Q_ARG(int, static_cast<int>(level)), Q_ARG(QByteArray, messageData));
#endif
}
#endif
Expand Down
3 changes: 2 additions & 1 deletion syncthingwidgets/settings/settingsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1150,7 +1150,8 @@ QWidget *LauncherOptionPage::setupWidget()
}

// set placeholder texts in path selections
for (auto *const pathSelection : std::initializer_list<QtUtilities::PathSelection *>{ ui()->configDirPathSelection, ui()->dataDirPathSelection }) {
for (auto *const pathSelection :
std::initializer_list<QtUtilities::PathSelection *>{ ui()->configDirPathSelection, ui()->dataDirPathSelection }) {
pathSelection->lineEdit()->setPlaceholderText(tr("Leave empty for default path"));
}

Expand Down
46 changes: 21 additions & 25 deletions tray/gui/quick/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ static void handleAndroidIntent(JNIEnv *, jobject, jstring page, jboolean fromNo
QMetaObject::invokeMethod(appObjectForJava, "handleAndroidIntent", Qt::QueuedConnection,
Q_ARG(QString, QJniObject::fromLocalRef(page).toString()), Q_ARG(bool, fromNotification));
}
}
} // namespace JniFn
#endif

App::App(bool insecure, QObject *parent)
Expand All @@ -131,7 +131,7 @@ App::App(bool insecure, QObject *parent)
, m_sortFilterDevModel(&m_devModel)
, m_changesModel(m_connection)
, m_faUrlBase(QStringLiteral("image://fa/"))
, m_uiObjects({&m_dirModel, &m_sortFilterDirModel, &m_devModel, &m_sortFilterDevModel, &m_changesModel})
, m_uiObjects({ &m_dirModel, &m_sortFilterDirModel, &m_devModel, &m_sortFilterDevModel, &m_changesModel })
, m_iconSize(16)
, m_tabIndex(-1)
, m_importExportStatus(ImportExportStatus::None)
Expand Down Expand Up @@ -173,7 +173,8 @@ App::App(bool insecure, QObject *parent)

m_connection.setPollingFlags(SyncthingConnection::PollingFlags::MainEvents | SyncthingConnection::PollingFlags::Errors);
#ifdef Q_OS_ANDROID
m_notifier.setEnabledNotifications(SyncthingHighLevelNotification::ConnectedDisconnected | SyncthingHighLevelNotification::NewDevice | SyncthingHighLevelNotification::NewDir);
m_notifier.setEnabledNotifications(
SyncthingHighLevelNotification::ConnectedDisconnected | SyncthingHighLevelNotification::NewDevice | SyncthingHighLevelNotification::NewDir);
#else
m_notifier.setEnabledNotifications(SyncthingHighLevelNotification::ConnectedDisconnected);
#endif
Expand Down Expand Up @@ -521,11 +522,12 @@ bool App::loadStatistics(const QJSValue &callback)
if (!callback.isCallable()) {
return false;
}
auto query = m_connection.requestJsonData(QByteArrayLiteral("GET"), QStringLiteral("svc/report"), QUrlQuery(), QByteArray(), [this, callback](QJsonDocument &&doc, QString &&error) {
auto report = doc.object().toVariantMap();
statistics(report);
callback.call(QJSValueList({ m_engine.toScriptValue(report), QJSValue(std::move(error)) }));
});
auto query = m_connection.requestJsonData(
QByteArrayLiteral("GET"), QStringLiteral("svc/report"), QUrlQuery(), QByteArray(), [this, callback](QJsonDocument &&doc, QString &&error) {
auto report = doc.object().toVariantMap();
statistics(report);
callback.call(QJSValueList({ m_engine.toScriptValue(report), QJSValue(std::move(error)) }));
});
connect(this, &QObject::destroyed, query.reply, &QNetworkReply::deleteLater);
connect(this, &QObject::destroyed, [c = query.connection] { disconnect(c); });
return true;
Expand Down Expand Up @@ -662,9 +664,7 @@ bool App::shouldIgnorePermissions(const QString &path)
Q_UNUSED(path)
return true;
#else
static const auto problematicFileSystems = QSet<QByteArray>({
QByteArrayLiteral("fat"), QByteArrayLiteral("vfat"), QByteArrayLiteral("exfat")
});
static const auto problematicFileSystems = QSet<QByteArray>({ QByteArrayLiteral("fat"), QByteArrayLiteral("vfat"), QByteArrayLiteral("exfat") });
const auto storageInfo = QStorageInfo(path);
return storageInfo.isValid() && problematicFileSystems.contains(storageInfo.fileSystemType());
#endif
Expand Down Expand Up @@ -814,12 +814,9 @@ void App::clearAndroidExtraNotifications(int firstId, int lastId)
void App::updateSyncthingErrorsNotification(CppUtilities::DateTime when, const QString &message)
{
++m_syncthingErrors;
const auto title = QJniObject::fromString(m_syncthingErrors == 1
? tr("Syncthing error/notification")
: tr("%1 Syncthing errors/notifications").arg(m_syncthingErrors));
const auto text = QJniObject::fromString(m_syncthingErrors == 1
? message
: tr("most recent: ") + message);
const auto title = QJniObject::fromString(
m_syncthingErrors == 1 ? tr("Syncthing error/notification") : tr("%1 Syncthing errors/notifications").arg(m_syncthingErrors));
const auto text = QJniObject::fromString(m_syncthingErrors == 1 ? message : tr("most recent: ") + message);
const auto subText = QJniObject::fromString(QString::fromStdString(when.toString()));
static const auto page = QJniObject::fromString(QStringLiteral("connectionErrors"));
const auto &icon = makeAndroidIcon(commonForkAwesomeIcons().exclamation);
Expand All @@ -834,12 +831,9 @@ void App::clearSyncthingErrorsNotification()

void App::showInternalError(const InternalError &error)
{
const auto title = QJniObject::fromString(m_internalErrors.empty()
? tr("Syncthing API error")
: tr("%1 Syncthing API errors").arg(m_internalErrors.size() + 1));
const auto text = QJniObject::fromString(m_internalErrors.empty()
? error.message
: tr("most recent: ") + error.message);
const auto title = QJniObject::fromString(
m_internalErrors.empty() ? tr("Syncthing API error") : tr("%1 Syncthing API errors").arg(m_internalErrors.size() + 1));
const auto text = QJniObject::fromString(m_internalErrors.empty() ? error.message : tr("most recent: ") + error.message);
const auto subText = QJniObject::fromString(error.url.isEmpty() ? QString() : QStringLiteral("URL: ") + error.url.toString());
static const auto page = QJniObject::fromString(QStringLiteral("internalErrors"));
const auto &icon = makeAndroidIcon(commonForkAwesomeIcons().exclamation);
Expand Down Expand Up @@ -868,7 +862,9 @@ void App::showNewDir(const QString &devId, const QString &dirId, const QString &

static auto splitFolderRef(QStringView folderRef)
{
struct { QStringView deviceId, folderId, folderLabel; } res;
struct {
QStringView deviceId, folderId, folderLabel;
} res;
if (const auto separatorPos1 = folderRef.indexOf(QChar(':')); separatorPos1 >= 0) {
res.deviceId = folderRef.mid(0, separatorPos1);
res.folderId = folderRef.mid(separatorPos1 + 1);
Expand Down Expand Up @@ -1361,7 +1357,7 @@ bool App::importSettings(const QVariantMap &availableSettings, const QVariantMap

setImportExportStatus(ImportExportStatus::Importing);

QtConcurrent::run([this, importSyncthingHome, availableSettings, selectedSettings, rawConfig = m_connection.rawConfig()] () mutable {
QtConcurrent::run([this, importSyncthingHome, availableSettings, selectedSettings, rawConfig = m_connection.rawConfig()]() mutable {
// copy selected files from import directory to settings directory
auto summary = QStringList();
try {
Expand Down

0 comments on commit be6c2b2

Please sign in to comment.