Skip to content

ENH: ctkSettingsDialog: Add removePanel function. - #1423

Open
NogginBops wants to merge 5 commits into
commontk:masterfrom
NogginBops:remove-settings-panel
Open

ENH: ctkSettingsDialog: Add removePanel function.#1423
NogginBops wants to merge 5 commits into
commontk:masterfrom
NogginBops:remove-settings-panel

Conversation

@NogginBops

Copy link
Copy Markdown
Contributor

Fixes #1422

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a ctkSettingsDialog::removePanel(...) API (by label or by panel pointer) to support use cases like reloadable plugins where settings panels need to be unregistered from the dialog (Fixes #1422).

Changes:

  • Added two Q_INVOKABLE overloads for ctkSettingsDialog::removePanel in the public header.
  • Implemented recursive removal logic to delete the corresponding QTreeWidgetItem subtree and detach panels from the QStackedWidget.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
Libs/Widgets/ctkSettingsDialog.h Declares the new removePanel public API overloads.
Libs/Widgets/ctkSettingsDialog.cpp Implements recursive panel removal and the two new removePanel entry points.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Libs/Widgets/ctkSettingsDialog.cpp Outdated
Comment thread Libs/Widgets/ctkSettingsDialog.cpp Outdated
Comment thread Libs/Widgets/ctkSettingsDialog.cpp Outdated
Comment thread Libs/Widgets/ctkSettingsDialog.cpp Outdated
Comment thread Libs/Widgets/ctkSettingsDialog.cpp Outdated
Comment on lines +289 to +316
void ctkSettingsDialog::removePanel(const QString& label)
{
Q_D(ctkSettingsDialog);

QTreeWidgetItem* item = d->item(label);

if (item != d->SettingsTreeWidget->invisibleRootItem())
{
d->removePanelRecursive(item);
}

this->adjustTreeWidgetToContents();
}

// --------------------------------------------------------------------------
void ctkSettingsDialog::removePanel(ctkSettingsPanel* panel)
{
Q_D(ctkSettingsDialog);

QTreeWidgetItem* item = d->item(panel);

if (item != d->SettingsTreeWidget->invisibleRootItem())
{
d->removePanelRecursive(item);
}

this->adjustTreeWidgetToContents();
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lassoan should I try to write tests or should we do it the same way we did with the last PR?

@NogginBops
NogginBops force-pushed the remove-settings-panel branch from 78af6f3 to 37ecd56 Compare May 25, 2026 11:21
@NogginBops

Copy link
Copy Markdown
Contributor Author

@lassoan Does this make sense to merge without the tests or should I/you write tests for this to be merged.
My position at my current employer is coming to an end and so I will likely not be spending more time on this particular issue in the future, so getting this merged soon would be ideal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Ability to remove ctkSettingsPanels from ctkSettingsDialog

2 participants