Added magnifier for more precise selections (#2219)

* added a magnifierwidget

* added option to show magnifier and added option to switch to square shaped magnifier

* integrated magnifierwidget into capture

this could probably be done in a nicer way.
right now the magnifier wont show if you select via the move tool.

Co-authored-by: Silas Dohm <silas@sdohm.xyz>
This commit is contained in:
SilasDo
2022-02-06 02:51:28 +01:00
committed by GitHub
parent 4affa92b91
commit cf08755c8b
9 changed files with 252 additions and 0 deletions

View File

@@ -67,6 +67,7 @@ CaptureWidget::CaptureWidget(const CaptureRequest& req,
, m_panel(nullptr)
, m_sidePanel(nullptr)
, m_selection(nullptr)
, m_magnifier(nullptr)
, m_existingObjectIsChanged(false)
, m_startMove(false)
, m_toolSizeByKeyboard(0)
@@ -181,6 +182,10 @@ CaptureWidget::CaptureWidget(const CaptureRequest& req,
initButtons();
initSelection(); // button handler must be initialized before
initShortcuts(); // must be called after initSelection
// init magnify
if (m_config.showMagnifier())
m_magnifier = new MagnifierWidget(
m_context.screenshot, m_uiColor, m_config.squareMagnifier(), this);
// Init color picker
m_colorPicker = new ColorPicker(this);
@@ -679,6 +684,15 @@ void CaptureWidget::mouseDoubleClickEvent(QMouseEvent* event)
void CaptureWidget::mouseMoveEvent(QMouseEvent* e)
{
if (m_magnifier) {
if (!m_activeButton) {
m_magnifier->show();
m_magnifier->update();
} else {
m_magnifier->hide();
}
}
m_context.mousePos = e->pos();
if (e->buttons() != Qt::LeftButton) {
updateTool(activeButtonTool());