20 #include <QSignalMapper>
38 #include <config-kstars.h>
49 #include <basedevice.h>
57 QString magToStr(
double m) {
58 return QString(
"%1<sup>m</sup>").arg(m, 0,
'f', 2);
79 QString riseSetTimeLabel(
SkyObject* o,
bool isRaise) {
84 QString time = KGlobal::locale()->formatTime( t.addSecs(30) );
86 i18n (
"Rise time: %1", time) :
87 i18nc(
"the time at which an object falls below the horizon",
"Set time: %1" , time);
90 return isRaise ? i18n(
"No rise time: Circumpolar" ) : i18n(
"No set time: Circumpolar" );
92 return isRaise ? i18n(
"No rise time: Never rises" ) : i18n(
"No set time: Never rises" );
101 return i18n(
"Transit time: %1", KGlobal::locale()->formatTime( t.addSecs(30) ) );
110 :
KMenu(
KStars::Instance() ), m_CurrentFlagIdx(-1), m_EditActionMapping(0), m_DeleteActionMapping(0)
115 if(m_EditActionMapping) {
116 delete m_EditActionMapping;
119 if(m_DeleteActionMapping) {
120 delete m_DeleteActionMapping;
129 initPopupMenu( &o, i18n(
"Empty sky" ), QString(), QString(),
false,
false );
130 addAction(
i18nc(
"Sloan Digital Sky Survey",
"Show SDSS Image" ), ks->
map(), SLOT( slotSDSS() ) );
131 addAction(
i18nc(
"Digitized Sky Survey",
"Show DSS Image" ), ks->
map(), SLOT( slotDSS() ) );
134 void KSPopupMenu::slotEditFlag() {
135 if ( m_CurrentFlagIdx != -1 ) {
140 void KSPopupMenu::slotDeleteFlag() {
141 if ( m_CurrentFlagIdx != -1 ) {
146 void KSPopupMenu::slotEditFlag( QAction *action ) {
147 int idx = m_EditActionMapping->value( action, -1 );
158 void KSPopupMenu::slotDeleteFlag( QAction *action ) {
159 int idx = m_DeleteActionMapping->value( action, -1 );
174 if( star->
name() !=
"star" ) {
178 name = QString(
"HD%1" ).arg( QString::number( star->
getHDIndex() ) );
184 initPopupMenu( star, name, i18n(
"star" ), i18n(
"%1<sup>m</sup>, %2", star->
mag(), star->
sptype()) );
186 if ( star->
name() !=
"star" ) {
189 addAction(
i18nc(
"Sloan Digital Sky Survey",
"Show SDSS Image" ), ks->
map(), SLOT( slotSDSS() ) );
190 addAction(
i18nc(
"Digitized Sky Survey",
"Show DSS Image" ), ks->
map(), SLOT( slotDSS() ) );
195 QString name = getObjectName(obj);
198 QString info = magToStr( obj->
mag() );
199 initPopupMenu( obj, name, typeName, info );
204 QString info = magToStr( p->
mag() );
205 QString type = i18n(
"Solar system object");;
211 QString info = QString(
"%1, %2").arg( magToStr(moon->
mag()), moon->
phaseName() );
218 QString velocity, altitude, range;
219 velocity.setNum( satellite->
velocity() );
220 altitude.setNum( satellite->
altitude() );
221 range.setNum( satellite->
range() );
225 addFancyLabel( satellite->
name() );
226 addFancyLabel( satellite->
id() );
227 addFancyLabel( i18n(
"satellite" ) );
228 addFancyLabel(
KStarsData::Instance()->skyComposite()->getConstellationBoundary()->constellationName( satellite ) );
232 addFancyLabel( i18n(
"Velocity : %1 km/s", velocity ), -2 );
233 addFancyLabel( i18n(
"Altitude : %1 km", altitude ), -2 );
234 addFancyLabel( i18n(
"Range : %1 km", range ), -2 );
239 addAction( i18n(
"Center && Track" ), ks->
map(), SLOT( slotCenter() ) );
242 addAction( i18n(
"Angular Distance To... [" ), ks->
map(),
243 SLOT(slotBeginAngularDistance()) );
244 addAction( i18n(
"Starhop from here to... " ), ks->
map(),
245 SLOT(slotBeginStarHop()) );
249 addAction( i18n(
"Remove Label" ), ks->
map(), SLOT( slotRemoveObjectLabel() ) );
251 addAction( i18n(
"Attach Label" ), ks->
map(), SLOT( slotAddObjectLabel() ) );
256 QString name=supernova->
name();
257 float mag = supernova->
mag();
258 QString type = supernova->
getType();
259 initPopupMenu( supernova, name, i18n(
"supernova" ), i18n(
"%1<sup>m</sup>, %2", mag, type) );
262 void KSPopupMenu::initPopupMenu(
SkyObject *obj, QString name, QString type, QString info,
263 bool showDetails,
bool showObsList,
bool showFlags )
268 bool showLabel = name != i18n(
"star") && !name.isEmpty();
270 name = i18n(
"Empty sky" );
272 addFancyLabel( name );
273 addFancyLabel( type );
274 addFancyLabel( info );
275 addFancyLabel(
KStarsData::Instance()->skyComposite()->getConstellationBoundary()->constellationName( obj ) );
280 addFancyLabel( riseSetTimeLabel(o,
true), -2 );
281 addFancyLabel( riseSetTimeLabel(o,
false), -2 );
282 addFancyLabel( transitTimeLabel(o), -2 );
288 addAction( i18n(
"Select this object"),
KStars::Instance()->map(), SLOT(slotObjectSelected()));
292 addAction( i18n(
"Center && Track" ), ks->
map(), SLOT( slotCenter() ) );
296 initFlagActions( obj );
301 addAction( i18n(
"Angular Distance To... [" ), ks->
map(),
302 SLOT(slotBeginAngularDistance()) );
303 addAction( i18n(
"Starhop from here to... " ), ks->
map(),
304 SLOT(slotBeginStarHop()) );
308 addAction(
i18nc(
"Show Detailed Information Dialog",
"Details" ), ks->
map(), SLOT( slotDetail() ) );
312 addAction( i18n(
"Remove Label" ), ks->
map(), SLOT( slotRemoveObjectLabel() ) );
314 addAction( i18n(
"Attach Label" ), ks->
map(), SLOT( slotAddObjectLabel() ) );
320 addAction( i18n(
"Remove From Observing WishList"), ks->
observingList(), SLOT( slotRemoveObject() ) );
322 addAction( i18n(
"Add to Observing WishList"), ks->
observingList(), SLOT( slotAddObject() ) );
328 addAction( i18n(
"Remove Trail" ), ks->
map(), SLOT( slotRemovePlanetTrail() ) );
330 addAction( i18n(
"Add Trail" ), ks->
map(), SLOT( slotAddPlanetTrail() ) );
336 QMenu *xplanetSubmenu =
new QMenu();
337 xplanetSubmenu->setTitle( i18n(
"Print Xplanet view" ) );
338 xplanetSubmenu->addAction( i18n(
"To screen" ), ks->
map(), SLOT( slotXplanetToScreen() ) );
339 xplanetSubmenu->addAction( i18n(
"To file..." ), ks->
map(), SLOT( slotXplanetToFile() ) );
340 addMenu( xplanetSubmenu );
347 void KSPopupMenu::initFlagActions(
SkyObject *obj ) {
352 if ( flags.size() == 0 ) {
354 addAction( i18n(
"Add flag..."), ks->
map(), SLOT( slotAddFlag() ) );
357 else if( flags.size() == 1) {
359 addAction ( i18n (
"Edit flag"),
this, SLOT( slotEditFlag() ) );
360 addAction ( i18n (
"Delete flag"),
this, SLOT( slotDeleteFlag() ) );
362 m_CurrentFlagIdx = flags.first();
368 QMenu *deleteMenu =
new QMenu ( i18n (
"Delete flag..."),
KStars::Instance() );
370 connect( editMenu, SIGNAL( triggered(QAction*) ),
this, SLOT( slotEditFlag(QAction*) ) );
371 connect( deleteMenu, SIGNAL( triggered(QAction*) ),
this, SLOT( slotDeleteFlag(QAction*) ) );
373 if ( m_EditActionMapping ) {
374 delete m_EditActionMapping;
377 if ( m_DeleteActionMapping ) {
378 delete m_DeleteActionMapping;
381 m_EditActionMapping =
new QHash<QAction*, int>;
382 m_DeleteActionMapping =
new QHash<QAction*, int>;
384 foreach (
int idx, flags ) {
388 if ( flagLabel.size() > 35 ) {
389 flagLabel = flagLabel.left( 35 );
390 flagLabel.append(
"..." );
393 QAction *editAction =
new QAction( flagIcon, flagLabel, ks );
394 editAction->setIconVisibleInMenu(
true );
395 editMenu->addAction( editAction );
396 m_EditActionMapping->insert( editAction, idx );
398 QAction *deleteAction =
new QAction( flagIcon, flagLabel, ks );
399 deleteAction->setIconVisibleInMenu(
true );
400 deleteMenu->addAction( deleteAction );
401 m_DeleteActionMapping->insert( deleteAction, idx);
405 addMenu( deleteMenu );
412 QStringList::ConstIterator itList, itTitle, itListEnd;
418 QMenu *imageLinkSubMenu=
new QMenu();
419 imageLinkSubMenu->setTitle( i18n(
"Image Resources" ) );
420 for ( ; itList != itListEnd; ++itList ) {
421 QString t = QString(*itTitle);
422 sURL = QString(*itList);
423 imageLinkSubMenu->addAction(
i18nc(
"Image/info menu item (should be translated)", t.toLocal8Bit() ), ks->
map(), SLOT( slotImage() ) );
426 addMenu( imageLinkSubMenu );
430 addAction(
i18nc(
"Sloan Digital Sky Survey",
"Show SDSS Image" ), ks->
map(), SLOT( slotSDSS() ) );
431 addAction(
i18nc(
"Digitized Sky Survey",
"Show DSS Image" ), ks->
map(), SLOT( slotDSS() ) );
437 itList = obj->
InfoList().constBegin();
439 itListEnd = obj->
InfoList().constEnd();
442 QMenu *infoLinkSubMenu=
new QMenu();
443 infoLinkSubMenu->setTitle( i18n(
"Information Resources" ) );
444 for ( ; itList != itListEnd; ++itList ) {
445 QString t = QString(*itTitle);
446 sURL = QString(*itList);
447 infoLinkSubMenu->addAction(
i18nc(
"Image/info menu item (should be translated)", t.toLocal8Bit() ), ks->
map(), SLOT( slotInfo() ) );
450 addMenu( infoLinkSubMenu );
454 void KSPopupMenu::addINDI()
471 KMenu* menuDevice = NULL;
479 QSignalMapper *sMapper =
new QSignalMapper(
this);
481 ISwitchVectorProperty *svp = pp->getSwitch();
483 for (
int i=0; i < svp->nsp; i++)
485 if (menuDevice == NULL)
491 QAction *a = menuDevice->addAction(svp->sp[i].label);
495 sMapper->setMapping(a, cmd);
497 connect(a, SIGNAL(triggered()), sMapper, SLOT(map()));
499 if (!strcmp(svp->sp[i].name,
"SLEW") || !strcmp(svp->sp[i].name,
"SYNC") || !strcmp(svp->sp[i].name,
"TRACK"))
506 QSignalMapper *scopeMapper =
new QSignalMapper(
this);
509 connect(a, SIGNAL(triggered()), scopeMapper, SLOT(map()));
511 connect(scopeMapper, SIGNAL(mapped(
int)), telescope, SLOT(runCommand(
int)));
518 connect(sMapper, SIGNAL(mapped(
QObject*)), gd, SLOT(setProperty(
QObject*)));
520 menuDevice->addSeparator();
525 if (telescope && menuDevice)
527 menuDevice->addSeparator();
529 QAction *a = menuDevice->addAction(i18n(
"Center Crosshair"));
531 QSignalMapper *scopeMapper =
new QSignalMapper(
this);
533 connect(a, SIGNAL(triggered()), scopeMapper, SLOT(map()));
534 connect(scopeMapper, SIGNAL(mapped(
int)), telescope, SLOT(runCommand(
int)));
542 void KSPopupMenu::addFancyLabel(QString name,
int deltaFontSize) {
546 label->setAlignment( Qt::AlignHCenter | Qt::AlignVCenter );
547 if( deltaFontSize != 0 ) {
548 QFont font = label->font();
549 font.setPointSize( font.pointSize() + deltaFontSize );
550 label->setFont( font );
552 KAction* act =
new KAction(
this );
553 act->setDefaultWidget( label );
556 #include "kspopupmenu.moc"
KStarsData is the backbone of KStars.
QString translatedName() const
QString sptype(void) const
Returns entire spectral type string.
static INDIListener * Instance()
virtual INDI::BaseDevice * getBaseDevice()=0
virtual QString longname(void) const
void setAz(dms az)
Sets Az, the Azimuth.
static KStarsData * Instance()
const double & Degrees() const
QTime riseSetTime(const KStarsDateTime &dt, const GeoLocation *geo, bool rst, bool exact=true)
Determine the time at which the point will rise or set.
virtual const char * getDeviceName()=0
static KStars * Instance()
QTime transitTime(const KStarsDateTime &dt, const GeoLocation *geo)
The same iteration technique described in riseSetTime() is used here.
This is the main window for KStars.
QImage image(int index)
Get image.
The sky coordinates of a point in the sky.
ISD::GDInterface * getDevice(const QString &name)
void slotDeleteFlag(int flagIdx)
Delete selected flag.
ObservingList * observingList() const
QStringList & ImageList()
QString label(int index)
Get label.
Represents the supernova object.
i18nc("string from libindi, used in the config dialog","100x")
bool isStandardProperty(const QString &name)
bool isSolarSystem() const
QString translatedLongName() const
SkyMapComposite * skyComposite()
QString phaseName() const
bool isObjectLabeled(SkyObject *o)
Provides all necessary information about a deep-sky object: data inherited from SkyObject (coordinate...
QStringList & InfoTitle()
virtual SkyObject * clone() const
Create copy of object.
A subclass of SkyObject that provides information needed for the Moon.
provides a SkyObject with an attachable Trail
void slotEditFlag(int flagIdx)
Open Flag Manager window with selected flag focused and ready to edit.
KStarsData * data() const
QString translatedName2() const
Represents an artificial satellites.
void setAlt(dms alt)
Sets Alt, the Altitude.
const KStarsDateTime & ut() const
virtual QList< INDI::Property * > getProperties()=0
virtual QString name(void) const
virtual QString name(void) const
If star is unnamed return "star" otherwise return the name.
This is a subclass of SkyObject.
static QString typeName(const int t)
Provides all necessary information about an object in the sky: its coordinates, name(s), type, magnitude, and QStringLists of URLs for images and webpages regarding the object.
QStringList & ImageTitle()
virtual QString name(void) const
QList< int > getFlagsNearPix(SkyPoint *point, int pixelRadius)
Get list of flag indexes near specified SkyPoint with radius specified in pixels. ...