/***********************************************************************
**
**   preflightmiscpage.cpp
**
**   This file is part of Cumulus
**
************************************************************************
**
**   Copyright (c):  2004 by André Somers
**
**   This file is distributed under the terms of the General Public
**   Licence. See the file COPYING for more information.
**
**   $Id: preflightmiscpage.cpp,v 1.2 2004/03/12 14:59:29 andre Exp $
**
***********************************************************************/

#include "preflightmiscpage.h"
#include <qlayout.h>
#include "igclogger.h"
#include "qmessagebox.h"

PreFlightMiscPage::PreFlightMiscPage(QWidget *parent, const char *name ) : QWidget(parent,name) {
  QGridLayout * topLayout = new QGridLayout(this, 3,2,5);

  chkLogAutoStart = new QCheckBox(tr("Automaticly start logging."),this,"log_autostart");
  topLayout->addMultiCellWidget(chkLogAutoStart,0,0,0,1);

  topLayout->setRowStretch(1,20);

  chkLogAutoStart->setChecked(IgcLogger::instance()->getisStandby());
}

PreFlightMiscPage::~PreFlightMiscPage(){
}

void PreFlightMiscPage::save() {
qDebug("  PreFlightMiscPage::save()");
  IgcLogger * log=IgcLogger::instance();
  if (chkLogAutoStart->isChecked()) {
    if (log->getisLogging()) {
      int answer= QMessageBox::warning(this,tr("Restart Logging?"),
        tr("Cumulus is currently\nlogging.\nDo you want\nto close this logfile\nand start a new log?"),
        QMessageBox::Yes,
        QMessageBox::No | QMessageBox::Escape | QMessageBox::Default);

      if (answer==QMessageBox::Yes) {
        log->Standby();
      }
    } else {
      log->Standby();
    }
  } else {
    if (log->getisStandby()) {
      log->Stop();
    }
  }
}

