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{
71 KStars::Instance()->actionCollection()->setDefaultShortcut(ka, sh);
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};
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};
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);
147 actionCollection()->setDefaultShortcut(ka, QKeySequence(Qt::CTRL + Qt::Key_N));
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
198 // If we are started in --paused state make sure the icon reflects that now
199 if (StartClockRunning == false)
200 {
201 QAction *a = actionCollection()->action("clock_startstop");
202 if (a)
203 a->setIcon(QIcon::fromTheme("run-build-install-root"));
204 }
205
206 QObject::connect(data()->clock(), &SimClock::clockToggled, [ = ](bool toggled)
207 {
208 QAction *a = actionCollection()->action("clock_startstop");
209 if (a)
210 {
211 a->setChecked(toggled);
212 // Many users forget to unpause KStars, so we are using run-build-install-root icon which is red
213 // and stands out from the rest of the icons so users are aware when KStars is paused visually
214 a->setIcon(toggled ? QIcon::fromTheme("run-build-install-root") : QIcon::fromTheme("media-playback-pause"));
215 a->setToolTip(toggled ? i18n("Resume Clock") : i18n("Stop Clock"));
216 }
217 });
218 //UpdateTime() if clock is stopped (so hidden objects get drawn)
219 QObject::connect(data()->clock(), SIGNAL(clockToggled(bool)), this, SLOT(updateTime()));
220 actionCollection()->addAction("time_step_forward", this, SLOT(slotStepForward()))
221 << i18n("Advance One Step Forward in Time")
222 << QIcon::fromTheme("media-skip-forward")
224 actionCollection()->addAction("time_step_backward", this, SLOT(slotStepBackward()))
225 << i18n("Advance One Step Backward in Time")
226 << QIcon::fromTheme("media-skip-backward")
228
229 // ==== Pointing Menu ================
230 actionCollection()->addAction("zenith", this, SLOT(slotPointFocus())) << i18n("&Zenith") << QKeySequence("Z");
231 actionCollection()->addAction("north", this, SLOT(slotPointFocus())) << i18n("&North") << QKeySequence("N");
232 actionCollection()->addAction("east", this, SLOT(slotPointFocus())) << i18n("&East") << QKeySequence("E");
233 actionCollection()->addAction("south", this, SLOT(slotPointFocus())) << i18n("&South") << QKeySequence("S");
234 actionCollection()->addAction("west", this, SLOT(slotPointFocus())) << i18n("&West") << QKeySequence("W");
235
236 actionCollection()->addAction("find_object", this, SLOT(slotFind()))
237 << i18n("&Find Object...") << QIcon::fromTheme("edit-find")
239 actionCollection()->addAction("track_object", this, SLOT(slotTrack()))
240 << i18n("Engage &Tracking")
241 << QIcon::fromTheme("object-locked")
243 actionCollection()->addAction("manual_focus", this, SLOT(slotManualFocus()))
244 << i18n("Set Coordinates &Manually...") << QKeySequence(Qt::CTRL + Qt::Key_M);
245
247
248 // ==== View Menu ================
249 action = actionCollection()->addAction(KStandardAction::ZoomIn, "zoom_in", map(), SLOT(slotZoomIn()));
250 action->setIcon(QIcon::fromTheme("zoom-in"));
251
252 action = actionCollection()->addAction(KStandardAction::ZoomOut, "zoom_out", map(), SLOT(slotZoomOut()));
253 action->setIcon(QIcon::fromTheme("zoom-out"));
254
255 actionCollection()->addAction("zoom_default", map(), SLOT(slotZoomDefault()))
256 << i18n("&Default Zoom") << QIcon::fromTheme("zoom-fit-best")
258 actionCollection()->addAction("zoom_set", this, SLOT(slotSetZoom()))
259 << i18n("&Zoom to Angular Size...")
260 << QIcon::fromTheme("zoom-original")
262
263 action = actionCollection()->addAction(KStandardAction::FullScreen, this, SLOT(slotFullScreen()));
264 action->setIcon(QIcon::fromTheme("view-fullscreen"));
265
266 actionCollection()->addAction("coordsys", this, SLOT(slotCoordSys()))
267 << (Options::useAltAz() ? i18n("Switch to Star Globe View (Equatorial &Coordinates)") :
268 i18n("Switch to Horizontal View (Horizontal &Coordinates)"))
269 << QKeySequence("Space");
270
272 actionCollection(), "mirror_skymap",
273 i18nc("Mirror the view of the sky map", "Mirrored View"),
274 this, SLOT(slotSkyMapOrientation())) << QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_M);;
275
276 actionCollection()->addAction("toggle_terrain", this, SLOT(slotTerrain()))
277 << (Options::showTerrain() ? i18n("Hide Terrain") :
278 i18n("Show Terrain"))
279 << QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_T);
280
281 actionCollection()->addAction("toggle_image_overlays", this, SLOT(slotImageOverlays()))
282 << (Options::showImageOverlays() ? i18n("Hide Image Overlays") :
283 i18n("Show Image Overlays"))
284 << QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_O);
285
286 actionCollection()->addAction("project_lambert", this, SLOT(slotMapProjection()))
287 << i18n("&Lambert Azimuthal Equal-area") << QKeySequence("F5") << AddToGroup(projectionGroup)
288 << Checked(Options::projection() == Projector::Lambert);
289 actionCollection()->addAction("project_azequidistant", this, SLOT(slotMapProjection()))
290 << i18n("&Azimuthal Equidistant") << QKeySequence("F6") << AddToGroup(projectionGroup)
291 << Checked(Options::projection() == Projector::AzimuthalEquidistant);
292 actionCollection()->addAction("project_orthographic", this, SLOT(slotMapProjection()))
293 << i18n("&Orthographic") << QKeySequence("F7") << AddToGroup(projectionGroup)
294 << Checked(Options::projection() == Projector::Orthographic);
295 actionCollection()->addAction("project_equirectangular", this, SLOT(slotMapProjection()))
296 << i18n("&Equirectangular") << QKeySequence("F8") << AddToGroup(projectionGroup)
297 << Checked(Options::projection() == Projector::Equirectangular);
298 actionCollection()->addAction("project_stereographic", this, SLOT(slotMapProjection()))
299 << i18n("&Stereographic") << QKeySequence("F9") << AddToGroup(projectionGroup)
300 << Checked(Options::projection() == Projector::Stereographic);
301 actionCollection()->addAction("project_gnomonic", this, SLOT(slotMapProjection()))
302 << i18n("&Gnomonic") << QKeySequence("F10") << AddToGroup(projectionGroup)
303 << Checked(Options::projection() == Projector::Gnomonic);
304
305 //Settings Menu:
306 //Info Boxes option actions
307 QAction *kaBoxes = actionCollection()->add<KToggleAction>("show_boxes")
308 << i18nc("Show the information boxes", "Show &Info Boxes") << Checked(Options::showInfoBoxes());
309 connect(kaBoxes, SIGNAL(toggled(bool)), map(), SLOT(slotToggleInfoboxes(bool)));
310 kaBoxes->setChecked(Options::showInfoBoxes());
311
312 ka = actionCollection()->add<KToggleAction>("show_time_box")
313 << i18nc("Show time-related info box", "Show &Time Box");
314 connect(kaBoxes, SIGNAL(toggled(bool)), ka, SLOT(setEnabled(bool)));
315 connect(ka, SIGNAL(toggled(bool)), map(), SLOT(slotToggleTimeBox(bool)));
316 ka->setChecked(Options::showTimeBox());
317 ka->setEnabled(Options::showInfoBoxes());
318
319 ka = actionCollection()->add<KToggleAction>("show_focus_box")
320 << i18nc("Show focus-related info box", "Show &Focus Box");
321 connect(kaBoxes, SIGNAL(toggled(bool)), ka, SLOT(setEnabled(bool)));
322 connect(ka, SIGNAL(toggled(bool)), map(), SLOT(slotToggleFocusBox(bool)));
323 ka->setChecked(Options::showFocusBox());
324 ka->setEnabled(Options::showInfoBoxes());
325
326 ka = actionCollection()->add<KToggleAction>("show_location_box")
327 << i18nc("Show location-related info box", "Show &Location Box");
328 connect(kaBoxes, SIGNAL(toggled(bool)), ka, SLOT(setEnabled(bool)));
329 connect(ka, SIGNAL(toggled(bool)), map(), SLOT(slotToggleGeoBox(bool)));
330 ka->setChecked(Options::showGeoBox());
331 ka->setEnabled(Options::showInfoBoxes());
332
333 //Toolbar options
334 newToggleAction(actionCollection(), "show_mainToolBar", i18n("Show Main Toolbar"), toolBar("kstarsToolBar"),
335 SLOT(setVisible(bool)));
336 newToggleAction(actionCollection(), "show_viewToolBar", i18n("Show View Toolbar"), toolBar("viewToolBar"),
337 SLOT(setVisible(bool)));
338
339 //Statusbar view options
340 newToggleAction(actionCollection(), "show_statusBar", i18n("Show Statusbar"), this, SLOT(slotShowGUIItem(bool)));
341 newToggleAction(actionCollection(), "show_sbAzAlt", i18n("Show Az/Alt Field"), this, SLOT(slotShowGUIItem(bool)));
342 newToggleAction(actionCollection(), "show_sbRADec", i18n("Show RA/Dec Field"), this, SLOT(slotShowGUIItem(bool)));
343 newToggleAction(actionCollection(), "show_sbJ2000RADec", i18n("Show J2000.0 RA/Dec Field"), this,
344 SLOT(slotShowGUIItem(bool)));
345
346 populateThemes();
347
348 //Color scheme actions. These are added to the "colorschemes" KActionMenu.
349 colorActionMenu = actionCollection()->add<KActionMenu>("colorschemes");
350 colorActionMenu->setText(i18n("C&olor Schemes"));
351 addColorMenuItem(i18n("&Classic"), "cs_classic");
352 addColorMenuItem(i18n("&Star Chart"), "cs_chart");
353 addColorMenuItem(i18n("&Night Vision"), "cs_night");
354 addColorMenuItem(i18n("&Moonless Night"), "cs_moonless-night");
355
356 //Add any user-defined color schemes:
357 //determine filename in local user KDE directory tree.
358 QFile file(KSPaths::locate(QStandardPaths::AppLocalDataLocation, "colors.dat"));
359 if (file.exists() && file.open(QIODevice::ReadOnly))
360 {
361 QTextStream stream(&file);
362 while (!stream.atEnd())
363 {
364 QString line = stream.readLine();
365 QString schemeName = line.left(line.indexOf(':'));
366 QString actionname = "cs_" + line.mid(line.indexOf(':') + 1, line.indexOf('.') - line.indexOf(':') - 1);
367 addColorMenuItem(i18n(schemeName.toLocal8Bit()), actionname.toLocal8Bit());
368 }
369 file.close();
370 }
371
372 //Add FOV Symbol actions
373 fovActionMenu = actionCollection()->add<KActionMenu>("fovsymbols");
374 fovActionMenu->setText(i18n("&FOV Symbols"));
375 fovActionMenu->setDelayed(false);
376 fovActionMenu->setIcon(QIcon::fromTheme("crosshairs"));
378 repopulateFOV();
379
380 //Add Views menu actions
381 viewsActionMenu = actionCollection()->add<KActionMenu>("views");
382 viewsActionMenu->setText(i18n("&Views"));
383 viewsActionMenu->setDelayed(false);
384 viewsActionMenu->setIcon(QIcon::fromTheme("text_rotation"));
387
388 //Add HIPS Sources actions
389 hipsActionMenu = actionCollection()->add<KActionMenu>("hipssources");
390 hipsActionMenu->setText(i18n("HiPS All Sky Overlay"));
391 hipsActionMenu->setDelayed(false);
392 hipsActionMenu->setIcon(QIcon::fromTheme("view-preview"));
393 HIPSManager::Instance()->readSources();
395
396 orientationActionMenu = actionCollection()->add<KActionMenu>("skymap_orientation");
397 orientationActionMenu->setText(i18n("Skymap Orientation"));
398 orientationActionMenu->setDelayed(false);
399 orientationActionMenu->setIcon(QIcon::fromTheme("screen-rotate-auto-on"));
400 repopulateOrientation();
401
402 actionCollection()->addAction("geolocation", this, SLOT(slotGeoLocator()))
403 << i18nc("Location on Earth", "&Geographic...")
404 << QIcon::fromTheme("kstars_xplanet")
406
407 // Configure Notifications
408#ifdef HAVE_NOTIFYCONFIG
409 KStandardAction::configureNotifications(this, SLOT(slotConfigureNotifications()), actionCollection());
410#endif
411
412 // Prepare the options dialog early for modules to connect signals
413 prepareOps();
414
415 ka = actionCollection()->addAction(KStandardAction::Preferences, "configure", this, SLOT(slotViewOps()));
416 //I am not sure what icon preferences is supposed to be.
417 //ka->setIcon( QIcon::fromTheme(""));
418
419 actionCollection()->addAction("startwizard", this, SLOT(slotWizard()))
420 << i18n("Startup Wizard...")
421 << QIcon::fromTheme("tools-wizard");
422
423 // Manual data entry
424 actionCollection()->addAction("dso_catalog_gui", this, SLOT(slotDSOCatalogGUI()))
425 << i18n("Manage DSO Catalogs");
426
427 // Updates actions
428 actionCollection()->addAction("update_comets", this, SLOT(slotUpdateComets()))
429 << i18n("Update Comets Orbital Elements");
430 actionCollection()->addAction("update_asteroids", this, SLOT(slotUpdateAsteroids()))
431 << i18n("Update Asteroids Orbital Elements");
432 actionCollection()->addAction("update_supernovae", this, SLOT(slotUpdateSupernovae()))
433 << i18n("Update Recent Supernovae Data");
434 actionCollection()->addAction("update_satellites", this, SLOT(slotUpdateSatellites()))
435 << i18n("Update Satellites Orbital Elements");
436
437 //Tools Menu:
438 actionCollection()->addAction("astrocalculator", this, SLOT(slotCalculator()))
439 << i18n("Calculator")
440 << QIcon::fromTheme("accessories-calculator")
442
443 /* FIXME Enable once port to KF5 is complete for moonphasetool
444 actionCollection()->addAction("moonphasetool", this, SLOT(slotMoonPhaseTool()) )
445 << i18n("Moon Phase Calendar");
446 */
447
448 actionCollection()->addAction("obslist", this, SLOT(slotObsList()))
449 << i18n("Observation Planner") << QKeySequence(Qt::CTRL + Qt::Key_L);
450
451 actionCollection()->addAction("altitude_vs_time", this, SLOT(slotAVT()))
452 << i18n("Altitude vs. Time") << QKeySequence(Qt::CTRL + Qt::Key_A);
453
454 actionCollection()->addAction("whats_up_tonight", this, SLOT(slotWUT()))
455 << i18n("What's up Tonight") << QKeySequence(Qt::CTRL + Qt::Key_U);
456
457 //FIXME Port to QML2
458 //#if 0
459 actionCollection()->addAction("whats_interesting", this, SLOT(slotToggleWIView()))
460 << i18n("What's Interesting...") << QKeySequence(Qt::CTRL + Qt::Key_W);
461 //#endif
462
463 actionCollection()->addAction("XPlanet", map(), SLOT(slotStartXplanetViewer()))
464 << i18n("XPlanet Solar System Simulator") << QKeySequence(Qt::CTRL + Qt::Key_X);
465
466 actionCollection()->addAction("skycalendar", this, SLOT(slotCalendar())) << i18n("Sky Calendar");
467
468#ifdef HAVE_INDI
469 ka = actionCollection()->addAction("ekos", this, SLOT(slotEkos()))
470 << i18n("Ekos") << QKeySequence(Qt::CTRL + Qt::Key_K);
471 ka->setShortcutContext(Qt::ApplicationShortcut);
472#endif
473
474 //FIXME: implement glossary
475 // ka = actionCollection()->addAction("glossary");
476 // ka->setText( i18n("Glossary...") );
477 // ka->setShortcuts( QKeySequence(Qt::CTRL+Qt::Key_K ) );
478 // connect( ka, SIGNAL(triggered()), this, SLOT(slotGlossary()) );
479
480 // 2017-09-17 Jasem: FIXME! Scripting does not work properly under non UNIX systems.
481 // It must be updated to use DBus session bus from Qt (like scheduler)
482#ifndef Q_OS_WIN
483 actionCollection()->addAction("scriptbuilder", this, SLOT(slotScriptBuilder()))
484 << i18n("Script Builder") << QKeySequence(Qt::CTRL + Qt::Key_B);
485#endif
486
487 actionCollection()->addAction("solarsystem", this, SLOT(slotSolarSystem()))
488 << i18n("Solar System") << QKeySequence(Qt::CTRL + Qt::Key_Y);
489
490 // Disabled until fixed later
491 actionCollection()->addAction("jmoontool", this, SLOT(slotJMoonTool()) )
492 << i18n("Jupiter's Moons")
494
495 actionCollection()->addAction("flagmanager", this, SLOT(slotFlagManager())) << i18n("Flags");
496
497 actionCollection()->addAction("equipmentwriter", this, SLOT(slotEquipmentWriter()))
498 << i18n("List your &Equipment...") << QIcon::fromTheme("kstars") << QKeySequence(Qt::CTRL + Qt::Key_0);
499 actionCollection()->addAction("manageobserver", this, SLOT(slotObserverManager()))
500 << i18n("Manage Observer...") << QIcon::fromTheme("im-user") << QKeySequence(Qt::CTRL + Qt::Key_1);
501
502 //TODO only enable it when finished
503 actionCollection()->addAction("artificialhorizon", this, SLOT(slotHorizonManager()))
504 << i18n("Artificial Horizon...");
505
506 // ==== observation menu - execute ================
507 actionCollection()->addAction("execute", this, SLOT(slotExecute()))
508 << i18n("Execute the Session Plan...") << QKeySequence(Qt::CTRL + Qt::Key_2);
509
510 // ==== observation menu - polaris hour angle ================
511 actionCollection()->addAction("polaris_hour_angle", this, SLOT(slotPolarisHourAngle()))
512 << i18n("Polaris Hour Angle...");
513
514 // ==== devices Menu ================
515#ifdef HAVE_INDI
516#ifndef Q_OS_WIN
517#if 0
518 actionCollection()->addAction("telescope_wizard", this, SLOT(slotTelescopeWizard()))
519 << i18n("Telescope Wizard...")
520 << QIcon::fromTheme("tools-wizard");
521#endif
522#endif
523 actionCollection()->addAction("device_manager", this, SLOT(slotINDIDriver()))
524 << i18n("Device Manager...")
525 << QIcon::fromTheme("network-server")
527 actionCollection()->addAction("custom_drivers", DriverManager::Instance(), SLOT(showCustomDrivers()))
528 << i18n("Custom Drivers...")
529 << QIcon::fromTheme("address-book-new");
530 ka = actionCollection()->addAction("indi_cpl", this, SLOT(slotINDIPanel()))
531 << i18n("INDI Control Panel...")
533 ka->setShortcutContext(Qt::ApplicationShortcut);
534 ka->setEnabled(false);
535#else
536 //FIXME need to disable/hide devices submenu in the tools menu. It is created from the kstarsui.rc file
537 //but I don't know how to hide/disable it yet. menuBar()->findChildren<QMenu *>() does not return any children that I can
538 //iterate over. Anyway to resolve this?
539#endif
540
541 //Help Menu:
542 ka = actionCollection()->addAction(KStandardAction::TipofDay, "help_tipofday", this, SLOT(slotTipOfDay()));
543 ka->setWhatsThis(i18n("Displays the Tip of the Day"));
544 ka->setIcon(QIcon::fromTheme("help-hint"));
545 // KStandardAction::help(this, SLOT(appHelpActivated()), actionCollection(), "help_contents" );
546
547 //Add timestep widget for toolbar
548 m_TimeStepBox = new TimeStepBox(toolBar("kstarsToolBar"));
549 // Add a tool tip to TimeStep describing the weird nature of time steps
550 QString TSBToolTip = i18nc("Tooltip describing the nature of the time step control",
551 "Use this to set the rate at which time in the simulation flows.\nFor time step \'X\' "
552 "up to 10 minutes, time passes at the rate of \'X\' per second.\nFor time steps larger "
553 "than 10 minutes, frames are displayed at an interval of \'X\'.");
554 m_TimeStepBox->setToolTip(TSBToolTip);
555 m_TimeStepBox->tsbox()->setToolTip(TSBToolTip);
556 QWidgetAction *wa = new QWidgetAction(this);
557 wa->setDefaultWidget(m_TimeStepBox);
558
559 // Add actions for the timestep widget's functions
560 actionCollection()->addAction("timestep_control", wa) << i18n("Time step control");
561 const auto unitbox = m_TimeStepBox->unitbox();
562 ka = actionCollection()->addAction("timestep_increase_units", unitbox->increaseUnitsAction());
563 actionCollection()->setDefaultShortcut(ka, QKeySequence(Qt::Key_Plus));
564 ka = actionCollection()->addAction("timestep_decrease_units", unitbox->decreaseUnitsAction());
565 actionCollection()->setDefaultShortcut(ka, QKeySequence(Qt::Key_Underscore));
566
567 // ==== viewToolBar actions ================
568 actionCollection()->add<KToggleAction>("show_stars", this, SLOT(slotViewToolBar()))
569 << i18nc("Toggle Stars in the display", "Stars")
570 << QIcon::fromTheme("kstars_stars")
571 << ToolTip(i18n("Toggle stars"));
572 actionCollection()->add<KToggleAction>("show_deepsky", this, SLOT(slotViewToolBar()))
573 << i18nc("Toggle Deep Sky Objects in the display", "Deep Sky")
574 << QIcon::fromTheme("kstars_deepsky")
575 << ToolTip(i18n("Toggle deep sky objects"));
576 actionCollection()->add<KToggleAction>("show_planets", this, SLOT(slotViewToolBar()))
577 << i18nc("Toggle Solar System objects in the display", "Solar System")
578 << QIcon::fromTheme("kstars_planets")
579 << ToolTip(i18n("Toggle Solar system objects"));
580 actionCollection()->add<KToggleAction>("show_clines", this, SLOT(slotViewToolBar()))
581 << i18nc("Toggle Constellation Lines in the display", "Const. Lines")
582 << QIcon::fromTheme("kstars_clines")
583 << ToolTip(i18n("Toggle constellation lines"));
584 actionCollection()->add<KToggleAction>("show_cnames", this, SLOT(slotViewToolBar()))
585 << i18nc("Toggle Constellation Names in the display", "Const. Names")
586 << QIcon::fromTheme("kstars_cnames")
587 << ToolTip(i18n("Toggle constellation names"));
588 actionCollection()->add<KToggleAction>("show_cbounds", this, SLOT(slotViewToolBar()))
589 << i18nc("Toggle Constellation Boundaries in the display", "C. Boundaries")
590 << QIcon::fromTheme("kstars_cbound")
591 << ToolTip(i18n("Toggle constellation boundaries"));
592 actionCollection()->add<KToggleAction>("show_constellationart", this, SLOT(slotViewToolBar()))
593 << xi18nc("Toggle Constellation Art in the display", "C. Art (BETA)")
594 << QIcon::fromTheme("kstars_constellationart")
595 << ToolTip(xi18n("Toggle constellation art (BETA)"));
596 actionCollection()->add<KToggleAction>("show_mw", this, SLOT(slotViewToolBar()))
597 << i18nc("Toggle Milky Way in the display", "Milky Way")
598 << QIcon::fromTheme("kstars_mw")
599 << ToolTip(i18n("Toggle milky way"));
600 actionCollection()->add<KToggleAction>("show_equatorial_grid", this, SLOT(slotViewToolBar()))
601 << i18nc("Toggle Equatorial Coordinate Grid in the display", "Equatorial coord. grid")
602 << QIcon::fromTheme("kstars_grid")
603 << ToolTip(i18n("Toggle equatorial coordinate grid"));
604 actionCollection()->add<KToggleAction>("show_horizontal_grid", this, SLOT(slotViewToolBar()))
605 << i18nc("Toggle Horizontal Coordinate Grid in the display", "Horizontal coord. grid")
606 << QIcon::fromTheme("kstars_hgrid")
607 << ToolTip(i18n("Toggle horizontal coordinate grid"));
608 actionCollection()->add<KToggleAction>("show_horizon", this, SLOT(slotViewToolBar()))
609 << i18nc("Toggle the opaque fill of the ground polygon in the display", "Ground")
610 << QIcon::fromTheme("kstars_horizon")
611 << ToolTip(i18n("Toggle opaque ground"));
612 actionCollection()->add<KToggleAction>("simulate_daytime", this, SLOT(slotViewToolBar()))
613 << i18nc("Toggle Daytime Simulation", "Daytime")
614 << QIcon::fromTheme("kstars_sun", QIcon(":/icons/kstars_sun.png"))
615 << ToolTip(i18n("Toggle daytime simulation"));
616 actionCollection()->add<KToggleAction>("show_flags", this, SLOT(slotViewToolBar()))
617 << i18nc("Toggle flags in the display", "Flags")
618 << QIcon::fromTheme("kstars_flag")
619 << ToolTip(i18n("Toggle flags"));
620 actionCollection()->add<KToggleAction>("show_satellites", this, SLOT(slotViewToolBar()))
621 << i18nc("Toggle satellites in the display", "Satellites")
622 << QIcon::fromTheme("kstars_satellites")
623 << ToolTip(i18n("Toggle satellites"));
624 actionCollection()->add<KToggleAction>("show_supernovae", this, SLOT(slotViewToolBar()))
625 << i18nc("Toggle supernovae in the display", "Supernovae")
626 << QIcon::fromTheme("kstars_supernovae")
627 << ToolTip(i18n("Toggle supernovae"));
628 actionCollection()->add<KToggleAction>("show_whatsinteresting", this, SLOT(slotToggleWIView()))
629 << i18nc("Toggle What's Interesting", "What's Interesting")
630 << QIcon::fromTheme("view-list-details")
631 << ToolTip(i18n("Toggle What's Interesting"));
632
633#ifdef HAVE_INDI
634 // ==== INDIToolBar actions ================
635 actionCollection()->add<KToggleAction>("show_ekos", this, SLOT(slotINDIToolBar()))
636 << i18nc("Toggle Ekos in the display", "Ekos")
637 << QIcon::fromTheme("kstars_ekos")
638 << ToolTip(i18n("Toggle Ekos"));
639 ka = actionCollection()->add<KToggleAction>("show_control_panel", this, SLOT(slotINDIToolBar()))
640 << i18nc("Toggle the INDI Control Panel in the display", "INDI Control Panel")
641 << QIcon::fromTheme("kstars_indi")
642 << ToolTip(i18n("Toggle INDI Control Panel"));
643 ka->setEnabled(false);
644 ka = actionCollection()->add<KToggleAction>("show_fits_viewer", this, SLOT(slotINDIToolBar()))
645 << i18nc("Toggle the FITS Viewer in the display", "FITS Viewer")
646 << QIcon::fromTheme("kstars_fitsviewer")
647 << ToolTip(i18n("Toggle FITS Viewer"));
648 ka->setEnabled(false);
649
650 ka = actionCollection()->add<KToggleAction>("show_sensor_fov", this, SLOT(slotINDIToolBar()))
651 << i18nc("Toggle the sensor Field of View", "Sensor FOV")
652 << QIcon::fromTheme("archive-extract")
653 << ToolTip(i18n("Toggle Sensor FOV"));
654 ka->setEnabled(false);
655 ka->setChecked(Options::showSensorFOV());
656
657 ka = actionCollection()->add<KToggleAction>("show_mosaic_panel", this, SLOT(slotINDIToolBar()))
658 << i18nc("Toggle the Mosaic Panel", "Mosaic Panel")
659 << QIcon::fromTheme("zoom-draw")
660 << ToolTip(i18n("Toggle Mosaic Panel"));
661 ka->setEnabled(true);
662 ka->setChecked(Options::showMosaicPanel());
663
664 ka = actionCollection()->add<KToggleAction>("show_mount_box", this, SLOT(slotINDIToolBar()))
665 << i18nc("Toggle the Mount Control Panel", "Mount Control")
666 << QIcon::fromTheme("draw-text")
667 << ToolTip(i18n("Toggle Mount Control Panel"));
668 telescopeGroup->addAction(ka);
669
670 ka = actionCollection()->add<KToggleAction>("lock_telescope", this, SLOT(slotINDIToolBar()))
671 << i18nc("Toggle the telescope center lock in display", "Center Telescope")
672 << QIcon::fromTheme("center_telescope", QIcon(":/icons/center_telescope.svg"))
673 << ToolTip(i18n("Toggle Lock Telescope Center"));
674 telescopeGroup->addAction(ka);
675
676 ka = actionCollection()->add<KToggleAction>("telescope_track", this, SLOT(slotINDITelescopeTrack()))
677 << i18n("Toggle Telescope Tracking")
678 << QIcon::fromTheme("object-locked");
679 telescopeGroup->addAction(ka);
680 ka = actionCollection()->addAction("telescope_slew", this, SLOT(slotINDITelescopeSlew()))
681 << i18n("Slew telescope to the focused object")
682 << QIcon::fromTheme("object-rotate-right");
683 telescopeGroup->addAction(ka);
684 ka = actionCollection()->addAction("telescope_sync", this, SLOT(slotINDITelescopeSync()))
685 << i18n("Sync telescope to the focused object")
686 << QIcon::fromTheme("media-record");
687 telescopeGroup->addAction(ka);
688 ka = actionCollection()->addAction("telescope_abort", this, SLOT(slotINDITelescopeAbort()))
689 << i18n("Abort telescope motions")
690 << QIcon::fromTheme("process-stop");
691 ka->setShortcutContext(Qt::ApplicationShortcut);
692 telescopeGroup->addAction(ka);
693 ka = actionCollection()->addAction("telescope_park", this, SLOT(slotINDITelescopePark()))
694 << i18n("Park telescope")
695 << QIcon::fromTheme("flag-red");
696 telescopeGroup->addAction(ka);
697 ka = actionCollection()->addAction("telescope_unpark", this, SLOT(slotINDITelescopeUnpark()))
698 << i18n("Unpark telescope")
699 << QIcon::fromTheme("flag-green");
700 ka->setShortcutContext(Qt::ApplicationShortcut);
701 telescopeGroup->addAction(ka);
702
703 actionCollection()->addAction("telescope_slew_mouse", this, SLOT(slotINDITelescopeSlewMousePointer()))
704 << i18n("Slew the telescope to the mouse pointer position");
705
706 actionCollection()->addAction("telescope_sync_mouse", this, SLOT(slotINDITelescopeSyncMousePointer()))
707 << i18n("Sync the telescope to the mouse pointer position");
708
709 // Disable all telescope actions by default
710 telescopeGroup->setEnabled(false);
711
712 // Dome Actions
713 ka = actionCollection()->addAction("dome_park", this, SLOT(slotINDIDomePark()))
714 << i18n("Park dome")
715 << QIcon::fromTheme("dome-park", QIcon(":/icons/dome-park.svg"));
716 domeGroup->addAction(ka);
717 ka = actionCollection()->addAction("dome_unpark", this, SLOT(slotINDIDomeUnpark()))
718 << i18n("Unpark dome")
719 << QIcon::fromTheme("dome-unpark", QIcon(":/icons/dome-unpark.svg"));
720 ka->setShortcutContext(Qt::ApplicationShortcut);
721 domeGroup->addAction(ka);
722
723 domeGroup->setEnabled(false);
724#endif
725}
726
727void KStars::repopulateOrientation()
728{
729 double rot = dms{Options::skyRotation()}.reduce().Degrees();
730 bool useAltAz = Options::useAltAz();
731 // TODO: Allow adding preset orientations, e.g. for finder scope, main scope etc.
732 orientationActionMenu->menu()->clear();
733 orientationActionMenu->addAction(
735 "up_orientation", this, SLOT(slotSkyMapOrientation()))
736 << (useAltAz ? i18nc("Orientation of the sky map", "Zenith &Up") : i18nc("Orientation of the sky map", "North &Up"))
737 << AddToGroup(skymapOrientationGroup)
738 << Checked(rot == 0.)
739 << ToolTip(i18nc("Orientation of the sky map",
740 "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.")));
741
742 orientationActionMenu->addAction(
744 "down_orientation", this, SLOT(slotSkyMapOrientation()))
745 << (useAltAz ? i18nc("Orientation of the sky map", "Zenith &Down") : i18nc("Orientation of the sky map", "North &Down"))
746 << AddToGroup(skymapOrientationGroup)
747 << Checked(rot == 180.)
748 << ToolTip(i18nc("Orientation of the sky map",
749 "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.")));
750
751 orientationActionMenu->addAction(
753 "arbitrary_orientation", this, SLOT(slotSkyMapOrientation()))
754 << i18nc("Orientation of the sky map is arbitrary as it has been adjusted by the user", "Arbitrary")
755 << AddToGroup(skymapOrientationGroup)
756 << Checked(rot != 180. && rot != 0.)
757 << ToolTip(i18nc("Orientation of the sky map",
758 "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")));
759
760 orientationActionMenu->addSeparator();
761
762 orientationActionMenu->addAction(
764 "erect_observer_correction_off", this, SLOT(slotSkyMapOrientation()))
765 << i18nc("Do not adjust the orientation of the sky map for an erect observer", "No correction")
766 << AddToGroup(erectObserverCorrectionGroup)
767 << Checked(Options::erectObserverCorrection() == 0)
768 << ToolTip(i18nc("Orientation of the sky map",
769 "Select this if you are using a camera on the telescope, or have the sky map display mounted on your telescope")));
770
771 orientationActionMenu->addAction(
773 "erect_observer_correction_left", this, SLOT(slotSkyMapOrientation()))
774 << i18nc("Adjust the orientation of the sky map for an erect observer, left-handed telescope",
775 "Erect observer correction, left-handed")
776 << AddToGroup(erectObserverCorrectionGroup)
777 << Checked(Options::erectObserverCorrection() == 1)
778 << ToolTip(i18nc("Orientation of the sky map",
779 "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.")));
780
781 orientationActionMenu->addAction(
783 "erect_observer_correction_right", this, SLOT(slotSkyMapOrientation()))
784 << i18nc("Adjust the orientation of the sky map for an erect observer, left-handed telescope",
785 "Erect observer correction, right-handed")
786 << AddToGroup(erectObserverCorrectionGroup)
787 << Checked(Options::erectObserverCorrection() == 2)
788 << ToolTip(i18nc("Orientation of the sky map",
789 "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.")));
790
791}
792
794{
795 viewsActionMenu->menu()->clear();
796
797 QList<QAction*> actions = viewsGroup->actions();
798 for (auto &action : actions)
799 viewsGroup->removeAction(action);
800
801 for (const auto &view : SkyMapViewManager::getViews())
802 {
803 QAction* action = actionCollection()->addAction(QString("view:%1").arg(view.name), this, [ = ]()
804 {
805 slotApplySkyMapView(view.name);
806 })
807 << view.name << AddToGroup(viewsGroup) << Checked(false);
808 viewsActionMenu->addAction(action);
809 action->setData(view.name);
810 }
811 viewsActionMenu->addAction(
812 actionCollection()->addAction("view:arbitrary")
813 << i18nc("Arbitrary Sky Map View", "Arbitrary") << AddToGroup(viewsGroup) << Checked(true)); // FIXME
814
815 // Add menu bottom
816 QAction *ka = actionCollection()->addAction("edit_views", this, SLOT(slotEditViews())) << i18n("Edit Views...");
817 viewsActionMenu->addSeparator();
818 viewsActionMenu->addAction(ka);
819}
820
821void KStars::repopulateFOV()
822{
823 // Read list of all FOVs
824 //qDeleteAll( data()->availFOVs );
825 data()->availFOVs = FOVManager::getFOVs();
826 data()->syncFOV();
827
828 // Iterate through FOVs
829 fovActionMenu->menu()->clear();
830 foreach (FOV *fov, data()->availFOVs)
831 {
832 KToggleAction *kta = actionCollection()->add<KToggleAction>(fov->name());
833 kta->setText(fov->name());
834 if (Options::fOVNames().contains(fov->name()))
835 {
836 kta->setChecked(true);
837 }
838
839 fovActionMenu->addAction(kta);
840 connect(kta, SIGNAL(toggled(bool)), this, SLOT(slotTargetSymbol(bool)));
841 }
842 // Add menu bottom
843 QAction *ka = actionCollection()->addAction("edit_fov", this, SLOT(slotFOVEdit())) << i18n("Edit FOV Symbols...");
844 fovActionMenu->addSeparator();
845 fovActionMenu->addAction(ka);
846}
847
849{
850 // Iterate through actions
851 hipsActionMenu->menu()->clear();
852 // Remove all actions
853 QList<QAction*> actions = hipsGroup->actions();
854
855 for (auto &action : actions)
856 hipsGroup->removeAction(action);
857
858 auto ka = actionCollection()->addAction(i18n("None"), this, SLOT(slotHIPSSource()))
859 << i18n("None") << AddToGroup(hipsGroup)
860 << Checked(Options::hIPSSource() == "None");
861
862 hipsActionMenu->addAction(ka);
863 hipsActionMenu->addSeparator();
864
865 for (QMap<QString, QString> source : HIPSManager::Instance()->getHIPSSources())
866 {
867 QString title = source.value("obs_title");
868
869 auto newAction = actionCollection()->addAction(title, this, SLOT(slotHIPSSource()))
870 << title << AddToGroup(hipsGroup)
871 << Checked(Options::hIPSSource() == title);
872
873 newAction->setDisabled(Options::hIPSUseOfflineSource() && title != "DSS Colored");
874
875 hipsActionMenu->addAction(newAction);
876 }
877
878 // Hips settings
879 ka = actionCollection()->addAction("hipssettings", HIPSManager::Instance(),
880 SLOT(showSettings())) << i18n("HiPS Settings...");
881 hipsActionMenu->addSeparator();
882 hipsActionMenu->addAction(ka);
883}
884
885void KStars::initStatusBar()
886{
887 statusBar()->showMessage(i18n(" Welcome to KStars "));
888
889 QString s = "000d 00m 00s, +00d 00\' 00\""; //only need this to set the width
890
891 AltAzField.setHidden(!Options::showAltAzField());
892 AltAzField.setText(s);
893 statusBar()->insertPermanentWidget(0, &AltAzField);
894
895 RADecField.setHidden(!Options::showRADecField());
896 RADecField.setText(s);
897 statusBar()->insertPermanentWidget(1, &RADecField);
898
899 J2000RADecField.setHidden(!Options::showJ2000RADecField());
900 J2000RADecField.setText(s);
901 statusBar()->insertPermanentWidget(2, &J2000RADecField);
902
903 if (!Options::showStatusBar())
904 statusBar()->hide();
905}
906
907void KStars::datainitFinished()
908{
909 //Time-related connections
910 connect(data()->clock(), &SimClock::timeAdvanced, this, [this]()
911 {
912 updateTime();
913 });
914 connect(data()->clock(), &SimClock::timeChanged, this, [this]()
915 {
916 updateTime();
917 });
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 //Show TotD
969 KTipDialog::showTip(this, "kstars/tips");
970
971 // Update comets and asteroids if enabled.
972 if (Options::orbitalElementsAutoUpdate())
973 {
974 slotUpdateComets(true);
975 slotUpdateAsteroids(true);
976 }
977
978#ifdef HAVE_INDI
979 Ekos::Manager::Instance()->initialize();
980#endif
981}
982
983void KStars::initFocus()
984{
985 //Case 1: tracking on an object
986 if (Options::isTracking() && Options::focusObject() != i18n("nothing"))
987 {
989 if (Options::focusObject() == i18n("star"))
990 {
991 SkyPoint p(Options::focusRA(), Options::focusDec());
992 double maxrad = 1.0;
993
995 }
996 else
997 {
998 oFocus = data()->objectNamed(Options::focusObject());
999 }
1000
1001 if (oFocus)
1002 {
1006 }
1007 else
1008 {
1009 qWarning() << "Cannot center on " << Options::focusObject() << ": no object found.";
1010 }
1011
1012 //Case 2: not tracking, and using Alt/Az coords. Set focus point using
1013 //FocusRA as the Azimuth, and FocusDec as the Altitude
1014 }
1015 else if (!Options::isTracking() && Options::useAltAz())
1016 {
1018 pFocus.setAz(Options::focusRA());
1019 pFocus.setAlt(Options::focusDec());
1020 pFocus.HorizontalToEquatorial(data()->lst(), data()->geo()->lat());
1022
1023 //Default: set focus point using FocusRA as the RA and
1024 //FocusDec as the Dec
1025 }
1026 else
1027 {
1028 SkyPoint pFocus(Options::focusRA(), Options::focusDec());
1029 pFocus.EquatorialToHorizontal(data()->lst(), data()->geo()->lat());
1031 }
1033 map()->setDestination(*map()->focusPoint());
1034 map()->setFocus(map()->destination());
1035
1036 map()->showFocusCoords();
1037
1038 //Check whether initial position is below the horizon.
1039 if (Options::useAltAz() && Options::showGround() && map()->focus()->alt().Degrees() <= SkyPoint::altCrit)
1040 {
1041 QString caption = i18n("Initial Position is Below Horizon");
1042 QString message =
1043 i18n("The initial position is below the horizon.\nWould you like to reset to the default position?");
1044 if (KMessageBox::warningYesNo(this, message, caption, KGuiItem(i18n("Reset Position")),
1045 KGuiItem(i18n("Do Not Reset")), "dag_start_below_horiz") == KMessageBox::Yes)
1046 {
1047 map()->setClickedObject(nullptr);
1048 map()->setFocusObject(nullptr);
1049 Options::setIsTracking(false);
1050
1051 data()->setSnapNextFocus(true);
1052
1054 DefaultFocus.setAz(180.0);
1055 DefaultFocus.setAlt(45.0);
1056 DefaultFocus.HorizontalToEquatorial(data()->lst(), data()->geo()->lat());
1058 }
1059 }
1060
1061 //If there is a focusObject() and it is a SS body, add a temporary Trail
1062 if (map()->focusObject() && map()->focusObject()->isSolarSystem() && Options::useAutoTrail())
1063 {
1064 ((KSPlanetBase *)map()->focusObject())->addToTrail();
1065 data()->temporaryTrail = true;
1066 }
1067}
1068
1069void KStars::buildGUI()
1070{
1071 //create the texture manager
1073 //create the skymap
1074 m_SkyMap = SkyMap::Create();
1075 connect(m_SkyMap, SIGNAL(mousePointChanged(SkyPoint*)), SLOT(slotShowPositionBar(SkyPoint*)));
1076 connect(m_SkyMap, SIGNAL(zoomChanged()), SLOT(slotZoomChanged()));
1077 setCentralWidget(m_SkyMap);
1078
1079 //Initialize menus, toolbars, and statusbars
1080 initStatusBar();
1081 initActions();
1082
1083 // Setup GUI from the settings file
1084 // UI tests provide the default settings file from the resources explicitly file to render UI properly
1085 setupGUI(StandardWindowOptions(Default), m_KStarsUIResource);
1086
1087 //get focus of keyboard and mouse actions (for example zoom in with +)
1088 map()->QWidget::setFocus();
1089 resize(Options::windowWidth(), Options::windowHeight());
1090
1091 // check zoom in/out buttons
1092 if (Options::zoomFactor() >= MAXZOOM)
1093 actionCollection()->action("zoom_in")->setEnabled(false);
1094 if (Options::zoomFactor() <= MINZOOM)
1095 actionCollection()->action("zoom_out")->setEnabled(false);
1096}
1097
1098void KStars::populateThemes()
1099{
1100 KSTheme::Manager::instance()->setThemeMenuAction(new QMenu(i18n("&Themes"), this));
1101 KSTheme::Manager::instance()->registerThemeActions(this);
1102
1103 connect(KSTheme::Manager::instance(), SIGNAL(signalThemeChanged()), this, SLOT(slotThemeChanged()));
1104}
1105
1106void KStars::slotThemeChanged()
1107{
1108 Options::setCurrentTheme(KSTheme::Manager::instance()->currentThemeName());
1109}
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
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 scaleChanged(float)
The timestep has changed.
Q_SCRIPTABLE Q_NOREPLY void setClockScale(double scale)
DBUS function to set scale of simclock.
Definition simclock.cpp:169
const KStarsDateTime & utc() const
Definition simclock.h:35
Q_SCRIPTABLE Q_NOREPLY void start()
DBUS function to start the SimClock.
Definition simclock.cpp:120
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
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
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)
QAction * configureNotifications(const QObject *recvr, const char *slot, QObject *parent)
QString name(StandardAction id)
void setChecked(bool)
void setIcon(const QIcon &icon)
QMenu * menu() const const
void setText(const QString &text)
void setToolTip(const QString &tip)
void triggered(bool checked)
QList< QAction * > actions() const const
QAction * addAction(QAction *action)
void setEnabled(bool)
void removeAction(QAction *action)
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
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)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 24 2024 11:49:22 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.