Fix multi-monitor result and editor positions

Fixes #90
This commit is contained in:
Gres 2022-03-26 16:19:33 +03:00
parent 7d84bd2f7b
commit 4f195f5629
4 changed files with 6 additions and 5 deletions

View File

@ -12,7 +12,8 @@ CaptureArea::CaptureArea(const QRect &rect, const Settings &settings)
{ {
} }
TaskPtr CaptureArea::task(const QPixmap &pixmap) const TaskPtr CaptureArea::task(const QPixmap &pixmap,
const QPoint &pixmapOffset) const
{ {
if (pixmap.isNull() || !isValid()) if (pixmap.isNull() || !isValid())
return {}; return {};
@ -21,7 +22,7 @@ TaskPtr CaptureArea::task(const QPixmap &pixmap) const
task->generation = generation_; task->generation = generation_;
task->useHunspell = useHunspell_; task->useHunspell = useHunspell_;
task->captured = pixmap.copy(rect_); task->captured = pixmap.copy(rect_);
task->capturePoint = rect_.topLeft(); task->capturePoint = pixmapOffset + rect_.topLeft();
task->sourceLanguage = sourceLanguage_; task->sourceLanguage = sourceLanguage_;
if (task->sourceLanguage.isEmpty()) if (task->sourceLanguage.isEmpty())
task->error += QObject::tr("No source language set"); task->error += QObject::tr("No source language set");

View File

@ -11,7 +11,7 @@ class CaptureArea
{ {
public: public:
CaptureArea(const QRect& rect, const Settings& settings); CaptureArea(const QRect& rect, const Settings& settings);
TaskPtr task(const QPixmap& pixmap) const; TaskPtr task(const QPixmap& pixmap, const QPoint& pixmapOffset) const;
void setGeneration(uint generation); void setGeneration(uint generation);
bool isValid() const; bool isValid() const;

View File

@ -339,7 +339,7 @@ void CaptureAreaSelector::customize(const std::shared_ptr<CaptureArea> &area)
edited_ = area; edited_ = area;
editor_->show(); editor_->show();
const auto topLeft = service::geometry::cornerAtPoint( const auto topLeft = service::geometry::cornerAtPoint(
area->rect().center(), editor_->size(), geometry()); area->rect().center(), editor_->size(), QRect({}, size()));
editor_->move(topLeft); editor_->move(topLeft);
update(); update();
} }

View File

@ -91,7 +91,7 @@ void Capturer::selected(const CaptureArea &area)
selector_->hide(); selector_->hide();
SOFT_ASSERT(!pixmap_.isNull(), return manager_.captureCanceled()) SOFT_ASSERT(!pixmap_.isNull(), return manager_.captureCanceled())
auto task = area.task(pixmap_); auto task = area.task(pixmap_, pixmapOffset_);
if (task) if (task)
manager_.captured(task); manager_.captured(task);
else else