main.cpp   main.cpp 
skipping to change at line 20 skipping to change at line 20
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA.
*/ */
#include <config.h>
#include "StelMainWindow.hpp" #include "StelMainWindow.hpp"
#include "StelTranslator.hpp" #include "StelTranslator.hpp"
#include "StelLogger.hpp" #include "StelLogger.hpp"
#include "StelFileMgr.hpp" #include "StelFileMgr.hpp"
#include "CLIProcessor.hpp" #include "CLIProcessor.hpp"
#include "StelIniParser.hpp" #include "StelIniParser.hpp"
#include <QDebug> #include <QDebug>
#include <QApplication> #include <QApplication>
#include <QMessageBox> #include <QMessageBox>
#include <QTranslator> #include <QTranslator>
#include <QGLFormat> #include <QGLFormat>
#include <QPlastiqueStyle> #include <QPlastiqueStyle>
#include <QFileInfo> #include <QFileInfo>
#include <QtPlugin> #include <QFontDatabase>
#ifdef Q_OS_WIN
Q_IMPORT_PLUGIN(StelGui) #include <windows.h>
#endif //Q_OS_WIN
#ifdef USE_STATIC_PLUGIN_VIRGO
Q_IMPORT_PLUGIN(VirGO)
#endif
#ifdef USE_STATIC_PLUGIN_SVMT
Q_IMPORT_PLUGIN(SVMT)
#endif
#ifdef USE_STATIC_PLUGIN_HELLOSTELMODULE
Q_IMPORT_PLUGIN(HelloStelModule)
#endif
#ifdef USE_STATIC_PLUGIN_ANGLEMEASURE
Q_IMPORT_PLUGIN(AngleMeasure)
#endif
#ifdef USE_STATIC_PLUGIN_COMPASSMARKS
Q_IMPORT_PLUGIN(CompassMarks)
#endif
#ifdef USE_STATIC_PLUGIN_SATELLITES
Q_IMPORT_PLUGIN(Satellites)
#endif
#ifdef USE_STATIC_PLUGIN_TEXTUSERINTERFACE
Q_IMPORT_PLUGIN(TextUserInterface)
#endif
#ifdef USE_STATIC_PLUGIN_LOGBOOK
Q_IMPORT_PLUGIN(LogBook)
#endif
#ifdef USE_STATIC_PLUGIN_OCULARS
Q_IMPORT_PLUGIN(Oculars)
#endif
#ifdef USE_STATIC_PLUGIN_TELESCOPECONTROL
Q_IMPORT_PLUGIN(TelescopeControl)
#endif
//! @class GettextStelTranslator //! @class GettextStelTranslator
//! Provides i18n support through gettext. //! Provides i18n support through gettext.
class GettextStelTranslator : public QTranslator class GettextStelTranslator : public QTranslator
{ {
public: public:
virtual bool isEmpty() const { return false; } virtual bool isEmpty() const { return false; }
virtual QString translate(const char* context, const char* sourceTex t, const char* comment=0) const virtual QString translate(const char* context, const char* sourceTex t, const char* comment=0) const
{ {
Q_UNUSED(context);
Q_UNUSED(comment);
return q_(sourceText); return q_(sourceText);
} }
}; };
//! Copies the default configuration file. //! Copies the default configuration file.
//! This function copies the default_config.ini file to config.ini (or othe r //! This function copies the default_config.ini file to config.ini (or othe r
//! name specified on the command line located in the user data directory. //! name specified on the command line located in the user data directory.
void copyDefaultConfigFile(const QString& newPath) void copyDefaultConfigFile(const QString& newPath)
{ {
QString defaultConfigFilePath; QString defaultConfigFilePath;
skipping to change at line 117 skipping to change at line 79
if (!StelFileMgr::exists(newPath)) if (!StelFileMgr::exists(newPath))
{ {
qFatal("ERROR copyDefaultConfigFile failed to copy file %s to %s. You could try to copy it by hand.", qFatal("ERROR copyDefaultConfigFile failed to copy file %s to %s. You could try to copy it by hand.",
qPrintable(defaultConfigFilePath), qPrintable(newPat h)); qPrintable(defaultConfigFilePath), qPrintable(newPat h));
} }
} }
// Main stellarium procedure // Main stellarium procedure
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
#ifdef Q_OS_WIN
// Fix for the speeding system clock bug on systems that use ACPI
// See http://support.microsoft.com/kb/821893
UINT timerGrain = 1;
if (timeBeginPeriod(timerGrain) == TIMERR_NOCANDO)
{
// If this is too fine a grain, try the lowest value used by
a timer
timerGrain = 5;
if (timeBeginPeriod(timerGrain) == TIMERR_NOCANDO)
timerGrain = 0;
}
#endif
QCoreApplication::setApplicationName("stellarium"); QCoreApplication::setApplicationName("stellarium");
QCoreApplication::setApplicationVersion(StelUtils::getApplicationVer sion()); QCoreApplication::setApplicationVersion(StelUtils::getApplicationVer sion());
QCoreApplication::setOrganizationDomain("stellarium.org"); QCoreApplication::setOrganizationDomain("stellarium.org");
QCoreApplication::setOrganizationName("stellarium"); QCoreApplication::setOrganizationName("stellarium");
#ifndef USE_OPENGL_ES2 #ifndef BUILD_FOR_MAEMO
QApplication::setStyle(new QPlastiqueStyle()); QApplication::setStyle(new QPlastiqueStyle());
#endif #endif
// Used for getting system date formatting
setlocale(LC_TIME, "");
// We need scanf()/printf() and friends to always work in the C loca
le,
// otherwise configuration/INI file parsing will be erroneous.
setlocale(LC_NUMERIC, "C");
// Handle command line options for alternative Qt graphics system ty pes. // Handle command line options for alternative Qt graphics system ty pes.
// DEFAULT_GRAPHICS_SYSTEM is defined per platform in the main CMake Lists.txt file. // DEFAULT_GRAPHICS_SYSTEM is defined per platform in the main CMake Lists.txt file.
// Avoid overriding if the user already specified the mode on the CL I. // Avoid overriding if the user already specified the mode on the CL I.
bool doSetDefaultGraphicsSystem=true; bool doSetDefaultGraphicsSystem=true;
for (int i = 1; i < argc; ++i) for (int i = 1; i < argc; ++i)
{ {
//QApplication accepts -graphicssystem only if //QApplication accepts -graphicssystem only if
//its value is a separate argument (the next value in argv) //its value is a separate argument (the next value in argv)
if (QString(argv[i]) == "-graphicssystem") if (QString(argv[i]) == "-graphicssystem")
{ {
skipping to change at line 155 skipping to change at line 124
// If the user didn't set the graphics-system on the command line, u se the one provided at compile time. // If the user didn't set the graphics-system on the command line, u se the one provided at compile time.
if (doSetDefaultGraphicsSystem) if (doSetDefaultGraphicsSystem)
{ {
qDebug() << "Using default graphics system specified at buil d time: " << DEFAULT_GRAPHICS_SYSTEM; qDebug() << "Using default graphics system specified at buil d time: " << DEFAULT_GRAPHICS_SYSTEM;
QApplication::setGraphicsSystem(DEFAULT_GRAPHICS_SYSTEM); QApplication::setGraphicsSystem(DEFAULT_GRAPHICS_SYSTEM);
} }
// The QApplication MUST be created before the StelFileMgr is initia lized. // The QApplication MUST be created before the StelFileMgr is initia lized.
QApplication app(argc, argv); QApplication app(argc, argv);
// QApplication sets current locale, but
// we need scanf()/printf() and friends to always work in the C loca
le,
// otherwise configuration/INI file parsing will be erroneous.
setlocale(LC_NUMERIC, "C");
// Init the file manager // Init the file manager
StelFileMgr::init(); StelFileMgr::init();
// Start logging.
StelLogger::init(StelFileMgr::getUserDir()+"/log.txt");
// Log command line arguments // Log command line arguments
QString argStr; QString argStr;
QStringList argList; QStringList argList;
for (int i=0; i<argc; ++i) for (int i=0; i<argc; ++i)
{ {
argList << argv[i]; argList << argv[i];
argStr += QString("%1 ").arg(argv[i]); argStr += QString("%1 ").arg(argv[i]);
} }
StelLogger::writeLog(argStr);
// Parse for first set of CLI arguments - stuff we want to process b efore other // Parse for first set of CLI arguments - stuff we want to process b efore other
// output, such as --help and --version // output, such as --help and --version
CLIProcessor::parseCLIArgsPreConfig(argList); CLIProcessor::parseCLIArgsPreConfig(argList);
// Start logging.
StelLogger::init(StelFileMgr::getUserDir()+"/log.txt");
StelLogger::writeLog(argStr);
// OK we start the full program. // OK we start the full program.
// Print the console splash and get on with loading the program // Print the console splash and get on with loading the program
QString versionLine = QString("This is %1 - http://www.stellarium.or g").arg(StelUtils::getApplicationName()); QString versionLine = QString("This is %1 - http://www.stellarium.or g").arg(StelUtils::getApplicationName());
QString copyrightLine = QString("Copyright (C) 2000-2010 Fabien Cher eau et al"); QString copyrightLine = QString("Copyright (C) 2000-2010 Fabien Cher eau et al");
int maxLength = qMax(versionLine.size(), copyrightLine.size()); int maxLength = qMax(versionLine.size(), copyrightLine.size());
qDebug() << qPrintable(QString(" %1").arg(QString().fill('-', maxLen gth+2))); qDebug() << qPrintable(QString(" %1").arg(QString().fill('-', maxLen gth+2)));
qDebug() << qPrintable(QString("[ %1 ]").arg(versionLine.leftJustifi ed(maxLength, ' '))); qDebug() << qPrintable(QString("[ %1 ]").arg(versionLine.leftJustifi ed(maxLength, ' ')));
qDebug() << qPrintable(QString("[ %1 ]").arg(copyrightLine.leftJusti fied(maxLength, ' '))); qDebug() << qPrintable(QString("[ %1 ]").arg(copyrightLine.leftJusti fied(maxLength, ' ')));
qDebug() << qPrintable(QString(" %1").arg(QString().fill('-', maxLen gth+2))); qDebug() << qPrintable(QString(" %1").arg(QString().fill('-', maxLen gth+2)));
qDebug() << "Writing log file to:" << StelLogger::getLogFileName(); qDebug() << "Writing log file to:" << StelLogger::getLogFileName();
skipping to change at line 287 skipping to change at line 260
copyDefaultConfigFile(configFileFullPath); copyDefaultConfigFile(configFileFullPath);
confSettings = new QSettings(configFileFullPath, StelIniForm at); confSettings = new QSettings(configFileFullPath, StelIniForm at);
} }
Q_ASSERT(confSettings); Q_ASSERT(confSettings);
qDebug() << "Config file is: " << configFileFullPath; qDebug() << "Config file is: " << configFileFullPath;
// Override config file values from CLI. // Override config file values from CLI.
CLIProcessor::parseCLIArgsPostConfig(argList, confSettings); CLIProcessor::parseCLIArgsPostConfig(argList, confSettings);
if (confSettings->value("main/use_qpaintenginegl2", true).toBool()) bool safeMode = false;
if (confSettings->value("main/use_qpaintenginegl2", true).toBool() &
& !qApp->property("onetime_safe_mode").isValid())
{ {
// The default is to let Qt choose which paint engine fits t he best between OpenGL and OpenGL2. // The default is to let Qt choose which paint engine fits t he best between OpenGL and OpenGL2.
// However it causes troubles on some older hardware, so add an option. // However it causes troubles on some older hardware, so add an option.
} }
else else
{ {
// The user explicitely request to use the older paint engin e. // The user explicitely request to use the older paint engin e.
QGL::setPreferredPaintEngine(QPaintEngine::OpenGL); QGL::setPreferredPaintEngine(QPaintEngine::OpenGL);
safeMode = true;
} }
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
// On Leopard (10.5) + ppc architecture, text display is buggy if Op enGL2 Qt paint engine is used. // On Leopard (10.5) + ppc architecture, text display is buggy if Op enGL2 Qt paint engine is used.
if ((QSysInfo::MacintoshVersion == QSysInfo::MV_LEOPARD) && (QSysInf o::ByteOrder == QSysInfo::BigEndian)) if ((QSysInfo::MacintoshVersion == QSysInfo::MV_LEOPARD) && (QSysInf o::ByteOrder == QSysInfo::BigEndian))
QGL::setPreferredPaintEngine(QPaintEngine::OpenGL); QGL::setPreferredPaintEngine(QPaintEngine::OpenGL);
#endif #endif
// On maemo we'll use the standard OS font
#ifndef BUILD_FOR_MAEMO
// Add the DejaVu font that we use everywhere in the program
try
{
const QString& fName = StelFileMgr::findFile("data/DejaVuSan
s.ttf");
if (!fName.isEmpty())
QFontDatabase::addApplicationFont(fName);
}
catch (std::runtime_error& e)
{
// Removed this warning practically allowing to package the
program without the font file.
// This is useful for distribution having already a package
for DejaVu font.
// qWarning() << "ERROR while loading font DejaVuSans : " <<
e.what();
}
// Set the default application font and font size.
// Note that style sheet will possibly override this setting.
#ifdef Q_OS_WIN
// On windows use Verdana font, to avoid unresolved bug with OpenGL1
Qt paint engine.
// See Launchpad question #111823 for more info
QFont tmpFont(safeMode ? "Verdana" : "DejaVu Sans");
// Activate verdana by defaut for all win32 builds to see if it impr
oves things.
// -> this seems to bring crippled arabic fonts with OpenGL2 paint e
ngine..
// QFont tmpFont("Verdana");
#else
#ifdef Q_OS_MAC
QFont tmpFont("Verdana");
#else
QFont tmpFont("DejaVu Sans");
#endif
#endif
tmpFont.setPixelSize(13);
QApplication::setFont(tmpFont);
#endif
// Initialize translator feature // Initialize translator feature
try try
{ {
StelTranslator::init(StelFileMgr::findFile("data/iso639-1.ut f8")); StelTranslator::init(StelFileMgr::findFile("data/iso639-1.ut f8"));
} }
catch (std::runtime_error& e) catch (std::runtime_error& e)
{ {
qWarning() << "ERROR while loading translations: " << e.what () << endl; qWarning() << "ERROR while loading translations: " << e.what () << endl;
} }
// Use our gettext translator for Qt translations as well // Use our gettext translator for Qt translations as well
skipping to change at line 329 skipping to change at line 341
QMessageBox::warning(0, "Stellarium", q_("This system does n ot support OpenGL.")); QMessageBox::warning(0, "Stellarium", q_("This system does n ot support OpenGL."));
} }
StelMainWindow mainWin; StelMainWindow mainWin;
mainWin.init(confSettings); mainWin.init(confSettings);
app.exec(); app.exec();
mainWin.deinit(); mainWin.deinit();
delete confSettings; delete confSettings;
StelLogger::deinit(); StelLogger::deinit();
#ifdef Q_OS_WIN
if(timerGrain)
timeEndPeriod(timerGrain);
#endif //Q_OS_WIN
return 0; return 0;
} }
 End of changes. 14 change blocks. 
58 lines changed or deleted 85 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/