Kstars

ksnotification.cpp
1/*
2 SPDX-FileCopyrightText: 2016 Jasem Mutlaq <mutlaqja@ikarustech.com>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#include "ksnotification.h"
8#include "config-kstars.h"
9#include "Options.h"
10
11#ifdef KSTARS_LITE
12#include "kstarslite.h"
13#else
14#include <QPointer>
15#include <QTimer>
16#include <KNotification>
17
18#include "ksmessagebox.h"
19
20#ifdef HAVE_INDI
21#ifdef HAVE_CFITSIO
22#include "kstars.h"
23#include "ekos/manager.h"
24#endif
25#endif
26#endif // KSTARS_LITE
27
29{
30void error(const QString &message, const QString &title, uint32_t timeout)
31{
32#ifdef KSTARS_LITE
33 Q_UNUSED(title);
35#else
36 KSMessageBox::Instance()->error(message, title, timeout);
37#endif
38}
39
40void sorry(const QString &message, const QString &title, uint32_t timeout)
41{
42#ifdef KSTARS_LITE
43 Q_UNUSED(title);
45#else
46 KSMessageBox::Instance()->sorry(message, title, timeout);
47#endif
48}
49
50void info(const QString &message, const QString &title, uint32_t timeout)
51{
52#ifdef KSTARS_LITE
53 Q_UNUSED(title);
55#else
56 KSMessageBox::Instance()->info(message, title, timeout);
57#endif
58}
59
60void transient(const QString &message, const QString &title)
61{
62#ifdef KSTARS_LITE
63 Q_UNUSED(title);
65#else
67 msgBox->setAttribute(Qt::WA_DeleteOnClose);
68 msgBox->setWindowTitle(title);
69 msgBox->setText(message);
70 msgBox->setModal(false);
71 msgBox->setIcon(QMessageBox::Warning);
72 msgBox->show();
73 QTimer::singleShot(10000, msgBox, [msgBox]()
74 {
75 if (msgBox) msgBox->close();
76 });
77#endif
78}
79
80QSharedPointer<QMessageBox> closeableMessage(const QString &message, const QString &title)
81{
82#ifdef KSTARS_LITE
83 Q_UNUSED(title);
86#else
88 msgBox->setAttribute(Qt::WA_DeleteOnClose);
89 msgBox->setWindowTitle(title);
90 msgBox->setText(message);
91 msgBox->setModal(false);
92 msgBox->setIcon(QMessageBox::Warning);
93 msgBox->show();
94 return msgBox;
95#endif
96}
97
98void event(const QLatin1String &name, const QString &message, EventSource source, EventType type)
99{
100 Q_UNUSED(name)
101 Q_UNUSED(message)
102 Q_UNUSED(type)
103#ifndef KSTARS_LITE
104 KNotification::event(name, message);
105
106#ifdef HAVE_INDI
107#ifdef HAVE_CFITSIO
108 Ekos::Manager::Instance()->announceEvent(message, source, type);
109#endif
110#endif
111
112#endif
113}
114
115}
static KNotification * event(const QString &eventId, const QString &text=QString(), const QPixmap &pixmap=QPixmap(), const NotificationFlags &flags=CloseOnTimeout, const QString &componentName=QString())
static KStarsLite * Instance()
Definition kstarslite.h:77
void notificationMessage(QString msg)
Once this signal is emitted, notification with text msg will appear on the screen.
AKONADI_CALENDAR_EXPORT KCalendarCore::Event::Ptr event(const Akonadi::Item &item)
General KStars Notifications for desktop and lite version.
void transient(const QString &message, const QString &title)
transient Non modal message box that gets deleted on close.
WA_DeleteOnClose
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 3 2025 11:47:14 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.