コード例 #1
0
static PyObject *meth_QPrintEngine_setProperty(PyObject *sipSelf, PyObject *sipArgs)
{
    PyObject *sipParseErr = NULL;
    PyObject *sipOrigSelf = sipSelf;

    {
        QPrintEngine::PrintEnginePropertyKey a0;
        const QVariant * a1;
        int a1State = 0;
        QPrintEngine *sipCpp;

        if (sipParseArgs(&sipParseErr, sipArgs, "BEJ1", &sipSelf, sipType_QPrintEngine, &sipCpp, sipType_QPrintEngine_PrintEnginePropertyKey, &a0, sipType_QVariant,&a1, &a1State))
        {
            if (!sipOrigSelf)
            {
                sipAbstractMethod(sipName_QPrintEngine, sipName_setProperty);
                return NULL;
            }

            Py_BEGIN_ALLOW_THREADS
            sipCpp->setProperty(a0,*a1);
            Py_END_ALLOW_THREADS
            sipReleaseType(const_cast<QVariant *>(a1),sipType_QVariant,a1State);

            Py_INCREF(Py_None);
            return Py_None;
        }
    }

    /* Raise an exception if the arguments couldn't be parsed. */
    sipNoMethod(sipParseErr, sipName_QPrintEngine, sipName_setProperty, NULL);

    return NULL;
}
コード例 #2
0
static PyObject *meth_QPrintEngine_property(PyObject *sipSelf, PyObject *sipArgs)
{
    PyObject *sipParseErr = NULL;
    PyObject *sipOrigSelf = sipSelf;

    {
        QPrintEngine::PrintEnginePropertyKey a0;
        QPrintEngine *sipCpp;

        if (sipParseArgs(&sipParseErr, sipArgs, "BE", &sipSelf, sipType_QPrintEngine, &sipCpp, sipType_QPrintEngine_PrintEnginePropertyKey, &a0))
        {
            QVariant *sipRes;

            if (!sipOrigSelf)
            {
                sipAbstractMethod(sipName_QPrintEngine, sipName_property);
                return NULL;
            }

            Py_BEGIN_ALLOW_THREADS
            sipRes = new QVariant(sipCpp->property(a0));
            Py_END_ALLOW_THREADS

            return sipConvertFromNewType(sipRes,sipType_QVariant,NULL);
        }
    }
コード例 #3
0
// set gui data on printer
void QPageSetupWidget::setupPrinter() const
{
    QPrinter::Orientation orientation = widget.portrait->isChecked()
                                        ? QPrinter::Portrait
                                        : QPrinter::Landscape;
    m_printer->setOrientation(orientation);
    // paper format
    QVariant val = widget.paperSize->itemData(widget.paperSize->currentIndex());
    int ps = m_printer->pageSize();
    if (val.type() == QVariant::Int) {
        ps = val.toInt();
    }
#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
    else if (m_cups && QCUPSSupport::isAvailable() && m_cups->currentPPD()) {
        QByteArray cupsPageSize = val.toByteArray();
        QPrintEngine *engine = m_printer->printEngine();
        engine->setProperty(PPK_CupsStringPageSize, QString::fromLatin1(cupsPageSize));
        engine->setProperty(PPK_CupsOptions, m_cups->options());

        QRect pageRect = m_cups->pageRect(cupsPageSize);
        engine->setProperty(PPK_CupsPageRect, pageRect);

        QRect paperRect = m_cups->paperRect(cupsPageSize);
        engine->setProperty(PPK_CupsPaperRect, paperRect);

        for(ps = 0; ps < QPrinter::NPageSize; ++ps) {
            QPdf::PaperSize size = QPdf::paperSize(QPrinter::PaperSize(ps));
            if (size.width == paperRect.width() && size.height == paperRect.height())
                break;
        }
    }
#endif
    if (ps == QPrinter::Custom)
        m_printer->setPaperSize(sizeForOrientation(orientation, m_paperSize), QPrinter::Point);
    else
        m_printer->setPaperSize(static_cast<QPrinter::PaperSize>(ps));

#ifdef PSD_ENABLE_PAPERSOURCE
    m_printer->setPaperSource((QPrinter::PaperSource)widget.paperSource->currentIndex());
#endif
    m_printer->setPageMargins(m_leftMargin, m_topMargin, m_rightMargin, m_bottomMargin, QPrinter::Point);

}