SILICON
Loading...
Searching...
No Matches
inputDialogUtils.hpp
Go to the documentation of this file.
1/*
2 Copyright (c) 2026. Giulio Cocconi
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#pragma once
19
20#include <functional>
21
22#include <QString>
23#include <QStringList>
24
25class QGraphicsItem;
26class QWidget;
27class QObject;
28
30
31using TextCallback = std::function<void(const QString&)>;
32using AcceptedCallback = std::function<void()>;
33
34enum class Choice { Primary, Secondary, Cancel };
35using ChoiceCallback = std::function<void(Choice)>;
36
37QWidget* parentWidgetForGraphicsItem(const QGraphicsItem* item);
38
39void getText(QWidget* parent, const QString& title, const QString& label,
40 const QString& defaultText, TextCallback callback,
41 QObject* context = nullptr);
42
43void getItem(QWidget* parent, const QString& title, const QString& label,
44 const QStringList& items, int current, bool editable, TextCallback callback,
45 QObject* context = nullptr);
46
47void warning(QWidget* parent, const QString& title, const QString& text);
48
49void critical(QWidget* parent, const QString& title, const QString& text);
50
51void question(QWidget* parent, const QString& title, const QString& text,
52 AcceptedCallback accepted, QObject* context = nullptr);
53
55void warningChoice(QWidget* parent, const QString& title, const QString& text,
56 const QString& primaryText, const QString& secondaryText,
57 ChoiceCallback callback, QObject* context = nullptr);
58
59} // namespace SILICON::ui::inputDialog
std::function< void()> AcceptedCallback
void question(QWidget *parent, const QString &title, const QString &text, AcceptedCallback accepted, QObject *context)
std::function< void(const QString &)> TextCallback
QWidget * parentWidgetForGraphicsItem(const QGraphicsItem *item)
std::function< void(Choice)> ChoiceCallback
void critical(QWidget *parent, const QString &title, const QString &text)
void warningChoice(QWidget *parent, const QString &title, const QString &text, const QString &primaryText, const QString &secondaryText, ChoiceCallback callback, QObject *context)
Shows a three-way warning using caller-provided action labels.
void getItem(QWidget *parent, const QString &title, const QString &label, const QStringList &items, int current, bool editable, TextCallback callback, QObject *context)
void warning(QWidget *parent, const QString &title, const QString &text)
void getText(QWidget *parent, const QString &title, const QString &label, const QString &defaultText, TextCallback callback, QObject *context)