Skip to content

Commit

Permalink
Merge pull request supercollider#6464 from dyfer/topic/qt-remove-depr…
Browse files Browse the repository at this point in the history
…ecations-2

QT: remove deprecations for QT 5.15
  • Loading branch information
dyfer authored Sep 13, 2024
2 parents 4dc8de3 + 46175c4 commit b8d6d1d
Show file tree
Hide file tree
Showing 36 changed files with 85 additions and 70 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- job-name: "x64 legacy"
os-version: "12"
xcode-version: "13.4.1"
qt-version: "5.9.9" # will use qt from aqtinstall
qt-version: "5.15.2" # will use qt from aqtinstall
deployment-target: "10.15"
cmake-architectures: x86_64
use-syslibs: false
Expand Down
6 changes: 3 additions & 3 deletions QtCollider/QWidgetProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ void QWidgetProxy::performDrag() {
bool QWidgetProxy::preProcessEvent(QObject* o, QEvent* e, EventHandlerData& eh, QList<QVariant>& args) {
// NOTE We assume that qObject need not be checked here, as we wouldn't get events if
// it wasn't existing
int acquired_globalEventMask = _globalEventMask.load();
int acquired_globalEventMask = _globalEventMask.loadRelaxed();

switch (eh.type) {
case QEvent::KeyPress:
Expand Down Expand Up @@ -340,7 +340,7 @@ bool QWidgetProxy::interpretMouseEvent(QObject* o, QEvent* e, QList<QVariant>& a
case Qt::RightButton:
button = 1;
break;
case Qt::MidButton:
case Qt::MiddleButton:
button = 2;
break;
default:
Expand Down Expand Up @@ -370,7 +370,7 @@ bool QWidgetProxy::interpretMouseWheelEvent(QObject* o, QEvent* e, QList<QVarian
QWheelEvent* we = static_cast<QWheelEvent*>(e);

QWidget* w = widget();
QPoint pt = _mouseEventWidget == w ? we->pos() : _mouseEventWidget->mapTo(w, we->pos());
QPointF pt = _mouseEventWidget == w ? we->position() : _mouseEventWidget->mapTo(w, we->position().toPoint());

// only hi-res trackpads return pixelDelta everything else uses angleDelta..
QPointF delta = we->pixelDelta().isNull() ? we->angleDelta() / 8.f // scaled to return steps of 15
Expand Down
2 changes: 1 addition & 1 deletion QtCollider/QWidgetProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class QWidgetProxy : public QObjectProxy {

public:
static void setGlobalEventEnabled(GlobalEvent ev, bool b) {
int mask = _globalEventMask.load();
int mask = _globalEventMask.loadRelaxed();
if (b)
mask |= ev;
else
Expand Down
1 change: 1 addition & 0 deletions QtCollider/QcCallback.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#pragma once

#include <QObject>
#include <QPointer>

namespace QtCollider {
Expand Down
1 change: 1 addition & 0 deletions QtCollider/QcSignalSpy.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include <QObject>
#include <QMetaObject>
#include <QMetaMethod>
#include <QMetaType>
#include <QVariant>

class QcSignalSpy : public QObject {
Expand Down
2 changes: 1 addition & 1 deletion QtCollider/debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ static QAtomicInt& debugLevelInt() {
}

int QtCollider::debugLevel() {
int l = debugLevelInt().load();
int l = debugLevelInt().loadRelaxed();
return l;
}

Expand Down
2 changes: 1 addition & 1 deletion QtCollider/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ void QtCollider::init() {

#ifdef SC_USE_QTWEBENGINE
// Enable javascript localStorage for WebViews
QWebEngineSettings::globalSettings()->setAttribute(QWebEngineSettings::LocalStorageEnabled, true);
QWebEngineSettings::defaultSettings()->setAttribute(QWebEngineSettings::LocalStorageEnabled, true);
#endif

// NOTE: Qt may tamper with the C language locale, affecting POSIX number-string conversions.
Expand Down
4 changes: 2 additions & 2 deletions QtCollider/layouts/stack_layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,11 +257,11 @@ Qt::Orientations StackLayout::expandingDirections() const {

switch (_mode) {
case StackOne:
directions = _index >= 0 ? _list.at(_index)->expandingDirections() : (Qt::Orientations)0;
directions = _index >= 0 ? _list.at(_index)->expandingDirections() : Qt::Orientations {};
break;

case StackAll: {
Qt::Orientations directions = 0;
Qt::Orientations directions {};
int n = _list.count();
for (int i = 0; i < n; ++i)
directions |= _list.at(i)->expandingDirections();
Expand Down
1 change: 0 additions & 1 deletion QtCollider/primitives/prim_misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
#include <QFontDatabase>
#include <QFontInfo>
#include <QFontMetrics>
#include <QDesktopWidget>
#include <QStyleFactory>
#include <QCursor>
#include <QScreen>
Expand Down
12 changes: 6 additions & 6 deletions QtCollider/safeptr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ template <typename T> class SafePtr {

~SafePtr() { deref(); }

T* operator->() const { return d->ptr.load(); }
T* operator->() const { return d->ptr.loadRelaxed(); }

T& operator*() const { return *d->ptr.load(); }
T& operator*() const { return *d->ptr.loadRelaxed(); }

operator T*() const { return (d ? d->ptr.load() : 0); }
operator T*() const { return (d ? d->ptr.loadRelaxed() : 0); }

T* ptr() const { return (d ? d->ptr.load() : 0); }
T* ptr() const { return (d ? d->ptr.loadRelaxed() : 0); }

void* id() const { return (void*)d; } // useful for checking internal pointer identity

Expand All @@ -73,13 +73,13 @@ template <typename T> class SafePtr {
void ref() {
if (d) {
d->refCount.ref();
qcDebugMsg(2, QString("SafePtr: +refcount = %1").arg(d->refCount.load()));
qcDebugMsg(2, QString("SafePtr: +refcount = %1").arg(d->refCount.loadRelaxed()));
}
}
void deref() {
if (d) {
bool ref = d->refCount.deref();
qcDebugMsg(2, QString("SafePtr: -refcount = %1").arg(d->refCount.load()));
qcDebugMsg(2, QString("SafePtr: -refcount = %1").arg(d->refCount.loadRelaxed()));
if (!ref) {
qcDebugMsg(2, "SafePtr: unreferenced!");
delete d;
Expand Down
6 changes: 3 additions & 3 deletions QtCollider/widgets/QcCanvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void QcCanvas::animate(bool on) {
if (!_animating && _fps > 0) {
_frameCount = 0;
_animating = true;
_meterTime.start();
_meterTime = QTime::currentTime();
_timerId = startTimer(1000.f / _fps);
_fpsTimer.start(_meterPeriod, this);
}
Expand Down Expand Up @@ -169,10 +169,10 @@ void QcCanvas::timerEvent(QTimerEvent* e) {
repaint();
} else if (e->timerId() == _fpsTimer.timerId()) {
// recalc actual fps
float dTime = _meterTime.elapsed();
float dTime = _meterTime.msecsTo(QTime::currentTime());
_fpsActual = (dTime > 0) ? (_meterFrames * 1000.f / dTime) : 0.f;
// reset fps meter
_meterTime.restart();
_meterTime = QTime::currentTime();
_meterFrames = 0;
}
}
2 changes: 1 addition & 1 deletion QtCollider/widgets/QcGraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ private Q_SLOTS:
private:
struct SelectedElement {
SelectedElement(QcGraphElement* e): elem(e) {}
bool operator==(const SelectedElement& other) { return elem == other.elem; }
bool operator==(const SelectedElement& other) const { return elem == other.elem; }

QcGraphElement* elem;
QPointF moveOrigin; // in data domain
Expand Down
7 changes: 5 additions & 2 deletions QtCollider/widgets/QcNumberBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,11 @@ void QcNumberBox::mouseMoveEvent(QMouseEvent* event) {
}

void QcNumberBox::wheelEvent(QWheelEvent* event) {
if (scroll && isReadOnly() && _valueType == Number && event->orientation() == Qt::Vertical) {
stepBy(event->delta() > 0 ? 1 : -1, scrollStep);
if (scroll && isReadOnly() && _valueType == Number && event->angleDelta().x()) {
const QPointF delta = event->pixelDelta().isNull()
? event->angleDelta() / 8.f // scaled to return steps of 15
: event->pixelDelta() * 0.25f; // this matches old scaling of delta
stepBy(delta.x() > 0 ? 1 : -1, scrollStep);
Q_EMIT(action());
}
}
Expand Down
4 changes: 2 additions & 2 deletions QtCollider/widgets/QcPenPrinter.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ class QcPenPrinter : public QObject {

~QcPenPrinter() { delete dialog; }

QRect pageRect() const { return printer.pageRect(); }
QRect paperRect() const { return printer.paperRect(); }
QRect pageRect() const { return printer.pageLayout().paintRectPixels(printer.resolution()); }
QRect paperRect() const { return printer.pageLayout().fullRectPixels(printer.resolution()); }
int fromPage() const { return printer.fromPage(); }
int toPage() const { return printer.toPage(); }

Expand Down
3 changes: 2 additions & 1 deletion QtCollider/widgets/QcSlider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ void QcSlider::mouseMoveEvent(QMouseEvent* e) {
void QcSlider::wheelEvent(QWheelEvent* e) {
double step = qMax(_step, pixelStep());
modifyStep(&step);
double dval = e->delta() / 120.0 * step;
const auto deltaX = e->pixelDelta().isNull() ? e->angleDelta().y() / 8.f : e->pixelDelta().y();
double dval = deltaX / 120.0 * step;
setValue(_value + dval);
Q_EMIT(action());
}
Expand Down
1 change: 0 additions & 1 deletion QtCollider/widgets/QcWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

#include <QShortcut>
#include <QApplication>
#include <QDesktopWidget>
#include <QScreen>

class QcWindowFactory : public QcObjectFactory<QcWindow> {
Expand Down
6 changes: 3 additions & 3 deletions editors/sc-ide/core/doc_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ void Document::setIndentWidth(int numSpaces) {
mIndentWidth = numSpaces;

QFontMetricsF fontMetrics(mDoc->defaultFont());
qreal tabStop = fontMetrics.width(' ') * numSpaces;
qreal tabStop = fontMetrics.horizontalAdvance(' ') * numSpaces;

QTextOption options = mDoc->defaultTextOption();

Expand Down Expand Up @@ -752,7 +752,7 @@ void DocumentManager::handleOpenFileScRequest(const QString& data) {
open(QString(path.c_str()), position, selectionLength, true, id.c_str(), false);
}
} catch (std::exception const& e) {
qWarning() << "DocumentManager::" << __FUNCTION__ << ": could not handle request:" << e.what() << endl;
qWarning() << "DocumentManager::" << __FUNCTION__ << ": could not handle request:" << e.what() << "\n";
return;
}
}
Expand Down Expand Up @@ -780,7 +780,7 @@ void DocumentManager::handleGetDocTextScRequest(const QString& data) {
}
}
} catch (std::exception const& e) {
qWarning() << "DocumentManager::" << __FUNCTION__ << ": could not handle request:" << e.what() << endl;
qWarning() << "DocumentManager::" << __FUNCTION__ << ": could not handle request:" << e.what() << "\n";
return;
}
}
Expand Down
2 changes: 1 addition & 1 deletion editors/sc-ide/core/doc_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ class DocumentManager : public QObject {

DocumentManager(Main*, Settings::Manager*);
QList<Document*> documents() { return mDocHash.values(); }
QList<QByteArray> documentIDs() { return mDocHash.uniqueKeys(); }
QList<QByteArray> documentIDs() { return mDocHash.keys(); }

void create();
void close(Document*);
Expand Down
1 change: 1 addition & 0 deletions editors/sc-ide/core/settings/serialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <boost/iostreams/concepts.hpp>
#include <boost/iostreams/stream.hpp>
#include <iostream>
#include <QIODevice>

namespace ScIDE { namespace Settings {

Expand Down
5 changes: 2 additions & 3 deletions editors/sc-ide/primitives/sc_ipc_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void SCIpcClient::readIDEData() {
avail -= mReadSize;

QDataStream in(baReceived);
in.setVersion(QDataStream::Qt_4_6);
in.setVersion(QDataStream::Qt_5_6);
QString selector;
QVariantList argList;
in >> selector;
Expand Down Expand Up @@ -128,8 +128,7 @@ QString SCIpcClient::getTextMirrorForDocument(QByteArray& id, int pos, int range
QString existingText = mDocumentTextMirrors[id];
if (range == -1)
range = existingText.size() - pos;
QStringRef returnTextRef = QStringRef(&existingText, pos, range);
returnText = returnTextRef.toString();
returnText = existingText.mid(pos, range);
mTextMirrorHashMutex.unlock();
}
} else {
Expand Down
1 change: 1 addition & 0 deletions editors/sc-ide/primitives/sc_ipc_client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <QLocalSocket>
#include <QMutex>
#include <QHash>
#include <QVariantList>

class SCIpcClient : public QObject {
Q_OBJECT
Expand Down
4 changes: 2 additions & 2 deletions editors/sc-ide/widgets/audio_status_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ void AudioStatusBox::onServerRunningChanged(bool running, const QString&, int, b
}

void AudioStatusBox::wheelEvent(QWheelEvent* event) {
if (event->orientation() == Qt::Vertical) {
if (event->delta() > 0)
if (!event->angleDelta().isNull()) {
if (event->angleDelta().x() > 0)
emit increaseVolume();
else
emit decreaseVolume();
Expand Down
10 changes: 6 additions & 4 deletions editors/sc-ide/widgets/code_editor/autocompleter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@
#include <QLabel>
#include <QScrollBar>
#include <QApplication>
#include <QDesktopWidget>
#include <QScreen>
#include <QWindow>
#include <QProxyStyle>
#include <QFile>

namespace ScIDE {

Expand Down Expand Up @@ -157,7 +159,7 @@ class MethodCallWidget : public QWidget {
QWidget* parentWid = parentWidget();
QWidget* referenceWidget = parentWid ? parentWid : this;

QRect screen = QApplication::desktop()->availableGeometry(referenceWidget);
QRect screen = referenceWidget->screen()->availableGeometry();
if (!screen.contains(rect)) {
if (rect.right() > screen.right())
rect.moveRight(screen.right());
Expand Down Expand Up @@ -702,9 +704,9 @@ void AutoCompleter::updateCompletionMenu(bool forceShow) {
if (!mCompletion.text.isEmpty()) {
QString pattern = mCompletion.text;
pattern.prepend("^");
menu->model()->setFilterRegExp(pattern);
menu->model()->setFilterRegularExpression(pattern);
} else
menu->model()->setFilterRegExp(QString());
menu->model()->setFilterRegularExpression(QString());

if (menu->model()->hasChildren()) {
menu->view()->setCurrentIndex(menu->model()->index(0, 0));
Expand Down
13 changes: 6 additions & 7 deletions editors/sc-ide/widgets/code_editor/editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ GenericCodeEditor::GenericCodeEditor(Document* doc, QWidget* parent):

setFrameShape(QFrame::NoFrame);

viewport()->setAttribute(Qt::WA_MacNoClickThrough, true);

mLineIndicator = new LineIndicator(this);
mLineIndicator->move(contentsRect().topLeft());

Expand Down Expand Up @@ -645,7 +643,7 @@ void GenericCodeEditor::mousePressEvent(QMouseEvent* e) {
case Qt::RightButton:
button = 1;
break;
case Qt::MidButton:
case Qt::MiddleButton:
button = 2;
break;
default:
Expand Down Expand Up @@ -674,7 +672,7 @@ void GenericCodeEditor::mouseDoubleClickEvent(QMouseEvent* e) {
case Qt::RightButton:
button = 1;
break;
case Qt::MidButton:
case Qt::MiddleButton:
button = 2;
break;
default:
Expand Down Expand Up @@ -703,7 +701,7 @@ void GenericCodeEditor::mouseReleaseEvent(QMouseEvent* e) {
case Qt::RightButton:
button = 1;
break;
case Qt::MidButton:
case Qt::MiddleButton:
button = 2;
break;
default:
Expand All @@ -730,8 +728,9 @@ void GenericCodeEditor::wheelEvent(QWheelEvent* e) {

// So rather just forward the event without modifiers.

QWheelEvent modifiedEvent(e->pos(), e->globalPos(), e->delta(), e->buttons(), 0, e->orientation());
QPlainTextEdit::wheelEvent(&modifiedEvent);
e->setModifiers(Qt::NoModifier);

QPlainTextEdit::wheelEvent(e);
return;

#if 0
Expand Down
9 changes: 5 additions & 4 deletions editors/sc-ide/widgets/code_editor/editor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <QPlainTextEdit>
#include <QGraphicsScene>
#include <QList>
#include <QRegExp>

namespace ScIDE {

Expand Down Expand Up @@ -56,10 +57,10 @@ class GenericCodeEditor : public QPlainTextEdit {
QTextDocument* textDocument() { return QPlainTextEdit::document(); }
bool showWhitespace();
bool showLinenumber();
bool find(const QRegExp& expr, QTextDocument::FindFlags options = 0);
bool replace(const QRegExp& expr, const QString& replacement, QTextDocument::FindFlags options = 0);
int findAll(const QRegExp& expr, QTextDocument::FindFlags options = 0);
int replaceAll(const QRegExp& expr, const QString& replacement, QTextDocument::FindFlags options = 0);
bool find(const QRegExp& expr, QTextDocument::FindFlags options);
bool replace(const QRegExp& expr, const QString& replacement, QTextDocument::FindFlags options);
int findAll(const QRegExp& expr, QTextDocument::FindFlags options);
int replaceAll(const QRegExp& expr, const QString& replacement, QTextDocument::FindFlags options);

void showPosition(int charPosition, int selectionLength = 0);
QString symbolUnderCursor();
Expand Down
Loading

0 comments on commit b8d6d1d

Please sign in to comment.