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;
|
rect_ = rect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString CaptureArea::toolTip() const
|
||||||
|
{
|
||||||
|
return doTranslation_ ? sourceLanguage_ + "->" + targetLanguage_
|
||||||
|
: sourceLanguage_;
|
||||||
|
}
|
||||||
|
@ -17,6 +17,8 @@ public:
|
|||||||
const QRect& rect() const;
|
const QRect& rect() const;
|
||||||
void setRect(const QRect& rect);
|
void setRect(const QRect& rect);
|
||||||
|
|
||||||
|
QString toolTip() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class CaptureAreaEditor;
|
friend class CaptureAreaEditor;
|
||||||
|
|
||||||
|
@ -86,9 +86,8 @@ void CaptureAreaSelector::paintEvent(QPaintEvent * /*event*/)
|
|||||||
if (!selection.isValid())
|
if (!selection.isValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
painter.setBrush({});
|
const auto area = CaptureArea(selection, settings_);
|
||||||
painter.setPen(Qt::red);
|
drawCaptureArea(painter, area);
|
||||||
painter.drawRect(selection);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CaptureAreaSelector::updateCurrentHelpRects()
|
bool CaptureAreaSelector::updateCurrentHelpRects()
|
||||||
@ -128,13 +127,24 @@ void CaptureAreaSelector::drawHelpRects(QPainter &painter,
|
|||||||
void CaptureAreaSelector::drawCaptureArea(QPainter &painter,
|
void CaptureAreaSelector::drawCaptureArea(QPainter &painter,
|
||||||
const CaptureArea &area) const
|
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.setBrush(QBrush(QColor(200, 200, 200, 50)));
|
||||||
painter.setPen(Qt::NoPen);
|
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.setBrush({});
|
||||||
painter.setPen(Qt::red);
|
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*/)
|
void CaptureAreaSelector::showEvent(QShowEvent * /*event*/)
|
||||||
|
Loading…
Reference in New Issue
Block a user