[Spreadsheet] Replace override cursor with QGraphicsItem::setCursor (#22097)
* [Spreadsheet] Replace the risky use of override cursor with QGraphicsItem::setCursor * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -60,19 +60,18 @@ using namespace App;
|
||||
void SheetViewHeader::mouseMoveEvent(QMouseEvent* e)
|
||||
{
|
||||
// for some reason QWidget::setCursor() has no effect in QGraphicsView
|
||||
// therefore we resort to override cursor
|
||||
// therefore we resort to QGraphicsItem::setCursor
|
||||
const QCursor currentCursor = this->cursor();
|
||||
QHeaderView::mouseMoveEvent(e);
|
||||
const QCursor newerCursor = this->cursor();
|
||||
if (newerCursor != currentCursor) {
|
||||
qApp->setOverrideCursor(newerCursor);
|
||||
Q_EMIT cursorChanged(newerCursor);
|
||||
}
|
||||
}
|
||||
|
||||
void SheetViewHeader::mouseReleaseEvent(QMouseEvent* event)
|
||||
{
|
||||
QHeaderView::mouseReleaseEvent(event);
|
||||
qApp->setOverrideCursor(Qt::ArrowCursor);
|
||||
Q_EMIT resizeFinished();
|
||||
}
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@ public:
|
||||
}
|
||||
Q_SIGNALS:
|
||||
void resizeFinished();
|
||||
void cursorChanged(QCursor);
|
||||
|
||||
protected:
|
||||
void mouseMoveEvent(QMouseEvent* e) override;
|
||||
|
||||
@@ -122,6 +122,18 @@ ZoomableView::ZoomableView(Ui::Sheet* ui)
|
||||
});
|
||||
|
||||
resetZoom();
|
||||
|
||||
auto connectCursorChangedSignal = [this](QHeaderView* hv) {
|
||||
auto header = qobject_cast<SpreadsheetGui::SheetViewHeader*>(hv);
|
||||
connect(header,
|
||||
&SpreadsheetGui::SheetViewHeader::cursorChanged,
|
||||
this,
|
||||
[this](const QCursor& newerCursor) {
|
||||
qpw->setCursor(newerCursor);
|
||||
});
|
||||
};
|
||||
connectCursorChangedSignal(stv->horizontalHeader());
|
||||
connectCursorChangedSignal(stv->verticalHeader());
|
||||
}
|
||||
|
||||
int ZoomableView::zoomLevel() const
|
||||
|
||||
Reference in New Issue
Block a user