Kstars

kstarsinit.cpp
1/*
2 SPDX-FileCopyrightText: 2002 Jason Harris <jharris@30doradus.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#include "kstars.h"
8
9#include "fov.h"
10#include "kspaths.h"
11#include "kstarsdata.h"
12#include "kstars_debug.h"
13#include "Options.h"
14#include "skymap.h"
15#include "texturemanager.h"
16#include "projections/projector.h"
17#include "skycomponents/skymapcomposite.h"
18#include "skyobjects/ksplanetbase.h"
19#include "widgets/timespinbox.h"
20#include "widgets/timestepbox.h"
21#include "widgets/timeunitbox.h"
22#include "hips/hipsmanager.h"
23#include "auxiliary/thememanager.h"
24
25#ifdef HAVE_INDI
26#include "indi/drivermanager.h"
27#include "indi/guimanager.h"
28#include "ekos/manager.h"
29#endif
30
31#include <KActionCollection>
32#include <KActionMenu>
33#include <KToggleAction>
34#include <KToolBar>
35
36#include <QMenu>
37#include <QStatusBar>
38
39//This file contains functions that kstars calls at startup (except constructors).
40//These functions are declared in kstars.h
41
42namespace
43{
44// A lot of QAction is defined there. In order to decrease amount
45// of boilerplate code a trick with << operator overloading is used.
46// This makes code more concise and readable.
47//
48// When data type could not used directly. Either because of
49// overloading rules or because one data type have different
50// semantics its wrapped into struct.
51//
52// Downside is unfamiliar syntax and really unhelpful error
53// messages due to general abuse of << overloading
54
55// Set QAction text
57{
58 ka->setText(text);
59 return ka;
60}
61// Set icon for QAction
62QAction *operator<<(QAction *ka, const QIcon &icon)
63{
64 ka->setIcon(icon);
65 return ka;
66}
67// Set keyboard shortcut
69{
71 //ka->setShortcut(sh);
72 return ka;
73}
74
75// Add action to group. AddToGroup struct acts as newtype wrapper
76// in order to allow overloading.
77struct AddToGroup
78{
79 QActionGroup *grp;
80 AddToGroup(QActionGroup *g) : grp(g) {}
81};
82QAction *operator<<(QAction *ka, AddToGroup g)
83{
84 g.grp->addAction(ka);
85 return ka;
86}
87
88// Set checked property. Checked is newtype wrapper.
89struct Checked
90{
91 bool flag;
92 Checked(bool f) : flag(f) {}
93};
94QAction *operator<<(QAction *ka, Checked chk)
95{
96 ka->setCheckable(true);
97 ka->setChecked(chk.flag);
98 return ka;
99}
100
101// Set tool tip. ToolTip is used as newtype wrapper.
102struct ToolTip
103{
104 QString tip;
105 ToolTip(QString msg) : tip(msg) {}
106};
107QAction *operator<<(QAction *ka, const ToolTip &tool)
108{
109 ka->setToolTip(tool.tip);
110 return ka;
111}
112
113// Create new KToggleAction and connect slot to toggled(bool) signal
114QAction *newToggleAction(KActionCollection *col, QString name, QString text, QObject *receiver, const char *member)
115{
116 QAction *ka = col->add<KToggleAction>(name) << text;
117 QObject::connect(ka, SIGNAL(toggled(bool)), receiver, member);
118 return ka;
119}
120}
121
122// Resource file override - used by UI tests
123QString KStars::m_KStarsUIResource = "kstarsui.rc";
125{
126 if (QFile(rc).exists())
127 {
128 m_KStarsUIResource = rc;
129 return true;
130 }
131 else return false;
132}
133
134void KStars::initActions()
135{
136 // Check if we have this specific Breeze icon. If not, try to set the theme search path and if appropriate, the icon theme rcc file
137 // in each OS
138 if (!QIcon::hasThemeIcon(QLatin1String("kstars_flag")))
139 KSTheme::Manager::instance()->setIconTheme(KSTheme::Manager::BREEZE_DARK_THEME);
140
141 QAction *ka;
142
143 // ==== File menu ================
144 ka = new QAction(QIcon::fromTheme("favorites"), i18n("Download New Data..."), this);
147 ka->setWhatsThis(i18n("Downloads new data"));
148 ka->setToolTip(ka->whatsThis());
149 ka->setStatusTip(ka->whatsThis());
150 actionCollection()->addAction(QStringLiteral("get_data"), ka);
151
152#ifdef HAVE_CFITSIO
153 actionCollection()->addAction("open_file", this, SLOT(slotOpenFITS()))
154 << i18n("Open Image(s)...") << QIcon::fromTheme("document-open")
156
157 actionCollection()->addAction("blink_directory", this, SLOT(slotBlink()))
158 << i18n("Open/Blink Directory") << QIcon::fromTheme("folder-open")
160
161#endif
162 actionCollection()->addAction("export_image", this, SLOT(slotExportImage()))
163 << i18n("&Save Sky Image...")
164 << QIcon::fromTheme("document-export-image");
165
166 // 2017-09-17 Jasem: FIXME! Scripting does not work properly under non UNIX systems.
167 // It must be updated to use DBus session bus from Qt (like scheduler)
168#ifndef Q_OS_WIN
169 actionCollection()->addAction("run_script", this, SLOT(slotRunScript()))
170 << i18n("&Run Script...") << QIcon::fromTheme("system-run")
172#endif
173 actionCollection()->addAction("printing_wizard", this, SLOT(slotPrintingWizard()))
174 << i18nc("start Printing Wizard", "Printing &Wizard...");
175 ka = actionCollection()->addAction(KStandardAction::Print, "print", this, SLOT(slotPrint()));
176 ka->setIcon(QIcon::fromTheme("document-print"));
177 //actionCollection()->addAction( KStandardAction::Quit, "quit", this, SLOT(close) );
178 ka = actionCollection()->addAction(KStandardAction::Quit, "quit", qApp, SLOT(closeAllWindows()));
179 ka->setIcon(QIcon::fromTheme("application-exit"));
180
181 // ==== Time Menu ================
182 actionCollection()->addAction("time_to_now", this, SLOT(slotSetTimeToNow()))
183 << i18n("Set Time to &Now") << QKeySequence(Qt::CTRL | Qt::Key_E)
184 << QIcon::fromTheme("clock");
185
186 actionCollection()->addAction("time_dialog", this, SLOT(slotSetTime()))
187 << i18nc("set Clock to New Time", "&Set Time...") << QKeySequence(Qt::CTRL | Qt::Key_S)
188 << QIcon::fromTheme("clock");
189
190 ka = actionCollection()->add<KToggleAction>("clock_startstop")
191 << i18n("Stop &Clock")
192 << QIcon::fromTheme("media-playback-pause");
193 if (!StartClockRunning)
194 ka->toggle();
195 QObject::connect(ka, SIGNAL(triggered()), this, SLOT(slotToggleTimer()));
196
198 << i18n("Run clock in realtime")
199 << QIcon::fromTheme("clock");
200
201 // If we are started in --paused state make sure the icon reflects that now
202 if (StartClockRunning == false)
203 {
204 QAction *a = actionCollection()->action("clock_startstop");
205 if (a)
206 a->setIcon(QIcon::fromTheme("run-build-install-root"));
207 }
208
209 QObject::connect(data()->clock(), &SimClock::clockToggled, [ = ](bool toggled)
210 {
211 QAction *a = actionCollection()->action("clock_startstop");
212 if (a)
213 {
214 a->setChecked(toggled);
215 // Many users forget to unpause KStars, so we are using run-build-install-root icon which is red
216 // and stands out from the rest of the icons so users are aware when KStars is paused visually
217 a->setIcon(toggled ? QIcon::fromTheme("run-build-install-root") : QIcon::fromTheme("media-playback-pause"));
218 a->setToolTip(toggled ? i18n("Resume Clock") : i18n("Stop Clock"));
219 }
220 });
221 //UpdateTime() if clock is stopped (so hidden objects get drawn)
222 QObject::connect(data()->clock(), SIGNAL(clockToggled(bool)), this, SLOT(updateTime()));
223 actionCollection()->addAction("time_step_forward", this, SLOT(slotStepForward()))
224 << i18n("Advance One Step Forward in Time")
225 << QIcon::fromTheme("media-skip-forward")
227 actionCollection()->addAction("time_step_backward", this, SLOT(slotStepBackward()))
228 << i18n("Advance One Step Backward in Time")
229 << QIcon::fromTheme("media-skip-backward")
231
232 // ==== Pointing Menu ================
233 actionCollection()->addAction("zenith", this, SLOT(slotPointFocus())) << i18n("&Zenith") << QKeySequence("Z");
234 actionCollection()->addAction("north", this, SLOT(slotPointFocus())) << i18n("&North") << QKeySequence("N");
235 actionCollection()->addAction("east", this, SLOT(slotPointFocus())) << i18n("&East") << QKeySequence("E");
236 actionCollection()->addAction("south", this, SLOT(slotPointFocus())) << i18n("&South") << QKeySequence("S");
237 actionCollection()->addAction("west", this, SLOT(slotPointFocus())) << i18n("&West") << QKeySequence("W");
238
239 actionCollection()->addAction("find_object", this, SLOT(slotFind()))
240 << i18n("&Find Object...") << QIcon::fromTheme("edit-find")
242 actionCollection()->addAction("track_object", this, SLOT(slotTrack()))
243 << i18n("Engage &Tracking")
244 << QIcon::fromTheme("object-locked")
246 actionCollection()->addAction("manual_focus", this, SLOT(slotManualFocus()))
247 << i18n("Set Coordinates &Manually...") << QKeySequence(Qt::CTRL | Qt::Key_M);
248
250
251 // ==== View Menu ================
252 action = actionCollection()->addAction(KStandardAction::ZoomIn, "zoom_in", map(), SLOT(slotZoomIn()));
253 action->setIcon(QIcon::fromTheme("zoom-in"));
254
255 action = actionCollection()->addAction(KStandardAction::ZoomOut, "zoom_out", map(), SLOT(slotZoomOut()));
256 action->setIcon(QIcon::fromTheme("zoom-out"));
257
258 actionCollection()->addAction("zoom_default", map(), SLOT(slotZoomDefault()))
259 << i18n("&Default Zoom") << QIcon::fromTheme("zoom-fit-best")
261 actionCollection()->addAction("zoom_set", this, SLOT(slotSetZoom()))
262 << i18n("&Zoom to Angular Size...")
263 << QIcon::fromTheme("zoom-original")
265
266 action = actionCollection()->addAction(KStandardAction::FullScreen, this, SLOT(slotFullScreen()));
267 action->setIcon(QIcon::fromTheme("view-fullscreen"));
268
269 actionCollection()->addAction("coordsys", this, SLOT(slotCoordSys()))
270 << (Options::useAltAz() ? i18n("Switch to Star Globe View (Equatorial &Coordinates)") :
271 i18n("Switch to Horizontal View (Horizontal &Coordinates)"))
272 << QKeySequence("Space");
273
274 newToggleAction(
275 actionCollection(), "mirror_skymap",
276 i18nc("Mirror the view of the sky map", "Mirrored View"),
277 this, SLOT(slotSkyMapOrientation())) << QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_M);
278
279 actionCollection()->addAction("toggle_terrain", this, SLOT(slotTerrain()))
280 << (Options::showTerrain() ? i18n("Hide Terrain") :
281 i18n("Show Terrain"))
282 << QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_T);
283
284 actionCollection()->addAction("toggle_image_overlays", this, SLOT(slotImageOverlays()))
285 << (Options::showImageOverlays() ? i18n("Hide Image Overlays") :
286 i18n("Show Image Overlays"))
287 << QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_O);
288
289 actionCollection()->addAction("project_lambert", this, SLOT(slotMapProjection()))
290 << i18n("&Lambert Azimuthal Equal-area") << QKeySequence("F5") << AddToGroup(projectionGroup)
291 << Checked(Options::projection() == Projector::Lambert);
292 actionCollection()->addAction("project_azequidistant", this, SLOT(slotMapProjection()))
293 << i18n("&Azimuthal Equidistant") << QKeySequence("F6") << AddToGroup(projectionGroup)
294 << Checked(Options::projection() == Projector::AzimuthalEquidistant);
295 actionCollection()->addAction("project_orthographic", this, SLOT(slotMapProjection()))
296 << i18n("&Orthographic") << QKeySequence("F7") << AddToGroup(projectionGroup)
297 << Checked(Options::projection() == Projector::Orthographic);
298 actionCollection()->addAction("project_equirectangular", this, SLOT(slotMapProjection()))
299 << i18n("&Equirectangular") << QKeySequence("F8") << AddToGroup(projectionGroup)
300 << Checked(Options::projection() == Projector::Equirectangular);
301 actionCollection()->addAction("project_stereographic", this, SLOT(slotMapProjection()))
302 << i18n("&Stereographic") << QKeySequence("F9") << AddToGroup(projectionGroup)
303 << Checked(Options::projection() == Projector::Stereographic);
304 actionCollection()->addAction("project_gnomonic", this, SLOT(slotMapProjection()))
305 << i18n("&Gnomonic") << QKeySequence("F10") << AddToGroup(projectionGroup)
306 << Checked(Options::projection() == Projector::Gnomonic);
307
308 //Settings Menu:
309 //Info Boxes option actions
310 QAction *kaBoxes = actionCollection()->add<KToggleAction>("show_boxes")
311 << i18nc("Show the information boxes", "Show &Info Boxes") << Checked(Options::showInfoBoxes());
312 connect(kaBoxes, SIGNAL(toggled(bool)), map(), SLOT(slotToggleInfoboxes(bool)));
313 kaBoxes->setChecked(Options::showInfoBoxes());
314
315 ka = actionCollection()->add<KToggleAction>("show_time_box")
316 << i18nc("Show time-related info box", "Show &Time Box");
317 connect(kaBoxes, SIGNAL(toggled(bool)), ka, SLOT(setEnabled(bool)));
318 connect(ka, SIGNAL(toggled(bool)), map(), SLOT(slotToggleTimeBox(bool)));
319 ka->setChecked(Options::showTimeBox());
320 ka->setEnabled(Options::showInfoBoxes());
321
322 ka = actionCollection()->add<KToggleAction>("show_focus_box")
323 << i18nc("Show focus-related info box", "Show &Focus Box");
324 connect(kaBoxes, SIGNAL(toggled(bool)), ka, SLOT(setEnabled(bool)));
325 connect(ka, SIGNAL(toggled(bool)), map(), SLOT(slotToggleFocusBox(bool)));
326 ka->setChecked(Options::showFocusBox());
327 ka->setEnabled(Options::showInfoBoxes());
328
329 ka = actionCollection()->add<KToggleAction>("show_location_box")
330 << i18nc("Show location-related info box", "Show &Location Box");
331 connect(kaBoxes, SIGNAL(toggled(bool)), ka, SLOT(setEnabled(bool)));
332 connect(ka, SIGNAL(toggled(bool)), map(), SLOT(slotToggleGeoBox(bool)));
333 ka->setChecked(Options::showGeoBox());
334 ka->setEnabled(Options::showInfoBoxes());
335
336 //Toolbar options
337 newToggleAction(actionCollection(), "show_mainToolBar", i18n("Show Main Toolbar"), toolBar("kstarsToolBar"),
338 SLOT(setVisible(bool)));
339 newToggleAction(actionCollection(), "show_viewToolBar", i18n("Show View Toolbar"), toolBar("viewToolBar"),
340 SLOT(setVisible(bool)));
341
342 //Statusbar view options
343 newToggleAction(actionCollection(), "show_statusBar", i18n("Show Statusbar"), this, SLOT(slotShowGUIItem(bool)));
344 newToggleAction(actionCollection(), "show_sbAzAlt", i18n("Show Az/Alt Field"), this, SLOT(slotShowGUIItem(bool)));
345 newToggleAction(actionCollection(), "show_sbRADec", i18n("Show RA/Dec Field"), this, SLOT(slotShowGUIItem(bool)));
346 newToggleAction(actionCollection(), "show_sbJ2000RADec", i18n("Show J2000.0 RA/Dec Field"), this,
347 SLOT(slotShowGUIItem(bool)));
348
349 populateThemes();
350
351 //Color scheme actions. These are added to the "colorschemes" KActionMenu.
352 colorActionMenu = actionCollection()->add<KActionMenu>("colorschemes");
353 colorActionMenu->setText(i18n("C&olor Schemes"));
354 addColorMenuItem(i18n("&Classic"), "cs_classic");
355 addColorMenuItem(i18n("&Star Chart"), "cs_chart");
356 addColorMenuItem(i18n("&Night Vision"), "cs_night");
357 addColorMenuItem(i18n("&Moonless Night"), "cs_moonless-night");
358
359 //Add any user-defined color schemes:
360 //determine filename in local user KDE directory tree.
361 QFile file(KSPaths::locate(QStandardPaths::AppLocalDataLocation, "colors.dat"));
362 if (file.exists() && file.open(QIODevice::ReadOnly))
363 {
364 QTextStream stream(&file);
365 while (!stream.atEnd())
366 {
367 QString line = stream.readLine();
368 QString schemeName = line.left(line.indexOf(':'));
369 QString actionname = "cs_" + line.mid(line.indexOf(':') + 1, line.indexOf('.') - line.indexOf(':') - 1);
370 addColorMenuItem(i18n(schemeName.toLocal8Bit()), actionname.toLocal8Bit());
371 }
372 file.close();
373 }
374
375 //Add FOV Symbol actions
376 fovActionMenu = actionCollection()->add<KActionMenu>("fovsymbols");
377 fovActionMenu->setText(i18n("&FOV Symbols"));
379 fovActionMenu->setIcon(QIcon::fromTheme("crosshairs"));
381 repopulateFOV();
382
383 //Add Views menu actions
384 viewsActionMenu = actionCollection()->add<KActionMenu>("views");
385 viewsActionMenu->setText(i18n("&Views"));
386 viewsActionMenu->setPopupMode(QToolButton::InstantPopup);
387 viewsActionMenu->setIcon(QIcon::fromTheme("text_rotation"));
390
391 //Add HIPS Sources actions
392 hipsActionMenu = actionCollection()->add<KActionMenu>("hipssources");
393 hipsActionMenu->setText(i18n("HiPS All Sky Overlay"));
395 hipsActionMenu->setIcon(QIcon::fromTheme("view-preview"));
396 HIPSManager::Instance()->readSources();
398
399 orientationActionMenu = actionCollection()->add<KActionMenu>("skymap_orientation");
400 orientationActionMenu->setText(i18n("Skymap Orientation"));
401 orientationActionMenu->setPopupMode(QToolButton::InstantPopup);
402 orientationActionMenu->setIcon(QIcon::fromTheme("screen-rotate-auto-on"));
403 repopulateOrientation();
404
405 actionCollection()->addAction("geolocation", this, SLOT(slotGeoLocator()))
406 << i18nc("Location on Earth", "&Geographic...")
407 << QIcon::fromTheme("kstars_xplanet")
409
410 // Configure Notifications
411#ifdef HAVE_NOTIFYCONFIG
412 KStandardAction::configureNotifications(this, SLOT(slotConfigureNotifications()), actionCollection());
413#endif
414
415 // Prepare the options dialog early for modules to connect signals
416 prepareOps();
417
418 ka = actionCollection()->addAction(KStandardAction::Preferences, "configure", this, SLOT(slotViewOps()));
419 //I am not sure what icon preferences is supposed to be.
420 //ka->setIcon( QIcon::fromTheme(""));
421
422 actionCollection()->addAction("startwizard", this, SLOT(slotWizard()))
423 << i18n("Startup Wizard...")
424 << QIcon::fromTheme("tools-wizard");
425
426 // Manual data entry
427 actionCollection()->addAction("dso_catalog_gui", this, SLOT(slotDSOCatalogGUI()))
428 << i18n("Manage DSO Catalogs");
429
430 // Updates actions
431 actionCollection()->addAction("update_comets", this, SLOT(slotUpdateComets()))
432 << i18n("Update Comets Orbital Elements");
433 actionCollection()->addAction("update_asteroids", this, SLOT(slotUpdateAsteroids()))
434 << i18n("Update Asteroids Orbital Elements");
435 actionCollection()->addAction("update_supernovae", this, SLOT(slotUpdateSupernovae()))
436 << i18n("Update Recent Supernovae Data");
437 actionCollection()->addAction("update_satellites", this, SLOT(slotUpdateSatellites()))
438 << i18n("Update Satellites Orbital Elements");
439
440 //Tools Menu:
441 actionCollection()->addAction("astrocalculator", this, SLOT(slotCalculator()))
442 << i18n("Calculator")
443 << QIcon::fromTheme("accessories-calculator")
445
446 /* FIXME Enable once port to KF5 is complete for moonphasetool
447 actionCollection()->addAction("moonphasetool", this, SLOT(slotMoonPhaseTool()) )
448 << i18n("Moon Phase Calendar");
449 */
450
451 actionCollection()->addAction("obslist", this, SLOT(slotObsList()))
452 << i18n("Observation Planner") << QKeySequence(Qt::CTRL | Qt::Key_L);
453
454#ifdef HAVE_INDI
455 actionCollection()->addAction("imagingPlanner", this, SLOT(slotImagingPlanner()))
456 << i18n("Imaging Planner") << QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_P);
457#endif
458
459 actionCollection()->addAction("altitude_vs_time", this, SLOT(slotAVT()))
460 << i18n("Altitude vs. Time") << QKeySequence(Qt::CTRL | Qt::Key_A);
461
462 actionCollection()->addAction("whats_up_tonight", this, SLOT(slotWUT()))
463 << i18n("What's up Tonight") << QKeySequence(Qt::CTRL | Qt::Key_U);
464
465 //FIXME Port to QML2
466 //#if 0
467 actionCollection()->addAction("whats_interesting", this, SLOT(slotToggleWIView()))
468 << i18n("What's Interesting...") << QKeySequence(Qt::CTRL | Qt::Key_W);
469 //#endif
470
471 actionCollection()->addAction("XPlanet", map(), SLOT(slotStartXplanetViewer()))
472 << i18n("XPlanet Solar System Simulator") << QKeySequence(Qt::CTRL | Qt::Key_X);
473
474 actionCollection()->addAction("skycalendar", this, SLOT(slotCalendar())) << i18n("Sky Calendar");
475
476#ifdef HAVE_INDI
477 ka = actionCollection()->addAction("ekos", this, SLOT(slotEkos()))
478 << i18n("Ekos") << QKeySequence(Qt::CTRL | Qt::Key_K);
480#endif
481
482 //FIXME: implement glossary
483 // ka = actionCollection()->addAction("glossary");
484 // ka->setText( i18n("Glossary...") );
485 // ka->setShortcuts( QKeySequence(Qt::CTRL+Qt::Key_K ) );
486 // connect( ka, SIGNAL(triggered()), this, SLOT(slotGlossary()) );
487
488 // 2017-09-17 Jasem: FIXME! Scripting does not work properly under non UNIX systems.
489 // It must be updated to use DBus session bus from Qt (like scheduler)
490#ifndef Q_OS_WIN
491 actionCollection()->addAction("scriptbuilder", this, SLOT(slotScriptBuilder()))
492 << i18n("Script Builder") << QKeySequence(Qt::CTRL | Qt::Key_B);
493#endif
494
495 actionCollection()->addAction("solarsystem", this, SLOT(slotSolarSystem()))
496 << i18n("Solar System") << QKeySequence(Qt::CTRL | Qt::Key_Y);
497
498 // Disabled until fixed later
499 actionCollection()->addAction("jmoontool", this, SLOT(slotJMoonTool()) )
500 << i18n("Jupiter's Moons")
502
503 actionCollection()->addAction("flagmanager", this, SLOT(slotFlagManager())) << i18n("Flags");
504
505 actionCollection()->addAction("equipmentwriter", this, SLOT(slotEquipmentWriter()))
506 << i18n("List your &Equipment...") << QIcon::fromTheme("kstars") << QKeySequence(Qt::CTRL | Qt::Key_0);
507 actionCollection()->addAction("manageobserver", this, SLOT(slotObserverManager()))
508 << i18n("Manage Observer...") << QIcon::fromTheme("im-user") << QKeySequence(Qt::CTRL | Qt::Key_1);
509
510 //TODO only enable it when finished
511 actionCollection()->addAction("artificialhorizon", this, SLOT(slotHorizonManager()))
512 << i18n("Artificial Horizon...");
513
514 // ==== observation menu - execute ================
515 actionCollection()->addAction("execute", this, SLOT(slotExecute()))
516 << i18n("Execute the Session Plan...") << QKeySequence(Qt::CTRL | Qt::Key_2);
517
518 // ==== observation menu - polaris hour angle ================
519 actionCollection()->addAction("polaris_hour_angle", this, SLOT(slotPolarisHourAngle()))
520 << i18n("Polaris Hour Angle...");
521
522 // ==== devices Menu ================
523#ifdef HAVE_INDI
524#ifndef Q_OS_WIN
525#if 0
526 actionCollection()->addAction("telescope_wizard", this, SLOT(slotTelescopeWizard()))
527 << i18n("Telescope Wizard...")
528 << QIcon::fromTheme("tools-wizard");
529#endif
530#endif
531 actionCollection()->addAction("device_manager", this, SLOT(slotINDIDriver()))
532 << i18n("Device Manager...")
533 << QIcon::fromTheme("network-server")
535 actionCollection()->addAction("custom_drivers", DriverManager::Instance(), SLOT(showCustomDrivers()))
536 << i18n("Custom Drivers...")
537 << QIcon::fromTheme("address-book-new");
538 ka = actionCollection()->addAction("indi_cpl", this, SLOT(slotINDIPanel()))
539 << i18n("INDI Control Panel...")
542 ka->setEnabled(false);
543#else
544 //FIXME need to disable/hide devices submenu in the tools menu. It is created from the kstarsui.rc file
545 //but I don't know how to hide/disable it yet. menuBar()->findChildren<QMenu *>() does not return any children that I can
546 //iterate over. Anyway to resolve this?
547#endif
548
549 // KStandardAction::help(this, SLOT(appHelpActivated()), actionCollection(), "help_contents" );
550
551 //Add timestep widget for toolbar
552 m_TimeStepBox = new TimeStepBox(toolBar("kstarsToolBar"));
553 // Add a tool tip to TimeStep describing the weird nature of time steps
554 QString TSBToolTip = i18nc("Tooltip describing the nature of the time step control",
555 "Use this to set the rate at which time in the simulation flows.\nFor time step \'X\' "
556 "up to 10 minutes, time passes at the rate of \'X\' per second.\nFor time steps larger "
557 "than 10 minutes, frames are displayed at an interval of \'X\'.");
558 m_TimeStepBox->setToolTip(TSBToolTip);
559 m_TimeStepBox->tsbox()->setToolTip(TSBToolTip);
560 QWidgetAction *wa = new QWidgetAction(this);
561 wa->setDefaultWidget(m_TimeStepBox);
562
563 // Add actions for the timestep widget's functions
564 actionCollection()->addAction("timestep_control", wa) << i18n("Time step control");
565 const auto unitbox = m_TimeStepBox->unitbox();
566 ka = actionCollection()->addAction("timestep_increase_units", unitbox->increaseUnitsAction());
568 ka = actionCollection()->addAction("timestep_decrease_units", unitbox->decreaseUnitsAction());
570
571 // ==== viewToolBar actions ================
572 actionCollection()->add<KToggleAction>("show_stars", this, SLOT(slotViewToolBar()))
573 << i18nc("Toggle Stars in the display", "Stars")
574 << QIcon::fromTheme("kstars_stars")
575 << ToolTip(i18n("Toggle stars"));
576 actionCollection()->add<KToggleAction>("show_deepsky", this, SLOT(slotViewToolBar()))
577 << i18nc("Toggle Deep Sky Objects in the display", "Deep Sky")
578 << QIcon::fromTheme("kstars_deepsky")
579 << ToolTip(i18n("Toggle deep sky objects"));
580 actionCollection()->add<KToggleAction>("show_planets", this, SLOT(slotViewToolBar()))
581 << i18nc("Toggle Solar System objects in the display", "Solar System")
582 << QIcon::fromTheme("kstars_planets")
583 << ToolTip(i18n("Toggle Solar system objects"));
584 actionCollection()->add<KToggleAction>("show_clines", this, SLOT(slotViewToolBar()))
585 << i18nc("Toggle Constellation Lines in the display", "Const. Lines")
586 << QIcon::fromTheme("kstars_clines")
587 << ToolTip(i18n("Toggle constellation lines"));
588 actionCollection()->add<KToggleAction>("show_cnames", this, SLOT(slotViewToolBar()))
589 << i18nc("Toggle Constellation Names in the display", "Const. Names")
590 << QIcon::fromTheme("kstars_cnames")
591 << ToolTip(i18n("Toggle constellation names"));
592 actionCollection()->add<KToggleAction>("show_cbounds", this, SLOT(slotViewToolBar()))
593 << i18nc("Toggle Constellation Boundaries in the display", "C. Boundaries")
594 << QIcon::fromTheme("kstars_cbound")
595 << ToolTip(i18n("Toggle constellation boundaries"));
596 actionCollection()->add<KToggleAction>("show_constellationart", this, SLOT(slotViewToolBar()))
597 << xi18nc("Toggle Constellation Art in the display", "C. Art (BETA)")
598 << QIcon::fromTheme("kstars_constellationart")
599 << ToolTip(xi18n("Toggle constellation art (BETA)"));
600 actionCollection()->add<KToggleAction>("show_mw", this, SLOT(slotViewToolBar()))
601 << i18nc("Toggle Milky Way in the display", "Milky Way")
602 << QIcon::fromTheme("kstars_mw")
603 << ToolTip(i18n("Toggle milky way"));
604 actionCollection()->add<KToggleAction>("show_equatorial_grid", this, SLOT(slotViewToolBar()))
605 << i18nc("Toggle Equatorial Coordinate Grid in the display", "Equatorial coord. grid")
606 << QIcon::fromTheme("kstars_grid")
607 << ToolTip(i18n("Toggle equatorial coordinate grid"));
608 actionCollection()->add<KToggleAction>("show_horizontal_grid", this, SLOT(slotViewToolBar()))
609 << i18nc("Toggle Horizontal Coordinate Grid in the display", "Horizontal coord. grid")
610 << QIcon::fromTheme("kstars_hgrid")
611 << ToolTip(i18n("Toggle horizontal coordinate grid"));
612 actionCollection()->add<KToggleAction>("show_horizon", this, SLOT(slotViewToolBar()))
613 << i18nc("Toggle the opaque fill of the ground polygon in the display", "Ground")
614 << QIcon::fromTheme("kstars_horizon")
615 << ToolTip(i18n("Toggle opaque ground"));
616 actionCollection()->add<KToggleAction>("simulate_daytime", this, SLOT(slotViewToolBar()))
617 << i18nc("Toggle Daytime Simulation", "Daytime")
618 << QIcon::fromTheme("kstars_sun", QIcon(":/icons/kstars_sun.png"))
619 << ToolTip(i18n("Toggle daytime simulation"));
620 actionCollection()->add<KToggleAction>("show_flags", this, SLOT(slotViewToolBar()))
621 << i18nc("Toggle flags in the display", "Flags")
622 << QIcon::fromTheme("kstars_flag")
623 << ToolTip(i18n("Toggle flags"));
624 actionCollection()->add<KToggleAction>("show_satellites", this, SLOT(slotViewToolBar()))
625 << i18nc("Toggle satellites in the display", "Satellites")
626 << QIcon::fromTheme("kstars_satellites")
627 << ToolTip(i18n("Toggle satellites"));
628 actionCollection()->add<KToggleAction>("show_supernovae", this, SLOT(slotViewToolBar()))
629 << i18nc("Toggle supernovae in the display", "Supernovae")
630 << QIcon::fromTheme("kstars_supernovae")
631 << ToolTip(i18n("Toggle supernovae"));
632 actionCollection()->add<KToggleAction>("show_whatsinteresting", this, SLOT(slotToggleWIView()))
633 << i18nc("Toggle What's Interesting", "What's Interesting")
634 << QIcon::fromTheme("view-list-details")
635 << ToolTip(i18n("Toggle What's Interesting"));
636
637#ifdef HAVE_INDI
638 // ==== INDIToolBar actions ================
639 actionCollection()->add<KToggleAction>("show_ekos", this, SLOT(slotINDIToolBar()))
640 << i18nc("Toggle Ekos in the display", "Ekos")
641 << QIcon::fromTheme("kstars_ekos")
642 << ToolTip(i18n("Toggle Ekos"));
643 ka = actionCollection()->add<KToggleAction>("show_control_panel", this, SLOT(slotINDIToolBar()))
644 << i18nc("Toggle the INDI Control Panel in the display", "INDI Control Panel")
645 << QIcon::fromTheme("kstars_indi")
646 << ToolTip(i18n("Toggle INDI Control Panel"));
647 ka->setEnabled(false);
648 ka = actionCollection()->add<KToggleAction>("show_fits_viewer", this, SLOT(slotINDIToolBar()))
649 << i18nc("Toggle the FITS Viewer in the display", "FITS Viewer")
650 << QIcon::fromTheme("kstars_fitsviewer")
651 << ToolTip(i18n("Toggle FITS Viewer"));
652 ka->setEnabled(false);
653
654 ka = actionCollection()->add<KToggleAction>("show_sensor_fov", this, SLOT(slotINDIToolBar()))
655 << i18nc("Toggle the sensor Field of View", "Sensor FOV")
656 << QIcon::fromTheme("archive-extract")
657 << ToolTip(i18n("Toggle Sensor FOV"));
658 ka->setEnabled(false);
659 ka->setChecked(Options::showSensorFOV());
660
661 ka = actionCollection()->add<KToggleAction>("show_mosaic_panel", this, SLOT(slotINDIToolBar()))
662 << i18nc("Toggle the Mosaic Panel", "Mosaic Panel")
663 << QIcon::fromTheme("zoom-draw")
664 << ToolTip(i18n("Toggle Mosaic Panel"));
665 ka->setEnabled(true);
666 ka->setChecked(Options::showMosaicPanel());
667
668 ka = actionCollection()->add<KToggleAction>("show_mount_box", this, SLOT(slotINDIToolBar()))
669 << i18nc("Toggle the Mount Control Panel", "Mount Control")
670 << QIcon::fromTheme("draw-text")
671 << ToolTip(i18n("Toggle Mount Control Panel"));
672 telescopeGroup->addAction(ka);
673
674 ka = actionCollection()->add<KToggleAction>("lock_telescope", this, SLOT(slotINDIToolBar()))
675 << i18nc("Toggle the telescope center lock in display", "Center Telescope")
676 << QIcon::fromTheme("center_telescope", QIcon(":/icons/center_telescope.svg"))
677 << ToolTip(i18n("Toggle Lock Telescope Center"));
678 telescopeGroup->addAction(ka);
679
680 ka = actionCollection()->add<KToggleAction>("telescope_track", this, SLOT(slotINDITelescopeTrack()))
681 << i18n("Toggle Telescope Tracking")
682 << QIcon::fromTheme("object-locked");
683 telescopeGroup->addAction(ka);
684 ka = actionCollection()->addAction("telescope_slew", this, SLOT(slotINDITelescopeSlew()))
685 << i18n("Slew telescope to the focused object")
686 << QIcon::fromTheme("object-rotate-right");
687 telescopeGroup->addAction(ka);
688 ka = actionCollection()->addAction("telescope_sync", this, SLOT(slotINDITelescopeSync()))
689 << i18n("Sync telescope to the focused object")
690 << QIcon::fromTheme("media-record");
691 telescopeGroup->addAction(ka);
692 ka = actionCollection()->addAction("telescope_abort", this, SLOT(slotINDITelescopeAbort()))
693 << i18n("Abort telescope motions")
694 << QIcon::fromTheme("process-stop");
696 telescopeGroup->addAction(ka);
697 ka = actionCollection()->addAction("telescope_park", this, SLOT(slotINDITelescopePark()))
698 << i18n("Park telescope")
699 << QIcon::fromTheme("flag-red");
700 telescopeGroup->addAction(ka);
701 ka = actionCollection()->addAction("telescope_unpark", this, SLOT(slotINDITelescopeUnpark()))
702 << i18n("Unpark telescope")
703 << QIcon::fromTheme("flag-green");
705 telescopeGroup->addAction(ka);
706
707 actionCollection()->addAction("telescope_slew_mouse", this, SLOT(slotINDITelescopeSlewMousePointer()))
708 << i18n("Slew the telescope to the mouse pointer position");
709
710 actionCollection()->addAction("telescope_sync_mouse", this, SLOT(slotINDITelescopeSyncMousePointer()))
711 << i18n("Sync the telescope to the mouse pointer position");
712
713 // Disable all telescope actions by default
714 telescopeGroup->setEnabled(false);
715
716 // Dome Actions
717 ka = actionCollection()->addAction("dome_park", this, SLOT(slotINDIDomePark()))
718 << i18n("Park dome")
719 << QIcon::fromTheme("dome-park", QIcon(":/icons/dome-park.svg"));
720 domeGroup->addAction(ka);
721 ka = actionCollection()->addAction("dome_unpark", this, SLOT(slotINDIDomeUnpark()))
722 << i18n("Unpark dome")
723 << QIcon::fromTheme("dome-unpark", QIcon(":/icons/dome-unpark.svg"));
725 domeGroup->addAction(ka);
726
727 domeGroup->setEnabled(false);
728#endif
729}
730
731void KStars::repopulateOrientation()
732{
733 double rot = dms{Options::skyRotation()}.reduce().Degrees();
734 bool useAltAz = Options::useAltAz();
735 // TODO: Allow adding preset orientations, e.g. for finder scope, main scope etc.
736 orientationActionMenu->menu()->clear();
737 orientationActionMenu->addAction(
739 "up_orientation", this, SLOT(slotSkyMapOrientation()))
740 << (useAltAz ? i18nc("Orientation of the sky map", "Zenith &Up") : i18nc("Orientation of the sky map", "North &Up"))
741 << AddToGroup(skymapOrientationGroup)
742 << Checked(rot == 0.)
743 << ToolTip(i18nc("Orientation of the sky map",
744 "Select this for erect view of the sky map, where north (in Equatorial Coordinate mode) or zenith (in Horizontal Coordinate mode) is vertically up. This would be the natural choice for an erect image finder scope or naked-eye view.")));
745
746 orientationActionMenu->addAction(
748 "down_orientation", this, SLOT(slotSkyMapOrientation()))
749 << (useAltAz ? i18nc("Orientation of the sky map", "Zenith &Down") : i18nc("Orientation of the sky map", "North &Down"))
750 << AddToGroup(skymapOrientationGroup)
751 << Checked(rot == 180.)
752 << ToolTip(i18nc("Orientation of the sky map",
753 "Select this for inverted view of the sky map, where north (in Equatorial Coordinate mode) or zenith (in Horizontal Coordinate mode) is vertically down. This would be the natural choice for an inverted image finder scope, refractor/cassegrain without erector prism, or Dobsonian.")));
754
755 orientationActionMenu->addAction(
757 "arbitrary_orientation", this, SLOT(slotSkyMapOrientation()))
758 << i18nc("Orientation of the sky map is arbitrary as it has been adjusted by the user", "Arbitrary")
759 << AddToGroup(skymapOrientationGroup)
760 << Checked(rot != 180. && rot != 0.)
761 << ToolTip(i18nc("Orientation of the sky map",
762 "This mode is selected automatically if you manually rotated the sky map using Shift + Drag mouse action, to inform you that the orientation is arbitrary")));
763
764 orientationActionMenu->addSeparator();
765
766 orientationActionMenu->addAction(
768 "erect_observer_correction_off", this, SLOT(slotSkyMapOrientation()))
769 << i18nc("Do not adjust the orientation of the sky map for an erect observer", "No correction")
770 << AddToGroup(erectObserverCorrectionGroup)
771 << Checked(Options::erectObserverCorrection() == 0)
772 << ToolTip(i18nc("Orientation of the sky map",
773 "Select this if you are using a camera on the telescope, or have the sky map display mounted on your telescope")));
774
775 orientationActionMenu->addAction(
777 "erect_observer_correction_left", this, SLOT(slotSkyMapOrientation()))
778 << i18nc("Adjust the orientation of the sky map for an erect observer, left-handed telescope",
779 "Erect observer correction, left-handed")
780 << AddToGroup(erectObserverCorrectionGroup)
781 << Checked(Options::erectObserverCorrection() == 1)
782 << ToolTip(i18nc("Orientation of the sky map",
783 "Select this if you are visually observing using a Dobsonian telescope which has the focuser appearing on the left side when looking up the telescope tube. This feature will correct the orientation of the sky-map to account for the observer remaining erect as the telescope moves up and down, unlike a camera which would rotate with the telescope. Typically makes sense to combine this with Zenith Down orientation.")));
784
785 orientationActionMenu->addAction(
787 "erect_observer_correction_right", this, SLOT(slotSkyMapOrientation()))
788 << i18nc("Adjust the orientation of the sky map for an erect observer, left-handed telescope",
789 "Erect observer correction, right-handed")
790 << AddToGroup(erectObserverCorrectionGroup)
791 << Checked(Options::erectObserverCorrection() == 2)
792 << ToolTip(i18nc("Orientation of the sky map",
793 "Select this if you are visually observing using a Dobsonian telescope which has the focuser appearing on the right side when looking up the telescope tube. This feature will correct the orientation of the sky-map to account for the observer remaining erect as the telescope moves up and down, unlike a camera which would rotate with the telescope. Typically makes sense to combine this with Zenith Down orientation.")));
794
795}
796
798{
799 viewsActionMenu->menu()->clear();
800
801 QList<QAction*> actions = viewsGroup->actions();
802 for (auto &action : actions)
803 viewsGroup->removeAction(action);
804
805 for (const auto &view : SkyMapViewManager::getViews())
806 {
807 QAction* action = actionCollection()->addAction(QString("view:%1").arg(view.name), this, [ = ]()
808 {
809 slotApplySkyMapView(view.name);
810 })
811 << view.name << AddToGroup(viewsGroup) << Checked(false);
812 viewsActionMenu->addAction(action);
813 action->setData(view.name);
814 }
815 viewsActionMenu->addAction(
816 actionCollection()->addAction("view:arbitrary")
817 << i18nc("Arbitrary Sky Map View", "Arbitrary") << AddToGroup(viewsGroup) << Checked(true)); // FIXME
818
819 // Add menu bottom
820 QAction *ka = actionCollection()->addAction("edit_views", this, SLOT(slotEditViews())) << i18n("Edit Views...");
821 viewsActionMenu->addSeparator();
822 viewsActionMenu->addAction(ka);
823}
824
825void KStars::repopulateFOV()
826{
827 // Read list of all FOVs
828 //qDeleteAll( data()->availFOVs );
829 data()->availFOVs = FOVManager::getFOVs();
830 data()->syncFOV();
831
832 // Iterate through FOVs
833 fovActionMenu->menu()->clear();
834 foreach (FOV *fov, data()->availFOVs)
835 {
836 KToggleAction *kta = actionCollection()->add<KToggleAction>(fov->name());
837 kta->setText(fov->name());
838 if (Options::fOVNames().contains(fov->name()))
839 {
840 kta->setChecked(true);
841 }
842
843 fovActionMenu->addAction(kta);
844 connect(kta, SIGNAL(toggled(bool)), this, SLOT(slotTargetSymbol(bool)));
845 }
846 // Add menu bottom
847 QAction *ka = actionCollection()->addAction("edit_fov", this, SLOT(slotFOVEdit())) << i18n("Edit FOV Symbols...");
848 fovActionMenu->addSeparator();
849 fovActionMenu->addAction(ka);
850}
851
853{
854 // Iterate through actions
855 hipsActionMenu->menu()->clear();
856 // Remove all actions
857 QList<QAction*> actions = hipsGroup->actions();
858
859 for (auto &action : actions)
860 hipsGroup->removeAction(action);
861
862 auto ka = actionCollection()->addAction(i18n("None"), this, SLOT(slotHIPSSource()))
863 << i18n("None") << AddToGroup(hipsGroup)
864 << Checked(Options::hIPSSource() == "None");
865
866 hipsActionMenu->addAction(ka);
867 hipsActionMenu->addSeparator();
868
869 for (QMap<QString, QString> source : HIPSManager::Instance()->getHIPSSources())
870 {
871 QString title = source.value("obs_title");
872
873 auto newAction = actionCollection()->addAction(title, this, SLOT(slotHIPSSource()))
874 << title << AddToGroup(hipsGroup)
875 << Checked(Options::hIPSSource() == title);
876
877 newAction->setDisabled(Options::hIPSUseOfflineSource() && title.compare("DSS Colored", Qt::CaseInsensitive));
878
879 hipsActionMenu->addAction(newAction);
880 }
881
882 // Hips settings
883 ka = actionCollection()->addAction("hipssettings", HIPSManager::Instance(),
884 SLOT(showSettings())) << i18n("HiPS Settings...");
885 hipsActionMenu->addSeparator();
886 hipsActionMenu->addAction(ka);
887}
888
889void KStars::initStatusBar()
890{
891 statusBar()->showMessage(i18n(" Welcome to KStars "));
892
893 QString s = "000d 00m 00s, +00d 00\' 00\""; //only need this to set the width
894
895 AltAzField.setHidden(!Options::showAltAzField());
896 AltAzField.setText(s);
897 statusBar()->insertPermanentWidget(0, &AltAzField);
898
899 RADecField.setHidden(!Options::showRADecField());
900 RADecField.setText(s);
901 statusBar()->insertPermanentWidget(1, &RADecField);
902
903 J2000RADecField.setHidden(!Options::showJ2000RADecField());
904 J2000RADecField.setText(s);
905 statusBar()->insertPermanentWidget(2, &J2000RADecField);
906
907 if (!Options::showStatusBar())
908 statusBar()->hide();
909}
910
911void KStars::datainitFinished()
912{
913 //Time-related connections
914 connect(data()->clock(), &SimClock::timeAdvanced, this, [this]()
915 {
916 updateTime();
917 });
918 connect(data()->clock(), &SimClock::timeChanged, this, [this]()
919 {
920 updateTime();
921 });
922 connect(data()->clock(), &SimClock::realtimeToogled, this, &KStars::slotRealTimeToogled);
923
924 //Add GUI elements to main window
925 buildGUI();
926
928
930 connect(m_TimeStepBox, &TimeStepBox::scaleChanged, data(), &KStarsData::setTimeDirection);
931 connect(m_TimeStepBox, &TimeStepBox::scaleChanged, data()->clock(), &SimClock::setClockScale);
932
933 //Do not start the clock if "--paused" specified on the cmd line
934 if (StartClockRunning)
935 {
936 // The initial time is set when KStars is first executed
937 // but until all data is loaded, some time elapsed already so we need to synchronize if no Start Date string
938 // was supplied to KStars
939 if (StartDateString.isEmpty())
941
942 data()->clock()->start();
943 }
944
945 // Connect cache function for Find dialog
946 connect(data(), SIGNAL(clearCache()), this, SLOT(clearCachedFindDialog()));
947
948 //Propagate config settings
949 applyConfig(false);
950
951 //show the window. must be before kswizard and messageboxes
952 show();
953
954 //Initialize focus
955 initFocus();
956
958 updateTime();
959
960 // Initial State
961 qCDebug(KSTARS) << "Date/Time is:" << data()->clock()->utc().toString();
962 qCDebug(KSTARS) << "Location:" << data()->geo()->fullName();
963 qCDebug(KSTARS) << "TZ0:" << data()->geo()->TZ0() << "TZ:" << data()->geo()->TZ();
964
965 KSTheme::Manager::instance()->setCurrentTheme(Options::currentTheme());
966
967 //If this is the first startup, show the wizard
968 if (Options::runStartupWizard())
969 {
970 slotWizard();
971 }
972
973 // Update comets and asteroids if enabled.
974 if (Options::orbitalElementsAutoUpdate())
975 {
976 slotUpdateComets(true);
977 slotUpdateAsteroids(true);
978 }
979
980#ifdef HAVE_INDI
981 Ekos::Manager::Instance()->initialize();
982#endif
983}
984
985void KStars::initFocus()
986{
987 //Case 1: tracking on an object
988 if (Options::isTracking() && Options::focusObject() != i18n("nothing"))
989 {
990 SkyObject *oFocus;
991 if (Options::focusObject() == i18n("star"))
992 {
993 SkyPoint p(Options::focusRA(), Options::focusDec());
994 double maxrad = 1.0;
995
996 oFocus = data()->skyComposite()->starNearest(&p, maxrad);
997 }
998 else
999 {
1000 oFocus = data()->objectNamed(Options::focusObject());
1001 }
1002
1003 if (oFocus)
1004 {
1005 map()->setFocusObject(oFocus);
1006 map()->setClickedObject(oFocus);
1007 map()->setFocusPoint(oFocus);
1008 }
1009 else
1010 {
1011 qWarning() << "Cannot center on " << Options::focusObject() << ": no object found.";
1012 }
1013
1014 //Case 2: not tracking, and using Alt/Az coords. Set focus point using
1015 //FocusRA as the Azimuth, and FocusDec as the Altitude
1016 }
1017 else if (!Options::isTracking() && Options::useAltAz())
1018 {
1019 SkyPoint pFocus;
1020 pFocus.setAz(Options::focusRA());
1021 pFocus.setAlt(Options::focusDec());
1022 pFocus.HorizontalToEquatorial(data()->lst(), data()->geo()->lat());
1023 map()->setFocusPoint(&pFocus);
1024
1025 //Default: set focus point using FocusRA as the RA and
1026 //FocusDec as the Dec
1027 }
1028 else
1029 {
1030 SkyPoint pFocus(Options::focusRA(), Options::focusDec());
1031 pFocus.EquatorialToHorizontal(data()->lst(), data()->geo()->lat());
1032 map()->setFocusPoint(&pFocus);
1033 }
1035 map()->setDestination(*map()->focusPoint());
1036 map()->setFocus(map()->destination());
1037
1038 map()->showFocusCoords();
1039
1040 //Check whether initial position is below the horizon.
1041 if (Options::useAltAz() && Options::showGround() && map()->focus()->alt().Degrees() <= SkyPoint::altCrit)
1042 {
1043 QString caption = i18n("Initial Position is Below Horizon");
1044 QString message =
1045 i18n("The initial position is below the horizon.\nWould you like to reset to the default position?");
1046 if (KMessageBox::warningContinueCancel(this, message, caption, KGuiItem(i18n("Reset Position")),
1047 KGuiItem(i18n("Do Not Reset")), "dag_start_below_horiz") == KMessageBox::Continue)
1048 {
1049 map()->setClickedObject(nullptr);
1050 map()->setFocusObject(nullptr);
1051 Options::setIsTracking(false);
1052
1053 data()->setSnapNextFocus(true);
1054
1055 SkyPoint DefaultFocus;
1056 DefaultFocus.setAz(180.0);
1057 DefaultFocus.setAlt(45.0);
1058 DefaultFocus.HorizontalToEquatorial(data()->lst(), data()->geo()->lat());
1059 map()->setDestination(DefaultFocus);
1060 }
1061 }
1062
1063 //If there is a focusObject() and it is a SS body, add a temporary Trail
1064 if (map()->focusObject() && map()->focusObject()->isSolarSystem() && Options::useAutoTrail())
1065 {
1066 ((KSPlanetBase *)map()->focusObject())->addToTrail();
1067 data()->temporaryTrail = true;
1068 }
1069}
1070
1071void KStars::buildGUI()
1072{
1073 //create the texture manager
1075 //create the skymap
1076 m_SkyMap = SkyMap::Create();
1077 connect(m_SkyMap, SIGNAL(mousePointChanged(SkyPoint*)), SLOT(slotShowPositionBar(SkyPoint*)));
1078 connect(m_SkyMap, SIGNAL(zoomChanged()), SLOT(slotZoomChanged()));
1079 setCentralWidget(m_SkyMap);
1080
1081 //Initialize menus, toolbars, and statusbars
1082 initStatusBar();
1083 initActions();
1084
1085 // Setup GUI from the settings file
1086 // UI tests provide the default settings file from the resources explicitly file to render UI properly
1087 setupGUI(StandardWindowOptions(Default), m_KStarsUIResource);
1088
1089 //get focus of keyboard and mouse actions (for example zoom in with +)
1090 map()->QWidget::setFocus();
1091 resize(Options::windowWidth(), Options::windowHeight());
1092
1093 // check zoom in/out buttons
1094 if (Options::zoomFactor() >= MAXZOOM)
1095 actionCollection()->action("zoom_in")->setEnabled(false);
1096 if (Options::zoomFactor() <= MINZOOM)
1097 actionCollection()->action("zoom_out")->setEnabled(false);
1098}
1099
1100void KStars::populateThemes()
1101{
1102 KSTheme::Manager::instance()->setThemeMenuAction(new QMenu(i18n("&Themes"), this));
1103 KSTheme::Manager::instance()->registerThemeActions(this);
1104
1105 connect(KSTheme::Manager::instance(), SIGNAL(signalThemeChanged()), this, SLOT(slotThemeChanged()));
1106}
1107
1108void KStars::slotThemeChanged()
1109{
1110 Options::setCurrentTheme(KSTheme::Manager::instance()->currentThemeName());
1111}
static const QList< FOV * > & readFOVs()
Read list of FOVs from "fov.dat".
Definition fov.cpp:76
A simple class encapsulating a Field-of-View symbol.
Definition fov.h:28
QString fullName() const
double TZ0() const
double TZ() const
Q_INVOKABLE QAction * action(const QString &name) const
ActionType * add(const QString &name, const QObject *receiver=nullptr, const char *member=nullptr)
QAction * addAction(const QString &name, const QObject *receiver=nullptr, const char *member=nullptr)
static void setDefaultShortcut(QAction *action, const QKeySequence &shortcut)
void setPopupMode(QToolButton::ToolButtonPopupMode popupMode)
void addAction(QAction *action)
KToolBar * toolBar(const QString &name=QString())
A subclass of TrailObject that provides additional information needed for most solar system objects.
void changeDateTime(const KStarsDateTime &newDate)
Change the current simulation date/time to the KStarsDateTime argument.
void setFullTimeUpdate()
The Sky is updated more frequently than the moon, which is updated more frequently than the planets.
SkyObject * objectNamed(const QString &name)
Find object by name.
void setTimeDirection(float scale)
Sets the direction of time and stores it in bool TimeRunForwards.
void skyUpdate(bool)
Should be used to refresh skymap.
void syncFOV()
Synchronize list of visible FOVs and list of selected FOVs in Options.
Q_INVOKABLE SimClock * clock()
Definition kstarsdata.h:220
GeoLocation * geo()
Definition kstarsdata.h:232
SkyMapComposite * skyComposite()
Definition kstarsdata.h:168
void setSnapNextFocus(bool b=true)
Disable or re-enable the slewing animation for the next Focus change.
Definition kstarsdata.h:285
static KStarsDateTime currentDateTimeUtc()
void slotSetZoom()
action slot: Allow user to specify a field-of-view angle for the display window in degrees,...
void repopulateViews()
Load Views and repopulate menu.
SkyMap * map() const
Definition kstars.h:139
void applyConfig(bool doApplyFocus=true)
Apply config options throughout the program.
Definition kstars.cpp:311
void slotDownload()
action slot: open KNewStuff window to download extra data.
static KStars * Instance()
Definition kstars.h:121
void slotToggleWIView()
action slot: toggle What's Interesting window
void slotDSOCatalogGUI()
Show the DSO Catalog Management GUI.
void slotWizard()
action slot: open KStars startup wizard
void slotTrack()
action slot: Toggle whether kstars is tracking current position
void addColorMenuItem(QString name, const QString &actionName)
Add an item to the color-scheme action manu.
KStarsData * data() const
Definition kstars.h:133
void clearCachedFindDialog()
Delete FindDialog because ObjNames list has changed in KStarsData due to reloading star data.
Definition kstars.cpp:293
void slotGeoLocator()
action slot: open dialog for selecting a new geographic location
void slotFlagManager()
action slot: open Flag Manager
void updateTime(const bool automaticDSTchange=true)
Update time-dependent data and (possibly) repaint the sky map.
Definition kstars.cpp:592
void repopulateHIPS()
Load HIPS information and repopulate menu.
void slotShowPositionBar(SkyPoint *)
Display position in the status bar.
static bool setResourceFile(QString const rc)
Override KStars UI resource file.
void slotSetTimeToNow()
action slot: sync kstars clock to system time
void slotZoomChanged()
Called when zoom level is changed.
virtual KActionCollection * actionCollection() const
virtual QAction * action(const QDomElement &element) const
void setupGUI(const QSize &defaultSize, StandardWindowOptions options=Default, const QString &xmlfile=QString())
QFlags< StandardWindowOption > StandardWindowOptions
void clockToggled(bool)
This is an signal that is called on either clock start or clock stop with an appropriate boolean argu...
void timeAdvanced()
The clock has ticked (emitted by tick() )
void timeChanged()
The time has changed (emitted by setUTC() )
void setRealTime(bool on=true)
Realtime mode will lock SimClock with system clock.
Definition simclock.cpp:88
void scaleChanged(float)
The timestep has changed.
Q_SCRIPTABLE Q_NOREPLY void setClockScale(double scale)
DBUS function to set scale of simclock.
Definition simclock.cpp:210
const KStarsDateTime & utc() const
Definition simclock.h:35
Q_SCRIPTABLE Q_NOREPLY void start()
DBUS function to start the SimClock.
Definition simclock.cpp:155
void realtimeToogled(bool)
Emitted when realtime clock is toggled.
SkyObject * starNearest(SkyPoint *p, double &maxrad)
static const QList< SkyMapView > & getViews()
Get the list of available views.
Definition skymapview.h:66
static const QList< SkyMapView > & readViews()
Read the list of views from the database.
void showFocusCoords()
Update object name and coordinates in the Focus InfoBox.
Definition skymap.cpp:327
void setClickedObject(SkyObject *o)
Set the ClickedObject pointer to the argument.
Definition skymap.cpp:366
void slotClockSlewing()
Checks whether the timestep exceeds a threshold value.
Definition skymap.cpp:953
void setDestination(const SkyPoint &f)
sets the destination point of the sky map.
Definition skymap.cpp:993
void forceUpdateNow()
Convenience function; simply calls forceUpdate(true).
Definition skymap.h:378
void setFocus(SkyPoint *f)
sets the central focus point of the sky map.
Definition skymap.cpp:967
void setFocusObject(SkyObject *o)
Set the FocusObject pointer to the argument.
Definition skymap.cpp:371
void setFocusPoint(SkyPoint *f)
set the FocusPoint; the position that is to be the next Destination.
Definition skymap.h:204
Provides all necessary information about an object in the sky: its coordinates, name(s),...
Definition skyobject.h:42
The sky coordinates of a point in the sky.
Definition skypoint.h:45
static const double altCrit
Critical height for atmospheric refraction corrections.
Definition skypoint.h:727
void EquatorialToHorizontal(const CachingDms *LST, const CachingDms *lat)
Determine the (Altitude, Azimuth) coordinates of the SkyPoint from its (RA, Dec) coordinates,...
Definition skypoint.cpp:77
void setAlt(dms alt)
Sets Alt, the Altitude.
Definition skypoint.h:194
void HorizontalToEquatorial(const dms *LST, const dms *lat)
Determine the (RA, Dec) coordinates of the SkyPoint from its (Altitude, Azimuth) coordinates,...
Definition skypoint.cpp:143
void setAz(dms az)
Sets Az, the Azimuth.
Definition skypoint.h:230
static TextureManager * Create()
Create the instance of TextureManager.
Composite spinbox for specifying a time step.
Definition timestepbox.h:28
TimeUnitBox * unitbox() const
Definition timestepbox.h:38
TimeSpinBox * tsbox() const
Definition timestepbox.h:35
An angle, stored as degrees, but expressible in many ways.
Definition dms.h:38
const dms reduce() const
return the equivalent angle between 0 and 360 degrees.
Definition dms.cpp:251
const double & Degrees() const
Definition dms.h:141
QString xi18nc(const char *context, const char *text, const TYPE &arg...)
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString xi18n(const char *text, const TYPE &arg...)
QString i18n(const char *text, const TYPE &arg...)
QDebug operator<<(QDebug dbg, const DcrawInfoContainer &c)
GeoCoordinates geo(const QVariant &location)
ButtonCode warningContinueCancel(QWidget *parent, const QString &text, const QString &title=QString(), const KGuiItem &buttonContinue=KStandardGuiItem::cont(), const KGuiItem &buttonCancel=KStandardGuiItem::cancel(), const QString &dontAskAgainName=QString(), Options options=Notify)
QAction * configureNotifications(const QObject *recvr, const char *slot, QObject *parent)
QString name(StandardAction id)
void setCheckable(bool)
void setChecked(bool)
void setEnabled(bool)
void setIcon(const QIcon &icon)
QMenu * menu() const const
void setData(const QVariant &data)
void setShortcutContext(Qt::ShortcutContext context)
void setStatusTip(const QString &statusTip)
void setText(const QString &text)
void toggle()
void setToolTip(const QString &tip)
void triggered(bool checked)
void setWhatsThis(const QString &what)
QList< QAction * > actions() const const
QAction * addAction(QAction *action)
void setEnabled(bool)
void removeAction(QAction *action)
QString toString(QStringView format, QCalendar cal) const const
QIcon fromTheme(const QString &name)
bool hasThemeIcon(const QString &name)
void setText(const QString &)
void setCentralWidget(QWidget *widget)
QStatusBar * statusBar() const const
void clear()
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
int insertPermanentWidget(int index, QWidget *widget, int stretch)
void showMessage(const QString &message, int timeout)
int compare(QLatin1StringView s1, const QString &s2, Qt::CaseSensitivity cs)
qsizetype indexOf(QChar ch, qsizetype from, Qt::CaseSensitivity cs) const const
bool isEmpty() const const
QString left(qsizetype n) const const
QString mid(qsizetype position, qsizetype n) const const
QByteArray toLocal8Bit() const const
CaseInsensitive
AltModifier
ApplicationShortcut
QList< QAction * > actions() const const
QAction * addAction(const QIcon &icon, const QString &text)
void setEnabled(bool)
void hide()
void setHidden(bool hidden)
void show()
void resize(const QSize &)
void setToolTip(const QString &)
virtual void setVisible(bool visible)
void setDefaultWidget(QWidget *widget)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:04:46 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.