diff --git a/src/qt4gui/qt4/WMainWindow.cpp b/src/qt4gui/qt4/WMainWindow.cpp index c9190ea59ef675f6f80b1944c89b4dc402c6e9c7..aa3fe2968f1002875544745e4e8e1053e1e6a546 100644 --- a/src/qt4gui/qt4/WMainWindow.cpp +++ b/src/qt4gui/qt4/WMainWindow.cpp @@ -49,10 +49,13 @@ #include #endif +#include "../icons/WIcons.xpm" +#include "controlPanel/WPropertyBoolWidget.h" +#include "controlPanel/WQtControlPanel.h" #include "core/common/WColor.h" #include "core/common/WIOTools.h" -#include "core/common/WProjectFileIO.h" #include "core/common/WPathHelper.h" +#include "core/common/WProjectFileIO.h" #include "core/dataHandler/WDataSetFibers.h" #include "core/dataHandler/WDataSetSingle.h" #include "core/dataHandler/WEEG2.h" @@ -66,22 +69,20 @@ #include "core/kernel/WProjectFile.h" #include "core/kernel/WROIManager.h" #include "core/kernel/WSelectionManager.h" -#include "../icons/WIcons.xpm" -#include "controlPanel/WPropertyBoolWidget.h" -#include "controlPanel/WQtControlPanel.h" #include "events/WEventTypes.h" #include "events/WModuleCrashEvent.h" #include "events/WModuleReadyEvent.h" #include "events/WModuleRemovedEvent.h" #include "events/WOpenCustomDockWidgetEvent.h" #include "guiElements/WQtPropertyBoolAction.h" +#include "WQt4Gui.h" #include "WQtCombinerToolbar.h" #include "WQtCustomDockWidget.h" -#include "WQtNavGLWidget.h" #include "WQtGLDockWidget.h" -#include "WQt4Gui.h" +#include "WQtNavGLWidget.h" #include "WSettingAction.h" #include "WSettingMenu.h" +#include "WQtMessageDialog.h" #include "WMainWindow.h" #include "WMainWindow.moc" @@ -1009,7 +1010,20 @@ void WMainWindow::handleLogLevelUpdate( unsigned int logLevel ) void WMainWindow::handleGLVendor() { // WARNING: never put blocking code here, as it might freeze the mainGLWidget. - std::string vendor = m_mainGLWidget->getViewer()->getOpenGLVendor(); + std::string vendor = string_utils::toLower( m_mainGLWidget->getViewer()->getOpenGLVendor() ); - // TODO(ebaum): warning + // is this a mesa card? + if( vendor.find( "mesa" ) != std::string::npos ) + { + QString msg = "Warning: Your graphics card is powered by the Mesa OpenGL implementation. OpenWalnut does not support Mesa " + "officially, since Mesa has some severe problems with GLSL shaders. You can still use OpenWalnut, but you should be " + "aware that Mesa can freeze OpenWalnut. Ensure you have the latest version of Mesa installed to avoid problems."; + QLabel* l = new QLabel( msg ); + l->setWordWrap( true ); + l->setGeometry( 0, 0, 400, 200 ); + l->setMinimumWidth( 400 ); + + WQtMessageDialog* msgDia = new WQtMessageDialog( "MesaWarning", "Mesa Warning", l, getSettings(), this ); + msgDia->show(); + } } diff --git a/src/qt4gui/qt4/WQtMessageDialog.cpp b/src/qt4gui/qt4/WQtMessageDialog.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4067c2f67cfddc902d22d6609958f18237c241cc --- /dev/null +++ b/src/qt4gui/qt4/WQtMessageDialog.cpp @@ -0,0 +1,105 @@ +//--------------------------------------------------------------------------- +// +// Project: OpenWalnut ( http://www.openwalnut.org ) +// +// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS +// For more information see http://www.openwalnut.org/copying +// +// This file is part of OpenWalnut. +// +// OpenWalnut is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// OpenWalnut is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with OpenWalnut. If not, see . +// +//--------------------------------------------------------------------------- + +#include + +#include +#include + +#include "WMainWindow.h" + +#include "WQtMessageDialog.h" +#include "WQtMessageDialog.moc" + +WQtMessageDialog::WQtMessageDialog( QString msgID, QString title, QWidget* content, QSettings& settings, QWidget* parent ): // NOLINT - yes use a non-const ref + QDialog( parent ), + m_content( content ), + m_msgID( msgID ), + m_settings( settings ) +{ + setWindowTitle( title ); + setModal( false ); + + // setup contents + QVBoxLayout* mainLayout = new QVBoxLayout(); + + // text widget + mainLayout->addWidget( m_content ); + + // dialog buttons and checkbox to bottom layout + QHBoxLayout* bottomLayout = new QHBoxLayout(); + QWidget* bottomWidget = new QWidget( this ); + bottomWidget->setLayout( bottomLayout ); + mainLayout->addWidget( bottomWidget ); + this->setLayout( mainLayout ); + + m_checkBox = new QCheckBox( bottomWidget ); + m_checkBox->setText( "Do not show again" ); + m_buttonBox = new QDialogButtonBox( bottomWidget ); + m_buttonBox->setOrientation( Qt::Horizontal ); + m_buttonBox->setStandardButtons( QDialogButtonBox::Ok ); + bottomLayout->addWidget( m_checkBox ); + bottomLayout->addWidget( m_buttonBox ); + + // connect dialog box to close event + QObject::connect( m_buttonBox, SIGNAL( accepted() ), this, SLOT( accept() ) ); + QObject::connect( m_buttonBox, SIGNAL( rejected() ), this, SLOT( reject() ) ); +} + +WQtMessageDialog::~WQtMessageDialog() +{ + // cleanup +} + +void WQtMessageDialog::show() +{ + // check if message is allowed + bool show = m_settings.value( m_msgID + "_showAgain", true ).toBool(); + m_checkBox->setCheckState( show ? Qt::Unchecked : Qt::Checked ); + + // only show if wanted by user + if( !show ) + { + return; + } + + QDialog::show(); +} + +void WQtMessageDialog::reject() +{ + QDialog::reject(); +} + +void WQtMessageDialog::accept() +{ + handleClose(); + QDialog::accept(); +} + +void WQtMessageDialog::handleClose() +{ + m_settings.setValue( m_msgID + "_showAgain", m_checkBox->checkState() == Qt::Unchecked ); +} + diff --git a/src/qt4gui/qt4/WQtMessageDialog.h b/src/qt4gui/qt4/WQtMessageDialog.h new file mode 100644 index 0000000000000000000000000000000000000000..61d3fdf6262986bb6c9689b50c0ff266e09f4789 --- /dev/null +++ b/src/qt4gui/qt4/WQtMessageDialog.h @@ -0,0 +1,111 @@ +//--------------------------------------------------------------------------- +// +// Project: OpenWalnut ( http://www.openwalnut.org ) +// +// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS +// For more information see http://www.openwalnut.org/copying +// +// This file is part of OpenWalnut. +// +// OpenWalnut is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// OpenWalnut is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with OpenWalnut. If not, see . +// +//--------------------------------------------------------------------------- + +#ifndef WQTMESSAGEDIALOG_H +#define WQTMESSAGEDIALOG_H + +#include +#include +#include +#include +#include +#include + +/** + * General purpose message dialog, able to show arbitrary content. It additionally allows the user to decide whether he wants to see this again + * or not. + */ +class WQtMessageDialog: public QDialog +{ + Q_OBJECT +public: + /** + * Construct a message dialog. + * + * \param msgID the id used to check whether to show the message or not. + * \param title the title of the dialog + * \param content the widget representing the content + * \param settings the object storing the info about disabled messages + * \param parent parent window + */ + WQtMessageDialog( QString msgID, QString title, QWidget* content, QSettings& settings, QWidget* parent ); // NOLINT - yes use a non-const ref + + /** + * Destructor. + */ + virtual ~WQtMessageDialog(); + + /** + * Shows the dialog if the user does not disabled it. + */ + virtual void show(); + +protected: + +private slots: + + /** + * Dialog closed + */ + virtual void reject(); + + /** + * Dialog closed + */ + virtual void accept(); + +private: + /** + * Dialog buttons. + */ + QDialogButtonBox* m_buttonBox; + + /** + * Do not show again - Checkbox + */ + QCheckBox* m_checkBox; + + /** + * The widget showing the content + */ + QWidget* m_content; + + /** + * The message ID + */ + QString m_msgID; + + /** + * Settings object of the main window + */ + QSettings& m_settings; + + /** + * Handles close and saves setting + */ + void handleClose(); +}; + +#endif // WQTMESSAGEDIALOG_H +