Commit a8eb4030 authored by Samikshan Bairagya's avatar Samikshan Bairagya

Open KConfigDialog for WI settings, currently with only one page for "Light Pollution Settings".

parent a50e54ec
......@@ -59,9 +59,9 @@ KStars::KStars( bool doSplash, bool clockrun, const QString &startdate )
: KXmlGuiWindow(), kstarsData(0), skymap(0), TimeStep(0),
colorActionMenu(0), fovActionMenu(0), findDialog(0),
imgExportDialog(0), obsList(0), execute(0),
avt(0), wut(0), wi(0), wiWiz(0), wiDock(0), skycal(0), sb(0), pv(0),
jmt(0), mpt(0), fm(0), astrocalc(0), printingWizard(0), ekosmenu(0),
DialogIsObsolete(false), StartClockRunning( clockrun ),
avt(0), wut(0), wi(0), wiObsConditions(0), wiWiz(0), wiDock(0), skycal(0),
sb(0), pv(0), jmt(0), mpt(0), fm(0), astrocalc(0), printingWizard(0),
ekosmenu(0), DialogIsObsolete(false), StartClockRunning( clockrun ),
StartDateString( startdate )
{
new KstarsAdaptor(this);
......@@ -327,31 +327,9 @@ void KStars::selectPreviousFov()
map()->update();
}
void KStars::showWIWizard()
void KStars::showWISettingsUI()
{
wiDock->setVisible(false);
wiWiz->restart();
wiWiz->setVisible(true);
}
void KStars::showWI(ObsConditions *obs)
{
if ( ! wi )
{
wi = new WIView(0, obs);
wiDock = new QDockWidget(this);
wiDock->setObjectName("What's Interesting");
wiDock->setAllowedAreas(Qt::RightDockWidgetArea);
wiDock->setWidget(wi->getWIBaseView());
wiDock->setMinimumWidth(wi->getWIBaseView()->width());
addDockWidget(Qt::RightDockWidgetArea, wiDock);
wiDock->setVisible(true);
}
else
{
wi->updateModels(obs);
wiDock->setVisible(true);
}
slotWISettings();
}
void KStars::updateTime( const bool automaticDSTchange ) {
......
......@@ -46,6 +46,7 @@ class AltVsTime;
class WUTDialog;
class WIView;
class WIUserSettings;
class WILPSettings;
class ObsConditions;
class AstroCalc;
class SkyCalendar;
......@@ -170,7 +171,7 @@ public:
void selectPreviousFov();
void showWIWizard();
void showWISettingsUI();
void showWI(ObsConditions *obs);
......@@ -507,8 +508,11 @@ private slots:
/** action slot: open What's up tonight dialog */
void slotWUT();
/** action slot: open What's Interesting settings window */
void slotWISettings();
/** action slot: open What's Interesting window */
void slotWI();
void slotShowWIView(int status);
/** action slot: open Sky Calendar tool */
void slotCalendar();
......@@ -655,6 +659,8 @@ private:
AltVsTime *avt;
WUTDialog *wut;
WIView *wi;
WILPSettings *wiLPSettings;
ObsConditions *wiObsConditions;
WIUserSettings *wiWiz;
QDockWidget *wiDock;
SkyCalendar *skycal;
......
......@@ -1180,6 +1180,32 @@
<default>10.0</default>
</entry>
</group>
<group name="WISettings">
<entry name="BortleClass" type="UInt">
<label>Bortle dark-sky rating</label>
<default>4</default>
</entry>
<entry name="TelescopeCheck" type="Bool">
<label>Availability of telescope</label>
<default>false</default>
</entry>
<entry name="BinocularsCheck" type="Bool">
<label>Availability of binoculars</label>
<default>false</default>
</entry>
<entry name="NoEquipCheck" type="Bool">
<label>Availability of both telescope and binoculars</label>
<default>false</default>
</entry>
<entry name="Aperture" type="Double">
<label>Aperture of available equipment</label>
<default>30.0</default>
</entry>
<entry name="TelescopeType" type="String">
<label>Type of telescope: Reflector/Refractor</label>
<default>Reflector</default>
</entry>
</group>
<group name="Ekos">
<entry name="TelescopeDriver" type="String">
<label>Default telescope driver</label>
......
......@@ -77,6 +77,7 @@
#include "tools/wutdialog.h"
#include "tools/whatsinteresting/wiview.h"
#include "tools/whatsinteresting/wiusersettings.h"
#include "tools/whatsinteresting/wilpsettings.h"
#include "tools/skycalendar.h"
#include "tools/scriptbuilder.h"
#include "tools/planetviewer.h"
......@@ -279,10 +280,48 @@ void KStars::slotWUT() {
wut->show();
}
void KStars::slotWI() {
if ( ! wiWiz ) wiWiz = new WIUserSettings(this);
if ( wiDock && wiDock->isVisible() ) return;
wiWiz->show();
void KStars::slotWISettings()
{
if (KConfigDialog::showDialog("wisettings")) return;
KConfigDialog* dialog = new KConfigDialog(this, "wisettings", Options::self());
connect(dialog, SIGNAL(settingsChanged(const QString &)), this, SLOT(slotApplyConfigChanges()));
connect(dialog, SIGNAL(finished(int)), this, SLOT(slotShowWIView(int)));
wiLPSettings = new WILPSettings(this);
dialog->addPage(wiLPSettings, i18n("What's Interesting Settings"));
dialog->show();
}
void KStars::slotShowWIView(int status)
{
if (status == 0) return; //Cancelled
//Update observing conditions for What's Interesting
kDebug()<<"Bortle class: "<<Options::bortleClass();
if (!wiObsConditions)
wiObsConditions = new ObsConditions(Options::bortleClass(), 30.0,
ObsConditions::Telescope, ObsConditions::Reflector);
else
wiObsConditions->setObsConditions(Options::bortleClass(), 30.0,
ObsConditions::Telescope, ObsConditions::Reflector);
if (!wi)
{
wi = new WIView(0, wiObsConditions);
wiDock = new QDockWidget(this);
wiDock->setObjectName("What's Interesting");
wiDock->setAllowedAreas(Qt::RightDockWidgetArea);
wiDock->setWidget(wi->getWIBaseView());
wiDock->setMinimumWidth(wi->getWIBaseView()->width());
addDockWidget(Qt::RightDockWidgetArea, wiDock);
wiDock->setVisible(true);
}
else
{
wi->updateModels(wiObsConditions);
}
}
void KStars::slotCalendar() {
......
......@@ -375,7 +375,7 @@ void KStars::initActions() {
actionCollection()->addAction("whats_up_tonight", this, SLOT( slotWUT() ) )
<< i18n("What's up Tonight")
<< KShortcut(Qt::CTRL+Qt::Key_U );
actionCollection()->addAction("whats_interesting", this, SLOT( slotWI() ) )
actionCollection()->addAction("whats_interesting", this, SLOT( slotWISettings() ) )
<< i18n("What's Interesting...")
<< KShortcut(Qt::CTRL+Qt::Key_W );
actionCollection()->addAction("skycalendar", this, SLOT( slotCalendar() ) )
......
......@@ -95,3 +95,12 @@ bool ObsConditions::isVisible(GeoLocation *geo, dms *lst, SkyObject *so)
return (sp.alt().Degrees() > 6.0 && so->mag() < getTrueMagLim());
}
void ObsConditions::setObsConditions(int bortle, double aperture, ObsConditions::Equipment equip, ObsConditions::TelescopeType telType)
{
m_BortleClass = bortle;
setLimMagnitude();
m_Aperture = 30.0;
m_Equip = Telescope;
m_TelType = Reflector;
}
......@@ -72,6 +72,11 @@ public:
*/
void setLimMagnitude();
/**
* \brief Set new observing conditions.
*/
void setObsConditions(int bortle, double aperture, Equipment equip, TelescopeType telType);
/**
* \brief Get optimum magnification under current observing conditions.
* \return Get optimum magnification under current observing conditions
......
......@@ -28,7 +28,7 @@
WIView::WIView(QWidget *parent, ObsConditions *obs) : QWidget(parent), m_Obs(obs)
{
m_ModManager = new ModelManager(obs);
m_ModManager = new ModelManager(m_Obs);
m_BaseView = new QDeclarativeView();
......@@ -91,7 +91,6 @@ void WIView::onSoListItemClicked(int type, QString typeName, int index)
void WIView::loadDetailsView(SkyObjItem *soitem, int index)
{
m_CurSoItem = soitem;
m_CurIndex = index;
......@@ -171,5 +170,5 @@ void WIView::onDetailsButtonClicked()
void WIView::onSettingsIconClicked()
{
KStars *kstars = KStars::Instance();
kstars->showWIWizard();
kstars->showWISettingsUI();
}
......@@ -56,7 +56,10 @@ public:
*/
void loadDetailsView(SkyObjItem* soitem, int index);
inline void updateModels(ObsConditions *obs) { m_ModManager->updateModels(obs); }
/**
* \brief Updates sky-object list models
*/
inline void updateModels(ObsConditions *obs) { m_Obs = obs; m_ModManager->updateModels(m_Obs); }
inline QDeclarativeView *getWIBaseView() const { return m_BaseView; }
......
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