Make clang-format <13 and clang-format >=13 behave the same

I think old clang-format is just buggy in those cases, so we should
reenable those blocks, once everyone has 13 or up.
pull/835/head
Nicolas Werner 3 years ago
parent b1092c0f2f
commit a13f492e7d
No known key found for this signature in database
GPG Key ID: C8D75E610773F2D9
  1. 3
      .clang-format
  2. 4
      src/BlurhashProvider.h
  3. 65
      src/Cache_p.h
  4. 5
      src/CompletionProxyModel.h
  5. 4
      src/Config.h
  6. 4
      src/JdenticonProvider.h
  7. 10
      src/MainWindow.h
  8. 4
      src/MxcImageProvider.h
  9. 7
      src/encryption/DeviceVerificationFlow.cpp
  10. 32
      src/encryption/DeviceVerificationFlow.h
  11. 5
      src/notifications/Manager.h
  12. 15
      src/notifications/ManagerWin.cpp
  13. 10
      src/timeline/EventStore.h
  14. 36
      src/timeline/TimelineModel.cpp
  15. 4
      src/ui/FlatButton.cpp
  16. 2
      src/ui/FlatButton.h
  17. 2
      src/ui/RaisedButton.cpp
  18. 1
      src/ui/RaisedButton.h
  19. 2
      src/ui/ThemeManager.cpp
  20. 2
      src/ui/ThemeManager.h
  21. 4
      src/voip/CallDevices.h
  22. 9
      src/voip/WebRTCSession.cpp

@ -4,7 +4,7 @@ Standard: c++17
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: true
AllowShortFunctionsOnASingleLine: true
AllowShortFunctionsOnASingleLine: InlineOnly
BasedOnStyle: Mozilla
ColumnLimit: 100
IndentCaseLabels: false
@ -12,3 +12,4 @@ IndentWidth: 4
KeepEmptyLinesAtTheStartOfBlocks: false
PointerAlignment: Right
Cpp11BracedListStyle: true
PenaltyReturnTypeOnItsOwnLine: 0

