Browse Source

Merge pull request #6005

Jimi Huotari (1):
      refactor(Qt): fix build with Qt 5.15
reviewable/pr6019/r3
sudden6 5 years ago
parent
commit
4345fafbc6
No known key found for this signature in database
GPG Key ID: 279509B499E032B9
  1. 7
      src/core/core.cpp
  2. 4
      src/main.cpp
  3. 4
      src/model/sessionchatlog.cpp
  4. 4
      src/persistence/history.cpp
  5. 8
      src/widget/emoticonswidget.cpp
  6. 2
      src/widget/flowlayout.cpp
  7. 4
      src/widget/form/loadhistorydialog.cpp
  8. 4
      src/widget/form/searchsettingsform.cpp
  9. 11
      src/widget/form/settings/privacyform.cpp
  10. 4
      src/widget/genericchatitemlayout.h
  11. 4
      src/widget/tool/activatedialog.h

7
src/core/core.cpp

@ -34,6 +34,9 @@ @@ -34,6 +34,9 @@
#include "src/util/strongtype.h"
#include <QCoreApplication>
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
#include <QRandomGenerator>
#endif
#include <QRegularExpression>
#include <QString>
#include <QStringBuilder>
@ -792,7 +795,11 @@ void Core::bootstrapDht() @@ -792,7 +795,11 @@ void Core::bootstrapDht()
}
int i = 0;
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
static int j = QRandomGenerator::global()->generate() % listSize;
#else
static int j = qrand() % listSize;
#endif
// i think the more we bootstrap, the more we jitter because the more we overwrite nodes
while (i < 2) {
const DhtServer& dhtServer = bootstrapNodes[j % listSize];

4
src/main.cpp

@ -175,7 +175,9 @@ int main(int argc, char* argv[]) @@ -175,7 +175,9 @@ int main(int argc, char* argv[])
qInstallMessageHandler(logMessageHandler);
// initialize random number generator
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 0))
qsrand(time(nullptr));
#endif
std::unique_ptr<QApplication> a(new QApplication(argc, argv));
@ -207,7 +209,9 @@ int main(int argc, char* argv[]) @@ -207,7 +209,9 @@ int main(int argc, char* argv[])
osx::migrateProfiles();
#endif
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 0))
qsrand(time(nullptr));
#endif
Settings& settings = Settings::getInstance();
QString locale = settings.getTranslation();
Translator::translate(locale);

4
src/model/sessionchatlog.cpp

