fix: get grab rect error

This commit is contained in:
rankun 2020-05-06 16:51:01 +08:00
parent f2f8c462fb
commit f0ce346406
2 changed files with 12 additions and 9 deletions

View file

@ -215,18 +215,21 @@ void Device::initSignals()
// update ui
if (m_videoForm) {
// must be show before updateShowSize
m_videoForm->show();
m_videoForm->setWindowTitle(deviceName);
m_videoForm->updateShowSize(size);
bool deviceVer = size.height() > size.width();
QRect rc = Config::getInstance().getRect(getSerial());
if (rc.isValid()) {
m_videoForm->move(rc.topLeft());
bool rcVer = rc.height() > rc.width();
// same width/height rate
if (rc.isValid() && (deviceVer == rcVer)) {
// mark: resize is for fix setGeometry magneticwidget bug
m_videoForm->resize(rc.size());
// TODO: setGeometry magneticwidget bug
//m_videoForm->setGeometry(rc);
m_videoForm->setGeometry(rc);
}
// videoForm delay show
m_videoForm->show();
}
// init recorder

View file

@ -88,14 +88,14 @@ QRect VideoForm::getGrabCursorRect()
{
QRect rc;
#if defined(Q_OS_WIN32)
rc = QRect(m_videoWidget->mapToGlobal(m_videoWidget->pos()), m_videoWidget->size());
rc = QRect(ui->keepRadioWidget->mapToGlobal(m_videoWidget->pos()), m_videoWidget->size());
// high dpi support
rc.setTopLeft(rc.topLeft() * m_videoWidget->devicePixelRatio());
rc.setBottomRight(rc.bottomRight() * m_videoWidget->devicePixelRatio());
#elif defined(Q_OS_OSX)
rc = m_videoWidget->geometry();
rc.setTopLeft(m_videoWidget->mapToGlobal(rc.topLeft()));
rc.setBottomRight(m_videoWidget->mapToGlobal(rc.bottomRight()));
rc.setTopLeft(ui->keepRadioWidget->mapToGlobal(rc.topLeft()));
rc.setBottomRight(ui->keepRadioWidget->mapToGlobal(rc.bottomRight()));
rc.setX(rc.x() + 100);
rc.setY(rc.y() + 30);
rc.setWidth(rc.width() - 180);