File: upstream_b559cb8f_basictab-Add-option-for-GPU-handling.patch

package info (click to toggle)
kmenuedit 4%3A6.3.4-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 2,728 kB
  • sloc: cpp: 3,731; xml: 164; makefile: 3; sh: 2
file content (112 lines) | stat: -rw-r--r-- 4,664 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
From b559cb8f487b5ba66d9fe9f471b01b6e2ca4d8bf Mon Sep 17 00:00:00 2001
From: Oliver Beard <olib141@outlook.com>
Date: Tue, 1 Apr 2025 15:34:21 +0100
Subject: [PATCH] basictab: Add option for GPU handling This commit introduces
 the option to configure the keys PrefersNonDefaultGPU/X-KDE-RunOnDiscreteGpu.
 Both are considered, but the latter is a fallback and not updated.

It has the same implementation as the file properties dialog, but cannot be contextually disabled (KIO::hasDiscreteGpu is not exposed).

BUG: 502198
FIXED-IN: 6.4
---
 basictab.cpp | 23 +++++++++++++++++++++++
 basictab.h   |  2 ++
 2 files changed, 25 insertions(+)

diff --git a/basictab.cpp b/basictab.cpp
index d95bfb99..2eddcadd 100644
--- a/basictab.cpp
+++ b/basictab.cpp
@@ -185,6 +185,13 @@ void BasicTab::initAdvancedTab()
     userGroupLayout->addWidget(userNameGroup);
     advancedTabLayout->addWidget(_userGroup);
 
+    // gpu
+    _gpuGroup = new QGroupBox();
+    QHBoxLayout *gpuGroupLayout = new QHBoxLayout(_gpuGroup);
+    _gpuCB = new QCheckBox(i18n("Run using dedicated &graphics card"));
+    gpuGroupLayout->addWidget(_gpuCB);
+    advancedTabLayout->addWidget(_gpuGroup);
+
     // key binding
     _keyBindingGroup = new QGroupBox();
     QHBoxLayout *keyBindingGroupLayout = new QHBoxLayout(_keyBindingGroup);
@@ -222,6 +229,7 @@ void BasicTab::initConnections()
     connect(_terminalCB, &QCheckBox::clicked, this, &BasicTab::termcb_clicked);
     connect(_terminalOptionsEdit, &QLineEdit::textChanged, this, &BasicTab::slotChanged);
     connect(_userCB, &QCheckBox::clicked, this, &BasicTab::uidcb_clicked);
+    connect(_gpuCB, &QCheckBox::clicked, this, &BasicTab::slotChanged);
     connect(_userNameEdit, &QLineEdit::textChanged, this, &BasicTab::slotChanged);
     connect(_keyBindingEdit, &KKeySequenceWidget::keySequenceChanged, this, &BasicTab::slotCapturedKeySequence);
 }
@@ -248,6 +256,7 @@ void BasicTab::slotDisableAction()
     _workPathGroup->setEnabled(false);
     _terminalGroup->setEnabled(false);
     _userGroup->setEnabled(false);
+    _gpuGroup->setEnabled(false);
     _iconButton->setEnabled(false);
     // key binding part
     _keyBindingGroup->setEnabled(false);
@@ -277,6 +286,7 @@ void BasicTab::enableWidgets(bool isDF, bool isDeleted)
     _terminalGroup->setEnabled(isDF && !isDeleted);
     _userGroup->setEnabled(isDF && !isDeleted);
     _keyBindingGroup->setEnabled(isDF && !isDeleted);
+    _gpuGroup->setEnabled(isDF && !isDeleted);
 
     _terminalOptionsEdit->setEnabled(isDF && !isDeleted && _terminalCB->isChecked());
     _terminalOptionsLabel->setEnabled(isDF && !isDeleted && _terminalCB->isChecked());
@@ -310,6 +320,7 @@ void BasicTab::setFolderInfo(MenuFolderInfo *folderInfo)
     _onlyShowInKdeCB->setChecked(false);
     _hiddenEntryCB->setChecked(false);
     _userCB->setChecked(false);
+    _gpuCB->setChecked(false);
     _keyBindingEdit->clearKeySequence();
 
     enableWidgets(false, folderInfo->hidden);
@@ -411,6 +422,12 @@ void BasicTab::setEntryInfo(MenuEntryInfo *entryInfo)
 
     _userCB->setChecked(df->desktopGroup().readEntry("X-KDE-SubstituteUID", false));
 
+    if (df->desktopGroup().hasKey("PrefersNonDefaultGPU")) {
+        _gpuCB->setChecked(df->desktopGroup().readEntry("PrefersNonDefaultGPU", false));
+    } else {
+        _gpuCB->setChecked(df->desktopGroup().readEntry("X-KDE-RunOnDiscreteGpu", false));
+    }
+
     enableWidgets(true, entryInfo->hidden);
     blockSignals(false);
 }
@@ -465,6 +482,12 @@ void BasicTab::apply()
         } else {
             dg.writeXdgListEntry("OnlyShowIn", onlyShowIn);
         }
+
+        dg.writeEntry("PrefersNonDefaultGPU", _gpuCB->isChecked());
+        // Delete the old key — it could cause confusion when inspecting .desktop content
+        if (dg.hasKey("X-KDE-RunOnDiscreteGpu")) {
+            dg.deleteEntry("X-KDE-RunOnDiscreteGpu");
+        }
     } else {
         _menuFolderInfo->setCaption(_nameEdit->text());
         _menuFolderInfo->setGenericName(_descriptionEdit->text());
diff --git a/basictab.h b/basictab.h
index 5559e1c3..01ce48b6 100644
--- a/basictab.h
+++ b/basictab.h
@@ -86,10 +86,12 @@ protected:
     QCheckBox *_launchCB = nullptr;
     QCheckBox *_onlyShowInKdeCB = nullptr;
     QCheckBox *_hiddenEntryCB = nullptr;
+    QCheckBox *_gpuCB = nullptr;
     KIconButton *_iconButton = nullptr;
     QGroupBox *_workPathGroup = nullptr;
     QGroupBox *_terminalGroup = nullptr;
     QGroupBox *_userGroup = nullptr;
+    QGroupBox *_gpuGroup = nullptr;
     QGroupBox *_keyBindingGroup = nullptr;
     QLabel *_terminalOptionsLabel = nullptr;
     QLabel *_userNameLabel = nullptr;
-- 
GitLab