mirror of
https://git.code.sf.net/p/newrpl/sources
synced 2024-11-16 19:51:25 +01:00
Fixed high DPI scaling for Android
This commit is contained in:
parent
c5616cdf1b
commit
82be9920e3
1 changed files with 13 additions and 4 deletions
|
@ -138,15 +138,24 @@ void MainWindow::resizeEvent(QResizeEvent *event)
|
|||
int w,h;
|
||||
qreal scale;
|
||||
|
||||
|
||||
//qreal realdpi=qApp->primaryScreen()->logicalDotsPerInch();
|
||||
qreal dpratio=qApp->primaryScreen()->devicePixelRatio();
|
||||
w=ui->EmuScreen->screen_width;
|
||||
h=ui->EmuScreen->screen_height+5;
|
||||
if(!h) h=85;
|
||||
if(!w) w=131;
|
||||
scale=((qreal)event->size().width())/w;
|
||||
qreal dpwidth=event->size().width();
|
||||
qreal realwidth=dpwidth*dpratio;
|
||||
scale=realwidth/w;
|
||||
if((int)scale<1) scale=1.0;
|
||||
if(event->size().height()*0.38<scale*h) scale=event->size().height()*0.38/h;
|
||||
ui->EmuScreen->setScale((int)scale);
|
||||
else scale=(int)scale;
|
||||
if(event->size().height()*0.38*dpratio<scale*h) {
|
||||
scale=event->size().height()*0.38*dpratio/h;
|
||||
if((int)scale<1) scale=1.0;
|
||||
else scale=(int)scale;
|
||||
}
|
||||
// NOW CONVERT BACK TO dp SCALE
|
||||
ui->EmuScreen->setScale(scale/dpratio);
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue