Kstars

kstars.cpp
1 /*
2  SPDX-FileCopyrightText: 2001 Jason Harris <[email protected]>
3 
4  SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #include "kstars.h"
8 
9 #include "config-kstars.h"
10 #include "version.h"
11 
12 #include "fov.h"
13 #include "kactionmenu.h"
14 #include "kstarsadaptor.h"
15 #include "kstarsdata.h"
16 #include "kstarssplash.h"
17 #include "observinglist.h"
18 #include "Options.h"
19 #include "skymap.h"
20 #include "skyqpainter.h"
21 #include "texturemanager.h"
22 #include "dialogs/finddialog.h"
23 #include "dialogs/exportimagedialog.h"
24 #include "skycomponents/starblockfactory.h"
25 #ifdef HAVE_INDI
26 #include "ekos/manager.h"
27 #include "indi/drivermanager.h"
28 #include "indi/guimanager.h"
29 #include "indi/indilistener.h"
30 #endif
31 
32 #ifdef HAVE_CFITSIO
33 #include "fitsviewer/fitsviewer.h"
34 #endif
35 
36 #include <KActionCollection>
37 #include <KToolBar>
38 
39 #ifdef Q_OS_WIN
40 #include <QProcess>
41 #endif
42 #include <QStatusBar>
43 #include <QMenu>
44 
45 #include <kstars_debug.h>
46 
47 KStars *KStars::pinstance = nullptr;
48 bool KStars::Closing = false;
49 
50 KStars::KStars(bool doSplash, bool clockrun, const QString &startdate)
51  : KXmlGuiWindow(), StartClockRunning(clockrun), StartDateString(startdate)
52 {
53  // FIXME Hack to set RTL direction for Arabic
54  // This is not a solution. It seems qtbase_ar.qm needs to take care of this?
55  // qttranslations5-l10n does not contain qtbase_ar.qm
56  // It seems qtbase_ar.ts does not exist for Qt 5.9 at all and needs to be translated.
57  // https://wiki.qt.io/Qt_Localization
58  if (i18n("Sky") == "السماء")
60 
61  setWindowTitle(i18nc("@title:window", "KStars"));
62 
63  // Set thread stack size to 32MB
64 #if QT_VERSION >= QT_VERSION_CHECK(5,10,0)
66 #endif
67 
68  // Initialize logging settings
69  if (Options::disableLogging())
71  else if (Options::logToFile())
73  else
75 
77 
78  qCInfo(KSTARS) << "Welcome to KStars" << KSTARS_VERSION << KSTARS_BUILD_RELEASE;
79  qCInfo(KSTARS) << "Build:" << KSTARS_BUILD_TS;
80  qCInfo(KSTARS) << "OS:" << QSysInfo::productType();
81  qCInfo(KSTARS) << "API:" << QSysInfo::buildAbi();
82  qCInfo(KSTARS) << "Arch:" << QSysInfo::currentCpuArchitecture();
83  qCInfo(KSTARS) << "Kernel Type:" << QSysInfo::kernelType();
84  qCInfo(KSTARS) << "Kernel Version:" << QSysInfo::kernelVersion();
85  qCInfo(KSTARS) << "Qt Version:" << QT_VERSION_STR;
86 
87  new KstarsAdaptor(
88  this); // NOTE the weird case convention, which cannot be changed as the file is generated by the moc.
89 
90 #ifdef Q_OS_OSX
91 
92  QString vlcPlugins = QDir(QCoreApplication::applicationDirPath() + "/../PlugIns/vlc").absolutePath();
93  qputenv("VLC_PLUGIN_PATH", vlcPlugins.toLatin1());
94  QString phonon_backend_path = QDir(QCoreApplication::applicationDirPath() +
95  "/../PlugIns/phonon4qt5_backend/phonon_vlc.so").absolutePath();
96  qputenv("PHONON_BACKEND", phonon_backend_path.toLatin1());
97 
99  QString path = env.value("PATH", "");
100  env.insert("PATH", "/usr/bin:/usr/local/bin:\"" + QCoreApplication::applicationDirPath() + "\":" + path);
101 
102  QProcess dbusCheck;
103  dbusCheck.setProcessEnvironment(env);
104 
105  QString pluginsDir = QDir(QCoreApplication::applicationDirPath() + "/../PlugIns").absolutePath();
106  QString dbusPlist = pluginsDir + "/dbus/org.freedesktop.dbus-kstars.plist";
107  QFile file(dbusPlist);
108  if (file.open(QIODevice::ReadOnly))
109  {
110  QTextStream in(&file);
111  QString pListText = in.readAll();
112  file.close();
113  int programArgsLeft = pListText.indexOf("<key>ProgramArguments</key>");
114  int programArgsRight = pListText.indexOf("</array>", programArgsLeft) + 8 - programArgsLeft;
115  QString currentProgramArgs = pListText.mid(programArgsLeft, programArgsRight);
116  QString newProgramArguments = ""
117  "<key>ProgramArguments</key>\n"
118  " <array>\n"
119  " <string>" +
121  "/dbus-daemon</string>\n"
122  " <string>--nofork</string>\n"
123  " <string>--config-file=" +
124  pluginsDir +
125  "/dbus/kstars.conf</string>\n"
126  " </array>";
127  pListText.replace(currentProgramArgs, newProgramArguments);
128  if (file.open(QIODevice::WriteOnly))
129  {
130  QTextStream stream(&file);
131  stream << pListText;
132  file.close();
133 
134  dbusCheck.start("chmod 775 " + dbusPlist);
135  dbusCheck.waitForFinished();
136  dbusCheck.start("launchctl load -w \"" + dbusPlist + "\"");
137  dbusCheck.waitForFinished();
138  qDebug("Starting DBus");
139  }
140  else
141  {
142  qDebug("DBus File Write Error");
143  }
144  }
145  else
146  {
147  qDebug("DBus File Read Error");
148  }
149 #endif
150 
151  QDBusConnection::sessionBus().registerObject("/KStars", this);
152  QDBusConnection::sessionBus().registerService("org.kde.kstars");
153 
154 #ifdef HAVE_CFITSIO
155  m_GenericFITSViewer.clear();
156 #endif
157 
158  // Set pinstance to yourself
159  pinstance = this;
160 
161  connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(slotAboutToQuit()));
162 
163  //Initialize QActionGroups
164  projectionGroup = new QActionGroup(this);
165  cschemeGroup = new QActionGroup(this);
166  hipsGroup = new QActionGroup(this);
167  telescopeGroup = new QActionGroup(this);
168  telescopeGroup->setExclusive(false);
169  domeGroup = new QActionGroup(this);
170  domeGroup->setExclusive(false);
171 
172 
173  m_KStarsData = KStarsData::Create();
174  Q_ASSERT(m_KStarsData);
175  //Set Geographic Location from Options
176  m_KStarsData->setLocationFromOptions();
177 
178  //Initialize Time and Date
179  bool datetimeSet = false;
180  if (StartDateString.isEmpty() == false)
181  {
182  KStarsDateTime startDate = KStarsDateTime::fromString(StartDateString);
183  if (startDate.isValid())
184  data()->changeDateTime(data()->geo()->LTtoUT(startDate));
185  else
186  data()->changeDateTime(KStarsDateTime::currentDateTimeUtc());
187 
188  datetimeSet = true;
189  }
190  // JM 2016-11-15: Not need to set it again as it was initialized in the ctor of SimClock
191  /*
192  else
193  data()->changeDateTime( KStarsDateTime::currentDateTimeUtc() );
194  */
195 
196  // If we are starting paused (--paused is not in the command line) change datetime in data
197  if (StartClockRunning == false)
198  {
199  qCInfo(KSTARS) << "KStars is started in paused state.";
200  if (datetimeSet == false)
201  data()->changeDateTime(KStarsDateTime::currentDateTimeUtc());
202  }
203 
204  // Setup splash screen
205  KStarsSplash *splash = nullptr;
206  if (doSplash)
207  {
208  splash = new KStarsSplash(nullptr);
209  connect(m_KStarsData, SIGNAL(progressText(QString)), splash, SLOT(setMessage(QString)));
210  splash->show();
211  }
212  else
213  {
214  connect(m_KStarsData, SIGNAL(progressText(QString)), m_KStarsData, SLOT(slotConsoleMessage(QString)));
215  }
216 
217  /*
218  //set up Dark color scheme for application windows
219  DarkPalette = QPalette(QColor("black"), QColor("black"));
220  DarkPalette.setColor(QPalette::Inactive, QPalette::WindowText, QColor("red"));
221  DarkPalette.setColor(QPalette::Normal, QPalette::WindowText, QColor("red"));
222  DarkPalette.setColor(QPalette::Normal, QPalette::Base, QColor("black"));
223  DarkPalette.setColor(QPalette::Normal, QPalette::Text, QColor(238, 0, 0));
224  DarkPalette.setColor(QPalette::Normal, QPalette::Highlight, QColor(238, 0, 0));
225  DarkPalette.setColor(QPalette::Normal, QPalette::HighlightedText, QColor("black"));
226  DarkPalette.setColor(QPalette::Inactive, QPalette::Text, QColor(238, 0, 0));
227  DarkPalette.setColor(QPalette::Inactive, QPalette::Base, QColor(30, 10, 10));
228  //store original color scheme
229  OriginalPalette = QApplication::palette();
230  */
231 
232  //Initialize data. When initialization is complete, it will run dataInitFinished()
233  if (!m_KStarsData->initialize())
234  return;
235  delete splash;
236  datainitFinished();
237 }
238 
239 KStars *KStars::createInstance(bool doSplash, bool clockrun, const QString &startdate)
240 {
241  delete pinstance;
242  // pinstance is set directly in constructor.
243  new KStars(doSplash, clockrun, startdate);
244  Q_ASSERT(pinstance && "pinstance must be non NULL");
245  return pinstance;
246 }
247 
249 {
251  Q_ASSERT(pinstance);
252  pinstance = nullptr;
253 #ifdef PROFILE_COORDINATE_CONVERSION
254  qDebug() << Q_FUNC_INFO << "Spent " << SkyPoint::cpuTime_EqToHz << " seconds in " << SkyPoint::eqToHzCalls
255  << " calls to SkyPoint::EquatorialToHorizontal, for an average of "
256  << 1000. * (SkyPoint::cpuTime_EqToHz / SkyPoint::eqToHzCalls) << " ms per call";
257 #endif
258 
259 #ifdef COUNT_DMS_SINCOS_CALLS
260  qDebug() << Q_FUNC_INFO << "Constructed " << dms::dms_constructor_calls << " dms objects, of which " << dms::dms_with_sincos_called
261  << " had trigonometric functions called on them = "
262  << (float(dms::dms_with_sincos_called) / float(dms::dms_constructor_calls)) * 100. << "%";
263  qDebug() << Q_FUNC_INFO << "Of the " << dms::trig_function_calls << " calls to sin/cos/sincos on dms objects, "
264  << dms::redundant_trig_function_calls << " were redundant = "
265  << ((float(dms::redundant_trig_function_calls) / float(dms::trig_function_calls)) * 100.) << "%";
266  qDebug() << Q_FUNC_INFO << "We had " << CachingDms::cachingdms_bad_uses << " bad uses of CachingDms in all, compared to "
267  << CachingDms::cachingdms_constructor_calls << " constructed CachingDms objects = "
268  << (float(CachingDms::cachingdms_bad_uses) / float(CachingDms::cachingdms_constructor_calls)) * 100.
269  << "% bad uses";
270 #endif
271 
272  /* BUG 366596: Some KDE applications processes remain as background (zombie) processes after closing
273  * No solution to this bug so far using Qt 5.8 as of 2016-11-24
274  * Therefore, the only way to solve this on Windows is to explicitly kill kstars.exe
275  * Hopefully we do not need this hack once the above bug is resolved.
276  */
277 #ifdef Q_OS_WIN
278  QProcess::execute("taskkill /im kstars.exe /f");
279 #endif
280 }
281 
283 {
284  delete m_KStarsData;
285  m_KStarsData = nullptr;
286  delete StarBlockFactory::Instance();
290 
291 #ifdef HAVE_INDI
292  GUIManager::release();
294 #endif
295 
296 #ifdef HAVE_CFITSIO
297  //if (Options::independentWindowFITS())
298  qDeleteAll(m_FITSViewers);
299 #endif
300 
303 }
304 
306 {
307 #if 0
308  if (m_FindDialog) // dialog is cached
309  {
310  /** Delete findDialog only if it is not opened */
311  if (m_FindDialog->isHidden())
312  {
313  delete m_FindDialog;
314  m_FindDialog = nullptr;
315  DialogIsObsolete = false;
316  }
317  else
318  DialogIsObsolete = true; // dialog was opened so it could not deleted
319  }
320 #endif
321 }
322 
323 void KStars::applyConfig(bool doApplyFocus)
324 {
325  if (Options::isTracking())
326  {
327  actionCollection()->action("track_object")->setText(i18n("Stop &Tracking"));
329  ->action("track_object")
330  ->setIcon(QIcon::fromTheme("document-encrypt"));
331  }
332 
334  ->action("coordsys")
335  ->setText(Options::useAltAz() ? i18n("Switch to Star Globe View (Equatorial &Coordinates)") :
336  i18n("Switch to Horizonal View (Horizontal &Coordinates)"));
337 
338  actionCollection()->action("show_time_box")->setChecked(Options::showTimeBox());
339  actionCollection()->action("show_location_box")->setChecked(Options::showGeoBox());
340  actionCollection()->action("show_focus_box")->setChecked(Options::showFocusBox());
341  actionCollection()->action("show_statusBar")->setChecked(Options::showStatusBar());
342  actionCollection()->action("show_sbAzAlt")->setChecked(Options::showAltAzField());
343  actionCollection()->action("show_sbRADec")->setChecked(Options::showRADecField());
344  actionCollection()->action("show_sbJ2000RADec")->setChecked(Options::showJ2000RADecField());
345  actionCollection()->action("show_stars")->setChecked(Options::showStars());
346  actionCollection()->action("show_deepsky")->setChecked(Options::showDeepSky());
347  actionCollection()->action("show_planets")->setChecked(Options::showSolarSystem());
348  actionCollection()->action("show_clines")->setChecked(Options::showCLines());
349  actionCollection()->action("show_constellationart")->setChecked(Options::showConstellationArt());
350  actionCollection()->action("show_cnames")->setChecked(Options::showCNames());
351  actionCollection()->action("show_cbounds")->setChecked(Options::showCBounds());
352  actionCollection()->action("show_mw")->setChecked(Options::showMilkyWay());
353  actionCollection()->action("show_equatorial_grid")->setChecked(Options::showEquatorialGrid());
354  actionCollection()->action("show_horizontal_grid")->setChecked(Options::showHorizontalGrid());
355  actionCollection()->action("show_horizon")->setChecked(Options::showGround());
356  actionCollection()->action("show_flags")->setChecked(Options::showFlags());
357  actionCollection()->action("show_supernovae")->setChecked(Options::showSupernovae());
358  actionCollection()->action("show_satellites")->setChecked(Options::showSatellites());
359  statusBar()->setVisible(Options::showStatusBar());
360 
361  //color scheme
362  m_KStarsData->colorScheme()->loadFromConfig();
363  //QApplication::setPalette(Options::darkAppColors() ? DarkPalette : OriginalPalette);
364  /**
365  //Note: This uses style sheets to set the dark colors, this should be cross platform. Palettes have a different behavior on OS X and Windows as opposed to Linux.
366  //It might be a good idea to use stylesheets in the future instead of palettes but this will work for now for OS X.
367  //This is also in KStarsDbus.cpp. If you change it, change it in BOTH places.
368  @code
369  #ifdef Q_OS_OSX
370  if (Options::darkAppColors())
371  qApp->setStyleSheet(
372  "QWidget { background-color: black; color:red; "
373  "selection-background-color:rgb(30,30,30);selection-color:white}"
374  "QToolBar { border:none }"
375  "QTabBar::tab:selected { background-color:rgb(50,50,50) }"
376  "QTabBar::tab:!selected { background-color:rgb(30,30,30) }"
377  "QPushButton { background-color:rgb(50,50,50);border-width:1px; border-style:solid;border-color:black}"
378  "QPushButton::disabled { background-color:rgb(10,10,10);border-width:1px; "
379  "border-style:solid;border-color:black }"
380  "QToolButton:Checked { background-color:rgb(30,30,30); border:none }"
381  "QComboBox { background-color:rgb(30,30,30); }"
382  "QComboBox::disabled { background-color:rgb(10,10,10) }"
383  "QScrollBar::handle { background: rgb(30,30,30) }"
384  "QSpinBox { border-width: 1px; border-style:solid; border-color:rgb(30,30,30) }"
385  "QDoubleSpinBox { border-width:1px; border-style:solid; border-color:rgb(30,30,30) }"
386  "QLineEdit { border-width: 1px; border-style: solid; border-color:rgb(30,30,30) }"
387  "QCheckBox::indicator:unchecked { background-color:rgb(30,30,30);border-width:1px; "
388  "border-style:solid;border-color:black }"
389  "QCheckBox::indicator:checked { background-color:red;border-width:1px; "
390  "border-style:solid;border-color:black }"
391  "QRadioButton::indicator:unchecked { background-color:rgb(30,30,30) }"
392  "QRadioButton::indicator:checked { background-color:red }"
393  "QRoundProgressBar { alternate-background-color:black }"
394  "QDateTimeEdit {background-color:rgb(30,30,30); border-width: 1px; border-style:solid; "
395  "border-color:rgb(30,30,30) }"
396  "QHeaderView { color:red;background-color:black }"
397  "QHeaderView::Section { background-color:rgb(30,30,30) }"
398  "QTableCornerButton::section{ background-color:rgb(30,30,30) }"
399  "");
400  else
401  qApp->setStyleSheet("");
402  #endif
403  @endcode
404  **/
405 
406  //Set toolbar options from config file
407  toolBar("kstarsToolBar")->applySettings(KSharedConfig::openConfig()->group("MainToolBar"));
408  toolBar("viewToolBar")->applySettings(KSharedConfig::openConfig()->group("ViewToolBar"));
409 
410  //Geographic location
412 
413  //Focus
414  if (doApplyFocus)
415  {
416  SkyObject *fo = data()->objectNamed(Options::focusObject());
417  if (fo && fo != map()->focusObject())
418  {
419  map()->setClickedObject(fo);
420  map()->setClickedPoint(fo);
421  map()->slotCenter();
422  }
423 
424  if (!fo)
425  {
426  SkyPoint fp(Options::focusRA(), Options::focusDec());
427  if (fp.ra().Degrees() != map()->focus()->ra().Degrees() ||
428  fp.dec().Degrees() != map()->focus()->dec().Degrees())
429  {
430  map()->setClickedPoint(&fp);
431  map()->slotCenter();
432  }
433  }
434  }
435 }
436 
437 void KStars::showImgExportDialog()
438 {
439  if (m_ExportImageDialog)
440  m_ExportImageDialog->show();
441 }
442 
443 void KStars::syncFOVActions()
444 {
445  foreach (QAction *action, fovActionMenu->menu()->actions())
446  {
447  if (action->text().isEmpty())
448  {
449  continue;
450  }
451 
452  if (Options::fOVNames().contains(action->text().remove(0, 1)))
453  {
454  action->setChecked(true);
455  }
456  else
457  {
458  action->setChecked(false);
459  }
460  }
461 }
462 
463 void KStars::hideAllFovExceptFirst()
464 {
465  // When there is only one visible FOV symbol, we don't need to do anything
466  // Also, don't do anything if there are no available FOV symbols.
467  if (data()->visibleFOVs.size() == 1 || data()->availFOVs.isEmpty())
468  {
469  return;
470  }
471  else
472  {
473  // If there are no visible FOVs, select first available
474  if (data()->visibleFOVs.isEmpty())
475  {
476  Q_ASSERT(!data()->availFOVs.isEmpty());
477  Options::setFOVNames(QStringList(data()->availFOVs.first()->name()));
478  }
479  else
480  {
481  Options::setFOVNames(QStringList(data()->visibleFOVs.first()->name()));
482  }
483 
484  // Sync FOV and update skymap
485  data()->syncFOV();
486  syncFOVActions();
487  map()->update(); // SkyMap::forceUpdate() is not required, as FOVs are drawn as overlays
488  }
489 }
490 
491 void KStars::selectNextFov()
492 {
493  if (data()->getVisibleFOVs().isEmpty())
494  return;
495 
496  Q_ASSERT(!data()
497  ->getAvailableFOVs()
498  .isEmpty()); // The available FOVs had better not be empty if the visible ones are not.
499 
500  FOV *currentFov = data()->getVisibleFOVs().first();
501  int currentIdx = data()->availFOVs.indexOf(currentFov);
502 
503  // If current FOV is not the available FOV list or there is only 1 FOV available, then return
504  if (currentIdx == -1 || data()->availFOVs.size() < 2)
505  {
506  return;
507  }
508 
509  QStringList nextFovName;
510  if (currentIdx == data()->availFOVs.size() - 1)
511  {
512  nextFovName << data()->availFOVs.first()->name();
513  }
514  else
515  {
516  nextFovName << data()->availFOVs.at(currentIdx + 1)->name();
517  }
518 
519  Options::setFOVNames(nextFovName);
520  data()->syncFOV();
521  syncFOVActions();
522  map()->update();
523 }
524 
525 void KStars::selectPreviousFov()
526 {
527  if (data()->getVisibleFOVs().isEmpty())
528  return;
529 
530  Q_ASSERT(!data()
531  ->getAvailableFOVs()
532  .isEmpty()); // The available FOVs had better not be empty if the visible ones are not.
533 
534  FOV *currentFov = data()->getVisibleFOVs().first();
535  int currentIdx = data()->availFOVs.indexOf(currentFov);
536 
537  // If current FOV is not the available FOV list or there is only 1 FOV available, then return
538  if (currentIdx == -1 || data()->availFOVs.size() < 2)
539  {
540  return;
541  }
542 
543  QStringList prevFovName;
544  if (currentIdx == 0)
545  {
546  prevFovName << data()->availFOVs.last()->name();
547  }
548  else
549  {
550  prevFovName << data()->availFOVs.at(currentIdx - 1)->name();
551  }
552 
553  Options::setFOVNames(prevFovName);
554  data()->syncFOV();
555  syncFOVActions();
556  map()->update();
557 }
558 
559 //FIXME Port to QML2
560 //#if 0
561 void KStars::showWISettingsUI()
562 {
563  slotWISettings();
564 }
565 //#endif
566 
567 void KStars::updateTime(const bool automaticDSTchange)
568 {
569  // Due to frequently use of this function save data and map pointers for speedup.
570  // Save options and geo() to a pointer would not speedup because most of time options
571  // and geo will accessed only one time.
572  KStarsData *Data = data();
573  // dms oldLST( Data->lst()->Degrees() );
574 
575  Data->updateTime(Data->geo(), automaticDSTchange);
576 
577  //We do this outside of kstarsdata just to get the coordinates
578  //displayed in the infobox to update every second.
579  // if ( !Options::isTracking() && LST()->Degrees() > oldLST.Degrees() ) {
580  // int nSec = int( 3600.*( LST()->Hours() - oldLST.Hours() ) );
581  // Map->focus()->setRA( Map->focus()->ra().Hours() + double( nSec )/3600. );
582  // if ( Options::useAltAz() ) Map->focus()->EquatorialToHorizontal( LST(), geo()->lat() );
583  // Map->showFocusCoords();
584  // }
585 
586  //If time is accelerated beyond slewTimescale, then the clock's timer is stopped,
587  //so that it can be ticked manually after each update, in order to make each time
588  //step exactly equal to the timeScale setting.
589  //Wrap the call to manualTick() in a singleshot timer so that it doesn't get called until
590  //the skymap has been completely updated.
591  if (Data->clock()->isManualMode() && Data->clock()->isActive())
592  {
593  // Jasem 2017-11-13: Time for each update varies.
594  // Ideally we want to advance the simulation clock by
595  // the current clock scale (e.g. 1 hour) every 1 second
596  // of real time. However, the sky map update, depending on calculations and
597  // drawing of objects, takes variable time to complete.
598  //QTimer::singleShot(0, Data->clock(), SLOT(manualTick()));
599  QTimer::singleShot(1000, Data->clock(), SLOT(manualTick()));
600  }
601 }
602 
603 #ifdef HAVE_CFITSIO
604 const QPointer<FITSViewer> &KStars::createFITSViewer()
605 {
606  if (Options::singleWindowCapturedFITS())
607  return KStars::Instance()->genericFITSViewer();
608  else
609  {
610  QPointer<FITSViewer> newFITSViewer = new FITSViewer(Options::independentWindowFITS() ? nullptr : KStars::Instance());
611 
612  connect(newFITSViewer.data(), &FITSViewer::destroyed, [ = ]()
613  {
614  m_FITSViewers.removeOne(newFITSViewer);
615  });
616 
617  m_FITSViewers.append(newFITSViewer);
618  return m_FITSViewers.constLast();
619  }
620 }
621 
622 const QPointer<FITSViewer> &KStars::genericFITSViewer()
623 {
624  if (m_GenericFITSViewer.isNull())
625  {
626  m_GenericFITSViewer = new FITSViewer(Options::independentWindowFITS() ? nullptr : this);
627  //m_GenericFITSViewer->setAttribute(Qt::WA_DeleteOnClose);
628  m_FITSViewers.append(m_GenericFITSViewer);
629  }
630 
631  return m_GenericFITSViewer;
632 }
633 
634 //void KStars::addFITSViewer(const QSharedPointer<FITSViewer> &fv)
635 //{
636 // m_FITSViewers.append(fv);
637 // connect(fv.data(), &FITSViewer::terminated, [ = ]()
638 // {
639 // m_FITSViewers.removeOne(fv);
640 // });
641 //}
642 
643 void KStars::clearAllViewers()
644 {
645  for (auto &fv : m_FITSViewers)
646  fv->close();
647 
648  m_FITSViewers.clear();
649 }
650 #endif
651 
652 void KStars::closeEvent(QCloseEvent *event)
653 {
654  KStars::Closing = true;
656  slotAboutToQuit();
657 }
void start(const QString &program, const QStringList &arguments, QIODevice::OpenMode mode)
static void releaseImageCache()
Release the image cache.
Definition: skyqpainter.cpp:91
T & first()
Definition: fov.h:27
Extension of QDateTime for KStars KStarsDateTime can represent the date/time as a Julian Day,...
void updateTime(const bool automaticDSTchange=true)
Update time-dependent data and (possibly) repaint the sky map.
Definition: kstars.cpp:567
QAction * action(const QString &name) const
QList< QAction * > actions() const const
void updateTime(GeoLocation *geo, const bool automaticDSTchange=true)
Update the Simulation Clock.
Definition: kstarsdata.cpp:234
bool waitForFinished(int msecs)
void setLocationFromOptions()
Set the GeoLocation according to the values stored in the configuration file.
Definition: kstarsdata.cpp:396
virtual void release(quint64 objid)
void setProcessEnvironment(const QProcessEnvironment &environment)
Stores dms coordinates for a point in the sky. for converting between coordinate systems.
Definition: skypoint.h:44
const QList< FOV * > getVisibleFOVs() const
Definition: kstarsdata.h:305
void update()
void setClickedPoint(const SkyPoint *f)
Set the ClickedPoint to the skypoint given as an argument.
Definition: skymap.cpp:996
QIcon fromTheme(const QString &name)
QProcessEnvironment systemEnvironment()
SkyObject * objectNamed(const QString &name)
Find object by name.
Definition: kstarsdata.cpp:429
bool event(QEvent *event) override
void loadFromConfig()
Read color-scheme data from the Config object.
QThreadPool * globalInstance()
void removeDatabase(const QString &connectionName)
static KStarsDateTime fromString(const QString &s)
SkyMap * map() const
Definition: kstars.h:143
QString applicationDirPath()
static KStarsDateTime currentDateTimeUtc()
QByteArray toLatin1() const const
bool registerObject(const QString &path, QObject *object, QDBusConnection::RegisterOptions options)
QString buildAbi()
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
static KSharedConfig::Ptr openConfig(const QString &fileName=QString(), OpenFlags mode=FullConfig, QStandardPaths::StandardLocation type=QStandardPaths::GenericConfigLocation)
QString productType()
static KStars * Instance()
Definition: kstars.h:125
void destroyed(QObject *obj)
virtual void setVisible(bool visible)
QMenu * menu() const const
void setIcon(const QIcon &icon)
static void UseFile()
Store all logs into the specified file.
Definition: ksutils.cpp:927
QString i18n(const char *text, const TYPE &arg...)
QDBusConnection sessionBus()
bool registerService(const QString &serviceName)
const CachingDms & dec() const
Definition: skypoint.h:269
the KStars Splash Screen.
Definition: kstarssplash.h:20
void releaseResources()
Syncs config file.
Definition: kstars.cpp:282
int indexOf(const T &value, int from) const const
static void SyncFilterRules()
SyncFilterRules Sync QtLogging filter rules from Options.
Definition: ksutils.cpp:1036
ColorScheme * colorScheme()
Definition: kstarsdata.h:171
Primary window to view monochrome and color FITS images. The FITSviewer can open multiple images each...
Definition: fitsviewer.h:48
GeoLocation * geo()
Definition: kstarsdata.h:229
int execute(const QString &program, const QStringList &arguments)
static void releaseCache()
Release the FOV cache.
Definition: fov.cpp:154
const T & at(int i) const const
Q_INVOKABLE SimClock * clock()
Definition: kstarsdata.h:217
void setStackSize(uint stackSize)
void setText(const QString &text)
void setClickedObject(SkyObject *o)
Set the ClickedObject pointer to the argument.
Definition: skymap.cpp:331
bool isManualMode() const
Manual Mode is a new (04/2002) addition to the SimClock.
Definition: simclock.h:68
void insert(const QString &name, const QString &value)
GeoCoordinates geo(const QVariant &location)
int indexOf(QChar ch, int from, Qt::CaseSensitivity cs) const const
This is the main window for KStars. In addition to the GUI elements, the class contains the program c...
Definition: kstars.h:92
QString absolutePath() const const
QString & replace(int position, int n, QChar after)
T & last()
void slotCenter()
Center the display at the point ClickedPoint.
Definition: skymap.cpp:345
QStatusBar * statusBar() const const
void show()
static void Disable()
Disable logging.
Definition: ksutils.cpp:1029
static bool Closing
Set to true when the application is being closed.
Definition: kstars.h:830
QAction * action(const char *name) const
~KStars() override
Destructor.
Definition: kstars.cpp:248
virtual KActionCollection * actionCollection() const
const CachingDms & ra() const
Definition: skypoint.h:263
KToolBar * toolBar(const QString &name=QString())
const double & Degrees() const
Definition: dms.h:141
static void UseDefault()
Use the default logging mechanism.
Definition: ksutils.cpp:1024
QString currentCpuArchitecture()
virtual void closeEvent(QCloseEvent *event)
RightToLeft
bool isValid() const const
QString i18nc(const char *context, const char *text, const TYPE &arg...)
void slotWISettings()
action slot: open What's Interesting settings window
QString kernelVersion()
KStarsData * data() const
Definition: kstars.h:137
void syncFOV()
Synchronize list of visible FOVs and list of selected FOVs in Options.
T * data() const const
void clearCachedFindDialog()
Delete FindDialog because ObjNames list has changed in KStarsData due to reloading star data.
Definition: kstars.cpp:305
void setChecked(bool)
Q_INVOKABLE bool isActive()
Whether the clock is active or not is a bit complicated by the introduction of "manual mode".
Definition: simclock.cpp:96
void setLayoutDirection(Qt::LayoutDirection direction)
QString mid(int position, int n) const const
Information about an object in the sky.
Definition: skyobject.h:41
void applyConfig(bool doApplyFocus=true)
Apply config options throughout the program.
Definition: kstars.cpp:323
static KStars * createInstance(bool doSplash, bool clockrunning=true, const QString &startDateString=QString())
Create an instance of this class.
Definition: kstars.cpp:239
QString value(const QString &name, const QString &defaultValue) const const
void applySettings(const KConfigGroup &cg)
static void Release()
Release the instance of TextureManager.
QString kernelType()
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.