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

@ -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

@ -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,7 +138,8 @@ ContentDialog::ContentDialog(SettingsWidget* settingsWidget, QWidget* parent)
Translator::registerHandler(std::bind(&ContentDialog::retranslateUi, this), this);
}
void ContentDialog::removeCurrent(QHash<int, ContactInfo>& infos) {
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);
@ -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

@ -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

@ -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/")) {