-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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 #15946: Add ability to replace image #15985
base: master
Are you sure you want to change the base?
Fix #15946: Add ability to replace image #15985
Conversation
f18b6f3
to
2297c62
Compare
return; | ||
} | ||
|
||
std::vector<std::string> filter = { trc("notation", "All Supported Files") + " (*.svg *.jpg *.jpeg *.png)", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here I see a code duplication problem.
If someone decides to make a change to this code(adding another filter) and forgets to make a change to addImage, then we will get a different behavior - a bug.
I propose to move the common parts into separate method(s) and reuse them in addImage and replaceImage methods.
Same for NotationInteraction::addImage and NotationInteraction::replaceImage
From a functional/UX POV I think this is all very nice. I don't have any problems with this proposal 🙂. |
2297c62
to
4bbb486
Compare
4bbb486
to
8ac6f31
Compare
8ac6f31
to
8ab89e3
Compare
|
||
navigation.panel: root.navigationPanel | ||
navigation.name: "KeepSizeRadioButton" | ||
navigation.row: root.navigationRowStart + 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Root doesn't have navigationRowStart property
I think it should be just navigation.row: 1
if (imagePath.empty() || !item) { | ||
return; | ||
if (imagePath.empty()) { | ||
return new Image(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is better to return nullptr
@@ -4179,14 +4178,24 @@ void NotationInteraction::addImageToItem(const io::path_t& imagePath, EngravingI | |||
|
|||
ImageType type = mu::value(suffixToType, suffix, ImageType::NONE); | |||
if (type == ImageType::NONE) { | |||
return; | |||
return new Image(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is better to return nullptr
} | ||
|
||
Image* image = Factory::createImage(item); | ||
image->setImageType(type); | ||
|
||
if (!image->load(imagePath)) { | ||
delete image; | ||
return new Image(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is better to return nullptr
@Eism Thanks for the review. 🙂 (apologies, forgot to mention this when pushing) |
8ab89e3
to
e96d002
Compare
@iwoithe are you still intending to complete this PR? 🙂 |
@bkunda Yes, I still intend to complete this PR. 🙂 |
FWIW I have resumed work on this PR, however, for various reasons (bugs, code quality, etc.) I have restarted from scratch and as such a new PR will be opened soon 🙂 |
fa1f8d3
to
525a11a
Compare
Resolves: #15946
Video
mu-15975.mp4