-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Add a save button in layer style panel #52037
Conversation
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.
Thanks for removing duplicate code 👍
Did you check that every piece of removed code was really equivalent?
I propose the friend option because looking into the code of the style panel, I was able to remove dupllicate code for the saving, saving as default, and open buttons, which mean more methods to change to public, where I just needed to add one friend statement. This is debatable, and I ask for opinions.
I prefer to keep friend keyword for really specific edge cases (test classes which need to access everything for instance) and in this particular scenario, I would prefer to make the needed method public.
I think it would be interesting to have an interface that define the different methods (savedefault, saveas, loadStyle) to avoid switch on type, and each properties class would implement it. What do you think?
break; | ||
|
||
// Not available for these | ||
case Qgis::LayerType::PointCloud: |
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.
Why not pointcloud ? we have a saveDefaultStyle.
The QGIS project highly values your contribution and would love to see this work merged! Unfortunately this PR has not had any activity in the last 14 days and is being automatically marked as "stale". If you think this pull request should be merged, please check
|
da358e5
to
c7f29ca
Compare
I chose to homogenize the behaviors when loading a style, it is applied. The methods are no longer private with friend keyword, but public. Thanks for the review. The unsuccessful check (cppcheck_18_04) is not related to this PR. |
Did you see my comment about point cloud? There is a call to saveStyleAs when it comes to PointCloud but any other other methods is not called. Is it normal? |
Yes, it's normal, point cloud was not supporting loading/saving layer styles with the panel before, I don't want to risk to go further than the bugfix here, which is to add the save button to layer types already supporting this section of the style panel. BUT the save style for point cloud was used in qgisapp code so I included point cloud in the minor refactoring of removing code duplucation. |
Description
Saving layer style QML file is already available at 2 places in QGIS, with code duplication:
For the purpose of #51515 a third place of code duplication was going to appear:
To remove code duplication, I had to choose between:
public
friend
I propose the
friend
option because looking into the code of the style panel, I was able to remove dupllicate code for the saving, saving as default, and open buttons, which mean more methods to change topublic
, where I just needed to add onefriend
statement. This is debatable, and I ask for opinions.Testing
I spent time on writing a unit test, but on GUI it's terribly difficult here because it's all about pop-up, and I ended with using QTimers and singleShots to mock user clicks, but it's really unstable (crashes QGIS when the test fails... and stops all the unit test run...).
Here the addition relies on calling code from the layer properties, which is tested, so I think that it's sufficient.
Other QGIS crash found and fixed
To reproduce:
Reason: the item of the QStandardItemModel was removed twice.