Commit a8767daa authored by Robert Lancaster's avatar Robert Lancaster Committed by Jasem Mutlaq

Further improvements to WIT tool

parent 925f6ebc
...@@ -575,7 +575,7 @@ void KStars::slotShowWIView(int status) ...@@ -575,7 +575,7 @@ void KStars::slotShowWIView(int status)
m_wiDock->setAllowedAreas(Qt::RightDockWidgetArea); m_wiDock->setAllowedAreas(Qt::RightDockWidgetArea);
QWidget * container = QWidget::createWindowContainer(m_WIView->getWIBaseView()); QWidget * container = QWidget::createWindowContainer(m_WIView->getWIBaseView());
m_wiDock->setWidget(container); m_wiDock->setWidget(container);
m_wiDock->setMinimumWidth(container->width()); m_wiDock->setMinimumWidth(300);
addDockWidget(Qt::RightDockWidgetArea, m_wiDock); addDockWidget(Qt::RightDockWidgetArea, m_wiDock);
m_wiDock->setVisible(true); m_wiDock->setVisible(true);
} }
......
...@@ -369,8 +369,28 @@ Rectangle { ...@@ -369,8 +369,28 @@ Rectangle {
id: soListItem id: soListItem
x: 8 x: 8
width: parent.width width: parent.width
height: (dispSummary.height >= 130) ? dispSummary.height + 20 : 160 height: (dispSummary.height >= 130) ? dispSummary.height + 20 : 160
Rectangle{
id: summaryBackground
color: "transparent"
width: parent.width
height: parent.height
Text {
id: dispSummary
objectName: dispObjSummary
text: dispObjSummary
x: image.width + 5
width: parent.width - image.width - 30
color: "#187988"
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
font{
family: "Cantarell"
pixelSize: 13
}
}
}
Image { Image {
id: image id: image
width: 150 width: 150
...@@ -378,7 +398,6 @@ Rectangle { ...@@ -378,7 +398,6 @@ Rectangle {
source: imageSource source: imageSource
} }
Text { Text {
id: dispText id: dispText
objectName: dispName objectName: dispName
...@@ -386,11 +405,20 @@ Rectangle { ...@@ -386,11 +405,20 @@ Rectangle {
color: "white" color: "white"
font.bold: true font.bold: true
MouseArea { }
MouseArea {
anchors.fill: parent anchors.fill: parent
hoverEnabled: true hoverEnabled: true
onEntered: dispText.color = "yellow" onEntered:{
onExited: dispText.color = "white" dispText.color = "yellow"
dispSummary.color = "yellow"
summaryBackground.color = "#030723"
}
onExited: {
dispText.color = "white"
dispSummary.color = "#187988"
summaryBackground.color ="transparent"
}
onClicked: { onClicked: {
soListView.currentIndex = index soListView.currentIndex = index
soListView.soListItemClicked( soListView.soListItemClicked(
...@@ -398,22 +426,7 @@ Rectangle { ...@@ -398,22 +426,7 @@ Rectangle {
soListView.currentIndex) soListView.currentIndex)
skyObjView.flipped = true skyObjView.flipped = true
} }
} }
}
Text {
id: dispSummary
objectName: dispObjSummary
text: dispObjSummary
x: image.width + 5
width: parent.width - image.width - 30
color: "#187988"
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
font{
family: "Cantarell"
pixelSize: 13
}
}
} }
model: soListModel model: soListModel
...@@ -448,12 +461,27 @@ Rectangle { ...@@ -448,12 +461,27 @@ Rectangle {
width: 4 width: 4
color: "#000000" color: "#000000"
} }
Image {
id: detailImg
height: 300
width:parent.width - 200
anchors{
right: parent.right
}
objectName: "detailImage"
property string refreshableSource
fillMode: Image.PreserveAspectFit
source: refreshableSource
}
Text { Text {
id: soname id: soname
objectName: "sonameObj" objectName: "sonameObj"
y: 8 y: 8
width: 273 width: parent.width
height: 22 height: 22
color: "#ffffff" color: "#ffffff"
text: xi18n("text") text: xi18n("text")
...@@ -467,19 +495,7 @@ Rectangle { ...@@ -467,19 +495,7 @@ Rectangle {
} }
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
} }
Image {
id: detailImg
anchors{
right: parent.right
}
objectName: "detailImage"
property string refreshableSource
height: 300
fillMode: Image.PreserveAspectFit
source: refreshableSource
}
Text { Text {
id: posText id: posText
objectName: "posTextObj" objectName: "posTextObj"
...@@ -488,7 +504,7 @@ Rectangle { ...@@ -488,7 +504,7 @@ Rectangle {
right: parent.right right: parent.right
rightMargin: 10 rightMargin: 10
} }
width: 320 width: parent.width
height: 16 height: 16
color: "#f7f7ac" color: "#f7f7ac"
text: xi18n("text") text: xi18n("text")
...@@ -504,7 +520,7 @@ Rectangle { ...@@ -504,7 +520,7 @@ Rectangle {
Rectangle { Rectangle {
id: descTextBox id: descTextBox
y: 347 y: 347
height: 175 height: 200
color: "#010a14" color: "#010a14"
radius: 10 radius: 10
border.width: 0 border.width: 0
...@@ -723,28 +739,17 @@ Rectangle { ...@@ -723,28 +739,17 @@ Rectangle {
Column { Column {
id: detailItemsCol id: detailItemsCol
x: 0 x: 0
y: 75 y: 100
width: 200 width: parent.width
height: 93 height: 93
spacing: 14 spacing: 14
DetailsItem {
id: sbText
objectName: "sbTextObj"
text: xi18n("Surface Brightness:")
}
DetailsItem { DetailsItem {
id: magText id: detailsText
objectName: "magTextObj" objectName: "detailsTextObj"
text: xi18n("Magnitude: ")
} }
DetailsItem {
id: sizeText
objectName: "sizeTextObj"
text: xi18n("Size: ")
}
} }
Column { Column {
......
...@@ -75,7 +75,7 @@ QVariant SkyObjItem::data(int role) ...@@ -75,7 +75,7 @@ QVariant SkyObjItem::data(int role)
case DispImageRole: case DispImageRole:
return getImageURL(); return getImageURL();
case DispSummaryRole: case DispSummaryRole:
return getDesc(); return getSummary();
case CategoryRole: case CategoryRole:
return getType(); return getType();
case CategoryNameRole: case CategoryNameRole:
...@@ -117,16 +117,21 @@ QString SkyObjItem::getImageURL() const ...@@ -117,16 +117,21 @@ QString SkyObjItem::getImageURL() const
return ""; return "";
} }
QString fname = KSPaths::locate(QStandardPaths::GenericDataLocation, "thumb-" + m_So->name().toLower().remove( ' ' ) + ".png" ) ; QString fname = KSPaths::locate(QStandardPaths::GenericDataLocation, "image_" + m_So->name().toLower().remove( ' ' ) + ".png" ) ;
if(fname=="")
fname = KSPaths::locate(QStandardPaths::GenericDataLocation, "thumb-" + m_So->name().toLower().remove( ' ' ) + ".png" ) ;
if(fname=="" && m_Type==Planet){ if(fname=="" && m_Type==Planet){
fname=KSPaths::locate(QStandardPaths::GenericDataLocation, "xplanet/" + getLongName() + ".png" ); fname=KSPaths::locate(QStandardPaths::GenericDataLocation, "xplanet/" + m_So->name() + ".png" );
} }
return fname; return fname;
} }
QString SkyObjItem::getSummary() const
{
return m_So->typeName()+"\n"+getRADE()+"\n"+getAltAz()+"\n";
}
QString SkyObjItem::getDesc() const QString SkyObjItem::getDesc() const
{ {
...@@ -160,7 +165,7 @@ QString SkyObjItem::getDesc() const ...@@ -160,7 +165,7 @@ QString SkyObjItem::getDesc() const
if(m_Type == Star) if(m_Type == Star)
return xi18n("Bright Star"); return xi18n("Bright Star");
return getTypeName(); return m_So->typeName();
} }
...@@ -197,7 +202,7 @@ QString SkyObjItem::getSurfaceBrightness() const ...@@ -197,7 +202,7 @@ QString SkyObjItem::getSurfaceBrightness() const
{ {
case Galaxy: case Galaxy:
case Nebula: case Nebula:
return QLocale().toString(SB, 2) + " mag/arcmin^2"; return QLocale().toString(SB,'f', 2) + "\n (mag/arcmin^2)";
default: default:
return QString(" --"); // Not applicable for other sky-objects return QString(" --"); // Not applicable for other sky-objects
} }
...@@ -210,9 +215,9 @@ QString SkyObjItem::getSize() const ...@@ -210,9 +215,9 @@ QString SkyObjItem::getSize() const
case Galaxy: case Galaxy:
case Cluster: case Cluster:
case Nebula: case Nebula:
return QLocale().toString(((DeepSkyObject *)m_So)->a(), 2) + " arcminutes"; return QLocale().toString(((DeepSkyObject *)m_So)->a(),'f', 2) + "\"";
case Planet: case Planet:
return QLocale().toString(((KSPlanetBase *)m_So)->angSize(), 2) + " arcseconds"; return QLocale().toString(((KSPlanetBase *)m_So)->angSize(),'f', 2) + "\"";
default: default:
return QString(" --"); return QString(" --");
} }
......
...@@ -75,7 +75,10 @@ class SkyObjItem ...@@ -75,7 +75,10 @@ class SkyObjItem
*/ */
inline QString getLongName() const inline QString getLongName() const
{ {
return m_LongName; if(m_LongName==m_Name)
return m_LongName;
else
return m_LongName + "\n (" + m_Name + ")";
} }
/** /**
...@@ -105,6 +108,24 @@ class SkyObjItem ...@@ -105,6 +108,24 @@ class SkyObjItem
return m_Position; return m_Position;
} }
/**
* \brief Get current RA/DE of sky-object associated with the SkyObjItem.
* \return Current RA/DE of sky-object associated with the SkyObjItem.
*/
inline QString getRADE() const
{
return "RA: "+ m_So->ra().toHMSString() + "\nDE: " + m_So->ra().toDMSString();
}
/**
* \brief Get current Altitute and Azimuth of sky-object associated with the SkyObjItem.
* \return Current Altitute and Azimuth of sky-object associated with the SkyObjItem.
*/
inline QString getAltAz() const
{
return "Alt: "+ QString::number(m_So->alt().Degrees(),'f', 2) + ", Az: " + QString::number(m_So->az().Degrees(),'f', 2);
}
/** /**
* \brief Get sky-object associated with the SkyObjItem. * \brief Get sky-object associated with the SkyObjItem.
* \return Pointer to SkyObject associated with the SkyObjItem. * \return Pointer to SkyObject associated with the SkyObjItem.
...@@ -117,6 +138,13 @@ class SkyObjItem ...@@ -117,6 +138,13 @@ class SkyObjItem
QString getImageURL() const; QString getImageURL() const;
/**
* \brief Get Summary Description for the SkyObjItem.
* \return Summary Description for the SkyObjItem as a QString.
*/
QString getSummary() const;
/** /**
* \brief Get description for the SkyObjItem. * \brief Get description for the SkyObjItem.
* \return Description for the SkyObjItem as a QString. * \return Description for the SkyObjItem as a QString.
......
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
#include "dialogs/detaildialog.h" #include "dialogs/detaildialog.h"
#include <klocalizedcontext.h> #include <klocalizedcontext.h>
#include "kspaths.h" #include "kspaths.h"
#include "starobject.h"
#ifdef HAVE_INDI #ifdef HAVE_INDI
#include <basedevice.h> #include <basedevice.h>
...@@ -261,26 +263,77 @@ void WIView::loadDetailsView(SkyObjItem * soitem, int index) ...@@ -261,26 +263,77 @@ void WIView::loadDetailsView(SkyObjItem * soitem, int index)
QObject * detailImage = m_DetailsViewObj->findChild<QObject *>("detailImage"); QObject * detailImage = m_DetailsViewObj->findChild<QObject *>("detailImage");
QObject * descTextObj = m_DetailsViewObj->findChild<QObject *>("descTextObj"); QObject * descTextObj = m_DetailsViewObj->findChild<QObject *>("descTextObj");
QObject * descSrcTextObj = m_DetailsViewObj->findChild<QObject *>("descSrcTextObj"); QObject * descSrcTextObj = m_DetailsViewObj->findChild<QObject *>("descSrcTextObj");
QObject * magTextObj = m_DetailsViewObj->findChild<QObject *>("magTextObj"); QObject * detailsTextObj = m_DetailsViewObj->findChild<QObject *>("detailsTextObj");
QObject * sbTextObj = m_DetailsViewObj->findChild<QObject *>("sbTextObj");
QObject * sizeTextObj = m_DetailsViewObj->findChild<QObject *>("sizeTextObj");
sonameObj->setProperty("text", soitem->getLongName()); sonameObj->setProperty("text", soitem->getLongName());
posTextObj->setProperty("text", soitem->getPosition()); posTextObj->setProperty("text", soitem->getPosition());
detailImage->setProperty("refreshableSource", soitem->getImageURL()); detailImage->setProperty("refreshableSource", soitem->getImageURL());
descTextObj->setProperty("text", soitem->getDesc()); descTextObj->setProperty("text", soitem->getDesc());
if(soitem->getType() != SkyObjItem::Planet)
tryToLoadFromWikipedia(descTextObj, descSrcTextObj, soitem);
descSrcTextObj->setProperty("text", soitem->getDescSource()); descSrcTextObj->setProperty("text", soitem->getDescSource());
QString summary=soitem->getSummary();
QString magText; QString magText;
if (soitem->getType() == SkyObjItem::Constellation) if (soitem->getType() == SkyObjItem::Constellation)
magText = xi18n("Magnitude: --"); magText = xi18n("Magnitude: --");
else else
magText = xi18n("Magnitude: %1 mag", QLocale().toString(soitem->getMagnitude(), 2)); magText = xi18n("Magnitude: %1", QLocale().toString(soitem->getMagnitude(),'f', 2));
magTextObj->setProperty("text", magText);
QString sbText = xi18n("Surface Brightness: %1", soitem->getSurfaceBrightness()); QString sbText = xi18n("Surface Brightness: %1", soitem->getSurfaceBrightness());
sbTextObj->setProperty("text", sbText);
QString sizeText = xi18n("Size: %1", soitem->getSize()); QString sizeText = xi18n("Size: %1", soitem->getSize());
sizeTextObj->setProperty("text", sizeText);
QString details = summary + "\n" + sbText + "\n" + magText + "\n" + sizeText;
detailsTextObj->setProperty("text", details);
}
void WIView::tryToLoadFromWikipedia(QObject * descTextObj, QObject * descSrcTextObj, SkyObjItem * soitem)
{
QString name;
if(soitem->getName().startsWith("M "))
name = soitem->getName().replace("M ","messier_").toLower().remove( ' ' );
else if(soitem->getType() == SkyObjItem::Constellation)
name = soitem->getName().toLower().remove( ' ' ) + "_constellation";
else if(soitem->getType() == SkyObjItem::Star){
StarObject *star=dynamic_cast<StarObject*>(soitem->getSkyObject());
if(star)
name = star->gname().toLower().remove( ' ' ); //the greek name seems to give the most consistent search results.
else
name = soitem->getName().toLower().remove( ' ' );
}else
name = soitem->getName().toLower().remove( ' ' );
QUrl url("https://en.wikipedia.org/w/api.php?action=opensearch&search=" + name + "&format=xml");
QNetworkAccessManager * manager = new QNetworkAccessManager();
QNetworkReply * response = manager->get(QNetworkRequest(url));
connect(manager, &QNetworkAccessManager::finished, this, [descTextObj, descSrcTextObj, manager, response]{
response->deleteLater();
manager->deleteLater();
if (response->error() != QNetworkReply::NoError) return;
QString contentType =
response->header(QNetworkRequest::ContentTypeHeader).toString();
if (!contentType.contains("charset=utf-8")) {
qWarning() << "Content charsets other than utf-8 are not implemented yet.";
return;
}
QString result = QString::fromUtf8(response->readAll());
int leftPos=result.indexOf("<Description")+34;
if(leftPos<34)
return;
int rightPos=result.indexOf("</Description>")-leftPos;
int leftURL=result.indexOf("<Url xml:space=\"preserve\">")+26;
int rightURL=result.indexOf("</Url>")-leftURL;
QString html="<HTML>" + result.mid(leftPos,rightPos) + "</HTML>";
QString srchtml="<HTML>Source: Wikipedia (<a href='" + result.mid(leftURL,rightURL) + "'>" + result.mid(leftURL,rightURL) + "</a>)</HTML>";
descTextObj->setProperty("text", html);
descSrcTextObj->setProperty("text", srchtml);
});
} }
...@@ -120,6 +120,9 @@ class WIView : public QWidget ...@@ -120,6 +120,9 @@ class WIView : public QWidget
*/ */
void onReloadIconClicked(); void onReloadIconClicked();
void tryToLoadFromWikipedia(QObject * descTextObj, QObject *descSrcTextObj, SkyObjItem * soitem);
private: private:
QQuickItem * m_BaseObj, *m_ViewsRowObj, *m_SoListObj, *m_DetailsViewObj, QQuickItem * m_BaseObj, *m_ViewsRowObj, *m_SoListObj, *m_DetailsViewObj,
*m_NextObj, *m_PrevObj, *m_SlewButtonObj, *m_SlewTelescopeButtonObj, *m_DetailsButtonObj; *m_NextObj, *m_PrevObj, *m_SlewButtonObj, *m_SlewTelescopeButtonObj, *m_DetailsButtonObj;
......
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