Skip to content

Commit

Permalink
feat: Add debuginfod settings (#366)
Browse files Browse the repository at this point in the history
Allow user to enable/disable debuginfod environment variable

Requirements: https://pms.uniontech.com/story-view-37445.html
Log: Add debuginfod settings
  • Loading branch information
ArchieMeng authored Nov 19, 2024
1 parent edb98c3 commit 35daf3d
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/assets/other/default-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
]
}
Expand Down
10 changes: 10 additions & 0 deletions src/settings/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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***************/

/*******************************************************************************
Expand Down
5 changes: 5 additions & 0 deletions src/settings/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/settings/settings_translation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
22 changes: 22 additions & 0 deletions src/views/termwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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";
}

Expand Down

0 comments on commit 35daf3d

Please sign in to comment.