2008-02-08 10:22:41 -07:00
|
|
|
// qtappwin.cpp
|
|
|
|
//
|
|
|
|
// Copyright (C) 2007-2008, Celestia Development Team
|
|
|
|
// celestia-developers@lists.sourceforge.net
|
|
|
|
//
|
|
|
|
// Main window for Celestia Qt front-end.
|
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
|
2019-08-20 18:40:59 -06:00
|
|
|
|
2018-12-24 13:14:22 -07:00
|
|
|
#include <memory>
|
2008-04-12 14:54:28 -06:00
|
|
|
|
2021-05-29 20:04:27 -06:00
|
|
|
#include <QStandardPaths>
|
|
|
|
#include <QActionGroup>
|
2016-12-07 05:50:07 -07:00
|
|
|
#include <QIcon>
|
2008-02-08 10:22:41 -07:00
|
|
|
#include <QHBoxLayout>
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
#include <QPushButton>
|
|
|
|
#include <QTimer>
|
|
|
|
#include <QMenu>
|
|
|
|
#include <QMenuBar>
|
|
|
|
#include <QSettings>
|
|
|
|
#include <QDockWidget>
|
|
|
|
#include <QTabWidget>
|
|
|
|
#include <QFileDialog>
|
|
|
|
#include <QFileInfo>
|
|
|
|
#include <QCloseEvent>
|
|
|
|
#include <QDir>
|
|
|
|
#include <QMessageBox>
|
2008-03-16 22:11:33 -06:00
|
|
|
#include <QTextEdit>
|
|
|
|
#include <QDialogButtonBox>
|
|
|
|
#include <QTextStream>
|
2008-03-20 20:11:22 -06:00
|
|
|
#include <QClipboard>
|
|
|
|
#include <QApplication>
|
2008-04-19 17:15:22 -06:00
|
|
|
#include <QProcess>
|
|
|
|
#include <QDesktopServices>
|
2018-11-09 07:20:23 -07:00
|
|
|
#include <QInputDialog>
|
2008-04-19 17:15:22 -06:00
|
|
|
#include <QUrl>
|
2019-11-19 10:57:22 -07:00
|
|
|
#include <QScreen>
|
2008-02-08 10:22:41 -07:00
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
2008-04-19 17:15:22 -06:00
|
|
|
#include <cassert>
|
2021-06-13 04:48:54 -06:00
|
|
|
#include <celengine/glsupport.h>
|
2020-02-13 09:21:42 -07:00
|
|
|
#include <celutil/gettext.h>
|
2021-02-28 01:58:23 -07:00
|
|
|
#include <celutil/util.h>
|
2008-02-08 10:22:41 -07:00
|
|
|
#include "qtappwin.h"
|
|
|
|
#include "qtglwidget.h"
|
|
|
|
#include "qtpreferencesdialog.h"
|
|
|
|
#include "qtsolarsystembrowser.h"
|
|
|
|
#include "qtcelestialbrowser.h"
|
|
|
|
#include "qtdeepskybrowser.h"
|
|
|
|
#include "qtselectionpopup.h"
|
|
|
|
#include "qttimetoolbar.h"
|
|
|
|
#include "qtcelestiaactions.h"
|
|
|
|
#include "qtinfopanel.h"
|
|
|
|
#include "qteventfinder.h"
|
|
|
|
#include "qtsettimedialog.h"
|
2018-11-27 10:39:07 -07:00
|
|
|
#include "qtgotoobjectdialog.h"
|
2021-03-02 11:10:18 -07:00
|
|
|
#include <celestia/celestiastate.h>
|
|
|
|
#include <celestia/scriptmenu.h>
|
|
|
|
#include <celestia/url.h>
|
2008-04-19 17:15:22 -06:00
|
|
|
#include "qtbookmark.h"
|
2008-02-08 10:22:41 -07:00
|
|
|
|
2011-03-09 14:17:51 -07:00
|
|
|
#ifndef CONFIG_DATA_DIR
|
|
|
|
#define CONFIG_DATA_DIR "./"
|
|
|
|
#endif
|
|
|
|
|
2020-03-13 02:39:44 -06:00
|
|
|
using namespace celestia;
|
2008-02-08 10:22:41 -07:00
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
2008-04-19 17:15:22 -06:00
|
|
|
QString BOOKMARKS_FILE = "bookmarks.xbel";
|
2008-02-08 10:22:41 -07:00
|
|
|
|
|
|
|
const QSize DEFAULT_MAIN_WINDOW_SIZE(800, 600);
|
2016-12-20 11:05:47 -07:00
|
|
|
const QPoint DEFAULT_MAIN_WINDOW_POSITION(20, 20);
|
2008-02-08 10:22:41 -07:00
|
|
|
|
|
|
|
// Used when saving and restoring main window state; increment whenever
|
|
|
|
// new dockables or toolbars are added.
|
2008-05-19 15:41:45 -06:00
|
|
|
static const int CELESTIA_MAIN_WINDOW_VERSION = 12;
|
2008-02-08 10:22:41 -07:00
|
|
|
|
2018-11-15 01:09:14 -07:00
|
|
|
static int fps_to_ms(int fps) { return fps > 0 ? 1000 / fps : 0; }
|
|
|
|
static int ms_to_fps(int ms) { return ms > 0? 1000 / ms : 0; }
|
2008-02-08 10:22:41 -07:00
|
|
|
|
|
|
|
// Progress notifier class receives update messages from CelestiaCore
|
|
|
|
// at startup. This simple implementation just forwards messages on
|
|
|
|
// to the main Celestia window.
|
|
|
|
class AppProgressNotifier : public ProgressNotifier
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
AppProgressNotifier(CelestiaAppWindow* _appWin) :
|
|
|
|
appWin(_appWin)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void update(const string& s)
|
|
|
|
{
|
|
|
|
appWin->loadingProgressUpdate(QString(s.c_str()));
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
CelestiaAppWindow* appWin;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Alerter callback class for CelestiaCore
|
|
|
|
class AppAlerter : public CelestiaCore::Alerter
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
AppAlerter(QWidget* _parent) :
|
|
|
|
parent(_parent)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2018-09-22 07:13:49 -06:00
|
|
|
~AppAlerter() = default;
|
2008-02-08 10:22:41 -07:00
|
|
|
|
|
|
|
void fatalError(const string& msg)
|
|
|
|
{
|
|
|
|
QMessageBox::critical(parent, "Celestia", QString(msg.c_str()));
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
QWidget* parent;
|
2018-03-11 07:12:58 -06:00
|
|
|
};
|
2008-02-08 10:22:41 -07:00
|
|
|
|
2018-11-16 02:06:23 -07:00
|
|
|
class FPSActionGroup
|
|
|
|
{
|
|
|
|
QActionGroup *m_actionGroup;
|
|
|
|
std::map<int, QAction*> m_actions;
|
|
|
|
QAction *m_customAction;
|
2019-06-19 05:33:10 -06:00
|
|
|
int m_lastFPS { 0 };
|
2018-11-16 02:06:23 -07:00
|
|
|
public:
|
|
|
|
FPSActionGroup(QObject *p = nullptr);
|
|
|
|
|
2019-06-19 05:33:26 -06:00
|
|
|
const std::map<int, QAction*>& actions() const { return m_actions; }
|
|
|
|
QAction *customAction() const { return m_customAction; }
|
|
|
|
int lastFPS() const { return m_lastFPS; }
|
2018-11-16 02:06:23 -07:00
|
|
|
void updateFPS(int);
|
|
|
|
};
|
|
|
|
|
|
|
|
FPSActionGroup::FPSActionGroup(QObject *p)
|
|
|
|
{
|
|
|
|
QAction *fps;
|
|
|
|
std::array<int, 5> fps_array = { 0, 15, 30, 60, 120 };
|
|
|
|
|
|
|
|
m_actionGroup = new QActionGroup(p);
|
|
|
|
for (auto ifps : fps_array)
|
|
|
|
{
|
|
|
|
fps = new QAction(ifps == 0 ? _("Auto") : QString::number(ifps), p);
|
|
|
|
fps->setCheckable(true);
|
|
|
|
fps->setData(ifps);
|
|
|
|
m_actions[ifps] = fps;
|
|
|
|
m_actionGroup->addAction(fps);
|
|
|
|
}
|
|
|
|
m_customAction = new QAction(_("Custom"), p);
|
|
|
|
m_customAction->setCheckable(true);
|
2018-11-20 10:15:28 -07:00
|
|
|
m_customAction->setShortcut(QString("Ctrl+`"));
|
2018-11-16 02:06:23 -07:00
|
|
|
m_actionGroup->addAction(m_customAction);
|
|
|
|
m_actionGroup->setExclusive(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void FPSActionGroup::updateFPS(int fps)
|
|
|
|
{
|
|
|
|
if (fps < 0 )
|
|
|
|
fps = 0;
|
|
|
|
if (m_actions.count(fps))
|
|
|
|
m_actions.at(fps)->setChecked(true);
|
|
|
|
else
|
|
|
|
m_customAction->setChecked(true);
|
|
|
|
m_lastFPS = fps;
|
|
|
|
}
|
|
|
|
|
2018-10-30 12:57:10 -06:00
|
|
|
CelestiaAppWindow::CelestiaAppWindow(QWidget* parent) :
|
2019-08-25 00:19:04 -06:00
|
|
|
QMainWindow(parent),
|
|
|
|
CelestiaCore::ContextMenuHandler()
|
2008-02-08 10:22:41 -07:00
|
|
|
{
|
|
|
|
setObjectName("celestia-mainwin");
|
2018-11-09 07:20:23 -07:00
|
|
|
timer = new QTimer(this);
|
2008-02-08 10:22:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CelestiaAppWindow::~CelestiaAppWindow()
|
|
|
|
{
|
|
|
|
delete(alerter);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-29 12:46:35 -06:00
|
|
|
void CelestiaAppWindow::init(int argc, char *argv[])
|
2008-02-08 10:22:41 -07:00
|
|
|
{
|
2008-04-19 17:15:22 -06:00
|
|
|
initAppDataDirectory();
|
|
|
|
|
|
|
|
m_appCore = new CelestiaCore();
|
2021-06-29 12:46:35 -06:00
|
|
|
m_appCore->getCommandLineParser().parse(argc, argv);
|
2018-03-11 07:12:58 -06:00
|
|
|
|
2018-09-22 07:13:49 -06:00
|
|
|
auto* progress = new AppProgressNotifier(this);
|
2008-02-08 10:22:41 -07:00
|
|
|
alerter = new AppAlerter(this);
|
2008-04-19 17:15:22 -06:00
|
|
|
m_appCore->setAlerter(alerter);
|
2008-02-08 10:22:41 -07:00
|
|
|
|
2018-03-11 07:12:58 -06:00
|
|
|
setWindowIcon(QIcon(":/icons/celestia.png"));
|
2008-02-08 10:22:41 -07:00
|
|
|
|
2021-06-29 12:46:35 -06:00
|
|
|
if (!m_appCore->initSimulation(progress))
|
2018-10-05 12:19:59 -06:00
|
|
|
{
|
|
|
|
// Error message is shown by celestiacore so we silently exit here.
|
|
|
|
exit(1);
|
|
|
|
}
|
2008-02-08 10:22:41 -07:00
|
|
|
delete progress;
|
|
|
|
|
2018-03-11 07:12:58 -06:00
|
|
|
// Enable antialiasing if requested in the config file.
|
|
|
|
// TODO: Make this settable via the GUI
|
2018-10-31 12:32:14 -06:00
|
|
|
QGLFormat glformat = QGLFormat::defaultFormat();
|
2018-03-11 07:12:58 -06:00
|
|
|
if (m_appCore->getConfig()->aaSamples > 1)
|
|
|
|
{
|
2018-10-31 12:32:14 -06:00
|
|
|
glformat.setSampleBuffers(true);
|
2018-03-11 07:12:58 -06:00
|
|
|
glformat.setSamples(m_appCore->getConfig()->aaSamples);
|
2018-10-31 12:32:14 -06:00
|
|
|
QGLFormat::setDefaultFormat(glformat);
|
2018-03-11 07:12:58 -06:00
|
|
|
}
|
2008-02-08 10:22:41 -07:00
|
|
|
|
2018-09-22 07:13:49 -06:00
|
|
|
glWidget = new CelestiaGlWidget(nullptr, "Celestia", m_appCore);
|
2018-10-31 12:32:14 -06:00
|
|
|
|
2008-04-19 17:15:22 -06:00
|
|
|
m_appCore->setCursorHandler(glWidget);
|
2019-08-25 00:19:04 -06:00
|
|
|
m_appCore->setContextMenuHandler(this);
|
2008-02-08 10:22:41 -07:00
|
|
|
|
|
|
|
setCentralWidget(glWidget);
|
|
|
|
|
|
|
|
setWindowTitle("Celestia");
|
|
|
|
|
2008-04-19 17:15:22 -06:00
|
|
|
actions = new CelestiaActions(this, m_appCore);
|
2008-02-08 10:22:41 -07:00
|
|
|
|
|
|
|
createMenus();
|
|
|
|
|
|
|
|
QTabWidget* tabWidget = new QTabWidget(this);
|
|
|
|
tabWidget->setObjectName("celestia-tabbed-browser");
|
|
|
|
|
2010-04-13 04:14:57 -06:00
|
|
|
toolsDock = new QDockWidget(_("Celestial Browser"), this);
|
2008-02-08 10:22:41 -07:00
|
|
|
toolsDock->setObjectName("celestia-tools-dock");
|
|
|
|
toolsDock->setAllowedAreas(Qt::LeftDockWidgetArea |
|
|
|
|
Qt::RightDockWidgetArea);
|
|
|
|
|
2018-10-28 12:51:02 -06:00
|
|
|
// Info browser for a selected object
|
|
|
|
infoPanel = new InfoPanel(m_appCore, _("Info Browser"), this);
|
|
|
|
infoPanel->setObjectName("info-panel");
|
|
|
|
infoPanel->setAllowedAreas(Qt::LeftDockWidgetArea |
|
|
|
|
Qt::RightDockWidgetArea);
|
|
|
|
infoPanel->setVisible(false);
|
|
|
|
|
2008-02-08 10:22:41 -07:00
|
|
|
// Create the various browser widgets
|
2018-10-28 12:51:02 -06:00
|
|
|
celestialBrowser = new CelestialBrowser(m_appCore, nullptr, infoPanel);
|
2008-02-08 10:22:41 -07:00
|
|
|
celestialBrowser->setObjectName("celestia-browser");
|
|
|
|
connect(celestialBrowser,
|
|
|
|
SIGNAL(selectionContextMenuRequested(const QPoint&, Selection&)),
|
|
|
|
this,
|
|
|
|
SLOT(slotShowSelectionContextMenu(const QPoint&, Selection&)));
|
|
|
|
|
2018-10-28 12:51:02 -06:00
|
|
|
QWidget* deepSkyBrowser = new DeepSkyBrowser(m_appCore, nullptr, infoPanel);
|
2008-02-08 10:22:41 -07:00
|
|
|
deepSkyBrowser->setObjectName("deepsky-browser");
|
|
|
|
connect(deepSkyBrowser,
|
|
|
|
SIGNAL(selectionContextMenuRequested(const QPoint&, Selection&)),
|
|
|
|
this,
|
|
|
|
SLOT(slotShowSelectionContextMenu(const QPoint&, Selection&)));
|
|
|
|
|
2018-10-28 12:51:02 -06:00
|
|
|
SolarSystemBrowser* solarSystemBrowser = new SolarSystemBrowser(m_appCore, nullptr, infoPanel);
|
2008-02-08 10:22:41 -07:00
|
|
|
solarSystemBrowser->setObjectName("ssys-browser");
|
|
|
|
connect(solarSystemBrowser,
|
|
|
|
SIGNAL(selectionContextMenuRequested(const QPoint&, Selection&)),
|
|
|
|
this,
|
|
|
|
SLOT(slotShowSelectionContextMenu(const QPoint&, Selection&)));
|
|
|
|
|
|
|
|
// Set up the browser tabs
|
2010-04-13 04:14:57 -06:00
|
|
|
tabWidget->addTab(solarSystemBrowser, _("Solar System"));
|
|
|
|
tabWidget->addTab(celestialBrowser, _("Stars"));
|
|
|
|
tabWidget->addTab(deepSkyBrowser, _("Deep Sky Objects"));
|
2008-02-08 10:22:41 -07:00
|
|
|
|
|
|
|
toolsDock->setWidget(tabWidget);
|
|
|
|
addDockWidget(Qt::LeftDockWidgetArea, toolsDock);
|
|
|
|
|
|
|
|
addDockWidget(Qt::RightDockWidgetArea, infoPanel);
|
|
|
|
|
2010-04-13 04:14:57 -06:00
|
|
|
eventFinder = new EventFinder(m_appCore, _("Event Finder"), this);
|
2008-02-08 10:22:41 -07:00
|
|
|
eventFinder->setObjectName("event-finder");
|
|
|
|
eventFinder->setAllowedAreas(Qt::LeftDockWidgetArea |
|
2008-02-12 03:41:27 -07:00
|
|
|
Qt::RightDockWidgetArea);
|
2008-02-08 10:22:41 -07:00
|
|
|
addDockWidget(Qt::LeftDockWidgetArea, eventFinder);
|
|
|
|
eventFinder->setVisible(false);
|
|
|
|
//addDockWidget(Qt::DockWidgetArea, eventFinder);
|
|
|
|
|
|
|
|
// Create the time toolbar
|
2010-04-13 04:14:57 -06:00
|
|
|
TimeToolBar* timeToolBar = new TimeToolBar(m_appCore, _("Time"));
|
2008-02-08 10:22:41 -07:00
|
|
|
timeToolBar->setObjectName("time-toolbar");
|
|
|
|
timeToolBar->setFloatable(true);
|
|
|
|
timeToolBar->setMovable(true);
|
|
|
|
addToolBar(Qt::TopToolBarArea, timeToolBar);
|
|
|
|
|
|
|
|
// Create the guides toolbar
|
2010-04-13 04:14:57 -06:00
|
|
|
QToolBar* guidesToolBar = new QToolBar(_("Guides"));
|
2008-02-08 10:22:41 -07:00
|
|
|
guidesToolBar->setObjectName("guides-toolbar");
|
|
|
|
guidesToolBar->setFloatable(true);
|
|
|
|
guidesToolBar->setMovable(true);
|
|
|
|
guidesToolBar->setToolButtonStyle(Qt::ToolButtonTextOnly);
|
|
|
|
|
2008-05-29 15:53:42 -06:00
|
|
|
guidesToolBar->addAction(actions->equatorialGridAction);
|
|
|
|
guidesToolBar->addAction(actions->galacticGridAction);
|
|
|
|
guidesToolBar->addAction(actions->eclipticGridAction);
|
2008-09-22 14:47:33 -06:00
|
|
|
guidesToolBar->addAction(actions->horizonGridAction);
|
|
|
|
guidesToolBar->addAction(actions->eclipticAction);
|
2008-02-08 10:22:41 -07:00
|
|
|
guidesToolBar->addAction(actions->markersAction);
|
|
|
|
guidesToolBar->addAction(actions->constellationsAction);
|
|
|
|
guidesToolBar->addAction(actions->boundariesAction);
|
|
|
|
guidesToolBar->addAction(actions->orbitsAction);
|
|
|
|
guidesToolBar->addAction(actions->labelsAction);
|
|
|
|
|
|
|
|
addToolBar(Qt::TopToolBarArea, guidesToolBar);
|
|
|
|
|
|
|
|
// Give keyboard focus to the 3D view
|
|
|
|
glWidget->setFocus();
|
|
|
|
|
2008-04-19 17:15:22 -06:00
|
|
|
m_bookmarkManager = new BookmarkManager(this);
|
|
|
|
|
|
|
|
// Load the bookmarks file and nitialize the bookmarks menu
|
|
|
|
if (!loadBookmarks())
|
|
|
|
m_bookmarkManager->initializeBookmarks();
|
|
|
|
populateBookmarkMenu();
|
|
|
|
connect(m_bookmarkManager, SIGNAL(bookmarkTriggered(const QString&)),
|
|
|
|
this, SLOT(slotBookmarkTriggered(const QString&)));
|
2018-03-11 07:12:58 -06:00
|
|
|
|
2008-04-21 17:06:14 -06:00
|
|
|
m_bookmarkToolBar = new BookmarkToolBar(m_bookmarkManager, this);
|
2018-03-11 07:12:58 -06:00
|
|
|
m_bookmarkToolBar->setObjectName("bookmark-toolbar");
|
2008-04-21 17:06:14 -06:00
|
|
|
m_bookmarkToolBar->rebuild();
|
|
|
|
addToolBar(Qt::TopToolBarArea, m_bookmarkToolBar);
|
2008-04-19 17:15:22 -06:00
|
|
|
|
2008-05-19 15:41:45 -06:00
|
|
|
// Read saved window preferences
|
|
|
|
readSettings();
|
2018-03-11 07:12:58 -06:00
|
|
|
|
2008-04-21 17:06:14 -06:00
|
|
|
// Build the view menu
|
|
|
|
// Add dockable panels and toolbars to the view menu
|
|
|
|
viewMenu->addAction(timeToolBar->toggleViewAction());
|
|
|
|
viewMenu->addAction(guidesToolBar->toggleViewAction());
|
|
|
|
viewMenu->addAction(m_bookmarkToolBar->toggleViewAction());
|
|
|
|
viewMenu->addSeparator();
|
|
|
|
viewMenu->addAction(toolsDock->toggleViewAction());
|
|
|
|
viewMenu->addAction(infoPanel->toggleViewAction());
|
|
|
|
viewMenu->addAction(eventFinder->toggleViewAction());
|
|
|
|
viewMenu->addSeparator();
|
2018-03-11 07:12:58 -06:00
|
|
|
|
2010-04-13 04:14:57 -06:00
|
|
|
QAction* fullScreenAction = new QAction(_("Full screen"), this);
|
2008-04-21 17:06:14 -06:00
|
|
|
fullScreenAction->setCheckable(true);
|
2010-04-13 04:14:57 -06:00
|
|
|
fullScreenAction->setShortcut(QString(_("Shift+F11")));
|
2008-04-21 17:06:14 -06:00
|
|
|
|
|
|
|
// Set the full screen check state only after reading settings
|
|
|
|
fullScreenAction->setChecked(isFullScreen());
|
2018-03-11 07:12:58 -06:00
|
|
|
|
2008-04-21 17:06:14 -06:00
|
|
|
connect(fullScreenAction, SIGNAL(triggered()), this, SLOT(slotToggleFullScreen()));
|
|
|
|
viewMenu->addAction(fullScreenAction);
|
2018-03-11 07:12:58 -06:00
|
|
|
|
2018-11-09 07:20:23 -07:00
|
|
|
// We use a timer to add m_appCore->tick to Qt's event loop
|
|
|
|
QObject::connect(timer, SIGNAL(timeout()), SLOT(celestia_tick()));
|
|
|
|
timer->start();
|
2008-02-08 10:22:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-04-19 17:15:22 -06:00
|
|
|
/*! Set up the application data directory, creating it if necessary. The
|
|
|
|
* directory contains user-specific, persistent information for Celestia
|
|
|
|
* (such as bookmarks) which aren't stored in settings. The location
|
|
|
|
* of the data directory depends on the platform:
|
|
|
|
*
|
2019-08-03 02:46:34 -06:00
|
|
|
* Win32: %LOCALAPPDATA%\Celestia
|
|
|
|
* Mac OS X: ~/Library/Application Support/Celestia
|
|
|
|
* Unix: $XDG_DATA_HOME/Celestia
|
|
|
|
*
|
|
|
|
* We don't use AppDataLocation because it returns Qt-specific location,
|
|
|
|
* e.g. "$XDG_DATA_HOME/Celestia Development Team/Celestia QT" while we
|
|
|
|
* should keep it compatible between all frontends.
|
2008-04-19 17:15:22 -06:00
|
|
|
*/
|
2019-08-03 02:46:34 -06:00
|
|
|
|
2008-04-19 17:15:22 -06:00
|
|
|
void CelestiaAppWindow::initAppDataDirectory()
|
|
|
|
{
|
2019-08-03 02:46:34 -06:00
|
|
|
auto dir = QDir(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation));
|
|
|
|
m_dataDirPath = dir.filePath("Celestia");
|
|
|
|
if (!QDir(m_dataDirPath).exists())
|
2008-04-19 17:15:22 -06:00
|
|
|
{
|
2019-08-03 02:46:34 -06:00
|
|
|
if (!dir.mkpath(m_dataDirPath))
|
2008-04-19 17:15:22 -06:00
|
|
|
{
|
2019-08-03 02:46:34 -06:00
|
|
|
// If the doesn't exist even after we tried to create it,
|
|
|
|
// give up on trying to load user data from there.
|
|
|
|
m_dataDirPath = "";
|
2008-04-19 17:15:22 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CelestiaAppWindow::readSettings()
|
|
|
|
{
|
|
|
|
QSettings settings;
|
|
|
|
|
|
|
|
settings.beginGroup("MainWindow");
|
2018-03-11 07:12:58 -06:00
|
|
|
|
2008-05-19 15:41:45 -06:00
|
|
|
QSize windowSize = settings.value("Size", DEFAULT_MAIN_WINDOW_SIZE).toSize();
|
|
|
|
QPoint windowPosition = settings.value("Pos", DEFAULT_MAIN_WINDOW_POSITION).toPoint();
|
2018-03-11 07:12:58 -06:00
|
|
|
|
2008-05-19 15:41:45 -06:00
|
|
|
// Make sure that the saved size fits on screen; it's possible for the previous saved
|
|
|
|
// position to be off-screen if the monitor settings have changed.
|
|
|
|
bool onScreen = false;
|
2019-11-19 10:57:22 -07:00
|
|
|
foreach (const QScreen *screen, QGuiApplication::screens())
|
2008-05-19 15:41:45 -06:00
|
|
|
{
|
2019-11-19 10:57:22 -07:00
|
|
|
if (screen->geometry().contains(windowPosition))
|
2008-05-19 15:41:45 -06:00
|
|
|
onScreen = true;
|
|
|
|
}
|
2018-03-11 07:12:58 -06:00
|
|
|
|
2008-05-19 15:41:45 -06:00
|
|
|
if (!onScreen)
|
|
|
|
{
|
|
|
|
windowPosition = DEFAULT_MAIN_WINDOW_POSITION;
|
|
|
|
windowSize = DEFAULT_MAIN_WINDOW_SIZE;
|
|
|
|
}
|
2018-03-11 07:12:58 -06:00
|
|
|
|
2008-05-19 15:41:45 -06:00
|
|
|
resize(windowSize);
|
|
|
|
move(windowPosition);
|
2008-04-19 17:15:22 -06:00
|
|
|
if (settings.contains("State"))
|
|
|
|
restoreState(settings.value("State").toByteArray(), CELESTIA_MAIN_WINDOW_VERSION);
|
|
|
|
if (settings.value("Fullscreen", false).toBool())
|
|
|
|
showFullScreen();
|
2018-03-11 07:12:58 -06:00
|
|
|
|
2008-04-19 17:15:22 -06:00
|
|
|
settings.endGroup();
|
|
|
|
|
2018-11-16 02:06:23 -07:00
|
|
|
setFPS(settings.value("fps", 0).toInt());
|
2018-11-09 07:20:23 -07:00
|
|
|
|
2008-04-19 17:15:22 -06:00
|
|
|
// Render settings read in qtglwidget
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-08 10:22:41 -07:00
|
|
|
void CelestiaAppWindow::writeSettings()
|
|
|
|
{
|
|
|
|
QSettings settings;
|
|
|
|
|
|
|
|
settings.beginGroup("MainWindow");
|
|
|
|
if (isFullScreen())
|
|
|
|
{
|
|
|
|
// Save the normal size, not the fullscreen size; fullscreen will
|
|
|
|
// be restored automatically.
|
|
|
|
settings.setValue("Size", normalGeometry().size());
|
|
|
|
settings.setValue("Pos", normalGeometry().topLeft());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
settings.setValue("Size", size());
|
|
|
|
settings.setValue("Pos", pos());
|
|
|
|
}
|
|
|
|
settings.setValue("State", saveState(CELESTIA_MAIN_WINDOW_VERSION));
|
|
|
|
settings.setValue("Fullscreen", isFullScreen());
|
|
|
|
settings.endGroup();
|
|
|
|
|
|
|
|
// Renderer settings
|
2008-04-19 17:15:22 -06:00
|
|
|
Renderer* renderer = m_appCore->getRenderer();
|
2018-11-13 13:31:07 -07:00
|
|
|
settings.setValue("RenderFlags", static_cast<quint64>(renderer->getRenderFlags()));
|
2008-02-08 10:22:41 -07:00
|
|
|
settings.setValue("OrbitMask", renderer->getOrbitMask());
|
|
|
|
settings.setValue("LabelMode", renderer->getLabelMode());
|
|
|
|
settings.setValue("AmbientLightLevel", renderer->getAmbientLightLevel());
|
|
|
|
settings.setValue("StarStyle", renderer->getStarStyle());
|
2019-06-18 05:20:01 -06:00
|
|
|
#ifdef USE_GLCONTEXT
|
2008-02-08 10:22:41 -07:00
|
|
|
settings.setValue("RenderPath", (int) renderer->getGLContext()->getRenderPath());
|
2019-06-18 05:20:01 -06:00
|
|
|
#endif
|
2008-02-08 10:22:41 -07:00
|
|
|
settings.setValue("TextureResolution", renderer->getResolution());
|
2017-03-04 07:18:23 -07:00
|
|
|
ColorTableType colorsst;
|
|
|
|
const ColorTemperatureTable* current = renderer->getStarColorTable();
|
|
|
|
|
|
|
|
if (current == GetStarColorTable(ColorTable_Blackbody_D65))
|
|
|
|
colorsst = ColorTable_Blackbody_D65;
|
|
|
|
else // if (current == GetStarColorTable(ColorTable_Enhanced))
|
|
|
|
colorsst = ColorTable_Enhanced;
|
|
|
|
settings.setValue("StarsColor", colorsst);
|
2008-02-08 10:22:41 -07:00
|
|
|
|
2008-04-19 17:15:22 -06:00
|
|
|
Simulation* simulation = m_appCore->getSimulation();
|
2017-03-04 07:18:23 -07:00
|
|
|
|
2008-02-08 10:22:41 -07:00
|
|
|
settings.beginGroup("Preferences");
|
2017-03-04 07:18:23 -07:00
|
|
|
settings.setValue("VisualMagnitude", simulation->getFaintestVisible());
|
2008-02-08 10:22:41 -07:00
|
|
|
settings.setValue("SyncTime", simulation->getSyncTime());
|
2008-04-19 17:15:22 -06:00
|
|
|
settings.setValue("FramesVisible", m_appCore->getFramesVisible());
|
|
|
|
settings.setValue("ActiveFrameVisible", m_appCore->getActiveFrameVisible());
|
2008-04-12 14:54:28 -06:00
|
|
|
|
|
|
|
// TODO: This is not a reliable way determine when local time is enabled, but it's
|
|
|
|
// all that CelestiaCore offers right now. useLocalTime won't ever be true when the system
|
|
|
|
// time zone is UTC+0. This could be a problem when switching to/from daylight saving
|
|
|
|
// time.
|
2008-04-19 17:15:22 -06:00
|
|
|
bool useLocalTime = m_appCore->getTimeZoneBias() != 0;
|
2008-04-12 14:54:28 -06:00
|
|
|
settings.setValue("LocalTime", useLocalTime);
|
2018-10-28 06:41:27 -06:00
|
|
|
settings.setValue("TimeZoneName", QString::fromStdString(m_appCore->getTimeZoneName()));
|
2008-02-08 10:22:41 -07:00
|
|
|
settings.endGroup();
|
2018-11-09 07:20:23 -07:00
|
|
|
|
|
|
|
settings.setValue("fps", ms_to_fps(timer->interval()));
|
2008-02-08 10:22:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-04-19 17:15:22 -06:00
|
|
|
bool CelestiaAppWindow::loadBookmarks()
|
2008-02-08 10:22:41 -07:00
|
|
|
{
|
2008-04-19 17:15:22 -06:00
|
|
|
bool loadedBookmarks = false;
|
|
|
|
QString bookmarksFilePath = QDir(m_dataDirPath).filePath(BOOKMARKS_FILE);
|
2018-10-05 10:44:36 -06:00
|
|
|
if (QFile::exists(bookmarksFilePath))
|
2008-04-19 17:15:22 -06:00
|
|
|
{
|
|
|
|
QFile bookmarksFile(bookmarksFilePath);
|
|
|
|
if (!bookmarksFile.open(QIODevice::ReadOnly))
|
|
|
|
{
|
2010-04-13 04:14:57 -06:00
|
|
|
QMessageBox::warning(this, _("Error opening bookmarks file"), bookmarksFile.errorString());
|
2008-04-19 17:15:22 -06:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
loadedBookmarks = m_bookmarkManager->loadBookmarks(&bookmarksFile);
|
|
|
|
bookmarksFile.close();
|
|
|
|
}
|
|
|
|
}
|
2008-02-08 10:22:41 -07:00
|
|
|
|
2008-04-19 17:15:22 -06:00
|
|
|
return loadedBookmarks;
|
|
|
|
}
|
2008-02-08 10:22:41 -07:00
|
|
|
|
2008-04-19 17:15:22 -06:00
|
|
|
|
|
|
|
void CelestiaAppWindow::saveBookmarks()
|
|
|
|
{
|
|
|
|
QString bookmarksFilePath = QDir(m_dataDirPath).filePath(BOOKMARKS_FILE);
|
|
|
|
QFile bookmarksFile(bookmarksFilePath);
|
|
|
|
if (!bookmarksFile.open(QIODevice::WriteOnly))
|
|
|
|
{
|
2010-04-13 04:14:57 -06:00
|
|
|
QMessageBox::warning(this, _("Error Saving Bookmarks"), bookmarksFile.errorString());
|
2008-04-19 17:15:22 -06:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_bookmarkManager->saveBookmarks(&bookmarksFile);
|
|
|
|
bookmarksFile.close();
|
|
|
|
}
|
2008-02-08 10:22:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CelestiaAppWindow::celestia_tick()
|
|
|
|
{
|
2008-04-19 17:15:22 -06:00
|
|
|
m_appCore->tick();
|
2018-10-31 12:32:14 -06:00
|
|
|
glWidget->updateGL();
|
2008-02-08 10:22:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CelestiaAppWindow::slotShowSelectionContextMenu(const QPoint& pos,
|
|
|
|
Selection& sel)
|
|
|
|
{
|
2008-04-19 17:15:22 -06:00
|
|
|
SelectionPopup* menu = new SelectionPopup(sel, m_appCore, this);
|
2008-02-08 10:22:41 -07:00
|
|
|
connect(menu, SIGNAL(selectionInfoRequested(Selection&)),
|
|
|
|
this, SLOT(slotShowObjectInfo(Selection&)));
|
|
|
|
menu->popupAtCenter(pos);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CelestiaAppWindow::slotGrabImage()
|
|
|
|
{
|
|
|
|
QString dir;
|
|
|
|
QSettings settings;
|
|
|
|
settings.beginGroup("Preferences");
|
|
|
|
if (settings.contains("GrabImageDir"))
|
|
|
|
dir = settings.value("GrabImageDir").toString();
|
|
|
|
else
|
|
|
|
dir = QDir::current().path();
|
|
|
|
|
|
|
|
QString saveAsName = QFileDialog::getSaveFileName(this,
|
2010-04-13 04:14:57 -06:00
|
|
|
_("Save Image"),
|
2008-02-08 10:22:41 -07:00
|
|
|
dir,
|
2010-04-13 04:14:57 -06:00
|
|
|
_("Images (*.png *.jpg)"));
|
2008-02-08 10:22:41 -07:00
|
|
|
|
|
|
|
if (!saveAsName.isEmpty())
|
|
|
|
{
|
2021-06-13 04:48:54 -06:00
|
|
|
m_appCore->saveScreenShot(saveAsName.toStdString());
|
2021-06-05 11:33:20 -06:00
|
|
|
settings.setValue("GrabImageDir", QFileInfo(saveAsName).absolutePath());
|
2008-02-08 10:22:41 -07:00
|
|
|
}
|
|
|
|
settings.endGroup();
|
|
|
|
}
|
|
|
|
|
2008-03-20 20:11:22 -06:00
|
|
|
|
2008-02-08 10:22:41 -07:00
|
|
|
void CelestiaAppWindow::slotCaptureVideo()
|
|
|
|
{
|
2018-12-24 13:14:22 -07:00
|
|
|
#ifdef USE_FFMPEG
|
2008-02-08 10:22:41 -07:00
|
|
|
QString dir;
|
|
|
|
QSettings settings;
|
|
|
|
settings.beginGroup("Preferences");
|
|
|
|
if (settings.contains("CaptureVideoDir"))
|
|
|
|
dir = settings.value("CaptureVideoDir").toString();
|
|
|
|
else
|
|
|
|
dir = QDir::current().path();
|
2018-12-24 13:14:22 -07:00
|
|
|
settings.endGroup();
|
|
|
|
|
2021-06-05 11:33:20 -06:00
|
|
|
QString saveAsName = QFileDialog::getSaveFileName(this,
|
|
|
|
_("Capture Video"),
|
|
|
|
dir,
|
|
|
|
_("Matroska Video (*.mkv)"));
|
2008-02-08 10:22:41 -07:00
|
|
|
|
2008-05-11 14:22:44 -06:00
|
|
|
if (!saveAsName.isEmpty())
|
|
|
|
{
|
2018-12-24 13:14:22 -07:00
|
|
|
#ifndef _WIN32
|
|
|
|
if (!saveAsName.endsWith(".mkv", Qt::CaseInsensitive))
|
|
|
|
saveAsName.append(".mkv");
|
|
|
|
#endif
|
|
|
|
|
2008-05-11 14:22:44 -06:00
|
|
|
QDialog videoInfoDialog(this);
|
2018-12-24 13:14:22 -07:00
|
|
|
videoInfoDialog.setWindowTitle(_("Capture Video"));
|
2008-05-11 14:22:44 -06:00
|
|
|
|
|
|
|
QGridLayout* layout = new QGridLayout(&videoInfoDialog);
|
|
|
|
|
|
|
|
QComboBox* resolutionCombo = new QComboBox(&videoInfoDialog);
|
2010-04-13 04:14:57 -06:00
|
|
|
layout->addWidget(new QLabel(_("Resolution:"), &videoInfoDialog), 0, 0);
|
2018-03-11 07:12:58 -06:00
|
|
|
layout->addWidget(resolutionCombo, 0, 1);
|
2021-05-25 10:07:36 -06:00
|
|
|
auto videoSizes = m_appCore->getSupportedMovieSizes();
|
2018-12-24 13:14:22 -07:00
|
|
|
for (const auto& size : videoSizes)
|
2021-05-25 10:07:36 -06:00
|
|
|
{
|
|
|
|
int w = size.width;
|
|
|
|
int h = size.height;
|
|
|
|
resolutionCombo->addItem(QString(_("%1 x %2")).arg(w).arg(h), QSize(w, h));
|
|
|
|
}
|
2018-03-11 07:12:58 -06:00
|
|
|
|
2008-05-11 14:22:44 -06:00
|
|
|
QComboBox* frameRateCombo = new QComboBox(&videoInfoDialog);
|
2010-04-13 04:14:57 -06:00
|
|
|
layout->addWidget(new QLabel(_("Frame rate:"), &videoInfoDialog), 1, 0);
|
2008-05-11 14:22:44 -06:00
|
|
|
layout->addWidget(frameRateCombo, 1, 1);
|
2021-05-25 10:07:36 -06:00
|
|
|
auto videoFrameRates = m_appCore->getSupportedMovieFramerates();
|
2018-12-24 13:14:22 -07:00
|
|
|
for (float i : videoFrameRates)
|
|
|
|
frameRateCombo->addItem(QString::number(i), i);
|
|
|
|
|
|
|
|
QComboBox* codecCombo = new QComboBox(&videoInfoDialog);
|
|
|
|
layout->addWidget(new QLabel(_("Video codec:"), &videoInfoDialog), 2, 0);
|
|
|
|
layout->addWidget(codecCombo, 2, 1);
|
2021-05-25 10:07:36 -06:00
|
|
|
auto videoCodecs = m_appCore->getSupportedMovieCodecs();
|
|
|
|
for (const auto &c : videoCodecs)
|
|
|
|
codecCombo->addItem(_(c.codecDescr), c.codecId);
|
2018-12-24 13:14:22 -07:00
|
|
|
|
|
|
|
QLineEdit* bitrateEdit = new QLineEdit("400000", &videoInfoDialog);
|
|
|
|
bitrateEdit->setInputMask("D000000000");
|
|
|
|
layout->addWidget(new QLabel(_("Bitrate:"), &videoInfoDialog), 3, 0);
|
|
|
|
layout->addWidget(bitrateEdit, 3, 1);
|
2008-05-11 14:22:44 -06:00
|
|
|
|
|
|
|
QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, &videoInfoDialog);
|
|
|
|
connect(buttons, SIGNAL(accepted()), &videoInfoDialog, SLOT(accept()));
|
|
|
|
connect(buttons, SIGNAL(rejected()), &videoInfoDialog, SLOT(reject()));
|
2018-12-24 13:14:22 -07:00
|
|
|
layout->addWidget(buttons, 4, 0, 1, 2);
|
2008-05-11 14:22:44 -06:00
|
|
|
|
|
|
|
videoInfoDialog.setLayout(layout);
|
|
|
|
|
|
|
|
if (videoInfoDialog.exec() == QDialog::Accepted)
|
|
|
|
{
|
|
|
|
QSize videoSize = resolutionCombo->itemData(resolutionCombo->currentIndex()).toSize();
|
2012-05-27 05:04:07 -06:00
|
|
|
float frameRate = frameRateCombo->itemData(frameRateCombo->currentIndex()).toFloat();
|
2021-05-25 10:07:36 -06:00
|
|
|
int codec = codecCombo->itemData(codecCombo->currentIndex()).toInt();
|
|
|
|
int64_t bitrate = bitrateEdit->text().toLongLong();
|
|
|
|
|
|
|
|
m_appCore->initMovieCapture(saveAsName.toStdString(),
|
|
|
|
videoSize.width(), videoSize.height(),
|
|
|
|
frameRate, bitrate, codec);
|
2008-05-11 14:22:44 -06:00
|
|
|
}
|
2008-10-13 22:47:19 -06:00
|
|
|
|
2018-12-24 13:14:22 -07:00
|
|
|
settings.beginGroup("Preferences");
|
2008-10-13 22:47:19 -06:00
|
|
|
settings.setValue("CaptureVideoDir", QFileInfo(saveAsName).absolutePath());
|
2018-12-24 13:14:22 -07:00
|
|
|
settings.endGroup();
|
2008-05-11 14:22:44 -06:00
|
|
|
}
|
2012-05-27 05:04:07 -06:00
|
|
|
#endif
|
2008-02-08 10:22:41 -07:00
|
|
|
}
|
|
|
|
|
2021-06-13 04:48:54 -06:00
|
|
|
static QImage::Format toQFormat(PixelFormat format)
|
|
|
|
{
|
|
|
|
switch (format)
|
|
|
|
{
|
|
|
|
case PixelFormat::RGB:
|
|
|
|
return QImage::Format_RGB888;
|
|
|
|
case PixelFormat::RGBA:
|
|
|
|
return QImage::Format_RGBA8888;
|
|
|
|
default:
|
|
|
|
return QImage::Format_Invalid;
|
|
|
|
}
|
|
|
|
}
|
2008-03-20 20:11:22 -06:00
|
|
|
|
|
|
|
void CelestiaAppWindow::slotCopyImage()
|
|
|
|
{
|
|
|
|
//glWidget->repaint();
|
2021-06-13 04:48:54 -06:00
|
|
|
Image image = m_appCore->captureImage();
|
|
|
|
QImage grabbedImage = QImage(image.getPixels(),
|
|
|
|
image.getWidth(),
|
|
|
|
image.getHeight(),
|
|
|
|
image.getPitch(),
|
|
|
|
toQFormat(image.getFormat()));
|
2008-03-20 20:11:22 -06:00
|
|
|
QApplication::clipboard()->setImage(grabbedImage);
|
2021-06-13 04:48:54 -06:00
|
|
|
m_appCore->flash(_("Captured screen shot to clipboard"));
|
2008-03-20 20:11:22 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CelestiaAppWindow::slotCopyURL()
|
|
|
|
{
|
2021-03-02 11:10:18 -07:00
|
|
|
CelestiaState appState(m_appCore);
|
|
|
|
appState.captureState();
|
2018-03-11 07:12:58 -06:00
|
|
|
|
2021-03-02 11:10:18 -07:00
|
|
|
Url url(appState);
|
2008-03-20 20:11:22 -06:00
|
|
|
QApplication::clipboard()->setText(url.getAsString().c_str());
|
2020-03-06 06:18:40 -07:00
|
|
|
m_appCore->flash(_("Copied URL"));
|
2008-03-20 20:11:22 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CelestiaAppWindow::slotPasteURL()
|
|
|
|
{
|
|
|
|
QString urlText = QApplication::clipboard()->text();
|
|
|
|
if (!urlText.isEmpty())
|
|
|
|
{
|
2020-03-06 06:18:40 -07:00
|
|
|
if (m_appCore->goToUrl(urlText.toStdString()))
|
|
|
|
m_appCore->flash(_("Pasting URL"));
|
2008-03-20 20:11:22 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-04-19 17:15:22 -06:00
|
|
|
/*! Cel: URL handler (called from QDesktopServices openURL)
|
|
|
|
*/
|
|
|
|
void CelestiaAppWindow::handleCelUrl(const QUrl& url)
|
|
|
|
{
|
|
|
|
QString urlText = url.toString();
|
|
|
|
if (!urlText.isEmpty())
|
|
|
|
{
|
2018-11-05 12:31:19 -07:00
|
|
|
m_appCore->goToUrl(urlText.toStdString());
|
2008-04-19 17:15:22 -06:00
|
|
|
}
|
|
|
|
}
|
2018-03-11 07:12:58 -06:00
|
|
|
|
2008-04-19 17:15:22 -06:00
|
|
|
|
2008-02-08 10:22:41 -07:00
|
|
|
void CelestiaAppWindow::selectSun()
|
|
|
|
{
|
2008-04-19 17:15:22 -06:00
|
|
|
m_appCore->charEntered("h");
|
2008-02-08 10:22:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CelestiaAppWindow::centerSelection()
|
|
|
|
{
|
2008-04-19 17:15:22 -06:00
|
|
|
m_appCore->charEntered("c");
|
2008-02-08 10:22:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CelestiaAppWindow::gotoSelection()
|
|
|
|
{
|
2008-04-19 17:15:22 -06:00
|
|
|
m_appCore->charEntered("g");
|
2008-02-08 10:22:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-11-27 10:39:07 -07:00
|
|
|
void CelestiaAppWindow::gotoObject()
|
|
|
|
{
|
|
|
|
GoToObjectDialog dlg(this, m_appCore);
|
|
|
|
dlg.exec();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-08 10:22:41 -07:00
|
|
|
void CelestiaAppWindow::slotPreferences()
|
|
|
|
{
|
2008-05-19 15:41:45 -06:00
|
|
|
PreferencesDialog dlg(this, m_appCore);
|
|
|
|
dlg.exec();
|
2008-05-11 14:22:44 -06:00
|
|
|
#if 0
|
2018-09-22 07:13:49 -06:00
|
|
|
if (m_preferencesDialog == nullptr)
|
2008-05-11 14:22:44 -06:00
|
|
|
{
|
|
|
|
m_preferencesDialog = new PreferencesDialog(this, m_appCore);
|
|
|
|
}
|
|
|
|
|
|
|
|
m_preferencesDialog->syncState();
|
2008-02-08 10:22:41 -07:00
|
|
|
|
2008-05-11 14:22:44 -06:00
|
|
|
m_preferencesDialog->show();
|
|
|
|
#endif
|
2008-02-08 10:22:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void CelestiaAppWindow::slotSplitViewVertically()
|
|
|
|
{
|
2008-04-19 17:15:22 -06:00
|
|
|
m_appCore->charEntered('\025');
|
2008-02-08 10:22:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void CelestiaAppWindow::slotSplitViewHorizontally()
|
|
|
|
{
|
2008-04-19 17:15:22 -06:00
|
|
|
m_appCore->charEntered('\022');
|
2008-02-08 10:22:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void CelestiaAppWindow::slotCycleView()
|
|
|
|
{
|
2008-04-19 17:15:22 -06:00
|
|
|
m_appCore->charEntered('\011');
|
2008-02-08 10:22:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void CelestiaAppWindow::slotSingleView()
|
|
|
|
{
|
2008-04-19 17:15:22 -06:00
|
|
|
m_appCore->charEntered('\004');
|
2008-02-08 10:22:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void CelestiaAppWindow::slotDeleteView()
|
|
|
|
{
|
2008-04-19 17:15:22 -06:00
|
|
|
m_appCore->charEntered(127);
|
2008-02-08 10:22:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void CelestiaAppWindow::slotToggleFramesVisible()
|
|
|
|
{
|
2008-04-19 17:15:22 -06:00
|
|
|
m_appCore->setFramesVisible(!m_appCore->getFramesVisible());
|
2008-02-08 10:22:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void CelestiaAppWindow::slotToggleActiveFrameVisible()
|
|
|
|
{
|
2008-04-19 17:15:22 -06:00
|
|
|
m_appCore->setActiveFrameVisible(!m_appCore->getActiveFrameVisible());
|
2008-02-08 10:22:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void CelestiaAppWindow::slotToggleSyncTime()
|
|
|
|
{
|
2008-04-19 17:15:22 -06:00
|
|
|
m_appCore->getSimulation()->setSyncTime(!m_appCore->getSimulation()->getSyncTime());
|
2008-02-08 10:22:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CelestiaAppWindow::slotShowObjectInfo(Selection& sel)
|
|
|
|
{
|
|
|
|
infoPanel->buildInfoPage(sel,
|
2008-04-19 17:15:22 -06:00
|
|
|
m_appCore->getSimulation()->getUniverse(),
|
|
|
|
m_appCore->getSimulation()->getTime());
|
2008-02-08 10:22:41 -07:00
|
|
|
if (!infoPanel->isVisible())
|
|
|
|
infoPanel->setVisible(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CelestiaAppWindow::slotOpenScriptDialog()
|
|
|
|
{
|
2008-05-12 16:32:10 -06:00
|
|
|
QString dir;
|
|
|
|
QSettings settings;
|
|
|
|
settings.beginGroup("Preferences");
|
|
|
|
if (settings.contains("OpenScriptDir"))
|
|
|
|
{
|
|
|
|
dir = settings.value("OpenScriptDir").toString();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dir = "scripts";
|
|
|
|
}
|
|
|
|
|
2008-02-08 10:22:41 -07:00
|
|
|
QString scriptFileName = QFileDialog::getOpenFileName(this,
|
2010-04-13 04:14:57 -06:00
|
|
|
_("Open Script"),
|
2008-05-12 16:32:10 -06:00
|
|
|
dir,
|
2010-04-13 04:14:57 -06:00
|
|
|
_("Celestia Scripts (*.celx *.cel)"));
|
2008-02-08 10:22:41 -07:00
|
|
|
|
|
|
|
if (!scriptFileName.isEmpty())
|
|
|
|
{
|
2008-04-19 17:15:22 -06:00
|
|
|
m_appCore->cancelScript();
|
2018-11-05 12:31:19 -07:00
|
|
|
m_appCore->runScript(scriptFileName.toStdString());
|
2008-05-12 16:32:10 -06:00
|
|
|
|
|
|
|
QFileInfo scriptFile(scriptFileName);
|
|
|
|
settings.setValue("OpenScriptDir", scriptFile.absolutePath());
|
2008-02-08 10:22:41 -07:00
|
|
|
}
|
2008-05-12 16:32:10 -06:00
|
|
|
|
|
|
|
settings.endGroup();
|
2008-02-08 10:22:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CelestiaAppWindow::slotOpenScript()
|
|
|
|
{
|
|
|
|
QAction* action = qobject_cast<QAction*>(sender());
|
2018-09-22 07:13:49 -06:00
|
|
|
if (action != nullptr)
|
2008-02-08 10:22:41 -07:00
|
|
|
{
|
2008-04-19 17:15:22 -06:00
|
|
|
m_appCore->cancelScript();
|
2018-11-05 12:31:19 -07:00
|
|
|
m_appCore->runScript(action->data().toString().toStdString());
|
2008-02-08 10:22:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-04-19 17:15:22 -06:00
|
|
|
void CelestiaAppWindow::slotShowTimeDialog()
|
|
|
|
{
|
|
|
|
SetTimeDialog* timeDialog = new SetTimeDialog(m_appCore->getSimulation()->getTime(),
|
2008-04-22 16:39:22 -06:00
|
|
|
this, m_appCore);
|
2008-04-19 17:15:22 -06:00
|
|
|
|
2010-04-13 04:14:57 -06:00
|
|
|
timeDialog->show();
|
2008-04-19 17:15:22 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-08 10:22:41 -07:00
|
|
|
void CelestiaAppWindow::slotToggleFullScreen()
|
|
|
|
{
|
|
|
|
if (isFullScreen())
|
|
|
|
showNormal();
|
|
|
|
else
|
|
|
|
showFullScreen();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-04-19 17:15:22 -06:00
|
|
|
void CelestiaAppWindow::slotAddBookmark()
|
|
|
|
{
|
|
|
|
// Set the default bookmark title to the name of the current selection
|
|
|
|
Selection sel = m_appCore->getSimulation()->getSelection();
|
2008-04-22 05:46:34 -06:00
|
|
|
QString defaultTitle;
|
2008-04-22 14:57:12 -06:00
|
|
|
|
2018-09-22 07:13:49 -06:00
|
|
|
if (sel.body() != nullptr)
|
2008-04-22 14:57:12 -06:00
|
|
|
{
|
2018-10-28 06:41:27 -06:00
|
|
|
defaultTitle = QString::fromStdString(sel.body()->getName(true));
|
2008-04-22 14:57:12 -06:00
|
|
|
}
|
2018-09-22 07:13:49 -06:00
|
|
|
else if (sel.star() != nullptr)
|
2008-04-22 14:57:12 -06:00
|
|
|
{
|
|
|
|
Universe* universe = m_appCore->getSimulation()->getUniverse();
|
2018-10-28 06:41:27 -06:00
|
|
|
defaultTitle = QString::fromStdString(ReplaceGreekLetterAbbr(universe->getStarCatalog()->getStarName(*sel.star(), true)));
|
2008-04-22 14:57:12 -06:00
|
|
|
}
|
2018-09-22 07:13:49 -06:00
|
|
|
else if (sel.deepsky() != nullptr)
|
2008-04-22 14:57:12 -06:00
|
|
|
{
|
|
|
|
Universe* universe = m_appCore->getSimulation()->getUniverse();
|
2018-10-28 06:41:27 -06:00
|
|
|
defaultTitle = QString::fromStdString(ReplaceGreekLetterAbbr(universe->getDSOCatalog()->getDSOName(sel.deepsky(), true)));
|
2008-04-22 14:57:12 -06:00
|
|
|
}
|
2018-09-22 07:13:49 -06:00
|
|
|
else if (sel.location() != nullptr)
|
2008-04-22 14:57:12 -06:00
|
|
|
{
|
|
|
|
defaultTitle = sel.location()->getName().c_str();
|
|
|
|
}
|
2018-03-11 07:12:58 -06:00
|
|
|
|
2008-04-22 14:57:12 -06:00
|
|
|
if (defaultTitle.isEmpty())
|
2010-04-13 04:14:57 -06:00
|
|
|
defaultTitle = _("New bookmark");
|
2008-04-22 14:57:12 -06:00
|
|
|
|
2021-03-02 11:10:18 -07:00
|
|
|
CelestiaState appState(m_appCore);
|
|
|
|
appState.captureState();
|
2018-03-11 07:12:58 -06:00
|
|
|
|
2008-04-22 05:46:34 -06:00
|
|
|
// Capture the current frame buffer to use as a bookmark icon.
|
2018-10-31 12:32:14 -06:00
|
|
|
QImage grabbedImage = glWidget->grabFrameBuffer();
|
2008-04-22 05:46:34 -06:00
|
|
|
int width = grabbedImage.width();
|
|
|
|
int height = grabbedImage.height();
|
|
|
|
|
|
|
|
// Crop the image to a square.
|
|
|
|
QImage iconImage;
|
|
|
|
if (width > height)
|
|
|
|
iconImage = grabbedImage.copy((width - height) / 2, 0, height, height);
|
|
|
|
else
|
|
|
|
iconImage = grabbedImage.copy(0, (height - width) / 2, width, width);
|
|
|
|
|
2008-05-05 13:09:31 -06:00
|
|
|
AddBookmarkDialog dialog(m_bookmarkManager, defaultTitle, appState, iconImage);
|
2008-04-19 17:15:22 -06:00
|
|
|
dialog.exec();
|
|
|
|
|
|
|
|
populateBookmarkMenu();
|
2008-04-21 17:06:14 -06:00
|
|
|
m_bookmarkToolBar->rebuild();
|
2008-04-19 17:15:22 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CelestiaAppWindow::slotOrganizeBookmarks()
|
|
|
|
{
|
|
|
|
OrganizeBookmarksDialog dialog(m_bookmarkManager);
|
|
|
|
dialog.exec();
|
|
|
|
|
|
|
|
populateBookmarkMenu();
|
2008-04-21 17:06:14 -06:00
|
|
|
m_bookmarkToolBar->rebuild();
|
2008-04-19 17:15:22 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CelestiaAppWindow::slotBookmarkTriggered(const QString& url)
|
|
|
|
{
|
|
|
|
QDesktopServices::openUrl(QUrl(url));
|
|
|
|
}
|
|
|
|
|
2016-12-20 11:05:47 -07:00
|
|
|
|
2016-12-07 05:50:07 -07:00
|
|
|
void CelestiaAppWindow::slotManual()
|
|
|
|
{
|
2019-06-04 03:56:11 -06:00
|
|
|
#if 0
|
2016-12-07 05:50:07 -07:00
|
|
|
QString MANUAL_FILE = "CelestiaGuide.html";
|
|
|
|
QDesktopServices::openUrl(QUrl(QUrl::fromLocalFile(QDir::toNativeSeparators(QApplication::applicationDirPath()) + QDir::toNativeSeparators(QDir::separator()) + "help" + QDir::toNativeSeparators(QDir::separator()) + MANUAL_FILE)));
|
2019-06-04 03:56:11 -06:00
|
|
|
#else
|
|
|
|
QDesktopServices::openUrl(QUrl("https://en.wikibooks.org/wiki/Celestia"));
|
|
|
|
#endif
|
2016-12-07 05:50:07 -07:00
|
|
|
}
|
2008-04-19 17:15:22 -06:00
|
|
|
|
2016-12-20 11:05:47 -07:00
|
|
|
|
2008-02-08 10:22:41 -07:00
|
|
|
void CelestiaAppWindow::slotShowAbout()
|
|
|
|
{
|
2019-08-27 15:19:36 -06:00
|
|
|
const char* aboutText = gettext_noop(
|
|
|
|
"<html>"
|
|
|
|
"<h1>Celestia 1.7</h1>"
|
|
|
|
"<p>Development snapshot, commit <b>%1</b>.</p>"
|
|
|
|
|
|
|
|
"<p>Built for %2 bit CPU<br>"
|
|
|
|
"Using %3 %4<br>"
|
|
|
|
"Built against Qt library: %5<br>"
|
2021-05-10 13:37:37 -06:00
|
|
|
"NAIF kernels are %7<br>"
|
2019-08-27 15:19:36 -06:00
|
|
|
"Runtime Qt version: %6</p>"
|
|
|
|
|
2021-05-07 09:47:18 -06:00
|
|
|
"<p>Copyright (C) 2001-2021 by the Celestia Development Team.<br>"
|
2019-08-27 15:19:36 -06:00
|
|
|
"Celestia 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.</p>"
|
|
|
|
|
|
|
|
"<p>Main site: <a href=\"https://celestia.space/\">"
|
|
|
|
"https://celestia.space/</a><br>"
|
|
|
|
"Forum: <a href=\"https://celestia.space/forum/\">"
|
|
|
|
"https://celestia.space/forum/</a><br>"
|
|
|
|
"GitHub project: <a href=\"https://github.com/CelestiaProject/Celestia\">"
|
|
|
|
"https://github.com/CelestiaProject/Celestia</a></p>"
|
|
|
|
"</html>"
|
|
|
|
);
|
|
|
|
|
|
|
|
auto qAboutText = QString(_(aboutText))
|
|
|
|
.arg(GIT_COMMIT)
|
|
|
|
.arg(QSysInfo::WordSize)
|
|
|
|
#if defined(_MSC_VER)
|
|
|
|
.arg("MSVC").arg(_MSC_FULL_VER)
|
|
|
|
#elif defined(__clang_version__)
|
|
|
|
.arg("Clang").arg(__clang_version__)
|
|
|
|
#elif defined(__GNUC__)
|
|
|
|
.arg("GNU GCC").arg(__VERSION__)
|
|
|
|
#else
|
|
|
|
.arg(_("Unknown compiler")).arg("")
|
|
|
|
#endif
|
|
|
|
.arg(QT_VERSION_STR, qVersion())
|
|
|
|
#if defined(USE_SPICE)
|
|
|
|
.arg(_("supported"))
|
|
|
|
#else
|
|
|
|
.arg(_("not supported"))
|
|
|
|
#endif
|
|
|
|
;
|
|
|
|
QMessageBox::about(this, _("About Celestia"), qAboutText);
|
2008-02-08 10:22:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-03-16 22:11:33 -06:00
|
|
|
/*! Show a dialog box with information about the OpenGL driver and hardware.
|
|
|
|
*/
|
|
|
|
void CelestiaAppWindow::slotShowGLInfo()
|
|
|
|
{
|
|
|
|
QString infoText;
|
|
|
|
QTextStream out(&infoText, QIODevice::WriteOnly);
|
|
|
|
|
2019-05-25 12:39:46 -06:00
|
|
|
map<string, string> info;
|
|
|
|
m_appCore->getRenderer()->getInfo(info);
|
|
|
|
|
2008-03-16 22:11:33 -06:00
|
|
|
// Get the version string
|
2018-08-10 12:55:56 -06:00
|
|
|
// QTextStream::operator<<(const char *string) assumes that the string has
|
|
|
|
// ISO-8859-1 encoding, so we need to convert in to QString
|
2019-05-25 12:39:46 -06:00
|
|
|
if (info.count("API") > 0 && info.count("APIVersion") > 0)
|
|
|
|
{
|
|
|
|
out << QString(_("<b>%1 version:</b> %2")).arg(info["API"].c_str(), info["APIVersion"].c_str());
|
|
|
|
out << "<br>\n";
|
|
|
|
}
|
2008-03-16 22:11:33 -06:00
|
|
|
|
2019-05-25 12:39:46 -06:00
|
|
|
if (info.count("Vendor") > 0)
|
|
|
|
{
|
2021-05-04 00:09:26 -06:00
|
|
|
out << QString(_("<b>Vendor:</b> %1")).arg(info["Vendor"].c_str());
|
2019-05-25 12:39:46 -06:00
|
|
|
out << "<br>\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (info.count("Renderer") > 0)
|
|
|
|
{
|
|
|
|
out << QString(_("<b>Renderer:</b> %1")).arg(info["Renderer"].c_str());
|
|
|
|
out << "<br>\n";
|
|
|
|
}
|
2008-03-16 22:11:33 -06:00
|
|
|
|
|
|
|
// shading language version
|
2019-05-25 12:39:46 -06:00
|
|
|
if (info.count("Language") > 0)
|
|
|
|
{
|
|
|
|
out << QString(_("<b>%1 Version:</b> %2")).arg(info["Language"].c_str(), info["LanguageVersion"].c_str());
|
|
|
|
out << "<br>\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
// textures
|
|
|
|
if (info.count("MaxTextureUnits") > 0)
|
|
|
|
{
|
|
|
|
out << QString(_("<b>Max simultaneous textures:</b> %1")).arg(info["MaxTextureUnits"].c_str());
|
|
|
|
out << "<br>\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (info.count("MaxTextureSize") > 0)
|
|
|
|
{
|
|
|
|
out << QString(_("<b>Maximum texture size:</b> %1")).arg(info["MaxTextureSize"].c_str());
|
|
|
|
out << "<br>\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (info.count("PointSizeMax") > 0 && info.count("PointSizeMin") > 0)
|
|
|
|
{
|
2021-05-04 00:09:26 -06:00
|
|
|
out << QString(_("<b>Point size range:</b> %1 - %2")).arg(info["PointSizeMin"].c_str(), info["PointSizeMax"].c_str());
|
2019-05-25 12:39:46 -06:00
|
|
|
out << "<br>\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (info.count("PointSizeGran") > 0)
|
|
|
|
{
|
2021-05-04 00:09:26 -06:00
|
|
|
out << QString(_("<b>Point size granularity:</b> %1")).arg(info["PointSizeGran"].c_str());
|
2019-05-25 12:39:46 -06:00
|
|
|
out << "<br>\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (info.count("MaxCubeMapSize") > 0)
|
2008-03-16 22:11:33 -06:00
|
|
|
{
|
2021-05-04 00:09:26 -06:00
|
|
|
out << QString(_("<b>Max cube map size:</b> %1")).arg(info["MaxCubeMapSize"].c_str());
|
2019-05-25 12:39:46 -06:00
|
|
|
out << "<br>\n";
|
2008-03-16 22:11:33 -06:00
|
|
|
}
|
|
|
|
|
2020-04-15 12:04:01 -06:00
|
|
|
if (info.count("MaxVaryingFloats") > 0)
|
|
|
|
{
|
2021-05-04 00:09:26 -06:00
|
|
|
out << QString(_("<b>Number of interpolators:</b> %1")).arg(info["MaxVaryingFloats"].c_str());
|
2020-04-15 12:04:01 -06:00
|
|
|
out << "<br>\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (info.count("MaxAnisotropy") > 0)
|
|
|
|
{
|
2021-05-04 00:09:26 -06:00
|
|
|
out << QString(_("<b>Max anisotropy filtering:</b> %1")).arg(info["MaxAnisotropy"].c_str());
|
2020-04-15 12:04:01 -06:00
|
|
|
out << "<br>\n";
|
|
|
|
}
|
|
|
|
|
2008-03-16 22:11:33 -06:00
|
|
|
|
|
|
|
out << "<br>\n";
|
|
|
|
|
|
|
|
// Show all supported extensions
|
2019-05-25 12:39:46 -06:00
|
|
|
if (info.count("Extensions") > 0)
|
2008-03-16 22:11:33 -06:00
|
|
|
{
|
2019-05-25 12:39:46 -06:00
|
|
|
out << QString(_("<b>Supported extensions:</b><br>\n"));
|
|
|
|
auto ext = info["Extensions"];
|
|
|
|
string::size_type old = 0, pos = ext.find(' ');
|
|
|
|
while (pos != string::npos)
|
2008-03-16 22:11:33 -06:00
|
|
|
{
|
2019-05-25 12:39:46 -06:00
|
|
|
out << ext.substr(old, pos - old).c_str() << "<br>\n";
|
|
|
|
old = pos + 1;
|
|
|
|
pos = ext.find(' ', old);
|
2008-03-16 22:11:33 -06:00
|
|
|
}
|
2019-05-25 12:39:46 -06:00
|
|
|
out << ext.substr(old).c_str();
|
2008-03-16 22:11:33 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
QDialog glInfo(this);
|
2018-03-11 07:12:58 -06:00
|
|
|
|
2019-05-25 12:39:46 -06:00
|
|
|
glInfo.setWindowTitle(_("Renderer Info"));
|
2018-10-29 12:35:11 -06:00
|
|
|
|
2008-03-16 22:11:33 -06:00
|
|
|
QVBoxLayout* layout = new QVBoxLayout(&glInfo);
|
|
|
|
QTextEdit* textEdit = new QTextEdit(infoText, &glInfo);
|
|
|
|
layout->addWidget(textEdit);
|
|
|
|
|
|
|
|
QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok, Qt::Horizontal, &glInfo);
|
|
|
|
connect(buttons, SIGNAL(accepted()), &glInfo, SLOT(accept()));
|
|
|
|
layout->addWidget(buttons);
|
|
|
|
|
|
|
|
glInfo.setMinimumSize(QSize(300, 450));
|
|
|
|
glInfo.setLayout(layout);
|
|
|
|
|
|
|
|
glInfo.exec();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-08 10:22:41 -07:00
|
|
|
void CelestiaAppWindow::createActions()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void CelestiaAppWindow::createMenus()
|
|
|
|
{
|
|
|
|
/****** File menu ******/
|
2010-04-13 04:14:57 -06:00
|
|
|
fileMenu = menuBar()->addMenu(_("&File"));
|
2008-02-08 10:22:41 -07:00
|
|
|
|
2016-12-07 05:50:07 -07:00
|
|
|
QAction* grabImageAction = new QAction(QIcon(":/icons/grab-image.png"),
|
2010-04-13 04:14:57 -06:00
|
|
|
_("&Grab image"), this);
|
|
|
|
grabImageAction->setShortcut(QString(_("F10")));
|
2008-02-08 10:22:41 -07:00
|
|
|
connect(grabImageAction, SIGNAL(triggered()), this, SLOT(slotGrabImage()));
|
|
|
|
fileMenu->addAction(grabImageAction);
|
|
|
|
|
2016-12-07 05:50:07 -07:00
|
|
|
QAction* captureVideoAction = new QAction(QIcon(":/icons/capture-video.png"),
|
2010-04-13 04:14:57 -06:00
|
|
|
_("Capture &video"), this);
|
2018-12-24 13:14:22 -07:00
|
|
|
#ifndef USE_FFMPEG
|
2012-05-27 05:04:07 -06:00
|
|
|
captureVideoAction->setEnabled(false);
|
|
|
|
#endif
|
2017-02-04 03:54:54 -07:00
|
|
|
captureVideoAction->setShortcut(QString(_("Shift+F10")));
|
2008-02-08 10:22:41 -07:00
|
|
|
connect(captureVideoAction, SIGNAL(triggered()), this, SLOT(slotCaptureVideo()));
|
|
|
|
fileMenu->addAction(captureVideoAction);
|
|
|
|
|
2016-12-07 05:50:07 -07:00
|
|
|
QAction* copyImageAction = new QAction(QIcon(":/icons/picture_copy.png"), _("&Copy image"), this);
|
2010-04-13 04:14:57 -06:00
|
|
|
copyImageAction->setShortcut(QString(_("Ctrl+Shift+C")));
|
2008-03-20 20:11:22 -06:00
|
|
|
connect(copyImageAction, SIGNAL(triggered()), this, SLOT(slotCopyImage()));
|
|
|
|
fileMenu->addAction(copyImageAction);
|
|
|
|
|
2008-02-08 10:22:41 -07:00
|
|
|
fileMenu->addSeparator();
|
|
|
|
|
2016-12-07 05:50:07 -07:00
|
|
|
QAction* openScriptAction = new QAction(QIcon(":/icons/script2.png"), _("&Open Script..."), this);
|
2008-02-08 10:22:41 -07:00
|
|
|
connect(openScriptAction, SIGNAL(triggered()), this, SLOT(slotOpenScriptDialog()));
|
|
|
|
fileMenu->addAction(openScriptAction);
|
|
|
|
|
|
|
|
QMenu* scriptsMenu = buildScriptsMenu();
|
2018-09-22 07:13:49 -06:00
|
|
|
if (scriptsMenu != nullptr)
|
2008-02-08 10:22:41 -07:00
|
|
|
fileMenu->addMenu(scriptsMenu);
|
|
|
|
|
|
|
|
fileMenu->addSeparator();
|
|
|
|
|
2016-12-07 05:50:07 -07:00
|
|
|
QAction* prefAct = new QAction(QIcon(":/icons/preferences.png"),
|
2010-04-13 04:14:57 -06:00
|
|
|
_("&Preferences..."), this);
|
2008-02-08 10:22:41 -07:00
|
|
|
connect(prefAct, SIGNAL(triggered()), this, SLOT(slotPreferences()));
|
|
|
|
fileMenu->addAction(prefAct);
|
|
|
|
|
2016-12-07 05:50:07 -07:00
|
|
|
QAction* quitAct = new QAction(QIcon(":/icons/exit.png"), _("E&xit"), this);
|
2010-04-13 04:14:57 -06:00
|
|
|
quitAct->setShortcut(QString(_("Ctrl+Q")));
|
2008-02-08 10:22:41 -07:00
|
|
|
connect(quitAct, SIGNAL(triggered()), this, SLOT(close()));
|
|
|
|
fileMenu->addAction(quitAct);
|
|
|
|
|
|
|
|
/****** Navigation menu ******/
|
2010-04-13 04:14:57 -06:00
|
|
|
navMenu = menuBar()->addMenu(_("&Navigation"));
|
2008-02-08 10:22:41 -07:00
|
|
|
|
2016-12-07 05:50:07 -07:00
|
|
|
QAction* sunAct = new QAction(QIcon(":/icons/select_sol.png"), _("Select Sun"), this);
|
2008-02-08 10:22:41 -07:00
|
|
|
connect(sunAct, SIGNAL(triggered()), this, SLOT(selectSun()));
|
|
|
|
navMenu->addAction(sunAct);
|
|
|
|
|
2016-12-07 05:50:07 -07:00
|
|
|
QAction* centerAct = new QAction(QIcon(":/icons/center-obj.png"), _("Center Selection"), this);
|
2008-02-08 10:22:41 -07:00
|
|
|
connect(centerAct, SIGNAL(triggered()), this, SLOT(centerSelection()));
|
|
|
|
navMenu->addAction(centerAct);
|
|
|
|
|
2016-12-07 05:50:07 -07:00
|
|
|
QAction* gotoAct = new QAction(QIcon(":/icons/go-jump.png"), _("Goto Selection"), this);
|
2008-02-08 10:22:41 -07:00
|
|
|
connect(gotoAct, SIGNAL(triggered()), this, SLOT(gotoSelection()));
|
|
|
|
navMenu->addAction(gotoAct);
|
|
|
|
|
2018-11-27 10:39:07 -07:00
|
|
|
QAction* gotoObjAct = new QAction(QIcon(":/icons/go-jump.png"), _("Goto Object..."), this);
|
|
|
|
connect(gotoObjAct, SIGNAL(triggered()), this, SLOT(gotoObject()));
|
|
|
|
navMenu->addAction(gotoObjAct);
|
2008-02-08 10:22:41 -07:00
|
|
|
|
2019-09-02 12:17:56 -06:00
|
|
|
QAction *copyAction = new QAction(QIcon(":/icons/clip_copy.png"), _("Copy URL / console text"), this);
|
|
|
|
copyAction->setShortcut(QString("Ctrl+C"));
|
|
|
|
connect(copyAction, &QAction::triggered, this, &CelestiaAppWindow::copyTextOrURL);
|
2019-03-27 14:58:50 -06:00
|
|
|
navMenu->addAction(copyAction);
|
|
|
|
|
2019-09-02 12:17:56 -06:00
|
|
|
QAction *pasteAction = new QAction(QIcon(":/icons/clip_paste.png"), _("Paste URL / console text"), this);
|
|
|
|
pasteAction->setShortcut(QString("Ctrl+V"));
|
|
|
|
connect(pasteAction, &QAction::triggered, this, &CelestiaAppWindow::pasteTextOrURL);
|
2019-03-27 14:58:50 -06:00
|
|
|
navMenu->addAction(pasteAction);
|
|
|
|
|
2008-02-08 10:22:41 -07:00
|
|
|
/****** Time menu ******/
|
2010-04-13 04:14:57 -06:00
|
|
|
timeMenu = menuBar()->addMenu(_("&Time"));
|
2008-02-08 10:22:41 -07:00
|
|
|
|
2016-12-07 05:50:07 -07:00
|
|
|
QAction* setTimeAct = new QAction(QIcon(":/icons/set-time.png"), _("Set &time"), this);
|
2008-02-08 10:22:41 -07:00
|
|
|
connect(setTimeAct, SIGNAL(triggered()), this, SLOT(slotShowTimeDialog()));
|
|
|
|
timeMenu->addAction(setTimeAct);
|
|
|
|
|
2008-05-01 13:47:51 -06:00
|
|
|
timeMenu->addAction(actions->lightTimeDelayAction);
|
|
|
|
|
|
|
|
|
|
|
|
/****** Display menu ******/
|
2010-04-13 04:14:57 -06:00
|
|
|
displayMenu = menuBar()->addMenu(_("&Display"));
|
2008-05-01 13:47:51 -06:00
|
|
|
displayMenu->addAction(actions->atmospheresAction);
|
|
|
|
displayMenu->addAction(actions->cloudsAction);
|
|
|
|
displayMenu->addAction(actions->cometTailsAction);
|
|
|
|
displayMenu->addAction(actions->nightSideLightsAction);
|
|
|
|
|
2010-04-13 04:14:57 -06:00
|
|
|
QMenu* deepSkyMenu = displayMenu->addMenu(_("Dee&p Sky Objects"));
|
2008-05-01 13:47:51 -06:00
|
|
|
deepSkyMenu->addAction(actions->galaxiesAction);
|
2008-09-22 14:47:33 -06:00
|
|
|
deepSkyMenu->addAction(actions->globularsAction);
|
|
|
|
deepSkyMenu->addAction(actions->openClustersAction);
|
2008-05-01 13:47:51 -06:00
|
|
|
deepSkyMenu->addAction(actions->nebulaeAction);
|
|
|
|
|
2010-04-13 04:14:57 -06:00
|
|
|
QMenu* shadowMenu = displayMenu->addMenu(_("&Shadows"));
|
2008-05-01 13:47:51 -06:00
|
|
|
shadowMenu->addAction(actions->ringShadowsAction);
|
|
|
|
shadowMenu->addAction(actions->eclipseShadowsAction);
|
|
|
|
shadowMenu->addAction(actions->cloudShadowsAction);
|
|
|
|
|
|
|
|
displayMenu->addSeparator();
|
|
|
|
|
|
|
|
displayMenu->addAction(actions->increaseLimitingMagAction);
|
|
|
|
displayMenu->addAction(actions->decreaseLimitingMagAction);
|
|
|
|
displayMenu->addAction(actions->autoMagAction);
|
|
|
|
|
2010-04-13 04:14:57 -06:00
|
|
|
QMenu* starStyleMenu = displayMenu->addMenu(_("Star St&yle"));
|
2008-05-01 13:47:51 -06:00
|
|
|
starStyleMenu->addAction(actions->pointStarAction);
|
|
|
|
starStyleMenu->addAction(actions->fuzzyPointStarAction);
|
|
|
|
starStyleMenu->addAction(actions->scaledDiscStarAction);
|
|
|
|
|
2008-10-14 20:07:36 -06:00
|
|
|
displayMenu->addSeparator();
|
|
|
|
|
2010-04-13 04:14:57 -06:00
|
|
|
QMenu* textureResolutionMenu = displayMenu->addMenu(_("Texture &Resolution"));
|
2008-10-14 20:07:36 -06:00
|
|
|
textureResolutionMenu->addAction(actions->lowResAction);
|
|
|
|
textureResolutionMenu->addAction(actions->mediumResAction);
|
|
|
|
textureResolutionMenu->addAction(actions->highResAction);
|
|
|
|
|
2018-11-15 01:09:14 -07:00
|
|
|
QMenu *fpsMenu = new QMenu(_("&FPS control"), this);
|
2018-11-09 07:20:23 -07:00
|
|
|
|
2018-11-16 02:06:23 -07:00
|
|
|
fpsActions = new FPSActionGroup(this);
|
|
|
|
for (const auto &a : fpsActions->actions())
|
2018-11-15 01:09:14 -07:00
|
|
|
{
|
2018-11-16 02:06:23 -07:00
|
|
|
QObject::connect(a.second, &QAction::triggered, this, &CelestiaAppWindow::setCheckedFPS);
|
|
|
|
fpsMenu->addAction(a.second);
|
2018-11-09 07:20:23 -07:00
|
|
|
}
|
2018-11-16 02:06:23 -07:00
|
|
|
QObject::connect(fpsActions->customAction(), &QAction::triggered, this, &CelestiaAppWindow::setCustomFPS);
|
|
|
|
fpsMenu->addAction(fpsActions->customAction());
|
2018-11-15 01:09:14 -07:00
|
|
|
#ifdef VIDEO_SYNC
|
|
|
|
fpsMenu->addSeparator();
|
|
|
|
fpsMenu->addAction(actions->toggleVSyncAction);
|
|
|
|
#endif
|
2018-11-09 07:20:23 -07:00
|
|
|
displayMenu->addMenu(fpsMenu);
|
|
|
|
|
2008-04-19 17:15:22 -06:00
|
|
|
/****** Bookmark menu ******/
|
2010-04-13 04:14:57 -06:00
|
|
|
bookmarkMenu = menuBar()->addMenu(_("&Bookmarks"));
|
2008-02-08 10:22:41 -07:00
|
|
|
|
|
|
|
/****** View menu ******/
|
2010-04-13 04:14:57 -06:00
|
|
|
viewMenu = menuBar()->addMenu(_("&View"));
|
2008-02-08 10:22:41 -07:00
|
|
|
|
|
|
|
/****** MultiView menu ******/
|
2010-04-13 04:14:57 -06:00
|
|
|
QMenu* multiviewMenu = menuBar()->addMenu(_("&MultiView"));
|
2008-02-08 10:22:41 -07:00
|
|
|
|
2016-12-07 05:50:07 -07:00
|
|
|
QAction* splitViewVertAction = new QAction(QIcon(":/icons/split-vert.png"),
|
2010-04-13 04:14:57 -06:00
|
|
|
_("Split view vertically"), this);
|
|
|
|
splitViewVertAction->setShortcut(QString(_("Ctrl+R")));
|
2008-02-08 10:22:41 -07:00
|
|
|
connect(splitViewVertAction, SIGNAL(triggered()), this, SLOT(slotSplitViewVertically()));
|
|
|
|
multiviewMenu->addAction(splitViewVertAction);
|
|
|
|
|
2016-12-07 05:50:07 -07:00
|
|
|
QAction* splitViewHorizAction = new QAction(QIcon(":/icons/split-horiz.png"),
|
2010-04-13 04:14:57 -06:00
|
|
|
_("Split view horizontally"), this);
|
|
|
|
splitViewHorizAction->setShortcut(QString(_("Ctrl+U")));
|
2008-02-08 10:22:41 -07:00
|
|
|
connect(splitViewHorizAction, SIGNAL(triggered()), this, SLOT(slotSplitViewHorizontally()));
|
|
|
|
multiviewMenu->addAction(splitViewHorizAction);
|
|
|
|
|
2016-12-07 05:50:07 -07:00
|
|
|
QAction* cycleViewAction = new QAction(QIcon(":/icons/split-cycle.png"),
|
2010-04-13 04:14:57 -06:00
|
|
|
_("Cycle views"), this);
|
|
|
|
cycleViewAction->setShortcut(QString(_("Tab")));
|
2008-02-08 10:22:41 -07:00
|
|
|
connect(cycleViewAction, SIGNAL(triggered()), this, SLOT(slotCycleView()));
|
|
|
|
multiviewMenu->addAction(cycleViewAction);
|
|
|
|
|
2016-12-07 05:50:07 -07:00
|
|
|
QAction* singleViewAction = new QAction(QIcon(":/icons/split-single.png"),
|
2010-04-13 04:14:57 -06:00
|
|
|
_("Single view"), this);
|
|
|
|
singleViewAction->setShortcut(QString(_("Ctrl+D")));
|
2008-02-08 10:22:41 -07:00
|
|
|
connect(singleViewAction, SIGNAL(triggered()), this, SLOT(slotSingleView()));
|
|
|
|
multiviewMenu->addAction(singleViewAction);
|
|
|
|
|
2016-12-07 05:50:07 -07:00
|
|
|
QAction* deleteViewAction = new QAction(QIcon(":/icons/split-delete.png"),
|
2010-04-13 04:14:57 -06:00
|
|
|
_("Delete view"), this);
|
|
|
|
deleteViewAction->setShortcut(QString(_("Delete")));
|
2008-02-08 10:22:41 -07:00
|
|
|
connect(deleteViewAction, SIGNAL(triggered()), this, SLOT(slotDeleteView()));
|
|
|
|
multiviewMenu->addAction(deleteViewAction);
|
|
|
|
|
|
|
|
multiviewMenu->addSeparator();
|
|
|
|
|
2010-04-13 04:14:57 -06:00
|
|
|
QAction* framesVisibleAction = new QAction(_("Frames visible"), this);
|
2008-02-08 10:22:41 -07:00
|
|
|
framesVisibleAction->setCheckable(true);
|
|
|
|
connect(framesVisibleAction, SIGNAL(triggered()), this, SLOT(slotToggleFramesVisible()));
|
|
|
|
multiviewMenu->addAction(framesVisibleAction);
|
|
|
|
|
|
|
|
// The toggle actions below shall have their settings saved:
|
|
|
|
bool check;
|
|
|
|
QSettings settings;
|
|
|
|
settings.beginGroup("Preferences");
|
2018-10-29 13:13:43 -06:00
|
|
|
|
2008-02-08 10:22:41 -07:00
|
|
|
if (settings.contains("FramesVisible"))
|
|
|
|
{
|
|
|
|
check = settings.value("FramesVisible").toBool();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-04-19 17:15:22 -06:00
|
|
|
check = m_appCore->getFramesVisible();
|
2008-02-08 10:22:41 -07:00
|
|
|
}
|
|
|
|
framesVisibleAction->setChecked(check);
|
2008-04-19 17:15:22 -06:00
|
|
|
m_appCore->setFramesVisible(check);
|
2008-02-08 10:22:41 -07:00
|
|
|
|
2010-04-13 04:14:57 -06:00
|
|
|
QAction* activeFrameVisibleAction = new QAction(_("Active frame visible"), this);
|
2008-02-08 10:22:41 -07:00
|
|
|
activeFrameVisibleAction->setCheckable(true);
|
|
|
|
connect(activeFrameVisibleAction, SIGNAL(triggered()), this, SLOT(slotToggleActiveFrameVisible()));
|
|
|
|
multiviewMenu->addAction(activeFrameVisibleAction);
|
|
|
|
|
|
|
|
if (settings.contains("ActiveFrameVisible"))
|
|
|
|
{
|
|
|
|
check = settings.value("ActiveFrameVisible").toBool();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-04-19 17:15:22 -06:00
|
|
|
check = m_appCore->getActiveFrameVisible();
|
2008-02-08 10:22:41 -07:00
|
|
|
}
|
|
|
|
activeFrameVisibleAction->setChecked(check);
|
2008-04-19 17:15:22 -06:00
|
|
|
m_appCore->setActiveFrameVisible(check);
|
2008-02-08 10:22:41 -07:00
|
|
|
|
2010-04-13 04:14:57 -06:00
|
|
|
QAction* syncTimeAction = new QAction(_("Synchronize time"), this);
|
2008-02-08 10:22:41 -07:00
|
|
|
syncTimeAction->setCheckable(true);
|
|
|
|
connect(syncTimeAction, SIGNAL(triggered()), this, SLOT(slotToggleSyncTime()));
|
|
|
|
multiviewMenu->addAction(syncTimeAction);
|
|
|
|
|
|
|
|
if (settings.contains("SyncTime"))
|
|
|
|
{
|
|
|
|
check = settings.value("SyncTime").toBool();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-04-19 17:15:22 -06:00
|
|
|
check = m_appCore->getSimulation()->getSyncTime();
|
2008-02-08 10:22:41 -07:00
|
|
|
}
|
|
|
|
syncTimeAction->setChecked(check);
|
2008-04-19 17:15:22 -06:00
|
|
|
m_appCore->getSimulation()->setSyncTime(check);
|
2008-02-08 10:22:41 -07:00
|
|
|
|
2008-04-12 14:54:28 -06:00
|
|
|
// Set up the default time zone name and offset from UTC
|
2020-01-24 13:50:42 -07:00
|
|
|
m_appCore->start();
|
2008-04-12 14:54:28 -06:00
|
|
|
|
2020-01-24 13:50:42 -07:00
|
|
|
string tzName;
|
|
|
|
int dstBias;
|
|
|
|
if (GetTZInfo(tzName, dstBias))
|
2018-09-22 08:34:26 -06:00
|
|
|
{
|
2020-01-24 13:50:42 -07:00
|
|
|
m_appCore->setTimeZoneName(tzName);
|
|
|
|
m_appCore->setTimeZoneBias(dstBias);
|
2018-09-22 08:34:26 -06:00
|
|
|
}
|
2008-04-12 14:54:28 -06:00
|
|
|
|
|
|
|
// If LocalTime is set to false, set the time zone bias to zero.
|
|
|
|
if (settings.contains("LocalTime"))
|
|
|
|
{
|
|
|
|
bool useLocalTime = settings.value("LocalTime").toBool();
|
|
|
|
if (!useLocalTime)
|
2008-04-19 17:15:22 -06:00
|
|
|
m_appCore->setTimeZoneBias(0);
|
2008-04-12 14:54:28 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
if (settings.contains("TimeZoneName"))
|
|
|
|
{
|
2018-11-05 12:31:19 -07:00
|
|
|
m_appCore->setTimeZoneName(settings.value("TimeZoneName").toString().toStdString());
|
2008-04-12 14:54:28 -06:00
|
|
|
}
|
|
|
|
|
2018-03-11 07:12:58 -06:00
|
|
|
/****** Help Menu ******/
|
2010-04-13 04:14:57 -06:00
|
|
|
helpMenu = menuBar()->addMenu(_("&Help"));
|
2008-02-08 10:22:41 -07:00
|
|
|
|
2018-05-08 08:10:32 -06:00
|
|
|
QAction* helpManualAct = new QAction(QIcon(":/icons/book.png"), _("Celestia Manual"), this);
|
2016-12-07 05:50:07 -07:00
|
|
|
connect(helpManualAct, SIGNAL(triggered()), this, SLOT(slotManual()));
|
|
|
|
helpMenu->addAction(helpManualAct);
|
2008-03-16 22:11:33 -06:00
|
|
|
helpMenu->addSeparator();
|
2018-03-11 07:12:58 -06:00
|
|
|
|
2016-12-07 05:50:07 -07:00
|
|
|
QAction* glInfoAct = new QAction(QIcon(":/icons/report_GL.png"), _("OpenGL Info"), this);
|
2008-03-16 22:11:33 -06:00
|
|
|
connect(glInfoAct, SIGNAL(triggered()), this, SLOT(slotShowGLInfo()));
|
|
|
|
helpMenu->addAction(glInfoAct);
|
2018-03-11 07:12:58 -06:00
|
|
|
|
2016-12-07 05:50:07 -07:00
|
|
|
QAction* aboutAct = new QAction(QIcon(":/icons/about.png"), _("About Celestia"), this);
|
|
|
|
connect(aboutAct, SIGNAL(triggered()), this, SLOT(slotShowAbout()));
|
|
|
|
helpMenu->addAction(aboutAct);
|
2008-02-08 10:22:41 -07:00
|
|
|
|
|
|
|
settings.endGroup();
|
|
|
|
}
|
|
|
|
|
2008-04-19 17:15:22 -06:00
|
|
|
|
|
|
|
/*! Rebuild the Bookmarks menu. This method needs to be called after the
|
|
|
|
* bookmarks file is loaded and whenever the bookmarks lists is changed
|
|
|
|
* (add bookmarks or organize bookmarks.)
|
|
|
|
*/
|
|
|
|
void CelestiaAppWindow::populateBookmarkMenu()
|
|
|
|
{
|
|
|
|
bookmarkMenu->clear();
|
2018-03-11 07:12:58 -06:00
|
|
|
|
2016-12-07 05:50:07 -07:00
|
|
|
QAction* addBookmarkAction = new QAction(QIcon(":/icons/bookmark-add.png"), _("Add Bookmark..."), bookmarkMenu);
|
2008-04-19 17:15:22 -06:00
|
|
|
bookmarkMenu->addAction(addBookmarkAction);
|
|
|
|
connect(addBookmarkAction, SIGNAL(triggered()), this, SLOT(slotAddBookmark()));
|
2018-03-11 07:12:58 -06:00
|
|
|
|
2016-12-07 05:50:07 -07:00
|
|
|
QAction* organizeBookmarksAction = new QAction(QIcon(":/icons/application-bookmark.png"), _("Organize Bookmarks..."), bookmarkMenu);
|
2008-04-19 17:15:22 -06:00
|
|
|
bookmarkMenu->addAction(organizeBookmarksAction);
|
|
|
|
connect(organizeBookmarksAction, SIGNAL(triggered()), this, SLOT(slotOrganizeBookmarks()));
|
2018-03-11 07:12:58 -06:00
|
|
|
|
2008-04-19 17:15:22 -06:00
|
|
|
bookmarkMenu->addSeparator();
|
|
|
|
|
|
|
|
m_bookmarkManager->populateBookmarkMenu(bookmarkMenu);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-08 10:22:41 -07:00
|
|
|
void CelestiaAppWindow::closeEvent(QCloseEvent* event)
|
|
|
|
{
|
|
|
|
writeSettings();
|
2008-04-19 17:15:22 -06:00
|
|
|
saveBookmarks();
|
|
|
|
|
2008-02-08 10:22:41 -07:00
|
|
|
event->accept();
|
|
|
|
}
|
|
|
|
|
2018-11-15 01:09:14 -07:00
|
|
|
void CelestiaAppWindow::setCheckedFPS()
|
2018-11-09 07:20:23 -07:00
|
|
|
{
|
|
|
|
QAction *act = qobject_cast<QAction*>(sender());
|
|
|
|
if (act)
|
|
|
|
{
|
2018-11-15 01:09:14 -07:00
|
|
|
int fps = act->data().toInt();
|
2018-11-16 02:06:23 -07:00
|
|
|
setFPS(fps);
|
2018-11-09 07:20:23 -07:00
|
|
|
}
|
2018-11-15 01:09:14 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void CelestiaAppWindow::setFPS(int fps)
|
|
|
|
{
|
2018-11-09 07:20:23 -07:00
|
|
|
timer->setInterval(fps_to_ms(fps));
|
2018-11-16 02:06:23 -07:00
|
|
|
fpsActions->updateFPS(fps);
|
2018-11-09 07:20:23 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void CelestiaAppWindow::setCustomFPS()
|
|
|
|
{
|
|
|
|
bool ok;
|
2018-11-16 02:06:23 -07:00
|
|
|
int fps = QInputDialog::getInt(this,
|
|
|
|
_("Set custom FPS"),
|
|
|
|
_("FPS value"),
|
|
|
|
ms_to_fps(timer->interval()),
|
|
|
|
0, 2048, 1, &ok);
|
|
|
|
if (ok)
|
|
|
|
setFPS(fps);
|
|
|
|
else
|
|
|
|
fpsActions->updateFPS(fpsActions->lastFPS());
|
2018-11-09 07:20:23 -07:00
|
|
|
}
|
|
|
|
|
2019-08-25 00:19:04 -06:00
|
|
|
void CelestiaAppWindow::requestContextMenu(float x, float y, Selection sel)
|
2008-02-08 10:22:41 -07:00
|
|
|
{
|
2021-05-15 09:06:35 -06:00
|
|
|
float scale = devicePixelRatioF();
|
2008-04-19 17:15:22 -06:00
|
|
|
SelectionPopup* menu = new SelectionPopup(sel, m_appCore, this);
|
2008-02-08 10:22:41 -07:00
|
|
|
connect(menu, SIGNAL(selectionInfoRequested(Selection&)),
|
|
|
|
this, SLOT(slotShowObjectInfo(Selection&)));
|
2021-05-15 09:06:35 -06:00
|
|
|
menu->popupAtCenter(centralWidget()->mapToGlobal(QPoint((int)(x / scale), (int)(y / scale))));
|
2008-02-08 10:22:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CelestiaAppWindow::loadingProgressUpdate(const QString& s)
|
|
|
|
{
|
2018-10-13 16:11:01 -06:00
|
|
|
emit progressUpdate(QString(_("Loading data files: %1\n\n")).arg(s),
|
|
|
|
Qt::AlignHCenter | Qt::AlignBottom, Qt::white);
|
2008-02-08 10:22:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QMenu* CelestiaAppWindow::buildScriptsMenu()
|
|
|
|
{
|
|
|
|
vector<ScriptMenuItem>* scripts = ScanScriptsDirectory("scripts", false);
|
|
|
|
if (scripts->empty())
|
2018-09-22 07:13:49 -06:00
|
|
|
return nullptr;
|
2008-02-08 10:22:41 -07:00
|
|
|
|
2010-04-13 04:14:57 -06:00
|
|
|
QMenu* menu = new QMenu(_("Scripts"));
|
2018-03-11 07:12:58 -06:00
|
|
|
|
2018-09-22 07:13:49 -06:00
|
|
|
for (const auto& script : *scripts)
|
2008-02-08 10:22:41 -07:00
|
|
|
{
|
2018-09-22 07:13:49 -06:00
|
|
|
QAction* act = new QAction(script.title.c_str(), this);
|
2019-08-15 13:21:22 -06:00
|
|
|
act->setData(script.filename.string().c_str());
|
2008-02-08 10:22:41 -07:00
|
|
|
connect(act, SIGNAL(triggered()), this, SLOT(slotOpenScript()));
|
|
|
|
menu->addAction(act);
|
|
|
|
}
|
|
|
|
|
|
|
|
return menu;
|
|
|
|
}
|
|
|
|
|
2019-09-02 12:17:56 -06:00
|
|
|
void CelestiaAppWindow::copyText()
|
|
|
|
{
|
|
|
|
QString text(m_appCore->getTypedText().c_str());
|
|
|
|
if (!text.isEmpty())
|
|
|
|
QGuiApplication::clipboard()->setText(text);
|
|
|
|
}
|
|
|
|
|
2019-03-27 14:58:50 -06:00
|
|
|
void CelestiaAppWindow::pasteText()
|
|
|
|
{
|
|
|
|
QString text = QGuiApplication::clipboard()->text();
|
|
|
|
if (!text.isEmpty())
|
|
|
|
m_appCore->setTypedText(text.toUtf8().data());
|
|
|
|
}
|
|
|
|
|
2019-09-02 12:17:56 -06:00
|
|
|
void CelestiaAppWindow::copyTextOrURL()
|
2019-03-27 14:58:50 -06:00
|
|
|
{
|
2019-09-02 12:17:56 -06:00
|
|
|
if (m_appCore->getTextEnterMode()) // True when the search console is opened
|
|
|
|
copyText();
|
|
|
|
else
|
|
|
|
slotCopyURL();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CelestiaAppWindow::pasteTextOrURL()
|
|
|
|
{
|
|
|
|
if (m_appCore->getTextEnterMode()) // True when the search console is opened
|
|
|
|
pasteText();
|
|
|
|
else
|
|
|
|
slotPasteURL();
|
2019-03-27 14:58:50 -06:00
|
|
|
}
|