Commit e11303db authored by Jasem Mutlaq's avatar Jasem Mutlaq

Keep track of all active FITSViewers in a dedicated list since we cannot rely...

Keep track of all active FITSViewers in a dedicated list since we cannot rely on getChildren since some FITSViewers are independent Windows.
parent aa8fc272
......@@ -2549,9 +2549,15 @@ void Focus::showFITSViewer()
if (Options::singleWindowCapturedFITS())
fv = KStars::Instance()->genericFITSViewer();
else
{
fv = new FITSViewer(Options::independentWindowFITS() ? NULL : KStars::Instance());
KStars::Instance()->getFITSViewersList().append(fv);
}
fv->addFITS(&url);
FITSView *currentView = fv->getCurrentView();
if (currentView)
currentView->getImageData()->setAutoRemoveTemporaryFITS(false);
}
else
fv->updateFITS(&url, 0);
......
......@@ -2162,9 +2162,15 @@ void Guide::showFITSViewer()
if (Options::singleWindowCapturedFITS())
fv = KStars::Instance()->genericFITSViewer();
else
{
fv = new FITSViewer(Options::independentWindowFITS() ? NULL : KStars::Instance());
KStars::Instance()->getFITSViewersList().append(fv);
}
fv->addFITS(&url);
FITSView *currentView = fv->getCurrentView();
if (currentView)
currentView->getImageData()->setAutoRemoveTemporaryFITS(false);
}
else
fv->updateFITS(&url, 0);
......
......@@ -286,6 +286,9 @@ void FITSViewer::changeAlwaysOnTop(Qt::ApplicationState state)
FITSViewer::~FITSViewer()
{
if (KStars::Instance())
KStars::Instance()->getFITSViewersList().removeOne(this);
fitsTab->disconnect();
qDeleteAll(fitsTabs);
......@@ -320,7 +323,7 @@ void FITSViewer::hideEvent(QHideEvent * /*event*/)
{
QList<FITSViewer *> viewers = KStars::Instance()->findChildren<FITSViewer *>();
if (viewers.count() == 1)
if (viewers.count() <= 1)
a->setChecked(false);
}
}
......
......@@ -1402,14 +1402,19 @@ void CCD::processBLOB(IBLOB* bp)
// If there is no FITSViewer, create it. Unless it is a dedicated Focus or Guide frame
// then no need for a FITS Viewer as they get displayed inside Ekos
if (Options::useFITSViewerInCapture()||!targetChip->isBatchMode()){
if (fv.isNull() && targetChip->getCaptureMode() != FITS_GUIDE && targetChip->getCaptureMode() != FITS_FOCUS)
if (fv.isNull() && targetChip->getCaptureMode() != FITS_GUIDE
&& targetChip->getCaptureMode() != FITS_FOCUS
&& targetChip->getCaptureMode() != FITS_ALIGN)
{
normalTabID = calibrationTabID = focusTabID = guideTabID = alignTabID = -1;
if (Options::singleWindowCapturedFITS())
fv = KStars::Instance()->genericFITSViewer();
else
{
fv = new FITSViewer(Options::independentWindowFITS() ? NULL : KStars::Instance());
KStars::Instance()->getFITSViewersList().append(fv);
}
//connect(fv, SIGNAL(destroyed()), this, SLOT(FITSViewerDestroyed()));
//connect(fv, SIGNAL(destroyed()), this, SIGNAL(FITSViewerClosed()));
......
......@@ -475,6 +475,8 @@ FITSViewer * KStars::genericFITSViewer()
{
m_GenericFITSViewer = new FITSViewer(Options::independentWindowFITS() ? NULL : this);
m_GenericFITSViewer->setAttribute(Qt::WA_DeleteOnClose);
m_FITSViewers.append(m_GenericFITSViewer);
}
return m_GenericFITSViewer;
......
......@@ -136,6 +136,7 @@ public:
#ifdef HAVE_CFITSIO
FITSViewer *genericFITSViewer();
QList<FITSViewer*> & getFITSViewersList() { return m_FITSViewers; }
#endif
#ifdef HAVE_INDI
......@@ -684,6 +685,7 @@ private:
EyepieceField *m_EyepieceView;
#ifdef HAVE_CFITSIO
QPointer<FITSViewer> m_GenericFITSViewer;
QList<FITSViewer*> m_FITSViewers;
#endif
#ifdef HAVE_INDI
......
......@@ -266,9 +266,7 @@ void KStars::slotINDIToolBar()
}
else if ( a == actionCollection()->action( "show_fits_viewer" ) )
{
QList<FITSViewer *> viewers = findChildren<FITSViewer *>();
if (viewers.isEmpty())
if (m_FITSViewers.isEmpty())
{
a->setEnabled(false);
return;
......@@ -276,16 +274,19 @@ void KStars::slotINDIToolBar()
if (a->isChecked())
{
foreach(FITSViewer *view, viewers)
foreach(FITSViewer *view, m_FITSViewers)
{
view->raise();
view->activateWindow();
view->showNormal();
if (view->getTabs().empty() == false)
{
view->raise();
view->activateWindow();
view->showNormal();
}
}
}
else
{
foreach(FITSViewer *view, viewers)
foreach(FITSViewer *view, m_FITSViewers)
{
view->hide();
}
......
......@@ -754,7 +754,10 @@ bool KStars::openFITS(const QUrl &imageURL)
if (Options::singleWindowOpenedFITS())
fv = genericFITSViewer();
else
{
fv = new FITSViewer((Options::independentWindowFITS()) ? NULL : this);
KStars::Instance()->getFITSViewersList().append(fv);
}
// Error opening file
if (fv->addFITS(&imageURL) == -2)
{
......
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