Kstars

ksmessagebox.h
1/* KStars Asynchronous Message Box Implementation for Desktop/Android and EkosLive
2 Based on QMessageBox.
3
4 SPDX-FileCopyrightText: 2019 Jasem Mutlaq <mutlaqja@ikarustech.com>
5
6 SPDX-License-Identifier: GPL-2.0-or-later
7*/
8
9#pragma once
10
11#include <KLocalizedString>
12
13#include <QMessageBox>
14#include <QPointer>
15#include <QTimer>
16#include <QRoundProgressBar.h>
17#include <QJsonObject>
18#include <QJsonArray>
19#include <QHBoxLayout>
20
21/**
22 * @class KSMessageBox
23 * KStars Message Box implementation.
24 *
25 * @author Jasem Mutlaq
26 */
28{
30 Q_PROPERTY(quint32 timeout MEMBER m_Timeout)
31
32 public:
33 static KSMessageBox *Instance();
34
35 void questionYesNo(const QString &message, const QString &title = i18n("Question"), quint32 timeout = 0,
36 bool defaultToYes = true, const QString &yesText = i18n("Yes"), const QString &noText = i18n("No"));
37 void warningContinueCancel(const QString &message, const QString &title = i18n("Warning"), quint32 timeout = 0,
38 bool defaultToContinue = true, const QString &continueText = i18n("Continue"), const QString &cancelText = i18n("Cancel"));
39 void error(const QString &message, const QString &title = i18n("Error"), quint32 timeout = 0);
40 void sorry(const QString &message, const QString &title = i18n("Sorry"), quint32 timeout = 0);
41 void info(const QString &message, const QString &title = i18n("Info"), quint32 timeout = 0);
42 /**
43 * @brief transient Non modal message box that gets deleted on close.
44 * @param message message content
45 * @param title message title
46 */
47 void transient(const QString &message, const QString &title);
48
49 /**
50 * @brief selectResponse Programatically select one the buttons in the dialog.
51 * @param button text of button to click
52 * @return True if button is found and clicked, false otherwise.
53 */
54 bool selectResponse(const QString &button);
55
56 signals:
57 void newMessage(const QJsonObject &message);
58
59 protected:
60 void timerTick();
61
62 private:
63 // Dialog timeout in seconds
64 quint32 m_Timeout {60};
65
66 static KSMessageBox *m_Instance;
67
68 void reset();
69 void addOKButton();
70 void setupTimeout(quint32 timeout);
71 void resetTimeout()
72 {
73 m_Timeout = 0;
74 }
75 QJsonObject createMessageObject();
77
78 QPointer<QRoundProgressBar> m_ProgressIndicator;
79 QPointer<QLabel> m_ProgressLabel;
80 QPointer<QHBoxLayout> m_ProgressLayout;
81
82 QTimer m_ProgressTimer;
83};
84
KStars Message Box implementation.
void transient(const QString &message, const QString &title)
transient Non modal message box that gets deleted on close.
bool selectResponse(const QString &button)
selectResponse Programatically select one the buttons in the dialog.
QString i18n(const char *text, const TYPE &arg...)
QAbstractButton * button(StandardButton which) const const
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:16:39 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.