Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

二次改变截取区域大小的时候 Magnifier 中显示的颜色是截图边框的颜色 #58

Closed
cs2130 opened this issue Jun 8, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@cs2130
Copy link

cs2130 commented Jun 8, 2024

QPixmap Magnifier::grab() const
{
const auto rect = grabRect();
if (desktop_.isNull()) {
return QGuiApplication::primaryScreen()->grabWindow(
probe::graphics::virtual_screen().handle, rect.x(), rect.y(), rect.width(), rect.height());
}

return desktop_.copy(rect);

}

@ffiirree
Copy link
Owner

ffiirree commented Jun 8, 2024

是个bug,谢谢

@ffiirree ffiirree added the bug Something isn't working label Jun 8, 2024
@cs2130
Copy link
Author

cs2130 commented Jun 9, 2024

简单修复了一下,自己先用着, 感谢开源了这么好的截图软件!

void Selector::mousePressEvent(QMouseEvent *event)
{
    auto pos = event->globalPos();
    if (event->button() == Qt::LeftButton && status_ != SelectorStatus::LOCKED) {
        cursor_pos_ = box_.absolutePos(pos);
        switch (status_) {
        case SelectorStatus::PREY_SELECTING:
#ifdef _WIN32
            if (scope_ == scope_t::display) {
                auto display = probe::graphics::display_contains(pos);
                if (display.has_value()) {
                    box_.range(display.value().geometry);
                }
            }
#endif 
            sbegin_ = pos;
            status(SelectorStatus::PREY_SELECTING | SelectorStatus::FREE_SELECTING);
            break;

        case SelectorStatus::CAPTURED:
            if (cursor_pos_ == ResizerLocation::EMPTY_INSIDE) {
                move_spos_ = move_epos_ = pos;
                status(SelectorStatus::MOVING);
            }
            else if (!!(cursor_pos_ & ResizerLocation::ADJUST_AREA)) {
                emit resizeFresh(); //-- 改变窗口大小,刷新
                status(SelectorStatus::RESIZING);
            }
            break;

        default: loge("error status"); break;
        }
    }
}
connect(selector_, &Selector::resizeFresh, this, [this]() {
        const auto menuv = menu_->isVisible();
        if (menuv) { menu_->hide(); }
        auto pixmap = QPixmap::fromImage(backgroundBrush().textureImage());
        QPainter painter(&pixmap);
        scene()->render(&painter, pixmap.rect());
        magnifier_->setGrabPixmap(pixmap);
    });

@ffiirree
Copy link
Owner

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants