Implemented a minimal set time dialog for Qt4 front-end.
parent
69eeee8c42
commit
034be6c893
|
@ -292,7 +292,8 @@ QTAPP_SOURCES = \
|
|||
celestia/qt/qttimetoolbar.cpp \
|
||||
celestia/qt/qtcelestiaactions.cpp \
|
||||
celestia/qt/qtinfopanel.cpp \
|
||||
celestia/qt/qteventfinder.cpp
|
||||
celestia/qt/qteventfinder.cpp \
|
||||
celestia/qt/qtsettimedialog.cpp
|
||||
|
||||
QTAPP_HEADERS = \
|
||||
celestia/qt/qtappwin.h \
|
||||
|
@ -306,7 +307,8 @@ QTAPP_HEADERS = \
|
|||
celestia/qt/qttimetoolbar.h \
|
||||
celestia/qt/qtcelestiaactions.h \
|
||||
celestia/qt/qtinfopanel.h \
|
||||
celestia/qt/qteventfinder.h
|
||||
celestia/qt/qteventfinder.h \
|
||||
celestia/qt/qtsettimedialog.h
|
||||
|
||||
SOURCES = \
|
||||
$$UTIL_SOURCES \
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
// of the License, or (at your option) any later version.
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QVBoxLayout>
|
||||
#include <QPushButton>
|
||||
#include <QTimer>
|
||||
#include <QMenu>
|
||||
|
@ -23,6 +24,7 @@
|
|||
#include <QCloseEvent>
|
||||
#include <QDir>
|
||||
#include <QMessageBox>
|
||||
#include <QDateTimeEdit>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include "qtappwin.h"
|
||||
|
@ -36,6 +38,7 @@
|
|||
#include "qtcelestiaactions.h"
|
||||
#include "qtinfopanel.h"
|
||||
#include "qteventfinder.h"
|
||||
#include "qtsettimedialog.h"
|
||||
//#include "qtvideocapturedialog.h"
|
||||
#include "celestia/scriptmenu.h"
|
||||
|
||||
|
@ -454,6 +457,22 @@ void CelestiaAppWindow::slotOpenScript()
|
|||
}
|
||||
|
||||
|
||||
void CelestiaAppWindow::slotShowTimeDialog()
|
||||
{
|
||||
SetTimeDialog* timeDialog = new SetTimeDialog(appCore->getSimulation()->getTime(),
|
||||
this);
|
||||
connect(timeDialog, SIGNAL(setTimeTriggered(double)), this, SLOT(slotSetTime(double)));
|
||||
|
||||
timeDialog->exec();
|
||||
}
|
||||
|
||||
|
||||
void CelestiaAppWindow::slotSetTime(double tdb)
|
||||
{
|
||||
appCore->getSimulation()->setTime(tdb);
|
||||
}
|
||||
|
||||
|
||||
void CelestiaAppWindow::createActions()
|
||||
{
|
||||
}
|
||||
|
@ -514,11 +533,14 @@ void CelestiaAppWindow::createMenus()
|
|||
connect(gotoAct, SIGNAL(triggered()), this, SLOT(gotoSelection()));
|
||||
navMenu->addAction(gotoAct);
|
||||
|
||||
//navMenu->addAction();
|
||||
|
||||
/****** Time menu ******/
|
||||
timeMenu = menuBar()->addMenu(tr("&Time"));
|
||||
//timeMenu->addAction();
|
||||
|
||||
QAction* setTimeAct = new QAction(tr("Set &time"), this);
|
||||
connect(setTimeAct, SIGNAL(triggered()), this, SLOT(slotShowTimeDialog()));
|
||||
timeMenu->addAction(setTimeAct);
|
||||
|
||||
|
||||
/****** View menu ******/
|
||||
viewMenu = menuBar()->addMenu(tr("&View"));
|
||||
|
|
|
@ -72,6 +72,10 @@ class CelestiaAppWindow : public QMainWindow
|
|||
|
||||
void slotOpenScriptDialog();
|
||||
void slotOpenScript();
|
||||
|
||||
void slotShowTimeDialog();
|
||||
|
||||
void slotSetTime(double tdb);
|
||||
|
||||
signals:
|
||||
void progressUpdate(const QString& s, int align, const QColor& c);
|
||||
|
|
|
@ -0,0 +1,75 @@
|
|||
// qtsettimedialog.cpp
|
||||
//
|
||||
// Copyright (C) 2008, Celestia Development Team
|
||||
// celestia-developers@lists.sourceforge.net
|
||||
//
|
||||
// Set time/date dialog box.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
|
||||
#include "qtsettimedialog.h"
|
||||
#include <QPushButton>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QDateTimeEdit>
|
||||
#include <QVBoxLayout>
|
||||
#include "celengine/astro.h"
|
||||
|
||||
|
||||
SetTimeDialog::SetTimeDialog(double currentTimeTDB,
|
||||
QWidget* parent) :
|
||||
QDialog(parent),
|
||||
dateEdit(NULL)
|
||||
{
|
||||
QVBoxLayout* layout = new QVBoxLayout();
|
||||
|
||||
dateEdit = new QDateTimeEdit(this);
|
||||
// The date control doesn't seem to work properly with earlier dates
|
||||
dateEdit->setMinimumDate(QDate(1000, 1, 1));
|
||||
dateEdit->setDisplayFormat("dd MMM yyyy hh:mm:ss.zzz");
|
||||
dateEdit->setCalendarPopup(true);
|
||||
|
||||
astro::Date utc = astro::TDBtoUTC(currentTimeTDB);
|
||||
|
||||
int sec = (int) utc.seconds;
|
||||
int msec = (int) ((utc.seconds - sec) * 1000);
|
||||
QDateTime d(QDate(utc.year, utc.month, utc.day),
|
||||
QTime(utc.hour, utc.minute, sec, msec));
|
||||
dateEdit->setDateTime(d);
|
||||
|
||||
layout->addWidget(dateEdit, 0, 0);
|
||||
|
||||
QDialogButtonBox* buttonBox = new QDialogButtonBox(this);
|
||||
buttonBox->setStandardButtons(QDialogButtonBox::Cancel);
|
||||
|
||||
QPushButton* setTimeButton = new QPushButton(tr("Set time"), buttonBox);
|
||||
buttonBox->addButton(setTimeButton, QDialogButtonBox::ApplyRole);
|
||||
connect(setTimeButton, SIGNAL(clicked()), this, SLOT(slotSetTime()));
|
||||
|
||||
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
|
||||
|
||||
layout->addWidget(buttonBox);
|
||||
|
||||
setLayout(layout);
|
||||
}
|
||||
|
||||
|
||||
SetTimeDialog::~SetTimeDialog()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void SetTimeDialog::slotSetTime()
|
||||
{
|
||||
QDate d = dateEdit->date();
|
||||
QTime t = dateEdit->time();
|
||||
|
||||
astro::Date utc(d.year(), d.month(), d.day());
|
||||
utc.hour = t.hour();
|
||||
utc.minute = t.minute();
|
||||
utc.seconds = (double) t.second() + t.msec() / 1000.0;
|
||||
|
||||
emit setTimeTriggered(astro::UTCtoTDB(utc));
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
// qtsettimedialog.h
|
||||
//
|
||||
// Copyright (C) 2008, Celestia Development Team
|
||||
// celestia-developers@lists.sourceforge.net
|
||||
//
|
||||
// Set time/date dialog box.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
|
||||
#ifndef _QTSETTIMEDIALOG_H_
|
||||
#define _QTSETTIMEDIALOG_H_
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
class QDateTimeEdit;
|
||||
|
||||
|
||||
class SetTimeDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SetTimeDialog(double currentTimeTDB,
|
||||
QWidget* parent = NULL);
|
||||
~SetTimeDialog();
|
||||
|
||||
public slots:
|
||||
void slotSetTime();
|
||||
|
||||
signals:
|
||||
void setTimeTriggered(double tdb);
|
||||
|
||||
private:
|
||||
QDateTimeEdit* dateEdit;
|
||||
};
|
||||
|
||||
#endif // _QTSETTIMEDIALOG_H_
|
Loading…
Reference in New Issue