From 76f694fe731431ea9a805bf596efc0a924491539 Mon Sep 17 00:00:00 2001 From: Diadlo Date: Thu, 7 Jul 2016 12:55:53 +0300 Subject: [PATCH 1/5] style(widget): Style fixes --- res.qrc | 2 + src/widget/categorywidget.cpp | 55 +++++-------------- src/widget/contentdialog.cpp | 6 +- src/widget/form/addfriendform.cpp | 12 ++-- src/widget/form/chatform.cpp | 6 +- src/widget/form/chatform.h | 12 ++-- src/widget/form/genericchatform.cpp | 16 ++---- src/widget/form/groupchatform.cpp | 6 +- src/widget/form/groupinviteform.cpp | 5 +- src/widget/form/profileform.cpp | 4 +- src/widget/form/profileform.h | 5 +- src/widget/form/settings/aboutform.h | 5 +- src/widget/form/settings/advancedform.h | 5 +- src/widget/form/settings/avform.cpp | 4 +- src/widget/form/settings/generalform.h | 5 +- src/widget/form/settings/genericsettings.h | 5 +- src/widget/form/settings/privacyform.h | 5 +- src/widget/genericchatroomwidget.cpp | 6 +- src/widget/loginscreen.cpp | 8 +-- .../tool/screengrabberchooserrectitem.cpp | 7 +-- src/widget/widget.cpp | 8 +-- ui/contentDialog/contentDialog.css | 16 ++++++ ui/tooliconsZone/tooliconsZone.css | 23 ++++++++ 23 files changed, 124 insertions(+), 102 deletions(-) create mode 100644 ui/contentDialog/contentDialog.css create mode 100644 ui/tooliconsZone/tooliconsZone.css diff --git a/res.qrc b/res.qrc index 37e02067a..819196aa8 100644 --- a/res.qrc +++ b/res.qrc @@ -131,5 +131,7 @@ ui/loginScreen/loginScreen.css img/others/logout-icon.svg img/caps_lock.svg + ui/contentDialog/contentDialog.css + ui/tooliconsZone/tooliconsZone.css diff --git a/src/widget/categorywidget.cpp b/src/widget/categorywidget.cpp index 31140ecd4..73ca47452 100644 --- a/src/widget/categorywidget.cpp +++ b/src/widget/categorywidget.cpp @@ -254,52 +254,25 @@ void CategoryWidget::onCompactChanged(bool _compact) topLayout->setSpacing(0); topLayout->setMargin(0); - (void)_compact; + Q_UNUSED(_compact); setCompact(true); - if (true) - { - nameLabel->minimizeMaximumWidth(); + nameLabel->minimizeMaximumWidth(); - mainLayout = nullptr; + mainLayout = nullptr; - container->setFixedHeight(25); - container->setLayout(topLayout); + container->setFixedHeight(25); + container->setLayout(topLayout); - topLayout->addSpacing(18); - topLayout->addWidget(&statusPic); - topLayout->addSpacing(5); - topLayout->addWidget(nameLabel, 100); - topLayout->addWidget(lineFrame, 1); - topLayout->addSpacing(5); - topLayout->addWidget(statusLabel); - topLayout->addSpacing(5); - topLayout->activate(); - } - /*else - { - nameLabel->setMaximumWidth(QWIDGETSIZE_MAX); - - mainLayout = new QVBoxLayout(); - mainLayout->setSpacing(0); - mainLayout->setContentsMargins(20, 0, 20, 0); - - container->setFixedHeight(25); - container->setLayout(mainLayout); - - topLayout->addWidget(&statusPic); - topLayout->addSpacing(10); - topLayout->addWidget(nameLabel, 1); - topLayout->addSpacing(5); - topLayout->addWidget(statusLabel); - topLayout->activate(); - - mainLayout->addStretch(); - mainLayout->addLayout(topLayout); - mainLayout->addWidget(lineFrame); - mainLayout->addStretch(); - mainLayout->activate(); - }*/ + topLayout->addSpacing(18); + topLayout->addWidget(&statusPic); + topLayout->addSpacing(5); + topLayout->addWidget(nameLabel, 100); + topLayout->addWidget(lineFrame, 1); + topLayout->addSpacing(5); + topLayout->addWidget(statusLabel); + topLayout->addSpacing(5); + topLayout->activate(); Style::repolish(this); } diff --git a/src/widget/contentdialog.cpp b/src/widget/contentdialog.cpp index 5121fb2b4..eba8acf2a 100644 --- a/src/widget/contentdialog.cpp +++ b/src/widget/contentdialog.cpp @@ -59,7 +59,7 @@ ContentDialog::ContentDialog(SettingsWidget* settingsWidget, QWidget* parent) boxLayout->setSpacing(0); splitter = new QSplitter(this); - setStyleSheet("QSplitter{color: rgb(255, 255, 255);background-color: rgb(255, 255, 255);alternate-background-color: rgb(255, 255, 255);border-color: rgb(255, 255, 255);gridline-color: rgb(255, 255, 255);selection-color: rgb(255, 255, 255);selection-background-color: rgb(255, 255, 255);}QSplitter:handle{color: rgb(255, 255, 255);background-color: rgb(255, 255, 255);}"); + setStyleSheet(Style::getStylesheet(":/ui/contentDialog/contentDialog.css")); splitter->setHandleWidth(6); QWidget *friendWidget = new QWidget(); @@ -455,7 +455,7 @@ void ContentDialog::updateTitleAndStatusIcon(const QString& username) setWindowTitle(displayWidget->getTitle() + QStringLiteral(" - ") + username); // it's null when it's a groupchat - if(displayWidget->getFriend() == nullptr) + if (displayWidget->getFriend() == nullptr) { setWindowIcon(QIcon(":/img/group.svg")); return; @@ -611,7 +611,7 @@ void ContentDialog::moveEvent(QMoveEvent* event) void ContentDialog::keyPressEvent(QKeyEvent* event) { - if(event->key() != Qt::Key_Escape) + if (event->key() != Qt::Key_Escape) QDialog::keyPressEvent(event); // Ignore escape keyboard shortcut. } diff --git a/src/widget/form/addfriendform.cpp b/src/widget/form/addfriendform.cpp index 72b7e6a0a..4c21e09be 100644 --- a/src/widget/form/addfriendform.cpp +++ b/src/widget/form/addfriendform.cpp @@ -133,13 +133,12 @@ void AddFriendForm::setMode(Mode mode) bool AddFriendForm::addFriendRequest(const QString &friendAddress, const QString &message) { - if(Settings::getInstance().addFriendRequest(friendAddress, message)) + if (Settings::getInstance().addFriendRequest(friendAddress, message)) { addFriendRequestWidget(friendAddress, message); - if(isShown()) - { + if (isShown()) onCurrentChanged(tabWidget->currentIndex()); - } + return true; } return false; @@ -197,13 +196,14 @@ void AddFriendForm::onIdChanged(const QString &id) QString toxIdText(tr("Tox ID", "Tox ID of the person you're sending a friend request to")); QString toxIdComment(tr("either 76 hexadecimal characters or name@example.com", "Tox ID format description")); - if(isValidId) + if (isValidId) { toxIdLabel.setText(toxIdText + QStringLiteral(" (") + toxIdComment + QStringLiteral(")")); - } else + } + else { toxIdLabel.setText(toxIdText + QStringLiteral(" (") + diff --git a/src/widget/form/chatform.cpp b/src/widget/form/chatform.cpp index 6ae3e4dd7..27b63ba45 100644 --- a/src/widget/form/chatform.cpp +++ b/src/widget/form/chatform.cpp @@ -119,7 +119,7 @@ ChatForm::ChatForm(Friend* chatFriend) connect(this, &ChatForm::chatAreaCleared, getOfflineMsgEngine(), &OfflineMsgEngine::removeAllReceipts); connect(statusMessageLabel, &CroppingLabel::customContextMenuRequested, this, [&](const QPoint& pos) { - if(!statusMessageLabel->text().isEmpty()) + if (!statusMessageLabel->text().isEmpty()) { QWidget* sender = static_cast(this->sender()); @@ -580,7 +580,7 @@ void ChatForm::onEnableCallButtons() void ChatForm::onMicMuteToggle() { - if (audioInputFlag == true) + if (audioInputFlag) { coreav->micMuteToggle(f->getFriendID()); if (micButton->objectName() == "red") @@ -600,7 +600,7 @@ void ChatForm::onMicMuteToggle() void ChatForm::onVolMuteToggle() { - if (audioOutputFlag == true) + if (audioOutputFlag) { coreav->volMuteToggle(f->getFriendID()); if (volButton->objectName() == "red") diff --git a/src/widget/form/chatform.h b/src/widget/form/chatform.h index 37569bc56..2ed951dc4 100644 --- a/src/widget/form/chatform.h +++ b/src/widget/form/chatform.h @@ -92,6 +92,12 @@ private slots: private: void retranslateUi(); void showOutgoingCall(bool video); + void startCounter(); + void stopCounter(); + QString secondsToDHMS(quint32 duration); + void enableCallButtons(); + void disableCallButtons(); + void SendMessageStr(QString msg); protected: virtual GenericNetCamView* createNetcam() final override; @@ -117,14 +123,8 @@ private: ScreenshotGrabber* screenshotGrabber; QHash ftransWidgets; - void startCounter(); - void stopCounter(); - QString secondsToDHMS(quint32 duration); CallConfirmWidget *callConfirm; - void enableCallButtons(); - void disableCallButtons(); bool isTyping; - void SendMessageStr(QString msg); }; #endif // CHATFORM_H diff --git a/src/widget/form/genericchatform.cpp b/src/widget/form/genericchatform.cpp index 17f23b7e7..e7fdc1539 100644 --- a/src/widget/form/genericchatform.cpp +++ b/src/widget/form/genericchatform.cpp @@ -243,7 +243,7 @@ void GenericChatForm::showFileMenu() void GenericChatForm::hideFileMenu() { - if(fileFlyout->isShown() || fileFlyout->isBeingShown()) + if (fileFlyout->isShown() || fileFlyout->isBeingShown()) fileFlyout->animateHide(); } @@ -470,17 +470,13 @@ QString GenericChatForm::resolveToxId(const ToxId &id) { Friend *f = FriendList::findFriend(id); if (f) - { return f->getDisplayedName(); - } - else + + for (Group *it : GroupList::getAllGroups()) { - for (auto it : GroupList::getAllGroups()) - { - QString res = it->resolveToxId(id); - if (res.size()) - return res; - } + QString res = it->resolveToxId(id); + if (res.size()) + return res; } return QString(); diff --git a/src/widget/form/groupchatform.cpp b/src/widget/form/groupchatform.cpp index b1f95c2f1..f12a4194e 100644 --- a/src/widget/form/groupchatform.cpp +++ b/src/widget/form/groupchatform.cpp @@ -220,7 +220,7 @@ void GroupChatForm::onUserListChanged() if (peersCount > 1 && group->isAvGroupchat()) { // don't set button to green if call running - if(!inCall) + if (!inCall) { callButton->setEnabled(true); callButton->setObjectName("green"); @@ -285,7 +285,7 @@ void GroupChatForm::dropEvent(QDropEvent *ev) void GroupChatForm::onMicMuteToggle() { - if (audioInputFlag == true) + if (audioInputFlag) { if (micButton->objectName() == "red") { @@ -306,7 +306,7 @@ void GroupChatForm::onMicMuteToggle() void GroupChatForm::onVolMuteToggle() { - if (audioOutputFlag == true) + if (audioOutputFlag) { if (volButton->objectName() == "red") { diff --git a/src/widget/form/groupinviteform.cpp b/src/widget/form/groupinviteform.cpp index 34778f904..0f2fce038 100644 --- a/src/widget/form/groupinviteform.cpp +++ b/src/widget/form/groupinviteform.cpp @@ -186,10 +186,9 @@ void GroupInviteForm::deleteInviteButtons(QWidget* widget) void GroupInviteForm::retranslateUi() { headLabel->setText(tr("Groups")); - if(createButton) - { + if (createButton) createButton->setText(tr("Create new group")); - } + inviteBox->setTitle(tr("Group invites")); for (QPushButton* acceptButton : acceptButtons) diff --git a/src/widget/form/profileform.cpp b/src/widget/form/profileform.cpp index 6db478a6d..8d9156c94 100644 --- a/src/widget/form/profileform.cpp +++ b/src/widget/form/profileform.cpp @@ -370,11 +370,11 @@ void ProfileForm::onDeleteClicked() QVector manualDeleteFiles = nexus.getProfile()->remove(); - if(!manualDeleteFiles.empty()) + if (!manualDeleteFiles.empty()) { QString message = tr("The following files could not be deleted:", "deletion failed text part 1") + "\n\n"; - for(auto& file : manualDeleteFiles) + for (auto& file : manualDeleteFiles) { message = message + file + "\n"; } diff --git a/src/widget/form/profileform.h b/src/widget/form/profileform.h index 762124bf7..b30d31236 100644 --- a/src/widget/form/profileform.h +++ b/src/widget/form/profileform.h @@ -45,7 +45,10 @@ signals: void clicked(); protected: - virtual void mouseReleaseEvent(QMouseEvent*) final override {emit clicked();} + virtual void mouseReleaseEvent(QMouseEvent*) final override + { + emit clicked(); + } }; class ProfileForm : public QWidget diff --git a/src/widget/form/settings/aboutform.h b/src/widget/form/settings/aboutform.h index 9c9f9db1a..ff32fdf9b 100644 --- a/src/widget/form/settings/aboutform.h +++ b/src/widget/form/settings/aboutform.h @@ -35,7 +35,10 @@ class AboutForm : public GenericForm public: AboutForm(); ~AboutForm(); - virtual QString getFormName() final override {return tr("About");} + virtual QString getFormName() final override + { + return tr("About"); + } protected: diff --git a/src/widget/form/settings/advancedform.h b/src/widget/form/settings/advancedform.h index 8eea447f0..3f3743370 100644 --- a/src/widget/form/settings/advancedform.h +++ b/src/widget/form/settings/advancedform.h @@ -34,7 +34,10 @@ class AdvancedForm : public GenericForm public: AdvancedForm(); ~AdvancedForm(); - virtual QString getFormName() final override {return tr("Advanced");} + virtual QString getFormName() final override + { + return tr("Advanced"); + } protected: bool eventFilter(QObject *o, QEvent *e) final override; diff --git a/src/widget/form/settings/avform.cpp b/src/widget/form/settings/avform.cpp index 9a3caa1d7..b99d4491a 100644 --- a/src/widget/form/settings/avform.cpp +++ b/src/widget/form/settings/avform.cpp @@ -212,10 +212,10 @@ void AVForm::selectBestModes(QVector &allVideoModes) qDebug("width: %d, height: %d, FPS: %f, pixel format: %s", mode.width, mode.height, mode.FPS, pixelFormat.toStdString().c_str()); // PS3-Cam protection, everything above 60fps makes no sense - if(mode.FPS > 60) + if (mode.FPS > 60) continue; - for(auto iter = idealModes.begin(); iter != idealModes.end(); ++iter) + for (auto iter = idealModes.begin(); iter != idealModes.end(); ++iter) { int res = iter->first; VideoMode idealMode = iter->second; diff --git a/src/widget/form/settings/generalform.h b/src/widget/form/settings/generalform.h index 6fad7acab..9e29ba21a 100644 --- a/src/widget/form/settings/generalform.h +++ b/src/widget/form/settings/generalform.h @@ -34,7 +34,10 @@ class GeneralForm : public GenericForm public: explicit GeneralForm(SettingsWidget *parent); ~GeneralForm(); - virtual QString getFormName() final override {return tr("General");} + virtual QString getFormName() final override + { + return tr("General"); + } private slots: void onEnableIPv6Updated(); diff --git a/src/widget/form/settings/genericsettings.h b/src/widget/form/settings/genericsettings.h index e2833f96b..4d56d2124 100644 --- a/src/widget/form/settings/genericsettings.h +++ b/src/widget/form/settings/genericsettings.h @@ -28,7 +28,10 @@ public: virtual ~GenericForm() {} virtual QString getFormName() = 0; - QPixmap getFormIcon() {return formIcon;} + QPixmap getFormIcon() + { + return formIcon; + } protected: QPixmap formIcon; diff --git a/src/widget/form/settings/privacyform.h b/src/widget/form/settings/privacyform.h index ef344ce00..eef87b534 100644 --- a/src/widget/form/settings/privacyform.h +++ b/src/widget/form/settings/privacyform.h @@ -32,7 +32,10 @@ class PrivacyForm : public GenericForm public: PrivacyForm(); ~PrivacyForm(); - virtual QString getFormName() final override {return tr("Privacy");} + virtual QString getFormName() final override + { + return tr("Privacy"); + } private slots: void onEnableLoggingUpdated(); diff --git a/src/widget/genericchatroomwidget.cpp b/src/widget/genericchatroomwidget.cpp index 8a2b037f1..1d668480e 100644 --- a/src/widget/genericchatroomwidget.cpp +++ b/src/widget/genericchatroomwidget.cpp @@ -183,14 +183,10 @@ void GenericChatroomWidget::reloadTheme() void GenericChatroomWidget::mouseReleaseEvent(QMouseEvent* event) { - if(event->button() == Qt::LeftButton) - { + if (event->button() == Qt::LeftButton) emit chatroomWidgetClicked(this); - } else - { event->ignore(); - } } void GenericChatroomWidget::enterEvent(QEvent*) diff --git a/src/widget/loginscreen.cpp b/src/widget/loginscreen.cpp index 99b39dd88..65d97e54b 100644 --- a/src/widget/loginscreen.cpp +++ b/src/widget/loginscreen.cpp @@ -40,7 +40,7 @@ LoginScreen::LoginScreen(QWidget *parent) : ui->setupUi(this); // permanently disables maximize button https://github.com/tux3/qTox/issues/1973 - this->setWindowFlags(windowFlags() &! Qt::WindowMaximizeButtonHint); + this->setWindowFlags(windowFlags() & ~Qt::WindowMaximizeButtonHint); this->setFixedSize(this->size()); connect(&quitShortcut, &QShortcut::activated, this, &LoginScreen::close); @@ -271,9 +271,9 @@ void LoginScreen::retranslateUi() void LoginScreen::onImportProfile() { ProfileImporter *pi = new ProfileImporter(this); - if(pi->importProfile() == true) - { + + if (pi->importProfile()) reset(); - } + delete pi; } diff --git a/src/widget/tool/screengrabberchooserrectitem.cpp b/src/widget/tool/screengrabberchooserrectitem.cpp index c0d933e12..a6deb8acd 100644 --- a/src/widget/tool/screengrabberchooserrectitem.cpp +++ b/src/widget/tool/screengrabberchooserrectitem.cpp @@ -203,9 +203,8 @@ void ScreenGrabberChooserRectItem::mousePressHandle(int x, int y, QGraphicsScene Q_UNUSED(x); Q_UNUSED(y); - if(event->button() == Qt::LeftButton) + if (event->button() == Qt::LeftButton) this->state = HandleResizing; - } void ScreenGrabberChooserRectItem::mouseMoveHandle(int x, int y, QGraphicsSceneMouseEvent* event) @@ -221,13 +220,13 @@ void ScreenGrabberChooserRectItem::mouseMoveHandle(int x, int y, QGraphicsSceneM bool increaseX = ((x < 0) == (delta.x() < 0)); bool increaseY = ((y < 0) == (delta.y() < 0)); - if((delta.x() < 0 && increaseX) || (delta.x() >= 0 && !increaseX)) + if ((delta.x() < 0 && increaseX) || (delta.x() >= 0 && !increaseX)) { moveBy(delta.x(), 0); delta.rx() *= -1; } - if((delta.y() < 0 && increaseY) || (delta.y() >= 0 && !increaseY)) + if ((delta.y() < 0 && increaseY) || (delta.y() >= 0 && !increaseY)) { moveBy(0, delta.y()); delta.ry() *= -1; diff --git a/src/widget/widget.cpp b/src/widget/widget.cpp index 278ec20f9..78864a569 100644 --- a/src/widget/widget.cpp +++ b/src/widget/widget.cpp @@ -563,7 +563,7 @@ void Widget::moveEvent(QMoveEvent *event) void Widget::closeEvent(QCloseEvent *event) { - if (Settings::getInstance().getShowSystemTray() && Settings::getInstance().getCloseToTray() == true) + if (Settings::getInstance().getShowSystemTray() && Settings::getInstance().getCloseToTray()) { event->ignore(); this->hide(); @@ -1020,7 +1020,7 @@ void Widget::onFriendStatusChanged(int friendId, Status status) f->setStatus(status); f->getFriendWidget()->updateStatusLight(); - if(f->getFriendWidget()->isActive()) + if (f->getFriendWidget()->isActive()) setWindowTitle(f->getFriendWidget()->getTitle()); ContentDialog::updateFriendStatus(friendId); @@ -1342,7 +1342,7 @@ bool Widget::newMessageAlert(QWidget* currentWindow, bool isActive, bool sound, void Widget::onFriendRequestReceived(const QString& userId, const QString& message) { - if(addFriendForm->addFriendRequest(userId, message)) + if (addFriendForm->addFriendRequest(userId, message)) { friendRequestsUpdate(); newMessageAlert(window(), isActiveWindow(), true, true); @@ -1981,7 +1981,7 @@ void Widget::clearAllReceipts() void Widget::reloadTheme() { QString statusPanelStyle = Style::getStylesheet(":/ui/window/statusPanel.css"); - ui->tooliconsZone->setStyleSheet(Style::resolve("QPushButton{background-color:@themeDark;border:none;}QPushButton:hover{background-color:@themeMediumDark;border:none;}QPushButton:checked{background-color:@themeMedium;border:none;}QPushButton:pressed{background-color:@themeMediumLight;border:none;}")); + ui->tooliconsZone->setStyleSheet(Style::getStylesheet(":/ui/tooliconsZone/tooliconsZone.css")); ui->statusPanel->setStyleSheet(statusPanelStyle); ui->statusHead->setStyleSheet(statusPanelStyle); ui->friendList->setStyleSheet(Style::getStylesheet(":/ui/friendList/friendList.css")); diff --git a/ui/contentDialog/contentDialog.css b/ui/contentDialog/contentDialog.css new file mode 100644 index 000000000..ebfe7c1da --- /dev/null +++ b/ui/contentDialog/contentDialog.css @@ -0,0 +1,16 @@ +QSplitter +{ + color: white; + background-color: white; + alternate-background-color: white; + border-color: white; + gridline-color: white; + selection-color: white; + selection-background-color: white; +} + +QSplitter:handle +{ + color: white; + background-color: white; +} diff --git a/ui/tooliconsZone/tooliconsZone.css b/ui/tooliconsZone/tooliconsZone.css new file mode 100644 index 000000000..5e549c2ab --- /dev/null +++ b/ui/tooliconsZone/tooliconsZone.css @@ -0,0 +1,23 @@ +QPushButton +{ + background-color: @themeDark; + border: none; +} + +QPushButton:hover +{ + background-color: @themeMediumDark; + border: none; +} + +QPushButton:checked +{ + background-color: @themeMedium; + border: none; +} + +QPushButton:pressed +{ + background-color: @themeMediumLight; + border: none; +} From 2258748d2879f2b5ce7d7b82c54b4e8b75279c6b Mon Sep 17 00:00:00 2001 From: Diadlo Date: Thu, 7 Jul 2016 12:58:28 +0300 Subject: [PATCH 2/5] style(audio, video): Style fixes --- src/audio/audio.cpp | 9 --------- src/audio/audio.h | 5 ++++- src/video/cameradevice.cpp | 8 +++++--- src/video/camerasource.cpp | 11 ++++++----- 4 files changed, 15 insertions(+), 18 deletions(-) diff --git a/src/audio/audio.cpp b/src/audio/audio.cpp index 9757fa647..1e684c960 100644 --- a/src/audio/audio.cpp +++ b/src/audio/audio.cpp @@ -582,15 +582,6 @@ void Audio::doCapture() emit frameAvailable(buf, AUDIO_FRAME_SAMPLE_COUNT, AUDIO_CHANNELS, AUDIO_SAMPLE_RATE); } -/** -Returns true if the input device is open and suscribed to -*/ -bool Audio::isInputReady() const -{ - QMutexLocker locker(&audioLock); - return alInDev && inSubscriptions; -} - /** Returns true if the output device is open */ diff --git a/src/audio/audio.h b/src/audio/audio.h index 7693f839b..317ad7998 100644 --- a/src/audio/audio.h +++ b/src/audio/audio.h @@ -63,21 +63,24 @@ public: qreal minInputGain() const; void setMinInputGain(qreal dB); + qreal maxInputGain() const; void setMaxInputGain(qreal dB); + qreal inputGain() const; void setInputGain(qreal dB); void reinitInput(const QString& inDevDesc); bool reinitOutput(const QString& outDevDesc); - bool isInputReady() const; bool isOutputReady() const; static QStringList outDeviceNames(); static QStringList inDeviceNames(); + void subscribeOutput(ALuint& sid); void unsubscribeOutput(ALuint& sid); + void subscribeInput(); void unsubscribeInput(); diff --git a/src/video/cameradevice.cpp b/src/video/cameradevice.cpp index 6a9c2c92c..e0b8e676f 100644 --- a/src/video/cameradevice.cpp +++ b/src/video/cameradevice.cpp @@ -194,13 +194,14 @@ CameraDevice* CameraDevice::open(QString devName, VideoMode mode) #endif else if (mode) { - qWarning() << "Video mode-setting not implemented for input "<name; - (void)mode; + qWarning() << "Video mode-setting not implemented for input " << iformat->name; + Q_UNUSED(mode); } CameraDevice* dev = open(devName, &options); if (options) av_dict_free(&options); + return dev; } @@ -367,6 +368,8 @@ QVector CameraDevice::getScreenModes() QVector CameraDevice::getVideoModes(QString devName) { + Q_UNUSED(devName); + if (!iformat); else if (isScreen(devName)) return getScreenModes(); @@ -385,7 +388,6 @@ QVector CameraDevice::getVideoModes(QString devName) else qWarning() << "Video mode listing not implemented for input "<name; - (void)devName; return {}; } diff --git a/src/video/camerasource.cpp b/src/video/camerasource.cpp index 1bcbcc296..99dcc7c95 100644 --- a/src/video/camerasource.cpp +++ b/src/video/camerasource.cpp @@ -137,8 +137,9 @@ CameraSource::~CameraSource() if (device) { - for(int i = 0; i < subscriptions; i++) + for (int i = 0; i < subscriptions; i++) device->close(); + device = nullptr; } @@ -241,7 +242,7 @@ bool CameraSource::openDevice() // Find the first video stream for (unsigned i = 0; i < device->context->nb_streams; i++) { - if(device->context->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO) + if (device->context->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO) { videoStreamIndex = i; break; @@ -257,7 +258,7 @@ bool CameraSource::openDevice() // Get a pointer to the codec context for the video stream cctxOrig = device->context->streams[videoStreamIndex]->codec; codec = avcodec_find_decoder(cctxOrig->codec_id); - if(!codec) + if (!codec) { qWarning() << "Codec not found"; return false; @@ -265,7 +266,7 @@ bool CameraSource::openDevice() // Copy context, since we apparently aren't allowed to use the original cctx = avcodec_alloc_context3(codec); - if(avcodec_copy_context(cctx, cctxOrig) != 0) + if (avcodec_copy_context(cctx, cctxOrig) != 0) { qWarning() << "Can't copy context"; return false; @@ -274,7 +275,7 @@ bool CameraSource::openDevice() cctx->refcounted_frames = 1; // Open codec - if(avcodec_open2(cctx, codec, nullptr)<0) + if (avcodec_open2(cctx, codec, nullptr)<0) { qWarning() << "Can't open codec"; avcodec_free_context(&cctx); From 20d3225f29b1a137ca6bc1cecbe5790d02977d60 Mon Sep 17 00:00:00 2001 From: Diadlo Date: Thu, 7 Jul 2016 13:08:32 +0300 Subject: [PATCH 3/5] style(chatlog, persistence): Style fixes --- src/chatlog/chatlog.cpp | 15 ++++++++++++--- src/persistence/profile.cpp | 12 ++++++------ src/persistence/settingsserializer.cpp | 9 +++------ 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/chatlog/chatlog.cpp b/src/chatlog/chatlog.cpp index b2e9a85e2..ef5109789 100644 --- a/src/chatlog/chatlog.cpp +++ b/src/chatlog/chatlog.cpp @@ -69,20 +69,29 @@ ChatLog::ChatLog(QWidget* parent) copyAction->setIcon(QIcon::fromTheme("edit-copy")); copyAction->setShortcut(QKeySequence::Copy); copyAction->setEnabled(false); - connect(copyAction, &QAction::triggered, this, [this]() { copySelectedText(); }); + connect(copyAction, &QAction::triggered, this, [this]() + { + copySelectedText(); + }); addAction(copyAction); #ifdef Q_OS_LINUX // Ctrl+Insert shortcut QShortcut* copyCtrlInsShortcut = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Insert), this); - connect(copyCtrlInsShortcut, &QShortcut::activated, this, [this]() { copySelectedText(); }); + connect(copyCtrlInsShortcut, &QShortcut::activated, this, [this]() + { + copySelectedText(); + }); #endif // select all action (ie. Ctrl+A) selectAllAction = new QAction(this); selectAllAction->setIcon(QIcon::fromTheme("edit-select-all")); selectAllAction->setShortcut(QKeySequence::SelectAll); - connect(selectAllAction, &QAction::triggered, this, [this]() { selectAll(); }); + connect(selectAllAction, &QAction::triggered, this, [this]() + { + selectAll(); + }); addAction(selectAllAction); // This timer is used to scroll the view while the user is diff --git a/src/persistence/profile.cpp b/src/persistence/profile.cpp index c8f32d53b..daf09b7e3 100644 --- a/src/persistence/profile.cpp +++ b/src/persistence/profile.cpp @@ -328,7 +328,7 @@ void Profile::saveToxSave(QByteArray data) saveFile.write(data); // check if everything got written - if(saveFile.flush()) + if (saveFile.flush()) { saveFile.commit(); newProfile = false; @@ -511,23 +511,23 @@ QVector Profile::remove() QVector ret; - if(!profileMain.remove() && profileMain.exists()) + if (!profileMain.remove() && profileMain.exists()) { ret.push_back(profileMain.fileName()); qWarning() << "Could not remove file " << profileMain.fileName(); } - if(!profileConfig.remove() && profileConfig.exists()) + if (!profileConfig.remove() && profileConfig.exists()) { ret.push_back(profileConfig.fileName()); qWarning() << "Could not remove file " << profileConfig.fileName(); } - if(!historyLegacyUnencrypted.remove() && historyLegacyUnencrypted.exists()) + if (!historyLegacyUnencrypted.remove() && historyLegacyUnencrypted.exists()) { ret.push_back(historyLegacyUnencrypted.fileName()); qWarning() << "Could not remove file " << historyLegacyUnencrypted.fileName(); } - if(!historyLegacyEncrypted.remove() && historyLegacyEncrypted.exists()) + if (!historyLegacyEncrypted.remove() && historyLegacyEncrypted.exists()) { ret.push_back(historyLegacyEncrypted.fileName()); qWarning() << "Could not remove file " << historyLegacyUnencrypted.fileName(); @@ -535,7 +535,7 @@ QVector Profile::remove() if (history) { - if(!history->remove() && QFile::exists(History::getDbPath(name))) + if (!history->remove() && QFile::exists(History::getDbPath(name))) { ret.push_back(History::getDbPath(name)); qWarning() << "Could not remove file " << History::getDbPath(name); diff --git a/src/persistence/settingsserializer.cpp b/src/persistence/settingsserializer.cpp index df8ac02d2..28aa1ccd5 100644 --- a/src/persistence/settingsserializer.cpp +++ b/src/persistence/settingsserializer.cpp @@ -283,7 +283,7 @@ void SettingsSerializer::save() f.write(data); // check if everything got written - if(f.flush()) + if (f.flush()) { f.commit(); } @@ -412,10 +412,10 @@ void SettingsSerializer::readIni() // Add all keys if (!s.group().isEmpty()) beginGroup(s.group()); + for (QString k : s.childKeys()) { setValue(k, s.value(k)); - //qDebug() << "Read key "< a.size) a.size = groupArrayIndex; @@ -530,7 +528,6 @@ void SettingsSerializer::readIni() v.array = ai; v.arrayIndex = groupArrayIndex; a.values.append(vi); - //qDebug() << "Found key"< Date: Thu, 7 Jul 2016 13:10:41 +0300 Subject: [PATCH 4/5] style(platform): Style fixes --- src/platform/autorun_osx.cpp | 12 ++---------- src/platform/camera/v4l2.cpp | 9 ++++++--- src/platform/install_osx.cpp | 33 ++++++++++++++++----------------- 3 files changed, 24 insertions(+), 30 deletions(-) diff --git a/src/platform/autorun_osx.cpp b/src/platform/autorun_osx.cpp index 62344d6ad..6a5571446 100644 --- a/src/platform/autorun_osx.cpp +++ b/src/platform/autorun_osx.cpp @@ -36,16 +36,8 @@ bool Platform::setAutorun(bool on) autoRun.setValue("Label","chat.tox.qtox.autorun"); autoRun.setValue("Program", qtoxDir); - if (on) - { - autoRun.setValue("RunAtLoad",true); - state = true; - } - else - { - autoRun.setValue("RunAtLoad",false); - state = false; - } + state = on; + autoRun.setValue("RunAtLoad", state); } bool Platform::getAutorun() diff --git a/src/platform/camera/v4l2.cpp b/src/platform/camera/v4l2.cpp index 26c9a6d6b..e851d3c68 100644 --- a/src/platform/camera/v4l2.cpp +++ b/src/platform/camera/v4l2.cpp @@ -97,7 +97,7 @@ static QVector getDeviceModeFramerates(int fd, unsigned w, unsig vfve.height = h; vfve.width = w; - while(!ioctl(fd, VIDIOC_ENUM_FRAMEINTERVALS, &vfve)) { + while (!ioctl(fd, VIDIOC_ENUM_FRAMEINTERVALS, &vfve)) { int rate; switch (vfve.type) { case V4L2_FRMSIZE_TYPE_DISCRETE: @@ -128,13 +128,15 @@ QVector v4l2::getDeviceModes(QString devName) v4l2_fmtdesc vfd{}; vfd.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - while(!ioctl(fd, VIDIOC_ENUM_FMT, &vfd)) { + while (!ioctl(fd, VIDIOC_ENUM_FMT, &vfd)) + { vfd.index++; v4l2_frmsizeenum vfse{}; vfse.pixel_format = vfd.pixelformat; - while(!ioctl(fd, VIDIOC_ENUM_FRAMESIZES, &vfse)) { + while (!ioctl(fd, VIDIOC_ENUM_FRAMESIZES, &vfse)) + { VideoMode mode; mode.pixel_format = vfse.pixel_format; switch (vfse.type) { @@ -150,6 +152,7 @@ QVector v4l2::getDeviceModes(QString devName) default: continue; } + QVector rates = getDeviceModeFramerates(fd, mode.width, mode.height, vfd.pixelformat); for (unsigned short rate : rates) { diff --git a/src/platform/install_osx.cpp b/src/platform/install_osx.cpp index a5a832bdd..d1c4dc158 100644 --- a/src/platform/install_osx.cpp +++ b/src/platform/install_osx.cpp @@ -95,25 +95,24 @@ void osx::migrateProfiles() + "Library" + QDir::separator() + "Application Support" + QDir::separator() + "Tox"); QDir dir; - if (checkDir.exists() && checkDir.isDir()) - { - qDebug() << "OS X: Old settings directory detected migrating to default"; - if( !dir.rename(oldPath, newPath) ) - { - qDebug() << "OS X: Profile migration failed. ~/Library/Application Support/Tox already exists. Using alternate migration method."; - QString OSXMigrater = "../Resources/OSX-Migrater.sh" ; - QProcess::execute(OSXMigrater); - QMessageBox MigrateProfile; - MigrateProfile.setIcon(QMessageBox::Information); - MigrateProfile.setWindowModality(Qt::ApplicationModal); - MigrateProfile.setText("Alternate profile migration method used."); - MigrateProfile.setInformativeText("It has been detected that your profiles \nwhere migrated to the new settings directory; \nusing the alternate migration method. \n\nA backup can be found in your: \n/Users/[USER]/.Tox-Backup[DATE-TIME] \n\nJust in case. \r\n"); - MigrateProfile.exec(); - } - } - else + if (!checkDir.exists() || !checkDir.isDir()) { qDebug() << "OS X: Old settings directory not detected"; + return; + } + + qDebug() << "OS X: Old settings directory detected migrating to default"; + if (!dir.rename(oldPath, newPath)) + { + qDebug() << "OS X: Profile migration failed. ~/Library/Application Support/Tox already exists. Using alternate migration method."; + QString OSXMigrater = "../Resources/OSX-Migrater.sh" ; + QProcess::execute(OSXMigrater); + QMessageBox MigrateProfile; + MigrateProfile.setIcon(QMessageBox::Information); + MigrateProfile.setWindowModality(Qt::ApplicationModal); + MigrateProfile.setText("Alternate profile migration method used."); + MigrateProfile.setInformativeText("It has been detected that your profiles \nwhere migrated to the new settings directory; \nusing the alternate migration method. \n\nA backup can be found in your: \n/Users/[USER]/.Tox-Backup[DATE-TIME] \n\nJust in case. \r\n"); + MigrateProfile.exec(); } } // End migrateProfiles() compatibility code From f8eda7eb5741a0cf5a39d3402e19d2c0a406e5d2 Mon Sep 17 00:00:00 2001 From: Diadlo Date: Thu, 7 Jul 2016 13:10:53 +0300 Subject: [PATCH 5/5] style(core): Style fixes --- src/core/core.cpp | 45 +++++++++++++++++++--------------------- src/core/core.h | 2 +- src/core/coreav.cpp | 5 +++-- src/core/corefile.cpp | 14 ++++--------- src/core/corefile.h | 2 +- src/core/corestructs.cpp | 6 +++--- src/core/corestructs.h | 2 +- src/friend.cpp | 8 +++---- src/nexus.cpp | 14 ++++++------- 9 files changed, 45 insertions(+), 53 deletions(-) diff --git a/src/core/core.cpp b/src/core/core.cpp index 180b5f941..bc625480f 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -618,7 +618,7 @@ int Core::sendAction(uint32_t friendId, const QString &action) void Core::sendTyping(uint32_t friendId, bool typing) { bool ret = tox_self_set_typing(tox, friendId, typing, nullptr); - if (ret == false) + if (!ret) emit failedToSetTyping(typing); } @@ -656,9 +656,9 @@ void Core::changeGroupTitle(int groupId, const QString& title) emit groupTitleChanged(groupId, getUsername(), title); } -void Core::sendFile(uint32_t friendId, QString Filename, QString FilePath, long long filesize) +void Core::sendFile(uint32_t friendId, QString filename, QString filePath, long long filesize) { - CoreFile::sendFile(this, friendId, Filename, FilePath, filesize); + CoreFile::sendFile(this, friendId, filename, filePath, filesize); } void Core::sendAvatarFile(uint32_t friendId, const QByteArray& data) @@ -701,15 +701,14 @@ void Core::removeFriend(uint32_t friendId, bool fake) if (!isReady() || fake) return; - if (tox_friend_delete(tox, friendId, nullptr) == false) + if (!tox_friend_delete(tox, friendId, nullptr)) { emit failedToRemoveFriend(friendId); + return; } - else - { - profile.saveToxSave(); - emit friendRemoved(friendId); - } + + profile.saveToxSave(); + emit friendRemoved(friendId); } void Core::removeGroup(int groupId, bool fake) @@ -741,16 +740,15 @@ void Core::setUsername(const QString& username) CString cUsername(username); - if (tox_self_set_name(tox, cUsername.data(), cUsername.size(), nullptr) == false) + if (!tox_self_set_name(tox, cUsername.data(), cUsername.size(), nullptr)) { emit failedToSetUsername(username); + return; } - else - { - emit usernameSet(username); - if (ready) - profile.saveToxSave(); - } + + emit usernameSet(username); + if (ready) + profile.saveToxSave(); } void Core::setAvatar(const QByteArray& data) @@ -817,16 +815,15 @@ void Core::setStatusMessage(const QString& message) CString cMessage(message); - if (tox_self_set_status_message(tox, cMessage.data(), cMessage.size(), nullptr) == false) + if (!tox_self_set_status_message(tox, cMessage.data(), cMessage.size(), nullptr)) { emit failedToSetStatusMessage(message); + return; } - else - { - if (ready) - profile.saveToxSave(); - emit statusMessageSet(message); - } + + if (ready) + profile.saveToxSave(); + emit statusMessageSet(message); } void Core::setStatus(Status status) @@ -1188,7 +1185,7 @@ QString Core::getPeerName(const ToxId& id) const return name; uint8_t* cname = new uint8_t[nameSizecalls.contains(friendNum)) + if (!self->calls.contains(friendNum)) { qWarning() << QString("stateCallback called, but call %1 is already dead").arg(friendNum); self->threadSwitchLock.clear(std::memory_order_release); return; } + ToxFriendCall& call = self->calls[friendNum]; if (state & TOXAV_FRIEND_CALL_STATE_ERROR) diff --git a/src/core/corefile.cpp b/src/core/corefile.cpp index e885fca3f..6d0d27c2e 100644 --- a/src/core/corefile.cpp +++ b/src/core/corefile.cpp @@ -77,7 +77,6 @@ void CoreFile::sendAvatarFile(Core* core, uint32_t friendId, const QByteArray& d qWarning() << "sendAvatarFile: Can't create the Tox file sender, error"<tox, friendId, TOX_FILE_KIND_DATA, filesize, nullptr, (uint8_t*)fileName.data(), fileName.size(), nullptr); if (fileNum == std::numeric_limits::max()) { qWarning() << "sendFile: Can't create the Tox file sender"; - emit core->fileSendFailed(friendId, Filename); + emit core->fileSendFailed(friendId, filename); return; } qDebug() << QString("sendFile: Created file sender %1 with friend %2").arg(fileNum).arg(friendId); - ToxFile file{fileNum, friendId, fileName, FilePath, ToxFile::SENDING}; + ToxFile file{fileNum, friendId, fileName, filePath, ToxFile::SENDING}; file.filesize = filesize; file.resumeFileId.resize(TOX_FILE_ID_LENGTH); tox_file_get_file_id(core->tox, friendId, fileNum, (uint8_t*)file.resumeFileId.data(), nullptr); @@ -350,7 +349,6 @@ void CoreFile::onFileControlCallback(Tox*, uint32_t friendId, uint32_t fileId, void CoreFile::onFileDataCallback(Tox *tox, uint32_t friendId, uint32_t fileId, uint64_t pos, size_t length, void* core) { - //qDebug() << "File data req of "<fileKind != TOX_FILE_KIND_AVATAR) { emit static_cast(core)->fileTransferFinished(*file); @@ -408,9 +405,6 @@ void CoreFile::onFileDataCallback(Tox *tox, uint32_t friendId, uint32_t fileId, void CoreFile::onFileRecvChunkCallback(Tox *tox, uint32_t friendId, uint32_t fileId, uint64_t position, const uint8_t *data, size_t length, void *_core) { - //qDebug() << QString("Received chunk for %1:%2 pos %3 size %4") - // .arg(friendId).arg(fileId).arg(position).arg(length); - Core* core = static_cast(_core); ToxFile* file = findFile(friendId, fileId); if (!file) diff --git a/src/core/corefile.h b/src/core/corefile.h index 5a4b3e241..14fa6465c 100644 --- a/src/core/corefile.h +++ b/src/core/corefile.h @@ -46,7 +46,7 @@ private: // Internal file sending APIs, used by Core. Public API in core.h private: - static void sendFile(Core *core, uint32_t friendId, QString Filename, QString FilePath, long long filesize); + static void sendFile(Core *core, uint32_t friendId, QString filename, QString filePath, long long filesize); static void sendAvatarFile(Core* core, uint32_t friendId, const QByteArray& data); static void pauseResumeFileSend(Core* core, uint32_t friendId, uint32_t fileId); static void pauseResumeFileRecv(Core* core, uint32_t friendId, uint32_t fileId); diff --git a/src/core/corestructs.cpp b/src/core/corestructs.cpp index abc5dc695..5014c00d7 100644 --- a/src/core/corestructs.cpp +++ b/src/core/corestructs.cpp @@ -6,9 +6,9 @@ #define TOX_HEX_ID_LENGTH 2*TOX_ADDRESS_SIZE -ToxFile::ToxFile(uint32_t FileNum, uint32_t FriendId, QByteArray FileName, QString FilePath, FileDirection Direction) - : fileKind{TOX_FILE_KIND_DATA}, fileNum(FileNum), friendId(FriendId), fileName{FileName}, - filePath{FilePath}, file{new QFile(filePath)}, bytesSent{0}, filesize{0}, +ToxFile::ToxFile(uint32_t fileNum, uint32_t friendId, QByteArray filename, QString filePath, FileDirection Direction) + : fileKind{TOX_FILE_KIND_DATA}, fileNum(fileNum), friendId(friendId), fileName{filename}, + filePath{filePath}, file{new QFile(filePath)}, bytesSent{0}, filesize{0}, status{STOPPED}, direction{Direction} { } diff --git a/src/core/corestructs.h b/src/core/corestructs.h index 2f8cba0ca..4b36ececf 100644 --- a/src/core/corestructs.h +++ b/src/core/corestructs.h @@ -36,7 +36,7 @@ struct ToxFile }; ToxFile()=default; - ToxFile(uint32_t FileNum, uint32_t FriendId, QByteArray FileName, QString FilePath, FileDirection Direction); + ToxFile(uint32_t FileNum, uint32_t FriendId, QByteArray FileName, QString filePath, FileDirection Direction); ~ToxFile(){} bool operator==(const ToxFile& other) const; diff --git a/src/friend.cpp b/src/friend.cpp index 25428b272..fe7f530d2 100644 --- a/src/friend.cpp +++ b/src/friend.cpp @@ -31,11 +31,11 @@ #include "src/group.h" Friend::Friend(uint32_t FriendId, const ToxId &UserId) - : userName{Core::getInstance()->getPeerName(UserId)}, - userID{UserId}, friendId{FriendId} + : userName{Core::getInstance()->getPeerName(UserId)} + , userID(UserId), friendId(FriendId) + , hasNewEvents(0), friendStatus(Status::Offline) + { - hasNewEvents = 0; - friendStatus = Status::Offline; if (userName.size() == 0) userName = UserId.publicKey; diff --git a/src/nexus.cpp b/src/nexus.cpp index 977d6bda8..95a865f01 100644 --- a/src/nexus.cpp +++ b/src/nexus.cpp @@ -189,14 +189,13 @@ void Nexus::showMainGUI() connect(core, &Core::groupNamelistChanged, widget, &Widget::onGroupNamelistChanged); connect(core, &Core::groupTitleChanged, widget, &Widget::onGroupTitleChanged); connect(core, &Core::groupPeerAudioPlaying, widget, &Widget::onGroupPeerAudioPlaying); - connect(core, &Core::emptyGroupCreated, widget, &Widget::onEmptyGroupCreated); - connect(core, &Core::friendTypingChanged, widget, &Widget::onFriendTypingChanged); + connect(core, &Core::emptyGroupCreated, widget, &Widget::onEmptyGroupCreated); + connect(core, &Core::friendTypingChanged, widget, &Widget::onFriendTypingChanged); + connect(core, &Core::messageSentResult, widget, &Widget::onMessageSendResult); + connect(core, &Core::groupSentResult, widget, &Widget::onGroupSendResult); - connect(core, &Core::messageSentResult, widget, &Widget::onMessageSendResult); - connect(core, &Core::groupSentResult, widget, &Widget::onGroupSendResult); - - connect(widget, &Widget::statusSet, core, &Core::setStatus); - connect(widget, &Widget::friendRequested, core, &Core::requestFriendship); + connect(widget, &Widget::statusSet, core, &Core::setStatus); + connect(widget, &Widget::friendRequested, core, &Core::requestFriendship); connect(widget, &Widget::friendRequestAccepted, core, &Core::acceptFriendRequest); profile->startCore(); @@ -221,6 +220,7 @@ Core* Nexus::getCore() Nexus& nexus = getInstance(); if (!nexus.profile) return nullptr; + return nexus.profile->getCore(); }