diff --git a/CMakeLists.txt b/CMakeLists.txt index c793ca083..04fc8ce8d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -106,7 +106,11 @@ set(QT_LIBRARIES if (UNIX AND NOT APPLE) list(APPEND QT_LIBRARIES DBus) endif() -find_package(QT NAMES Qt6 Qt5 REQUIRED +find_package(QT + NAMES + Qt6 + Qt5 + REQUIRED COMPONENTS ${QT_LIBRARIES} OPTIONAL_COMPONENTS diff --git a/app/dialog/task/task.cpp b/app/dialog/task/task.cpp index 2cc6fc063..aab2b2979 100644 --- a/app/dialog/task/task.cpp +++ b/app/dialog/task/task.cpp @@ -56,7 +56,13 @@ void TaskDialog::showEvent(QShowEvent *e) this, &TaskDialog::TaskFinished, Qt::QueuedConnection); // Run task in another thread with QtConcurrent - task_watcher->setFuture(QtConcurrent::run(&Task::Start, task_)); + task_watcher->setFuture( +#if QT_VERSION_MAJOR >= 6 + QtConcurrent::run(&Task::Start, task_) +#else + QtConcurrent::run(task_, &Task::Start) +#endif + ); already_shown_ = true; } diff --git a/app/task/taskmanager.cpp b/app/task/taskmanager.cpp index d961a7b5a..5d2be1036 100644 --- a/app/task/taskmanager.cpp +++ b/app/task/taskmanager.cpp @@ -93,7 +93,13 @@ void TaskManager::AddTask(Task* t) tasks_.insert(watcher, t); // Run task concurrently - watcher->setFuture(QtConcurrent::run(&Task::Start, t)); + watcher->setFuture( +#if QT_VERSION_MAJOR >= 6 + QtConcurrent::run(&Task::Start, t) +#else + QtConcurrent::run(t, &Task::Start) +#endif + ); // Emit signal that a Task was added emit TaskAdded(t); diff --git a/app/widget/handmovableview/handmovableview.cpp b/app/widget/handmovableview/handmovableview.cpp index 231a75a65..d7b748195 100644 --- a/app/widget/handmovableview/handmovableview.cpp +++ b/app/widget/handmovableview/handmovableview.cpp @@ -61,7 +61,7 @@ bool HandMovableView::HandPress(QMouseEvent *event) // Transform mouse event to act like the left button is pressed QMouseEvent transformed(event->type(), - event->localPos(), + event->pos(), Qt::LeftButton, Qt::LeftButton, event->modifiers()); @@ -83,15 +83,15 @@ bool HandMovableView::HandMove(QMouseEvent *event) QPoint adjustment(0, 0); QMouseEvent transformed(event->type(), - event->localPos() - transformed_pos_, + event->pos() - transformed_pos_, Qt::LeftButton, Qt::LeftButton, event->modifiers()); - if (event->localPos().x() < 0) { + if (event->pos().x() < 0) { transformed_pos_.setX(transformed_pos_.x() + width()); adjustment.setX(width()); - } else if (event->localPos().x() >= width()) { + } else if (event->pos().x() >= width()) { transformed_pos_.setX(transformed_pos_.x() - width()); adjustment.setX(-width()); } @@ -118,14 +118,13 @@ bool HandMovableView::HandRelease(QMouseEvent *event) if (dragging_hand_) { // Transform mouse event to act like the left button is pressed QMouseEvent transformed(event->type(), - event->position(), - event->scenePosition(), - event->globalPosition(), + event->localPos(), + event->windowPos(), + event->screenPos(), Qt::LeftButton, Qt::LeftButton, event->modifiers(), - event->source(), - event->pointingDevice()); + event->source()); super::mouseReleaseEvent(&transformed); diff --git a/app/widget/viewer/viewerdisplay.cpp b/app/widget/viewer/viewerdisplay.cpp index fcbc6553d..cd75d91e2 100644 --- a/app/widget/viewer/viewerdisplay.cpp +++ b/app/widget/viewer/viewerdisplay.cpp @@ -1129,11 +1129,12 @@ void ViewerDisplayWidget::ForwardDragEventToTextEdit(T *e) if constexpr (std::is_same_v) { text_edit_->dragLeaveEvent(e); } else { - T relay(AdjustPosByVAlign(GetVirtualPosForTextEdit(e->position())).toPoint(), + + T relay(AdjustPosByVAlign(GetVirtualPosForTextEdit(e->pos())).toPoint(), e->possibleActions(), e->mimeData(), - e->buttons(), - e->modifiers()); + e->mouseButtons(), + e->keyboardModifiers()); if (e->type() == QEvent::DragEnter) { text_edit_->dragEnterEvent(static_cast(&relay)); @@ -1152,7 +1153,7 @@ void ViewerDisplayWidget::ForwardDragEventToTextEdit(T *e) bool ViewerDisplayWidget::ForwardMouseEventToTextEdit(QMouseEvent *event, bool check_if_outside) { // Transform screen mouse coords to world mouse coords - QPointF local_pos = GetVirtualPosForTextEdit(event->position()); + QPointF local_pos = GetVirtualPosForTextEdit(event->pos()); if (check_if_outside) { if (local_pos.x() < 0 || local_pos.x() >= text_edit_->width() || local_pos.y() < 0 || local_pos.y() >= text_edit_->height()) { @@ -1163,7 +1164,7 @@ bool ViewerDisplayWidget::ForwardMouseEventToTextEdit(QMouseEvent *event, bool c local_pos = AdjustPosByVAlign(local_pos); - QMouseEvent derived(event->type(), local_pos, event->scenePosition(), event->globalPosition(), event->button(), event->buttons(), event->modifiers(), event->source(), event->pointingDevice()); + QMouseEvent derived(event->type(), local_pos, event->windowPos(), event->screenPos(), event->button(), event->buttons(), event->modifiers(), event->source()); return ForwardEventToTextEdit(&derived); } diff --git a/app/widget/viewer/viewertexteditor.cpp b/app/widget/viewer/viewertexteditor.cpp index 8dcbdf6bc..7c8c27fad 100644 --- a/app/widget/viewer/viewertexteditor.cpp +++ b/app/widget/viewer/viewertexteditor.cpp @@ -160,7 +160,7 @@ void ViewerTextEditor::UpdateToolBar(ViewerTextEditorToolBar *toolbar, const QTe } QString style = f.fontStyleName().toString(); - QStringList styles = QFontDatabase::styles(family); + QStringList styles = QFontDatabase().styles(family); if (!styles.isEmpty() && (style.isEmpty() || !styles.contains(style))) { // There seems to be no better way to find the "regular" style outside of this heuristic. // Feel free to add more if a font isn't working right. @@ -267,8 +267,8 @@ void ViewerTextEditor::ApplyStyle(QTextCharFormat *format, const QString &family { // NOTE: Windows appears to require setting weight and italic manually, while macOS and Linux are // perfectly fine with just the style name - format->setFontWeight(QFontDatabase::weight(family, style)); - format->setFontItalic(QFontDatabase::italic(family, style)); + format->setFontWeight(QFontDatabase().weight(family, style)); + format->setFontItalic(QFontDatabase().italic(family, style)); format->setFontStyleName(style); } @@ -536,7 +536,7 @@ void ViewerTextEditorToolBar::UpdateFontStyleList(const QString &family) style_combo_->blockSignals(true); style_combo_->clear(); - QStringList l = QFontDatabase::styles(family); + QStringList l = QFontDatabase().styles(family); foreach (const QString &style, l) { style_combo_->addItem(style); }