Commit 83430ff8 authored by Robert Lancaster's avatar Robert Lancaster Committed by Jasem Mutlaq

Here are some more improvements to the Whats Interesting panel.

This will download wikipedia info text box in addition to the description.
It can dynamically display the content in a tabbed pane or right next to each other depending on the width of the page. Both the descriptions and the info text are now saved after loaded the first time for easier loading later.
I also captured the wikipedia image from the info text box and added that to the list of images available in the thumbnail picker.  I also improved some of the layouts in whats interesting
parent 9c6c0c85
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
***************************************************************************/ ***************************************************************************/
import QtQuick 2.5 import QtQuick 2.5
import QtQuick.Layouts 1.1 import QtQuick.Layouts 1.1
import QtQuick.Controls 1.2 import QtQuick.Controls 1.4
Rectangle { Rectangle {
id: container id: container
...@@ -380,6 +380,7 @@ Rectangle { ...@@ -380,6 +380,7 @@ Rectangle {
id: dispSummary id: dispSummary
objectName: dispObjSummary objectName: dispObjSummary
text: dispObjSummary text: dispObjSummary
textFormat: Text.RichText
x: image.width + 5 x: image.width + 5
width: parent.width - image.width - 30 width: parent.width - image.width - 30
color: "#187988" color: "#187988"
...@@ -462,20 +463,6 @@ Rectangle { ...@@ -462,20 +463,6 @@ Rectangle {
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
...@@ -499,7 +486,7 @@ Rectangle { ...@@ -499,7 +486,7 @@ Rectangle {
Text { Text {
id: posText id: posText
objectName: "posTextObj" objectName: "posTextObj"
y: 300 y: parent.height - 50
anchors{ anchors{
right: parent.right right: parent.right
rightMargin: 10 rightMargin: 10
...@@ -516,83 +503,197 @@ Rectangle { ...@@ -516,83 +503,197 @@ Rectangle {
} }
} }
TabView {
Rectangle { id: tabbedView
id: descTextBox y: 170
y: 347 width: parent.width
height: 200 height: parent.height - 170 - 50
color: "#010a14" Tab {
radius: 10 title: "Object Information"
border.width: 0
anchors{ Rectangle {
right: parent.right id: descTextBox
rightMargin: 4 height: parent.height
left: parent.left width: parent.width
leftMargin: 4 color: "#010a14"
} radius: 10
border.color: "#585454" border.width: 0
anchors{
Flickable { top: parent.top
id: flickableDescText left: parent.left
clip: true leftMargin: 4
flickableDirection: Flickable.VerticalFlick right: parent.right
width: parent.width rightMargin: 4
height: parent.height }
anchors{ border.color: "#585454"
top: parent.top
topMargin: 3 Flickable {
bottom: parent.bottom id: flickableDescText
bottomMargin: 4 clip: true
} flickableDirection: Flickable.VerticalFlick
width: parent.width
contentWidth: parent.width height: parent.height - 10
contentHeight: col.height + 4 anchors{
top: parent.top
Item { topMargin: 10
id: descTextItem bottom: parent.bottom
anchors{ bottomMargin: 4
top: parent.top left: parent.left
topMargin: 3 right: parent.right
left: parent.left }
leftMargin: 6 contentWidth: parent.width
right: parent.right contentHeight: col.height + 4
} Item {
Column { id: descTextItem
id: col anchors.fill: parent
width: parent.width Column {
Text { id: col
id: descText width: parent.width
objectName: "descTextObj" Image {
color: "#187988" id: detailImg
text: xi18n("text") width:parent.width
clip: true anchors{
wrapMode: Text.WrapAtWordBoundaryOrAnywhere right: parent.right
width: parent.width }
font{ objectName: "detailImage"
family: "Cantarell" property string refreshableSource
pixelSize: 13 fillMode: Image.PreserveAspectFit
} source: refreshableSource
} }
Text { Text {
id: descSrcText id: descText
objectName: "descSrcTextObj" objectName: "descTextObj"
color: "#18885f" color: "#187988"
text: xi18n("Source: ") text: xi18n("text")
clip: true clip: true
horizontalAlignment: Text.AlignRight wrapMode: Text.WrapAtWordBoundaryOrAnywhere
wrapMode: Text.WrapAtWordBoundaryOrAnywhere width: parent.width
width: parent.width font{
onLinkActivated: Qt.openUrlExternally(link) family: "Cantarell"
font{ pixelSize: 13
family: "Cantarell" }
pixelSize: 13 }
italic: true Text {
} id: descSrcText
} objectName: "descSrcTextObj"
} color: "#18885f"
} text: xi18n("Source: ")
} clip: true
} horizontalAlignment: Text.AlignRight
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
width: parent.width
onLinkActivated: Qt.openUrlExternally(link)
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.NoButton // we don't want to eat clicks on the Text
cursorShape: parent.hoveredLink ? Qt.PointingHandCursor : Qt.ArrowCursor
}
font{
family: "Cantarell"
pixelSize: 13
italic: true
} //font
} //text
} //column
} //item
} //flickable
} //rectangle
} //tab
Tab {
id: infoBoxTab
title: "Wikipedia Infotext"
active: true
Rectangle {
id: descTextBox2
width: parent.width
height: (detailsViewContainer.width >= 600) ? parent.height - 10 - 50 : parent.height
color: "#010a14"
radius: 10
border.width: 0
states: [
State {
name: "outOfTab"
ParentChange { target: descTextBox2; parent: detailsView; x: detailsView.width/2; y: 10 }
PropertyChanges{target:tabbedView; currentIndex: 0}
PropertyChanges{target:tabbedView; tabsVisible: false}
PropertyChanges{target:tabbedView; width: detailsView.width / 2}
PropertyChanges{target:descTextBox2; width: detailsView.width / 2}
},
State {
name: "inTab"
ParentChange { target: descTextBox2; parent: infoBoxTab; x: 0; y: 0 }
}
]
onWidthChanged: (detailsViewContainer.width >= 600) ? descTextBox2.state = "outOfTab" : descTextBox2.state = "inTab"
anchors{
right: parent.right
rightMargin: 4
left: (detailsViewContainer.width >= 600) ? parent.horizontalCenter : parent.left
leftMargin: 4
}
border.color: "#585454"
Flickable {
id: flickableInfoText
clip: true
flickableDirection: Flickable.VerticalFlick
width: parent.width
height: parent.height - 10
anchors{
top: parent.top
topMargin: 10
bottom: parent.bottom
bottomMargin: 4
left: parent.left
right: parent.right
}
contentWidth: parent.width
contentHeight: col2.height + 4
Item {
id: descInfoTextItem
anchors{
top: parent.top
topMargin: 0
left: parent.left
leftMargin: 4
right: parent.right
rightMargin: 4
}
Column {
id: col2
width: parent.width
Text {
id: infoText
objectName: "infoBoxText"
textFormat: Text.RichText
color: "white"
onLinkActivated: Qt.openUrlExternally(link)
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.NoButton // we don't want to eat clicks on the Text
cursorShape: parent.hoveredLink ? Qt.PointingHandCursor : Qt.ArrowCursor
}
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
text: xi18n("\ntrying to Load from Wikipedia. . .")
clip: true
width: parent.width
font{
family: "Cantarell"
pixelSize: 13
} //font
} //text
} //column
} //item
} //flickable
} //rectangle
} //tab
} //tabview
Item { Item {
id: nextObjRect id: nextObjRect
...@@ -603,7 +704,7 @@ Rectangle { ...@@ -603,7 +704,7 @@ Rectangle {
right: parent.right right: parent.right
rightMargin: 10 rightMargin: 10
bottom: parent.bottom bottom: parent.bottom
bottomMargin: 10 bottomMargin: 0
} }
signal nextObjClicked signal nextObjClicked
...@@ -677,7 +778,7 @@ Rectangle { ...@@ -677,7 +778,7 @@ Rectangle {
left: parent.left left: parent.left
leftMargin: 10 leftMargin: 10
bottom: parent.bottom bottom: parent.bottom
bottomMargin: 10 bottomMargin: 0
} }
signal prevObjClicked signal prevObjClicked
...@@ -738,14 +839,15 @@ Rectangle { ...@@ -738,14 +839,15 @@ Rectangle {
Column { Column {
id: detailItemsCol id: detailItemsCol
x: 0 x: 150
y: 100 y: 80
width: parent.width width: parent.width
height: 93 height: 93
spacing: 14 spacing: 14
DetailsItem { DetailsItem {
id: detailsText id: detailsText
textFormat: Text.RichText
objectName: "detailsTextObj" objectName: "detailsTextObj"
} }
...@@ -754,7 +856,7 @@ Rectangle { ...@@ -754,7 +856,7 @@ Rectangle {
Column { Column {
id: detailsViewButtonsCol id: detailsViewButtonsCol
y: 200 y: 50
anchors { anchors {
left: parent.left left: parent.left
leftMargin: 10 leftMargin: 10
...@@ -768,7 +870,7 @@ Rectangle { ...@@ -768,7 +870,7 @@ Rectangle {
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
color: "white" color: "white"
text: xi18n("More object details") text: xi18n("More Details")
font { font {
underline: true underline: true
family: "Cantarell" family: "Cantarell"
...@@ -794,7 +896,7 @@ Rectangle { ...@@ -794,7 +896,7 @@ Rectangle {
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
color: "white" color: "white"
text: xi18n("Slew map to object") text: xi18n("Center in Map")
font { font {
underline: true underline: true
family: "Cantarell" family: "Cantarell"
...@@ -820,7 +922,7 @@ Rectangle { ...@@ -820,7 +922,7 @@ Rectangle {
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
color: "white" color: "white"
text: xi18n("Slew telescope to object") text: xi18n("Slew Telescope")
font { font {
underline: true underline: true
family: "Cantarell" family: "Cantarell"
......
...@@ -73,9 +73,9 @@ QVariant SkyObjItem::data(int role) ...@@ -73,9 +73,9 @@ QVariant SkyObjItem::data(int role)
case DispNameRole: case DispNameRole:
return getLongName(); return getLongName();
case DispImageRole: case DispImageRole:
return getImageURL(); return getImageURL(true);
case DispSummaryRole: case DispSummaryRole:
return getSummary(); return getSummary(true);
case CategoryRole: case CategoryRole:
return getType(); return getType();
case CategoryNameRole: case CategoryNameRole:
...@@ -110,14 +110,23 @@ void SkyObjItem::setPosition(SkyObject * so) ...@@ -110,14 +110,23 @@ void SkyObjItem::setPosition(SkyObject * so)
m_Position = xi18n("Now visible: About %1 degrees above the %2 horizon", rounded_altitude, KSUtils::toDirectionString( sp.az() ) ); m_Position = xi18n("Now visible: About %1 degrees above the %2 horizon", rounded_altitude, KSUtils::toDirectionString( sp.az() ) );
} }
QString SkyObjItem::getImageURL() const QString SkyObjItem::getImageURL(bool preferThumb) const
{ {
if ( m_Type==Star ) if ( m_Type==Star )
{ {
return ""; return "";
} }
QString thumbName = KSPaths::locate(QStandardPaths::GenericDataLocation, "thumb-" + m_So->name().toLower().remove( ' ' ) + ".png" ) ;
QString fullSizeName = KSPaths::locate(QStandardPaths::GenericDataLocation, "Image_" + m_So->name().toLower().remove( ' ' ) + ".png" ) ;
QString fname = KSPaths::locate(QStandardPaths::GenericDataLocation, "image_" + m_So->name().toLower().remove( ' ' ) + ".png" ) ; //First try to return the preferred file
if(thumbName!=""&&preferThumb)
return thumbName;
if(fullSizeName!=""&&(!preferThumb))
return fullSizeName;
//If that fails, try to return the large image first, then the thumb and then if it is a planet, the xplanet image.
QString fname = KSPaths::locate(QStandardPaths::GenericDataLocation, "Image_" + m_So->name().toLower().remove( ' ' ) + ".png" ) ;
if(fname=="") if(fname=="")
fname = KSPaths::locate(QStandardPaths::GenericDataLocation, "thumb-" + m_So->name().toLower().remove( ' ' ) + ".png" ) ; fname = KSPaths::locate(QStandardPaths::GenericDataLocation, "thumb-" + m_So->name().toLower().remove( ' ' ) + ".png" ) ;
if(fname=="" && m_Type==Planet){ if(fname=="" && m_Type==Planet){
...@@ -128,9 +137,12 @@ QString SkyObjItem::getImageURL() const ...@@ -128,9 +137,12 @@ QString SkyObjItem::getImageURL() const
} }
QString SkyObjItem::getSummary() const QString SkyObjItem::getSummary(bool includeDescription) const
{ {
return m_So->typeName()+"\n"+getRADE()+"\n"+getAltAz()+"\n"; if(includeDescription)
return m_So->typeName() + "<BR>" + getRADE() + "<BR>" + getAltAz()+"<BR><BR>" + loadObjectDescription();
else
return m_So->typeName() + "<BR>" + getRADE() + "<BR>" + getAltAz();
} }
QString SkyObjItem::getDesc() const QString SkyObjItem::getDesc() const
...@@ -222,3 +234,22 @@ QString SkyObjItem::getSize() const ...@@ -222,3 +234,22 @@ QString SkyObjItem::getSize() const
return QString(" --"); return QString(" --");
} }
} }
inline QString SkyObjItem::loadObjectDescription() const{
QFile file;
QString fname = "description-" + getName().toLower().remove( ' ' ) + ".html";
file.setFileName( KSPaths::writableLocation(QStandardPaths::GenericDataLocation) + "descriptions/" + fname ) ; //determine filename in local user KDE directory tree.
if(file.exists())
{
if(file.open(QIODevice::ReadOnly))
{
QTextStream in(&file);
QString line;
line = in.readAll();
file.close();
return line;
}
}
return "";
}
...@@ -114,7 +114,7 @@ class SkyObjItem ...@@ -114,7 +114,7 @@ class SkyObjItem
*/ */
inline QString getRADE() const inline QString getRADE() const
{ {
return "RA: "+ m_So->ra().toHMSString() + "\nDE: " + m_So->ra().toDMSString(); return "RA: "+ m_So->ra().toHMSString() + "<BR>DE: " + m_So->ra().toDMSString();
} }
/** /**
...@@ -135,14 +135,16 @@ class SkyObjItem ...@@ -135,14 +135,16 @@ class SkyObjItem
return m_So; return m_So;
} }
QString getImageURL() const; QString getImageURL(bool preferThumb) const;
inline QString loadObjectDescription() const;
/** /**
* \brief Get Summary Description for the SkyObjItem. * \brief Get Summary Description for the SkyObjItem.
* \return Summary Description for the SkyObjItem as a QString. * \return Summary Description for the SkyObjItem as a QString.
*/ */
QString getSummary() const; QString getSummary(bool includeDescription) const;
/** /**
...@@ -194,6 +196,7 @@ class SkyObjItem ...@@ -194,6 +196,7 @@ class SkyObjItem
Type m_Type; ///Category of sky-object of type SkyObjItem::Type Type m_Type; ///Category of sky-object of type SkyObjItem::Type
SkyObject * m_So; ///Pointer to SkyObject represented by SkyObjItem SkyObject * m_So; ///Pointer to SkyObject represented by SkyObjItem
SkyObjDescription * skd; /// pointer to SkyObjDescription SkyObjDescription * skd; /// pointer to SkyObjDescription
}; };
#endif #endif
...@@ -263,17 +263,21 @@ void WIView::loadDetailsView(SkyObjItem * soitem, int index) ...@@ -263,17 +263,21 @@ 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 * infoBoxTextObj = m_DetailsViewObj->findChild<QObject *>("infoBoxText");
QObject * detailsTextObj = m_DetailsViewObj->findChild<QObject *>("detailsTextObj"); QObject * detailsTextObj = m_DetailsViewObj->findChild<QObject *>("detailsTextObj");
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(false));
descTextObj->setProperty("text", soitem->getDesc()); descTextObj->setProperty("text", soitem->getDesc());
if(soitem->getType() != SkyObjItem::Planet) if(soitem->getType() != SkyObjItem::Planet)
tryToLoadFromWikipedia(descTextObj, descSrcTextObj, soitem); loadObjectDescription(descTextObj, descSrcTextObj, soitem);
infoBoxTextObj->setProperty("text", "trying to Load infoText box from Wikipedia. . .");
loadObjectInfoBox(infoBoxTextObj, soitem);
descSrcTextObj->setProperty("text", soitem->getDescSource()); descSrcTextObj->setProperty("text", soitem->getDescSource());
QString summary=soitem->getSummary(); QString summary=soitem->getSummary(false);
QString magText; QString magText;
if (soitem->getType() == SkyObjItem::Constellation) if (soitem->getType() == SkyObjItem::Constellation)
...@@ -285,13 +289,13 @@ void WIView::loadDetailsView(SkyObjItem * soitem, int index) ...@@ -285,13 +289,13 @@ void WIView::loadDetailsView(SkyObjItem * soitem, int index)
QString sizeText = xi18n("Size: %1", soitem->getSize()); QString sizeText = xi18n("Size: %1", soitem->getSize());