How to have bullet points in an error message?

About the development of the Part Design module/workbench. PLEASE DO NOT POST HELP REQUESTS HERE!
wmayer
Site Admin
Posts: 14076
Joined: Thu Feb 19, 2009 10:32 am

Re: How to have bullet points in an error message?

Postby wmayer » Mon Dec 03, 2018 1:57 pm

If you like you can make your first PR so that it can be merged into master. Before doing so there are two other features with a similar meaningless error message: FeatureHole.cpp in line 952 and FeatureGroove.cpp in line 102.
User avatar
DeepSOIC
Posts: 6528
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: How to have bullet points in an error message?

Postby DeepSOIC » Mon Dec 03, 2018 1:58 pm

NormandC wrote:
Sun Dec 02, 2018 8:23 am
But the real important question: what does cheese have to do with face creation? :D
FaceMakerCheese is adapted face-making code of Part Extrude and PartDesign (same code was repeated in about three places I think). I called it "cheese" because it supports making faces with holes, but doesn't support islands inside holes. If you take a slice of cheese, it can have holes but can't have islands inside holes... That's why!
User avatar
DeepSOIC
Posts: 6528
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: How to have bullet points in an error message?

Postby DeepSOIC » Mon Dec 03, 2018 2:07 pm

Use html, maybe?
html-in-qmessagebox.PNG
html-in-qmessagebox.PNG (28 KiB) Viewed 288 times
User avatar
NormandC
Posts: 18534
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: How to have bullet points in an error message?

Postby NormandC » Tue Dec 04, 2018 3:16 am

DeepSOIC wrote:
Mon Dec 03, 2018 2:07 pm
Use html, maybe?
Thanks, creative, but not working for me. C++ may not be directly recognizing html, seems like Python does?

FC018_PD_error_message_enhancement_03.png
FC018_PD_error_message_enhancement_03.png (36.92 KiB) Viewed 257 times

I guess it's related to what wmayer mentioned in his next to last reply.

wmayer wrote:
Mon Dec 03, 2018 1:45 pm
So, because QString::fromLatin1 instead of QString::fromUtf8 is used the characters are not properly decoded.
Thanks, I'm very much tempted to change it to utf8. I'm guessing it shouldn't affect other errors that use this routine.

wmayer wrote:
Mon Dec 03, 2018 1:57 pm
If you like you can make your first PR so that it can be merged into master. Before doing so there are two other features with a similar meaningless error message: FeatureHole.cpp in line 952 and FeatureGroove.cpp in line 102.
I'd like to try, if I can figure out the PR process with Git (so far I've only created a local branch - maybe I'll make things easier on myself and redo everything on Github's web UI!). I had already made the same change in FeatureHole.cpp, I hadn't thought of looking in FeatureGroove.cpp.

DeepSOIC wrote:
Mon Dec 03, 2018 1:58 pm
I called it "cheese" because it supports making faces with holes, but doesn't support islands inside holes.
Ha! Thanks for the explanation, the Swiss cheese analogy did pass through my mind. :D
User avatar
NormandC
Posts: 18534
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: How to have bullet points in an error message?

Postby NormandC » Tue Dec 04, 2018 3:31 am

Success:

FC018_PD_error_message_enhancement_04.png
FC018_PD_error_message_enhancement_04.png (33.49 KiB) Viewed 256 times

But it does not look nice without indentation, and with the text right beneath the bullet. I wanted to avoid forcing carriage returns because I thought the window could be resized by then end user, but it looks like its width is fixed.
User avatar
NormandC
Posts: 18534
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: How to have bullet points in an error message?

Postby NormandC » Tue Dec 04, 2018 3:39 am

Better, but missing an empty line before the bullet list! Line breaks are not to my liking either.
Attachments
FC018_PD_error_message_enhancement_05.png
FC018_PD_error_message_enhancement_05.png (33.59 KiB) Viewed 255 times
User avatar
NormandC
Posts: 18534
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: How to have bullet points in an error message?

Postby NormandC » Tue Dec 04, 2018 3:50 am

I think this is it.

What do you guys think?

FC018_PD_error_message_enhancement_06.png
FC018_PD_error_message_enhancement_06.png (32.82 KiB) Viewed 252 times

Now, the big question is, how will this text string be translated? I mean, how will it appear on Crowdin: as it's shown above, or will the bullet points be shown as \xe2\x80\xa2 :?:
chrisb
Posts: 15249
Joined: Tue Mar 17, 2015 9:14 am

Re: How to have bullet points in an error message?

Postby chrisb » Tue Dec 04, 2018 6:21 am

That looks good. It is good to see that you have similar high aesthetic standards as I have. How does it look with another space (half a line would be nice, haha) between the bullet paragraphs?
wmayer
Site Admin
Posts: 14076
Joined: Thu Feb 19, 2009 10:32 am

Re: How to have bullet points in an error message?

Postby wmayer » Tue Dec 04, 2018 9:06 am

Now, the big question is, how will this text string be translated?
Not at all because Qt's lupdate tool won't pick up the string because it's not marked accordingly. The string must be put inside the QT_TR_NOOP macro and then when it is about to be displayed QApplication::translate must be used.
I mean, how will it appear on Crowdin: as it's shown above, or will the bullet points be shown as \xe2\x80\xa2
I guess that it will show the \xe2\x80\xa2. However, it's always a bit problematic if technical stuff is part of a string because some translators don't know what to do and simply omit it.
IMO, the best practise to avoid such cases is that it's up to the programmers to split the whole string into two parts. The technical part that won't be marked for translation and the actual content that will be marked.

Code: Select all

/* TRANSLATOR PartDesign::Pocket */

Code: Select all

std::string message = QT_TR_NOOP("The requested feature cannot be created. The reason may be that:");
message += "\n\xe2\x80\xa2";
message += QT_TR_NOOP("the active Body does not contain a base shape, so there is no material to be removed");
message += "\n\xe2\x80\xa2";
message += QT_TR_NOOP("the selected sketch does not belong to the active Body.");
On crowdin the translator will see three strings within the context "PartDesign::Pocket". So, the likelihood that he messes things up should be rather low.
The code to display the error message should then be changed to (TaskDlgFeatureParameters::accept()):

Code: Select all

QMessageBox::warning(Gui::getMainWindow(), tr("Input error"), QApplication::translate(feature->getTypeId().getName(), e.what()));
User avatar
DeepSOIC
Posts: 6528
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: How to have bullet points in an error message?

Postby DeepSOIC » Tue Dec 04, 2018 9:29 am

wmayer wrote:
Tue Dec 04, 2018 9:06 am

Code: Select all

std::string message = QT_TR_NOOP("The requested feature cannot be created. The reason may be that:");
message += "\n\xe2\x80\xa2";
message += QT_TR_NOOP("the active Body does not contain a base shape, so there is no material to be removed");
message += "\n\xe2\x80\xa2";
message += QT_TR_NOOP("the selected sketch does not belong to the active Body.");
...
The code to display the error message should then be changed to (TaskDlgFeatureParameters::accept()):

Code: Select all

QMessageBox::warning(..., QApplication::translate(..., e.what()));
But will it work at all? I thought, Qt looks up the whole string in the translation library, but will not find it because only pieces are in the library?