Exemplo n.º 1
0
MessageListView::MessageListView(QWidget *parent) :
    QTableView(parent)
{
    this->horizontalHeader()->hide();
    this->verticalHeader()->hide();
    this->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
    this->verticalHeader()->setDefaultSectionSize(60);
    this->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    this->setShowGrid(false);
    this->setSelectionMode(QAbstractItemView::NoSelection);
    /*
     * 添加滑屏操作
    */
    this->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);

    QScroller *scroller = QScroller::scroller(this->viewport());

    QScrollerProperties prop = scroller->scrollerProperties();

    prop.setScrollMetric(QScrollerProperties::AxisLockThreshold, 0.66);
    prop.setScrollMetric(QScrollerProperties::ScrollingCurve, QEasingCurve(QEasingCurve::OutExpo));
    prop.setScrollMetric(QScrollerProperties::DecelerationFactor, 0.05);
    prop.setScrollMetric(QScrollerProperties::MaximumVelocity, 0);
    prop.setScrollMetric(QScrollerProperties::OvershootDragResistanceFactor, 0.33);
    prop.setScrollMetric(QScrollerProperties::OvershootScrollDistanceFactor, 0.33);
    prop.setScrollMetric(QScrollerProperties::SnapPositionRatio, 0.93);
    prop.setScrollMetric(QScrollerProperties::DragStartDistance, 0.001);
    prop.setScrollMetric(QScrollerProperties::SnapPositionRatio,0.5);

    scroller->setScrollerProperties(prop);

    scroller->grabGesture(this, QScroller::TouchGesture);
    scroller->grabGesture(this, QScroller::LeftMouseButtonGesture);
}
Exemplo n.º 2
0
/**
 * @brief Class constructor
 * @param parent
 */
