Use C++11 braced list style (#121)

pull/1/head
Benjamin Saunders 7 years ago committed by mujx
parent 4ccb5ed81f
commit 5bd5555a51
  1. 2
      .clang-format
  2. 10
      src/Cache.cc
  3. 10
      src/EmojiPanel.cc
  4. 2
      src/EmojiPickButton.cc
  5. 2847
      src/EmojiProvider.cc
  6. 10
      src/ImageItem.cc
  7. 4
      src/ImageOverlayDialog.cc
  8. 8
      src/Login.cc
  9. 2
      src/LoginPage.cc
  10. 4
      src/MainWindow.cc
  11. 24
      src/MatrixClient.cc
  12. 2
      src/Register.cc
  13. 2
      src/RoomInfoListItem.cc
  14. 2
      src/SideBarActions.cc
  15. 41
      src/TimelineItem.cc
  16. 8
      src/TimelineView.cc
  17. 2
      src/TimelineViewManager.cc
  18. 2
      src/TopRoomBar.cc
  19. 2
      src/TypingDisplay.cc
  20. 6
      src/UserInfoWidget.cc
  21. 6
      src/UserSettingsPage.cc
  22. 4
      src/ui/OverlayModal.cc
  23. 2
      src/ui/ScrollBar.cc
  24. 16
      src/ui/Theme.cc
  25. 14
      src/ui/ToggleButton.cc

@ -1,5 +1,6 @@
---
Language: Cpp
Standard: Cpp11
AccessModifierOffset: -8
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: true
@ -10,3 +11,4 @@ IndentCaseLabels: false
IndentWidth: 8
KeepEmptyLinesAtTheStartOfBlocks: false
PointerAlignment: Right
Cpp11BracedListStyle: true

@ -31,11 +31,11 @@ static const lmdb::val NEXT_BATCH_KEY("next_batch");
static const lmdb::val transactionID("transaction_id");
Cache::Cache(const QString &userId)
: env_{ nullptr }
, stateDb_{ 0 }
, roomDb_{ 0 }
, isMounted_{ false }
, userId_{ userId }
: env_{nullptr}
, stateDb_{0}
, roomDb_{0}
, isMounted_{false}
, userId_{userId}
{}
void

@ -26,11 +26,11 @@
EmojiPanel::EmojiPanel(QWidget *parent)
: QWidget(parent)
, shadowMargin_{ 2 }
, width_{ 370 }
, height_{ 350 }
, animationDuration_{ 100 }
, categoryIconSize_{ 20 }
, shadowMargin_{2}
, width_{370}
, height_{350}
, animationDuration_{100}
, categoryIconSize_{20}
{
setStyleSheet("QWidget {background: #fff; color: #e8e8e8; border: none;}"
"QScrollBar:vertical { background-color: #fff; width: 8px; margin: 0px "

@ -20,7 +20,7 @@
EmojiPickButton::EmojiPickButton(QWidget *parent)
: FlatButton(parent)
, panel_{ nullptr }
, panel_{nullptr}
{}
void

File diff suppressed because it is too large Load Diff

@ -32,8 +32,8 @@ ImageItem::ImageItem(QSharedPointer<MatrixClient> client,
const events::MessageEvent<msgs::Image> &event,
QWidget *parent)
: QWidget(parent)
, event_{ event }
, client_{ client }
, event_{event}
, client_{client}
{
setMouseTracking(true);
setCursor(Qt::PointingHandCursor);
@ -66,9 +66,9 @@ ImageItem::ImageItem(QSharedPointer<MatrixClient> client,
const QString &filename,
QWidget *parent)
: QWidget(parent)
, url_{ url }
, text_{ QFileInfo(filename).fileName() }
, client_{ client }
, url_{url}
, text_{QFileInfo(filename).fileName()}
, client_{client}
{
setMouseTracking(true);
setCursor(Qt::PointingHandCursor);

@ -22,8 +22,8 @@
#include "ImageOverlayDialog.h"
ImageOverlayDialog::ImageOverlayDialog(QPixmap image, QWidget *parent)
: QWidget{ parent }
, originalImage_{ image }
: QWidget{parent}
, originalImage_{image}
{
setMouseTracking(true);
setParent(0);

@ -39,10 +39,10 @@ LoginRequest::serialize() noexcept
#endif
QJsonObject body{
{ "type", "m.login.password" },
{ "user", user_ },
{ "password", password_ },
{ "initial_device_display_name", initialDeviceName },
{"type", "m.login.password"},
{"user", user_},
{"password", password_},
{"initial_device_display_name", initialDeviceName},
};
return QJsonDocument(body).toJson(QJsonDocument::Compact);

@ -28,7 +28,7 @@
LoginPage::LoginPage(QSharedPointer<MatrixClient> client, QWidget *parent)
: QWidget(parent)
, inferredServerAddress_()
, client_{ client }
, client_{client}
{
setStyleSheet("background-color: #fff");

@ -38,8 +38,8 @@ MainWindow *MainWindow::instance_ = nullptr;
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, progressModal_{ nullptr }
, spinner_{ nullptr }
, progressModal_{nullptr}
, spinner_{nullptr}
{
QSizePolicy sizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
setSizePolicy(sizePolicy);

@ -38,9 +38,9 @@
MatrixClient::MatrixClient(QString server, QObject *parent)
: QNetworkAccessManager(parent)
, clientApiUrl_{ "/_matrix/client/r0" }
, mediaApiUrl_{ "/_matrix/media/r0" }
, server_{ "https://" + server }
, clientApiUrl_{"/_matrix/client/r0"}
, mediaApiUrl_{"/_matrix/media/r0"}
, server_{"https://" + server}
{
QSettings settings;
txn_id_ = settings.value("client/transaction_id", 1).toInt();
@ -203,10 +203,10 @@ void
MatrixClient::sync() noexcept
{
QJsonObject filter{
{ "room",
QJsonObject{
{ "include_leave", true },
} },
{"room",
QJsonObject{
{"include_leave", true},
}},
};
QUrlQuery query;
@ -278,13 +278,13 @@ MatrixClient::sendRoomMessage(matrix::events::MessageEventType ty,
switch (ty) {
case matrix::events::MessageEventType::Text:
body = { { "msgtype", "m.text" }, { "body", msg } };
body = {{"msgtype", "m.text"}, {"body", msg}};
break;
case matrix::events::MessageEventType::Emote:
body = { { "msgtype", "m.emote" }, { "body", msg } };
body = {{"msgtype", "m.emote"}, {"body", msg}};
break;
case matrix::events::MessageEventType::Image:
body = { { "msgtype", "m.image" }, { "body", msg }, { "url", url } };
body = {{"msgtype", "m.image"}, {"body", msg}, {"url", url}};
break;
default:
qDebug() << "SendRoomMessage: Unknown message type for" << msg;
@ -812,7 +812,7 @@ MatrixClient::sendTypingNotification(const QString &roomid, int timeoutInMillis)
QString msgType("");
QJsonObject body;
body = { { "typing", true }, { "timeout", timeoutInMillis } };
body = {{"typing", true}, {"timeout", timeoutInMillis}};
QNetworkRequest request(QString(endpoint.toEncoded()));
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
@ -837,7 +837,7 @@ MatrixClient::removeTypingNotification(const QString &roomid)
QString msgType("");
QJsonObject body;
body = { { "typing", false } };
body = {{"typing", false}};
QNetworkRequest request(QString(endpoint.toEncoded()));
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");

@ -27,7 +27,7 @@ RegisterRequest::RegisterRequest(const QString &username, const QString &passwor
QByteArray
RegisterRequest::serialize() noexcept
{
QJsonObject body{ { "username", user_ }, { "password", password_ } };
QJsonObject body{{"username", user_}, {"password", password_}};
return QJsonDocument(body).toJson(QJsonDocument::Compact);
}

@ -33,7 +33,7 @@ RoomInfoListItem::RoomInfoListItem(QSharedPointer<RoomSettings> settings,
: QWidget(parent)
, state_(state)
, roomId_(room_id)
, roomSettings_{ settings }
, roomSettings_{settings}
, isPressed_(false)
, maxHeight_(IconSize + 2 * Padding)
, unreadMsgCount_(0)

@ -5,7 +5,7 @@
#include "Theme.h"
SideBarActions::SideBarActions(QWidget *parent)
: QWidget{ parent }
: QWidget{parent}
{
setFixedHeight(conf::sidebarActions::height);

@ -85,11 +85,10 @@ TimelineItem::TimelineItem(events::MessageEventType ty,
if (ty == events::MessageEventType::Emote) {
body = QString("* %1 %2").arg(displayName).arg(body);
descriptionMsg_ = { "", userid, body, descriptiveTime(timestamp) };
descriptionMsg_ = {"", userid, body, descriptiveTime(timestamp)};
} else {
descriptionMsg_ = {
"You: ", userid, body, descriptiveTime(QDateTime::currentDateTime())
};
"You: ", userid, body, descriptiveTime(QDateTime::currentDateTime())};
}
body = body.toHtmlEscaped();
@ -114,14 +113,14 @@ TimelineItem::TimelineItem(ImageItem *image,
const QString &userid,
bool withSender,
QWidget *parent)
: QWidget{ parent }
: QWidget{parent}
{
init();
auto displayName = TimelineViewManager::displayName(userid);
auto timestamp = QDateTime::currentDateTime();
descriptionMsg_ = { "You", userid, " sent an image", descriptiveTime(timestamp) };
descriptionMsg_ = {"You", userid, " sent an image", descriptiveTime(timestamp)};
generateTimestamp(timestamp);
@ -158,10 +157,10 @@ TimelineItem::TimelineItem(ImageItem *image,
auto displayName = TimelineViewManager::displayName(event.sender());
QSettings settings;
descriptionMsg_ = { event.sender() == settings.value("auth/user_id") ? "You" : displayName,
event.sender(),
" sent an image",
descriptiveTime(QDateTime::fromMSecsSinceEpoch(event.timestamp())) };
descriptionMsg_ = {event.sender() == settings.value("auth/user_id") ? "You" : displayName,
event.sender(),
" sent an image",
descriptiveTime(QDateTime::fromMSecsSinceEpoch(event.timestamp()))};
generateTimestamp(timestamp);
@ -193,10 +192,10 @@ TimelineItem::TimelineItem(const events::MessageEvent<msgs::Notice> &event,
: QWidget(parent)
{
init();
descriptionMsg_ = { TimelineViewManager::displayName(event.sender()),
event.sender(),
" sent a notification",
descriptiveTime(QDateTime::fromMSecsSinceEpoch(event.timestamp())) };
descriptionMsg_ = {TimelineViewManager::displayName(event.sender()),
event.sender(),
" sent a notification",
descriptiveTime(QDateTime::fromMSecsSinceEpoch(event.timestamp()))};
auto body = event.content().body().trimmed().toHtmlEscaped();
auto timestamp = QDateTime::fromMSecsSinceEpoch(event.timestamp());
@ -238,10 +237,10 @@ TimelineItem::TimelineItem(const events::MessageEvent<msgs::Emote> &event,
auto displayName = TimelineViewManager::displayName(event.sender());
auto emoteMsg = QString("* %1 %2").arg(displayName).arg(body);
descriptionMsg_ = { "",
event.sender(),
emoteMsg,
descriptiveTime(QDateTime::fromMSecsSinceEpoch(event.timestamp())) };
descriptionMsg_ = {"",
event.sender(),
emoteMsg,
descriptiveTime(QDateTime::fromMSecsSinceEpoch(event.timestamp()))};
generateTimestamp(timestamp);
emoteMsg = emoteMsg.toHtmlEscaped();
@ -276,10 +275,10 @@ TimelineItem::TimelineItem(const events::MessageEvent<msgs::Text> &event,
auto displayName = TimelineViewManager::displayName(event.sender());
QSettings settings;
descriptionMsg_ = { event.sender() == settings.value("auth/user_id") ? "You" : displayName,
event.sender(),
QString(": %1").arg(body),
descriptiveTime(QDateTime::fromMSecsSinceEpoch(event.timestamp())) };
descriptionMsg_ = {event.sender() == settings.value("auth/user_id") ? "You" : displayName,
event.sender(),
QString(": %1").arg(body),
descriptiveTime(QDateTime::fromMSecsSinceEpoch(event.timestamp()))};
generateTimestamp(timestamp);

@ -49,8 +49,8 @@ TimelineView::TimelineView(const Timeline &timeline,
const QString &room_id,
QWidget *parent)
: QWidget(parent)
, room_id_{ room_id }
, client_{ client }
, room_id_{room_id}
, client_{client}
{
init();
addEvents(timeline);
@ -60,8 +60,8 @@ TimelineView::TimelineView(QSharedPointer<MatrixClient> client,
const QString &room_id,
QWidget *parent)
: QWidget(parent)
, room_id_{ room_id }
, client_{ client }
, room_id_{room_id}
, client_{client}
{
init();
client_->messages(room_id_, "");

@ -194,7 +194,7 @@ QString
TimelineViewManager::chooseRandomColor()
{
std::random_device random_device;
std::mt19937 engine{ random_device() };
std::mt19937 engine{random_device()};
std::uniform_real_distribution<float> dist(0, 1);
float hue = dist(engine);

@ -30,7 +30,7 @@
TopRoomBar::TopRoomBar(QWidget *parent)
: QWidget(parent)
, buttonSize_{ 32 }
, buttonSize_{32}
{
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
setMinimumSize(QSize(0, 65));

@ -6,7 +6,7 @@
TypingDisplay::TypingDisplay(QWidget *parent)
: QWidget(parent)
, leftPadding_{ 24 }
, leftPadding_{24}
{
QFont font;
font.setPixelSize(conf::typingNotificationFontSize);

@ -29,9 +29,9 @@ UserInfoWidget::UserInfoWidget(QWidget *parent)
: QWidget(parent)
, display_name_("User")
, user_id_("@user:homeserver.org")
, logoutModal_{ nullptr }
, logoutDialog_{ nullptr }
, logoutButtonSize_{ 20 }
, logoutModal_{nullptr}
, logoutDialog_{nullptr}
, logoutButtonSize_{20}
{
QSizePolicy sizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
setSizePolicy(sizePolicy);

@ -51,15 +51,15 @@ UserSettings::save()
}
HorizontalLine::HorizontalLine(QWidget *parent)
: QFrame{ parent }
: QFrame{parent}
{
setFrameShape(QFrame::HLine);
setFrameShadow(QFrame::Sunken);
}
UserSettingsPage::UserSettingsPage(QSharedPointer<UserSettings> settings, QWidget *parent)
: QWidget{ parent }
, settings_{ settings }
: QWidget{parent}
, settings_{settings}
{
topLayout_ = new QVBoxLayout(this);

@ -22,8 +22,8 @@
OverlayModal::OverlayModal(QWidget *parent, QWidget *content)
: OverlayWidget(parent)
, duration_{ 500 }
, color_{ QColor(55, 55, 55) }
, duration_{500}
, color_{QColor(55, 55, 55)}
{
setAttribute(Qt::WA_TranslucentBackground);

@ -23,7 +23,7 @@
ScrollBar::ScrollBar(QScrollArea *area, QWidget *parent)
: QScrollBar(parent)
, area_{ area }
, area_{area}
{
hideTimer_.setSingleShot(true);

@ -54,15 +54,21 @@ void
Theme::setColor(const QString &key, ui::Color color)
{
static const QColor palette[] = {
QColor("#171919"),
QColor("#171919"),
QColor("#EBEBEB"), QColor("#C9C9C9"), QColor("#929292"),
QColor("#EBEBEB"),
QColor("#C9C9C9"),
QColor("#929292"),
QColor("#1C3133"), QColor("#577275"), QColor("#46A451"),
QColor("#1C3133"),
QColor("#577275"),
QColor("#46A451"),
QColor("#5D6565"), QColor("#E22826"), QColor("#81B3A9"),
QColor("#5D6565"),
QColor("#E22826"),
QColor("#81B3A9"),
rgba(0, 0, 0, 0),
rgba(0, 0, 0, 0),
};
colors_.insert(key, palette[static_cast<int>(color)]);

@ -12,7 +12,7 @@ Toggle::paintEvent(QPaintEvent *event)
}
Toggle::Toggle(QWidget *parent)
: QAbstractButton{ parent }
: QAbstractButton{parent}
{
init();
@ -89,10 +89,10 @@ Toggle::setTrackColor(const QColor &color)
}
ToggleThumb::ToggleThumb(Toggle *parent)
: QWidget{ parent }
, toggle_{ parent }
, position_{ Position::Right }
, offset_{ 0 }
: QWidget{parent}
, toggle_{parent}
, position_{Position::Right}
, offset_{0}
{
parent->installEventFilter(this);
}
@ -158,8 +158,8 @@ ToggleThumb::updateOffset()
}
ToggleTrack::ToggleTrack(Toggle *parent)
: QWidget{ parent }
, toggle_{ parent }
: QWidget{parent}
, toggle_{parent}
{
Q_ASSERT(parent);

Loading…
Cancel
Save