various: ensure qt 5 compatibility
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -1129,11 +1129,12 @@ void ViewerDisplayWidget::ForwardDragEventToTextEdit(T *e)
|
||||
if constexpr (std::is_same_v<T, QDragLeaveEvent>) {
|
||||
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<QDragEnterEvent*>(&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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user