HelpDialog::HelpDialog(QWidget* parent) : QDialog(parent), ui(new Ui::HelpDialog){
    ui->setupUi(this);

    //enables figer scrolling for android
    #ifdef ANDROID
        QScroller::grabGesture(ui->scrollArea, QScroller::LeftMouseButtonGesture);
        QScrollerProperties sp;
        sp.setScrollMetric(QScrollerProperties::DragStartDistance, 0.001);
        sp.setScrollMetric(QScrollerProperties::FrameRate, QScrollerProperties::Fps60);
        sp.setScrollMetric(QScrollerProperties::MousePressEventDelay, 0.1);
        sp.setScrollMetric(QScrollerProperties::VerticalOvershootPolicy, QScrollerProperties::OvershootAlwaysOff);
        sp.setScrollMetric(QScrollerProperties::HorizontalOvershootPolicy, QScrollerProperties::OvershootAlwaysOff);
        sp.setScrollMetric(QScrollerProperties::OvershootDragDistanceFactor, 0.1);
        sp.setScrollMetric(QScrollerProperties::OvershootScrollDistanceFactor, 0.1);
        QScroller* qs = QScroller::scroller(ui->scrollArea);
        qs->setScrollerProperties(sp);
    #endif

    //loads help text from resources
    #ifdef ANDROID
        QFile file(":/strings/help_android");
        file.open(QIODevice::ReadOnly);
        ui->mainLabel->setText(file.readAll());
        file.close();
    #else
        QFile file(":/strings/help_pc");
        file.open(QIODevice::ReadOnly);
        ui->mainLabel->setText(file.readAll());
        file.close();
    #endif
}
Exemplo n.º 3
0
static PyObject *meth_QScroller_handleInput(PyObject *sipSelf, PyObject *sipArgs, PyObject *sipKwds)
{
    PyObject *sipParseErr = NULL;

    {
        QScroller::Input a0;
        const QPointF* a1;
        int a1State = 0;
        qint64 a2 = 0;
        QScroller *sipCpp;

        static const char *sipKwdList[] = {
            NULL,
            NULL,
            sipName_timestamp,
        };

        if (sipParseKwdArgs(&sipParseErr, sipArgs, sipKwds, sipKwdList, NULL, "BEJ1|n", &sipSelf, sipType_QScroller, &sipCpp, sipType_QScroller_Input, &a0, sipType_QPointF, &a1, &a1State, &a2))
        {
            bool sipRes;

            sipRes = sipCpp->handleInput(a0,*a1,a2);
            sipReleaseType(const_cast<QPointF *>(a1),sipType_QPointF,a1State);

            return PyBool_FromLong(sipRes);
        }
    }

    /* Raise an exception if the arguments couldn't be parsed. */
    sipNoMethod(sipParseErr, sipName_QScroller, sipName_handleInput, doc_QScroller_handleInput);

    return NULL;
}
bool AbstractWheelWidget::event(QEvent *e)
{
    switch (e->type()) {
// ![1]
    case QEvent::ScrollPrepare:
    {
        // We set the snap positions as late as possible so that we are sure
        // we get the correct itemHeight
        QScroller *scroller = QScroller::scroller(this);
        scroller->setSnapPositionsY( WHEEL_SCROLL_OFFSET, itemHeight() );

        QScrollPrepareEvent *se = static_cast<QScrollPrepareEvent *>(e);
        se->setViewportSize(QSizeF(size()));
        // we claim a huge scrolling area and a huge content position and
        // hope that the user doesn't notice that the scroll area is restricted
        se->setContentPosRange(QRectF(0.0, 0.0, 0.0, WHEEL_SCROLL_OFFSET * 2));
        se->setContentPos(QPointF(0.0, WHEEL_SCROLL_OFFSET + m_currentItem * itemHeight() + m_itemOffset));
        se->accept();
        return true;
    }
// ![1]
// ![2]
    case QEvent::Scroll:
    {
        QScrollEvent *se = static_cast<QScrollEvent *>(e);

        qreal y = se->contentPos().y();
        int iy = y - WHEEL_SCROLL_OFFSET;
        int ih = itemHeight();

// ![2]
// ![3]
        // -- calculate the current item position and offset and redraw the widget
        int ic = itemCount();
        if (ic>0) {
            m_currentItem = iy / ih % ic;
            m_itemOffset = iy % ih;

            // take care when scrolling backwards. Modulo returns negative numbers
            if (m_itemOffset < 0) {
                m_itemOffset += ih;
                m_currentItem--;
            }

            if (m_currentItem < 0)
                m_currentItem += ic;
        }
        // -- repaint
        update();

        se->accept();
        return true;
// ![3]
    }
    default:
        return QWidget::event(e);
    }
    return true;
}
Exemplo n.º 5
0
AllSensorsDialog::AllSensorsDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::AllSensorsDialog)
{
    ui->setupUi(this);

#ifdef Q_OS_ANDROID
    this->setWindowState(Qt::WindowMaximized);
#else
    this->resize(1000,750);
#endif


     QScroller *scroller = QScroller::scroller(ui->scrollArea);
     scroller->grabGesture(ui->scrollArea, QScroller::LeftMouseButtonGesture);
}
Exemplo n.º 6
0
bool PlotWidget::eventFilter(QObject *obj, QEvent *ev)
{
    if (ev->type() == QEvent::Scroll) {
        QScrollEvent *se = static_cast<QScrollEvent *>(ev);
        QScroller *scroller = QScroller::scroller(m_widget);

        QPointF v = scroller->velocity();
        //v.rx() *= scroller->pixelPerMeter().x();
        //v.ry() *= scroller->pixelPerMeter().y();

        PlotItem pi = { v, se->contentPos(), se->overshootDistance() };
        addPlotItem(pi);
    }

    return QWidget::eventFilter(obj, ev);
}
Exemplo n.º 7
0
void StreamsWidget::setupKineticScroller(QObject *target)
{
    QScrollerProperties sp;

    sp.setScrollMetric(QScrollerProperties::DragVelocitySmoothingFactor, 0.6);
    sp.setScrollMetric(QScrollerProperties::MinimumVelocity, 0.0);
    sp.setScrollMetric(QScrollerProperties::MaximumVelocity, 0.5);
    sp.setScrollMetric(QScrollerProperties::AcceleratingFlickMaximumTime, 0.4);
    sp.setScrollMetric(QScrollerProperties::AcceleratingFlickSpeedupFactor, 1.2);
    sp.setScrollMetric(QScrollerProperties::SnapPositionRatio, 0.2);
    sp.setScrollMetric(QScrollerProperties::MaximumClickThroughVelocity, 0);
    sp.setScrollMetric(QScrollerProperties::DragStartDistance, 0.001);
    sp.setScrollMetric(QScrollerProperties::MousePressEventDelay, 0.5);
    QScroller* scroller = QScroller::scroller(target);

    scroller->grabGesture(target, QScroller::LeftMouseButtonGesture);

    scroller->setScrollerProperties(sp);
}
Exemplo n.º 8
0
static PyObject *meth_QScroller_resendPrepareEvent(PyObject *sipSelf, PyObject *sipArgs)
{
    PyObject *sipParseErr = NULL;

    {
        QScroller *sipCpp;

        if (sipParseArgs(&sipParseErr, sipArgs, "B", &sipSelf, sipType_QScroller, &sipCpp))
        {
            sipCpp->resendPrepareEvent();

            Py_INCREF(Py_None);
            return Py_None;
        }
    }

    /* Raise an exception if the arguments couldn't be parsed. */
    sipNoMethod(sipParseErr, sipName_QScroller, sipName_resendPrepareEvent, doc_QScroller_resendPrepareEvent);

    return NULL;
}
Exemplo n.º 9
0
NotifyView::NotifyView(QWidget *parent) : QListView(parent)
{
    setFrameStyle(QFrame::NoFrame);
    setMouseTracking(true);
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setVerticalScrollMode(QListView::ScrollPerPixel);
    setSpacing(0);
    setContentsMargins(0, 0, 0, 0);
    setUpdatesEnabled(true);
    setStyleSheet("background-color: rgba(255, 255, 255, 7.65);");

    connect(this, &NotifyView::currentHoverChanged, this, &NotifyView::onCurrentHoverChanged);
    connect(this, &NotifyView::entered, this, &NotifyView::onItemEntered);

    QScroller::grabGesture(this, QScroller::LeftMouseButtonGesture);
    QScroller *scroller = QScroller::scroller(this);
    QScrollerProperties sp;
    sp.setScrollMetric(QScrollerProperties::VerticalOvershootPolicy, QScrollerProperties::OvershootAlwaysOff);
    scroller->setScrollerProperties(sp);
}
Exemplo n.º 10
0
static PyObject *meth_QScroller_ensureVisible(PyObject *sipSelf, PyObject *sipArgs)
{
    PyObject *sipParseErr = NULL;

    {
        const QRectF* a0;
        qreal a1;
        qreal a2;
        QScroller *sipCpp;

        if (sipParseArgs(&sipParseErr, sipArgs, "BJ9dd", &sipSelf, sipType_QScroller, &sipCpp, sipType_QRectF, &a0, &a1, &a2))
        {
            sipCpp->ensureVisible(*a0,a1,a2);

            Py_INCREF(Py_None);
            return Py_None;
        }
    }

    {
        const QRectF* a0;
        qreal a1;
        qreal a2;
        int a3;
        QScroller *sipCpp;

        if (sipParseArgs(&sipParseErr, sipArgs, "BJ9ddi", &sipSelf, sipType_QScroller, &sipCpp, sipType_QRectF, &a0, &a1, &a2, &a3))
        {
            sipCpp->ensureVisible(*a0,a1,a2,a3);

            Py_INCREF(Py_None);
            return Py_None;
        }
    }

    /* Raise an exception if the arguments couldn't be parsed. */
    sipNoMethod(sipParseErr, sipName_QScroller, sipName_ensureVisible, doc_QScroller_ensureVisible);

    return NULL;
}
Exemplo n.º 11
0
static PyObject *meth_QScroller_scrollTo(PyObject *sipSelf, PyObject *sipArgs)
{
    PyObject *sipParseErr = NULL;

    {
        const QPointF* a0;
        int a0State = 0;
        QScroller *sipCpp;

        if (sipParseArgs(&sipParseErr, sipArgs, "BJ1", &sipSelf, sipType_QScroller, &sipCpp, sipType_QPointF, &a0, &a0State))
        {
            sipCpp->scrollTo(*a0);
            sipReleaseType(const_cast<QPointF *>(a0),sipType_QPointF,a0State);

            Py_INCREF(Py_None);
            return Py_None;
        }
    }

    {
        const QPointF* a0;
        int a0State = 0;
        int a1;
        QScroller *sipCpp;

        if (sipParseArgs(&sipParseErr, sipArgs, "BJ1i", &sipSelf, sipType_QScroller, &sipCpp, sipType_QPointF, &a0, &a0State, &a1))
        {
            sipCpp->scrollTo(*a0,a1);
            sipReleaseType(const_cast<QPointF *>(a0),sipType_QPointF,a0State);

            Py_INCREF(Py_None);
            return Py_None;
        }
    }

    /* Raise an exception if the arguments couldn't be parsed. */
    sipNoMethod(sipParseErr, sipName_QScroller, sipName_scrollTo, doc_QScroller_scrollTo);

    return NULL;
}
Exemplo n.º 12
0
static PyObject *meth_QScroller_setScrollerProperties(PyObject *sipSelf, PyObject *sipArgs)
{
    PyObject *sipParseErr = NULL;

    {
        const QScrollerProperties* a0;
        QScroller *sipCpp;

        if (sipParseArgs(&sipParseErr, sipArgs, "BJ9", &sipSelf, sipType_QScroller, &sipCpp, sipType_QScrollerProperties, &a0))
        {
            sipCpp->setScrollerProperties(*a0);

            Py_INCREF(Py_None);
            return Py_None;
        }
    }

    /* Raise an exception if the arguments couldn't be parsed. */
    sipNoMethod(sipParseErr, sipName_QScroller, sipName_setScrollerProperties, doc_QScroller_setScrollerProperties);

    return NULL;
}
Exemplo n.º 13
0
static PyObject *meth_QScroller_setSnapPositionsY(PyObject *sipSelf, PyObject *sipArgs)
{
    PyObject *sipParseErr = NULL;

    {
        const QList<qreal>* a0;
        int a0State = 0;
        QScroller *sipCpp;

        if (sipParseArgs(&sipParseErr, sipArgs, "BJ1", &sipSelf, sipType_QScroller, &sipCpp, sipType_QList_2400,&a0, &a0State))
        {
            sipCpp->setSnapPositionsY(*a0);
            sipReleaseType(const_cast<QList<qreal> *>(a0),sipType_QList_2400,a0State);

            Py_INCREF(Py_None);
            return Py_None;
        }
    }

    {
        qreal a0;
        qreal a1;
        QScroller *sipCpp;

        if (sipParseArgs(&sipParseErr, sipArgs, "Bdd", &sipSelf, sipType_QScroller, &sipCpp, &a0, &a1))
        {
            sipCpp->setSnapPositionsY(a0,a1);

            Py_INCREF(Py_None);
            return Py_None;
        }
    }

    /* Raise an exception if the arguments couldn't be parsed. */
    sipNoMethod(sipParseErr, sipName_QScroller, sipName_setSnapPositionsY, doc_QScroller_setSnapPositionsY);

    return NULL;
}
Exemplo n.º 14
0
bool QtViewportInteractionEngine::scrollAnimationActive() const
{
    QScroller* scroller = const_cast<QtViewportInteractionEngine*>(this)->scroller();
    return scroller->state() == QScroller::Scrolling;
}
/*!
    Rotates the wheel widget to a given index.
    You can also give an index greater than itemCount or less than zero in which
    case the wheel widget will scroll in the given direction and end up with
    (index % itemCount)
*/
void AbstractWheelWidget::scrollTo(int index)
{
    QScroller *scroller = QScroller::scroller(this);

    scroller->scrollTo(QPointF(0, WHEEL_SCROLL_OFFSET + index * itemHeight()), 5000);
}
Exemplo n.º 16
0
bool QtViewportInteractionEngine::panGestureActive() const
{
    QScroller* scroller = const_cast<QtViewportInteractionEngine*>(this)->scroller();
    return scroller->state() == QScroller::Pressed || scroller->state() == QScroller::Dragging;
}
Exemplo n.º 17
0
CConfCore::CConfCore( const char *sDev, const char *sName, const char *sAon, int nMixPlata, int nMaxActivePorts, int nPartys,  QWidget *parent ) : QGroupBox(parent)
{
    m_pOwner = qobject_cast<CConfSMPClient*>(parent);
    if(!m_pOwner)
        QCoreApplication::exit(EXIT_FAILURE);

    QTextCodec *codec = QTextCodec::codecForName("Windows-1251");
    QString name = codec->toUnicode(sName);
    if(name.isEmpty())
        name = QString::number(m_pOwner->pOwner()->m_nVirtLink);

    QString title;
    title = name;
    title += '@';

    QString connected = m_pOwner->pOwner()->m_sHost;
    if(m_pOwner->pOwner()->m_nPort != 10011)
    {
        connected += ':';
        connected += QString::number(m_pOwner->pOwner()->m_nPort);
    }
    title += connected;
    title += " (";
    title += sDev;
    title += ')';

    setAlignment(Qt::AlignHCenter);
    setTitle(title);

    QString tooltip;
    tooltip += tr("Название");
    tooltip += ": ";
    tooltip += name;
    tooltip += '\n';

    tooltip += tr("Номер");
    tooltip += ": ";
    tooltip += sAon;
    tooltip += '\n';

    tooltip += tr("Подключен");
    tooltip += ": ";
    tooltip += connected;
    tooltip += '\n';

    tooltip += tr("Слот");
    tooltip += ": ";
    tooltip += QString::number(m_pOwner->pOwner()->m_nVirtLink - 768);
    tooltip += '\n';

    tooltip += tr("Плата");
    tooltip += ": ";
    tooltip += QString::number(nMixPlata);
    tooltip += '\n';

    tooltip += tr("Максимум активных");
    tooltip += ": ";
    tooltip += QString::number(nMaxActivePorts);

    setToolTip(tooltip);

    m_nMaxActivePorts = nMaxActivePorts;
#ifdef ANDROID
    FlowLayout* pLayout = new FlowLayout(6, 10, 7);
#else
    FlowLayout* pLayout = new FlowLayout(8, 8, 6);
#endif
    for(int i = 0; i < nPartys; i++)
    {
        CConfParty* party = new CConfParty(this);
        m_pPartys.push_back(party);
        pLayout->addWidget(party);
    }

    QVBoxLayout* pTopLayout = new QVBoxLayout;

    QScrollArea* scrl = new QScrollArea();
#ifdef ANDROID
    QScroller::grabGesture(scrl, QScroller::LeftMouseButtonGesture);
    QScroller* s = QScroller::scroller(scrl);
    QScrollerProperties p = s->scrollerProperties();
    p.setScrollMetric(QScrollerProperties::HorizontalOvershootPolicy, QScrollerProperties::OvershootAlwaysOff);
    p.setScrollMetric(QScrollerProperties::VerticalOvershootPolicy, QScrollerProperties::OvershootAlwaysOff);
    p.setScrollMetric(QScrollerProperties::OvershootDragDistanceFactor, 0);
    p.setScrollMetric(QScrollerProperties::OvershootScrollDistanceFactor, 0);

    //p.setScrollMetric(QScrollerProperties::OvershootDragResistanceFactor,  0.9);
    //p.setScrollMetric(QScrollerProperties::DragStartDistance,   0.001 );
    //p.setScrollMetric(QScrollerProperties::ScrollingCurve, QEasingCurve::Linear );
    //p.setScrollMetric(QScrollerProperties::AxisLockThreshold, 0.9);

    //Does this help?
    //p.setScrollMetric(QScrollerProperties::SnapTime, 1);
    //p.setScrollMetric(QScrollerProperties::SnapPositionRatio, 1);

    //p.setScrollMetric(QScrollerProperties::AcceleratingFlickSpeedupFactor, 2.5);
    //p.setScrollMetric(QScrollerProperties::AcceleratingFlickMaximumTime, 1.25);
    s->setScrollerProperties(p);
#endif
    QWidget* wgt = new QWidget();
    scrl->setWidget(wgt);
    scrl->setWidgetResizable(true);
    wgt->setLayout(pLayout);
    pTopLayout->addWidget(scrl);

    m_pBtnGather = new QPushButton(tr("Собрать всех"));
    m_pBtnGather->setIcon(m_pOwner->pOwner()->pix_gather);
    connect(m_pBtnGather, SIGNAL(clicked()), SLOT(slotGatherClicked()));
    m_pBtnGather->setToolTip(tr("Вызвать всех участников конференции"));

    m_pBtnDestroy = new QPushButton(tr("Отбить всех"));
    m_pBtnDestroy->setIcon(m_pOwner->pOwner()->pix_call_down);
    connect(m_pBtnDestroy, SIGNAL(clicked()), SLOT(slotDestroyClicked()));
    m_pBtnDestroy->setToolTip(tr("Отбить всех участников конференции"));

    m_pBtnReconnect = new QPushButton(tr("Обновить соединение"));
    m_pBtnReconnect->setIcon(m_pOwner->pOwner()->pix_connection);
    connect(m_pBtnReconnect, SIGNAL(clicked()), SLOT(slotReconnectClicked()));
    m_pBtnReconnect->setToolTip(tr("Обновить соединение с АТС"));

    QHBoxLayout* pLayoutH = new QHBoxLayout;
    pLayoutH->addWidget(m_pBtnGather);
    pLayoutH->addWidget(m_pBtnDestroy);
    pLayoutH->addWidget(m_pBtnReconnect);
    pTopLayout->addLayout(pLayoutH);
    pTopLayout->setMargin(4);
    setLayout(pTopLayout);
}