@ -96,7 +96,11 @@ bool toxFileIsComplete(ToxFile::FileStatus status) @@ -96,7 +96,11 @@ bool toxFileIsComplete(ToxFile::FileStatus status)
std::map<ChatLogIdx, ChatLogItem>::const_iterator
firstItemAfterDate(QDate date, const std::map<ChatLogIdx, ChatLogItem>& items)
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
return std::lower_bound(items.begin(), items.end(), QDateTime(date.startOfDay()),
#else
return std::lower_bound(items.begin(), items.end(), QDateTime(date),
#endif
[](const MessageDateAdaptor& a, MessageDateAdaptor const& b) {
return a.timestamp.date() < b.timestamp.date();
});

4
src/persistence/history.cpp

@ -957,7 +957,11 @@ QList<History::DateIdx> History::getNumMessagesForFriendBeforeDateBoundaries(con @@ -957,7 +957,11 @@ QList<History::DateIdx> History::getNumMessagesForFriendBeforeDateBoundaries(con
"%4;")
.arg(countMessagesForFriend)
.arg(friendPkString)
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
.arg(QDateTime(from.startOfDay()).toMSecsSinceEpoch())
#else
.arg(QDateTime(from).toMSecsSinceEpoch())
#endif
.arg(limitString);
QList<DateIdx> dateIdxs;

8
src/widget/emoticonswidget.cpp

@ -161,8 +161,16 @@ void EmoticonsWidget::mousePressEvent(QMouseEvent*) @@ -161,8 +161,16 @@ void EmoticonsWidget::mousePressEvent(QMouseEvent*)
void EmoticonsWidget::wheelEvent(QWheelEvent* e)
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
const bool vertical = qAbs(e->angleDelta().y()) >= qAbs(e->angleDelta().x());
const int delta = vertical ? e->angleDelta().y() : e->angleDelta().x();
if (vertical) {
if (delta < 0) {
#else
if (e->orientation() == Qt::Vertical) {
if (e->delta() < 0) {
#endif
stack.setCurrentIndex(stack.currentIndex() + 1);
} else {
stack.setCurrentIndex(stack.currentIndex() - 1);

2
src/widget/flowlayout.cpp

@ -104,7 +104,7 @@ QLayoutItem* FlowLayout::takeAt(int index) @@ -104,7 +104,7 @@ QLayoutItem* FlowLayout::takeAt(int index)
Qt::Orientations FlowLayout::expandingDirections() const
{
return nullptr;
return {};
}
bool FlowLayout::hasHeightForWidth() const

4
src/widget/form/loadhistorydialog.cpp

@ -56,7 +56,11 @@ LoadHistoryDialog::~LoadHistoryDialog() @@ -56,7 +56,11 @@ LoadHistoryDialog::~LoadHistoryDialog()
QDateTime LoadHistoryDialog::getFromDate()
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
QDateTime res(ui->fromDate->selectedDate().startOfDay());
#else
QDateTime res(ui->fromDate->selectedDate());
#endif
if (res.date().month() != ui->fromDate->monthShown()
|| res.date().year() != ui->fromDate->yearShown()) {
QDate newDate(ui->fromDate->yearShown(), ui->fromDate->monthShown(), 1);

4
src/widget/form/searchsettingsform.cpp

@ -37,7 +37,11 @@ SearchSettingsForm::SearchSettingsForm(QWidget *parent) : @@ -37,7 +37,11 @@ SearchSettingsForm::SearchSettingsForm(QWidget *parent) :
reloadTheme();
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
connect(ui->startSearchComboBox, QOverload<int, const QString &>::of(&QComboBox::currentIndexChanged),
#else
connect(ui->startSearchComboBox, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
#endif
this, &SearchSettingsForm::onStartSearchSelected);
connect(ui->registerCheckBox, &QCheckBox::clicked, this, &SearchSettingsForm::onRegisterClicked);
connect(ui->wordsOnlyRadioButton, &QCheckBox::clicked, this, &SearchSettingsForm::onWordsOnlyClicked);

11
src/widget/form/settings/privacyform.cpp

@ -23,6 +23,9 @@ @@ -23,6 +23,9 @@
#include <QDebug>
#include <QFile>
#include <QMessageBox>
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
#include <QRandomGenerator>
#endif
#include "src/core/core.h"
#include "src/nexus.h"
@ -98,11 +101,19 @@ void PrivacyForm::showEvent(QShowEvent*) @@ -98,11 +101,19 @@ void PrivacyForm::showEvent(QShowEvent*)
void PrivacyForm::on_randomNosapamButton_clicked()
{
QTime time = QTime::currentTime();
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
QRandomGenerator((uint)time.msec());
#else
qsrand((uint)time.msec());
#endif
uint32_t newNospam{0};
for (int i = 0; i < 4; ++i)
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
newNospam = (newNospam << 8) + (QRandomGenerator::global()->generate() % 256); // Generate byte by byte. For some reason.
#else
newNospam = (newNospam << 8) + (qrand() % 256); // Generate byte by byte. For some reason.
#endif
Core::getInstance()->setNospam(newNospam);
bodyUI->nospamLineEdit->setText(Core::getInstance()->getSelfId().getNoSpamString());

4
src/widget/genericchatitemlayout.h

@ -33,7 +33,11 @@ public: @@ -33,7 +33,11 @@ public:
GenericChatItemLayout(const GenericChatItemLayout& layout) = delete;
~GenericChatItemLayout();
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
void addSortedWidget(GenericChatItemWidget* widget, int stretch = 0, Qt::Alignment alignment = Qt::Alignment());
#else
void addSortedWidget(GenericChatItemWidget* widget, int stretch = 0, Qt::Alignment alignment = nullptr);
#endif
int indexOfSortedWidget(GenericChatItemWidget* widget) const;
bool existsSortedWidget(GenericChatItemWidget* widget) const;
void removeSortedWidget(GenericChatItemWidget* widget);

4
src/widget/tool/activatedialog.h

@ -26,7 +26,11 @@ class ActivateDialog : public QDialog @@ -26,7 +26,11 @@ class ActivateDialog : public QDialog
{
Q_OBJECT
public:
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
ActivateDialog(QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
#else
ActivateDialog(QWidget* parent = nullptr, Qt::WindowFlags f = nullptr);
#endif
bool event(QEvent* event) override;
signals:

Loading…
Cancel
Save