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

feat: confirmation dialog for duplicate palette color addition #3334

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

KartikWatts
Copy link
Contributor

This PR contains the enhancement discussed in #3215

A confirmation dialog will be displayed to the User when they attempt to add a duplicate color again into the color palette.

A new public method Palette::is_color_present is implemented to check the duplicate color presence
Additional private method Dock_PalEdit::confirm_duplicate_color_addition() is implemented to be called within existing Dock_PalEdit::add_color method for modularity to trigger UIInterface::confirmation

closes #3215

`Palette::is_color_present` is implemented to check duplicate color and trigger `Dock_PalEdit::confirm_duplicate_color_addition()` for user confirmation
Copy link
Contributor Author

@KartikWatts KartikWatts left a comment

Choose a reason for hiding this comment

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

During implementation, I had some thoughts, and wanted to point them out. Regards.

{
iterator iter;

for(iter=begin();iter!=end();++iter)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The current approach requires traversing through the vector for every color addition.
Seems fine to me though, but we may maintain a hashmap if we need further optimization. Thoughts are welcome.

Comment on lines +551 to +553
Dock_PalEdit::confirm_duplicate_color_addition()
{
return App::get_ui_interface()->confirmation(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have created a separate method to be called within add_color. Also, does this behavior require to be controlled with User preferences or a checkbox something like: Don't ask again.
However, I felt it should be okay, as this won't happen regularly anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adding colors to color palette
1 participant