umbrello  26.08.2
Umbrello UML Modeller is a Unified Modelling Language (UML) diagram program based on KDE Technology
umlmessagebox.h
Go to the documentation of this file.
1 /*
2  SPDX-FileCopyrightText: 2025 Umbrello UML Modeller Authors <umbrello-devel@kde.org>
3  SPDX-License-Identifier: GPL-2.0-or-later
4 */
5 
6 #pragma once
7 
8 #include <KGuiItem>
9 #include <KLocalizedString>
10 #include <KMessageBox>
11 #include <KStandardGuiItem>
12 
13 #include <QString>
14 #include <QWidget>
15 
16 // ----------------------------------------------------------------------------
17 // Project Includes
18 
19 namespace UmlMessageBox {
20 
21 const int Yes = KMessageBox::PrimaryAction;
22 const int No = KMessageBox::SecondaryAction;
24 
25 inline KGuiItem yes()
26 {
27  return KGuiItem(i18nc("@action:button", "Yes"), QStringLiteral("dialog-ok"));
28 }
29 
30 inline KGuiItem no()
31 {
32  return KGuiItem(i18nc("@action:button", "No"), QStringLiteral("dialog-no"));
33 }
34 
35 inline KGuiItem cancel()
36 {
37  return KStandardGuiItem::cancel();
38 }
39 
40 inline int questionYesNo(QWidget *parent,
41  const QString &text,
42  const QString &caption = QString(),
43  const KGuiItem &yes = UmlMessageBox::yes(),
44  const KGuiItem &no = UmlMessageBox::no())
45 {
46  auto result = KMessageBox::questionTwoActions(parent, text, caption, yes, no);
47  return (result == KMessageBox::PrimaryAction) ? Yes : No;
48 }
49 
50 inline int warningYesNo(QWidget *parent,
51  const QString &text,
52  const QString &caption = QString(),
53  const KGuiItem &yes = UmlMessageBox::yes(),
54  const KGuiItem &no = UmlMessageBox::no())
55 {
56  auto result = KMessageBox::warningTwoActions(parent, text, caption, yes, no);
57  return (result == KMessageBox::PrimaryAction) ? Yes : No;
58 }
59 
60 inline int warningYesNoCancel(QWidget *parent,
61  const QString &text,
62  const QString &caption = QString(),
63  const KGuiItem &yes = UmlMessageBox::yes(),
64  const KGuiItem &no = UmlMessageBox::no(),
65  const KGuiItem &cancel = UmlMessageBox::cancel())
66 {
67  auto result = KMessageBox::warningTwoActionsCancel(parent, text, caption, yes, no, cancel);
68  return (result == KMessageBox::PrimaryAction) ? Yes : No;
69 }
70 
71 } // namespace UmlMessageBox
const int Yes
Definition: umlmessagebox.h:21
int questionYesNo(QWidget *parent, const QString &text, const QString &caption=QString(), const KGuiItem &yes=UmlMessageBox::yes(), const KGuiItem &no=UmlMessageBox::no())
Definition: umlmessagebox.h:40
KGuiItem yes()
Definition: umlmessagebox.h:25
Definition: umlmessagebox.h:19
int warningYesNoCancel(QWidget *parent, const QString &text, const QString &caption=QString(), const KGuiItem &yes=UmlMessageBox::yes(), const KGuiItem &no=UmlMessageBox::no(), const KGuiItem &cancel=UmlMessageBox::cancel())
Definition: umlmessagebox.h:60
const int No
Definition: umlmessagebox.h:22
int warningYesNo(QWidget *parent, const QString &text, const QString &caption=QString(), const KGuiItem &yes=UmlMessageBox::yes(), const KGuiItem &no=UmlMessageBox::no())
Definition: umlmessagebox.h:50
KGuiItem cancel()
Definition: umlmessagebox.h:35
const int Cancel
Definition: umlmessagebox.h:23
KGuiItem no()
Definition: umlmessagebox.h:30