1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Merge pull request #5332

iphydf (1):
      chore: Use `nullptr` instead of `0` for NULL pointer constants.
This commit is contained in:
sudden6 2018-09-13 20:04:20 +02:00
commit ffbcbddcaf
No known key found for this signature in database
GPG Key ID: 279509B499E032B9
46 changed files with 86 additions and 87 deletions

View File

@ -633,9 +633,9 @@ bool OpenAL::isOutputReady() const
QStringList OpenAL::outDeviceNames() QStringList OpenAL::outDeviceNames()
{ {
QStringList list; QStringList list;
const ALchar* pDeviceList = (alcIsExtensionPresent(NULL, "ALC_ENUMERATE_ALL_EXT") != AL_FALSE) const ALchar* pDeviceList = (alcIsExtensionPresent(nullptr, "ALC_ENUMERATE_ALL_EXT") != AL_FALSE)
? alcGetString(NULL, ALC_ALL_DEVICES_SPECIFIER) ? alcGetString(nullptr, ALC_ALL_DEVICES_SPECIFIER)
: alcGetString(NULL, ALC_DEVICE_SPECIFIER); : alcGetString(nullptr, ALC_DEVICE_SPECIFIER);
if (pDeviceList) { if (pDeviceList) {
while (*pDeviceList) { while (*pDeviceList) {
@ -651,7 +651,7 @@ QStringList OpenAL::outDeviceNames()
QStringList OpenAL::inDeviceNames() QStringList OpenAL::inDeviceNames()
{ {
QStringList list; QStringList list;
const ALchar* pDeviceList = alcGetString(NULL, ALC_CAPTURE_DEVICE_SPECIFIER); const ALchar* pDeviceList = alcGetString(nullptr, ALC_CAPTURE_DEVICE_SPECIFIER);
if (pDeviceList) { if (pDeviceList) {
while (*pDeviceList) { while (*pDeviceList) {

View File

@ -164,7 +164,7 @@ bool OpenAL2::initOutputEchoCancel()
Audio::AUDIO_SAMPLE_RATE, Audio::AUDIO_SAMPLE_RATE,
0}; // End of List 0}; // End of List
alProxyDev = alcLoopbackOpenDeviceSOFT(NULL); alProxyDev = alcLoopbackOpenDeviceSOFT(nullptr);
checkAlcError(alProxyDev); checkAlcError(alProxyDev);
if (!alProxyDev) { if (!alProxyDev) {
qDebug() << "Couldn't create proxy device"; qDebug() << "Couldn't create proxy device";

View File

@ -38,7 +38,7 @@ class ChatLog : public QGraphicsView
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit ChatLog(QWidget* parent = 0); explicit ChatLog(QWidget* parent = nullptr);
virtual ~ChatLog(); virtual ~ChatLog();
void insertChatlineAtBottom(ChatLine::Ptr l); void insertChatlineAtBottom(ChatLine::Ptr l);

View File

@ -144,7 +144,7 @@ ChatMessage::Ptr ChatMessage::createFileTransferMessage(const QString& sender, T
msg->addColumn(new Text(sender, authorFont, true), msg->addColumn(new Text(sender, authorFont, true),
ColumnFormat(NAME_COL_WIDTH, ColumnFormat::FixedSize, ColumnFormat::Right)); 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)); ColumnFormat(1.0, ColumnFormat::VariableSize));
msg->addColumn(new Timestamp(date, Settings::getInstance().getTimestampFormat(), baseFont), msg->addColumn(new Timestamp(date, Settings::getInstance().getTimestampFormat(), baseFont),
ColumnFormat(TIME_COL_WIDTH, ColumnFormat::FixedSize, ColumnFormat::Right)); ColumnFormat(TIME_COL_WIDTH, ColumnFormat::FixedSize, ColumnFormat::Right));

View File

@ -331,7 +331,7 @@ void FileTransferWidget::onFileTransferCancelled(ToxFile file)
setupButtons(); setupButtons();
hideWidgets(); hideWidgets();
disconnect(Core::getInstance(), 0, this, 0); disconnect(Core::getInstance(), nullptr, this, nullptr);
} }
void FileTransferWidget::onFileTransferPaused(ToxFile file) void FileTransferWidget::onFileTransferPaused(ToxFile file)
@ -401,7 +401,7 @@ void FileTransferWidget::onFileTransferFinished(ToxFile file)
if (fileInfo.direction == ToxFile::RECEIVING) if (fileInfo.direction == ToxFile::RECEIVING)
showPreview(fileInfo.filePath); showPreview(fileInfo.filePath);
disconnect(Core::getInstance(), 0, this, 0); disconnect(Core::getInstance(), nullptr, this, nullptr);
} }
void FileTransferWidget::fileTransferRemotePausedUnpaused(ToxFile file, bool paused) void FileTransferWidget::fileTransferRemotePausedUnpaused(ToxFile file, bool paused)

View File

@ -64,7 +64,7 @@ IPC::IPC(uint32_t profileId)
IPCMemory* mem = global(); IPCMemory* mem = global();
memset(mem, 0, sizeof(IPCMemory)); memset(mem, 0, sizeof(IPCMemory));
mem->globalId = globalId; mem->globalId = globalId;
mem->lastProcessed = time(0); mem->lastProcessed = time(nullptr);
globalMemory.unlock(); globalMemory.unlock();
} else { } else {
qWarning() << "Couldn't lock to take ownership"; 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)); memset(evt, 0, sizeof(IPCEvent));
memcpy(evt->name, binName.constData(), binName.length()); memcpy(evt->name, binName.constData(), binName.length());
memcpy(evt->data, data.constData(), data.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->dest = dest;
evt->sender = getpid(); evt->sender = getpid();
qDebug() << "postEvent " << name << "to" << dest; 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 IPC::waitUntilAccepted(time_t postTime, int32_t timeout /*=-1*/)
{ {
bool result = false; bool result = false;
time_t start = time(0); time_t start = time(nullptr);
forever forever
{ {
result = isEventAccepted(postTime); result = isEventAccepted(postTime);
if (result || (timeout > 0 && difftime(time(0), start) >= timeout)) if (result || (timeout > 0 && difftime(time(nullptr), start) >= timeout))
break; break;
qApp->processEvents(); qApp->processEvents();
@ -213,8 +213,8 @@ IPC::IPCEvent* IPC::fetchEvent()
// Garbage-collect events that were not processed in EVENT_GC_TIMEOUT // Garbage-collect events that were not processed in EVENT_GC_TIMEOUT
// and events that were processed and EVENT_GC_TIMEOUT passed after // and events that were processed and EVENT_GC_TIMEOUT passed after
// so sending instance has time to react to those events. // so sending instance has time to react to those events.
if ((evt->processed && difftime(time(0), evt->processed) > EVENT_GC_TIMEOUT) if ((evt->processed && difftime(time(nullptr), evt->processed) > EVENT_GC_TIMEOUT)
|| (!evt->processed && difftime(time(0), evt->posted) > EVENT_GC_TIMEOUT)) || (!evt->processed && difftime(time(nullptr), evt->posted) > EVENT_GC_TIMEOUT))
memset(evt, 0, sizeof(IPCEvent)); memset(evt, 0, sizeof(IPCEvent));
if (evt->posted && !evt->processed && evt->sender != getpid() if (evt->posted && !evt->processed && evt->sender != getpid()
@ -245,17 +245,17 @@ void IPC::processEvents()
if (mem->globalId == globalId) { if (mem->globalId == globalId) {
// We're the owner, let's process those events // We're the owner, let's process those events
mem->lastProcessed = time(0); mem->lastProcessed = time(nullptr);
} else { } else {
// Only the owner processes events. But if the previous owner's dead, we can take // Only the owner processes events. But if the previous owner's dead, we can take
// ownership now // 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 << "->" qDebug() << "Previous owner timed out, taking ownership" << mem->globalId << "->"
<< globalId; << globalId;
// Ignore events that were not meant for this instance // Ignore events that were not meant for this instance
memset(mem, 0, sizeof(IPCMemory)); memset(mem, 0, sizeof(IPCMemory));
mem->globalId = globalId; mem->globalId = globalId;
mem->lastProcessed = time(0); mem->lastProcessed = time(nullptr);
} }
// Non-main instance is limited to events destined for specific profile it runs // Non-main instance is limited to events destined for specific profile it runs
} }
@ -271,9 +271,9 @@ void IPC::processEvents()
// Otherwise global // Otherwise global
// event would be consumed by very first instance that gets to check it. // event would be consumed by very first instance that gets to check it.
if (evt->accepted) if (evt->accepted)
evt->processed = time(0); evt->processed = time(nullptr);
} else { } else {
evt->processed = time(0); evt->processed = time(nullptr);
} }
} }
} }

View File

@ -181,7 +181,7 @@ int main(int argc, char* argv[])
osx::migrateProfiles(); osx::migrateProfiles();
#endif #endif
qsrand(time(0)); qsrand(time(nullptr));
Settings::getInstance(); Settings::getInstance();
QString locale = Settings::getInstance().getTranslation(); QString locale = Settings::getInstance().getTranslation();
Translator::translate(locale); Translator::translate(locale);

View File

@ -85,7 +85,7 @@ private:
#endif #endif
private: private:
explicit Nexus(QObject* parent = 0); explicit Nexus(QObject* parent = nullptr);
~Nexus(); ~Nexus();
private: private:

View File

@ -163,13 +163,13 @@ bool RawDatabase::open(const QString& path, const QString& hexKey)
return false; 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"; qWarning() << "Failed to create function regexp";
close(); close();
return false; 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"; qWarning() << "Failed to create function regexpsensitive";
close(); close();
return false; return false;

View File

@ -88,7 +88,7 @@ void PosixSignalNotifier::watchSignal(int signum)
action.sa_handler = detail::signalHandler; action.sa_handler = detail::signalHandler;
action.sa_mask = blockMask; // allow old signal to finish before new is raised 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); qFatal("Failed to setup signal %d, error = %d", signum, errno);
} }
} }

View File

@ -112,7 +112,7 @@ CameraDevice* CameraDevice::open(QString devName, AVDictionary** options)
aduration = fctx->max_analyze_duration = 0; aduration = fctx->max_analyze_duration = 0;
#endif #endif
if (avformat_find_stream_info(fctx, NULL) < 0) { if (avformat_find_stream_info(fctx, nullptr) < 0) {
avformat_close_input(&fctx); avformat_close_input(&fctx);
goto out; goto out;
} }
@ -297,7 +297,7 @@ QVector<QPair<QString, QString>> CameraDevice::getRawDeviceListGeneric()
av_opt_set_defaults(s->priv_data); av_opt_set_defaults(s->priv_data);
} }
} else { } else {
s->priv_data = NULL; s->priv_data = nullptr;
} }
// List the devices for this context // List the devices for this context

