fix: get grab rect error

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

View file

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

View file

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