Browse Source

chore(formatting): run clang-format

reviewable/pr4434/r1
sudden6 8 years ago
parent
commit
a3b234e6dd
No known key found for this signature in database
GPG Key ID: 279509B499E032B9
  1. 3
      src/audio/audio.h
  2. 8
      src/audio/backend/openal.cpp
  3. 1
      src/audio/backend/openal.h
  4. 34
      src/chatlog/content/filetransferwidget.cpp
  5. 5
      src/chatlog/content/text.cpp
  6. 5
      src/ipc.cpp
  7. 6
      src/main.cpp
  8. 3
      src/net/toxuri.cpp
  9. 25
      src/widget/contentdialog.cpp
  10. 3
      src/widget/contentdialog.h
  11. 3
      src/widget/form/chatform.cpp
  12. 3
      src/widget/form/genericchatform.cpp
  13. 4
      src/widget/form/profileform.cpp
  14. 3
      src/widget/translator.cpp

3
src/audio/audio.h

@ -95,7 +95,8 @@ public:
// Public default audio settings // Public default audio settings
static constexpr uint32_t AUDIO_SAMPLE_RATE = 48000; static constexpr uint32_t AUDIO_SAMPLE_RATE = 48000;
static constexpr uint32_t AUDIO_FRAME_DURATION = 20; 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; static constexpr uint32_t AUDIO_CHANNELS = 2;
signals: signals:

8
src/audio/backend/openal.cpp

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

1
src/audio/backend/openal.h

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

34
src/chatlog/content/filetransferwidget.cpp

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

5
src/chatlog/content/text.cpp

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

5
src/ipc.cpp

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

6
src/main.cpp

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

3
src/net/toxuri.cpp

@ -91,7 +91,8 @@ bool handleToxURI(const QString& toxURI)
return false; 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!"); "Default message in Tox URI friend requests. Write something appropriate!");
const QString username = Nexus::getCore()->getUsername(); const QString username = Nexus::getCore()->getUsername();
ToxURIDialog* dialog = new ToxURIDialog(nullptr, toxaddr, defaultMessage.arg(username)); ToxURIDialog* dialog = new ToxURIDialog(nullptr, toxaddr, defaultMessage.arg(username));

25
src/widget/contentdialog.cpp

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

3
src/widget/contentdialog.h

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

3
src/widget/form/chatform.cpp

@ -610,7 +610,8 @@ void ChatForm::dropEvent(QDropEvent* ev)
QFile file(info.absoluteFilePath()); QFile file(info.absoluteFilePath());
QString urlString = url.toString(); 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); SendMessageStr(urlString);
continue; continue;
} }

3
src/widget/form/genericchatform.cpp

@ -451,8 +451,7 @@ void GenericChatForm::addMessage(const ToxPk& author, const QString& message, co
/** /**
* @brief Inserts int ChatLog message that you have sent * @brief Inserts int ChatLog message that you have sent
*/ */
void GenericChatForm::addSelfMessage(const QString& message, const QDateTime& datetime, void GenericChatForm::addSelfMessage(const QString& message, const QDateTime& datetime, bool isAction)
bool isAction)
{ {
createSelfMessage(message, datetime, isAction, true); createSelfMessage(message, datetime, isAction, true);
} }

4
src/widget/form/profileform.cpp

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

3
src/widget/translator.cpp

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

Loading…
Cancel
Save