View File

@ -36,11 +36,11 @@
class LabeledVideo : public QFrame class LabeledVideo : public QFrame
{ {
public: public:
LabeledVideo(const QPixmap& avatar, QWidget* parent = 0, bool expanding = true) LabeledVideo(const QPixmap& avatar, QWidget* parent = nullptr, bool expanding = true)
: QFrame(parent) : QFrame(parent)
{ {
qDebug() << "Created expanding? " << expanding; qDebug() << "Created expanding? " << expanding;
videoSurface = new VideoSurface(avatar, 0, expanding); videoSurface = new VideoSurface(avatar, nullptr, expanding);
videoSurface->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); videoSurface->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
videoSurface->setMinimumHeight(32); videoSurface->setMinimumHeight(32);

View File

@ -32,7 +32,7 @@ class QHBoxLayout;
class GroupNetCamView : public GenericNetCamView class GroupNetCamView : public GenericNetCamView
{ {
public: public:
GroupNetCamView(int group, QWidget* parent = 0); GroupNetCamView(int group, QWidget* parent = nullptr);
void clearPeers(); void clearPeers();
void addPeer(const ToxPk& peer, const QString& name); void addPeer(const ToxPk& peer, const QString& name);
void removePeer(const ToxPk& peer); void removePeer(const ToxPk& peer);

View File

@ -34,7 +34,7 @@ class NetCamView : public GenericNetCamView
Q_OBJECT Q_OBJECT
public: public:
NetCamView(int friendId, QWidget* parent = 0); NetCamView(int friendId, QWidget* parent = nullptr);
~NetCamView(); ~NetCamView();
virtual void show(VideoSource* source, const QString& title); virtual void show(VideoSource* source, const QString& title);

View File

@ -30,8 +30,8 @@ class VideoSurface : public QWidget
Q_OBJECT Q_OBJECT
public: public:
VideoSurface(const QPixmap& avatar, QWidget* parent = 0, bool expanding = false); VideoSurface(const QPixmap& avatar, QWidget* parent = nullptr, bool expanding = false);
VideoSurface(const QPixmap& avatar, VideoSource* source, QWidget* parent = 0); VideoSurface(const QPixmap& avatar, VideoSource* source, QWidget* parent = nullptr);
~VideoSurface(); ~VideoSurface();
bool isExpanding() const; bool isExpanding() const;

View File

@ -17,7 +17,7 @@ class AboutFriendForm : public QDialog
Q_OBJECT Q_OBJECT
public: public:
AboutFriendForm(std::unique_ptr<IAboutFriend> about, QWidget* parent = 0); AboutFriendForm(std::unique_ptr<IAboutFriend> about, QWidget* parent = nullptr);
~AboutFriendForm(); ~AboutFriendForm();
private: private:

View File

@ -33,7 +33,7 @@ class CategoryWidget : public GenericChatItemWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit CategoryWidget(bool compact, QWidget* parent = 0); explicit CategoryWidget(bool compact, QWidget* parent = nullptr);
bool isExpanded() const; bool isExpanded() const;
void setExpanded(bool isExpanded, bool save = true); void setExpanded(bool isExpanded, bool save = true);

View File

@ -69,13 +69,13 @@ ContentLayout::~ContentLayout()
void ContentLayout::clear() void ContentLayout::clear()
{ {
QLayoutItem* item; QLayoutItem* item;
while ((item = mainHead->layout()->takeAt(0)) != 0) { while ((item = mainHead->layout()->takeAt(0)) != nullptr) {
item->widget()->hide(); item->widget()->hide();
item->widget()->setParent(nullptr); item->widget()->setParent(nullptr);
delete item; delete item;
} }
while ((item = mainContent->layout()->takeAt(0)) != 0) { while ((item = mainContent->layout()->takeAt(0)) != nullptr) {
item->widget()->hide(); item->widget()->hide();
item->widget()->setParent(nullptr); item->widget()->setParent(nullptr);
delete item; delete item;

View File

@ -33,7 +33,7 @@ class EmoticonsWidget : public QMenu
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit EmoticonsWidget(QWidget* parent = 0); explicit EmoticonsWidget(QWidget* parent = nullptr);
signals: signals:
void insertEmoticon(QString str); void insertEmoticon(QString str);

View File

@ -99,12 +99,12 @@ QLayoutItem* FlowLayout::takeAt(int index)
if (index >= 0 && index < itemList.size()) if (index >= 0 && index < itemList.size())
return itemList.takeAt(index); return itemList.takeAt(index);
else else
return 0; return nullptr;
} }
Qt::Orientations FlowLayout::expandingDirections() const Qt::Orientations FlowLayout::expandingDirections() const
{ {
return 0; return nullptr;
} }
bool FlowLayout::hasHeightForWidth() const bool FlowLayout::hasHeightForWidth() const
@ -184,7 +184,7 @@ int FlowLayout::smartSpacing(QStyle::PixelMetric pm) const
return -1; return -1;
} else if (parent->isWidgetType()) { } else if (parent->isWidgetType()) {
QWidget* pw = static_cast<QWidget*>(parent); QWidget* pw = static_cast<QWidget*>(parent);
return pw->style()->pixelMetric(pm, 0, pw); return pw->style()->pixelMetric(pm, nullptr, pw);
} else { } else {
return static_cast<QLayout*>(parent)->spacing(); return static_cast<QLayout*>(parent)->spacing();
} }

View File

@ -268,7 +268,7 @@ void ChatForm::onTextEditChanged()
void ChatForm::onAttachClicked() void ChatForm::onAttachClicked()
{ {
QStringList paths = 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()) { if (paths.isEmpty()) {
return; return;
@ -714,7 +714,7 @@ void ChatForm::dropEvent(QDropEvent* ev)
file.close(); file.close();
if (file.isSequential()) { if (file.isSequential()) {
QMessageBox::critical(0, tr("Bad idea"), QMessageBox::critical(nullptr, tr("Bad idea"),
tr("You're trying to send a sequential file, " tr("You're trying to send a sequential file, "
"which is not going to work!")); "which is not going to work!"));
continue; continue;

View File

@ -33,8 +33,8 @@ class LoadHistoryDialog : public QDialog
Q_OBJECT Q_OBJECT
public: public:
explicit LoadHistoryDialog(const ToxPk& friendPk, QWidget* parent = 0); explicit LoadHistoryDialog(const ToxPk& friendPk, QWidget* parent = nullptr);
explicit LoadHistoryDialog(QWidget* parent = 0); explicit LoadHistoryDialog(QWidget* parent = nullptr);
~LoadHistoryDialog(); ~LoadHistoryDialog();
QDateTime getFromDate(); QDateTime getFromDate();

View File

@ -37,7 +37,7 @@ public:
Accepted = QDialog::Accepted, Accepted = QDialog::Accepted,
Tertiary Tertiary
}; };
explicit SetPasswordDialog(QString body, QString extraButton, QWidget* parent = 0); explicit SetPasswordDialog(QString body, QString extraButton, QWidget* parent = nullptr);
~SetPasswordDialog(); ~SetPasswordDialog();
QString getPassword(); QString getPassword();
static int getPasswordStrength(QString pass); static int getPasswordStrength(QString pass);

View File

@ -614,7 +614,7 @@ void AVForm::killVideoSurface()
return; return;
QLayoutItem* child; QLayoutItem* child;
while ((child = gridLayout->takeAt(0)) != 0) while ((child = gridLayout->takeAt(0)) != nullptr)
delete child; delete child;
camVideoSurface->close(); camVideoSurface->close();

View File

@ -62,7 +62,7 @@ void PrivacyForm::on_cbKeepHistory_stateChanged()
if (!bodyUI->cbKeepHistory->isChecked()) { if (!bodyUI->cbKeepHistory->isChecked()) {
QMessageBox::StandardButton dialogDelHistory; QMessageBox::StandardButton dialogDelHistory;
dialogDelHistory = dialogDelHistory =
QMessageBox::question(0, tr("Confirmation"), QMessageBox::question(nullptr, tr("Confirmation"),
tr("Do you want to permanently delete all chat history?"), tr("Do you want to permanently delete all chat history?"),
QMessageBox::Yes | QMessageBox::No); QMessageBox::Yes | QMessageBox::No);
if (dialogDelHistory == QMessageBox::Yes) { if (dialogDelHistory == QMessageBox::Yes) {

View File

@ -29,7 +29,7 @@ class VerticalOnlyScroller : public QScrollArea
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit VerticalOnlyScroller(QWidget* parent = 0); explicit VerticalOnlyScroller(QWidget* parent = nullptr);
protected: protected:
virtual void resizeEvent(QResizeEvent* event) final override; virtual void resizeEvent(QResizeEvent* event) final override;

View File

@ -27,7 +27,7 @@ public:
GenericChatItemLayout(const GenericChatItemLayout& layout) = delete; GenericChatItemLayout(const GenericChatItemLayout& layout) = delete;
~GenericChatItemLayout(); ~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; int indexOfSortedWidget(GenericChatItemWidget* widget) const;
bool existsSortedWidget(GenericChatItemWidget* widget) const; bool existsSortedWidget(GenericChatItemWidget* widget) const;
void removeSortedWidget(GenericChatItemWidget* widget); void removeSortedWidget(GenericChatItemWidget* widget);

View File

@ -34,7 +34,7 @@ class GenericChatroomWidget : public GenericChatItemWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit GenericChatroomWidget(bool compact, QWidget* parent = 0); explicit GenericChatroomWidget(bool compact, QWidget* parent = nullptr);
public slots: public slots:
virtual void setAsActiveChatroom() = 0; virtual void setAsActiveChatroom() = 0;

View File

@ -47,13 +47,13 @@ public:
static QString itemInputDialog(QWidget* parent, const QString& title, const QString& label, static QString itemInputDialog(QWidget* parent, const QString& title, const QString& label,
const QStringList& items, int current = 0, bool editable = true, 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); Qt::InputMethodHints hints = Qt::ImhNone);
static QString passwordDialog(const QString& cancel, const QString& body); static QString passwordDialog(const QString& cancel, const QString& body);
private: private:
explicit GUI(QObject* parent = 0); explicit GUI(QObject* parent = nullptr);
private slots: private slots:
// Private implementation, those must be called from the GUI thread // 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); const QString& button2, bool defaultAns = false, bool warning = true);
QString _itemInputDialog(QWidget* parent, const QString& title, const QString& label, QString _itemInputDialog(QWidget* parent, const QString& title, const QString& label,
const QStringList& items, int current = 0, bool editable = true, 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); Qt::InputMethodHints inputMethodHints = Qt::ImhNone);
QString _passwordDialog(const QString& cancel, const QString& body); QString _passwordDialog(const QString& cancel, const QString& body);
}; };

View File

@ -34,7 +34,7 @@ public:
Bottom Bottom
}; };
explicit NotificationEdgeWidget(Position position, QWidget* parent = 0); explicit NotificationEdgeWidget(Position position, QWidget* parent = nullptr);
void updateNotificationCount(int count); void updateNotificationCount(int count);
signals: signals:

View File

@ -29,7 +29,7 @@ class NotificationEdgeWidget;
class NotificationScrollArea final : public AdjustingScrollArea class NotificationScrollArea final : public AdjustingScrollArea
{ {
public: public:
explicit NotificationScrollArea(QWidget* parent = 0); explicit NotificationScrollArea(QWidget* parent = nullptr);
public slots: public slots:
void trackWidget(GenericChatroomWidget* widget); void trackWidget(GenericChatroomWidget* widget);

View File

@ -71,9 +71,8 @@ QImage* QRWidget::getImage()
*/ */
bool QRWidget::saveImage(QString path) bool QRWidget::saveImage(QString path)
{ {
return image // 0 - image format same as file extension, 75-quality, png file is ~6.3kb
->save(path, 0, return image->save(path, nullptr, 75);
75); // 0 - image format same as file extension, 75-quality, png file is ~6.3kb
} }
// http://stackoverflow.com/questions/21400254/how-to-draw-a-qr-code-with-qt-in-native-c-c // http://stackoverflow.com/questions/21400254/how-to-draw-a-qr-code-with-qt-in-native-c-c

View File

@ -28,7 +28,7 @@ class QRWidget : public QWidget
Q_OBJECT Q_OBJECT
public: public:
explicit QRWidget(QWidget* parent = 0); explicit QRWidget(QWidget* parent = nullptr);
~QRWidget(); ~QRWidget();
void setQRData(const QString& data); void setQRData(const QString& data);
QImage* getImage(); QImage* getImage();

View File

@ -120,7 +120,7 @@ GdkPixbuf* SystemTrayIcon::convertQIconToPixbuf(const QIcon& icon)
return gdk_pixbuf_new_from_data(image_bytes, GDK_COLORSPACE_RGB, image.hasAlphaChannel(), 8, return gdk_pixbuf_new_from_data(image_bytes, GDK_COLORSPACE_RGB, image.hasAlphaChannel(), 8,
image.width(), image.height(), image.bytesPerLine(), image.width(), image.height(), image.bytesPerLine(),
callbackFreeImage, NULL); callbackFreeImage, nullptr);
} }
#endif #endif
@ -231,8 +231,8 @@ void SystemTrayIcon::setContextMenu(QMenu* menu)
app_indicator_set_menu(unityIndicator, GTK_MENU(unityMenu)); app_indicator_set_menu(unityIndicator, GTK_MENU(unityMenu));
DbusmenuServer* menuServer; DbusmenuServer* menuServer;
DbusmenuMenuitem* rootMenuItem; DbusmenuMenuitem* rootMenuItem;
g_object_get(unityIndicator, "dbus-menu-server", &menuServer, NULL); g_object_get(unityIndicator, "dbus-menu-server", &menuServer, nullptr);
g_object_get(menuServer, "root-node", &rootMenuItem, NULL); g_object_get(menuServer, "root-node", &rootMenuItem, nullptr);
void (*callback)(DbusmenuMenuitem*, gpointer) = [](DbusmenuMenuitem*, gpointer data) { void (*callback)(DbusmenuMenuitem*, gpointer) = [](DbusmenuMenuitem*, gpointer data) {
static_cast<SystemTrayIcon*>(data)->activated(QSystemTrayIcon::Unknown); static_cast<SystemTrayIcon*>(data)->activated(QSystemTrayIcon::Unknown);
}; };

View File

@ -26,7 +26,7 @@ class ActivateDialog : public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
ActivateDialog(QWidget* parent = 0, Qt::WindowFlags f = 0); ActivateDialog(QWidget* parent = nullptr, Qt::WindowFlags f = nullptr);
bool event(QEvent* event) override; bool event(QEvent* event) override;
signals: signals:

View File

@ -26,7 +26,7 @@ class AdjustingScrollArea : public QScrollArea
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit AdjustingScrollArea(QWidget* parent = 0); explicit AdjustingScrollArea(QWidget* parent = nullptr);
virtual ~AdjustingScrollArea() = default; virtual ~AdjustingScrollArea() = default;
protected: protected:

View File

@ -26,7 +26,7 @@ class ChatTextEdit final : public QTextEdit
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit ChatTextEdit(QWidget* parent = 0); explicit ChatTextEdit(QWidget* parent = nullptr);
~ChatTextEdit(); ~ChatTextEdit();
void setLastMessage(QString lm); void setLastMessage(QString lm);
void sendKeyEvent(QKeyEvent* event); void sendKeyEvent(QKeyEvent* event);

View File

@ -34,7 +34,7 @@ CroppingLabel::CroppingLabel(QWidget* parent)
class LineEdit : public QLineEdit class LineEdit : public QLineEdit
{ {
public: public:
explicit LineEdit(QWidget* parent = 0) explicit LineEdit(QWidget* parent = nullptr)
: QLineEdit(parent) : QLineEdit(parent)
{ {
} }

View File

@ -28,7 +28,7 @@ class CroppingLabel : public QLabel
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit CroppingLabel(QWidget* parent = 0); explicit CroppingLabel(QWidget* parent = nullptr);
public slots: public slots:
void editBegin(); void editBegin();

View File

@ -30,7 +30,7 @@ class FlyoutOverlayWidget : public QWidget
Q_OBJECT Q_OBJECT
Q_PROPERTY(qreal flyoutPercent READ flyoutPercent WRITE setFlyoutPercent) Q_PROPERTY(qreal flyoutPercent READ flyoutPercent WRITE setFlyoutPercent)
public: public:
explicit FlyoutOverlayWidget(QWidget* parent = 0); explicit FlyoutOverlayWidget(QWidget* parent = nullptr);
~FlyoutOverlayWidget(); ~FlyoutOverlayWidget();
int animationDuration() const; int animationDuration() const;

View File

@ -27,7 +27,7 @@ class ProfileImporter : public QWidget
Q_OBJECT Q_OBJECT
public: public:
explicit ProfileImporter(QWidget* parent = 0); explicit ProfileImporter(QWidget* parent = nullptr);
bool importProfile(const QString& path); bool importProfile(const QString& path);
bool importProfile(); bool importProfile();

View File

@ -38,7 +38,7 @@
ScreenshotGrabber::ScreenshotGrabber() ScreenshotGrabber::ScreenshotGrabber()
: QObject() : QObject()
, mKeysBlocked(false) , mKeysBlocked(false)
, scene(0) , scene(nullptr)
, mQToxVisible(true) , mQToxVisible(true)
{ {
window = new QGraphicsView(scene); // Top-level widget window = new QGraphicsView(scene); // Top-level widget

View File

@ -699,7 +699,7 @@ void Widget::onSeparateWindowChanged(bool separate, bool clicked)
if (contentLayout) { if (contentLayout) {
contentLayout->clear(); contentLayout->clear();
contentLayout->parentWidget()->setParent(0); // Remove from splitter. contentLayout->parentWidget()->setParent(nullptr); // Remove from splitter.
contentLayout->parentWidget()->hide(); contentLayout->parentWidget()->hide();
contentLayout->parentWidget()->deleteLater(); contentLayout->parentWidget()->deleteLater();
contentLayout->deleteLater(); contentLayout->deleteLater();
@ -1043,7 +1043,7 @@ void Widget::addFriendFailed(const ToxPk&, const QString& errorInfo)
info = info + QStringLiteral(": ") + errorInfo; info = info + QStringLiteral(": ") + errorInfo;
} }
QMessageBox::critical(0, "Error", info); QMessageBox::critical(nullptr, "Error", info);
} }
void Widget::onFriendStatusChanged(int friendId, Status status) void Widget::onFriendStatusChanged(int friendId, Status status)

View File

@ -103,7 +103,7 @@ private:
}; };
public: public:
explicit Widget(QWidget* parent = 0); explicit Widget(QWidget* parent = nullptr);
~Widget(); ~Widget();
void init(); void init();
void setCentralWidget(QWidget* widget, const QString& widgetName); void setCentralWidget(QWidget* widget, const QString& widgetName);

View File

@ -116,8 +116,8 @@ Q_DECLARE_METATYPE(ToxId)
void TestToxmeData::lookup_data() void TestToxmeData::lookup_data()
{ {
qRegisterMetaType<ToxId>("ToxId"); qRegisterMetaType<ToxId>("ToxId");
QTest::addColumn<QString>("input"); QTest::addColumn<QString>("input", nullptr);
QTest::addColumn<ToxId>("result"); QTest::addColumn<ToxId>("result", nullptr);
QString sToxId = testToxId.toHex(); QString sToxId = testToxId.toHex();
QTest::newRow("Valid ToxId") << QStringLiteral(R"({"tox_id": "%1"})").arg(sToxId) QTest::newRow("Valid ToxId") << QStringLiteral(R"({"tox_id": "%1"})").arg(sToxId)
@ -149,8 +149,8 @@ Q_DECLARE_METATYPE(ToxmeData::ExecCode)
void TestToxmeData::extractCode_data() void TestToxmeData::extractCode_data()
{ {
qRegisterMetaType<ToxmeData::ExecCode>("ToxmeData::ExecCode"); qRegisterMetaType<ToxmeData::ExecCode>("ToxmeData::ExecCode");
QTest::addColumn<QString>("input"); QTest::addColumn<QString>("input", nullptr);
QTest::addColumn<ToxmeData::ExecCode>("result"); QTest::addColumn<ToxmeData::ExecCode>("result", nullptr);
QTest::newRow("Custom code") << QStringLiteral(R"({"c": 123})") QTest::newRow("Custom code") << QStringLiteral(R"({"c": 123})")
<< ToxmeData::ExecCode(123); << ToxmeData::ExecCode(123);
@ -205,7 +205,7 @@ void TestToxmeData::createAddressRequest()
QCOMPARE(bioRes, bio); QCOMPARE(bioRes, bio);
int timeRes = json["timestamp"].toInt(); 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 // than 100 seconds
QVERIFY(qAbs(timeRes - timestamp) < 100); QVERIFY(qAbs(timeRes - timestamp) < 100);
} }
@ -216,9 +216,9 @@ void TestToxmeData::createAddressRequest()
void TestToxmeData::getPassTest_data() void TestToxmeData::getPassTest_data()
{ {
qRegisterMetaType<ToxmeData::ExecCode>("ToxmeData::ExecCode"); qRegisterMetaType<ToxmeData::ExecCode>("ToxmeData::ExecCode");
QTest::addColumn<QString>("input"); QTest::addColumn<QString>("input", nullptr);
QTest::addColumn<QString>("result"); QTest::addColumn<QString>("result", nullptr);
QTest::addColumn<ToxmeData::ExecCode>("code"); QTest::addColumn<ToxmeData::ExecCode>("code", nullptr);
QTest::newRow("Valid password") << QStringLiteral(R"({"password": "123qwe"})") QTest::newRow("Valid password") << QStringLiteral(R"({"password": "123qwe"})")
<< QStringLiteral("123qwe") << QStringLiteral("123qwe")
@ -280,7 +280,7 @@ void TestToxmeData::deleteAddressRequestTest()
QCOMPARE(pkRes, testPublicKey); QCOMPARE(pkRes, testPublicKey);
int timeRes = json["timestamp"].toInt(); 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 // than 100 seconds
QVERIFY(qAbs(timeRes - timestamp) < 100); QVERIFY(qAbs(timeRes - timestamp) < 100);
} }

View File

@ -38,14 +38,14 @@ Settings::Settings()
DWORD dwLastErr = 0; DWORD dwLastErr = 0;
// Enable SeIncreaseQuotaPrivilege // Enable SeIncreaseQuotaPrivilege
HANDLE hProcessToken = NULL; HANDLE hProcessToken = nullptr;
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &hProcessToken)) if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &hProcessToken))
goto unelevateFail; goto unelevateFail;
TOKEN_PRIVILEGES tkp; TOKEN_PRIVILEGES tkp;
tkp.PrivilegeCount = 1; 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; tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges(hProcessToken, FALSE, &tkp, 0, NULL, NULL); AdjustTokenPrivileges(hProcessToken, FALSE, &tkp, 0, nullptr, nullptr);
dwLastErr = GetLastError(); dwLastErr = GetLastError();
CloseHandle(hProcessToken); CloseHandle(hProcessToken);
if (ERROR_SUCCESS != dwLastErr) if (ERROR_SUCCESS != dwLastErr)
@ -68,7 +68,7 @@ Settings::Settings()
// Duplicate the shell's process token to get a primary token. // Duplicate the shell's process token to get a primary token.
// Based on experimentation, this is the minimal set of rights required for // Based on experimentation, this is the minimal set of rights required for
// CreateProcessWithTokenW (contrary to current documentation). // CreateProcessWithTokenW (contrary to current documentation).
if (!DuplicateTokenEx(hShellProcessToken, dwTokenRights, NULL, SecurityImpersonation, if (!DuplicateTokenEx(hShellProcessToken, dwTokenRights, nullptr, SecurityImpersonation,
TokenPrimary, &hPrimaryToken)) TokenPrimary, &hPrimaryToken))
goto unelevateFail; goto unelevateFail;