Disable rich text for ui_msgbox()-generated dialogs
No strings that gets passed to `ui_msgbox()` use HTML, and it causes newlines to be ignored unless replaced by <br> `MainWindow::showMessage()` can still accept rich text, but it's now optional and disabled by default
This commit is contained in:
@@ -501,7 +501,7 @@ network_attach(void *card_drv, uint8_t *mac, NETRXCB rx, NETSETLINKSTATE set_lin
|
||||
|
||||
if(net_cards_conf[net_card_current].net_type != NET_TYPE_NONE) {
|
||||
// We're here because of a failure
|
||||
swprintf(tempmsg, sizeof_w(tempmsg), L"%ls:<br /><br />%s<br /><br />%ls", plat_get_string(STRING_NET_ERROR), net_drv_error, plat_get_string(STRING_NET_ERROR_DESC));
|
||||
swprintf(tempmsg, sizeof_w(tempmsg), L"%ls:\n\n%s\n\n%ls", plat_get_string(STRING_NET_ERROR), net_drv_error, plat_get_string(STRING_NET_ERROR_DESC));
|
||||
ui_msgbox(MBX_ERROR, tempmsg);
|
||||
net_cards_conf[net_card_current].net_type = NET_TYPE_NONE;
|
||||
}
|
||||
|
||||
@@ -1342,17 +1342,17 @@ MainWindow::refreshMediaMenu()
|
||||
}
|
||||
|
||||
void
|
||||
MainWindow::showMessage(int flags, const QString &header, const QString &message)
|
||||
MainWindow::showMessage(int flags, const QString &header, const QString &message, bool richText)
|
||||
{
|
||||
if (QThread::currentThread() == this->thread()) {
|
||||
if (!cpu_thread_running) {
|
||||
showMessageForNonQtThread(flags, header, message, nullptr);
|
||||
showMessageForNonQtThread(flags, header, message, richText, nullptr);
|
||||
}
|
||||
else
|
||||
showMessage_(flags, header, message);
|
||||
showMessage_(flags, header, message, richText);
|
||||
} else {
|
||||
std::atomic_bool done = false;
|
||||
emit showMessageForNonQtThread(flags, header, message, &done);
|
||||
emit showMessageForNonQtThread(flags, header, message, richText, &done);
|
||||
while (!done) {
|
||||
QThread::msleep(1);
|
||||
}
|
||||
@@ -1360,7 +1360,7 @@ MainWindow::showMessage(int flags, const QString &header, const QString &message
|
||||
}
|
||||
|
||||
void
|
||||
MainWindow::showMessage_(int flags, const QString &header, const QString &message, std::atomic_bool *done)
|
||||
MainWindow::showMessage_(int flags, const QString &header, const QString &message, bool richText, std::atomic_bool *done)
|
||||
{
|
||||
if (done) {
|
||||
*done = false;
|
||||
@@ -1372,7 +1372,8 @@ MainWindow::showMessage_(int flags, const QString &header, const QString &messag
|
||||
} else if (!(flags & (MBX_ERROR | MBX_WARNING))) {
|
||||
box.setIcon(QMessageBox::Warning);
|
||||
}
|
||||
box.setTextFormat(Qt::TextFormat::RichText);
|
||||
if (richText)
|
||||
box.setTextFormat(Qt::TextFormat::RichText);
|
||||
box.exec();
|
||||
if (done) {
|
||||
*done = true;
|
||||
|
||||
@@ -26,7 +26,7 @@ public:
|
||||
explicit MainWindow(QWidget *parent = nullptr);
|
||||
~MainWindow();
|
||||
|
||||
void showMessage(int flags, const QString &header, const QString &message);
|
||||
void showMessage(int flags, const QString &header, const QString &message, bool richText);
|
||||
void getTitle(wchar_t *title);
|
||||
void blitToWidget(int x, int y, int w, int h, int monitor_index);
|
||||
QSize getRenderWidgetSize();
|
||||
@@ -55,7 +55,7 @@ signals:
|
||||
void setFullscreen(bool state);
|
||||
void setMouseCapture(bool state);
|
||||
|
||||
void showMessageForNonQtThread(int flags, const QString &header, const QString &message, std::atomic_bool* done);
|
||||
void showMessageForNonQtThread(int flags, const QString &header, const QString &message, bool richText, std::atomic_bool* done);
|
||||
void getTitleForNonQtThread(wchar_t *title);
|
||||
public slots:
|
||||
void showSettings();
|
||||
@@ -123,7 +123,7 @@ private slots:
|
||||
void on_actionRenderer_options_triggered();
|
||||
|
||||
void refreshMediaMenu();
|
||||
void showMessage_(int flags, const QString &header, const QString &message, std::atomic_bool* done = nullptr);
|
||||
void showMessage_(int flags, const QString &header, const QString &message, bool richText, std::atomic_bool* done = nullptr);
|
||||
void getTitle_(wchar_t *title);
|
||||
|
||||
void on_actionMCA_devices_triggered();
|
||||
|
||||
@@ -200,7 +200,7 @@ OpenGLRenderer::create_program(struct shader_program *program)
|
||||
glw.glGetProgramiv(program->id, GL_INFO_LOG_LENGTH, &maxLength);
|
||||
char *log = (char *) malloc(maxLength);
|
||||
glw.glGetProgramInfoLog(program->id, maxLength, &length, log);
|
||||
main_window->showMessage(MBX_ERROR | MBX_FATAL, tr("GLSL Error"), tr("Program not linked:\n\n%1").arg(log).replace("\n", "<br>"));
|
||||
main_window->showMessage(MBX_ERROR | MBX_FATAL, tr("GLSL Error"), tr("Program not linked:\n\n%1").arg(log), false);
|
||||
// wx_simple_messagebox("GLSL Error", "Program not linked:\n%s", log);
|
||||
free(log);
|
||||
return 0;
|
||||
@@ -247,7 +247,7 @@ OpenGLRenderer::compile_shader(GLenum shader_type, const char *prepend, const ch
|
||||
glw.glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &length);
|
||||
char *log = (char *) malloc(length);
|
||||
glw.glGetShaderInfoLog(shader, length, &length, log);
|
||||
main_window->showMessage(MBX_ERROR | MBX_FATAL, tr("GLSL Error"), tr("Could not compile shader:\n\n%1").arg(log).replace("\n", "<br>"));
|
||||
main_window->showMessage(MBX_ERROR | MBX_FATAL, tr("GLSL Error"), tr("Could not compile shader:\n\n%1").arg(log), false);
|
||||
// wx_simple_messagebox("GLSL Error", "Could not compile shader:\n%s", log);
|
||||
|
||||
ogl3_log("Could not compile shader: %s\n", log);
|
||||
@@ -651,7 +651,7 @@ OpenGLRenderer::load_glslp(glsl_t *glsl, int num_shader, const char *f)
|
||||
|
||||
if (!load_texture(file, &tex->texture)) {
|
||||
//QMessageBox::critical(main_window, tr("GLSL Error"), tr("Could not load texture: %s").arg(file));
|
||||
main_window->showMessage(MBX_ERROR | MBX_FATAL, tr("GLSL Error"), tr("Could not load texture: %1").arg(file));
|
||||
main_window->showMessage(MBX_ERROR | MBX_FATAL, tr("GLSL Error"), tr("Could not load texture: %1").arg(file), false);
|
||||
ogl3_log("Could not load texture %s!\n", file);
|
||||
failed = 1;
|
||||
break;
|
||||
@@ -697,7 +697,7 @@ OpenGLRenderer::load_glslp(glsl_t *glsl, int num_shader, const char *f)
|
||||
ogl3_log("Creating pass %u (%s)\n", (i + 1), pass->alias);
|
||||
ogl3_log("Loading shader %s...\n", shader->shader_fn);
|
||||
if (!shader->shader_program) {
|
||||
main_window->showMessage(MBX_ERROR | MBX_FATAL, tr("GLSL Error"), tr("Could not load shader: %1").arg(shader->shader_fn));
|
||||
main_window->showMessage(MBX_ERROR | MBX_FATAL, tr("GLSL Error"), tr("Could not load shader: %1").arg(shader->shader_fn), false);
|
||||
// wx_simple_messagebox("GLSL Error", "Could not load shader: %s", shader->shader_fn);
|
||||
ogl3_log("Could not load shader %s\n", shader->shader_fn);
|
||||
failed = 1;
|
||||
@@ -1115,7 +1115,7 @@ OpenGLRenderer::initialize()
|
||||
for (auto &flag : buf_usage)
|
||||
flag.test_and_set();
|
||||
|
||||
main_window->showMessage(MBX_ERROR | MBX_FATAL, tr("Error initializing OpenGL"), e.what() + tr("\nFalling back to software rendering."));
|
||||
main_window->showMessage(MBX_ERROR | MBX_FATAL, tr("Error initializing OpenGL"), e.what() + tr("\nFalling back to software rendering."), false);
|
||||
|
||||
context->doneCurrent();
|
||||
isFinalized = true;
|
||||
|
||||
@@ -142,11 +142,10 @@ ui_msgbox_header(int flags, void *header, void *message)
|
||||
// any error in early init
|
||||
if (main_window == nullptr) {
|
||||
QMessageBox msgBox(QMessageBox::Icon::Critical, hdr, msg);
|
||||
msgBox.setTextFormat(Qt::TextFormat::RichText);
|
||||
msgBox.exec();
|
||||
} else {
|
||||
// else scope it to main_window
|
||||
main_window->showMessage(flags, hdr, msg);
|
||||
main_window->showMessage(flags, hdr, msg, false);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user