Show current languages for capture area
This commit is contained in:
parent
1ff3fb1f1b
commit
ac1267c88d
@ -42,3 +42,9 @@ void CaptureArea::setRect(const QRect &rect)
|
||||
{
|
||||
rect_ = rect;
|
||||
}
|
||||
|
||||
QString CaptureArea::toolTip() const
|
||||
{
|
||||
return doTranslation_ ? sourceLanguage_ + "->" + targetLanguage_
|
||||
: sourceLanguage_;
|
||||
}
|
||||
|
@ -17,6 +17,8 @@ public:
|
||||
const QRect& rect() const;
|
||||
void setRect(const QRect& rect);
|
||||
|
||||
QString toolTip() const;
|
||||
|
||||
private:
|
||||
friend class CaptureAreaEditor;
|
||||
|
||||
|
@ -86,9 +86,8 @@ void CaptureAreaSelector::paintEvent(QPaintEvent * /*event*/)
|
||||
if (!selection.isValid())
|
||||
return;
|
||||
|
||||
painter.setBrush({});
|
||||
painter.setPen(Qt::red);
|
||||
painter.drawRect(selection);
|
||||
const auto area = CaptureArea(selection, settings_);
|
||||
drawCaptureArea(painter, area);
|
||||
}
|
||||
|
||||
bool CaptureAreaSelector::updateCurrentHelpRects()
|
||||
@ -128,13 +127,24 @@ void CaptureAreaSelector::drawHelpRects(QPainter &painter,
|
||||
void CaptureAreaSelector::drawCaptureArea(QPainter &painter,
|
||||
const CaptureArea &area) const
|
||||
{
|
||||
const auto areaRect = area.rect();
|
||||
const auto toolTip = area.toolTip();
|
||||
auto toolTipRect = painter.boundingRect(QRect(), 0, toolTip);
|
||||
toolTipRect.moveTopLeft(areaRect.topLeft() - QPoint(0, toolTipRect.height()));
|
||||
|
||||
painter.setBrush(QBrush(QColor(200, 200, 200, 50)));
|
||||
painter.setPen(Qt::NoPen);
|
||||
painter.drawRect(area.rect());
|
||||
painter.drawRect(areaRect);
|
||||
|
||||
painter.setBrush(QBrush(QColor(200, 200, 200, 150)));
|
||||
painter.drawRect(toolTipRect);
|
||||
|
||||
painter.setBrush({});
|
||||
painter.setPen(Qt::red);
|
||||
painter.drawRect(area.rect());
|
||||
painter.drawRect(areaRect);
|
||||
|
||||
painter.setPen(Qt::white);
|
||||
painter.drawText(toolTipRect, 0, toolTip);
|
||||
}
|
||||
|
||||
void CaptureAreaSelector::showEvent(QShowEvent * /*event*/)
|
||||
|
Loading…
Reference in New Issue
Block a user