Kstars

ksnotification.cpp
1 /*
2  SPDX-FileCopyrightText: 2016 Jasem Mutlaq <[email protected]>
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 
28 namespace KSNotification
29 {
30 void 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 
40 void 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 
50 void 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 
60 void transient(const QString &message, const QString &title)
61 {
62 #ifdef KSTARS_LITE
63  Q_UNUSED(title);
65 #else
66  QPointer<QMessageBox> msgBox = new QMessageBox();
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 
80 void event(const QLatin1String &name, const QString &message, EventType type)
81 {
82  Q_UNUSED(name)
83  Q_UNUSED(message)
84  Q_UNUSED(type)
85 #ifndef KSTARS_LITE
87 
88 #ifdef HAVE_INDI
89 #ifdef HAVE_CFITSIO
90  Ekos::Manager::Instance()->announceEvent(message, type);
91 #endif
92 #endif
93 
94 #endif
95 }
96 
97 }
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.
static KNotification * event(const QString &eventId, const QString &text=QString(), const QPixmap &pixmap=QPixmap(), QWidget *widget=nullptr, const NotificationFlags &flags=CloseOnTimeout, const QString &componentName=QString())
QString message
WA_DeleteOnClose
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Fri Aug 12 2022 04:00:55 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.