Commit 4455e7ec authored by Robert Lancaster's avatar Robert Lancaster Committed by Jasem Mutlaq

I was working on the Whats Interesting tool because I think it has a lot of...

I was working on the Whats Interesting tool because I think it has a lot of potential.  I added photos and descriptions to the list.  I added photos to the detail view.  I also changed some of the layouts.  And finally I added a telescope slew button.
parent 215a4faf
......@@ -83,6 +83,8 @@ KStars::KStars( bool doSplash, bool clockrun, const QString &startdate )
klauncher->start("kdeinit5");
#endif
// Initialize logging settings
if (Options::disableLogging())
KSUtils::Logging::Disable();
......
......@@ -39,7 +39,7 @@ Rectangle {
id: base
y: 89
width: parent.width
height: 385
height: parent.height
anchors {
left: parent.left
leftMargin: 0
......@@ -320,12 +320,9 @@ Rectangle {
Flipable {
id: skyObjView
width: parent.width
height: parent.height
height: parent.height - 150
anchors.leftMargin: categoryView.width
//anchors.leftMargin: 370
anchors.left: categoryView.right
property bool flipped: false
front: Item {
......@@ -346,7 +343,7 @@ Rectangle {
x: parent.x + 15
y: 31
width: parent.width - 30
height: 351
height: parent.height -30
color: "transparent"
radius: 12
border {
......@@ -371,14 +368,23 @@ Rectangle {
delegate: Item {
id: soListItem
x: 8
height: 40
width: parent.width
height: (dispSummary.height >= 130) ? dispSummary.height + 20 : 160
Image {
id: image
width: 150
fillMode: Image.PreserveAspectFit
source: imageSource
}
Text {
id: dispText
objectName: dispName
text: dispName
color: "white"
anchors.verticalCenter: parent.verticalCenter
font.bold: true
MouseArea {
anchors.fill: parent
......@@ -394,6 +400,20 @@ Rectangle {
}
}
}
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
......@@ -407,6 +427,7 @@ Rectangle {
height: parent.height
enabled: parent.flipped
Rectangle {
id: detailsViewBackground
anchors.fill: detailsView
......@@ -419,7 +440,7 @@ Rectangle {
id: detailsView
objectName: "detailsViewObj"
x: parent.x + 15
height: 415
height: parent.height
width: parent.width - 30
color: "transparent"
radius: 12
......@@ -446,11 +467,23 @@ Rectangle {
}
verticalAlignment: Text.AlignVCenter
}
Image {
id: detailImg
anchors{
right: parent.right
}
objectName: "detailImage"
property string refreshableSource
height: 300
fillMode: Image.PreserveAspectFit
source: refreshableSource
}
Text {
id: posText
objectName: "posTextObj"
y: 45
y: 300
anchors{
right: parent.right
rightMargin: 10
......@@ -470,7 +503,7 @@ Rectangle {
Rectangle {
id: descTextBox
y: 197
y: 347
height: 175
color: "#010a14"
radius: 10
......@@ -690,7 +723,7 @@ Rectangle {
Column {
id: detailItemsCol
x: 0
y: 78
y: 75
width: 200
height: 93
spacing: 14
......@@ -716,13 +749,12 @@ Rectangle {
Column {
id: detailsViewButtonsCol
y: 134
//width: 132
//height: 52
anchors{
right: parent.right
rightMargin: 10
y: 200
anchors {
left: parent.left
leftMargin: 10
}
spacing: 14
Text {
......@@ -776,6 +808,32 @@ Rectangle {
onClicked: slewButton.slewButtonClicked()
}
}
Text {
id: slewTelescopeButton
objectName: "slewTelescopeButtonObj"
verticalAlignment: Text.AlignVCenter
color: "white"
text: xi18n("Slew telescope to object")
font {
underline: true
family: "Cantarell"
pixelSize: 14
}
signal slewTelescopeButtonClicked
MouseArea {
id: slewTelescopeObjMouseArea
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
anchors.fill: parent
onEntered: slewTelescopeButton.color = "yellow"
onExited: slewTelescopeButton.color = "white"
onClicked: slewTelescopeButton.slewTelescopeButtonClicked()
}
}
}
} //end of detailsView
} //end of detailsViewContainer
......@@ -835,7 +893,7 @@ Rectangle {
Rectangle {
id: backButton
x: container.width + 10
y: 518
y: container.height - 50
width: leftArrow.width + goBackText.width + 18
height: 49
color: "#00000000"
......@@ -907,7 +965,7 @@ Rectangle {
id: settingsIcon
objectName: "settingsIconObj"
x: 9
y: 529
y: container.height - 50
width: 28
height: 28
anchors{
......@@ -945,7 +1003,7 @@ Rectangle {
id: reloadIcon
objectName: "reloadIconObj"
x: 50
y: 529
y: container.height - 50
width: 28
height: 28
anchors{
......
......@@ -21,6 +21,7 @@
#include "ksplanetbase.h"
#include "skyobjitem.h"
#include "ksutils.h"
#include "kspaths.h"
SkyObjItem::SkyObjItem(SkyObject * so) : m_Name(so->name()), m_LongName(so->longname()),m_TypeName(so->typeName()), m_So(so), skd(NULL)
{
......@@ -71,6 +72,10 @@ QVariant SkyObjItem::data(int role)
{
case DispNameRole:
return getLongName();
case DispImageRole:
return getImageURL();
case DispSummaryRole:
return getDesc();
case CategoryRole:
return getType();
case CategoryNameRole:
......@@ -105,6 +110,24 @@ void SkyObjItem::setPosition(SkyObject * so)
m_Position = xi18n("Now visible: About %1 degrees above the %2 horizon", rounded_altitude, KSUtils::toDirectionString( sp.az() ) );
}
QString SkyObjItem::getImageURL() const
{
if ( m_Type==Star )
{
return "";
}
QString fname = KSPaths::locate(QStandardPaths::GenericDataLocation, "thumb-" + m_So->name().toLower().remove( ' ' ) + ".png" ) ;
if(fname=="" && m_Type==Planet){
fname=KSPaths::locate(QStandardPaths::GenericDataLocation, "xplanet/" + getLongName() + ".png" );
}
return fname;
}
QString SkyObjItem::getDesc() const
{
if (m_Type == Planet)
......
......@@ -34,7 +34,7 @@ class SkyObjItem
* \enum SkyObjectRoles
* User-defined role for the SkyObjItem
*/
enum SkyObjectRoles { DispNameRole = Qt::UserRole + 1, CategoryRole, CategoryNameRole };
enum SkyObjectRoles { DispNameRole = Qt::UserRole + 1, DispImageRole, DispSummaryRole, CategoryRole, CategoryNameRole };
/**
* \enum Type
......@@ -114,6 +114,9 @@ class SkyObjItem
return m_So;
}
QString getImageURL() const;
/**
* \brief Get description for the SkyObjItem.
* \return Description for the SkyObjItem as a QString.
......
......@@ -29,6 +29,8 @@ QHash<int, QByteArray> SkyObjListModel::roleNames() const
{
QHash<int, QByteArray> roles;
roles[SkyObjItem::DispNameRole] = "dispName";
roles[SkyObjItem::DispImageRole] = "imageSource";
roles[SkyObjItem::DispSummaryRole] = "dispObjSummary";
roles[SkyObjItem::CategoryRole] = "type";
roles[SkyObjItem::CategoryNameRole] = "typeName";
return roles;
......
......@@ -26,6 +26,13 @@
#include <klocalizedcontext.h>
#include "kspaths.h"
#ifdef HAVE_INDI
#include <basedevice.h>
#include "indi/indilistener.h"
#include "indi/indistd.h"
#include "indi/driverinfo.h"
#endif
WIView::WIView(QWidget * parent, ObsConditions * obs) : QWidget(parent), m_Obs(obs), m_CurCategorySelected(-1)
{
......@@ -68,6 +75,9 @@ WIView::WIView(QWidget * parent, ObsConditions * obs) : QWidget(parent), m_Obs(o
m_SlewButtonObj = m_BaseObj->findChild<QQuickItem *>("slewButtonObj");
connect(m_SlewButtonObj, SIGNAL(slewButtonClicked()), this, SLOT(onSlewButtonClicked()));
m_SlewTelescopeButtonObj = m_BaseObj->findChild<QQuickItem *>("slewTelescopeButtonObj");
connect(m_SlewTelescopeButtonObj, SIGNAL(slewTelescopeButtonClicked()), this, SLOT(onSlewTelescopeButtonClicked()));
m_DetailsButtonObj = m_BaseObj->findChild<QQuickItem *>("detailsButtonObj");
connect(m_DetailsButtonObj, SIGNAL(detailsButtonClicked()), this, SLOT(onDetailsButtonClicked()));
......@@ -134,6 +144,58 @@ void WIView::onSlewButtonClicked()
}
}
void WIView::onSlewTelescopeButtonClicked()
{
if(KMessageBox::Continue==KMessageBox::warningContinueCancel(NULL, "Are you sure you want your telescope to slew to this object?",
i18n("Continue Slew"), KStandardGuiItem::cont(), KStandardGuiItem::cancel(), "continue_wi_slew_warning"))
{
#ifdef HAVE_INDI
if (INDIListener::Instance()->size() == 0)
{
KMessageBox::sorry(0, i18n("KStars did not find any active telescopes."));
return;
}
foreach(ISD::GDInterface * gd, INDIListener::Instance()->getDevices())
{
INDI::BaseDevice * bd = gd->getBaseDevice();
if (gd->getType() != KSTARS_TELESCOPE)
continue;
if (bd == NULL)
continue;
if (bd->isConnected() == false)
{
KMessageBox::error(0, i18n("Telescope %1 is offline. Please connect and retry again.", gd->getDeviceName()));
return;
}
ISD::GDSetCommand SlewCMD(INDI_SWITCH, "ON_COORD_SET", "TRACK", ISS_ON, this);
gd->setProperty(&SlewCMD);
gd->runCommand(INDI_SEND_COORDS, m_CurSoItem->getSkyObject());
///Slew map to selected sky-object
onSlewButtonClicked();
return;
}
KMessageBox::sorry(0, i18n("KStars did not find any active telescopes."));
#endif
}
}
void WIView::onDetailsButtonClicked()
{
///Code taken from WUTDialog::slotDetails()
......@@ -196,6 +258,7 @@ void WIView::loadDetailsView(SkyObjItem * soitem, int index)
QObject * sonameObj = m_DetailsViewObj->findChild<QObject *>("sonameObj");
QObject * posTextObj = m_DetailsViewObj->findChild<QObject *>("posTextObj");
QObject * detailImage = m_DetailsViewObj->findChild<QObject *>("detailImage");
QObject * descTextObj = m_DetailsViewObj->findChild<QObject *>("descTextObj");
QObject * descSrcTextObj = m_DetailsViewObj->findChild<QObject *>("descSrcTextObj");
QObject * magTextObj = m_DetailsViewObj->findChild<QObject *>("magTextObj");
......@@ -204,6 +267,7 @@ void WIView::loadDetailsView(SkyObjItem * soitem, int index)
sonameObj->setProperty("text", soitem->getLongName());
posTextObj->setProperty("text", soitem->getPosition());
detailImage->setProperty("refreshableSource", soitem->getImageURL());
descTextObj->setProperty("text", soitem->getDesc());
descSrcTextObj->setProperty("text", soitem->getDescSource());
......
......@@ -100,6 +100,11 @@ class WIView : public QWidget
*/
void onSlewButtonClicked();
/**
* \brief public slot - Slew map to current sky-object in the details view.
*/
void onSlewTelescopeButtonClicked();
/**
* \brief public slot - Open Details Dialog to show more details for current sky-object.
*/
......@@ -117,7 +122,7 @@ class WIView : public QWidget
private:
QQuickItem * m_BaseObj, *m_ViewsRowObj, *m_SoListObj, *m_DetailsViewObj,
*m_NextObj, *m_PrevObj, *m_SlewButtonObj, *m_DetailsButtonObj;
*m_NextObj, *m_PrevObj, *m_SlewButtonObj, *m_SlewTelescopeButtonObj, *m_DetailsButtonObj;
QQmlContext * m_Ctxt;
QQuickView * m_BaseView;
ObsConditions * m_Obs;
......
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