StelMainView.cpp   StelMainView.cpp 
skipping to change at line 27 skipping to change at line 27
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
*/ */
#include "StelMainView.hpp" #include "StelMainView.hpp"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
#include "StelFileMgr.hpp" #include "StelFileMgr.hpp"
#include "StelProjector.hpp" #include "StelProjector.hpp"
#include "StelModuleMgr.hpp" #include "StelModuleMgr.hpp"
#include "StelPainter.hpp" #include "StelPainter.hpp"
#include "StelGuiBase.hpp" #include "StelGui.hpp"
#include "StelTranslator.hpp" #include "StelTranslator.hpp"
#include "StelUtils.hpp" #include "StelUtils.hpp"
#include "StelActionMgr.hpp" #include "StelActionMgr.hpp"
#include "StelOpenGL.hpp" #include "StelOpenGL.hpp"
#include <QDeclarativeItem> #include <QDeclarativeItem>
#include <QDebug> #include <QDebug>
#include <QDir> #include <QDir>
#if STEL_USE_NEW_OPENGL_WIDGETS #if STEL_USE_NEW_OPENGL_WIDGETS
#include <QOpenGLWidget> #include <QOpenGLWidget>
#else #else
#include <QGLWidget> #include <QGLWidget>
#endif #endif
#include <QApplication>
#include <QDesktopWidget>
#include <QGuiApplication> #include <QGuiApplication>
#include <QFileInfo> #include <QFileInfo>
#include <QIcon> #include <QIcon>
#include <QMoveEvent> #include <QMoveEvent>
#include <QPluginLoader> #include <QPluginLoader>
#include <QScreen> #include <QScreen>
#include <QSettings> #include <QSettings>
#include <QtPlugin> #include <QtPlugin>
#include <QThread> #include <QThread>
#include <QTimer> #include <QTimer>
skipping to change at line 190 skipping to change at line 192
case QEvent::TouchUpdate: case QEvent::TouchUpdate:
case QEvent::TouchEnd: case QEvent::TouchEnd:
{ {
QTouchEvent *touchEvent = static_cast<QTouchEvent *>(e); QTouchEvent *touchEvent = static_cast<QTouchEvent *>(e);
QList<QTouchEvent::TouchPoint> touchPoints = touchEvent->tou chPoints(); QList<QTouchEvent::TouchPoint> touchPoints = touchEvent->tou chPoints();
if (touchPoints.count() == 1) if (touchPoints.count() == 1)
setAcceptedMouseButtons(Qt::LeftButton | Qt::RightBu tton | Qt::MiddleButton); setAcceptedMouseButtons(Qt::LeftButton | Qt::RightBu tton | Qt::MiddleButton);
return true; return true;
}
break; break;
}
case QEvent::Gesture: case QEvent::Gesture:
setAcceptedMouseButtons(0); setAcceptedMouseButtons(0);
return gestureEvent(static_cast<QGestureEvent*>(e)); return gestureEvent(static_cast<QGestureEvent*>(e));
break; break;
default: default:
return false; return false;
} }
} }
skipping to change at line 414 skipping to change at line 416
skyItem->setFocus(); skyItem->setFocus();
} }
StelMainView::~StelMainView() StelMainView::~StelMainView()
{ {
StelApp::deinitStatic(); StelApp::deinitStatic();
} }
void StelMainView::init(QSettings* conf) void StelMainView::init(QSettings* conf)
{ {
// Look for a static GUI plugins. gui = new StelGui();
foreach (QObject *plugin, QPluginLoader::staticInstances())
{
StelGuiPluginInterface* pluginInterface = qobject_cast<StelG
uiPluginInterface*>(plugin);
if (pluginInterface)
{
gui = pluginInterface->getStelGuiBase();
}
break;
}
Q_ASSERT(gui);
#if STEL_USE_NEW_OPENGL_WIDGETS #if STEL_USE_NEW_OPENGL_WIDGETS
//glWidget->initializeGL(); // protected... //glWidget->initializeGL(); // protected...
//Q_ASSERT(glWidget->isValid()); //Q_ASSERT(glWidget->isValid());
#else #else
Q_ASSERT(glWidget->isValid()); Q_ASSERT(glWidget->isValid());
glWidget->makeCurrent(); glWidget->makeCurrent();
#endif #endif
// Should be check of requirements disabled? // Should be check of requirements disabled?
skipping to change at line 465 skipping to change at line 457
QSize size = glWidget->windowHandle()->screen()->size(); QSize size = glWidget->windowHandle()->screen()->size();
size = QSize(conf->value("video/screen_w", size.width()).toInt(), size = QSize(conf->value("video/screen_w", size.width()).toInt(),
conf->value("video/screen_h", size.height()).toInt()); conf->value("video/screen_h", size.height()).toInt());
bool fullscreen = conf->value("video/fullscreen", true).toBool(); bool fullscreen = conf->value("video/fullscreen", true).toBool();
// Without this, the screen is not shown on a Mac + we should use re size() for correct work of fullscreen/windowed mode switch. --AW WTF??? // Without this, the screen is not shown on a Mac + we should use re size() for correct work of fullscreen/windowed mode switch. --AW WTF???
resize(size); resize(size);
QDesktopWidget *desktop = QApplication::desktop();
int screen = conf->value("video/screen_number", 0).toInt();
if (screen < 0 || screen >= desktop->screenCount())
{
qWarning() << "WARNING: screen" << screen << "not found";
screen = 0;
}
QRect screenGeom = desktop->screenGeometry(screen);
if (fullscreen) if (fullscreen)
{ {
// The "+1" below is to work around Linux/Gnome problem with
mouse focus.
move(screenGeom.x()+1, screenGeom.y()+1);
// The fullscreen window appears on screen where is the majo
rity of
// the normal window. Therefore we crop the normal window to
the
// screen area to ensure that the majority is not on another
screen.
setGeometry(geometry() & screenGeom);
setFullScreen(true); setFullScreen(true);
} }
else else
{ {
setFullScreen(false); setFullScreen(false);
int x = conf->value("video/screen_x", 0).toInt(); int x = conf->value("video/screen_x", 0).toInt();
int y = conf->value("video/screen_y", 0).toInt(); int y = conf->value("video/screen_y", 0).toInt();
move(x, y); move(x + screenGeom.x(), y + screenGeom.y());
} }
flagInvertScreenShotColors = conf->value("main/invert_screenshots_co lors", false).toBool(); flagInvertScreenShotColors = conf->value("main/invert_screenshots_co lors", false).toBool();
setFlagCursorTimeout(conf->value("gui/flag_mouse_cursor_timeout", fa lse).toBool()); setFlagCursorTimeout(conf->value("gui/flag_mouse_cursor_timeout", fa lse).toBool());
setCursorTimeout(conf->value("gui/mouse_cursor_timeout", 10.f).toFlo at()); setCursorTimeout(conf->value("gui/mouse_cursor_timeout", 10.f).toFlo at());
maxfps = conf->value("video/maximum_fps",10000.f).toFloat(); maxfps = conf->value("video/maximum_fps",10000.f).toFloat();
minfps = conf->value("video/minimum_fps",10000.f).toFloat(); minfps = conf->value("video/minimum_fps",10000.f).toFloat();
flagMaxFpsUpdatePending = false; flagMaxFpsUpdatePending = false;
// XXX: This should be done in StelApp::init(), unfortunately for th e moment we need init the gui before the // XXX: This should be done in StelApp::init(), unfortunately for th e moment we need init the gui before the
skipping to change at line 504 skipping to change at line 511
// No changes of OpenGL state is done here. // No changes of OpenGL state is done here.
// If problems are detected, warn the user one time, but continue. Warning panel will be suppressed on next start. // If problems are detected, warn the user one time, but continue. Warning panel will be suppressed on next start.
// Work in progress, as long as we get reports about bad systems or until O penGL startup is finalized and safe. // Work in progress, as long as we get reports about bad systems or until O penGL startup is finalized and safe.
// Several tests do not apply to MacOS X. // Several tests do not apply to MacOS X.
#if STEL_USE_NEW_OPENGL_WIDGETS #if STEL_USE_NEW_OPENGL_WIDGETS
void StelMainView::processOpenGLdiagnosticsAndWarnings(QSettings *co nf, StelQOpenGLWidget* glWidget) const; void StelMainView::processOpenGLdiagnosticsAndWarnings(QSettings *co nf, StelQOpenGLWidget* glWidget) const;
#else #else
void StelMainView::processOpenGLdiagnosticsAndWarnings(QSettings *co nf, StelQGLWidget* glWidget) const void StelMainView::processOpenGLdiagnosticsAndWarnings(QSettings *co nf, StelQGLWidget* glWidget) const
#endif #endif
{ {
#ifdef Q_OS_MAC
Q_UNUSED(conf);
#endif
QOpenGLContext* context=glWidget->context()->contextHandle(); QOpenGLContext* context=glWidget->context()->contextHandle();
QSurfaceFormat format=context->format(); QSurfaceFormat format=context->format();
// These tests are not required on MacOS X // These tests are not required on MacOS X
#ifndef Q_OS_MAC #ifndef Q_OS_MAC
bool openGLerror=false; bool openGLerror=false;
if (format.renderableType()==QSurfaceFormat::OpenGL || format.render ableType()==QSurfaceFormat::OpenGLES) if (format.renderableType()==QSurfaceFormat::OpenGL || format.render ableType()==QSurfaceFormat::OpenGLES)
{ {
qDebug() << "Detected:" << (format.renderableType()==QSurfac eFormat::OpenGL ? "OpenGL" : "OpenGL ES" ) << QString("%1.%2").arg(format. majorVersion()).arg(format.minorVersion()); qDebug() << "Detected:" << (format.renderableType()==QSurfac eFormat::OpenGL ? "OpenGL" : "OpenGL ES" ) << QString("%1.%2").arg(format. majorVersion()).arg(format.minorVersion());
} }
skipping to change at line 526 skipping to change at line 537
openGLerror=true; openGLerror=true;
qDebug() << "Neither OpenGL nor OpenGL ES detected: Unsuppor ted Format!"; qDebug() << "Neither OpenGL nor OpenGL ES detected: Unsuppor ted Format!";
} }
#endif #endif
QString glDriver(reinterpret_cast<const char*>(glGetString(GL_VERSIO N))); QString glDriver(reinterpret_cast<const char*>(glGetString(GL_VERSIO N)));
qDebug() << "Driver version string:" << glDriver; qDebug() << "Driver version string:" << glDriver;
qDebug() << "GL vendor is" << QString(reinterpret_cast<const char*>( glGetString(GL_VENDOR))); qDebug() << "GL vendor is" << QString(reinterpret_cast<const char*>( glGetString(GL_VENDOR)));
QString glRenderer(reinterpret_cast<const char*>(glGetString(GL_REND ERER))); QString glRenderer(reinterpret_cast<const char*>(glGetString(GL_REND ERER)));
qDebug() << "GL renderer is" << glRenderer; qDebug() << "GL renderer is" << glRenderer;
bool isMesa=glDriver.contains("Mesa", Qt::CaseInsensitive);
// Minimal required version of OpenGL for Qt5 is 2.1 and OpenGL Shad ing Language may be 1.20 (or OpenGL ES is 2.0 and GLSL ES is 1.0). // Minimal required version of OpenGL for Qt5 is 2.1 and OpenGL Shad ing Language may be 1.20 (or OpenGL ES is 2.0 and GLSL ES is 1.0).
// As of V0.13.0..1, we use GLSL 1.10/GLSL ES 1.00 (implicitly, by o mitting a #version line), but in case of using ANGLE we need hardware // As of V0.13.0..1, we use GLSL 1.10/GLSL ES 1.00 (implicitly, by o mitting a #version line), but in case of using ANGLE we need hardware
// detected as providing ps_3_0. // detected as providing ps_3_0.
// This means, usually systems with OpenGL3 support reported in the driver will work, those with reported 2.1 only will almost certainly fail. // This means, usually systems with OpenGL3 support reported in the driver will work, those with reported 2.1 only will almost certainly fail.
// If platform does not even support minimal OpenGL version for Qt5, then tell the user about troubles and quit from application. // If platform does not even support minimal OpenGL version for Qt5, then tell the user about troubles and quit from application.
// This test is apparently not applicable on MacOS X due to its beha ving differently from all other known OSes. // This test is apparently not applicable on MacOS X due to its beha ving differently from all other known OSes.
// The correct way to handle driver issues on MacOS X remains howeve r unclear for now. // The correct way to handle driver issues on MacOS X remains howeve r unclear for now.
#ifndef Q_OS_MAC #ifndef Q_OS_MAC
bool isMesa=glDriver.contains("Mesa", Qt::CaseInsensitive);
if ( openGLerror || if ( openGLerror ||
((format.renderableType()==QSurfaceFormat::OpenGL ) && (format .version() < QPair<int, int>(2, 1)) && !isMesa) || ((format.renderableType()==QSurfaceFormat::OpenGL ) && (format .version() < QPair<int, int>(2, 1)) && !isMesa) ||
((format.renderableType()==QSurfaceFormat::OpenGL ) && (format .version() < QPair<int, int>(2, 0)) && isMesa) || // Mesa defaults to 2.0 but works! ((format.renderableType()==QSurfaceFormat::OpenGL ) && (format .version() < QPair<int, int>(2, 0)) && isMesa) || // Mesa defaults to 2.0 but works!
((format.renderableType()==QSurfaceFormat::OpenGLES) && (format .version() < QPair<int, int>(2, 0))) ) ((format.renderableType()==QSurfaceFormat::OpenGLES) && (format .version() < QPair<int, int>(2, 0))) )
{ {
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
qWarning() << "Oops... Insufficient OpenGL version. Please u pdate drivers, graphics hardware, or use MESA (or ANGLE) version."; qWarning() << "Oops... Insufficient OpenGL version. Please u pdate drivers, graphics hardware, or use MESA (or ANGLE) version.";
QMessageBox::critical(0, "Stellarium", q_("Insufficient Open GL version. Please update drivers, graphics hardware, or use MESA (or ANGLE ) version."), QMessageBox::Abort, QMessageBox::Abort); QMessageBox::critical(0, "Stellarium", q_("Insufficient Open GL version. Please update drivers, graphics hardware, or use MESA (or ANGLE ) version."), QMessageBox::Abort, QMessageBox::Abort);
#else #else
qWarning() << "Oops... Insufficient OpenGL version. Please u pdate drivers, or graphics hardware."; qWarning() << "Oops... Insufficient OpenGL version. Please u pdate drivers, or graphics hardware.";
 End of changes. 11 change blocks. 
16 lines changed or deleted 30 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/