QtPass
2.0.0
Developer documentation
Toggle main menu visibility
Loading...
Searching...
No Matches
plainmessagebox.cpp
Go to the documentation of this file.
1
// SPDX-FileCopyrightText: 2026 Anne Jan Brouwer
2
// SPDX-License-Identifier: GPL-3.0-or-later
8
#include "
plainmessagebox.h
"
9
10
auto
PlainMessageBox::show
(QWidget *parent, QMessageBox::Icon icon,
11
const
QString &title,
const
QString &text,
12
QMessageBox::StandardButtons buttons)
13
-> QMessageBox::StandardButton {
14
QMessageBox box(parent);
15
box.setIcon(icon);
16
box.setWindowTitle(title);
17
// Before the text: set afterwards, the text would already have been laid
18
// out as rich text once.
19
box.setTextFormat(Qt::PlainText);
20
box.setText(text);
21
box.setStandardButtons(buttons);
22
return
static_cast<
QMessageBox::StandardButton
>
(box.exec());
23
}
24
25
auto
PlainMessageBox::askYes
(QWidget *parent,
const
QString &title,
26
const
QString &text) ->
bool
{
27
return
show
(parent, QMessageBox::Question, title, text,
28
QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes;
29
}
30
31
void
PlainMessageBox::warning
(QWidget *parent,
const
QString &title,
32
const
QString &text) {
33
show
(parent, QMessageBox::Warning, title, text);
34
}
35
36
void
PlainMessageBox::critical
(QWidget *parent,
const
QString &title,
37
const
QString &text) {
38
show
(parent, QMessageBox::Critical, title, text);
39
}
PlainMessageBox::show
auto show(QWidget *parent, QMessageBox::Icon icon, const QString &title, const QString &text, QMessageBox::StandardButtons buttons=QMessageBox::Ok) -> QMessageBox::StandardButton
Show a modal message box with plain text and wait for it.
Definition
plainmessagebox.cpp:10
PlainMessageBox::askYes
auto askYes(QWidget *parent, const QString &title, const QString &text) -> bool
Ask a yes/no question in plain text.
Definition
plainmessagebox.cpp:25
PlainMessageBox::warning
void warning(QWidget *parent, const QString &title, const QString &text)
Show a warning in plain text.
Definition
plainmessagebox.cpp:31
PlainMessageBox::critical
void critical(QWidget *parent, const QString &title, const QString &text)
Show an error in plain text.
Definition
plainmessagebox.cpp:36
plainmessagebox.h
QMessageBox helpers that force Qt::PlainText so store-controlled names can never be read as rich-text...
src
plainmessagebox.cpp
Generated by
1.18.0