1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

chore(formatting): run clang-format

This commit is contained in:
sudden6 2017-06-01 09:50:59 +02:00
parent a1181e10f2
commit a3b234e6dd
No known key found for this signature in database
GPG Key ID: 279509B499E032B9
20 changed files with 75 additions and 87 deletions

View File

@ -95,7 +95,8 @@ public:
// Public default audio settings
static constexpr uint32_t AUDIO_SAMPLE_RATE = 48000;
static constexpr uint32_t AUDIO_FRAME_DURATION = 20;
static constexpr uint32_t AUDIO_FRAME_SAMPLE_COUNT = AUDIO_FRAME_DURATION * AUDIO_SAMPLE_RATE / 1000;
static constexpr uint32_t AUDIO_FRAME_SAMPLE_COUNT =
AUDIO_FRAME_DURATION * AUDIO_SAMPLE_RATE / 1000;
static constexpr uint32_t AUDIO_CHANNELS = 2;
signals:

View File

@ -42,8 +42,8 @@
static const unsigned int BUFFER_COUNT = 16;
OpenAL::OpenAL() :
audioThread{new QThread}
OpenAL::OpenAL()
: audioThread{new QThread}
, alInDev{nullptr}
, inSubscriptions{0}
, alOutDev{nullptr}
@ -463,9 +463,7 @@ void OpenAL::playMono16SoundCleanup()
alSourcei(alMainSource, AL_BUFFER, AL_NONE);
alDeleteBuffers(1, &alMainBuffer);
alMainBuffer = 0;
}
else
{
} else {
// the audio didn't finish, try again later
playMono16Timer.start(10);
}

View File

@ -89,7 +89,6 @@ public:
int sampleRate);
private:
static void checkAlError() noexcept;
static void checkAlcError(ALCdevice* device) noexcept;

View File

@ -99,10 +99,8 @@ FileTransferWidget::FileTransferWidget(QWidget* parent, ToxFile file)
&FileTransferWidget::fileTransferRemotePausedUnpaused);
connect(Core::getInstance(), &Core::fileTransferBrokenUnbroken, this,
&FileTransferWidget::fileTransferBrokenUnbroken);
connect(ui->leftButton, &QPushButton::clicked, this,
&FileTransferWidget::onLeftButtonClicked);
connect(ui->rightButton, &QPushButton::clicked, this,
&FileTransferWidget::onRightButtonClicked);
connect(ui->leftButton, &QPushButton::clicked, this, &FileTransferWidget::onLeftButtonClicked);
connect(ui->rightButton, &QPushButton::clicked, this, &FileTransferWidget::onRightButtonClicked);
connect(ui->previewButton, &QPushButton::clicked, this,
&FileTransferWidget::onPreviewButtonClicked);
@ -222,32 +220,32 @@ void FileTransferWidget::paintEvent(QPaintEvent*)
if (drawButtonAreaNeeded()) {
// Draw the button background:
QPainterPath buttonBackground;
buttonBackground.addRoundRect(width()-2*buttonFieldWidth-lineWidth*2, 0, buttonFieldWidth,
buttonFieldWidth+lineWidth, 50, 50);
buttonBackground.addRect(width()-2*buttonFieldWidth-lineWidth*2, 0, buttonFieldWidth*2,
buttonFieldWidth/2);
buttonBackground.addRect(width()-1.5*buttonFieldWidth-lineWidth*2, 0, buttonFieldWidth*2,
buttonFieldWidth+1);
buttonBackground.addRoundRect(width() - 2 * buttonFieldWidth - lineWidth * 2, 0,
buttonFieldWidth, buttonFieldWidth + lineWidth, 50, 50);
buttonBackground.addRect(width() - 2 * buttonFieldWidth - lineWidth * 2, 0,
buttonFieldWidth * 2, buttonFieldWidth / 2);
buttonBackground.addRect(width() - 1.5 * buttonFieldWidth - lineWidth * 2, 0,
buttonFieldWidth * 2, buttonFieldWidth + 1);
buttonBackground.setFillRule(Qt::WindingFill);
painter.setBrush(QBrush(buttonBackgroundColor));
painter.drawPath(buttonBackground);
// Draw the left button:
QPainterPath leftButton;
leftButton.addRoundRect(QRect(width()-2*buttonFieldWidth-lineWidth, 0, buttonFieldWidth,
buttonFieldWidth), 50, 50);
leftButton.addRect(QRect(width()-2*buttonFieldWidth-lineWidth, 0, buttonFieldWidth/2,
buttonFieldWidth/2));
leftButton.addRect(QRect(width()-1.5*buttonFieldWidth-lineWidth, 0, buttonFieldWidth/2,
buttonFieldWidth));
leftButton.addRoundRect(QRect(width() - 2 * buttonFieldWidth - lineWidth, 0,
buttonFieldWidth, buttonFieldWidth),
50, 50);
leftButton.addRect(QRect(width() - 2 * buttonFieldWidth - lineWidth, 0,
buttonFieldWidth / 2, buttonFieldWidth / 2));
leftButton.addRect(QRect(width() - 1.5 * buttonFieldWidth - lineWidth, 0,
buttonFieldWidth / 2, buttonFieldWidth));
leftButton.setFillRule(Qt::WindingFill);
painter.setBrush(QBrush(buttonColor));
painter.drawPath(leftButton);
// Draw the right button:
painter.setBrush(QBrush(buttonColor));
painter.setClipRect(QRect(width()-buttonFieldWidth, 0, buttonFieldWidth,
buttonFieldWidth));
painter.setClipRect(QRect(width() - buttonFieldWidth, 0, buttonFieldWidth, buttonFieldWidth));
painter.drawRoundRect(geometry(), r * ratio, r);
}
}

