Changeset View
Changeset View
Standalone View
Standalone View
lib/documentview/documentview.cpp
Show First 20 Lines • Show All 637 Lines • ▼ Show 20 Line(s) | |||||
638 | void DocumentView::paint(QPainter* painter, const QStyleOptionGraphicsItem* /*option*/, QWidget* /*widget*/) | 638 | void DocumentView::paint(QPainter* painter, const QStyleOptionGraphicsItem* /*option*/, QWidget* /*widget*/) | ||
639 | { | 639 | { | ||
640 | // Fill background manually, because setAutoFillBackground(true) fill with QPalette::Window, | 640 | // Fill background manually, because setAutoFillBackground(true) fill with QPalette::Window, | ||
641 | // but our palettes use QPalette::Base for the background color/texture | 641 | // but our palettes use QPalette::Base for the background color/texture | ||
642 | painter->fillRect(rect(), palette().base()); | 642 | painter->fillRect(rect(), palette().base()); | ||
643 | 643 | | |||
644 | // Selection indicator/highlight | 644 | // Selection indicator/highlight | ||
645 | if (d->mCompareMode && d->mCurrent) { | 645 | if (d->mCompareMode && d->mCurrent) { | ||
646 | QRectF visibleRect = mapRectFromItem(d->mAdapter->widget(), d->mAdapter->visibleDocumentRect()); | | |||
647 | painter->save(); | 646 | painter->save(); | ||
648 | painter->setBrush(Qt::NoBrush); | 647 | painter->setBrush(Qt::NoBrush); | ||
649 | painter->setPen(QPen(palette().highlight().color(), 2)); | 648 | painter->setPen(QPen(palette().highlight().color(), 2)); | ||
650 | painter->setRenderHint(QPainter::Antialiasing); | 649 | painter->setRenderHint(QPainter::Antialiasing); | ||
651 | QRectF selectionRect = visibleRect.adjusted(-2, -2, 2, 2); | 650 | const QRectF visibleRectF = mapRectFromItem(d->mAdapter->widget(), d->mAdapter->visibleDocumentRect()); | ||
651 | // Round the point and size independently. This is different than calling toRect(), | ||||
652 | // and is necessary to keep consistent rects, otherwise the selection rect can be | ||||
653 | // drawn 1 pixel too big or small. | ||||
654 | const QRect visibleRect = QRect(visibleRectF.topLeft().toPoint(), visibleRectF.size().toSize()); | ||||
655 | const QRect selectionRect = visibleRect.adjusted(-1, -1, 1, 1); | ||||
652 | painter->drawRoundedRect(selectionRect, 3, 3); | 656 | painter->drawRoundedRect(selectionRect, 3, 3); | ||
653 | painter->restore(); | 657 | painter->restore(); | ||
654 | } | 658 | } | ||
655 | } | 659 | } | ||
656 | 660 | | |||
657 | void DocumentView::slotBusyChanged(const QUrl&, bool busy) | 661 | void DocumentView::slotBusyChanged(const QUrl&, bool busy) | ||
658 | { | 662 | { | ||
659 | if (busy) { | 663 | if (busy) { | ||
▲ Show 20 Lines • Show All 164 Lines • Show Last 20 Lines |