File indexing completed on 2025-04-13 06:35:54
0001 /* 0002 SPDX-FileCopyrightText: 2001 Jason Harris <jharris@30doradus.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include <QMenu> 0010 #include <QHash> 0011 0012 class QAction; 0013 0014 class DeepSkyObject; 0015 class CatalogObject; 0016 class KSMoon; 0017 class Satellite; 0018 class SkyObject; 0019 class SkyPoint; 0020 class StarObject; 0021 class Supernova; 0022 0023 /** 0024 * @class KSPopupMenu 0025 * The KStars Popup Menu. The menu is sensitive to the 0026 * object type of the object which was clicked to invoke the menu. 0027 * Items in the menu include name and type data; rise/transit/set times; 0028 * actions such as Center, Details, Telescope actions, and Label; 0029 * and Image and Information URL links. 0030 * 0031 * @author Jason Harris 0032 * @version 1.0 0033 */ 0034 class KSPopupMenu : public QMenu 0035 { 0036 Q_OBJECT 0037 public: 0038 /** Default constructor*/ 0039 KSPopupMenu(); 0040 0041 /** Destructor (empty)*/ 0042 ~KSPopupMenu() override; 0043 0044 /** 0045 * Add an item to the popup menu for each of the URL links associated with 0046 * this object. URL links appear in two categories: images and information pages. 0047 * For some objects, a link to Digitized Sky Survey images will automatically be added 0048 * in addition to the object's normal image links. Also, for some objects, an 0049 * "Add link..." item will be included, which allows the user to add their own custom 0050 * URLs for this object. 0051 * @param obj pointer to the skyobject which the menu describes 0052 * @param showDSS if true, include DSS Image links 0053 */ 0054 void addLinksToMenu(SkyObject *obj, bool showDSS = true); 0055 0056 /** 0057 * @short Create a popup menu for a star. 0058 * 0059 * Stars get the following labels: a primary name and/or a genetive name, 0060 * a spectral type, an object type ("star"), and rise/transit/set times. 0061 * Stars get a "Center & Track" item, an Angular Distance item, and a 0062 * "Detailed Info" item. Named stars get an "Attach Label" item and an 0063 * "Add Link..." item, and may have image/info links; all stars get DSS 0064 * image links. Stars do not get an "Add Trail" item. 0065 * @param star pointer to the star which the menu describes 0066 */ 0067 void createStarMenu(StarObject *star); 0068 0069 /** 0070 * @short Create a popup menu for a deep-sky catalog object. 0071 * 0072 * DSOs get the following labels: 0073 * a common name and/or a catalog name, an object type, and rise/transit/set 0074 * times. DSOs get a "Center & Track" item, an Angular Distance item, an 0075 * "Attach Label" item, and a "Detailed Info" item. 0076 * They may have image/info links, and also get the DSS Image links and the 0077 * "Add Link..." item. They do not get an "Add Trail" item. 0078 * @param obj pointer to the object which the menu describes 0079 */ 0080 void createCatalogObjectMenu(CatalogObject *obj); 0081 0082 /** 0083 * @short Create a popup menu for a solar system body. 0084 * 0085 * Solar System bodies get a name label, a type label ("solar system object"), 0086 * and rise/set/transit time labels. They also get Center&Track, 0087 * Angular Distance, Detailed Info, Attach Label, and Add Trail items. 0088 * They can have image/info links, and also get the "Add Link..." item. 0089 * @note despite the name "createPlanetMenu", this function is used for 0090 * comets and asteroids as well. 0091 * @param p the solar system object which the menu describes. 0092 */ 0093 void createPlanetMenu(SkyObject *p); 0094 0095 void createMoonMenu(KSMoon *moon); 0096 0097 /** 0098 * @short Create a popup menu for a satellite. 0099 * @param satellite the satellite which the menu describes. 0100 */ 0101 void createSatelliteMenu(Satellite *satellite); 0102 0103 /** 0104 * @short Create a popup menu for a supernova 0105 * @param supernova the supernova which the menu describes. 0106 */ 0107 void createSupernovaMenu(Supernova *supernova); 0108 0109 /** 0110 * @short Create a popup menu for empty sky. 0111 * 0112 * The popup menu when right-clicking on nothing is still useful. 0113 * Instead of a name label, it shows "Empty Sky". The rise/set/transit 0114 * times of the clicked point on the sky are also shown. You also get 0115 * the Center & Track and Angular Distance items, and the DSS image links. 0116 * @param nullObj pointer to point on the sky 0117 */ 0118 void createEmptyMenu(SkyPoint *nullObj); 0119 0120 private slots: 0121 void slotEditFlag(); 0122 void slotDeleteFlag(); 0123 void slotEditFlag(QAction *action); 0124 void slotDeleteFlag(QAction *action); 0125 void slotViewInWI(); 0126 0127 private: 0128 /** 0129 * Initialize the popup menus. Adds name and type labels, and possibly 0130 * Rise/Set/Transit labels, Center/Track item, and Show Details item. 0131 * @short initialize the right-click popup menu 0132 * @param obj pointer to the skyobject which the menu describes 0133 * @param name The object name 0134 * @param type a string identifying the object type 0135 * @param type short information about object 0136 * @param showDetails if true, the Show-Details item is added 0137 * @param showObsList if true, the Add to List/Remove from List item is added. 0138 */ 0139 void initPopupMenu(SkyObject *obj, const QString &name, const QString &type, QString info, bool showDetails = true, 0140 bool showObsList = true, bool showFlags = true); 0141 0142 void initFlagActions(SkyObject *obj); 0143 0144 /** 0145 * Add a submenu for INDI controls (Slew, Track, Sync, etc). 0146 * @return true if a valid INDI menu was added. 0147 */ 0148 void addINDI(); 0149 0150 /** 0151 * Add fancy label to menu. 0152 * @param name is content of the label 0153 * @param deltaFontSize is change in font size from default 0154 */ 0155 void addFancyLabel(const QString &name, int deltaFontSize = 0); 0156 0157 int m_CurrentFlagIdx { 0 }; 0158 QHash<QAction *, int> *m_EditActionMapping { nullptr }; 0159 QHash<QAction *, int> *m_DeleteActionMapping { nullptr }; 0160 };