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
80void event(const QLatin1String &name, const QString &message, EventSource source, EventType type)
81{
82 Q_UNUSED(name)
83 Q_UNUSED(message)
84 Q_UNUSED(type)
85#ifndef KSTARS_LITE
86 KNotification::event(name, message);
87
88#ifdef HAVE_INDI
89#ifdef HAVE_CFITSIO
90 Ekos::Manager::Instance()->announceEvent(message, source, type);
91#endif
92#endif
93
94#endif
95}
96
97}
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.
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-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:04:45 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.