-
Notifications
You must be signed in to change notification settings - Fork 224
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
Implementation of global messages #2598
Conversation
Added files for global messageboxes with the main dialog as parent and with a standardized title. In headless mode the messages will be shown on terminal instead. (Also added myself to contributors list)
Added files for global messageboxes with the main dialog as parent and with a standardized title. In headless mode the messages will be shown on terminal instead. (Also added myself to contributors list)
The previous logic used eval to dynamically create variables. This is hard to follow. Instead, explicitly name the relevant two variables. Also, introduce readable variable names. Related: jamulussoftware#2474
Some suggestions do not apply. For those, a comment is added to disable the check and explain why shellcheck cannot properly judge it. Related: jamulussoftware#2474
Added files for global messageboxes with the main dialog as parent and with a standardized title. In headless mode the messages will be shown on terminal instead. (Also added myself to contributors list)
Great! Thank you! |
Could you please add a CHANGELOG entry in your PR description (and a short reasoning why you need this + advantages e.g uniform way to show error messages in future) |
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.
Looks interesting. Are there any examples yet where the new message box class is a benefit already?
void CMessages::ShowError ( QString strError ) | ||
{ | ||
#ifndef HEADLESS | ||
QMessageBox::critical ( pMainForm, strMainFormName + ": " + QObject::tr ( "Error" ), strError, QObject::tr ( "Ok" ), nullptr ); |
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.
QMessageBox::critical ( pMainForm, strMainFormName + ": " + QObject::tr ( "Error" ), strError, QObject::tr ( "Ok" ), nullptr ); | |
QMessageBox::critical ( pMainForm, strMainFormName + ": " + tr ( "Error" ), strError, tr ( "Ok" ), nullptr ); |
Is "Ok" really not an integrated button?
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.
Looks interesting. Are there any examples yet where the new message box class is a benefit already?
Well we first have to merge this one before we can modify the other messagebox calls of coarse...
But it has multiple benefits. From coding point of view showing a message becomes easier and more consistent, just CMessages::ShowError( 'text' ) and in headless mode the message will now show up on the terminal, so no actual need to check for HEADLESS defines.
From the users point of view it's especially of use for people running multiple instances, since the messagebox will popup on the instance generating the message and will have the 'clientname' in the title too.
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.
Is "Ok" really not an integrated button?
The standard messagebox has one button and here we just set the button text.
I don't like to depend on default values, since they might change. In this way I'm always sure what the result will be.
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.
Ok. Thanks for the note here.
Concerning the QObject::tr() call: I think the code doesn't use it in other places? Should't we stay consistent and use tr()
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.
I don't like to depend on default values, since they might change. In this way I'm always sure what the result will be.
Yes, however the default values exist for a reason. Also they're translated automatically.
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.
Concerning the QObject::tr() call: I think the code doesn't use it in other places? Should't we stay consistent and use tr()
Yes, but since tr is a static QObject function it is only available in a QObject, so since here we are not a QOject here using QObject::tr here is actually the same as tr in a QObject.
Done. Please let me know if it's ok this way. |
Questions: Do we want a "Jamulus [clientname]" prefix to appear on the debug steams too? Would it be useful to be able to set the button text from the "ShowXxxx" calls (optional parameter defaulting to "Ok")? |
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.
I think the UI abstraction makes sense, as it saves passing the parent window and the title all over again.
I'm less sure about the headless stuff. My gut feeling is that there are not that many instances where there's duplicated error handling for UI/CLI stuff, but I might be wrong. I think the CLI logging handling should use some reworking as well, so this might cover it. But maybe we should do that on its own as the first step and see if it makes sense to merge that later? My main concern is that if we replaced all qWarning/qInfo calls with the new abstraction, we might start showing solely informational messages as dialogs accidentially?
I think it would be good to have @pljones's judgement here first.
PR note: It seems like this PR adds and includes the infrastructure (src/messages) and updates one caller place. If we decide to add it, it would make sense to update all callers in the same go (separate commit, but same PR).
(Maybe there was some confusion about that in the other PRs regarding what to include. A PR should do one thing. If it aims to improve the message box implementation, it should include all of that, even if that touches lots of different files. It's just that all those changes should be related to the same specific goal.)
src/messages.cpp
Outdated
#ifndef HEADLESS | ||
QMessageBox::warning ( pMainForm, strMainFormName + ": " + QObject::tr ( "Warning" ), strWarning, QObject::tr ( "Ok" ), nullptr ); | ||
#else | ||
qWarning() << "Warning: " << strWarning.toLocal8Bit().data(); |
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 .toLocal8Bit()?
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.
As it is used everywhere, because the debug streams do not support unicode?
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.
Ok (although that's strange...)
# include <QMessageBox> | ||
# define tMainform QDialog | ||
#else | ||
# include <QDebug> |
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.
What does QDebug include? Does it add bloat on a release build?
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.
QDebug includes what's neccesary for the cli streams.
I mean you could also add a boolean parameter to only show it via CLI if needed. |
Overload the methods to add the ability to do that? |
There are several places places in the code with ifndef HEADLESS QMessage #else qStream #endif The QMessageBox class would make those ifdefs unnecessary.
I'm not sure if I really understand this remark. But we have Error, Warning and Info messageboxes. We would just replace all QMessagebox::xxxx calls with the matching CMessageBox::ShowXxxx call.
Sure !, but I did that in the other PR and I was requested NOT to do that again this PR but in a separate PR after this one is merged....
So I think there is still some difference in opinion on that. |
There are several ways to do it, but as said another button text would only seem useful to me if we take specific actions after the message is shown, so that would need another kind of (modal) message box that waits for the button to be pressed. |
Now translating html text to plain text before sending it to console.
ShowXxxWait messageboxes will wait for the/a button to be pressed in gui mode. ShowXxxWait messageboxes also have an optional 'abort' button and a default selection. In HEADLESS mode there is NO wait, and the default selection is returned.
Also added catching of generic exceptions withusing a ShowErrorWait
Can't use QTextEdit in messages Unused variables in main
Added files for global messageboxes with the main dialog as parent and with a standardized title. In headless mode the messages will be shown on terminal instead. (Also added myself to contributors list)
Now translating html text to plain text before sending it to console.
ShowXxxWait messageboxes will wait for the/a button to be pressed in gui mode. ShowXxxWait messageboxes also have an optional 'abort' button and a default selection. In HEADLESS mode there is NO wait, and the default selection is returned.
Also added catching of generic exceptions withusing a ShowErrorWait
Can't use QTextEdit in messages Unused variables in main
I think the idea is still valuable. However to keep the PR view clean, I'll close this for now. |
Short description of changes
New implementation of the messageboxes part of #2583
CHANGELOG: Messageboxes will show up related to the instance instead of at system default position and they will have 'clientname' in the window title. In headless mode the messages will appear on the terminal.
Context: Fixes an issue?
General improvement and preparation for sound-redesign.
Does this change need documentation? What needs to be documented and how?
No documentation changes
Status of this Pull Request
Waiting on review
What is missing until this pull request can be merged?
Checklist