@ -42,8 +42,8 @@ class BlurhashProvider
{
Q_OBJECT
public slots:
QQuickImageResponse *requestImageResponse(const QString &id,
const QSize &requestedSize) override
QQuickImageResponse *
requestImageResponse(const QString &id, const QSize &requestedSize) override
{
BlurhashResponse *response = new BlurhashResponse(id, requestedSize);
pool.start(response);

@ -47,9 +47,8 @@ public:
std::string statusMessage(const std::string &user_id);
// user cache stores user keys
std::map<std::string, std::optional<UserKeyCache>> getMembersWithKeys(
const std::string &room_id,
bool verified_only);
std::map<std::string, std::optional<UserKeyCache>>
getMembersWithKeys(const std::string &room_id, bool verified_only);
void updateUserKeys(const std::string &sync_token, const mtx::responses::QueryKeys &keyQuery);
void markUserKeysOutOfDate(const std::vector<std::string> &user_ids);
void markUserKeysOutOfDate(lmdb::txn &txn,
@ -90,8 +89,8 @@ public:
//! Get a specific state event
template<typename T>
std::optional<mtx::events::StateEvent<T>> getStateEvent(const std::string &room_id,
std::string_view state_key = "")
std::optional<mtx::events::StateEvent<T>>
getStateEvent(const std::string &room_id, std::string_view state_key = "")
{
auto txn = lmdb::txn::begin(env_, nullptr, MDB_RDONLY);
return getStateEvent<T>(txn, room_id, state_key);
@ -99,14 +98,12 @@ public:
//! retrieve a specific event from account data
//! pass empty room_id for global account data
std::optional<mtx::events::collections::RoomAccountDataEvents> getAccountData(
mtx::events::EventType type,
const std::string &room_id = "");
std::optional<mtx::events::collections::RoomAccountDataEvents>
getAccountData(mtx::events::EventType type, const std::string &room_id = "");
//! Retrieve member info from a room.
std::vector<RoomMember> getMembers(const std::string &room_id,
std::size_t startIndex = 0,
std::size_t len = 30);
std::vector<RoomMember>
getMembers(const std::string &room_id, std::size_t startIndex = 0, std::size_t len = 30);
std::vector<RoomMember> getMembersFromInvite(const std::string &room_id,
std::size_t startIndex = 0,
@ -186,8 +183,8 @@ public:
uint64_t index = std::numeric_limits<uint64_t>::max(),
bool forward = false);
std::optional<mtx::events::collections::TimelineEvent> getEvent(const std::string &room_id,
const std::string &event_id);
std::optional<mtx::events::collections::TimelineEvent>
getEvent(const std::string &room_id, const std::string &event_id);
void storeEvent(const std::string &room_id,
const std::string &event_id,
const mtx::events::collections::TimelineEvent &event);
@ -203,9 +200,8 @@ public:
std::optional<TimelineRange> getTimelineRange(const std::string &room_id);
std::optional<uint64_t> getTimelineIndex(const std::string &room_id, std::string_view event_id);
std::optional<uint64_t> getEventIndex(const std::string &room_id, std::string_view event_id);
std::optional<std::pair<uint64_t, std::string>> lastInvisibleEventAfter(
const std::string &room_id,
std::string_view event_id);
std::optional<std::pair<uint64_t, std::string>>
lastInvisibleEventAfter(const std::string &room_id, std::string_view event_id);
std::optional<std::string> getTimelineEventId(const std::string &room_id, uint64_t index);
std::optional<uint64_t> getArrivalIndex(const std::string &room_id, std::string_view event_id);
@ -213,8 +209,8 @@ public:
uint64_t saveOldMessages(const std::string &room_id, const mtx::responses::Messages &res);
void savePendingMessage(const std::string &room_id,
const mtx::events::collections::TimelineEvent &message);
std::optional<mtx::events::collections::TimelineEvent> firstPendingMessage(
const std::string &room_id);
std::optional<mtx::events::collections::TimelineEvent>
firstPendingMessage(const std::string &room_id);
void removePendingStatus(const std::string &room_id, const std::string &txn_id);
//! clear timeline keeping only the latest batch
@ -228,14 +224,14 @@ public:
std::vector<std::string> getParentRoomIds(const std::string &room_id);
std::vector<std::string> getChildRoomIds(const std::string &room_id);
std::vector<ImagePackInfo> getImagePacks(const std::string &room_id,
std::optional<bool> stickers);
std::vector<ImagePackInfo>
getImagePacks(const std::string &room_id, std::optional<bool> stickers);
//! Mark a room that uses e2e encryption.
void setEncryptedRoom(lmdb::txn &txn, const std::string &room_id);
bool isRoomEncrypted(const std::string &room_id);
std::optional<mtx::events::state::Encryption> roomEncryptionSettings(
const std::string &room_id);
std::optional<mtx::events::state::Encryption>
roomEncryptionSettings(const std::string &room_id);
//! Check if a user is a member of the room.
bool isRoomMember(const std::string &user_id, const std::string &room_id);
@ -273,8 +269,8 @@ public:
mtx::crypto::OlmSessionPtr session,
uint64_t timestamp);
std::vector<std::string> getOlmSessions(const std::string &curve25519);
std::optional<mtx::crypto::OlmSessionPtr> getOlmSession(const std::string &curve25519,
const std::string &session_id);
std::optional<mtx::crypto::OlmSessionPtr>
getOlmSession(const std::string &curve25519, const std::string &session_id);
std::optional<mtx::crypto::OlmSessionPtr> getLatestOlmSession(const std::string &curve25519);
void saveOlmAccount(const std::string &pickled);
@ -331,8 +327,8 @@ private:
const QList<mtx::responses::Notification> &res);
//! Get timeline items that a user was mentions in for a given room
mtx::responses::Notifications getTimelineMentionsForRoom(lmdb::txn &txn,
const std::string &room_id);
mtx::responses::Notifications
getTimelineMentionsForRoom(lmdb::txn &txn, const std::string &room_id);
QString getInviteRoomName(lmdb::txn &txn, lmdb::dbi &statesdb, lmdb::dbi &membersdb);
QString getInviteRoomTopic(lmdb::txn &txn, lmdb::dbi &statesdb);
@ -447,9 +443,8 @@ private:
}
template<typename T>
std::optional<mtx::events::StateEvent<T>> getStateEvent(lmdb::txn &txn,
const std::string &room_id,
std::string_view state_key = "")
std::optional<mtx::events::StateEvent<T>>
getStateEvent(lmdb::txn &txn, const std::string &room_id, std::string_view state_key = "")
{
try {
constexpr auto type = mtx::events::state_content_to_type<T>;
@ -492,8 +487,8 @@ private:
}
template<typename T>
std::vector<mtx::events::StateEvent<T>> getStateEventsWithType(lmdb::txn &txn,
const std::string &room_id)
std::vector<mtx::events::StateEvent<T>>
getStateEventsWithType(lmdb::txn &txn, const std::string &room_id)
{
constexpr auto type = mtx::events::state_content_to_type<T>;
@ -531,16 +526,16 @@ private:
return events;
}
void saveInvites(lmdb::txn &txn,
const std::map<std::string, mtx::responses::InvitedRoom> &rooms);
void
saveInvites(lmdb::txn &txn, const std::map<std::string, mtx::responses::InvitedRoom> &rooms);
void savePresence(
lmdb::txn &txn,
const std::vector<mtx::events::Event<mtx::events::presence::Presence>> &presenceUpdates);
//! Sends signals for the rooms that are removed.
void removeLeftRooms(lmdb::txn &txn,
const std::map<std::string, mtx::responses::LeftRoom> &rooms)
void
removeLeftRooms(lmdb::txn &txn, const std::map<std::string, mtx::responses::LeftRoom> &rooms)
{
for (const auto &room : rooms) {
removeRoom(txn, room.first);

@ -163,9 +163,8 @@ public:
QModelIndex mapFromSource(const QModelIndex &sourceIndex) const override;
QModelIndex mapToSource(const QModelIndex &proxyIndex) const override;
QModelIndex index(int row,
int column,
const QModelIndex &parent = QModelIndex()) const override;
QModelIndex
index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
QModelIndex parent(const QModelIndex &) const override;
public slots:

@ -61,8 +61,8 @@ const QRegularExpression url_regex(
// vvvv atomic match url -> fail if there is a " before or after vvv
R"((?<!["'])(?>((www\.(?!\.)|[a-z][a-z0-9+.-]*://)[^\s<>'"]+[^!,\.\s<>'"\]\)\:]))(?!["']))");
// match any markdown matrix.to link. Capture group 1 is the link name, group 2 is the target.
static const QRegularExpression matrixToMarkdownLink(
R"(\[(.*?)(?<!\\)\]\((https://matrix.to/#/.*?\)))");
static const QRegularExpression
matrixToMarkdownLink(R"(\[(.*?)(?<!\\)\]\((https://matrix.to/#/.*?\)))");
static const QRegularExpression matrixToLink(R"(<a href=\"(https://matrix.to/#/.*?)\">(.*?)</a>)");
}

