From 52a5951d265f0d9b49db5b42aaefced375246ded Mon Sep 17 00:00:00 2001 From: iphydf Date: Fri, 7 Sep 2018 09:56:52 +0000 Subject: [PATCH] chore: Use `nullptr` instead of `0` for NULL pointer constants. --- src/audio/backend/openal.cpp | 8 +++---- src/audio/backend/openal2.cpp | 2 +- src/chatlog/chatlog.h | 2 +- src/chatlog/chatmessage.cpp | 2 +- src/chatlog/content/filetransferwidget.cpp | 4 ++-- src/ipc.cpp | 22 +++++++++---------- src/main.cpp | 2 +- src/nexus.h | 2 +- src/persistence/db/rawdatabase.cpp | 4 ++-- src/platform/posixsignalnotifier.cpp | 2 +- src/video/cameradevice.cpp | 4 ++-- src/video/groupnetcamview.cpp | 4 ++-- src/video/groupnetcamview.h | 2 +- src/video/netcamview.h | 2 +- src/video/videosurface.h | 4 ++-- src/widget/about/aboutfriendform.h | 2 +- src/widget/categorywidget.h | 2 +- src/widget/contentlayout.cpp | 4 ++-- src/widget/emoticonswidget.h | 2 +- src/widget/flowlayout.cpp | 6 ++--- src/widget/form/chatform.cpp | 4 ++-- src/widget/form/loadhistorydialog.h | 4 ++-- src/widget/form/setpassworddialog.h | 2 +- src/widget/form/settings/avform.cpp | 2 +- src/widget/form/settings/privacyform.cpp | 2 +- .../form/settings/verticalonlyscroller.h | 2 +- src/widget/genericchatitemlayout.h | 2 +- src/widget/genericchatroomwidget.h | 2 +- src/widget/gui.h | 6 ++--- src/widget/notificationedgewidget.h | 2 +- src/widget/notificationscrollarea.h | 2 +- src/widget/qrwidget.cpp | 5 ++--- src/widget/qrwidget.h | 2 +- src/widget/systemtrayicon.cpp | 6 ++--- src/widget/tool/activatedialog.h | 2 +- src/widget/tool/adjustingscrollarea.h | 2 +- src/widget/tool/chattextedit.h | 2 +- src/widget/tool/croppinglabel.cpp | 2 +- src/widget/tool/croppinglabel.h | 2 +- src/widget/tool/flyoutoverlaywidget.h | 2 +- src/widget/tool/profileimporter.h | 2 +- src/widget/tool/screenshotgrabber.cpp | 2 +- src/widget/widget.cpp | 4 ++-- src/widget/widget.h | 2 +- test/net/toxmedata_test.cpp | 18 +++++++-------- updater/settings.cpp | 8 +++---- 46 files changed, 86 insertions(+), 87 deletions(-) diff --git a/src/audio/backend/openal.cpp b/src/audio/backend/openal.cpp index b6a46703c..56c86fd1e 100644 --- a/src/audio/backend/openal.cpp +++ b/src/audio/backend/openal.cpp @@ -633,9 +633,9 @@ bool OpenAL::isOutputReady() const QStringList OpenAL::outDeviceNames() { QStringList list; - const ALchar* pDeviceList = (alcIsExtensionPresent(NULL, "ALC_ENUMERATE_ALL_EXT") != AL_FALSE) - ? alcGetString(NULL, ALC_ALL_DEVICES_SPECIFIER) - : alcGetString(NULL, ALC_DEVICE_SPECIFIER); + const ALchar* pDeviceList = (alcIsExtensionPresent(nullptr, "ALC_ENUMERATE_ALL_EXT") != AL_FALSE) + ? alcGetString(nullptr, ALC_ALL_DEVICES_SPECIFIER) + : alcGetString(nullptr, ALC_DEVICE_SPECIFIER); if (pDeviceList) { while (*pDeviceList) { @@ -651,7 +651,7 @@ QStringList OpenAL::outDeviceNames() QStringList OpenAL::inDeviceNames() { QStringList list; - const ALchar* pDeviceList = alcGetString(NULL, ALC_CAPTURE_DEVICE_SPECIFIER); + const ALchar* pDeviceList = alcGetString(nullptr, ALC_CAPTURE_DEVICE_SPECIFIER); if (pDeviceList) { while (*pDeviceList) { diff --git a/src/audio/backend/openal2.cpp b/src/audio/backend/openal2.cpp index 3d9907116..3c174307b 100644 --- a/src/audio/backend/openal2.cpp +++ b/src/audio/backend/openal2.cpp @@ -164,7 +164,7 @@ bool OpenAL2::initOutputEchoCancel() Audio::AUDIO_SAMPLE_RATE, 0}; // End of List - alProxyDev = alcLoopbackOpenDeviceSOFT(NULL); + alProxyDev = alcLoopbackOpenDeviceSOFT(nullptr); checkAlcError(alProxyDev); if (!alProxyDev) { qDebug() << "Couldn't create proxy device"; diff --git a/src/chatlog/chatlog.h b/src/chatlog/chatlog.h index d98a86a6e..9ac12806f 100644 --- a/src/chatlog/chatlog.h +++ b/src/chatlog/chatlog.h @@ -38,7 +38,7 @@ class ChatLog : public QGraphicsView { Q_OBJECT public: - explicit ChatLog(QWidget* parent = 0); + explicit ChatLog(QWidget* parent = nullptr); virtual ~ChatLog(); void insertChatlineAtBottom(ChatLine::Ptr l); diff --git a/src/chatlog/chatmessage.cpp b/src/chatlog/chatmessage.cpp index 81a6e595d..03c0beec9 100644 --- a/src/chatlog/chatmessage.cpp +++ b/src/chatlog/chatmessage.cpp @@ -144,7 +144,7 @@ ChatMessage::Ptr ChatMessage::createFileTransferMessage(const QString& sender, T msg->addColumn(new Text(sender, authorFont, true), ColumnFormat(NAME_COL_WIDTH, ColumnFormat::FixedSize, ColumnFormat::Right)); - msg->addColumn(new ChatLineContentProxy(new FileTransferWidget(0, file), 320, 0.6f), + msg->addColumn(new ChatLineContentProxy(new FileTransferWidget(nullptr, file), 320, 0.6f), ColumnFormat(1.0, ColumnFormat::VariableSize)); msg->addColumn(new Timestamp(date, Settings::getInstance().getTimestampFormat(), baseFont), ColumnFormat(TIME_COL_WIDTH, ColumnFormat::FixedSize, ColumnFormat::Right)); diff --git a/src/chatlog/content/filetransferwidget.cpp b/src/chatlog/content/filetransferwidget.cpp index 82665f6aa..9fd45e59e 100644 --- a/src/chatlog/content/filetransferwidget.cpp +++ b/src/chatlog/content/filetransferwidget.cpp @@ -331,7 +331,7 @@ void FileTransferWidget::onFileTransferCancelled(ToxFile file) setupButtons(); hideWidgets(); - disconnect(Core::getInstance(), 0, this, 0); + disconnect(Core::getInstance(), nullptr, this, nullptr); } void FileTransferWidget::onFileTransferPaused(ToxFile file) @@ -401,7 +401,7 @@ void FileTransferWidget::onFileTransferFinished(ToxFile file) if (fileInfo.direction == ToxFile::RECEIVING) showPreview(fileInfo.filePath); - disconnect(Core::getInstance(), 0, this, 0); + disconnect(Core::getInstance(), nullptr, this, nullptr); } void FileTransferWidget::fileTransferRemotePausedUnpaused(ToxFile file, bool paused) diff --git a/src/ipc.cpp b/src/ipc.cpp index f187673a0..62345bc56 100644 --- a/src/ipc.cpp +++ b/src/ipc.cpp @@ -64,7 +64,7 @@ IPC::IPC(uint32_t profileId) IPCMemory* mem = global(); memset(mem, 0, sizeof(IPCMemory)); mem->globalId = globalId; - mem->lastProcessed = time(0); + mem->lastProcessed = time(nullptr); globalMemory.unlock(); } else { qWarning() << "Couldn't lock to take ownership"; @@ -122,7 +122,7 @@ time_t IPC::postEvent(const QString& name, const QByteArray& data, uint32_t dest memset(evt, 0, sizeof(IPCEvent)); memcpy(evt->name, binName.constData(), binName.length()); memcpy(evt->data, data.constData(), data.length()); - mem->lastEvent = evt->posted = result = qMax(mem->lastEvent + 1, time(0)); + mem->lastEvent = evt->posted = result = qMax(mem->lastEvent + 1, time(nullptr)); evt->dest = dest; evt->sender = getpid(); qDebug() << "postEvent " << name << "to" << dest; @@ -177,11 +177,11 @@ bool IPC::isEventAccepted(time_t time) bool IPC::waitUntilAccepted(time_t postTime, int32_t timeout /*=-1*/) { bool result = false; - time_t start = time(0); + time_t start = time(nullptr); forever { result = isEventAccepted(postTime); - if (result || (timeout > 0 && difftime(time(0), start) >= timeout)) + if (result || (timeout > 0 && difftime(time(nullptr), start) >= timeout)) break; qApp->processEvents(); @@ -213,8 +213,8 @@ IPC::IPCEvent* IPC::fetchEvent() // Garbage-collect events that were not processed in EVENT_GC_TIMEOUT // and events that were processed and EVENT_GC_TIMEOUT passed after // so sending instance has time to react to those events. - if ((evt->processed && difftime(time(0), evt->processed) > EVENT_GC_TIMEOUT) - || (!evt->processed && difftime(time(0), evt->posted) > EVENT_GC_TIMEOUT)) + if ((evt->processed && difftime(time(nullptr), evt->processed) > EVENT_GC_TIMEOUT) + || (!evt->processed && difftime(time(nullptr), evt->posted) > EVENT_GC_TIMEOUT)) memset(evt, 0, sizeof(IPCEvent)); if (evt->posted && !evt->processed && evt->sender != getpid() @@ -245,17 +245,17 @@ void IPC::processEvents() if (mem->globalId == globalId) { // We're the owner, let's process those events - mem->lastProcessed = time(0); + mem->lastProcessed = time(nullptr); } else { // Only the owner processes events. But if the previous owner's dead, we can take // ownership now - if (difftime(time(0), mem->lastProcessed) >= OWNERSHIP_TIMEOUT_S) { + if (difftime(time(nullptr), mem->lastProcessed) >= OWNERSHIP_TIMEOUT_S) { qDebug() << "Previous owner timed out, taking ownership" << mem->globalId << "->" << globalId; // Ignore events that were not meant for this instance memset(mem, 0, sizeof(IPCMemory)); mem->globalId = globalId; - mem->lastProcessed = time(0); + mem->lastProcessed = time(nullptr); } // Non-main instance is limited to events destined for specific profile it runs } @@ -271,9 +271,9 @@ void IPC::processEvents() // Otherwise global // event would be consumed by very first instance that gets to check it. if (evt->accepted) - evt->processed = time(0); + evt->processed = time(nullptr); } else { - evt->processed = time(0); + evt->processed = time(nullptr); } } } diff --git a/src/main.cpp b/src/main.cpp index 30cb246b3..763a669d9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -181,7 +181,7 @@ int main(int argc, char* argv[]) osx::migrateProfiles(); #endif - qsrand(time(0)); + qsrand(time(nullptr)); Settings::getInstance(); QString locale = Settings::getInstance().getTranslation(); Translator::translate(locale); diff --git a/src/nexus.h b/src/nexus.h index 4451a8b3f..9eb471910 100644 --- a/src/nexus.h +++ b/src/nexus.h @@ -85,7 +85,7 @@ private: #endif private: - explicit Nexus(QObject* parent = 0); + explicit Nexus(QObject* parent = nullptr); ~Nexus(); private: diff --git a/src/persistence/db/rawdatabase.cpp b/src/persistence/db/rawdatabase.cpp index 686bc7746..856323bfa 100644 --- a/src/persistence/db/rawdatabase.cpp +++ b/src/persistence/db/rawdatabase.cpp @@ -163,13 +163,13 @@ bool RawDatabase::open(const QString& path, const QString& hexKey) return false; } - if (sqlite3_create_function(sqlite, "regexp", 2, SQLITE_UTF8, NULL, &RawDatabase::regexpInsensitive, NULL, NULL)) { + if (sqlite3_create_function(sqlite, "regexp", 2, SQLITE_UTF8, nullptr, &RawDatabase::regexpInsensitive, nullptr, nullptr)) { qWarning() << "Failed to create function regexp"; close(); return false; } - if (sqlite3_create_function(sqlite, "regexpsensitive", 2, SQLITE_UTF8, NULL, &RawDatabase::regexpSensitive, NULL, NULL)) { + if (sqlite3_create_function(sqlite, "regexpsensitive", 2, SQLITE_UTF8, nullptr, &RawDatabase::regexpSensitive, nullptr, nullptr)) { qWarning() << "Failed to create function regexpsensitive"; close(); return false; diff --git a/src/platform/posixsignalnotifier.cpp b/src/platform/posixsignalnotifier.cpp index aec73a3cc..a1728b1cd 100644 --- a/src/platform/posixsignalnotifier.cpp +++ b/src/platform/posixsignalnotifier.cpp @@ -88,7 +88,7 @@ void PosixSignalNotifier::watchSignal(int signum) action.sa_handler = detail::signalHandler; action.sa_mask = blockMask; // allow old signal to finish before new is raised - if (::sigaction(signum, &action, 0)) { + if (::sigaction(signum, &action, nullptr)) { qFatal("Failed to setup signal %d, error = %d", signum, errno); } } diff --git a/src/video/cameradevice.cpp b/src/video/cameradevice.cpp index dc750a124..242e4b9cb 100644 --- a/src/video/cameradevice.cpp +++ b/src/video/cameradevice.cpp @@ -112,7 +112,7 @@ CameraDevice* CameraDevice::open(QString devName, AVDictionary** options) aduration = fctx->max_analyze_duration = 0; #endif - if (avformat_find_stream_info(fctx, NULL) < 0) { + if (avformat_find_stream_info(fctx, nullptr) < 0) { avformat_close_input(&fctx); goto out; } @@ -297,7 +297,7 @@ QVector> CameraDevice::getRawDeviceListGeneric() av_opt_set_defaults(s->priv_data); } } else { - s->priv_data = NULL; + s->priv_data = nullptr; } // List the devices for this context diff --git a/src/video/groupnetcamview.cpp b/src/video/groupnetcamview.cpp index d58d09e32..d5e1b6176 100644 --- a/src/video/groupnetcamview.cpp +++ b/src/video/groupnetcamview.cpp @@ -36,11 +36,11 @@ class LabeledVideo : public QFrame { public: - LabeledVideo(const QPixmap& avatar, QWidget* parent = 0, bool expanding = true) + LabeledVideo(const QPixmap& avatar, QWidget* parent = nullptr, bool expanding = true) : QFrame(parent) { qDebug() << "Created expanding? " << expanding; - videoSurface = new VideoSurface(avatar, 0, expanding); + videoSurface = new VideoSurface(avatar, nullptr, expanding); videoSurface->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); videoSurface->setMinimumHeight(32); diff --git a/src/video/groupnetcamview.h b/src/video/groupnetcamview.h index e7d4fc3cd..e7cd64b5e 100644 --- a/src/video/groupnetcamview.h +++ b/src/video/groupnetcamview.h @@ -32,7 +32,7 @@ class QHBoxLayout; class GroupNetCamView : public GenericNetCamView { public: - GroupNetCamView(int group, QWidget* parent = 0); + GroupNetCamView(int group, QWidget* parent = nullptr); void clearPeers(); void addPeer(const ToxPk& peer, const QString& name); void removePeer(const ToxPk& peer); diff --git a/src/video/netcamview.h b/src/video/netcamview.h index a76c44a67..733c3de57 100644 --- a/src/video/netcamview.h +++ b/src/video/netcamview.h @@ -34,7 +34,7 @@ class NetCamView : public GenericNetCamView Q_OBJECT public: - NetCamView(int friendId, QWidget* parent = 0); + NetCamView(int friendId, QWidget* parent = nullptr); ~NetCamView(); virtual void show(VideoSource* source, const QString& title); diff --git a/src/video/videosurface.h b/src/video/videosurface.h index dd84e62b0..d8e889621 100644 --- a/src/video/videosurface.h +++ b/src/video/videosurface.h @@ -30,8 +30,8 @@ class VideoSurface : public QWidget Q_OBJECT public: - VideoSurface(const QPixmap& avatar, QWidget* parent = 0, bool expanding = false); - VideoSurface(const QPixmap& avatar, VideoSource* source, QWidget* parent = 0); + VideoSurface(const QPixmap& avatar, QWidget* parent = nullptr, bool expanding = false); + VideoSurface(const QPixmap& avatar, VideoSource* source, QWidget* parent = nullptr); ~VideoSurface(); bool isExpanding() const; diff --git a/src/widget/about/aboutfriendform.h b/src/widget/about/aboutfriendform.h index d45b0012c..f80672628 100644 --- a/src/widget/about/aboutfriendform.h +++ b/src/widget/about/aboutfriendform.h @@ -17,7 +17,7 @@ class AboutFriendForm : public QDialog Q_OBJECT public: - AboutFriendForm(std::unique_ptr about, QWidget* parent = 0); + AboutFriendForm(std::unique_ptr about, QWidget* parent = nullptr); ~AboutFriendForm(); private: diff --git a/src/widget/categorywidget.h b/src/widget/categorywidget.h index 8a69fe3bc..e005bd515 100644 --- a/src/widget/categorywidget.h +++ b/src/widget/categorywidget.h @@ -33,7 +33,7 @@ class CategoryWidget : public GenericChatItemWidget { Q_OBJECT public: - explicit CategoryWidget(bool compact, QWidget* parent = 0); + explicit CategoryWidget(bool compact, QWidget* parent = nullptr); bool isExpanded() const; void setExpanded(bool isExpanded, bool save = true); diff --git a/src/widget/contentlayout.cpp b/src/widget/contentlayout.cpp index 37ecbada2..7e5d64a8a 100644 --- a/src/widget/contentlayout.cpp +++ b/src/widget/contentlayout.cpp @@ -69,13 +69,13 @@ ContentLayout::~ContentLayout() void ContentLayout::clear() { QLayoutItem* item; - while ((item = mainHead->layout()->takeAt(0)) != 0) { + while ((item = mainHead->layout()->takeAt(0)) != nullptr) { item->widget()->hide(); item->widget()->setParent(nullptr); delete item; } - while ((item = mainContent->layout()->takeAt(0)) != 0) { + while ((item = mainContent->layout()->takeAt(0)) != nullptr) { item->widget()->hide(); item->widget()->setParent(nullptr); delete item; diff --git a/src/widget/emoticonswidget.h b/src/widget/emoticonswidget.h index 5fd409578..3d6c7f15a 100644 --- a/src/widget/emoticonswidget.h +++ b/src/widget/emoticonswidget.h @@ -33,7 +33,7 @@ class EmoticonsWidget : public QMenu { Q_OBJECT public: - explicit EmoticonsWidget(QWidget* parent = 0); + explicit EmoticonsWidget(QWidget* parent = nullptr); signals: void insertEmoticon(QString str); diff --git a/src/widget/flowlayout.cpp b/src/widget/flowlayout.cpp index b38dc0aef..ac3895f04 100644 --- a/src/widget/flowlayout.cpp +++ b/src/widget/flowlayout.cpp @@ -99,12 +99,12 @@ QLayoutItem* FlowLayout::takeAt(int index) if (index >= 0 && index < itemList.size()) return itemList.takeAt(index); else - return 0; + return nullptr; } Qt::Orientations FlowLayout::expandingDirections() const { - return 0; + return nullptr; } bool FlowLayout::hasHeightForWidth() const @@ -184,7 +184,7 @@ int FlowLayout::smartSpacing(QStyle::PixelMetric pm) const return -1; } else if (parent->isWidgetType()) { QWidget* pw = static_cast(parent); - return pw->style()->pixelMetric(pm, 0, pw); + return pw->style()->pixelMetric(pm, nullptr, pw); } else { return static_cast(parent)->spacing(); } diff --git a/src/widget/form/chatform.cpp b/src/widget/form/chatform.cpp index cc78a989a..8a515eb6f 100644 --- a/src/widget/form/chatform.cpp +++ b/src/widget/form/chatform.cpp @@ -268,7 +268,7 @@ void ChatForm::onTextEditChanged() void ChatForm::onAttachClicked() { QStringList paths = - QFileDialog::getOpenFileNames(Q_NULLPTR, tr("Send a file"), QDir::homePath(), 0, 0); + QFileDialog::getOpenFileNames(Q_NULLPTR, tr("Send a file"), QDir::homePath(), nullptr, nullptr); if (paths.isEmpty()) { return; @@ -714,7 +714,7 @@ void ChatForm::dropEvent(QDropEvent* ev) file.close(); if (file.isSequential()) { - QMessageBox::critical(0, tr("Bad idea"), + QMessageBox::critical(nullptr, tr("Bad idea"), tr("You're trying to send a sequential file, " "which is not going to work!")); continue; diff --git a/src/widget/form/loadhistorydialog.h b/src/widget/form/loadhistorydialog.h index d28dd4396..a93b36f4e 100644 --- a/src/widget/form/loadhistorydialog.h +++ b/src/widget/form/loadhistorydialog.h @@ -33,8 +33,8 @@ class LoadHistoryDialog : public QDialog Q_OBJECT public: - explicit LoadHistoryDialog(const ToxPk& friendPk, QWidget* parent = 0); - explicit LoadHistoryDialog(QWidget* parent = 0); + explicit LoadHistoryDialog(const ToxPk& friendPk, QWidget* parent = nullptr); + explicit LoadHistoryDialog(QWidget* parent = nullptr); ~LoadHistoryDialog(); QDateTime getFromDate(); diff --git a/src/widget/form/setpassworddialog.h b/src/widget/form/setpassworddialog.h index 1496516a1..1b4bd77e0 100644 --- a/src/widget/form/setpassworddialog.h +++ b/src/widget/form/setpassworddialog.h @@ -37,7 +37,7 @@ public: Accepted = QDialog::Accepted, Tertiary }; - explicit SetPasswordDialog(QString body, QString extraButton, QWidget* parent = 0); + explicit SetPasswordDialog(QString body, QString extraButton, QWidget* parent = nullptr); ~SetPasswordDialog(); QString getPassword(); static int getPasswordStrength(QString pass); diff --git a/src/widget/form/settings/avform.cpp b/src/widget/form/settings/avform.cpp index 345aefa6c..00f90c4a6 100644 --- a/src/widget/form/settings/avform.cpp +++ b/src/widget/form/settings/avform.cpp @@ -614,7 +614,7 @@ void AVForm::killVideoSurface() return; QLayoutItem* child; - while ((child = gridLayout->takeAt(0)) != 0) + while ((child = gridLayout->takeAt(0)) != nullptr) delete child; camVideoSurface->close(); diff --git a/src/widget/form/settings/privacyform.cpp b/src/widget/form/settings/privacyform.cpp index fe02d6642..431ab0025 100644 --- a/src/widget/form/settings/privacyform.cpp +++ b/src/widget/form/settings/privacyform.cpp @@ -62,7 +62,7 @@ void PrivacyForm::on_cbKeepHistory_stateChanged() if (!bodyUI->cbKeepHistory->isChecked()) { QMessageBox::StandardButton dialogDelHistory; dialogDelHistory = - QMessageBox::question(0, tr("Confirmation"), + QMessageBox::question(nullptr, tr("Confirmation"), tr("Do you want to permanently delete all chat history?"), QMessageBox::Yes | QMessageBox::No); if (dialogDelHistory == QMessageBox::Yes) { diff --git a/src/widget/form/settings/verticalonlyscroller.h b/src/widget/form/settings/verticalonlyscroller.h index e9ab5d011..d1469c77f 100644 --- a/src/widget/form/settings/verticalonlyscroller.h +++ b/src/widget/form/settings/verticalonlyscroller.h @@ -29,7 +29,7 @@ class VerticalOnlyScroller : public QScrollArea { Q_OBJECT public: - explicit VerticalOnlyScroller(QWidget* parent = 0); + explicit VerticalOnlyScroller(QWidget* parent = nullptr); protected: virtual void resizeEvent(QResizeEvent* event) final override; diff --git a/src/widget/genericchatitemlayout.h b/src/widget/genericchatitemlayout.h index 06af47561..3254e2ad6 100644 --- a/src/widget/genericchatitemlayout.h +++ b/src/widget/genericchatitemlayout.h @@ -27,7 +27,7 @@ public: GenericChatItemLayout(const GenericChatItemLayout& layout) = delete; ~GenericChatItemLayout(); - void addSortedWidget(GenericChatItemWidget* widget, int stretch = 0, Qt::Alignment alignment = 0); + void addSortedWidget(GenericChatItemWidget* widget, int stretch = 0, Qt::Alignment alignment = nullptr); int indexOfSortedWidget(GenericChatItemWidget* widget) const; bool existsSortedWidget(GenericChatItemWidget* widget) const; void removeSortedWidget(GenericChatItemWidget* widget); diff --git a/src/widget/genericchatroomwidget.h b/src/widget/genericchatroomwidget.h index f28c062ed..228b558af 100644 --- a/src/widget/genericchatroomwidget.h +++ b/src/widget/genericchatroomwidget.h @@ -34,7 +34,7 @@ class GenericChatroomWidget : public GenericChatItemWidget { Q_OBJECT public: - explicit GenericChatroomWidget(bool compact, QWidget* parent = 0); + explicit GenericChatroomWidget(bool compact, QWidget* parent = nullptr); public slots: virtual void setAsActiveChatroom() = 0; diff --git a/src/widget/gui.h b/src/widget/gui.h index 2eabc5774..43fddcd8a 100644 --- a/src/widget/gui.h +++ b/src/widget/gui.h @@ -47,13 +47,13 @@ public: static QString itemInputDialog(QWidget* parent, const QString& title, const QString& label, const QStringList& items, int current = 0, bool editable = true, - bool* ok = 0, Qt::WindowFlags flags = 0, + bool* ok = nullptr, Qt::WindowFlags flags = nullptr, Qt::InputMethodHints hints = Qt::ImhNone); static QString passwordDialog(const QString& cancel, const QString& body); private: - explicit GUI(QObject* parent = 0); + explicit GUI(QObject* parent = nullptr); private slots: // Private implementation, those must be called from the GUI thread @@ -71,7 +71,7 @@ private slots: const QString& button2, bool defaultAns = false, bool warning = true); QString _itemInputDialog(QWidget* parent, const QString& title, const QString& label, const QStringList& items, int current = 0, bool editable = true, - bool* ok = 0, Qt::WindowFlags flags = 0, + bool* ok = nullptr, Qt::WindowFlags flags = nullptr, Qt::InputMethodHints inputMethodHints = Qt::ImhNone); QString _passwordDialog(const QString& cancel, const QString& body); }; diff --git a/src/widget/notificationedgewidget.h b/src/widget/notificationedgewidget.h index c839e702b..206a722af 100644 --- a/src/widget/notificationedgewidget.h +++ b/src/widget/notificationedgewidget.h @@ -34,7 +34,7 @@ public: Bottom }; - explicit NotificationEdgeWidget(Position position, QWidget* parent = 0); + explicit NotificationEdgeWidget(Position position, QWidget* parent = nullptr); void updateNotificationCount(int count); signals: diff --git a/src/widget/notificationscrollarea.h b/src/widget/notificationscrollarea.h index 798c9ae47..bb0a5cbe4 100644 --- a/src/widget/notificationscrollarea.h +++ b/src/widget/notificationscrollarea.h @@ -29,7 +29,7 @@ class NotificationEdgeWidget; class NotificationScrollArea final : public AdjustingScrollArea { public: - explicit NotificationScrollArea(QWidget* parent = 0); + explicit NotificationScrollArea(QWidget* parent = nullptr); public slots: void trackWidget(GenericChatroomWidget* widget); diff --git a/src/widget/qrwidget.cpp b/src/widget/qrwidget.cpp index 6e3721dd8..f076a59e5 100644 --- a/src/widget/qrwidget.cpp +++ b/src/widget/qrwidget.cpp @@ -71,9 +71,8 @@ QImage* QRWidget::getImage() */ bool QRWidget::saveImage(QString path) { - return image - ->save(path, 0, - 75); // 0 - image format same as file extension, 75-quality, png file is ~6.3kb + // 0 - image format same as file extension, 75-quality, png file is ~6.3kb + return image->save(path, nullptr, 75); } // http://stackoverflow.com/questions/21400254/how-to-draw-a-qr-code-with-qt-in-native-c-c diff --git a/src/widget/qrwidget.h b/src/widget/qrwidget.h index 5dc59e7d2..62b40e34d 100644 --- a/src/widget/qrwidget.h +++ b/src/widget/qrwidget.h @@ -28,7 +28,7 @@ class QRWidget : public QWidget Q_OBJECT public: - explicit QRWidget(QWidget* parent = 0); + explicit QRWidget(QWidget* parent = nullptr); ~QRWidget(); void setQRData(const QString& data); QImage* getImage(); diff --git a/src/widget/systemtrayicon.cpp b/src/widget/systemtrayicon.cpp index 7f857de42..ca1934b8d 100644 --- a/src/widget/systemtrayicon.cpp +++ b/src/widget/systemtrayicon.cpp @@ -120,7 +120,7 @@ GdkPixbuf* SystemTrayIcon::convertQIconToPixbuf(const QIcon& icon) return gdk_pixbuf_new_from_data(image_bytes, GDK_COLORSPACE_RGB, image.hasAlphaChannel(), 8, image.width(), image.height(), image.bytesPerLine(), - callbackFreeImage, NULL); + callbackFreeImage, nullptr); } #endif @@ -231,8 +231,8 @@ void SystemTrayIcon::setContextMenu(QMenu* menu) app_indicator_set_menu(unityIndicator, GTK_MENU(unityMenu)); DbusmenuServer* menuServer; DbusmenuMenuitem* rootMenuItem; - g_object_get(unityIndicator, "dbus-menu-server", &menuServer, NULL); - g_object_get(menuServer, "root-node", &rootMenuItem, NULL); + g_object_get(unityIndicator, "dbus-menu-server", &menuServer, nullptr); + g_object_get(menuServer, "root-node", &rootMenuItem, nullptr); void (*callback)(DbusmenuMenuitem*, gpointer) = [](DbusmenuMenuitem*, gpointer data) { static_cast(data)->activated(QSystemTrayIcon::Unknown); }; diff --git a/src/widget/tool/activatedialog.h b/src/widget/tool/activatedialog.h index d073f9a07..d6c2ea063 100644 --- a/src/widget/tool/activatedialog.h +++ b/src/widget/tool/activatedialog.h @@ -26,7 +26,7 @@ class ActivateDialog : public QDialog { Q_OBJECT public: - ActivateDialog(QWidget* parent = 0, Qt::WindowFlags f = 0); + ActivateDialog(QWidget* parent = nullptr, Qt::WindowFlags f = nullptr); bool event(QEvent* event) override; signals: diff --git a/src/widget/tool/adjustingscrollarea.h b/src/widget/tool/adjustingscrollarea.h index a71a89b0e..f20059da5 100644 --- a/src/widget/tool/adjustingscrollarea.h +++ b/src/widget/tool/adjustingscrollarea.h @@ -26,7 +26,7 @@ class AdjustingScrollArea : public QScrollArea { Q_OBJECT public: - explicit AdjustingScrollArea(QWidget* parent = 0); + explicit AdjustingScrollArea(QWidget* parent = nullptr); virtual ~AdjustingScrollArea() = default; protected: diff --git a/src/widget/tool/chattextedit.h b/src/widget/tool/chattextedit.h index ec6a56373..3e330a5ff 100644 --- a/src/widget/tool/chattextedit.h +++ b/src/widget/tool/chattextedit.h @@ -26,7 +26,7 @@ class ChatTextEdit final : public QTextEdit { Q_OBJECT public: - explicit ChatTextEdit(QWidget* parent = 0); + explicit ChatTextEdit(QWidget* parent = nullptr); ~ChatTextEdit(); void setLastMessage(QString lm); void sendKeyEvent(QKeyEvent* event); diff --git a/src/widget/tool/croppinglabel.cpp b/src/widget/tool/croppinglabel.cpp index 1371110bd..8fcef2878 100644 --- a/src/widget/tool/croppinglabel.cpp +++ b/src/widget/tool/croppinglabel.cpp @@ -34,7 +34,7 @@ CroppingLabel::CroppingLabel(QWidget* parent) class LineEdit : public QLineEdit { public: - explicit LineEdit(QWidget* parent = 0) + explicit LineEdit(QWidget* parent = nullptr) : QLineEdit(parent) { } diff --git a/src/widget/tool/croppinglabel.h b/src/widget/tool/croppinglabel.h index 328f72e77..89a7291c8 100644 --- a/src/widget/tool/croppinglabel.h +++ b/src/widget/tool/croppinglabel.h @@ -28,7 +28,7 @@ class CroppingLabel : public QLabel { Q_OBJECT public: - explicit CroppingLabel(QWidget* parent = 0); + explicit CroppingLabel(QWidget* parent = nullptr); public slots: void editBegin(); diff --git a/src/widget/tool/flyoutoverlaywidget.h b/src/widget/tool/flyoutoverlaywidget.h index 08f3d3f37..23c3356f4 100644 --- a/src/widget/tool/flyoutoverlaywidget.h +++ b/src/widget/tool/flyoutoverlaywidget.h @@ -30,7 +30,7 @@ class FlyoutOverlayWidget : public QWidget Q_OBJECT Q_PROPERTY(qreal flyoutPercent READ flyoutPercent WRITE setFlyoutPercent) public: - explicit FlyoutOverlayWidget(QWidget* parent = 0); + explicit FlyoutOverlayWidget(QWidget* parent = nullptr); ~FlyoutOverlayWidget(); int animationDuration() const; diff --git a/src/widget/tool/profileimporter.h b/src/widget/tool/profileimporter.h index 0a5b2d363..6c3722623 100644 --- a/src/widget/tool/profileimporter.h +++ b/src/widget/tool/profileimporter.h @@ -27,7 +27,7 @@ class ProfileImporter : public QWidget Q_OBJECT public: - explicit ProfileImporter(QWidget* parent = 0); + explicit ProfileImporter(QWidget* parent = nullptr); bool importProfile(const QString& path); bool importProfile(); diff --git a/src/widget/tool/screenshotgrabber.cpp b/src/widget/tool/screenshotgrabber.cpp index 45b18af88..39767b8d8 100644 --- a/src/widget/tool/screenshotgrabber.cpp +++ b/src/widget/tool/screenshotgrabber.cpp @@ -38,7 +38,7 @@ ScreenshotGrabber::ScreenshotGrabber() : QObject() , mKeysBlocked(false) - , scene(0) + , scene(nullptr) , mQToxVisible(true) { window = new QGraphicsView(scene); // Top-level widget diff --git a/src/widget/widget.cpp b/src/widget/widget.cpp index 75759fc16..51047e744 100644 --- a/src/widget/widget.cpp +++ b/src/widget/widget.cpp @@ -699,7 +699,7 @@ void Widget::onSeparateWindowChanged(bool separate, bool clicked) if (contentLayout) { contentLayout->clear(); - contentLayout->parentWidget()->setParent(0); // Remove from splitter. + contentLayout->parentWidget()->setParent(nullptr); // Remove from splitter. contentLayout->parentWidget()->hide(); contentLayout->parentWidget()->deleteLater(); contentLayout->deleteLater(); @@ -1043,7 +1043,7 @@ void Widget::addFriendFailed(const ToxPk&, const QString& errorInfo) info = info + QStringLiteral(": ") + errorInfo; } - QMessageBox::critical(0, "Error", info); + QMessageBox::critical(nullptr, "Error", info); } void Widget::onFriendStatusChanged(int friendId, Status status) diff --git a/src/widget/widget.h b/src/widget/widget.h index 0b3fbbb63..6745bdfbd 100644 --- a/src/widget/widget.h +++ b/src/widget/widget.h @@ -103,7 +103,7 @@ private: }; public: - explicit Widget(QWidget* parent = 0); + explicit Widget(QWidget* parent = nullptr); ~Widget(); void init(); void setCentralWidget(QWidget* widget, const QString& widgetName); diff --git a/test/net/toxmedata_test.cpp b/test/net/toxmedata_test.cpp index de01126cd..78a1025d9 100644 --- a/test/net/toxmedata_test.cpp +++ b/test/net/toxmedata_test.cpp @@ -116,8 +116,8 @@ Q_DECLARE_METATYPE(ToxId) void TestToxmeData::lookup_data() { qRegisterMetaType("ToxId"); - QTest::addColumn("input"); - QTest::addColumn("result"); + QTest::addColumn("input", nullptr); + QTest::addColumn("result", nullptr); QString sToxId = testToxId.toHex(); QTest::newRow("Valid ToxId") << QStringLiteral(R"({"tox_id": "%1"})").arg(sToxId) @@ -149,8 +149,8 @@ Q_DECLARE_METATYPE(ToxmeData::ExecCode) void TestToxmeData::extractCode_data() { qRegisterMetaType("ToxmeData::ExecCode"); - QTest::addColumn("input"); - QTest::addColumn("result"); + QTest::addColumn("input", nullptr); + QTest::addColumn("result", nullptr); QTest::newRow("Custom code") << QStringLiteral(R"({"c": 123})") << ToxmeData::ExecCode(123); @@ -205,7 +205,7 @@ void TestToxmeData::createAddressRequest() QCOMPARE(bioRes, bio); int timeRes = json["timestamp"].toInt(); - // Test will be failed if `createAddressRequest` will take more + // Test will be failed if `createAddressRequest` will take more // than 100 seconds QVERIFY(qAbs(timeRes - timestamp) < 100); } @@ -216,9 +216,9 @@ void TestToxmeData::createAddressRequest() void TestToxmeData::getPassTest_data() { qRegisterMetaType("ToxmeData::ExecCode"); - QTest::addColumn("input"); - QTest::addColumn("result"); - QTest::addColumn("code"); + QTest::addColumn("input", nullptr); + QTest::addColumn("result", nullptr); + QTest::addColumn("code", nullptr); QTest::newRow("Valid password") << QStringLiteral(R"({"password": "123qwe"})") << QStringLiteral("123qwe") @@ -280,7 +280,7 @@ void TestToxmeData::deleteAddressRequestTest() QCOMPARE(pkRes, testPublicKey); int timeRes = json["timestamp"].toInt(); - // Test will be failed if `deleteAddressRequest` will take more + // Test will be failed if `deleteAddressRequest` will take more // than 100 seconds QVERIFY(qAbs(timeRes - timestamp) < 100); } diff --git a/updater/settings.cpp b/updater/settings.cpp index 73737d9b8..774c5f94f 100644 --- a/updater/settings.cpp +++ b/updater/settings.cpp @@ -38,14 +38,14 @@ Settings::Settings() DWORD dwLastErr = 0; // Enable SeIncreaseQuotaPrivilege - HANDLE hProcessToken = NULL; + HANDLE hProcessToken = nullptr; if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &hProcessToken)) goto unelevateFail; TOKEN_PRIVILEGES tkp; tkp.PrivilegeCount = 1; - LookupPrivilegeValueW(NULL, SE_INCREASE_QUOTA_NAME, &tkp.Privileges[0].Luid); + LookupPrivilegeValueW(nullptr, SE_INCREASE_QUOTA_NAME, &tkp.Privileges[0].Luid); tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; - AdjustTokenPrivileges(hProcessToken, FALSE, &tkp, 0, NULL, NULL); + AdjustTokenPrivileges(hProcessToken, FALSE, &tkp, 0, nullptr, nullptr); dwLastErr = GetLastError(); CloseHandle(hProcessToken); if (ERROR_SUCCESS != dwLastErr) @@ -68,7 +68,7 @@ Settings::Settings() // Duplicate the shell's process token to get a primary token. // Based on experimentation, this is the minimal set of rights required for // CreateProcessWithTokenW (contrary to current documentation). - if (!DuplicateTokenEx(hShellProcessToken, dwTokenRights, NULL, SecurityImpersonation, + if (!DuplicateTokenEx(hShellProcessToken, dwTokenRights, nullptr, SecurityImpersonation, TokenPrimary, &hPrimaryToken)) goto unelevateFail;