spesmilo / electrum

Electrum Bitcoin Wallet
https://electrum.org
MIT License
7.44k stars 3.09k forks source link

Display scaling issue for some elements only (high DPI) #6432

Open Transisto opened 4 years ago

Transisto commented 4 years ago

On Windows 10 The electrum windows always opens on a display with scaling (175%). When moving it to the 1:1 no scaling display the elements keep the same proportions making it almost unreadable.

Some elements are scaled properly some aren't.

image (Some area blanked out intentionally) image image

The workaround is to override system scaling in compatibility settings.

image

Other possibly related : https://github.com/spesmilo/electrum/issues/1927

SomberNight commented 4 years ago

Does this only happen if you move the window between two displays with differing scaling, or does it also happen if you start the application on either display (without moving the running app across them)?

Transisto commented 4 years ago

Between display it's the same proportion but on the higher DPI screen I can read the text easier if look very close.

I was gonna test that but I can't open the wallet on the other display, https://github.com/spesmilo/electrum/issues/6433

SomberNight commented 9 months ago

Note: electron-cash uses high-dpi-related Qt settings, see e.g. https://github.com/Electron-Cash/Electron-Cash/pull/1413 (and follow-ups)

We could try something similar:

diff --git a/electrum/gui/qt/__init__.py b/electrum/gui/qt/__init__.py
index 58c6bee085..2c275342f7 100644
--- a/electrum/gui/qt/__init__.py
+++ b/electrum/gui/qt/__init__.py
@@ -123,6 +123,13 @@ class ElectrumGui(BaseElectrumGui, Logger):
             QtCore.QCoreApplication.setAttribute(QtCore.Qt.AA_ShareOpenGLContexts)
         if hasattr(QGuiApplication, 'setDesktopFileName'):
             QGuiApplication.setDesktopFileName('electrum.desktop')
+        if hasattr(Qt, "AA_EnableHighDpiScaling") and sys.platform not in ('darwin',):
+            # The below only applies to non-macOS. On macOS this setting is
+            # never used (because it is implicitly auto-negotiated by the OS
+            # in a different way).
+            QtCore.QCoreApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
+        if hasattr(Qt, "AA_UseHighDpiPixmaps"):
+            QtCore.QCoreApplication.setAttribute(Qt.AA_UseHighDpiPixmaps)
         self.gui_thread = threading.current_thread()
         self.windows = []  # type: List[ElectrumWindow]
         self.efilter = OpenFileEventFilter(self.windows)

See also https://github.com/spesmilo/electrum-docs/pull/140 and https://doc.qt.io/qt-5/highdpi.html Note that both Qt.AA_EnableHighDpiScaling and Qt.AA_UseHighDpiPixmaps would be default-enabled in Qt6.

However, particularly with the qdarkstyle theme, I see some ui bugs with these flags enabled atm.