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);
145 connect(ka, &QAction::triggered, this, &KStars::slotDownload);
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 actionCollection()->addAction("altitude_vs_time", this, SLOT(slotAVT()))
455 << i18n("Altitude vs. Time") << QKeySequence(Qt::CTRL | Qt::Key_A);
456
457 actionCollection()->addAction("whats_up_tonight", this, SLOT(slotWUT()))
458 << i18n("What's up Tonight") << QKeySequence(Qt::CTRL | Qt::Key_U);
459
460 //FIXME Port to QML2
461 //#if 0
462 actionCollection()->addAction("whats_interesting", this, SLOT(slotToggleWIView()))
463 << i18n("What's Interesting...") << QKeySequence(Qt::CTRL | Qt::Key_W);
464 //#endif
465
466 actionCollection()->addAction("XPlanet", map(), SLOT(slotStartXplanetViewer()))
467 << i18n("XPlanet Solar System Simulator") << QKeySequence(Qt::CTRL | Qt::Key_X);
468
469 actionCollection()->addAction("skycalendar", this, SLOT(slotCalendar())) << i18n("Sky Calendar");
470
471#ifdef HAVE_INDI
472 ka = actionCollection()->addAction("ekos", this, SLOT(slotEkos()))
473 << i18n("Ekos") << QKeySequence(Qt::CTRL | Qt::Key_K);
475#endif
476
477 //FIXME: implement glossary
478 // ka = actionCollection()->addAction("glossary");
479 // ka->setText( i18n("Glossary...") );
480 // ka->setShortcuts( QKeySequence(Qt::CTRL+Qt::Key_K ) );
481 // connect( ka, SIGNAL(triggered()), this, SLOT(slotGlossary()) );
482
483 // 2017-09-17 Jasem: FIXME! Scripting does not work properly under non UNIX systems.
484 // It must be updated to use DBus session bus from Qt (like scheduler)
485#ifndef Q_OS_WIN
486 actionCollection()->addAction("scriptbuilder", this, SLOT(slotScriptBuilder()))
487 << i18n("Script Builder") << QKeySequence(Qt::CTRL | Qt::Key_B);
488#endif
489
490 actionCollection()->addAction("solarsystem", this, SLOT(slotSolarSystem()))
491 << i18n("Solar System") << QKeySequence(Qt::CTRL | Qt::Key_Y);
492
493 // Disabled until fixed later
494 actionCollection()->addAction("jmoontool", this, SLOT(slotJMoonTool()) )
495 << i18n("Jupiter's Moons")
497
498 actionCollection()->addAction("flagmanager", this, SLOT(slotFlagManager())) << i18n("Flags");
499
500 actionCollection()->addAction("equipmentwriter", this, SLOT(slotEquipmentWriter()))
501 << i18n("List your &Equipment...") << QIcon::fromTheme("kstars") << QKeySequence(Qt::CTRL | Qt::Key_0);
502 actionCollection()->addAction("manageobserver", this, SLOT(slotObserverManager()))
503 << i18n("Manage Observer...") << QIcon::fromTheme("im-user") << QKeySequence(Qt::CTRL | Qt::Key_1);
504
505 //TODO only enable it when finished
506 actionCollection()->addAction("artificialhorizon", this, SLOT(slotHorizonManager()))
507 << i18n("Artificial Horizon...");
508
509 // ==== observation menu - execute ================
510 actionCollection()->addAction("execute", this, SLOT(slotExecute()))
511 << i18n("Execute the Session Plan...") << QKeySequence(Qt::CTRL | Qt::Key_2);
512
513 // ==== observation menu - polaris hour angle ================
514 actionCollection()->addAction("polaris_hour_angle", this, SLOT(slotPolarisHourAngle()))
515 << i18n("Polaris Hour Angle...");
516
517 // ==== devices Menu ================
518#ifdef HAVE_INDI
519#ifndef Q_OS_WIN
520#if 0
521 actionCollection()->addAction("telescope_wizard", this, SLOT(slotTelescopeWizard()))
522 << i18n("Telescope Wizard...")
523 << QIcon::fromTheme("tools-wizard");
524#endif
525#endif
526 actionCollection()->addAction("device_manager", this, SLOT(slotINDIDriver()))
527 << i18n("Device Manager...")
528 << QIcon::fromTheme("network-server")
530 actionCollection()->addAction("custom_drivers", DriverManager::Instance(), SLOT(showCustomDrivers()))
531 << i18n("Custom Drivers...")
532 << QIcon::fromTheme("address-book-new");
533 ka = actionCollection()->addAction("indi_cpl", this, SLOT(slotINDIPanel()))
534 << i18n("INDI Control Panel...")
537 ka->setEnabled(false);
538#else
539 //FIXME need to disable/hide devices submenu in the tools menu. It is created from the kstarsui.rc file
540 //but I don't know how to hide/disable it yet. menuBar()->findChildren<QMenu *>() does not return any children that I can
541 //iterate over. Anyway to resolve this?
542#endif
543
544 // KStandardAction::help(this, SLOT(appHelpActivated()), actionCollection(), "help_contents" );
545
546 //Add timestep widget for toolbar
547 m_TimeStepBox = new TimeStepBox(toolBar("kstarsToolBar"));
548 // Add a tool tip to TimeStep describing the weird nature of time steps
549 QString TSBToolTip = i18nc("Tooltip describing the nature of the time step control",
550 "Use this to set the rate at which time in the simulation flows.\nFor time step \'X\' "
551 "up to 10 minutes, time passes at the rate of \'X\' per second.\nFor time steps larger "
552 "than 10 minutes, frames are displayed at an interval of \'X\'.");
553 m_TimeStepBox->setToolTip(TSBToolTip);
554 m_TimeStepBox->tsbox()->setToolTip(TSBToolTip);
555 QWidgetAction *wa = new QWidgetAction(this);
556 wa->setDefaultWidget(m_TimeStepBox);
557
558 // Add actions for the timestep widget's functions
559 actionCollection()->addAction("timestep_control", wa) << i18n("Time step control");
560 const auto unitbox = m_TimeStepBox->unitbox();
561 ka = actionCollection()->addAction("timestep_increase_units", unitbox->increaseUnitsAction());
563 ka = actionCollection()->addAction("timestep_decrease_units", unitbox->decreaseUnitsAction());
565
566 // ==== viewToolBar actions ================
567 actionCollection()->add<KToggleAction>("show_stars", this, SLOT(slotViewToolBar()))
568 << i18nc("Toggle Stars in the display", "Stars")
569 << QIcon::fromTheme("kstars_stars")
570 << ToolTip(i18n("Toggle stars"));
571 actionCollection()->add<KToggleAction>("show_deepsky", this, SLOT(slotViewToolBar()))
572 << i18nc("Toggle Deep Sky Objects in the display", "Deep Sky")
573 << QIcon::fromTheme("kstars_deepsky")
574 << ToolTip(i18n("Toggle deep sky objects"));
575 actionCollection()->add<KToggleAction>("show_planets", this, SLOT(slotViewToolBar()))
576 << i18nc("Toggle Solar System objects in the display", "Solar System")
577 << QIcon::fromTheme("kstars_planets")
578 << ToolTip(i18n("Toggle Solar system objects"));
579 actionCollection()->add<KToggleAction>("show_clines", this, SLOT(slotViewToolBar()))
580 << i18nc("Toggle Constellation Lines in the display", "Const. Lines")
581 << QIcon::fromTheme("kstars_clines")
582 << ToolTip(i18n("Toggle constellation lines"));
583 actionCollection()->add<KToggleAction>("show_cnames", this, SLOT(slotViewToolBar()))
584 << i18nc("Toggle Constellation Names in the display", "Const. Names")
585 << QIcon::fromTheme("kstars_cnames")
586 << ToolTip(i18n("Toggle constellation names"));
587 actionCollection()->add<KToggleAction>("show_cbounds", this, SLOT(slotViewToolBar()))
588 << i18nc("Toggle Constellation Boundaries in the display", "C. Boundaries")
589 << QIcon::fromTheme("kstars_cbound")
590 << ToolTip(i18n("Toggle constellation boundaries"));
591 actionCollection()->add<KToggleAction>("show_constellationart", this, SLOT(slotViewToolBar()))
592 << xi18nc("Toggle Constellation Art in the display", "C. Art (BETA)")
593 << QIcon::fromTheme("kstars_constellationart")
594 << ToolTip(xi18n("Toggle constellation art (BETA)"));
595 actionCollection()->add<KToggleAction>("show_mw", this, SLOT(slotViewToolBar()))
596 << i18nc("Toggle Milky Way in the display", "Milky Way")
597 << QIcon::fromTheme("kstars_mw")
598 << ToolTip(i18n("Toggle milky way"));
599 actionCollection()->add<KToggleAction>("show_equatorial_grid", this, SLOT(slotViewToolBar()))
600 << i18nc("Toggle Equatorial Coordinate Grid in the display", "Equatorial coord. grid")
601 << QIcon::fromTheme("kstars_grid")
602 << ToolTip(i18n("Toggle equatorial coordinate grid"));
603 actionCollection()->add<KToggleAction>("show_horizontal_grid", this, SLOT(slotViewToolBar()))
604 << i18nc("Toggle Horizontal Coordinate Grid in the display", "Horizontal coord. grid")
605 << QIcon::fromTheme("kstars_hgrid")
606 << ToolTip(i18n("Toggle horizontal coordinate grid"));
607 actionCollection()->add<KToggleAction>("show_horizon", this, SLOT(slotViewToolBar()))
608 << i18nc("Toggle the opaque fill of the ground polygon in the display", "Ground")
609 << QIcon::fromTheme("kstars_horizon")
610 << ToolTip(i18n("Toggle opaque ground"));
611 actionCollection()->add<KToggleAction>("simulate_daytime", this, SLOT(slotViewToolBar()))
612 << i18nc("Toggle Daytime Simulation", "Daytime")
613 << QIcon::fromTheme("kstars_sun", QIcon(":/icons/kstars_sun.png"))
614 << ToolTip(i18n("Toggle daytime simulation"));
615 actionCollection()->add<KToggleAction>("show_flags", this, SLOT(slotViewToolBar()))
616 << i18nc("Toggle flags in the display", "Flags")
617 << QIcon::fromTheme("kstars_flag")
618 << ToolTip(i18n("Toggle flags"));
619 actionCollection()->add<KToggleAction>("show_satellites", this, SLOT(slotViewToolBar()))
620 << i18nc("Toggle satellites in the display", "Satellites")
621 << QIcon::fromTheme("kstars_satellites")
622 << ToolTip(i18n("Toggle satellites"));
623 actionCollection()->add<KToggleAction>("show_supernovae", this, SLOT(slotViewToolBar()))
624 << i18nc("Toggle supernovae in the display", "Supernovae")
625 << QIcon::fromTheme("kstars_supernovae")
626 << ToolTip(i18n("Toggle supernovae"));
627 actionCollection()->add<KToggleAction>("show_whatsinteresting", this, SLOT(slotToggleWIView()))
628 << i18nc("Toggle What's Interesting", "What's Interesting")
629 << QIcon::fromTheme("view-list-details")
630 << ToolTip(i18n("Toggle What's Interesting"));
631
632#ifdef HAVE_INDI
633 // ==== INDIToolBar actions ================
634 actionCollection()->add<KToggleAction>("show_ekos", this, SLOT(slotINDIToolBar()))
635 << i18nc("Toggle Ekos in the display", "Ekos")
636 << QIcon::fromTheme("kstars_ekos")
637 << ToolTip(i18n("Toggle Ekos"));
638 ka = actionCollection()->add<KToggleAction>("show_control_panel", this, SLOT(slotINDIToolBar()))
639 << i18nc("Toggle the INDI Control Panel in the display", "INDI Control Panel")
640 << QIcon::fromTheme("kstars_indi")
641 << ToolTip(i18n("Toggle INDI Control Panel"));
642 ka->setEnabled(false);
643 ka = actionCollection()->add<KToggleAction>("show_fits_viewer", this, SLOT(slotINDIToolBar()))
644 << i18nc("Toggle the FITS Viewer in the display", "FITS Viewer")
645 << QIcon::fromTheme("kstars_fitsviewer")
646 << ToolTip(i18n("Toggle FITS Viewer"));
647 ka->setEnabled(false);
648
649 ka = actionCollection()->add<KToggleAction>("show_sensor_fov", this, SLOT(slotINDIToolBar()))
650 << i18nc("Toggle the sensor Field of View", "Sensor FOV")
651 << QIcon::fromTheme("archive-extract")
652 << ToolTip(i18n("Toggle Sensor FOV"));
653 ka->setEnabled(false);
654 ka->setChecked(Options::showSensorFOV());
655
656 ka = actionCollection()->add<KToggleAction>("show_mosaic_panel", this, SLOT(slotINDIToolBar()))
657 << i18nc("Toggle the Mosaic Panel", "Mosaic Panel")
658 << QIcon::fromTheme("zoom-draw")
659 << ToolTip(i18n("Toggle Mosaic Panel"));
660 ka->setEnabled(true);
661 ka->setChecked(Options::showMosaicPanel());
662
663 ka = actionCollection()->add<KToggleAction>("show_mount_box", this, SLOT(slotINDIToolBar()))
664 << i18nc("Toggle the Mount Control Panel", "Mount Control")
665 << QIcon::fromTheme("draw-text")
666 << ToolTip(i18n("Toggle Mount Control Panel"));
667 telescopeGroup->addAction(ka);
668
669 ka = actionCollection()->add<KToggleAction>("lock_telescope", this, SLOT(slotINDIToolBar()))
670 << i18nc("Toggle the telescope center lock in display", "Center Telescope")
671 << QIcon::fromTheme("center_telescope", QIcon(":/icons/center_telescope.svg"))
672 << ToolTip(i18n("Toggle Lock Telescope Center"));
673 telescopeGroup->addAction(ka);
674
675 ka = actionCollection()->add<KToggleAction>("telescope_track", this, SLOT(slotINDITelescopeTrack()))
676 << i18n("Toggle Telescope Tracking")
677 << QIcon::fromTheme("object-locked");
678 telescopeGroup->addAction(ka);
679 ka = actionCollection()->addAction("telescope_slew", this, SLOT(slotINDITelescopeSlew()))
680 << i18n("Slew telescope to the focused object")
681 << QIcon::fromTheme("object-rotate-right");
682 telescopeGroup->addAction(ka);
683 ka = actionCollection()->addAction("telescope_sync", this, SLOT(slotINDITelescopeSync()))
684 << i18n("Sync telescope to the focused object")
685 << QIcon::fromTheme("media-record");
686 telescopeGroup->addAction(ka);
687 ka = actionCollection()->addAction("telescope_abort", this, SLOT(slotINDITelescopeAbort()))
688 << i18n("Abort telescope motions")
689 << QIcon::fromTheme("process-stop");
691 telescopeGroup->addAction(ka);
692 ka = actionCollection()->addAction("telescope_park", this, SLOT(slotINDITelescopePark()))
693 << i18n("Park telescope")
694 << QIcon::fromTheme("flag-red");
695 telescopeGroup->addAction(ka);
696 ka = actionCollection()->addAction("telescope_unpark", this, SLOT(slotINDITelescopeUnpark()))
697 << i18n("Unpark telescope")
698 << QIcon::fromTheme("flag-green");
700 telescopeGroup->addAction(ka);
701
702 actionCollection()->addAction("telescope_slew_mouse", this, SLOT(slotINDITelescopeSlewMousePointer()))
703 << i18n("Slew the telescope to the mouse pointer position");
704
705 actionCollection()->addAction("telescope_sync_mouse", this, SLOT(slotINDITelescopeSyncMousePointer()))
706 << i18n("Sync the telescope to the mouse pointer position");
707
708 // Disable all telescope actions by default
709 telescopeGroup->setEnabled(false);
710
711 // Dome Actions
712 ka = actionCollection()->addAction("dome_park", this, SLOT(slotINDIDomePark()))
713 << i18n("Park dome")
714 << QIcon::fromTheme("dome-park", QIcon(":/icons/dome-park.svg"));
715 domeGroup->addAction(ka);
716 ka = actionCollection()->addAction("dome_unpark", this, SLOT(slotINDIDomeUnpark()))
717 << i18n("Unpark dome")
718 << QIcon::fromTheme("dome-unpark", QIcon(":/icons/dome-unpark.svg"));
720 domeGroup->addAction(ka);
721
722 domeGroup->setEnabled(false);
723#endif
724}
725
726void KStars::repopulateOrientation()
727{
728 double rot = dms{Options::skyRotation()}.reduce().Degrees();
729 bool useAltAz = Options::useAltAz();
730 // TODO: Allow adding preset orientations, e.g. for finder scope, main scope etc.
731 orientationActionMenu->menu()->clear();
732 orientationActionMenu->addAction(
734 "up_orientation", this, SLOT(slotSkyMapOrientation()))
735 << (useAltAz ? i18nc("Orientation of the sky map", "Zenith &Up") : i18nc("Orientation of the sky map", "North &Up"))
736 << AddToGroup(skymapOrientationGroup)
737 << Checked(rot == 0.)
738 << ToolTip(i18nc("Orientation of the sky map",
739 "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.")));
740
741 orientationActionMenu->addAction(
743 "down_orientation", this, SLOT(slotSkyMapOrientation()))
744 << (useAltAz ? i18nc("Orientation of the sky map", "Zenith &Down") : i18nc("Orientation of the sky map", "North &Down"))
745 << AddToGroup(skymapOrientationGroup)
746 << Checked(rot == 180.)
747 << ToolTip(i18nc("Orientation of the sky map",
748 "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.")));
749
750 orientationActionMenu->addAction(
752 "arbitrary_orientation", this, SLOT(slotSkyMapOrientation()))
753 << i18nc("Orientation of the sky map is arbitrary as it has been adjusted by the user", "Arbitrary")
754 << AddToGroup(skymapOrientationGroup)
755 << Checked(rot != 180. && rot != 0.)
756 << ToolTip(i18nc("Orientation of the sky map",
757 "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")));
758
759 orientationActionMenu->addSeparator();
760
761 orientationActionMenu->addAction(
763 "erect_observer_correction_off", this, SLOT(slotSkyMapOrientation()))
764 << i18nc("Do not adjust the orientation of the sky map for an erect observer", "No correction")
765 << AddToGroup(erectObserverCorrectionGroup)
766 << Checked(Options::erectObserverCorrection() == 0)
767 << ToolTip(i18nc("Orientation of the sky map",
768 "Select this if you are using a camera on the telescope, or have the sky map display mounted on your telescope")));
769
770 orientationActionMenu->addAction(
772 "erect_observer_correction_left", this, SLOT(slotSkyMapOrientation()))
773 << i18nc("Adjust the orientation of the sky map for an erect observer, left-handed telescope",
774 "Erect observer correction, left-handed")
775 << AddToGroup(erectObserverCorrectionGroup)
776 << Checked(Options::erectObserverCorrection() == 1)
777 << ToolTip(i18nc("Orientation of the sky map",
778 "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.")));
779
780 orientationActionMenu->addAction(
782 "erect_observer_correction_right", this, SLOT(slotSkyMapOrientation()))
783 << i18nc("Adjust the orientation of the sky map for an erect observer, left-handed telescope",
784 "Erect observer correction, right-handed")
785 << AddToGroup(erectObserverCorrectionGroup)
786 << Checked(Options::erectObserverCorrection() == 2)
787 << ToolTip(i18nc("Orientation of the sky map",
788 "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.")));
789
790}
791
793{
794 viewsActionMenu->menu()->clear();
795
796 QList<QAction*> actions = viewsGroup->actions();
797 for (auto &action : actions)
798 viewsGroup->removeAction(action);
799
800 for (const auto &view : SkyMapViewManager::getViews())
801 {
802 QAction* action = actionCollection()->addAction(QString("view:%1").arg(view.name), this, [ = ]()
803 {
804 slotApplySkyMapView(view.name);
805 })
806 << view.name << AddToGroup(viewsGroup) << Checked(false);
807 viewsActionMenu->addAction(action);
808 action->setData(view.name);
809 }
810 viewsActionMenu->addAction(
811 actionCollection()->addAction("view:arbitrary")
812 << i18nc("Arbitrary Sky Map View", "Arbitrary") << AddToGroup(viewsGroup) << Checked(true)); // FIXME
813
814 // Add menu bottom
815 QAction *ka = actionCollection()->addAction("edit_views", this, SLOT(slotEditViews())) << i18n("Edit Views...");
816 viewsActionMenu->addSeparator();
817 viewsActionMenu->addAction(ka);
818}
819
820void KStars::repopulateFOV()
821{
822 // Read list of all FOVs
823 //qDeleteAll( data()->availFOVs );
824 data()->availFOVs = FOVManager::getFOVs();
825 data()->syncFOV();
826
827 // Iterate through FOVs
828 fovActionMenu->menu()->clear();
829 foreach (FOV *fov, data()->availFOVs)
830 {
831 KToggleAction *kta = actionCollection()->add<KToggleAction>(fov->name());
832 kta->setText(fov->name());
833 if (Options::fOVNames().contains(fov->name()))
834 {
835 kta->setChecked(true);
836 }
837
838 fovActionMenu->addAction(kta);
839 connect(kta, SIGNAL(toggled(bool)), this, SLOT(slotTargetSymbol(bool)));
840 }
841 // Add menu bottom
842 QAction *ka = actionCollection()->addAction("edit_fov", this, SLOT(slotFOVEdit())) << i18n("Edit FOV Symbols...");
843 fovActionMenu->addSeparator();
844 fovActionMenu->addAction(ka);
845}
846
848{
849 // Iterate through actions
850 hipsActionMenu->menu()->clear();
851 // Remove all actions
852 QList<QAction*> actions = hipsGroup->actions();
853
854 for (auto &action : actions)
855 hipsGroup->removeAction(action);
856
857 auto ka = actionCollection()->addAction(i18n("None"), this, SLOT(slotHIPSSource()))
858 << i18n("None") << AddToGroup(hipsGroup)
859 << Checked(Options::hIPSSource() == "None");
860
861 hipsActionMenu->addAction(ka);
862 hipsActionMenu->addSeparator();
863
864 for (QMap<QString, QString> source : HIPSManager::Instance()->getHIPSSources())
865 {
866 QString title = source.value("obs_title");
867
868 auto newAction = actionCollection()->addAction(title, this, SLOT(slotHIPSSource()))
869 << title << AddToGroup(hipsGroup)
870 << Checked(Options::hIPSSource() == title);
871
872 newAction->setDisabled(Options::hIPSUseOfflineSource() && title.compare("DSS Colored", Qt::CaseInsensitive));
873
874 hipsActionMenu->addAction(newAction);
875 }
876
877 // Hips settings
878 ka = actionCollection()->addAction("hipssettings", HIPSManager::Instance(),
879 SLOT(showSettings())) << i18n("HiPS Settings...");
880 hipsActionMenu->addSeparator();
881 hipsActionMenu->addAction(ka);
882}
883
884void KStars::initStatusBar()
885{
886 statusBar()->showMessage(i18n(" Welcome to KStars "));
887
888 QString s = "000d 00m 00s, +00d 00\' 00\""; //only need this to set the width
889
890 AltAzField.setHidden(!Options::showAltAzField());
891 AltAzField.setText(s);
892 statusBar()->insertPermanentWidget(0, &AltAzField);
893
894 RADecField.setHidden(!Options::showRADecField());
895 RADecField.setText(s);
896 statusBar()->insertPermanentWidget(1, &RADecField);
897
898 J2000RADecField.setHidden(!Options::showJ2000RADecField());
899 J2000RADecField.setText(s);
900 statusBar()->insertPermanentWidget(2, &J2000RADecField);
901
902 if (!Options::showStatusBar())
903 statusBar()->hide();
904}
905
906void KStars::datainitFinished()
907{
908 //Time-related connections
909 connect(data()->clock(), &SimClock::timeAdvanced, this, [this]()
910 {
911 updateTime();
912 });
913 connect(data()->clock(), &SimClock::timeChanged, this, [this]()
914 {
915 updateTime();
916 });
917 connect(data()->clock(), &SimClock::realtimeToogled, this, &KStars::slotRealTimeToogled);
918
919 //Add GUI elements to main window
920 buildGUI();
921
923
925 connect(m_TimeStepBox, &TimeStepBox::scaleChanged, data(), &KStarsData::setTimeDirection);
926 connect(m_TimeStepBox, &TimeStepBox::scaleChanged, data()->clock(), &SimClock::setClockScale);
927
928 //Do not start the clock if "--paused" specified on the cmd line
929 if (StartClockRunning)
930 {
931 // The initial time is set when KStars is first executed
932 // but until all data is loaded, some time elapsed already so we need to synchronize if no Start Date string
933 // was supplied to KStars
934 if (StartDateString.isEmpty())
936
937 data()->clock()->start();
938 }
939
940 // Connect cache function for Find dialog
941 connect(data(), SIGNAL(clearCache()), this, SLOT(clearCachedFindDialog()));
942
943 //Propagate config settings
944 applyConfig(false);
945
946 //show the window. must be before kswizard and messageboxes
947 show();
948
949 //Initialize focus
950 initFocus();
951
953 updateTime();
954
955 // Initial State
956 qCDebug(KSTARS) << "Date/Time is:" << data()->clock()->utc().toString();
957 qCDebug(KSTARS) << "Location:" << data()->geo()->fullName();
958 qCDebug(KSTARS) << "TZ0:" << data()->geo()->TZ0() << "TZ:" << data()->geo()->TZ();
959
960 KSTheme::Manager::instance()->setCurrentTheme(Options::currentTheme());
961
962 //If this is the first startup, show the wizard
963 if (Options::runStartupWizard())
964 {
965 slotWizard();
966 }
967
968 // Update comets and asteroids if enabled.
969 if (Options::orbitalElementsAutoUpdate())
970 {
971 slotUpdateComets(true);
972 slotUpdateAsteroids(true);
973 }
974
975#ifdef HAVE_INDI
976 Ekos::Manager::Instance()->initialize();
977#endif
978}
979
980void KStars::initFocus()
981{
982 //Case 1: tracking on an object
983 if (Options::isTracking() && Options::focusObject() != i18n("nothing"))
984 {
985 SkyObject *oFocus;
986 if (Options::focusObject() == i18n("star"))
987 {
988 SkyPoint p(Options::focusRA(), Options::focusDec());
989 double maxrad = 1.0;
990
991 oFocus = data()->skyComposite()->starNearest(&p, maxrad);
992 }
993 else
994 {
995 oFocus = data()->objectNamed(Options::focusObject());
996 }
997
998 if (oFocus)
999 {
1000 map()->setFocusObject(oFocus);
1001 map()->setClickedObject(oFocus);
1002 map()->setFocusPoint(oFocus);
1003 }
1004 else
1005 {
1006 qWarning() << "Cannot center on " << Options::focusObject() << ": no object found.";
1007 }
1008
1009 //Case 2: not tracking, and using Alt/Az coords. Set focus point using
1010 //FocusRA as the Azimuth, and FocusDec as the Altitude
1011 }
1012 else if (!Options::isTracking() && Options::useAltAz())
1013 {
1014 SkyPoint pFocus;
1015 pFocus.setAz(Options::focusRA());
1016 pFocus.setAlt(Options::focusDec());
1017 pFocus.HorizontalToEquatorial(data()->lst(), data()->geo()->lat());
1018 map()->setFocusPoint(&pFocus);
1019
1020 //Default: set focus point using FocusRA as the RA and
1021 //FocusDec as the Dec
1022 }
1023 else
1024 {
1025 SkyPoint pFocus(Options::focusRA(), Options::focusDec());
1026 pFocus.EquatorialToHorizontal(data()->lst(), data()->geo()->lat());
1027 map()->setFocusPoint(&pFocus);
1028 }
1030 map()->setDestination(*map()->focusPoint());
1031 map()->setFocus(map()->destination());
1032
1033 map()->showFocusCoords();
1034
1035 //Check whether initial position is below the horizon.
1036 if (Options::useAltAz() && Options::showGround() && map()->focus()->alt().Degrees() <= SkyPoint::altCrit)
1037 {
1038 QString caption = i18n("Initial Position is Below Horizon");
1039 QString message =
1040 i18n("The initial position is below the horizon.\nWould you like to reset to the default position?");
1041 if (KMessageBox::warningContinueCancel(this, message, caption, KGuiItem(i18n("Reset Position")),
1042 KGuiItem(i18n("Do Not Reset")), "dag_start_below_horiz") == KMessageBox::Continue)
1043 {
1044 map()->setClickedObject(nullptr);
1045 map()->setFocusObject(nullptr);
1046 Options::setIsTracking(false);
1047
1048 data()->setSnapNextFocus(true);
1049
1050 SkyPoint DefaultFocus;
1051 DefaultFocus.setAz(180.0);
1052 DefaultFocus.setAlt(45.0);
1053 DefaultFocus.HorizontalToEquatorial(data()->lst(), data()->geo()->lat());
1054 map()->setDestination(DefaultFocus);
1055 }
1056 }
1057
1058 //If there is a focusObject() and it is a SS body, add a temporary Trail
1059 if (map()->focusObject() && map()->focusObject()->isSolarSystem() && Options::useAutoTrail())
1060 {
1061 ((KSPlanetBase *)map()->focusObject())->addToTrail();
1062 data()->temporaryTrail = true;
1063 }
1064}
1065
1066void KStars::buildGUI()
1067{
1068 //create the texture manager
1070 //create the skymap
1071 m_SkyMap = SkyMap::Create();
1072 connect(m_SkyMap, SIGNAL(mousePointChanged(SkyPoint*)), SLOT(slotShowPositionBar(SkyPoint*)));
1073 connect(m_SkyMap, SIGNAL(zoomChanged()), SLOT(slotZoomChanged()));
1074 setCentralWidget(m_SkyMap);
1075
1076 //Initialize menus, toolbars, and statusbars
1077 initStatusBar();
1078 initActions();
1079
1080 // Setup GUI from the settings file
1081 // UI tests provide the default settings file from the resources explicitly file to render UI properly
1082 setupGUI(StandardWindowOptions(Default), m_KStarsUIResource);
1083
1084 //get focus of keyboard and mouse actions (for example zoom in with +)
1085 map()->QWidget::setFocus();
1086 resize(Options::windowWidth(), Options::windowHeight());
1087
1088 // check zoom in/out buttons
1089 if (Options::zoomFactor() >= MAXZOOM)
1090 actionCollection()->action("zoom_in")->setEnabled(false);
1091 if (Options::zoomFactor() <= MINZOOM)
1092 actionCollection()->action("zoom_out")->setEnabled(false);
1093}
1094
1095void KStars::populateThemes()
1096{
1097 KSTheme::Manager::instance()->setThemeMenuAction(new QMenu(i18n("&Themes"), this));
1098 KSTheme::Manager::instance()->registerThemeActions(this);
1099
1100 connect(KSTheme::Manager::instance(), SIGNAL(signalThemeChanged()), this, SLOT(slotThemeChanged()));
1101}
1102
1103void KStars::slotThemeChanged()
1104{
1105 Options::setCurrentTheme(KSTheme::Manager::instance()->currentThemeName());
1106}
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
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: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
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...)
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)
KTEXTEDITOR_EXPORT QDebug operator<<(QDebug s, const MovingCursor &cursor)
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 Fri Oct 11 2024 12:15:12 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.