Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Optimize debuginfod options #368

Merged
merged 1 commit into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/assets/other/default-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -419,10 +419,16 @@
"text": "Disable flow control using Ctrl+S, Ctrl+Q",
"type": "checkbox",
"default": "false"
},
}
]
},
{
"key": "debuginfod",
"name": "debuginfod",
"options": [
{
"key": "enable_debuginfod",
"text": "debuginfod",
"text": "The HTTP file server used for transmitting debugging information resources",
"type": "checkbox",
"default": "true"
},
Expand Down
48 changes: 48 additions & 0 deletions src/main/service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ void Service::init()
ServerConfigManager::instance()->initServerConfig();
// 主进程:首次赋值m_pShareMemoryInfo
listenWindowEffectSwitcher();
listenDebuginfodOption();
}

void Service::releaseInstance()
Expand Down Expand Up @@ -111,6 +112,8 @@ void Service::initSetting()

//判断未开启窗口特效时,隐藏透明度/背景模糊选项
showHideOpacityAndBlurOptions(DWindowManagerHelper::instance()->hasComposite());
// 根据是否开启debuginfod选项初始化debuginfod urls选项的显示与否
showHideDebuginfodUrlsOptions(Settings::instance()->enableDebuginfod());
}

void Service::slotSettingsDialogFinished(int result)
Expand Down Expand Up @@ -192,6 +195,42 @@ void Service::showHideOpacityAndBlurOptions(bool isShow)
}
}

void Service::showHideDebuginfodUrlsOptions(bool isShow)
{
QWidget *rightFrame = m_settingDialog->findChild<QWidget *>("RightFrame");
if (nullptr == rightFrame) {
qInfo() << "can not found RightFrame in QWidget";
return;
}

QList<QWidget *> rightWidgetList = rightFrame->findChildren<QWidget *>();
for (int i = 0; i < rightWidgetList.size(); i++) {
QWidget *widget = rightWidgetList.at(i);
if (nullptr == widget)
continue;

if (strcmp(widget->metaObject()->className(), "QLabel") == 0) {
QString text = (qobject_cast<QLabel *>(widget))->text();
if (QObject::tr("debuginfod urls") == text) {
QWidget *optionWidget = widget;
QWidget *parentWidget = widget->parentWidget();
QWidget *wrapWidget = parentWidget ? parentWidget->parentWidget() : nullptr;
if (wrapWidget && strcmp(wrapWidget->metaObject()->className(), "QWidget") == 0) {
wrapWidget->setVisible(isShow);
}

if (parentWidget && strcmp(parentWidget->metaObject()->className(), "Dtk::Widget::DFrame") == 0)
optionWidget = parentWidget;

if (isShow)
optionWidget->show();
else
optionWidget->hide();
}
}
}
}

void Service::listenWindowEffectSwitcher()
{
connect(DWindowManagerHelper::instance(), &DWindowManagerHelper::hasCompositeChanged, this, [this]() {
Expand All @@ -201,6 +240,15 @@ void Service::listenWindowEffectSwitcher()
});
}

void Service::listenDebuginfodOption()
{
connect(Settings::instance(), &Settings::terminalSettingChanged, this, [this] (const QString &keyName) {
if ("advanced.debuginfod.enable_debuginfod" == keyName) {
showHideDebuginfodUrlsOptions(Settings::instance()->enableDebuginfod());
}
});
}

qint64 Service::getEntryTime()
{
return m_entryTime;
Expand Down
4 changes: 4 additions & 0 deletions src/main/service.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,15 @@ public slots:
* @param isShow:显示
*/
void showHideOpacityAndBlurOptions(bool isShow);
// 显示/隐藏debuginfod urls选项
void showHideDebuginfodUrlsOptions(bool isShow);

/**
* @brief 监听窗口特效开关对应DBus信号,并实时显示/隐藏设置的透明度和背景模糊选项
*/
void listenWindowEffectSwitcher();
// 监听debuginfod勾选状态变化
void listenDebuginfodOption();

/**
* @brief 初始化
Expand Down
6 changes: 3 additions & 3 deletions src/settings/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ void Settings::initConnection()
{
connect(settings, &Dtk::Core::DSettings::valueChanged, this, [ = ](const QString & key, const QVariant & value) {
Q_UNUSED(value)
if (key.contains("basic.interface.") || key.contains("advanced.cursor.") || key.contains("advanced.scroll.") || key.contains("advanced.shell."))
if (key.contains("basic.interface.") || key.contains("advanced.cursor.") || key.contains("advanced.scroll.") || key.contains("advanced.shell.") || key.contains("advanced.debuginfod."))
emit terminalSettingChanged(key);
else if (key.contains("shortcuts."))
emit shortcutSettingChanged(key);
Expand Down Expand Up @@ -610,12 +610,12 @@ bool Settings::disableControlFlow(void)

bool Settings::enableDebuginfod()
{
return settings->option("advanced.shell.enable_debuginfod")->value().toBool();
return settings->option("advanced.debuginfod.enable_debuginfod")->value().toBool();
}

QString Settings::debuginfodUrls()
{
return settings->option("advanced.shell.debuginfod_urls")->value().toString();
return settings->option("advanced.debuginfod.debuginfod_urls")->value().toString();
}

/******** Add by ut001000 renfeixiang 2020-06-15:增加 每次显示设置界面时,更新设置的等宽字体 End***************/
Expand Down
4 changes: 2 additions & 2 deletions src/settings/settings_translation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +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);
auto enable_debuginfod = QObject::tr("The HTTP file server used for transmitting debugging information resources");
Q_UNUSED(enable_debuginfod);
}
4 changes: 2 additions & 2 deletions src/views/termwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1188,10 +1188,10 @@ void TermWidget::onSettingValueChanged(const QString &keyName)
return;
}

if ("advanced.shell.enable_debuginfod" == keyName) {
if ("advanced.debuginfod.enable_debuginfod" == keyName) {
if (!hasRunningProcess()) {
if (Settings::instance()->enableDebuginfod()) {
sendText(QString("test -z $DEBUGINFOD_URLS && export DEBUGINFOD_URLS=$1\n").arg(Settings::instance()->debuginfodUrls()));
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");
}
Expand Down
Loading
Loading