<commit_before>#include "widgetwrapper.h"
#include "qmh-config.h"
#include "qmh-util.h"
#include "backend.h"

#include <QGraphicsView>
#include <QDeclarativeView>
#include <QShortcut>

WidgetWrapper::WidgetWrapper(QWidget *prey)
    : QWidget(0),
      m_prey(prey),
      viewport(0)
{
    QAbstractScrollArea *scrollArea = qobject_cast<QAbstractScrollArea*>(prey);

    if (scrollArea)
        viewport = scrollArea->viewport();

    prey->setParent(this);

    setOrientation(Config::value("orientation", ScreenOrientationAuto));

    Utils::optimizeWidgetAttributes(this, true);
    Utils::optimizeWidgetAttributes(prey, true);

    if (viewport) {
        //Does not appear to work here
        //Not sure why
        Utils::optimizeWidgetAttributes(viewport, true);
    }

    installEventFilter(Backend::instance());

    new QShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::META + Qt::ALT + Qt::Key_Backspace), this, SLOT(resetUI()));
    new QShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::META + Qt::ALT + Qt::Key_Down), this, SIGNAL(shrink()));
    new QShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::META + Qt::ALT + Qt::Key_Up), this, SIGNAL(grow()));
    new QShortcut(QKeySequence(Qt::ALT + Qt::Key_Return), this, SIGNAL(toggleFullScreen()));

    resizeSettleTimer.setSingleShot(true);

    connect(&resizeSettleTimer, SIGNAL(timeout()), this, SLOT(handleResize()));
}

WidgetWrapper::~WidgetWrapper()
{
    delete m_prey;
}

void WidgetWrapper::resizeEvent(QResizeEvent *e)
{
    Q_UNUSED(e);
    static int staggerResizingDelay = Config::value("resizeDelay", 0);
    resizeSettleTimer.start(staggerResizingDelay);
}

void WidgetWrapper::setOrientation(ScreenOrientation orientation)
{
#if defined(Q_OS_SYMBIAN)
    // If the version of Qt on the device is < 4.7.2, that attribute won't work
    if (orientation != ScreenOrientationAuto) {
        const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.'));
        if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) {
            qWarning("Screen orientation locking only supported with Qt 4.7.2 and above");
            return;
        }
    }
#endif // Q_OS_SYMBIAN

    Qt::WidgetAttribute attribute;
    switch (orientation) {
#if QT_VERSION < 0x040702
    // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes
    case ScreenOrientationLockPortrait:
        attribute = static_cast<Qt::WidgetAttribute>(128);
        break;
    case ScreenOrientationLockLandscape:
        attribute = static_cast<Qt::WidgetAttribute>(129);
        break;
    default:<commit_msg>Give the resize-delay a sane default<commit_after>#include "widgetwrapper.h"
#include "qmh-config.h"
#include "qmh-util.h"
#include "backend.h"

#include <QGraphicsView>
#include <QDeclarativeView>
#include <QShortcut>

WidgetWrapper::WidgetWrapper(QWidget *prey)
    : QWidget(0),
      m_prey(prey),
      viewport(0)
{
    QAbstractScrollArea *scrollArea = qobject_cast<QAbstractScrollArea*>(prey);

    if (scrollArea)
        viewport = scrollArea->viewport();

    prey->setParent(this);

    setOrientation(Config::value("orientation", ScreenOrientationAuto));

    Utils::optimizeWidgetAttributes(this, true);
    Utils::optimizeWidgetAttributes(prey, true);

    if (viewport) {
        //Does not appear to work here
        //Not sure why
        Utils::optimizeWidgetAttributes(viewport, true);
    }

    installEventFilter(Backend::instance());

    new QShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::META + Qt::ALT + Qt::Key_Backspace), this, SLOT(resetUI()));
    new QShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::META + Qt::ALT + Qt::Key_Down), this, SIGNAL(shrink()));
    new QShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::META + Qt::ALT + Qt::Key_Up), this, SIGNAL(grow()));
    new QShortcut(QKeySequence(Qt::ALT + Qt::Key_Return), this, SIGNAL(toggleFullScreen()));

    resizeSettleTimer.setSingleShot(true);

    connect(&resizeSettleTimer, SIGNAL(timeout()), this, SLOT(handleResize()));
}

WidgetWrapper::~WidgetWrapper()
{
    delete m_prey;
}

void WidgetWrapper::resizeEvent(QResizeEvent *e)
{
    Q_UNUSED(e);
    static int staggerResizingDelay = Config::value("resize-delay", 25);
    resizeSettleTimer.start(staggerResizingDelay);
}

void WidgetWrapper::setOrientation(ScreenOrientation orientation)
{
#if defined(Q_OS_SYMBIAN)
    // If the version of Qt on the device is < 4.7.2, that attribute won't work
    if (orientation != ScreenOrientationAuto) {
        const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.'));
        if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) {
            qWarning("Screen orientation locking only supported with Qt 4.7.2 and above");
            return;
        }
    }
#endif // Q_OS_SYMBIAN

    Qt::WidgetAttribute attribute;
    switch (orientation) {
#if QT_VERSION < 0x040702
    // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes
    case ScreenOrientationLockPortrait:
        attribute = static_cast<Qt::WidgetAttribute>(128);
        break;
    case ScreenOrientationLockLandscape:
        attribute = static_cast<Qt::WidgetAttribute>(129);
        break;
    default:
{'fraction_non_alphanumeric': 0.14245014245014245, 'fraction_numerical': 0.015384615384615385, 'mean_word_length': 4.162745098039216, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 19, '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': '3268495', 'n_tokens_mistral': 1779, 'n_tokens_neox': 1664, 'n_words': 342}