diff --git a/src/audio.cpp b/src/audio.cpp index a394e72d4..d90d5d48e 100644 --- a/src/audio.cpp +++ b/src/audio.cpp @@ -184,14 +184,14 @@ void Audio::playAudioBuffer(ALuint alSource, const int16_t *data, int samples, u alGetSourcei(alSource, AL_BUFFERS_QUEUED, &queued); alSourcei(alSource, AL_LOOPING, AL_FALSE); - if(processed) + if (processed) { ALuint bufids[processed]; alSourceUnqueueBuffers(alSource, processed, bufids); alDeleteBuffers(processed - 1, bufids + 1); bufid = bufids[0]; } - else if(queued < 16) + else if (queued < 16) { alGenBuffers(1, &bufid); } @@ -207,6 +207,6 @@ void Audio::playAudioBuffer(ALuint alSource, const int16_t *data, int samples, u ALint state; alGetSourcei(alSource, AL_SOURCE_STATE, &state); - if(state != AL_PLAYING) + if (state != AL_PLAYING) alSourcePlay(alSource); } diff --git a/src/core.cpp b/src/core.cpp index 05ce62261..637436fb2 100644 --- a/src/core.cpp +++ b/src/core.cpp @@ -728,7 +728,7 @@ void Core::requestFriendship(const QString& friendAddress, const QString& messag { const QString userId = friendAddress.mid(0, TOX_CLIENT_ID_SIZE * 2); - if(hasFriendWithAddress(friendAddress)) + if (hasFriendWithAddress(friendAddress)) { emit failedToAddFriend(userId, QString(tr("Friend is already added"))); } @@ -1677,7 +1677,7 @@ void Core::createGroup(uint8_t type) bool Core::hasFriendWithAddress(const QString &addr) const { // Valid length check - if(addr.length() != (TOX_FRIEND_ADDRESS_SIZE * 2)) + if (addr.length() != (TOX_FRIEND_ADDRESS_SIZE * 2)) { return false; } @@ -1689,7 +1689,7 @@ bool Core::hasFriendWithAddress(const QString &addr) const bool Core::hasFriendWithPublicKey(const QString &pubkey) const { // Valid length check - if(pubkey.length() != (TOX_CLIENT_ID_SIZE * 2)) + if (pubkey.length() != (TOX_CLIENT_ID_SIZE * 2)) { return false; } @@ -1706,7 +1706,7 @@ bool Core::hasFriendWithPublicKey(const QString &pubkey) const QString addrOrId = getFriendAddress(ids[i]); // Set true if found - if(addrOrId.toUpper().startsWith(pubkey.toUpper())) + if (addrOrId.toUpper().startsWith(pubkey.toUpper())) { found = true; break; diff --git a/src/coreav.cpp b/src/coreav.cpp index a00d54ae6..13f6dd8c0 100644 --- a/src/coreav.cpp +++ b/src/coreav.cpp @@ -207,7 +207,7 @@ void Core::playCallAudio(void* toxav, int32_t callId, const int16_t *data, uint1 alGenSources(1, &calls[callId].alSource); ToxAvCSettings dest; - if(toxav_get_peer_csettings((ToxAv*)toxav, callId, 0, &dest) == 0) + if (toxav_get_peer_csettings((ToxAv*)toxav, callId, 0, &dest) == 0) playAudioBuffer(calls[callId].alSource, data, samples, dest.audio_channels, dest.audio_sample_rate); } @@ -229,24 +229,24 @@ void Core::sendCallAudio(int callId, ToxAv* toxav) bool frame = false; ALint samples; alcGetIntegerv(Audio::alInDev, ALC_CAPTURE_SAMPLES, sizeof(samples), &samples); - if(samples >= framesize) + if (samples >= framesize) { memset(buf, 0, bufsize); // Avoid uninitialized values (Valgrind) alcCaptureSamples(Audio::alInDev, buf, framesize); frame = 1; } - if(frame) + if (frame) { int r; - if((r = toxav_prepare_audio_frame(toxav, callId, dest, framesize*2, (int16_t*)buf, framesize)) < 0) + if ((r = toxav_prepare_audio_frame(toxav, callId, dest, framesize*2, (int16_t*)buf, framesize)) < 0) { qDebug() << "Core: toxav_prepare_audio_frame error"; calls[callId].sendAudioTimer->start(); return; } - if((r = toxav_send_audio(toxav, callId, dest, r)) < 0) + if ((r = toxav_send_audio(toxav, callId, dest, r)) < 0) qDebug() << "Core: toxav_send_audio error"; } calls[callId].sendAudioTimer->start(); @@ -271,7 +271,7 @@ void Core::sendCallVideo(int callId) if (frame.w && frame.h) { int result; - if((result = toxav_prepare_video_frame(toxav, callId, videobuf, videobufsize, &frame)) < 0) + if ((result = toxav_prepare_video_frame(toxav, callId, videobuf, videobufsize, &frame)) < 0) { qDebug() << QString("Core: toxav_prepare_video_frame: error %1").arg(result); vpx_img_free(&frame); @@ -279,7 +279,7 @@ void Core::sendCallVideo(int callId) return; } - if((result = toxav_send_video(toxav, callId, (uint8_t*)videobuf, result)) < 0) + if ((result = toxav_send_video(toxav, callId, (uint8_t*)videobuf, result)) < 0) qDebug() << QString("Core: toxav_send_video error: %1").arg(result); vpx_img_free(&frame); @@ -540,7 +540,7 @@ void Core::onAvStart(void* _toxav, int32_t call_index, void* core) // This function's logic was shamelessly stolen from uTox void Core::playAudioBuffer(ALuint alSource, const int16_t *data, int samples, unsigned channels, int sampleRate) { - if(!channels || channels > 2) + if (!channels || channels > 2) { qWarning() << "Core::playAudioBuffer: trying to play on "<= framesize) + if (samples >= framesize) { memset(buf, 0, bufsize); // Avoid uninitialized values (Valgrind) alcCaptureSamples(Audio::alInDev, buf, framesize); frame = 1; } - if(frame) + if (frame) { int r; - if((r = toxav_group_send_audio(toxav_get_tox(toxav), groupId, (int16_t*)buf, + if ((r = toxav_group_send_audio(toxav_get_tox(toxav), groupId, (int16_t*)buf, framesize, av_DefaultSettings.audio_channels, av_DefaultSettings.audio_sample_rate)) < 0) { qDebug() << "Core: toxav_group_send_audio error"; diff --git a/src/main.cpp b/src/main.cpp index 3ecb63d1c..ef378bfbc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -70,7 +70,7 @@ int main(int argc, char *argv[]) parser.process(a); Settings::getInstance(); // Build our Settings singleton as soon as QApplication is ready, not before - if(parser.isSet("P")) + if (parser.isSet("P")) Settings::getInstance().setCurrentProfile(parser.value("P")); sodium_init(); // For the auto-updater @@ -156,7 +156,7 @@ int main(int argc, char *argv[]) return EXIT_FAILURE; } } - else if(!ipc.isCurrentOwner() && !parser.isSet("P")) + else if (!ipc.isCurrentOwner() && !parser.isSet("P")) { time_t event = ipc.postEvent("$activate"); ipc.waitUntilProcessed(event); diff --git a/src/misc/smileypack.cpp b/src/misc/smileypack.cpp index 1ec70f954..c640fffb4 100644 --- a/src/misc/smileypack.cpp +++ b/src/misc/smileypack.cpp @@ -69,9 +69,9 @@ QList > SmileyPack::listSmileyPacks(const QStringList &p if (relPath.leftRef(2) == "..") { - if(!smileyPacks.contains(QPair(packageName, absPath))) + if (!smileyPacks.contains(QPair(packageName, absPath))) smileyPacks << QPair(packageName, absPath); - else if(!smileyPacks.contains(QPair(packageName, relPath))) + else if (!smileyPacks.contains(QPair(packageName, relPath))) smileyPacks << QPair(packageName, relPath); // use relative path for subdirectories } } @@ -97,7 +97,7 @@ bool SmileyPack::load(const QString& filename) // open emoticons.xml QFile xmlFile(filename); - if(!xmlFile.open(QIODevice::ReadOnly)) + if (!xmlFile.open(QIODevice::ReadOnly)) return false; // cannot open file /* parse the cfg file @@ -138,14 +138,14 @@ bool SmileyPack::load(const QString& filename) QPixmap pm; pm.loadFromData(getCachedSmiley(emoticon), "PNG"); - if(pm.size().width() > 0) + if (pm.size().width() > 0) emoticonSet.push_back(emoticon); stringElement = stringElement.nextSibling().toElement(); } - if(emoticonSet.size() > 0) + if (emoticonSet.size() > 0) emoticons.push_back(emoticonSet); } diff --git a/src/platform/timer_win.cpp b/src/platform/timer_win.cpp index e860a5ac6..31542f76f 100644 --- a/src/platform/timer_win.cpp +++ b/src/platform/timer_win.cpp @@ -24,7 +24,7 @@ uint32_t Platform::getIdleTime() { LASTINPUTINFO info = { 0 }; info.cbSize = sizeof(info); - if(GetLastInputInfo(&info)) + if (GetLastInputInfo(&info)) return GetTickCount() - info.dwTime; return 0; } diff --git a/src/platform/timer_x11.cpp b/src/platform/timer_x11.cpp index 5c9ac1b20..263a3b9b6 100644 --- a/src/platform/timer_x11.cpp +++ b/src/platform/timer_x11.cpp @@ -25,7 +25,7 @@ uint32_t Platform::getIdleTime() uint32_t idleTime = 0; Display *display = XOpenDisplay(NULL); - if(!display) + if (!display) { qDebug() << "XOpenDisplay(NULL) failed"; return 0; @@ -33,10 +33,10 @@ uint32_t Platform::getIdleTime() int32_t x11event = 0, x11error = 0; static int32_t hasExtension = XScreenSaverQueryExtension(display, &x11event, &x11error); - if(hasExtension) + if (hasExtension) { XScreenSaverInfo *info = XScreenSaverAllocInfo(); - if(info) + if (info) { XScreenSaverQueryInfo(display, DefaultRootWindow(display), info); idleTime = info->idle; diff --git a/src/video/cameraworker.cpp b/src/video/cameraworker.cpp index 8671d6568..da98e58f4 100644 --- a/src/video/cameraworker.cpp +++ b/src/video/cameraworker.cpp @@ -129,7 +129,7 @@ void CameraWorker::applyProps() if (!cam.isOpened()) return; - for(int prop : props.keys()) + for (int prop : props.keys()) cam.set(prop, props.value(prop)); } @@ -148,7 +148,7 @@ void CameraWorker::subscribe() void CameraWorker::unsubscribe() { - if(--refCount <= 0) + if (--refCount <= 0) { cam.release(); refCount = 0; diff --git a/src/widget/form/chatform.cpp b/src/widget/form/chatform.cpp index 50b455289..4f2c73998 100644 --- a/src/widget/form/chatform.cpp +++ b/src/widget/form/chatform.cpp @@ -793,7 +793,7 @@ void ChatForm::onLoadHistory() void ChatForm::startCounter() { - if(!timer) + if (!timer) { timer = new QTimer(); connect(timer, SIGNAL(timeout()), this, SLOT(updateTime())); @@ -805,7 +805,7 @@ void ChatForm::startCounter() void ChatForm::stopCounter() { - if(timer) + if (timer) { addSystemInfoMessage(tr("Call with %1 ended. %2").arg(f->getDisplayedName(), secondsToDHMS(timeElapsed.elapsed()/1000)), @@ -834,10 +834,10 @@ QString ChatForm::secondsToDHMS(quint32 duration) int hours = (int) (duration % 24); int days = (int) (duration / 24); - if(minutes == 0) + if (minutes == 0) return cD + res.sprintf("%02ds", seconds); - if(hours == 0 && days == 0) + if (hours == 0 && days == 0) return cD + res.sprintf("%02dm %02ds", minutes, seconds); if (days == 0) diff --git a/src/widget/form/settings/generalform.cpp b/src/widget/form/settings/generalform.cpp index c7f35a2ae..0f3ab819d 100644 --- a/src/widget/form/settings/generalform.cpp +++ b/src/widget/form/settings/generalform.cpp @@ -79,7 +79,7 @@ GeneralForm::GeneralForm(SettingsWidget *myParent) : bodyUI->styleBrowser->addItem(tr("None")); bodyUI->styleBrowser->addItems(QStyleFactory::keys()); - if(QStyleFactory::keys().contains(Settings::getInstance().getStyle())) + if (QStyleFactory::keys().contains(Settings::getInstance().getStyle())) bodyUI->styleBrowser->setCurrentText(Settings::getInstance().getStyle()); else bodyUI->styleBrowser->setCurrentText(tr("None")); @@ -124,7 +124,7 @@ GeneralForm::GeneralForm(SettingsWidget *myParent) : connect(bodyUI->autoAwaySpinBox, SIGNAL(editingFinished()), this, SLOT(onAutoAwayChanged())); connect(bodyUI->showInFront, &QCheckBox::stateChanged, this, &GeneralForm::onSetShowInFront); connect(bodyUI->autoacceptFiles, &QCheckBox::stateChanged, this, &GeneralForm::onAutoAcceptFileChange); - if(bodyUI->autoacceptFiles->isChecked()) + if (bodyUI->autoacceptFiles->isChecked()) connect(bodyUI->autoSaveFilesDir, SIGNAL(clicked()), this, SLOT(onAutoSaveDirChange())); //theme connect(bodyUI->useEmoticons, &QCheckBox::stateChanged, this, &GeneralForm::onUseEmoticonsChange); @@ -192,7 +192,7 @@ void GeneralForm::onSetMinimizeToTray() void GeneralForm::onStyleSelected(QString style) { - if(bodyUI->styleBrowser->currentIndex() == 0) + if (bodyUI->styleBrowser->currentIndex() == 0) Settings::getInstance().setStyle("None"); else Settings::getInstance().setStyle(style); @@ -221,7 +221,7 @@ void GeneralForm::onAutoAcceptFileChange() { Settings::getInstance().setAutoSaveEnabled(bodyUI->autoacceptFiles->isChecked()); - if(bodyUI->autoacceptFiles->isChecked() == true) + if (bodyUI->autoacceptFiles->isChecked() == true) connect(bodyUI->autoSaveFilesDir, SIGNAL(clicked()), this, SLOT(onAutoSaveDirChange())); else disconnect(bodyUI->autoSaveFilesDir, SIGNAL(clicked()),this, SLOT(onAutoSaveDirChange())); @@ -231,7 +231,7 @@ void GeneralForm::onAutoSaveDirChange() { QString previousDir = Settings::getInstance().getGlobalAutoAcceptDir(); QString directory = QFileDialog::getExistingDirectory(0, tr("Choose an auto accept directory","popup title")); - if(directory.isEmpty()) + if (directory.isEmpty()) directory = previousDir; Settings::getInstance().setGlobalAutoAcceptDir(directory); @@ -299,7 +299,7 @@ void GeneralForm::reloadSmiles() QStringList smiles; smiles << ":)" << ";)" << ":p" << ":O" << ":["; //just in case... - for(int i = 0; i < emoticons.size(); i++) + for (int i = 0; i < emoticons.size(); i++) smiles.push_front(emoticons.at(i).first()); int pixSize = 30; diff --git a/src/widget/form/tabcompleter.cpp b/src/widget/form/tabcompleter.cpp index 73d3ffeef..2fbaa48c7 100644 --- a/src/widget/form/tabcompleter.cpp +++ b/src/widget/form/tabcompleter.cpp @@ -52,7 +52,7 @@ void TabCompleter::buildCompletionList() // that section is then used as the completion regex QRegExp regex(QString("^[-_\\[\\]{}|`^.\\\\]*").append(QRegExp::escape(tabAbbrev)), Qt::CaseInsensitive); - for(auto name : group->getPeerList()) + for (auto name : group->getPeerList()) if (regex.indexIn(name) > -1) completionMap[name.toLower()] = name; diff --git a/src/widget/maskablepixmapwidget.cpp b/src/widget/maskablepixmapwidget.cpp index f0015d6d0..5f8d2ea99 100644 --- a/src/widget/maskablepixmapwidget.cpp +++ b/src/widget/maskablepixmapwidget.cpp @@ -130,6 +130,6 @@ void MaskablePixmapWidget::paintEvent(QPaintEvent *) void MaskablePixmapWidget::mousePressEvent(QMouseEvent*) { - if(clickable) + if (clickable) emit clicked(); } diff --git a/src/widget/tool/chatactions/messageaction.cpp b/src/widget/tool/chatactions/messageaction.cpp index 06f27ef1d..93b8271ee 100644 --- a/src/widget/tool/chatactions/messageaction.cpp +++ b/src/widget/tool/chatactions/messageaction.cpp @@ -29,7 +29,7 @@ MessageAction::MessageAction(const QString &author, const QString &message, cons QString MessageAction::getMessage(QString div) { QString message_; - if(Settings::getInstance().getUseEmoticons()) + if (Settings::getInstance().getUseEmoticons()) message_ = SmileyPack::getInstance().smileyfied(toHtmlChars(message)); else message_ = toHtmlChars(message); diff --git a/src/widget/widget.cpp b/src/widget/widget.cpp index dcf6c67a4..4f53a4c4e 100644 --- a/src/widget/widget.cpp +++ b/src/widget/widget.cpp @@ -54,7 +54,7 @@ void toxActivateEventHandler(const QByteArray& data) { - if(data != "$activate") + if (data != "$activate") return; Widget::getInstance()->show(); Widget::getInstance()->activateWindow(); @@ -116,7 +116,7 @@ void Widget::init() if (Settings::getInstance().getShowSystemTray()){ icon->show(); - if(Settings::getInstance().getAutostartInTray() == false) + if (Settings::getInstance().getAutostartInTray() == false) this->show(); } else @@ -149,7 +149,7 @@ void Widget::init() ui->tooliconsZone->setStyleSheet(Style::resolve("QPushButton{background-color:@themeDark;border:none;}QPushButton:hover{background-color:@themeMediumDark;border:none;}")); - if(QStyleFactory::keys().contains(Settings::getInstance().getStyle()) + if (QStyleFactory::keys().contains(Settings::getInstance().getStyle()) && Settings::getInstance().getStyle() != "None") { ui->mainHead->setStyle(QStyleFactory::create(Settings::getInstance().getStyle())); @@ -348,7 +348,7 @@ QThread* Widget::getCoreThread() void Widget::closeEvent(QCloseEvent *event) { - if(Settings::getInstance().getShowSystemTray() && Settings::getInstance().getCloseToTray() == true) + if (Settings::getInstance().getShowSystemTray() && Settings::getInstance().getCloseToTray() == true) { event->ignore(); this->hide(); @@ -365,7 +365,7 @@ void Widget::changeEvent(QEvent *event) { if (event->type() == QEvent::WindowStateChange) { - if(isMinimized() && Settings::getInstance().getMinimizeToTray()) + if (isMinimized() && Settings::getInstance().getMinimizeToTray()) { this->hide(); } @@ -415,7 +415,7 @@ QList Widget::searchProfiles() QDir dir(Settings::getSettingsDirPath()); dir.setFilter(QDir::Files | QDir::NoDotAndDotDot); dir.setNameFilters(QStringList("*.tox")); - for(QFileInfo file : dir.entryInfoList()) + for (QFileInfo file : dir.entryInfoList()) out += file.completeBaseName(); return out; } @@ -591,7 +591,7 @@ void Widget::onIconClick(QSystemTrayIcon::ActivationReason reason) { switch (reason) { case QSystemTrayIcon::Trigger: - if(this->isHidden() == true) + if (this->isHidden() == true) { this->show(); this->activateWindow(); @@ -712,7 +712,7 @@ void Widget::addFriend(int friendId, const QString &userId) void Widget::addFriendFailed(const QString&, const QString& errorInfo) { QString info = QString(tr("Couldn't request friendship")); - if(!errorInfo.isEmpty()) { + if (!errorInfo.isEmpty()) { info = info + (QString(": ") + errorInfo); } @@ -733,7 +733,7 @@ void Widget::onFriendStatusChanged(int friendId, Status status) f->getFriendWidget()->updateStatusLight(); //won't print the message if there were no messages before - if(!f->getChatForm()->isEmpty() + if (!f->getChatForm()->isEmpty() && Settings::getInstance().getStatusChangeNotificationEnabled()) { QString fStatus = "";