From 98130734c8026d603b050a2ec5bd7e4b6256d1bb Mon Sep 17 00:00:00 2001 From: Oliver Bock <oliver.bock@aei.mpg.de> Date: Fri, 6 Feb 2009 11:00:30 +0100 Subject: [PATCH] i18n preparations --- src/pulsaranimationwidget.cpp | 33 ++++++++++++++++++++++----------- src/pulsaranimationwidget.h | 1 + src/pulsatingscience.cpp | 29 +++++++++++++++++++---------- src/pulsescopewidget.cpp | 17 ++++++++++++----- src/pulsescopewidget.h | 1 + 5 files changed, 55 insertions(+), 26 deletions(-) diff --git a/src/pulsaranimationwidget.cpp b/src/pulsaranimationwidget.cpp index 6d4d2f0..7d982b7 100644 --- a/src/pulsaranimationwidget.cpp +++ b/src/pulsaranimationwidget.cpp @@ -27,20 +27,26 @@ PulsarAnimationWidget::PulsarAnimationWidget(QWidget *parent) : m_frameTimer(), m_pulseProfile(360, 0.0) { + QString msgThis = tr("3D animation"); if(!format().directRendering()) { - qWarning("Sorry, no direct rendering support for animation..."); + QString msg = tr("Sorry, no direct rendering support for %1..."); + qWarning() << msg.arg(msgThis); } if(!format().doubleBuffer()) { - qWarning("Sorry, no double buffering support for animation..."); + QString msg = tr("Sorry, no double buffering support for %1..."); + qWarning() << msg.arg(msgThis); } if(!format().rgba()) { - qWarning("Sorry, no RGBA support for animation..."); + QString msg = tr("Sorry, no RGBA support for %1..."); + qWarning() << msg.arg(msgThis); } if(!format().alpha()) { - qWarning("Sorry, no alpha channel support for animation..."); + QString msg = tr("Sorry, no alpha channel support for %1..."); + qWarning() << msg.arg(msgThis); } if(!format().sampleBuffers()) { - qWarning("Sorry, no multisampling support for animation..."); + QString msg = tr("Sorry, no multisampling support for %1..."); + qWarning() << msg.arg(msgThis); } // connect primary rendering timer to local callback @@ -168,39 +174,44 @@ void PulsarAnimationWidget::initializeGL() GLint maxTextureSize; glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize); + // prepare local messages + QString msgShape = tr("%1 texture shape not quadratic!"); + QString msgPower = tr("%1 texture dimensions not a power of 2!"); + QString msgSize = tr("Maximum texture size exceeded! Scaling down %1 texture to %2x%3..."); + // prepare and check pulsar texture QImage pulsarTexture(":/textures/resources/texture_pulsar.png"); if(pulsarTexture.width() != pulsarTexture.height()) { - qWarning("Warning: pulsar texture shape not quadratic!"); + qWarning() << msgShape.arg(tr("Pulsar")); } else { double integer = 0.0; double fraction = 0.0; fraction = modf(log(pulsarTexture.width()) / log(2.0), &integer); if(fraction > 0.0) { - qWarning("Warning: pulsar texture dimensions not a power of 2!"); + qWarning() << msgPower.arg(tr("Pulsar")); } } if(pulsarTexture.width() > maxTextureSize) { - qWarning("Warning: maximum texture size exceeded! Scaling down pulsar texture to %ix%i...", maxTextureSize, maxTextureSize); + qWarning() << msgSize.arg(tr("pulsar").arg(maxTextureSize).arg(maxTextureSize)); pulsarTexture = pulsarTexture.scaled(maxTextureSize, maxTextureSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); } // prepare and check background texture QImage backgroundTexture(":/textures/resources/texture_background_carina.jpg"); if(backgroundTexture.width() != backgroundTexture.height()) { - qWarning("Warning: invalid background texture shape!"); + qWarning() << msgShape.arg(tr("Background")); } else { double integer = 0.0; double fraction = 0.0; fraction = modf(log(backgroundTexture.width()) / log(2.0), &integer); if(fraction > 0.0) { - qWarning("Warning: background texture dimensions not a power of 2!"); + qWarning() << msgPower.arg(tr("Background")); } } if(backgroundTexture.width() > maxTextureSize) { - qWarning("Warning: maximum texture size exceeded! Scaling down background texture to %ix%i...", maxTextureSize, maxTextureSize); + qWarning() << msgSize.arg(tr("background").arg(maxTextureSize).arg(maxTextureSize)); backgroundTexture = backgroundTexture.scaled(maxTextureSize, maxTextureSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); } diff --git a/src/pulsaranimationwidget.h b/src/pulsaranimationwidget.h index cd7ee99..c060f1d 100644 --- a/src/pulsaranimationwidget.h +++ b/src/pulsaranimationwidget.h @@ -26,6 +26,7 @@ #include <QGLWidget> #include <QTimer> #include <QMouseEvent> +#include <QDebug> #define PI 3.14159265 diff --git a/src/pulsatingscience.cpp b/src/pulsatingscience.cpp index bb77ceb..81b3c19 100644 --- a/src/pulsatingscience.cpp +++ b/src/pulsatingscience.cpp @@ -25,7 +25,7 @@ PulsatingScience::PulsatingScience(QWidget *parent) : QMainWindow(parent) ui.setupUi(this); QAction* animControl = ui.dockAnimControl->toggleViewAction(); - animControl->setStatusTip("Toggle the animation control visibility"); + animControl->setStatusTip(tr("Toggle the animation control visibility")); animControl->setShortcut(QKeySequence(Qt::ALT + Qt::Key_A)); ui.menuView->addAction(animControl); @@ -350,15 +350,24 @@ void PulsatingScience::on_dockAnimControl_topLevelChanged(bool topLevel) { void PulsatingScience::on_actionAbout_activated() { - QMessageBox::about(this, "About", - "<b>Pulsating Science</b><br>" - "International Year of Astronomy 2009<br><br>" - "Authors: Oliver Bock, Benjamin Knispel<br><br>" - "Background image: The Carina Nebula<br>" - "(Courtesy of ESO/IDA/Danish 1.5 m/R.Gendler, J-E. Ovaldsen, C. Thöne and C. Feron)<br><br>" - "License: GNU General Public License (Version 3)<br><br>" - "Copyright © 2009 " - "<a href=\"http://www.aei.mpg.de\">Max-Planck-Institut für Gravitationsphysik</a>"); + QString content = "<b>%1</b><br>" + "%2<br><br>" + "%3: Oliver Bock, Benjamin Knispel<br><br>" + "%4<br>" + "(%5 ESO/IDA/Danish 1.5 m/R.Gendler, J-E. Ovaldsen, C. Thöne, C. Feron)<br><br>" + "%6: GNU General Public License (Version 3)<br><br>" + "Copyright © 2009 " + "<a href=\"http://www.aei.mpg.de\">Max-Planck-Institut für Gravitationsphysik</a>"; + + content = content.arg( + tr("Pulsating Science"), + tr("International Year of Astronomy 2009"), + tr("Authors"), + tr("Background image: The Carina Nebula"), + tr("Courtesy of"), + tr("License")); + + QMessageBox::about(this, tr("About \"Pulsating Science\""), content); } void PulsatingScience::updatePulsarSemiMajorAxisValue(double value) diff --git a/src/pulsescopewidget.cpp b/src/pulsescopewidget.cpp index e75bec9..c504b7a 100644 --- a/src/pulsescopewidget.cpp +++ b/src/pulsescopewidget.cpp @@ -26,20 +26,27 @@ PulseScopeWidget::PulseScopeWidget(QWidget *parent) : QGraphicsView(parent), { setViewport(new QGLWidget(QGLFormat(QGL::AlphaChannel | QGL::SampleBuffers))); QGLWidget *glScope = (QGLWidget*) viewport(); + + QString msgThis = tr("pulse profile"); if(!glScope->format().directRendering()) { - qWarning("Sorry, no direct rendering support for pulse scope..."); + QString msg = tr("Sorry, no direct rendering support for %1..."); + qWarning() << msg.arg(msgThis); } if(!glScope->format().doubleBuffer()) { - qWarning("Sorry, no double buffering support for pulse scope..."); + QString msg = tr("Sorry, no double buffering support for %1..."); + qWarning() << msg.arg(msgThis); } if(!glScope->format().rgba()) { - qWarning("Sorry, no RGBA support for pulse scope..."); + QString msg = tr("Sorry, no RGBA support for %1..."); + qWarning() << msg.arg(msgThis); } if(!glScope->format().alpha()) { - qWarning("Sorry, no alpha channel support for pulse scope..."); + QString msg = tr("Sorry, no alpha channel support for %1..."); + qWarning() << msg.arg(msgThis); } if(!glScope->format().sampleBuffers()) { - qWarning("Sorry, no multisampling support for pulse scope..."); + QString msg = tr("Sorry, no multisampling support for %1..."); + qWarning() << msg.arg(msgThis); } m_scopeSizeH = 360.0; diff --git a/src/pulsescopewidget.h b/src/pulsescopewidget.h index 267ef2f..88fc891 100644 --- a/src/pulsescopewidget.h +++ b/src/pulsescopewidget.h @@ -28,6 +28,7 @@ #include <QGLContext> #include <QGraphicsPathItem> #include <QGraphicsLineItem> +#include <QDebug> class PulseScopeWidget : public QGraphicsView -- GitLab