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 <KTipDialog>
34#include <KToggleAction>
35#include <KToolBar>
36
37#include <QMenu>
38#include <QStatusBar>
39
40//This file contains functions that kstars calls at startup (except constructors).
41//These functions are declared in kstars.h
42
43namespace
44{
45// A lot of QAction is defined there. In order to decrease amount
46// of boilerplate code a trick with << operator overloading is used.
47// This makes code more concise and readable.
48//
49// When data type could not used directly. Either because of
50// overloading rules or because one data type have different
51// semantics its wrapped into struct.
52//
53// Downside is unfamiliar syntax and really unhelpful error
54// messages due to general abuse of << overloading
55
56// Set QAction text
58{
59 ka->setText(text);
60 return ka;
61}
62// Set icon for QAction
63QAction *operator<<(QAction *ka, const QIcon &icon)
64{
65 ka->setIcon(icon);
66 return ka;
67}
68// Set keyboard shortcut
70{
72 //ka->setShortcut(sh);
73 return ka;
74}
75
76// Add action to group. AddToGroup struct acts as newtype wrapper
77// in order to allow overloading.
78struct AddToGroup
79{
80 QActionGroup *grp;
81 AddToGroup(QActionGroup *g) : grp(g) {}
82};
83QAction *operator<<(QAction *ka, AddToGroup g)
84{
85 g.grp->addAction(ka);
86 return ka;
87}
88
89// Set checked property. Checked is newtype wrapper.
90struct Checked
91{
92 bool flag;
93 Checked(bool f) : flag(f) {}
94};
95QAction *operator<<(QAction *ka, Checked chk)
96{
97 ka->setCheckable(true);
98 ka->setChecked(chk.flag);
99 return ka;
100}
101
102// Set tool tip. ToolTip is used as newtype wrapper.
103struct ToolTip
104{
105 QString tip;
106 ToolTip(QString msg) : tip(msg) {}
107};
108QAction *operator<<(QAction *ka, const ToolTip &tool)
109{
110 ka->setToolTip(tool.tip);
111 return ka;
112}
113
114// Create new KToggleAction and connect slot to toggled(bool) signal
115QAction *newToggleAction(KActionCollection *col, QString name, QString text, QObject *receiver, const char *member)
116{
117 QAction *ka = col->add<KToggleAction>(name) << text;
118 QObject::connect(ka, SIGNAL(toggled(bool)), receiver, member);
119 return ka;
120}
121}
122
123// Resource file override - used by UI tests
124QString KStars::m_KStarsUIResource = "kstarsui.rc";
126{
127 if (QFile(rc).exists())
128 {
129 m_KStarsUIResource = rc;
130 return true;
131 }
132 else return false;
133}
134
135void KStars::initActions()
136{
137 // 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
138 // in each OS
139 if (!QIcon::hasThemeIcon(QLatin1String("kstars_flag")))
140 KSTheme::Manager::instance()->setIconTheme(KSTheme::Manager::BREEZE_DARK_THEME);
141
142 QAction *ka;
143
144 // ==== File menu ================
145 ka = new QAction(QIcon::fromTheme("favorites"), i18n("Download New Data..."), this);
146 connect(ka, &QAction::triggered, this, &KStars::slotDownload);
148 ka->setWhatsThis(i18n("Downloads new data"));
149 ka->setToolTip(ka->whatsThis());
150 ka->setStatusTip(ka->whatsThis());
151 actionCollection()->addAction(QStringLiteral("get_data"), ka);
152
153#ifdef HAVE_CFITSIO
154 actionCollection()->addAction("open_file", this, SLOT(slotOpenFITS()))
155 << i18n("Open Image(s)...") << QIcon::fromTheme("document-open")
157
158 actionCollection()->addAction("blink_directory", this, SLOT(slotBlink()))
159 << i18n("Open/Blink Directory") << QIcon::fromTheme("folder-open")
161
162#endif
163 actionCollection()->addAction("export_image", this, SLOT(slotExportImage()))
164 << i18n("&Save Sky Image...")
165 << QIcon::fromTheme("document-export-image");
166
167 // 2017-09-17 Jasem: FIXME! Scripting does not work properly under non UNIX systems.
168 // It must be updated to use DBus session bus from Qt (like scheduler)
169#ifndef Q_OS_WIN
170 actionCollection()->addAction("run_script", this, SLOT(slotRunScript()))
171 << i18n("&Run Script...") << QIcon::fromTheme("system-run")
173#endif
174 actionCollection()->addAction("printing_wizard", this, SLOT(slotPrintingWizard()))
175 << i18nc("start Printing Wizard", "Printing &Wizard...");
176 ka = actionCollection()->addAction(KStandardAction::Print, "print", this, SLOT(slotPrint()));
177 ka->setIcon(QIcon::fromTheme("document-print"));
178 //actionCollection()->addAction( KStandardAction::Quit, "quit", this, SLOT(close) );
179 ka = actionCollection()->addAction(KStandardAction::Quit, "quit", qApp, SLOT(closeAllWindows()));
180 ka->setIcon(QIcon::fromTheme("application-exit"));
181
182 // ==== Time Menu ================
183 actionCollection()->addAction("time_to_now", this, SLOT(slotSetTimeToNow()))
184 << i18n("Set Time to &Now") << QKeySequence(Qt::CTRL + Qt::Key_E)
185 << QIcon::fromTheme("clock");
186
187 actionCollection()->addAction("time_dialog", this, SLOT(slotSetTime()))
188 << i18nc("set Clock to New Time", "&Set Time...") << QKeySequence(Qt::CTRL + Qt::Key_S)
189 << QIcon::fromTheme("clock");
190
191 ka = actionCollection()->add<KToggleAction>("clock_startstop")
192 << i18n("Stop &Clock")
193 << QIcon::fromTheme("media-playback-pause");
194 if (!StartClockRunning)
195 ka->toggle();
196 QObject::connect(ka, SIGNAL(triggered()), this, SLOT(slotToggleTimer()));
197
199 << i18n("Run clock in realtime")
200 << QIcon::fromTheme("clock");
201
202 // If we are started in --paused state make sure the icon reflects that now
203 if (StartClockRunning == false)
204 {
205 QAction *a = actionCollection()->action("clock_startstop");
206 if (a)
207 a->setIcon(QIcon::fromTheme("run-build-install-root"));
208 }
209
210 QObject::connect(data()->clock(), &SimClock::clockToggled, [ = ](bool toggled)
211 {
212 QAction *a = actionCollection()->action("clock_startstop");
213 if (a)
214 {
215 a->setChecked(toggled);
216 // Many users forget to unpause KStars, so we are using run-build-install-root icon which is red
217 // and stands out from the rest of the icons so users are aware when KStars is paused visually
218 a->setIcon(toggled ? QIcon::fromTheme("run-build-install-root") : QIcon::fromTheme("media-playback-pause"));
219 a->setToolTip(toggled ? i18n("Resume Clock") : i18n("Stop Clock"));
220 }
221 });
222 //UpdateTime() if clock is stopped (so hidden objects get drawn)
223 QObject::connect(data()->clock(), SIGNAL(clockToggled(bool)), this, SLOT(updateTime()));
224 actionCollection()->addAction("time_step_forward", this, SLOT(slotStepForward()))
225 << i18n("Advance One Step Forward in Time")
226 << QIcon::fromTheme("media-skip-forward")
228 actionCollection()->addAction("time_step_backward", this, SLOT(slotStepBackward()))
229 << i18n("Advance One Step Backward in Time")
230 << QIcon::fromTheme("media-skip-backward")
232
233 // ==== Pointing Menu ================
234 actionCollection()->addAction("zenith", this, SLOT(slotPointFocus())) << i18n("&Zenith") << QKeySequence("Z");
235 actionCollection()->addAction("north", this, SLOT(slotPointFocus())) << i18n("&North") << QKeySequence("N");
236 actionCollection()->addAction("east", this, SLOT(slotPointFocus())) << i18n("&East") << QKeySequence("E");
237 actionCollection()->addAction("south", this, SLOT(slotPointFocus())) << i18n("&South") << QKeySequence("S");
238 actionCollection()->addAction("west", this, SLOT(slotPointFocus())) << i18n("&West") << QKeySequence("W");
239
240 actionCollection()->addAction("find_object", this, SLOT(slotFind()))
241 << i18n("&Find Object...") << QIcon::fromTheme("edit-find")
243 actionCollection()->addAction("track_object", this, SLOT(slotTrack()))
244 << i18n("Engage &Tracking")
245 << QIcon::fromTheme("object-locked")
247 actionCollection()->addAction("manual_focus", this, SLOT(slotManualFocus()))
248 << i18n("Set Coordinates &Manually...") << QKeySequence(Qt::CTRL + Qt::Key_M);
249
251
252 // ==== View Menu ================
253 action = actionCollection()->addAction(KStandardAction::ZoomIn, "zoom_in", map(), SLOT(slotZoomIn()));
254 action->setIcon(QIcon::fromTheme("zoom-in"));
255
256 action = actionCollection()->addAction(KStandardAction::ZoomOut, "zoom_out", map(), SLOT(slotZoomOut()));
257 action->setIcon(QIcon::fromTheme("zoom-out"));
258
259 actionCollection()->addAction("zoom_default", map(), SLOT(slotZoomDefault()))
260 << i18n("&Default Zoom") << QIcon::fromTheme("zoom-fit-best")
262 actionCollection()->addAction("zoom_set", this, SLOT(slotSetZoom()))
263 << i18n("&Zoom to Angular Size...")
264 << QIcon::fromTheme("zoom-original")
266
267 action = actionCollection()->addAction(KStandardAction::FullScreen, this, SLOT(slotFullScreen()));
268 action->setIcon(QIcon::fromTheme("view-fullscreen"));
269
270 actionCollection()->addAction("coordsys", this, SLOT(slotCoordSys()))
271 << (Options::useAltAz() ? i18n("Switch to Star Globe View (Equatorial &Coordinates)") :
272 i18n("Switch to Horizontal View (Horizontal &Coordinates)"))
273 << QKeySequence("Space");
274
275 newToggleAction(
276 actionCollection(), "mirror_skymap",
277 i18nc("Mirror the view of the sky map", "Mirrored View"),
278 this, SLOT(slotSkyMapOrientation())) << QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_M);;
279
280 actionCollection()->addAction("toggle_terrain", this, SLOT(slotTerrain()))
281 << (Options::showTerrain() ? i18n("Hide Terrain") :
282 i18n("Show Terrain"))
283 << QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_T);
284
285 actionCollection()->addAction("toggle_image_overlays", this, SLOT(slotImageOverlays()))
286 << (Options::showImageOverlays() ? i18n("Hide Image Overlays") :
287 i18n("Show Image Overlays"))
288 << QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_O);
289
290 actionCollection()->addAction("project_lambert", this, SLOT(slotMapProjection()))
291 << i18n("&Lambert Azimuthal Equal-area") << QKeySequence("F5") << AddToGroup(projectionGroup)
292 << Checked(Options::projection() == Projector::Lambert);
293 actionCollection()->addAction("project_azequidistant", this, SLOT(slotMapProjection()))
294 << i18n("&Azimuthal Equidistant") << QKeySequence("F6") << AddToGroup(projectionGroup)
295 << Checked(Options::projection() == Projector::AzimuthalEquidistant);
296 actionCollection()->addAction("project_orthographic", this, SLOT(slotMapProjection()))
297 << i18n("&Orthographic") << QKeySequence("F7") << AddToGroup(projectionGroup)
298 << Checked(Options::projection() == Projector::Orthographic);
299 actionCollection()->addAction("project_equirectangular", this, SLOT(slotMapProjection()))
300 << i18n("&Equirectangular") << QKeySequence("F8") << AddToGroup(projectionGroup)
301 << Checked(Options::projection() == Projector::Equirectangular);
302 actionCollection()->addAction("project_stereographic", this, SLOT(slotMapProjection()))
303 << i18n("&Stereographic") << QKeySequence("F9") << AddToGroup(projectionGroup)
304 << Checked(Options::projection() == Projector::Stereographic);
305 actionCollection()->addAction("project_gnomonic", this, SLOT(slotMapProjection()))
306 << i18n("&Gnomonic") << QKeySequence("F10") << AddToGroup(projectionGroup)
307 << Checked(Options::projection() == Projector::Gnomonic);
308
309 //Settings Menu:
310 //Info Boxes option actions
311 QAction *kaBoxes = actionCollection()->add<KToggleAction>("show_boxes")
312 << i18nc("Show the information boxes", "Show &Info Boxes") << Checked(Options::showInfoBoxes());
313 connect(kaBoxes, SIGNAL(toggled(bool)), map(), SLOT(slotToggleInfoboxes(bool)));
314 kaBoxes->setChecked(Options::showInfoBoxes());
315
316 ka = actionCollection()->add<KToggleAction>("show_time_box")
317 << i18nc("Show time-related info box", "Show &Time Box");
318 connect(kaBoxes, SIGNAL(toggled(bool)), ka, SLOT(setEnabled(bool)));
319 connect(ka, SIGNAL(toggled(bool)), map(), SLOT(slotToggleTimeBox(bool)));
320 ka->setChecked(Options::showTimeBox());
321 ka->setEnabled(Options::showInfoBoxes());
322
323 ka = actionCollection()->add<KToggleAction>("show_focus_box")
324 << i18nc("Show focus-related info box", "Show &Focus Box");
325 connect(kaBoxes, SIGNAL(toggled(bool)), ka, SLOT(setEnabled(bool)));
326 connect(ka, SIGNAL(toggled(bool)), map(), SLOT(slotToggleFocusBox(bool)));
327 ka->setChecked(Options::showFocusBox());
328 ka->setEnabled(Options::showInfoBoxes());
329
330 ka = actionCollection()->add<KToggleAction>("show_location_box")
331 << i18nc("Show location-related info box", "Show &Location Box");
332 connect(kaBoxes, SIGNAL(toggled(bool)), ka, SLOT(setEnabled(bool)));
333 connect(ka, SIGNAL(toggled(bool)), map(), SLOT(slotToggleGeoBox(bool)));
334 ka->setChecked(Options::showGeoBox());
335 ka->setEnabled(Options::showInfoBoxes());
336
337 //Toolbar options
338 newToggleAction(actionCollection(), "show_mainToolBar", i18n("Show Main Toolbar"), toolBar("kstarsToolBar"),
339 SLOT(setVisible(bool)));
340 newToggleAction(actionCollection(), "show_viewToolBar", i18n("Show View Toolbar"), toolBar("viewToolBar"),
341 SLOT(setVisible(bool)));
342
343 //Statusbar view options
344 newToggleAction(actionCollection(), "show_statusBar", i18n("Show Statusbar"), this, SLOT(slotShowGUIItem(bool)));
345 newToggleAction(actionCollection(), "show_sbAzAlt", i18n("Show Az/Alt Field"), this, SLOT(slotShowGUIItem(bool)));
346 newToggleAction(actionCollection(), "show_sbRADec", i18n("Show RA/Dec Field"), this, SLOT(slotShowGUIItem(bool)));
347 newToggleAction(actionCollection(), "show_sbJ2000RADec", i18n("Show J2000.0 RA/Dec Field"), this,
348 SLOT(slotShowGUIItem(bool)));
349
350 populateThemes();
351
352 //Color scheme actions. These are added to the "colorschemes" KActionMenu.
353 colorActionMenu = actionCollection()->add<KActionMenu>("colorschemes");
354 colorActionMenu->setText(i18n("C&olor Schemes"));
355 addColorMenuItem(i18n("&Classic"), "cs_classic");
356 addColorMenuItem(i18n("&Star Chart"), "cs_chart");
357 addColorMenuItem(i18n("&Night Vision"), "cs_night");
358 addColorMenuItem(i18n("&Moonless Night"), "cs_moonless-night");
359
360 //Add any user-defined color schemes:
361 //determine filename in local user KDE directory tree.
362 QFile file(KSPaths::locate(QStandardPaths::AppLocalDataLocation, "colors.dat"));
363 if (file.exists() && file.open(QIODevice::ReadOnly))
364 {
365 QTextStream stream(&file);
366 while (!stream.atEnd())
367 {
368 QString line = stream.readLine();
369 QString schemeName = line.left(line.indexOf(':'));
370 QString actionname = "cs_" + line.mid(line.indexOf(':') + 1, line.indexOf('.') - line.indexOf(':') - 1);
371 addColorMenuItem(i18n(schemeName.toLocal8Bit()), actionname.toLocal8Bit());
372 }
373 file.close();
374 }
375
376 //Add FOV Symbol actions
377 fovActionMenu = actionCollection()->add<KActionMenu>("fovsymbols");
378 fovActionMenu->setText(i18n("&FOV Symbols"));
380 fovActionMenu->setIcon(QIcon::fromTheme("crosshairs"));
382 repopulateFOV();
383
384 //Add Views menu actions
385 viewsActionMenu = actionCollection()->add<KActionMenu>("views");
386 viewsActionMenu->setText(i18n("&Views"));
387 viewsActionMenu->setPopupMode(QToolButton::InstantPopup);
388 viewsActionMenu->setIcon(QIcon::fromTheme("text_rotation"));
391
392 //Add HIPS Sources actions
393 hipsActionMenu = actionCollection()->add<KActionMenu>("hipssources");
394 hipsActionMenu->setText(i18n("HiPS All Sky Overlay"));
396 hipsActionMenu->setIcon(QIcon::fromTheme("view-preview"));
397 HIPSManager::Instance()->readSources();
399
400 orientationActionMenu = actionCollection()->add<KActionMenu>("skymap_orientation");
401 orientationActionMenu->setText(i18n("Skymap Orientation"));
402 orientationActionMenu->setPopupMode(QToolButton::InstantPopup);
403 orientationActionMenu->setIcon(QIcon::fromTheme("screen-rotate-auto-on"));
404 repopulateOrientation();
405
406 actionCollection()->addAction("geolocation", this, SLOT(slotGeoLocator()))
407 << i18nc("Location on Earth", "&Geographic...")
408 << QIcon::fromTheme("kstars_xplanet")
410
411 // Configure Notifications
412#ifdef HAVE_NOTIFYCONFIG
413 KStandardAction::configureNotifications(this, SLOT(slotConfigureNotifications()), actionCollection());
414#endif
415
416 // Prepare the options dialog early for modules to connect signals
417 prepareOps();
418
419 ka = actionCollection()->addAction(KStandardAction::Preferences, "configure", this, SLOT(slotViewOps()));
420 //I am not sure what icon preferences is supposed to be.
421 //ka->setIcon( QIcon::fromTheme(""));
422
423 actionCollection()->addAction("startwizard", this, SLOT(slotWizard()))
424 << i18n("Startup Wizard...")
425 << QIcon::fromTheme("tools-wizard");
426
427 // Manual data entry
428 actionCollection()->addAction("dso_catalog_gui", this, SLOT(slotDSOCatalogGUI()))
429 << i18n("Manage DSO Catalogs");
430
431 // Updates actions
432 actionCollection()->addAction("update_comets", this, SLOT(slotUpdateComets()))
433 << i18n("Update Comets Orbital Elements");
434 actionCollection()->addAction("update_asteroids", this, SLOT(slotUpdateAsteroids()))
435 << i18n("Update Asteroids Orbital Elements");
436 actionCollection()->addAction("update_supernovae", this, SLOT(slotUpdateSupernovae()))
437 << i18n("Update Recent Supernovae Data");
438 actionCollection()->addAction("update_satellites", this, SLOT(slotUpdateSatellites()))
439 << i18n("Update Satellites Orbital Elements");
440
441 //Tools Menu:
442 actionCollection()->addAction("astrocalculator", this, SLOT(slotCalculator()))
443 << i18n("Calculator")
444 << QIcon::fromTheme("accessories-calculator")
446
447 /* FIXME Enable once port to KF5 is complete for moonphasetool
448 actionCollection()->addAction("moonphasetool", this, SLOT(slotMoonPhaseTool()) )
449 << i18n("Moon Phase Calendar");
450 */
451
452 actionCollection()->addAction("obslist", this, SLOT(slotObsList()))
453 << i18n("Observation Planner") << QKeySequence(Qt::CTRL + Qt::Key_L);
454
455 actionCollection()->addAction("altitude_vs_time", this, SLOT(slotAVT()))
456 << i18n("Altitude vs. Time") << QKeySequence(Qt::CTRL + Qt::Key_A);
457
458 actionCollection()->addAction("whats_up_tonight", this, SLOT(slotWUT()))
459 << i18n("What's up Tonight") << QKeySequence(Qt::CTRL + Qt::Key_U);
460
461 //FIXME Port to QML2
462 //#if 0
463 actionCollection()->addAction("whats_interesting", this, SLOT(slotToggleWIView()))
464 << i18n("What's Interesting...") << QKeySequence(Qt::CTRL + Qt::Key_W);
465 //#endif
466
467 actionCollection()->addAction("XPlanet", map(), SLOT(slotStartXplanetViewer()))
468 << i18n("XPlanet Solar System Simulator") << QKeySequence(Qt::CTRL + Qt::Key_X);
469
470 actionCollection()->addAction("skycalendar", this, SLOT(slotCalendar())) << i18n("Sky Calendar");
471
472#ifdef HAVE_INDI
473 ka = actionCollection()->addAction("ekos", this, SLOT(slotEkos()))
474 << i18n("Ekos") << QKeySequence(Qt::CTRL + Qt::Key_K);
476#endif
477
478 //FIXME: implement glossary
479 // ka = actionCollection()->addAction("glossary");
480 // ka->setText( i18n("Glossary...") );
481 // ka->setShortcuts( QKeySequence(Qt::CTRL+Qt::Key_K ) );
482 // connect( ka, SIGNAL(triggered()), this, SLOT(slotGlossary()) );
483
484 // 2017-09-17 Jasem: FIXME! Scripting does not work properly under non UNIX systems.
485 // It must be updated to use DBus session bus from Qt (like scheduler)
486#ifndef Q_OS_WIN
487 actionCollection()->addAction("scriptbuilder", this, SLOT(slotScriptBuilder()))
488 << i18n("Script Builder") << QKeySequence(Qt::CTRL + Qt::Key_B);
489#endif
490
491 actionCollection()->addAction("solarsystem", this, SLOT(slotSolarSystem()))
492 << i18n("Solar System") << QKeySequence(Qt::CTRL + Qt::Key_Y);
493
494 // Disabled until fixed later
495 actionCollection()->addAction("jmoontool", this, SLOT(slotJMoonTool()) )
496 << i18n("Jupiter's Moons")
498
499 actionCollection()->addAction("flagmanager", this, SLOT(slotFlagManager())) << i18n("Flags");
500
501 actionCollection()->addAction("equipmentwriter", this, SLOT(slotEquipmentWriter()))
502 << i18n("List your &Equipment...") << QIcon::fromTheme("kstars") << QKeySequence(Qt::CTRL + Qt::Key_0);
503 actionCollection()->addAction("manageobserver", this, SLOT(slotObserverManager()))
504 << i18n("Manage Observer...") << QIcon::fromTheme("im-user") << QKeySequence(Qt::CTRL + Qt::Key_1);
505
506 //TODO only enable it when finished
507 actionCollection()->addAction("artificialhorizon", this, SLOT(slotHorizonManager()))
508 << i18n("Artificial Horizon...");
509
510 // ==== observation menu - execute ================
511 actionCollection()->addAction("execute", this, SLOT(slotExecute()))
512 << i18n("Execute the Session Plan...") << QKeySequence(Qt::CTRL + Qt::Key_2);
513
514 // ==== observation menu - polaris hour angle ================
515 actionCollection()->addAction("polaris_hour_angle", this, SLOT(slotPolarisHourAngle()))
516 << i18n("Polaris Hour Angle...");
517
518 // ==== devices Menu ================
519#ifdef HAVE_INDI
520#ifndef Q_OS_WIN
521#if 0
522 actionCollection()->addAction("telescope_wizard", this, SLOT(slotTelescopeWizard()))
523 << i18n("Telescope Wizard...")
524 << QIcon::fromTheme("tools-wizard");
525#endif
526#endif
527 actionCollection()->addAction("device_manager", this, SLOT(slotINDIDriver()))
528 << i18n("Device Manager...")
529 << QIcon::fromTheme("network-server")
531 actionCollection()->addAction("custom_drivers", DriverManager::Instance(), SLOT(showCustomDrivers()))
532 << i18n("Custom Drivers...")
533 << QIcon::fromTheme("address-book-new");
534 ka = actionCollection()->addAction("indi_cpl", this, SLOT(slotINDIPanel()))
535 << i18n("INDI Control Panel...")
538 ka->setEnabled(false);
539#else
540 //FIXME need to disable/hide devices submenu in the tools menu. It is created from the kstarsui.rc file
541 //but I don't know how to hide/disable it yet. menuBar()->findChildren<QMenu *>() does not return any children that I can
542 //iterate over. Anyway to resolve this?
543#endif
544
545 //Help Menu:
546 ka = actionCollection()->addAction(KStandardAction::TipofDay, "help_tipofday", this, SLOT(slotTipOfDay()));
547 ka->setWhatsThis(i18n("Displays the Tip of the Day"));
548 ka->setIcon(QIcon::fromTheme("help-hint"));
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 != "DSS Colored");
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 //Show TotD
974 KTipDialog::showTip(this, "kstars/tips");
975
976 // Update comets and asteroids if enabled.
977 if (Options::orbitalElementsAutoUpdate())
978 {
979 slotUpdateComets(true);
980 slotUpdateAsteroids(true);
981 }
982
983#ifdef HAVE_INDI
984 Ekos::Manager::Instance()->initialize();
985#endif
986}
987
988void KStars::initFocus()
989{
990 //Case 1: tracking on an object
991 if (Options::isTracking() && Options::focusObject() != i18n("nothing"))
992 {
993 SkyObject *oFocus;
994 if (Options::focusObject() == i18n("star"))
995 {
996 SkyPoint p(Options::focusRA(), Options::focusDec());
997 double maxrad = 1.0;
998
999 oFocus = data()->skyComposite()->starNearest(&p, maxrad);
1000 }
1001 else
1002 {
1003 oFocus = data()->objectNamed(Options::focusObject());
1004 }
1005
1006 if (oFocus)
1007 {
1008 map()->setFocusObject(oFocus);
1009 map()->setClickedObject(oFocus);
1010 map()->setFocusPoint(oFocus);
1011 }
1012 else
1013 {
1014 qWarning() << "Cannot center on " << Options::focusObject() << ": no object found.";
1015 }
1016
1017 //Case 2: not tracking, and using Alt/Az coords. Set focus point using
1018 //FocusRA as the Azimuth, and FocusDec as the Altitude
1019 }
1020 else if (!Options::isTracking() && Options::useAltAz())
1021 {
1022 SkyPoint pFocus;
1023 pFocus.setAz(Options::focusRA());
1024 pFocus.setAlt(Options::focusDec());
1025 pFocus.HorizontalToEquatorial(data()->lst(), data()->geo()->lat());
1026 map()->setFocusPoint(&pFocus);
1027
1028 //Default: set focus point using FocusRA as the RA and
1029 //FocusDec as the Dec
1030 }
1031 else
1032 {
1033 SkyPoint pFocus(Options::focusRA(), Options::focusDec());
1034 pFocus.EquatorialToHorizontal(data()->lst(), data()->geo()->lat());
1035 map()->setFocusPoint(&pFocus);
1036 }
1038 map()->setDestination(*map()->focusPoint());
1039 map()->setFocus(map()->destination());
1040
1041 map()->showFocusCoords();
1042
1043 //Check whether initial position is below the horizon.
1044 if (Options::useAltAz() && Options::showGround() && map()->focus()->alt().Degrees() <= SkyPoint::altCrit)
1045 {
1046 QString caption = i18n("Initial Position is Below Horizon");
1047 QString message =
1048 i18n("The initial position is below the horizon.\nWould you like to reset to the default position?");
1049 if (KMessageBox::warningYesNo(this, message, caption, KGuiItem(i18n("Reset Position")),
1050 KGuiItem(i18n("Do Not Reset")), "dag_start_below_horiz") == KMessageBox::Yes)
1051 {
1052 map()->setClickedObject(nullptr);
1053 map()->setFocusObject(nullptr);
1054 Options::setIsTracking(false);
1055
1056 data()->setSnapNextFocus(true);
1057
1058 SkyPoint DefaultFocus;
1059 DefaultFocus.setAz(180.0);
1060 DefaultFocus.setAlt(45.0);
1061 DefaultFocus.HorizontalToEquatorial(data()->lst(), data()->geo()->lat());
1062 map()->setDestination(DefaultFocus);
1063 }
1064 }
1065
1066 //If there is a focusObject() and it is a SS body, add a temporary Trail
1067 if (map()->focusObject() && map()->focusObject()->isSolarSystem() && Options::useAutoTrail())
1068 {
1069 ((KSPlanetBase *)map()->focusObject())->addToTrail();
1070 data()->temporaryTrail = true;
1071 }
1072}
1073
1074void KStars::buildGUI()
1075{
1076 //create the texture manager
1078 //create the skymap
1079 m_SkyMap = SkyMap::Create();
1080 connect(m_SkyMap, SIGNAL(mousePointChanged(SkyPoint*)), SLOT(slotShowPositionBar(SkyPoint*)));
1081 connect(m_SkyMap, SIGNAL(zoomChanged()), SLOT(slotZoomChanged()));
1082 setCentralWidget(m_SkyMap);
1083
1084 //Initialize menus, toolbars, and statusbars
1085 initStatusBar();
1086 initActions();
1087
1088 // Setup GUI from the settings file
1089 // UI tests provide the default settings file from the resources explicitly file to render UI properly
1090 setupGUI(StandardWindowOptions(Default), m_KStarsUIResource);
1091
1092 //get focus of keyboard and mouse actions (for example zoom in with +)
1093 map()->QWidget::setFocus();
1094 resize(Options::windowWidth(), Options::windowHeight());
1095
1096 // check zoom in/out buttons
1097 if (Options::zoomFactor() >= MAXZOOM)
1098 actionCollection()->action("zoom_in")->setEnabled(false);
1099 if (Options::zoomFactor() <= MINZOOM)
1100 actionCollection()->action("zoom_out")->setEnabled(false);
1101}
1102
1103void KStars::populateThemes()
1104{
1105 KSTheme::Manager::instance()->setThemeMenuAction(new QMenu(i18n("&Themes"), this));
1106 KSTheme::Manager::instance()->registerThemeActions(this);
1107
1108 connect(KSTheme::Manager::instance(), SIGNAL(signalThemeChanged()), this, SLOT(slotThemeChanged()));
1109}
1110
1111void KStars::slotThemeChanged()
1112{
1113 Options::setCurrentTheme(KSTheme::Manager::instance()->currentThemeName());
1114}
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:218
GeoLocation * geo()
Definition kstarsdata.h:230
SkyMapComposite * skyComposite()
Definition kstarsdata.h:166
void setSnapNextFocus(bool b=true)
Disable or re-enable the slewing animation for the next Focus change.
Definition kstarsdata.h:283
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:141
void applyConfig(bool doApplyFocus=true)
Apply config options throughout the program.
Definition kstars.cpp:311
static KStars * Instance()
Definition kstars.h:123
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:135
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
QFlags< StandardWindowOption > StandardWindowOptions
void setupGUI(const QSize &defaultSize, StandardWindowOptions options=Default, const QString &xmlfile=QString())
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:944
void setDestination(const SkyPoint &f)
sets the destination point of the sky map.
Definition skymap.cpp:984
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:958
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
SkyObject * focusObject() const
Retrieve the object which is centered in the sky map.
Definition skymap.h:262
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:718
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...)
KCALENDARCORE_EXPORT QDataStream & operator<<(QDataStream &out, const KCalendarCore::Alarm::Ptr &)
QString name(GameStandardAction id)
GeoCoordinates geo(const QVariant &location)
QAction * configureNotifications(const QObject *recvr, const char *slot, QObject *parent)
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)
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
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 Fri Jul 26 2024 11:59:52 by doxygen 1.11.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.