diff --git a/src/assets/other/default-config.json b/src/assets/other/default-config.json index 50517fa4e..b41c094e1 100644 --- a/src/assets/other/default-config.json +++ b/src/assets/other/default-config.json @@ -419,6 +419,18 @@ "text": "Disable flow control using Ctrl+S, Ctrl+Q", "type": "checkbox", "default": "false" + }, + { + "key": "enable_debuginfod", + "text": "debuginfod", + "type": "checkbox", + "default": "true" + }, + { + "key": "debuginfod_urls", + "name": "debuginfod urls", + "type": "lineedit", + "default": "https://debuginfod.deepin.com" } ] } diff --git a/src/settings/settings.cpp b/src/settings/settings.cpp index 7e53a4bbd..ed22e8191 100644 --- a/src/settings/settings.cpp +++ b/src/settings/settings.cpp @@ -608,6 +608,16 @@ bool Settings::disableControlFlow(void) return settings->option("advanced.shell.disable_ctrl_flow")->value().toBool(); } +bool Settings::enableDebuginfod() +{ + return settings->option("advanced.shell.enable_debuginfod")->value().toBool(); +} + +QString Settings::debuginfodUrls() +{ + return settings->option("advanced.shell.debuginfod_urls")->value().toString(); +} + /******** Add by ut001000 renfeixiang 2020-06-15:增加 每次显示设置界面时,更新设置的等宽字体 End***************/ /******************************************************************************* diff --git a/src/settings/settings.h b/src/settings/settings.h index fe768e443..8cf9b24c6 100644 --- a/src/settings/settings.h +++ b/src/settings/settings.h @@ -213,6 +213,11 @@ class Settings : public QObject * @return */ bool disableControlFlow(void); + // 是否启用debuginfod:设置或取消DEBUGINFOD_URLS环境变量 + bool enableDebuginfod(); + // deepin-terminal设置的DEBUGINFOD_URLS环境变量值 + QString debuginfodUrls(); + /** * @brief 历史记录行数 * @author Archie Meng diff --git a/src/settings/settings_translation.cpp b/src/settings/settings_translation.cpp index e74e70e32..1d9abe5d9 100644 --- a/src/settings/settings_translation.cpp +++ b/src/settings/settings_translation.cpp @@ -150,4 +150,6 @@ void GenerateSettingTranslate() Q_UNUSED(include_special_characters_in_double_click_selectionisText); auto set_cursor_position = QObject::tr("Allow Ctrl + left mouse click to set cursor position"); Q_UNUSED(set_cursor_position); + auto debuginfod_urls = QObject::tr("debuginfod urls"); + Q_UNUSED(debuginfod_urls); } diff --git a/src/views/termwidget.cpp b/src/views/termwidget.cpp index 6828439bf..3845d1fff 100644 --- a/src/views/termwidget.cpp +++ b/src/views/termwidget.cpp @@ -52,6 +52,15 @@ TermWidget::TermWidget(const TermProperties &properties, QWidget *parent) : QTer setHistorySize(Settings::instance()->historySize()); setTerminalWordCharacters(Settings::instance()->wordCharacters()); + // 设置debuginfod + if (Settings::instance()->enableDebuginfod()) { + QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); + if (!env.contains("DEBUGINFOD_URLS")) { + env.insert("DEBUGINFOD_URLS", Settings::instance()->debuginfodUrls()); + setEnvironment(env.toStringList()); + } + } + QString strShellPath = Settings::instance()->shellPath(); // set shell program qInfo() << "set shell program : " << strShellPath; @@ -1179,6 +1188,19 @@ void TermWidget::onSettingValueChanged(const QString &keyName) return; } + if ("advanced.shell.enable_debuginfod" == keyName) { + if (!hasRunningProcess()) { + if (Settings::instance()->enableDebuginfod()) { + sendText(QString("test -z $DEBUGINFOD_URLS && export DEBUGINFOD_URLS=$1\n").arg(Settings::instance()->debuginfodUrls())); + } else { + sendText("test -z $DEBUGINFOD_URLS || unset DEBUGINFOD_URLS\n"); + } + } else { + // Todo(ArchieMeng): Should handle the situation when there is a running process. It should wait until all running processes being exited. + } + return; + } + qInfo() << "settingValue[" << keyName << "] changed is not effective"; }