@ -50,8 +50,8 @@ public:
static bool isAvailable() { return Jdenticon::getJdenticonInterface() != nullptr; }
public slots:
QQuickImageResponse *requestImageResponse(const QString &id,
const QSize &requestedSize) override
QQuickImageResponse *
requestImageResponse(const QString &id, const QSize &requestedSize) override
{
auto id_ = id;
bool crop = true;

@ -57,16 +57,16 @@ public:
static MainWindow *instance() { return instance_; }
void saveCurrentWindowSize();
void openCreateRoomDialog(
std::function<void(const mtx::requests::CreateRoom &request)> callback);
void
openCreateRoomDialog(std::function<void(const mtx::requests::CreateRoom &request)> callback);
void openJoinRoomDialog(std::function<void(const QString &room_id)> callback);
void openLogoutDialog();
void hideOverlay();
void showSolidOverlayModal(QWidget *content, QFlags<Qt::AlignmentFlag> flags = Qt::AlignCenter);
void showTransparentOverlayModal(QWidget *content,
QFlags<Qt::AlignmentFlag> flags = Qt::AlignTop |
Qt::AlignHCenter);
void
showTransparentOverlayModal(QWidget *content,
QFlags<Qt::AlignmentFlag> flags = Qt::AlignTop | Qt::AlignHCenter);
protected:
void closeEvent(QCloseEvent *event) override;

@ -49,8 +49,8 @@ class MxcImageProvider
{
Q_OBJECT
public slots:
QQuickImageResponse *requestImageResponse(const QString &id,
const QSize &requestedSize) override;
QQuickImageResponse *
requestImageResponse(const QString &id, const QSize &requestedSize) override;
static void addEncryptionInfo(mtx::crypto::EncryptedFile info);
static void download(const QString &id,

@ -662,9 +662,12 @@ DeviceVerificationFlow::sendVerificationRequest()
} else if (this->type == DeviceVerificationFlow::Type::RoomMsg && model_) {
req.to = this->toClient.to_string();
req.msgtype = "m.key.verification.request";
// clang-format off
// clang-format < 12 is buggy on this
req.body = "User is requesting to verify keys with you. However, your client does "
"not support this method, so you will need to use the legacy method of "
"key verification.";
"not support this method, so you will need to use the legacy method of "
"key verification.";
// clang-format on
}
send(req);

@ -103,22 +103,22 @@ public:
};
Q_ENUM(Error)
static QSharedPointer<DeviceVerificationFlow> NewInRoomVerification(
QObject *parent_,
TimelineModel *timelineModel_,
const mtx::events::msg::KeyVerificationRequest &msg,
QString other_user_,
QString event_id_);
static QSharedPointer<DeviceVerificationFlow> NewToDeviceVerification(
QObject *parent_,
const mtx::events::msg::KeyVerificationRequest &msg,
QString other_user_,
QString txn_id_);
static QSharedPointer<DeviceVerificationFlow> NewToDeviceVerification(
QObject *parent_,
const mtx::events::msg::KeyVerificationStart &msg,
QString other_user_,
QString txn_id_);
static QSharedPointer<DeviceVerificationFlow>
NewInRoomVerification(QObject *parent_,
TimelineModel *timelineModel_,
const mtx::events::msg::KeyVerificationRequest &msg,
QString other_user_,
QString event_id_);
static QSharedPointer<DeviceVerificationFlow>
NewToDeviceVerification(QObject *parent_,
const mtx::events::msg::KeyVerificationRequest &msg,
QString other_user_,
QString txn_id_);
static QSharedPointer<DeviceVerificationFlow>
NewToDeviceVerification(QObject *parent_,
const mtx::events::msg::KeyVerificationStart &msg,
QString other_user_,
QString txn_id_);
static QSharedPointer<DeviceVerificationFlow>
InitiateUserVerification(QObject *parent_, TimelineModel *timelineModel_, QString userid);
static QSharedPointer<DeviceVerificationFlow>

@ -87,9 +87,8 @@ private:
#if defined(Q_OS_WINDOWS)
private:
void systemPostNotification(const QString &line1,
const QString &line2,
const QString &iconPath);
void
systemPostNotification(const QString &line1, const QString &line2, const QString &iconPath);
#endif
// these slots are platform specific (D-Bus only)

@ -100,10 +100,19 @@ NotificationsManager::systemPostNotification(const QString &line1,
WinToast::instance()->showToast(templ, new CustomHandler());
}
void NotificationsManager::actionInvoked(uint, QString) {}
void NotificationsManager::notificationReplied(uint, QString) {}
// clang-format off
// clang-format < 12 is buggy on this
void
NotificationsManager::actionInvoked(uint, QString)
{}
void NotificationsManager::notificationClosed(uint, uint) {}
void
NotificationsManager::notificationReplied(uint, QString)
{}
void
NotificationsManager::notificationClosed(uint, uint)
{}
void
NotificationsManager::removeNotification(const QString &, const QString &)

@ -79,8 +79,8 @@ public:
QVariantList reactions(const std::string &event_id);
std::vector<mtx::events::collections::TimelineEvents> edits(const std::string &event_id);
olm::DecryptionErrorCode decryptionError(std::string id);
void requestSession(const mtx::events::EncryptedEvent<mtx::events::msg::Encrypted> &ev,
bool manual);
void
requestSession(const mtx::events::EncryptedEvent<mtx::events::msg::Encrypted> &ev, bool manual);
int size() const
{
@ -121,9 +121,9 @@ public slots:
void enableKeyRequests(bool suppressKeyRequests_);
private:
olm::DecryptionResult *decryptEvent(
const IdIndex &idx,
const mtx::events::EncryptedEvent<mtx::events::msg::Encrypted> &e);
olm::DecryptionResult *
decryptEvent(const IdIndex &idx,
const mtx::events::EncryptedEvent<mtx::events::msg::Encrypted> &e);
void handle_room_verification(mtx::events::collections::TimelineEvents event);
std::string room_id_;

@ -126,43 +126,43 @@ struct RoomEventType
{
return qml_mtx_events::EventType::VideoMessage;
}
qml_mtx_events::EventType operator()(
const mtx::events::Event<mtx::events::msg::KeyVerificationRequest> &)
qml_mtx_events::EventType
operator()(const mtx::events::Event<mtx::events::msg::KeyVerificationRequest> &)
{
return qml_mtx_events::EventType::KeyVerificationRequest;
}
qml_mtx_events::EventType operator()(
const mtx::events::Event<mtx::events::msg::KeyVerificationStart> &)
qml_mtx_events::EventType
operator()(const mtx::events::Event<mtx::events::msg::KeyVerificationStart> &)
{
return qml_mtx_events::EventType::KeyVerificationStart;
}
qml_mtx_events::EventType operator()(
const mtx::events::Event<mtx::events::msg::KeyVerificationMac> &)
qml_mtx_events::EventType
operator()(const mtx::events::Event<mtx::events::msg::KeyVerificationMac> &)
{
return qml_mtx_events::EventType::KeyVerificationMac;
}
qml_mtx_events::EventType operator()(
const mtx::events::Event<mtx::events::msg::KeyVerificationAccept> &)
qml_mtx_events::EventType
operator()(const mtx::events::Event<mtx::events::msg::KeyVerificationAccept> &)
{
return qml_mtx_events::EventType::KeyVerificationAccept;
}
qml_mtx_events::EventType operator()(
const mtx::events::Event<mtx::events::msg::KeyVerificationReady> &)
qml_mtx_events::EventType
operator()(const mtx::events::Event<mtx::events::msg::KeyVerificationReady> &)
{
return qml_mtx_events::EventType::KeyVerificationReady;
}
qml_mtx_events::EventType operator()(
const mtx::events::Event<mtx::events::msg::KeyVerificationCancel> &)
qml_mtx_events::EventType
operator()(const mtx::events::Event<mtx::events::msg::KeyVerificationCancel> &)
{
return qml_mtx_events::EventType::KeyVerificationCancel;
}
qml_mtx_events::EventType operator()(
const mtx::events::Event<mtx::events::msg::KeyVerificationKey> &)
qml_mtx_events::EventType
operator()(const mtx::events::Event<mtx::events::msg::KeyVerificationKey> &)
{
return qml_mtx_events::EventType::KeyVerificationKey;
}
qml_mtx_events::EventType operator()(
const mtx::events::Event<mtx::events::msg::KeyVerificationDone> &)
qml_mtx_events::EventType
operator()(const mtx::events::Event<mtx::events::msg::KeyVerificationDone> &)
{
return qml_mtx_events::EventType::KeyVerificationDone;
}
@ -182,8 +182,8 @@ struct RoomEventType
{
return qml_mtx_events::EventType::CallHangUp;
}
qml_mtx_events::EventType operator()(
const mtx::events::Event<mtx::events::msg::CallCandidates> &)
qml_mtx_events::EventType
operator()(const mtx::events::Event<mtx::events::msg::CallCandidates> &)
{
return qml_mtx_events::EventType::CallCandidates;
}

@ -86,8 +86,6 @@ FlatButton::FlatButton(const QString &text, ui::Role role, QWidget *parent, ui::
setRole(role);
}
FlatButton::~FlatButton() {}
void
FlatButton::applyPreset(ui::ButtonPreset preset)
{
@ -615,8 +613,6 @@ FlatButtonStateMachine::FlatButtonStateMachine(FlatButton *parent)
addTransition(button_, QEvent::FocusOut, pressed_state_, hovered_state_);
}
FlatButtonStateMachine::~FlatButtonStateMachine() {}
void
FlatButtonStateMachine::setOverlayOpacity(qreal opacity)
{

@ -22,7 +22,6 @@ class FlatButtonStateMachine : public QStateMachine
public:
explicit FlatButtonStateMachine(FlatButton *parent);
~FlatButtonStateMachine() override;
void setOverlayOpacity(qreal opacity);
void setCheckedOverlayProgress(qreal opacity);
@ -101,7 +100,6 @@ public:
ui::Role role,
QWidget *parent = nullptr,
ui::ButtonPreset preset = ui::ButtonPreset::FlatPreset);
~FlatButton() override;
void applyPreset(ui::ButtonPreset preset);

@ -74,8 +74,6 @@ RaisedButton::RaisedButton(const QString &text, QWidget *parent)
setText(text);
}
RaisedButton::~RaisedButton() {}
bool
RaisedButton::event(QEvent *event)
{

@ -17,7 +17,6 @@ class RaisedButton : public FlatButton
public:
explicit RaisedButton(QWidget *parent = nullptr);
explicit RaisedButton(const QString &text, QWidget *parent = nullptr);
~RaisedButton() override;
protected:
bool event(QEvent *event) override;

@ -6,8 +6,6 @@
#include "ThemeManager.h"
ThemeManager::ThemeManager() {}
QColor
ThemeManager::themeColor(const QString &key) const
{

@ -16,7 +16,7 @@ public:
QColor themeColor(const QString &key) const;
private:
ThemeManager();
ThemeManager() {}
ThemeManager(ThemeManager const &);
void operator=(ThemeManager const &);

@ -27,8 +27,8 @@ public:
bool haveCamera() const;
std::vector<std::string> names(bool isVideo, const std::string &defaultDevice) const;
std::vector<std::string> resolutions(const std::string &cameraName) const;
std::vector<std::string> frameRates(const std::string &cameraName,
const std::string &resolution) const;
std::vector<std::string>
frameRates(const std::string &cameraName, const std::string &resolution) const;
signals:
void devicesChanged();

@ -1115,7 +1115,14 @@ WebRTCSession::haveLocalPiP() const
return false;
}
bool WebRTCSession::createOffer(webrtc::CallType, uint32_t) { return false; }
// clang-format off
// clang-format < 12 is buggy on this
bool
WebRTCSession::createOffer(webrtc::CallType, uint32_t)
{
return false;
}
// clang-format on
bool
WebRTCSession::acceptOffer(const std::string &)

Loading…
Cancel
Save