Commit 8d474c6a authored by Alex Richardson's avatar Alex Richardson Committed by Nicolas Fella
Browse files

Allow compiling against a Qt build configured with -no-opengl

I am currently working on running Gwenview on an FreeBSD QEMU instance and
have configured my Qt build without OpenGL support since I don't have
any 3D graphics support. This change fixes compilation against such a
Qt configuration.
parent a4f13057
......@@ -99,7 +99,12 @@ ConfigDialog::ConfigDialog(QWidget* parent)
mAnimationMethodGroup = new InvisibleButtonGroup(widget);
mAnimationMethodGroup->setObjectName(QStringLiteral("kcfg_AnimationMethod"));
#ifdef QT_NO_OPENGL
mImageViewConfigPage.glAnimationRadioButton->setEnabled(false);
mAnimationMethodGroup->addButton(mImageViewConfigPage.glAnimationRadioButton, int(DocumentView::NoAnimation));
#else
mAnimationMethodGroup->addButton(mImageViewConfigPage.glAnimationRadioButton, int(DocumentView::GLAnimation));
#endif
mAnimationMethodGroup->addButton(mImageViewConfigPage.softwareAnimationRadioButton, int(DocumentView::SoftwareAnimation));
mAnimationMethodGroup->addButton(mImageViewConfigPage.noAnimationRadioButton, int(DocumentView::NoAnimation));
......
......@@ -75,7 +75,9 @@ public:
enum AnimationMethod {
NoAnimation,
SoftwareAnimation,
GLAnimation
#ifndef QT_NO_OPENGL
GLAnimation,
#endif
};
/**
......
......@@ -86,10 +86,12 @@ DocumentViewContainer::DocumentViewContainer(QWidget* parent)
{
d->q = this;
d->mScene = new QGraphicsScene(this);
#ifndef QT_NO_OPENGL
if (GwenviewConfig::animationMethod() == DocumentView::GLAnimation) {
auto* glWidget = new QOpenGLWidget;
setViewport(glWidget);
}
#endif
setScene(d->mScene);
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
......@@ -299,11 +301,13 @@ void DocumentViewContainer::slotFadeInFinished(DocumentView* view)
void DocumentViewContainer::slotConfigChanged()
{
#ifndef QT_NO_OPENGL
bool currentlyGL = qobject_cast<QOpenGLWidget*>(viewport());
bool wantGL = GwenviewConfig::animationMethod() == DocumentView::GLAnimation;
if (currentlyGL != wantGL) {
setViewport(wantGL ? new QOpenGLWidget() : new QWidget());
}
#endif
}
void DocumentViewContainer::showMessageWidget(QGraphicsWidget* widget, Qt::Alignment align)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment