<commit_before>// For conditions of distribution and use, see copyright notice in license.txt

#include "StableHeaders.h"
#include "QOgreUIView.h"

#ifdef Q_WS_X11
#include <QX11Info>
#endif

#ifdef Q_WS_WIN
#include <windows.h>
#endif

namespace OgreRenderer
{
    QOgreUIView::QOgreUIView () :
        QGraphicsView(),
        win_(0),
        view_(0)
    {
        Initialize_();
    }

    QOgreUIView::QOgreUIView (QWidget *parent, QGraphicsScene *scene) : 
        QGraphicsView(scene, parent),
        win_(0),
        view_(0)
    {
        Initialize_();
    }

    QOgreUIView::~QOgreUIView ()
    {
        if (scene())
            delete scene();
    }

    void QOgreUIView::Initialize_()
    {
        // Setup QGrapchicsView
        setUpdatesEnabled(false);
        setAutoFillBackground(false);
        setFocusPolicy (Qt::StrongFocus);
        setViewportUpdateMode (QGraphicsView::FullViewportUpdate);
        setHorizontalScrollBarPolicy (Qt::ScrollBarAlwaysOff);
        setVerticalScrollBarPolicy (Qt::ScrollBarAlwaysOff);

        #ifdef Q_WS_WIN
        // Get rid of extra white layers under widgets
        QPalette p;
        p.setColor(QPalette::Window, Qt::transparent); 
        p.setColor(QPalette::Base, Qt::transparent);
        setPalette(p);
        // Determine if we are running under windows 7 that has certain paint issues with Qt 4.6 in a QGraphicsView
        // If we are under win 7 we do some dirty hacks to go around this as a temp solution
        OSVERSIONINFOEX os_version_info;
        ZeroMemory(&os_version_info, sizeof(OSVERSIONINFOEX));
        os_version_info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
        if (GetVersionEx((OSVERSIONINFO *)&os_version_info))
            if ( os_version_info.dwMajorVersion == 6 && os_version_info.dwMinorVersion == 1)
                setAttribute(Qt::WA_DontShowOnScreen, true);
        #endif
    }    

    void QOgreUIView::SetWorldView(QOgreWorldView *view) 
    { 
        view_ = view; 
        QObject::connect(scene(), SIGNAL( changed (const QList<QRectF> &) ), this, SLOT( SceneChange() )); 
    }

    void QOgreUIView::InitializeWorldView(int width, int height)
    { 
        if (view_) view_->InitializeOverlay(width, height); 
    }

    Ogre::RenderWindow *QOgreUIView::CreateRenderWindow (const std::string &name,  int width, int height, int left, int top, bool fullscreen)
    {
        bool stealparent 
            ((parentWidget())? true : false);

        QWidget *nativewin 
            ((stealparent)? parentWidget() : this);<commit_msg>linux requires transparent palette hack as well<commit_after>// For conditions of distribution and use, see copyright notice in license.txt

#include "StableHeaders.h"
#include "QOgreUIView.h"

#ifdef Q_WS_X11
#include <QX11Info>
#endif

#ifdef Q_WS_WIN
#include <windows.h>
#endif

namespace OgreRenderer
{
    QOgreUIView::QOgreUIView () :
        QGraphicsView(),
        win_(0),
        view_(0)
    {
        Initialize_();
    }

    QOgreUIView::QOgreUIView (QWidget *parent, QGraphicsScene *scene) : 
        QGraphicsView(scene, parent),
        win_(0),
        view_(0)
    {
        Initialize_();
    }

    QOgreUIView::~QOgreUIView ()
    {
        if (scene())
            delete scene();
    }

    void QOgreUIView::Initialize_()
    {
        // Setup QGrapchicsView
        setUpdatesEnabled(false);
        setAutoFillBackground(false);
        setFocusPolicy (Qt::StrongFocus);
        setViewportUpdateMode (QGraphicsView::FullViewportUpdate);
        setHorizontalScrollBarPolicy (Qt::ScrollBarAlwaysOff);
        setVerticalScrollBarPolicy (Qt::ScrollBarAlwaysOff);

        // Get rid of extra white layers under widgets
        // Qt doesn't respect the above request to not fill background
        QPalette empty_background;
        empty_background.setColor (QPalette::Window, Qt::transparent); 
        empty_background.setColor (QPalette::Base, Qt::transparent);
        setPalette (empty_background);

        #ifdef Q_WS_WIN
        // Determine if we are running under windows 7 that has certain paint issues with Qt 4.6 in a QGraphicsView
        // If we are under win 7 we do some dirty hacks to go around this as a temp solution
        OSVERSIONINFOEX os_version_info;
        ZeroMemory(&os_version_info, sizeof(OSVERSIONINFOEX));
        os_version_info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
        if (GetVersionEx((OSVERSIONINFO *)&os_version_info))
            if ( os_version_info.dwMajorVersion == 6 && os_version_info.dwMinorVersion == 1)
                setAttribute(Qt::WA_DontShowOnScreen, true);
        #endif
    }    

    void QOgreUIView::SetWorldView(QOgreWorldView *view) 
    { 
        view_ = view; 
        QObject::connect(scene(), SIGNAL( changed (const QList<QRectF> &) ), this, SLOT( SceneChange() )); 
    }

    void QOgreUIView::InitializeWorldView(int width, int height)
    { 
        if (view_) view_->InitializeOverlay(width, height); 
    }

    Ogre::RenderWindow *QOgreUIView::CreateRenderWindow (const std::string &name,  int width, int height, int left, int top, bool fullscreen)
    {
        bool stealparent 
            ((parentWidget())? true : false);

        QWidget *nativewin 
            ((stealparent)? parentWidget() : this);
{'fraction_non_alphanumeric': 0.10009460737937559, 'fraction_numerical': 0.005298013245033113, 'mean_word_length': 2.813852813852814, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6594423', 'n_tokens_mistral': 1628, 'n_tokens_neox': 1574, 'n_words': 380}