<commit_before>/*******************************************************************************

Licensed to the OpenCOR team under one or more contributor license agreements.
See the NOTICE.txt file distributed with this work for additional information
regarding copyright ownership. The OpenCOR team licenses this file to you under
the Apache License, Version 2.0 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.

*******************************************************************************/

//==============================================================================
// Core GUI utilities
//==============================================================================

void showEnableAction(QAction *pAction, const bool &pVisible,
                      const bool &pEnabled)
{
    // Show/enable or hide/disable the given action

    pAction->setVisible(pVisible);
    pAction->setEnabled(pVisible && pEnabled);
}

//==============================================================================

QColor baseColor()
{
    // Return the base colour

    return qApp->palette().color(QPalette::Base);
}

//==============================================================================

QColor borderColor()
{
    // Retrieve and return the colour used for a 'normal' border, but first
    // retrieve our main window
    // Note #1: we use a QStackedWidget object and retrieve the colour of the
    //          pixel which is in the middle of the right border...
    // Note #2: we don't rely on the top border because it may be rendered in a
    //          special way. Also, we don't rely on a corner as such in case
    //          it's rendered as a rounded corner...

    QWidget *mainWindow = 0;

    foreach (QWidget *widget, qApp->topLevelWidgets()) {
        if (widget->inherits("QMainWindow")) {
            mainWindow = widget;

            break;
        }
    }

    Q_ASSERT(mainWindow);

    // Now, we can retrieve and return the border colour

    static QStackedWidget *stackedWidget;
    static QImage image;
    static int xPixel;
    static int yPixel;
    static bool firstTime = true;

    if (firstTime) {
        stackedWidget = new QStackedWidget(mainWindow);
        image = QImage(stackedWidget->size(),
                       QImage::Format_ARGB32_Premultiplied);

        stackedWidget->setFrameShape(QFrame::StyledPanel);
<commit_msg>OS X 10.11 (El Capitan): some work on addressing an issue with some parts of the GUI being black (closes #779).<commit_after>/*******************************************************************************

Licensed to the OpenCOR team under one or more contributor license agreements.
See the NOTICE.txt file distributed with this work for additional information
regarding copyright ownership. The OpenCOR team licenses this file to you under
the Apache License, Version 2.0 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.

*******************************************************************************/

//==============================================================================
// Core GUI utilities
//==============================================================================

void showEnableAction(QAction *pAction, const bool &pVisible,
                      const bool &pEnabled)
{
    // Show/enable or hide/disable the given action

    pAction->setVisible(pVisible);
    pAction->setEnabled(pVisible && pEnabled);
}

//==============================================================================

QColor baseColor()
{
    // Return the base colour

    return qApp->palette().color(QPalette::Base);
}

//==============================================================================

QColor borderColor()
{
    // Retrieve and return the colour used for a 'normal' border
    // Note #1: we use a QStackedWidget object and retrieve the colour of the
    //          pixel which is in the middle of the right border...
    // Note #2: we don't rely on the top border because it may be rendered in a
    //          special way. Also, we don't rely on a corner as such in case
    //          it's rendered as a rounded corner...

    static bool firstTime = true;
    static QStackedWidget *stackedWidget;
    static QImage image;
    static int xPixel;
    static int yPixel;

    if (firstTime) {
        // Retrieve our main window

        QWidget *mainWindow = 0;

        foreach (QWidget *widget, qApp->topLevelWidgets()) {
            if (widget->inherits("QMainWindow")) {
                mainWindow = widget;

                break;
            }
        }

        Q_ASSERT(mainWindow);

        // Create a QStackedWidget object, so we can render it in an image and
        // thus retrieve its border colour

        stackedWidget = new QStackedWidget(mainWindow);
        image = QImage(stackedWidget->size(),
                       QImage::Format_ARGB32_Premultiplied);

        stackedWidget->setFrameShape(QFrame::StyledPanel);

{'fraction_non_alphanumeric': 0.2262622781320007, 'fraction_numerical': 0.00430811649146993, 'mean_word_length': 3.444104134762634, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '412976', 'n_tokens_mistral': 1398, 'n_tokens_neox': 1288, 'n_words': 555}