Commit 6da8bb68 authored by Jasem Mutlaq's avatar Jasem Mutlaq
Browse files

Add Copy Coordinates action to the popup menu

parent 1d45a9c0
......@@ -358,6 +358,9 @@ void KSPopupMenu::initPopupMenu(SkyObject *obj, const QString &name, const QStri
//Insert item for Showing details dialog
if (showDetails)
addAction(i18nc("Show Detailed Information Dialog", "Details"), map, SLOT(slotDetail()));
addAction(i18n("Copy Coordinates"), map, &SkyMap::slotCopyCoordinates);
//Insert "Add/Remove Label" item
if (showLabel)
{
......@@ -405,6 +408,8 @@ void KSPopupMenu::initPopupMenu(SkyObject *obj, const QString &name, const QStri
addINDI();
addAction(i18n("View in What's Interesting"), this, SLOT(slotViewInWI()));
}
void KSPopupMenu::initFlagActions(SkyObject *obj)
......
......@@ -60,6 +60,7 @@
#include <QBitmap>
#include <QToolTip>
#include <QClipboard>
#include <QInputDialog>
#include <QDesktopServices>
......@@ -453,6 +454,40 @@ void SkyMap::slotDSS()
}
}
void SkyMap::slotCopyCoordinates()
{
dms J2000RA(0.0), J2000DE(0.0), JNowRA(0.0), JNowDE(0.0), Az, Alt;
if (clickedObject())
{
J2000RA = clickedObject()->ra0();
J2000DE = clickedObject()->dec0();
JNowRA = clickedObject()->ra();
JNowDE = clickedObject()->dec();
Az = clickedObject()->az();
Alt = clickedObject()->alt();
}
else
{
SkyPoint deprecessedPoint = clickedPoint()->deprecess(data->updateNum());
deprecessedPoint.EquatorialToHorizontal(data->lst(), data->geo()->lat());
J2000RA = deprecessedPoint.ra0();
J2000DE = deprecessedPoint.dec0();
JNowRA = deprecessedPoint.ra();
JNowDE = deprecessedPoint.dec();
Az = deprecessedPoint.az();
Alt = deprecessedPoint.alt();
}
QApplication::clipboard()->setText(i18nc("Equatorial & Horizontal Coordinates", "JNow:\t%1\t%2\nJ2000:\t%3\t%4\nAzAlt:\t%5\t%6",
JNowRA.toHMSString(),
JNowDE.toHMSString(),
J2000RA.toHMSString(),
J2000DE.toDMSString(),
Az.toDMSString(),
Alt.toDMSString()));
}
void SkyMap::slotSDSS()
{
// TODO: Remove code duplication -- we have the same stuff
......
......@@ -365,6 +365,11 @@ class SkyMap : public QGraphicsView
*/
void slotSDSS();
/**
* @brief slotCopyCoordinates Copies J2000 and JNow equatorial coordinates to the clipboard in addition to horizontal coords.
*/
void slotCopyCoordinates();
/** @short Popup menu function: Show webpage about ClickedObject
* (only available for some objects).
*/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment