mirror of
https://github.com/barry-ran/QtScrcpy.git
synced 2025-04-21 12:04:59 +00:00
窗口居中
This commit is contained in:
parent
4c873b98e7
commit
8affa1937d
2 changed files with 17 additions and 9 deletions
|
@ -77,16 +77,23 @@ VideoForm::~VideoForm()
|
|||
|
||||
void VideoForm::updateShowSize(const QSize &newSize)
|
||||
{
|
||||
QSize showSize = newSize;
|
||||
QDesktopWidget* desktop = QApplication::desktop();
|
||||
if (desktop) {
|
||||
QSize screenSize = desktop->size();
|
||||
showSize.setWidth(qMin(newSize.width(), screenSize.width()));
|
||||
showSize.setHeight(qMin(newSize.height(), screenSize.height() - 100));
|
||||
}
|
||||
if (frameSize != newSize) {
|
||||
frameSize = newSize;
|
||||
|
||||
if (showSize != size()) {
|
||||
resize(showSize);
|
||||
QSize showSize = newSize;
|
||||
QDesktopWidget* desktop = QApplication::desktop();
|
||||
if (desktop) {
|
||||
QRect screenRect = desktop->availableGeometry();
|
||||
showSize.setWidth(qMin(newSize.width(), screenRect.width()));
|
||||
showSize.setHeight(qMin(newSize.height(), screenRect.height() - 100));
|
||||
|
||||
// 窗口居中
|
||||
move(screenRect.center() - geometry().center());
|
||||
}
|
||||
|
||||
if (showSize != size()) {
|
||||
resize(showSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ protected:
|
|||
|
||||
private:
|
||||
Ui::videoForm *ui;
|
||||
QSize frameSize;
|
||||
Server* m_server = Q_NULLPTR;
|
||||
Decoder m_decoder;
|
||||
Frames m_frames;
|
||||
|
|
Loading…
Add table
Reference in a new issue