ui: allow to configure QT_QPA_PLATFORM from the GUI

Under Wayland the GUI doesn't work entirely well (#733).

Setting QT_QPA_PLATFORM to 'xcb' solves some issues, like correctly
positioning popups, but users had to configure it manually.

Now it's possible to configure it from the Preferences dialog.

Setting it to "" will use the default option of the Desktop Environment.
This commit is contained in:
Gustavo Iñiguez Goia 2024-12-17 21:29:11 +01:00
parent ee089af79b
commit 54ef3f6fac
Failed to generate hash of commit
4 changed files with 139 additions and 69 deletions

View file

@ -80,6 +80,14 @@ def configure_screen_scale_factor(cfg):
print("QT_SCREEN_SCALE_FACTORS:", screen_factor)
os.environ["QT_SCREEN_SCALE_FACTORS"] = screen_factor
def configure_qt_platform_plugin(cfg):
qt_plugin = cfg.getSettings(Config.QT_PLATFORM_PLUGIN)
if qt_plugin is None or qt_plugin == "":
return
print("QT_QPA_PLATFORM:", qt_plugin)
os.environ["QT_QPA_PLATFORM"] = qt_plugin
def check_environ():
if xdg_current_session == "":
print("""
@ -128,6 +136,7 @@ Examples:
logging.getLogger().disabled = not args.debug
cfg = Config.get()
configure_screen_scale_factor(cfg)
configure_qt_platform_plugin(cfg)
if args.debug and args.debug_grpc:
os.environ["GRPC_TRACE"] = "all"

View file

@ -139,6 +139,7 @@ class Config:
STATS_VIEW_COL_STATE = "statsDialog/view_columns_state"
STATS_VIEW_DETAILS_COL_STATE = "statsDialog/view_details_columns_state"
QT_PLATFORM_PLUGIN = "global/qt_platform_plugin"
QT_AUTO_SCREEN_SCALE_FACTOR = "global/screen_scale_factor_auto"
QT_SCREEN_SCALE_FACTOR = "global/screen_scale_factor"

View file

@ -370,6 +370,10 @@ class PreferencesDialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0]):
self.checkUIAutoScreen.blockSignals(False)
self._show_ui_scalefactor_widgets(auto_scale)
qt_platform = self._cfg.getSettings(Config.QT_PLATFORM_PLUGIN)
if qt_platform is not None and qt_platform != "":
self.comboUIQtPlatform.setCurrentText(qt_platform)
self.checkAutostart.setChecked(self._autostart.isEnabled())
self._load_ui_columns_config()
@ -672,6 +676,11 @@ class PreferencesDialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0]):
self._themes.save_theme(self.comboUITheme.currentIndex(), self.comboUITheme.currentText(), str(self.spinUIDensity.value()))
qt_platform = self._cfg.getSettings(Config.QT_PLATFORM_PLUGIN)
if qt_platform != self.comboUIQtPlatform.currentText():
self._changes_needs_restart = QC.translate("preferences", "Qt platform plugin changed")
self._cfg.setSettings(Config.QT_PLATFORM_PLUGIN, self.comboUIQtPlatform.currentText())
self._cfg.setSettings(Config.QT_AUTO_SCREEN_SCALE_FACTOR, bool(self.checkUIAutoScreen.isChecked()))
self._cfg.setSettings(Config.QT_SCREEN_SCALE_FACTOR, self.lineUIScreenFactor.text())
@ -942,11 +951,11 @@ class PreferencesDialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0]):
self._change_theme()
def _cb_ui_check_auto_scale_toggled(self, checked):
self._changes_needs_restart = True
self._changes_needs_restart = QC.translate("preferences", "Auto scale option changed")
self._show_ui_scalefactor_widgets(checked)
def _cb_ui_screen_factor_changed(self, text):
self._changes_needs_restart = True
self._changes_needs_restart = QC.translate("preferences", "Screen factor option changed")
def _cb_combo_auth_type_changed(self, index):
curtype = self.comboAuthType.itemData(self.comboAuthType.currentIndex())

View file

@ -222,7 +222,15 @@
</item>
<item row="2" column="0" colspan="4">
<widget class="QToolBox" name="toolBox">
<widget class="QWidget" name="page_7" native="true">
<widget class="QWidget" name="page_7">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>586</width>
<height>306</height>
</rect>
</property>
<attribute name="label">
<string>Default options</string>
</attribute>
@ -432,6 +440,14 @@
</layout>
</widget>
<widget class="QWidget" name="page_8">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>333</width>
<height>83</height>
</rect>
</property>
<attribute name="label">
<string>More</string>
</attribute>
@ -571,6 +587,25 @@
<string>General</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_16">
<item row="10" column="2" colspan="2">
<widget class="QLineEdit" name="lineUIScreenFactor">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Use numbers to define a global scale factor for the whole application:
1, 1.2, 1.5, 2, etc ...
Use ; to define multiple screens: 1;1.5 etc...</string>
</property>
<property name="placeholderText">
<string>ex: 1, 1.25, 1.5, 2, ...</string>
</property>
</widget>
</item>
<item row="0" column="2" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_8">
<property name="spacing">
@ -643,6 +678,28 @@
</item>
</layout>
</item>
<item row="3" column="2" colspan="2">
<widget class="QComboBox" name="comboUITheme">
<item>
<property name="text">
<string>System</string>
</property>
</item>
</widget>
</item>
<item row="12" column="0" colspan="2">
<widget class="QCheckBox" name="checkAutostart">
<property name="toolTip">
<string>By default the GUI is started when login</string>
</property>
<property name="text">
<string>Autostart the GUI upon login</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="label_27">
<property name="sizePolicy">
@ -659,42 +716,7 @@
</property>
</widget>
</item>
<item row="6" column="2" colspan="2">
<widget class="QLineEdit" name="lineUIScreenFactor">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Use numbers to define a global scale factor for the whole application:
1, 1.2, 1.5, 2, etc ...
Use ; to define multiple screens: 1;1.5 etc...</string>
</property>
<property name="placeholderText">
<string>ex: 1, 1.25, 1.5, 2, ...</string>
</property>
</widget>
</item>
<item row="1" column="2" colspan="2">
<widget class="QComboBox" name="comboUILang"/>
</item>
<item row="1" column="0" colspan="2">
<widget class="QLabel" name="label_19">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Language</string>
</property>
</widget>
</item>
<item row="7" column="0" colspan="2">
<item row="11" column="0" colspan="2">
<widget class="QLabel" name="labelUIDensity">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
@ -707,6 +729,16 @@ Use ; to define multiple screens: 1;1.5 etc...</string>
</property>
</widget>
</item>
<item row="7" column="0" colspan="4">
<widget class="QCheckBox" name="checkUIAutoScreen">
<property name="text">
<string>Auto screen scale factor</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_21">
<property name="sizePolicy">
@ -720,17 +752,10 @@ Use ; to define multiple screens: 1;1.5 etc...</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="4">
<widget class="QCheckBox" name="checkUIAutoScreen">
<property name="text">
<string>Auto screen scale factor</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
<item row="1" column="2" colspan="2">
<widget class="QComboBox" name="comboUILang"/>
</item>
<item row="6" column="0">
<item row="10" column="0">
<widget class="QLabel" name="labelUIScreenFactor">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
@ -743,7 +768,7 @@ Use ; to define multiple screens: 1;1.5 etc...</string>
</property>
</widget>
</item>
<item row="7" column="2" colspan="2">
<item row="11" column="2" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_9">
<property name="spacing">
<number>0</number>
@ -818,16 +843,20 @@ Use ; to define multiple screens: 1;1.5 etc...</string>
</item>
</layout>
</item>
<item row="3" column="2" colspan="2">
<widget class="QComboBox" name="comboUITheme">
<item>
<property name="text">
<string>System</string>
</property>
</item>
<item row="1" column="0" colspan="2">
<widget class="QLabel" name="label_19">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Language</string>
</property>
</widget>
</item>
<item row="4" column="0" colspan="4">
<item row="4" column="0">
<widget class="QLabel" name="labelThemeError">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
@ -843,16 +872,38 @@ Use ; to define multiple screens: 1;1.5 etc...</string>
</property>
</widget>
</item>
<item row="8" column="0" colspan="2">
<widget class="QCheckBox" name="checkAutostart">
<item row="5" column="2" colspan="2">
<widget class="QComboBox" name="comboUIQtPlatform">
<property name="editable">
<bool>true</bool>
</property>
<item>
<property name="text">
<string/>
</property>
</item>
<item>
<property name="text">
<string notr="true">xcb</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">wayland</string>
</property>
</item>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="QLabel" name="label_29">
<property name="toolTip">
<string>By default the GUI is started when login</string>
<string>This option will set QT_QPA_PLATFORM when launching the GUI.
xcb - X11 compatibility. If you experience issues with wayland, use this plugin.
wayland</string>
</property>
<property name="text">
<string>Autostart the GUI upon login</string>
</property>
<property name="checked">
<bool>true</bool>
<string>Qt platform plugin</string>
</property>
</widget>
</item>
@ -863,8 +914,8 @@ Use ; to define multiple screens: 1;1.5 etc...</string>
<rect>
<x>0</x>
<y>0</y>
<width>586</width>
<height>301</height>
<width>259</width>
<height>178</height>
</rect>
</property>
<attribute name="label">
@ -1723,8 +1774,8 @@ Temporary rules will still be valid, and you can use them when prompted to allow
<rect>
<x>0</x>
<y>0</y>
<width>586</width>
<height>260</height>
<width>296</width>
<height>211</height>
</rect>
</property>
<attribute name="label">