Skip to content

Commit

Permalink
add option font dpi -1 == disable (this is something else than 100%, …
Browse files Browse the repository at this point in the history
…argh)
  • Loading branch information
Consti10 committed Dec 3, 2023
1 parent eec88db commit b02d3c5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
15 changes: 9 additions & 6 deletions app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,21 +222,24 @@ int main(int argc, char *argv[]) {
settings.setValue("dev_always_use_generic_external_decode_service",true);
}
}

const int screen_custom_font_dpi = settings.value("screen_custom_font_dpi").toInt();
if (screen_custom_font_dpi) {
if(screen_custom_font_dpi<0){
// Disabled
QCoreApplication::setAttribute(Qt::AA_DisableHighDpiScaling);
}else if(screen_custom_font_dpi==0){
// Enabled (whatever qt thinks it wanna do on auto). Works on android, on other devices, meh
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
}else{
// Custom font dpi set by the user
QCoreApplication::setAttribute(Qt::AA_DisableHighDpiScaling);
const std::string font_dpi_s = std::to_string(screen_custom_font_dpi);
qputenv("QT_FONT_DPI", QByteArray(font_dpi_s.c_str(), font_dpi_s.length()));
} else {
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
}
//QCoreApplication::setAttribute(Qt::AA_UseOpenGLES);
//QCoreApplication::setAttribute(Qt::AA_DisableHighDpiScaling);
const double global_scale = settings.value("global_scale", 1.0).toDouble();
const std::string global_scale_s = std::to_string(global_scale);
QByteArray scaleAsQByteArray(global_scale_s.c_str(), global_scale_s.length());
qputenv("QT_SCALE_FACTOR", scaleAsQByteArray);
qputenv("QT_SCALE_FACTOR", QByteArray(global_scale_s.c_str(), global_scale_s.length()));

// https://doc.qt.io/qt-6/qtquick-visualcanvas-scenegraph-renderer.html
//qputenv("QSG_VISUALIZE", "overdraw");
Expand Down
10 changes: 6 additions & 4 deletions qml/ui/configpopup/qopenhd_settings/AppScreenSettingsView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ ScrollView {
anchors.horizontalCenter: parent.horizonatalCenter
width: 320
model: ListModel {
id: font_dpi
ListElement { text: qsTr("-1 Disable") ; value: -1 }
ListElement { text: qsTr("0 Auto (Recommended)") ; value: 0 }
ListElement { text: qsTr("50 (ultra small)") ; value: 50 }
ListElement { text: qsTr("72 (smaller)") ; value: 72 }
Expand All @@ -145,12 +145,14 @@ ScrollView {
}
}
}
onCurrentIndexChanged: {
const value_fdpi = font_dpi.get(currentIndex).value
onActivated:{
const value_fdpi = model.get(currentIndex).value
if(settings.screen_custom_font_dpi != value_fdpi){
console.log("font dpi changed from :"+settings.screen_custom_font_dpi+" to:"+value_fdpi);
_restartqopenhdmessagebox.show();
settings.screen_custom_font_dpi = value_fdpi
}
settings.screen_custom_font_dpi = value_fdpi

}
}
}
Expand Down

0 comments on commit b02d3c5

Please sign in to comment.