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!
User avatar
DeepSOIC
Posts: 6967
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:40 am

NormandC wrote:
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?
Hmm, strange. I was under impression that it's Qt doing the recognition and formatting. It is certainly not python, we are just calling the same QMessageBox after all. Maybe html in messageboxes isn't supported on linux? Or maybe it wants some flag? I don't know...

Can you try this? It's as close as it can get to C++ code. HTML formatting works here on Win for this warning popup.

Code: Select all

from PySide import QtGui
QtGui.QMessageBox.warning(None, "test", "<html>message<ul><li>item1</li><li>item2</li></ul></html>")
User avatar
DeepSOIC
Posts: 6967
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:46 am

NormandC wrote:
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?
OK, I think I found why it didn't work for you: <html> is ignored if a newline character is encountered before <html> tag. Try wrapping the whole message in html tags.
wmayer
Site Admin
Posts: 14788
Joined: Thu Feb 19, 2009 10:32 am

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

Postby wmayer » Tue Dec 04, 2018 10:35 am

DeepSOIC wrote:
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?
Oh word censored, you're right! I haven't thought of this. So, if following this idea you have to use QCoreApplication::translate already inside the Pocket feature, convert the whole QString into a raw C string using toUtf8() and later convert back with fromUtf8().

Code: Select all

QString message = QCoreApplication::translate("PartDesign::Pocket", "The requested feature cannot be created. The reason may be that:");
message += QLatin1String("\n\xe2\x80\xa2");
message += QCoreApplication::translate("PartDesign::Pocket", "the active Body does not contain a base shape, so there is no material to be removed");
message += QLatin1String("\n\xe2\x80\xa2");
message += QCoreApplication::translate("PartDesign::Pocket", "the selected sketch does not belong to the active Body.");
return new App::DocumentObjectExecReturn(message.toUtf8());

Code: Select all

QMessageBox::warning(..., QString::fromUtf8(e.what()));
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 » Sat Dec 08, 2018 8:57 pm

You guys have completely and utterly lost me, you know that, right?

How is the existing string currently translated? It must be, right? Why then won't the current translation system work if I make the aforementioned change to the string?
User avatar
DeepSOIC
Posts: 6967
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

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

Postby DeepSOIC » Sun Dec 09, 2018 11:45 am

NormandC wrote:
Sat Dec 08, 2018 8:57 pm
How is the existing string currently translated?
I don't quite know all the details, but the overall mechanism is:
1. a Qt tool ("lupdate"?) sweeps the source code, searching for translate("somethingsomething") and QT_TR_NOOP("somethingsomething"). It creates a .ts file with all the strings, along with some additional information (context).

2. translators add translations of the strings to the .ts file.
3. when FreeCAD is built, the .ts file with translations is packed into FreeCAD. In the calls to translate("somethingsomething"), the string "somethingsomething" is looked up in the packed .ts file, and the translated string is returned. (and afaik, the .ts file is converted into a binary database for faster lookup)
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 » Sun Dec 23, 2018 7:29 am

Thanks for your help, but you guys don't seem to realize how out of my depth this all is.

Sorry but I'm giving up. I'll create a bug report in the tracker. I really wish this would have made it in 0.18.
wmayer
Site Admin
Posts: 14788
Joined: Thu Feb 19, 2009 10:32 am

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

Postby wmayer » Mon Dec 31, 2018 5:31 pm

NormandC wrote:
Sun Dec 23, 2018 7:29 am
Thanks for your help, but you guys don't seem to realize how out of my depth this all is.

Sorry but I'm giving up. I'll create a bug report in the tracker. I really wish this would have made it in 0.18.
Did you create a ticket? I couldn't find one. Anyway, as first step see: git commit 563d020b6
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 » Mon Dec 31, 2018 5:40 pm

Thanks. Sorry, I didn't manage to create a ticket.
User avatar
Kunda1
Posts: 5515
Joined: Thu Jan 05, 2017 9:03 pm

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

Postby Kunda1 » Sat Feb 09, 2019 3:52 pm

Related issue:
https://github.com/FreeCAD/FreeCAD/blob ... 1366-L1368

Code: Select all

StdCmdViewRotateLeft::StdCmdViewRotateLeft()
  : Command("Std_ViewRotateLeft")
{
    sGroup        = QT_TR_NOOP("Standard-View");
    sMenuText     = QT_TR_NOOP("Rotate Left");
    sToolTipText  = QT_TR_NOOP("Rotate the view by 90\xc2\xb0 counter-clockwise");
    sWhatsThis    = "Std_ViewRotateLeft";
    sStatusTip    = QT_TR_NOOP("Rotate the view by 90\xc2\xb0 counter-clockwise");
    sPixmap       = "view-rotate-left";
    sAccel        = "Shift+Left";
    eType         = Alter3DView;
}
How do i get the degrees symbol ?

Edit: sorry for the multiple posts (that i just manually removed) was having wifi issues.
Last edited by Kunda1 on Sat Feb 09, 2019 3:56 pm, edited 1 time in total.
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
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 » Sat Feb 09, 2019 3:56 pm

I don't understand your questions. The code above already produces the degree symbol in the GUI.