diff --git a/UI/hotkey-edit.cpp b/UI/hotkey-edit.cpp index d2846f97a..5307c0ca4 100644 --- a/UI/hotkey-edit.cpp +++ b/UI/hotkey-edit.cpp @@ -419,7 +419,11 @@ static inline void updateStyle(QWidget *widget) widget->update(); } +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +void OBSHotkeyWidget::enterEvent(QEnterEvent *event) +#else void OBSHotkeyWidget::enterEvent(QEvent *event) +#endif { if (!label) return; @@ -448,7 +452,11 @@ void OBSHotkeyLabel::highlightPair(bool highlight) updateStyle(this); } +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +void OBSHotkeyLabel::enterEvent(QEnterEvent *event) +#else void OBSHotkeyLabel::enterEvent(QEvent *event) +#endif { if (!pairPartner) return; diff --git a/UI/hotkey-edit.hpp b/UI/hotkey-edit.hpp index b6e1c1411..c625e3a8e 100644 --- a/UI/hotkey-edit.hpp +++ b/UI/hotkey-edit.hpp @@ -36,7 +36,11 @@ public: QPointer pairPartner; QPointer widget; void highlightPair(bool highlight); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + void enterEvent(QEnterEvent *event) override; +#else void enterEvent(QEvent *event) override; +#endif void leaveEvent(QEvent *event) override; void setToolTip(const QString &toolTip); }; @@ -131,7 +135,11 @@ public: void Save(); void Save(std::vector &combinations); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + void enterEvent(QEnterEvent *event) override; +#else void enterEvent(QEvent *event) override; +#endif void leaveEvent(QEvent *event) override; private: diff --git a/UI/log-viewer.cpp b/UI/log-viewer.cpp index 837d6a971..ca3e4c00b 100644 --- a/UI/log-viewer.cpp +++ b/UI/log-viewer.cpp @@ -101,7 +101,11 @@ void OBSLogViewer::InitLog() if (file.open(QIODevice::ReadOnly)) { QTextStream in(&file); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + in.setEncoding(QStringConverter::Utf8); +#else in.setCodec("UTF-8"); +#endif while (!in.atEnd()) { QString line = in.readLine(); diff --git a/UI/qt-wrappers.cpp b/UI/qt-wrappers.cpp index 6967f5a73..545272739 100644 --- a/UI/qt-wrappers.cpp +++ b/UI/qt-wrappers.cpp @@ -31,7 +31,6 @@ #if !defined(_WIN32) && !defined(__APPLE__) #include -#include #endif #ifdef ENABLE_WAYLAND diff --git a/UI/qt-wrappers.hpp b/UI/qt-wrappers.hpp index 5042487e0..89948df06 100644 --- a/UI/qt-wrappers.hpp +++ b/UI/qt-wrappers.hpp @@ -28,7 +28,12 @@ #include #include +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +#define QT_UTF8(str) QString::fromUtf8(str, -1) +#else #define QT_UTF8(str) QString::fromUtf8(str) +#endif + #define QT_TO_UTF8(str) str.toUtf8().constData() class QDataStream; diff --git a/UI/source-tree.cpp b/UI/source-tree.cpp index 46f5c247d..f7dd79ce2 100644 --- a/UI/source-tree.cpp +++ b/UI/source-tree.cpp @@ -147,7 +147,7 @@ SourceTreeItem::SourceTreeItem(SourceTree *tree_, OBSSceneItem sceneitem_) void SourceTreeItem::paintEvent(QPaintEvent *event) { QStyleOption opt; - opt.init(this); + opt.initFrom(this); QPainter p(this); style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); @@ -305,7 +305,11 @@ void SourceTreeItem::mouseDoubleClickEvent(QMouseEvent *event) } } +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +void SourceTreeItem::enterEvent(QEnterEvent *event) +#else void SourceTreeItem::enterEvent(QEvent *event) +#endif { QWidget::enterEvent(event); diff --git a/UI/source-tree.hpp b/UI/source-tree.hpp index 329108f94..c0fdcbfd8 100644 --- a/UI/source-tree.hpp +++ b/UI/source-tree.hpp @@ -32,7 +32,11 @@ class SourceTreeItem : public QWidget { friend class SourceTreeModel; void mouseDoubleClickEvent(QMouseEvent *event) override; +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + void enterEvent(QEnterEvent *event) override; +#else void enterEvent(QEvent *event) override; +#endif void leaveEvent(QEvent *event) override; virtual bool eventFilter(QObject *object, QEvent *event) override; diff --git a/UI/window-basic-main.cpp b/UI/window-basic-main.cpp index 5a3984d60..5d91c777d 100644 --- a/UI/window-basic-main.cpp +++ b/UI/window-basic-main.cpp @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include @@ -73,7 +72,6 @@ #include #include -#include #include #include @@ -207,8 +205,10 @@ extern void RegisterRestreamAuth(); OBSBasic::OBSBasic(QWidget *parent) : OBSMainWindow(parent), ui(new Ui::OBSBasic) { +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) qRegisterMetaTypeStreamOperators>( "SignalContainer"); +#endif setAttribute(Qt::WA_NativeWindow); @@ -263,10 +263,12 @@ OBSBasic::OBSBasic(QWidget *parent) qRegisterMetaType("obs_hotkey_id"); qRegisterMetaType("SavedProjectorInfo *"); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) qRegisterMetaTypeStreamOperators>>( "std::vector>"); qRegisterMetaTypeStreamOperators("OBSScene"); qRegisterMetaTypeStreamOperators("OBSSceneItem"); +#endif ui->scenes->setAttribute(Qt::WA_MacShowFocusRect, false); ui->sources->setAttribute(Qt::WA_MacShowFocusRect, false); @@ -384,7 +386,8 @@ OBSBasic::OBSBasic(QWidget *parent) QRect windowGeometry = normalGeometry(); if (!WindowPositionValid(windowGeometry)) { - QRect rect = App()->desktop()->geometry(); + QRect rect = + QGuiApplication::primaryScreen()->geometry(); setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, size(), rect)); @@ -7286,7 +7289,8 @@ void OBSBasic::OpenSavedProjector(SavedProjectorInfo *info) projector->restoreGeometry(byteArray); if (!WindowPositionValid(projector->normalGeometry())) { - QRect rect = App()->desktop()->geometry(); + QRect rect = QGuiApplication::primaryScreen() + ->geometry(); projector->setGeometry(QStyle::alignedRect( Qt::LeftToRight, Qt::AlignCenter, size(), rect)); diff --git a/UI/window-basic-settings.cpp b/UI/window-basic-settings.cpp index a377a1121..6062c5f95 100644 --- a/UI/window-basic-settings.cpp +++ b/UI/window-basic-settings.cpp @@ -904,8 +904,8 @@ OBSBasicSettings::OBSBasicSettings(QWidget *parent) channelIndex = ui->channelSetup->currentIndex(); sampleRateIndex = ui->sampleRate->currentIndex(); - QRegExp rx("\\d{1,5}x\\d{1,5}"); - QValidator *validator = new QRegExpValidator(rx, this); + QRegularExpression rx("\\d{1,5}x\\d{1,5}"); + QValidator *validator = new QRegularExpressionValidator(rx, this); ui->baseResolution->lineEdit()->setValidator(validator); ui->outputResolution->lineEdit()->setValidator(validator); } diff --git a/UI/window-basic-stats.cpp b/UI/window-basic-stats.cpp index 90995ec70..b749d2862 100644 --- a/UI/window-basic-stats.cpp +++ b/UI/window-basic-stats.cpp @@ -6,12 +6,12 @@ #include "obs-app.hpp" #include "qt-wrappers.hpp" -#include #include #include #include #include #include +#include #include @@ -204,7 +204,8 @@ OBSBasicStats::OBSBasicStats(QWidget *parent, bool closeable) QRect windowGeometry = normalGeometry(); if (!WindowPositionValid(windowGeometry)) { - QRect rect = App()->desktop()->geometry(); + QRect rect = + QGuiApplication::primaryScreen()->geometry(); setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, size(), rect)); diff --git a/UI/window-missing-files.cpp b/UI/window-missing-files.cpp index 65b920b25..c202dd7e3 100644 --- a/UI/window-missing-files.cpp +++ b/UI/window-missing-files.cpp @@ -68,7 +68,7 @@ QWidget *MissingFilesPathItemDelegate::createEditor( }; QHBoxLayout *layout = new QHBoxLayout(); - layout->setMargin(0); + layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(0); QLineEdit *text = new QLineEdit();