dolphin 空格键问题修复

debian 12 里的 dolphin 空格键和之前功能不一样了,进入一个目录后,按空格键会进入Selection Mode而不是选中当前(第一个)项目,感觉很烦人,于是我就修改源码恢复到之前的功能了。

这里记录一下步骤,供需要的人参考。

  1. 安装devscripts
    sudo apt install devscripts
  2. 构建依赖软件包:
    mk-build-deps dolphin
  3. 安装构建依赖软件包:
    sudo apt install ./dolphin-build-deps_22.12.3-1_amd64.deb
  4. 下载dolphin源码:
    apt source dolphin
  5. 进入源码目录:
    cd dolphin-22.12.3/
  6. 修改源码文件src/kitemviews/kitemlistcontroller.cpp
@@ -435,11 +435,15 @@
                 m_selectionManager->setSelected(index, 1, KItemListSelectionManager::Toggle);
                 m_selectionManager->beginAnchoredSelection(index);
                 break;
-            } else if (m_keyboardManager->addKeyBeginsNewSearch()) { // File names shouldn't start with a space,
-                                                                     // so we can use this press as a keyboard shortcut instead.
-                Q_EMIT selectionModeChangeRequested(!m_selectionMode);
-                break;
+            } else {
+                // Select the current item if it is not selected yet.
+                const int current = m_selectionManager->currentItem();
+                if (!m_selectionManager->isSelected(current)) {
+                    m_selectionManager->setSelected(current);
+                    break;
+                }
             }
+
         }
         Q_FALLTHROUGH();  // fall through to the default case and add the Space to the current search string.
     default:
  1. 增加版本号:
    dch -n
  2. 构建软件包:
    debuild -b -us -uc
  3. 安装新软件包:
    sudo dpkg -i ./libdolphinvcs5_22.12.3-1.1_amd64.deb ../dolphin_22.12.3-1.1_amd64.deb
  4. 删除无用软件包(devscripts和构建依赖):
    sudo apt autoremove --purge devscripts dolphin-build-deps

最后再清理一下残留文件,整个过程就结束了。