ui: scroll to toggle on button press (#35604)

scroll so toggle in view when setCurrentPanel is called with param
This commit is contained in:
Jimmy
2025-06-26 09:22:58 -07:00
committed by GitHub
parent d1893ee3eb
commit fa5fce465a
2 changed files with 13 additions and 0 deletions
+11
View File
@@ -130,6 +130,15 @@ void TogglesPanel::expandToggleDescription(const QString &param) {
toggles[param.toStdString()]->showDescription();
}
void TogglesPanel::scrollToToggle(const QString &param) {
if (auto it = toggles.find(param.toStdString()); it != toggles.end()) {
auto scroll_area = qobject_cast<QScrollArea*>(parent()->parent());
if (scroll_area) {
scroll_area->ensureWidgetVisible(it->second);
}
}
}
void TogglesPanel::showEvent(QShowEvent *event) {
updateToggles();
}
@@ -411,6 +420,7 @@ void SettingsWindow::setCurrentPanel(int index, const QString &param) {
}
} else {
emit expandToggleDescription(param);
emit scrollToToggle(param);
}
}
@@ -451,6 +461,7 @@ SettingsWindow::SettingsWindow(QWidget *parent) : QFrame(parent) {
TogglesPanel *toggles = new TogglesPanel(this);
QObject::connect(this, &SettingsWindow::expandToggleDescription, toggles, &TogglesPanel::expandToggleDescription);
QObject::connect(this, &SettingsWindow::scrollToToggle, toggles, &TogglesPanel::scrollToToggle);
auto networking = new Networking(this);
QObject::connect(uiState()->prime_state, &PrimeState::changed, networking, &Networking::setPrimeType);
+2
View File
@@ -30,6 +30,7 @@ signals:
void reviewTrainingGuide();
void showDriverView();
void expandToggleDescription(const QString &param);
void scrollToToggle(const QString &param);
private:
QPushButton *sidebar_alert_widget;
@@ -66,6 +67,7 @@ public:
public slots:
void expandToggleDescription(const QString &param);
void scrollToToggle(const QString &param);
private slots:
void updateState(const UIState &s);