View File

@ -366,9 +366,8 @@ QString Text::extractSanitizedText(int from, int to) const
QTextBlock end = doc->findBlock(to);
for (QTextBlock block = begin; block != end.next() && block.isValid(); block = block.next()) {
for (QTextBlock::Iterator itr = block.begin(); itr != block.end(); ++itr) {
int pos =
itr.fragment()
.position(); // fragment position -> position of the first character in the fragment
int pos = itr.fragment().position(); // fragment position -> position of the first
// character in the fragment
if (itr.fragment().charFormat().isImageFormat()) {
QTextImageFormat imgFmt = itr.fragment().charFormat().toImageFormat();

View File

@ -174,7 +174,7 @@ static void processUrl(QString& str, std::function<QString(QString&)> func)
*/
void TextFormatter::applyHtmlFontStyling(bool showFormattingSymbols)
{
processUrl(message, [] (QString& str) {
processUrl(message, [](QString& str) {
for (char c : MARKDOWN_SYMBOLS) {
QString charCode = QString::number(static_cast<int>(c));
str.replace(c, HTML_CHARACTER_CODE.arg(charCode));
@ -217,7 +217,7 @@ void TextFormatter::applyHtmlFontStyling(bool showFormattingSymbols)
*/
void TextFormatter::wrapUrl()
{
processUrl(message, [] (QString& str) {
processUrl(message, [](QString& str) {
return htmlPatterns[TextStyle::HREF].arg(str.startsWith("www") ? "http://" : "", str);
});
}

View File

@ -21,9 +21,9 @@
#include <QCoreApplication>
#include <QDebug>
#include <QThread>
#include <ctime>
#include <random>
#include <unistd.h>
#include <ctime>
/**
* @var time_t IPC::lastEvent
@ -216,8 +216,7 @@ IPC::IPCEvent* IPC::fetchEvent()
memset(evt, 0, sizeof(IPCEvent));
if (evt->posted && !evt->processed && evt->sender != getpid()
&& (evt->dest == profileId
|| (evt->dest == 0 && isCurrentOwner())))
&& (evt->dest == profileId || (evt->dest == 0 && isCurrentOwner())))
return evt;
}

View File

@ -38,9 +38,9 @@
#include <QMutex>
#include <QMutexLocker>
#include <ctime>
#include <sodium.h>
#include <stdio.h>
#include <ctime>
#if defined(Q_OS_OSX)
#include "platform/install_osx.h"
@ -168,8 +168,8 @@ int main(int argc, char* argv[])
uint32_t profileId = Settings::getInstance().getCurrentProfileId();
IPC ipc(profileId);
QObject::connect(&Settings::getInstance(), &Settings::currentProfileIdChanged,
&ipc, &IPC::setProfileId);
QObject::connect(&Settings::getInstance(), &Settings::currentProfileIdChanged, &ipc,
&IPC::setProfileId);
if (sodium_init() < 0) // For the auto-updater
{

View File

@ -91,7 +91,8 @@ bool handleToxURI(const QString& toxURI)
return false;
}
const QString defaultMessage = QObject::tr("%1 here! Tox me maybe?",
const QString defaultMessage =
QObject::tr("%1 here! Tox me maybe?",
"Default message in Tox URI friend requests. Write something appropriate!");
const QString username = Nexus::getCore()->getUsername();
ToxURIDialog* dialog = new ToxURIDialog(nullptr, toxaddr, defaultMessage.arg(username));

View File

@ -93,7 +93,7 @@ CameraSource::CameraSource()
: deviceName{"none"}
, device{nullptr}
, mode(VideoMode())
// clang-format off
// clang-format off
, cctx{nullptr}
#if LIBAVCODEC_VERSION_INT < 3747941
, cctxOrig{nullptr}

View File

@ -69,11 +69,8 @@ ContentDialog::ContentDialog(SettingsWidget* settingsWidget, QWidget* parent)
friendLayout->setMargin(0);
friendLayout->setSpacing(0);
layouts = {
friendLayout->getLayoutOnline(),
groupLayout.getLayout(),
friendLayout->getLayoutOffline()
};
layouts = {friendLayout->getLayoutOnline(), groupLayout.getLayout(),
friendLayout->getLayoutOffline()};
if (s.getGroupchatPosition()) {
layouts.swap(0, 1);
@ -141,8 +138,9 @@ ContentDialog::ContentDialog(SettingsWidget* settingsWidget, QWidget* parent)
Translator::registerHandler(std::bind(&ContentDialog::retranslateUi, this), this);
}
void ContentDialog::removeCurrent(QHash<int, ContactInfo>& infos) {
for (auto it = infos.begin(); it != infos.end(); ) {
void ContentDialog::removeCurrent(QHash<int, ContactInfo>& infos)
{
for (auto it = infos.begin(); it != infos.end();) {
if (std::get<0>(*it) == this) {
it = infos.erase(it);
} else {
@ -354,9 +352,9 @@ void ContentDialog::cycleContacts(bool forward, bool inverse)
bool isCurOffline = currentLayout == friendLayout->getLayoutOffline();
bool isCurOnline = currentLayout == friendLayout->getLayoutOnline();
bool isCurGroup = currentLayout == groupLayout.getLayout();
bool nextIsEmpty = (isCurOnline && offlineEmpty && (groupsEmpty || groupsOnTop)) ||
(isCurGroup && offlineEmpty && (onlineEmpty || !groupsOnTop)) ||
isCurOffline;
bool nextIsEmpty = (isCurOnline && offlineEmpty && (groupsEmpty || groupsOnTop))
|| (isCurGroup && offlineEmpty && (onlineEmpty || !groupsOnTop))
|| isCurOffline;
if (nextIsEmpty) {
forward = !forward;
@ -509,12 +507,10 @@ void ContentDialog::updateTitleAndStatusIcon()
Status currentStatus = activeChatroomWidget->getFriend()->getStatus();
QMap<Status, QIcon> icons {
{Status::Online, QIcon(":/img/status/dot_online.svg")},
QMap<Status, QIcon> icons{{Status::Online, QIcon(":/img/status/dot_online.svg")},
{Status::Away, QIcon(":/img/status/dot_away.svg")},
{Status::Busy, QIcon(":/img/status/dot_busy.svg")},
{Status::Offline, QIcon(":/img/status/dot_offline.svg")}
};
{Status::Offline, QIcon(":/img/status/dot_offline.svg")}};
setWindowIcon(icons[currentStatus]);
}
@ -821,8 +817,7 @@ bool ContentDialog::hasWidget(int id, GenericChatroomWidget* chatroomWidget,
return false;
}
return std::get<0>(*iter) == this &&
std::get<1>(*iter) == chatroomWidget;
return std::get<0>(*iter) == this && std::get<1>(*iter) == chatroomWidget;
}
/**

View File

@ -112,8 +112,7 @@ private:
QLayout* nextLayout(QLayout* layout, bool forward) const;
int getCurrentLayout(QLayout*& layout);
bool hasWidget(int id, GenericChatroomWidget* chatroomWidget,
const QHash<int, ContactInfo>& list);
bool hasWidget(int id, GenericChatroomWidget* chatroomWidget, const QHash<int, ContactInfo>& list);
void removeCurrent(QHash<int, ContactInfo>& infos);
static bool existsWidget(int id, const QHash<int, ContactInfo>& list);
static void focusDialog(int id, const QHash<int, ContactInfo>& list);

View File

@ -610,7 +610,8 @@ void ChatForm::dropEvent(QDropEvent* ev)
QFile file(info.absoluteFilePath());
QString urlString = url.toString();
if (url.isValid() && !url.isLocalFile() && urlString.length() < static_cast<int>(tox_max_message_length())) {
if (url.isValid() && !url.isLocalFile()
&& urlString.length() < static_cast<int>(tox_max_message_length())) {
SendMessageStr(urlString);
continue;
}

View File

@ -55,7 +55,7 @@
* (excluded)
*/
#define SET_STYLESHEET(x) (x)->setStyleSheet(Style::getStylesheet(":/ui/"#x"/"#x".css"))
#define SET_STYLESHEET(x) (x)->setStyleSheet(Style::getStylesheet(":/ui/" #x "/" #x ".css"))
static const QSize AVATAR_SIZE{40, 40};
static const QSize CALL_BUTTONS_SIZE{50, 40};
@ -380,7 +380,7 @@ void GenericChatForm::onChatContextMenuRequested(QPoint pos)
* @param messageAuthor Author of the sent message
* @return True if it's needed to hide name, false otherwise
*/
bool GenericChatForm::needsToHideName(const ToxPk &messageAuthor) const
bool GenericChatForm::needsToHideName(const ToxPk& messageAuthor) const
{
qint64 messagesTimeDiff = prevMsgDateTime.secsTo(QDateTime::currentDateTime());
return messageAuthor == previousId && messagesTimeDiff < chatWidget->repNameAfter;
@ -451,8 +451,7 @@ void GenericChatForm::addMessage(const ToxPk& author, const QString& message, co
/**
* @brief Inserts int ChatLog message that you have sent
*/
void GenericChatForm::addSelfMessage(const QString& message, const QDateTime& datetime,
bool isAction)
void GenericChatForm::addSelfMessage(const QString& message, const QDateTime& datetime, bool isAction)
{
createSelfMessage(message, datetime, isAction, true);
}

View File

@ -56,8 +56,8 @@ ProfileForm::ProfileForm(QWidget* parent)
bodyUI->setupUi(this);
core = Core::getInstance();
bodyUI->userNameLabel->setToolTip(tr("Tox user names cannot exceed %1 characters.")
.arg(tox_max_name_length()));
bodyUI->userNameLabel->setToolTip(
tr("Tox user names cannot exceed %1 characters.").arg(tox_max_name_length()));
bodyUI->userName->setMaxLength(tox_max_name_length());
// tox

View File

@ -209,7 +209,7 @@ void FriendListWidget::setMode(Mode mode)
{ Time::Month4Ago, ql.monthName(today.addMonths(-4).month()) },
{ Time::Month5Ago, ql.monthName(today.addMonths(-5).month()) },
};
// clang-format on
// clang-format on
#undef COMMENT
activityLayout = new QVBoxLayout();

View File

@ -44,8 +44,7 @@ void Translator::translate(const QString& localeName)
// Load translations
QCoreApplication::removeTranslator(translator);
QString locale = localeName.isEmpty() ? QLocale::system().name().section('_', 0, 0)
: localeName;
QString locale = localeName.isEmpty() ? QLocale::system().name().section('_', 0, 0) : localeName;
if (locale != "en") {
if (translator->load(locale, ":translations/")) {

View File

@ -75,7 +75,7 @@ static const StringToString multilineCode{
{QStringLiteral("```int main()\n{\n return 0;\n}```"),
QStringLiteral("<font color=#595959><code>int main()\n{\n return 0;\n}</code></font>")}};
static const StringToString urlCases {
static const StringToString urlCases{
{QStringLiteral("https://github.com/qTox/qTox/issues/4233"),
QStringLiteral("<a href=\"https://github.com/qTox/qTox/issues/4233\">"
"https://github.com/qTox/qTox/issues/4233</a>")},

View File

@ -32,7 +32,7 @@ struct UpdateFileMeta
unsigned char sig[crypto_sign_BYTES]; ///< Signature of the file (ed25519)
QString id; ///< Unique id of the file
QString installpath; ///< Local path including the file name. May be relative to qtox-updater or
///absolute
/// absolute
uint64_t size; ///< Size in bytes of the file
bool operator==(const UpdateFileMeta& other)