MCPcopy Create free account
hub / github.com/TheAssassin/AppImageLauncher / displayMessageBox

Function displayMessageBox

src/shared/shared.cpp:244–253  ·  view source on GitHub ↗

avoids code duplication, and works for both graphical and non-graphical environments

Source from the content-addressed store, hash-verified

242
243// avoids code duplication, and works for both graphical and non-graphical environments
244void displayMessageBox(const QString& title, const QString& message, const QMessageBox::Icon icon) {
245 if (isHeadless()) {
246 std::cerr << title.toStdString() << ": " << message.toStdString() << std::endl;
247 } else {
248 // little complex, can't use QMessageBox::{critical,warning,...} for the same reason as in main()
249 auto* mb = new QMessageBox(icon, title, message, QMessageBox::Ok, nullptr);
250 mb->show();
251 QApplication::exec();
252 }
253}
254
255void displayError(const QString& message) {
256 displayMessageBox(QObject::tr("Error"), message, QMessageBox::Critical);

Callers 2

displayErrorFunction · 0.85
displayWarningFunction · 0.85

Calls 1

isHeadlessFunction · 0.85

Tested by

no test coverage detected