~ubuntu-sdk-team/ubuntu-ui-toolkit/orientationNoOp

« back to all changes in this revision

Viewing changes to src/Ubuntu/Components/plugin/uclistitem.cpp

  • Committer: Tarmac
  • Author(s): Christian Dywan
  • Date: 2015-07-29 12:07:02 UTC
  • mfrom: (1570.3.4 uut.staging)
  • Revision ID: tarmac-20150729120702-cll9n4yn2seonuxn
Only swipe with left button and block timer otherwise. Fixes: https://bugs.launchpad.net/bugs/1476300, https://bugs.launchpad.net/bugs/1476310.

Approved by Zsombor Egri, PS Jenkins bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1057
1057
{
1058
1058
    UCStyledItemBase::mousePressEvent(event);
1059
1059
    Q_D(UCListItem);
 
1060
    d->button = event->button();
1060
1061
    if (d->parentAttached && d->parentAttached->isMoving()) {
1061
1062
        // while moving, we cannot select any items
1062
1063
        return;
1063
1064
    }
1064
 
    if (d->canHighlight(event)
1065
 
            && !d->highlighted && event->button() == Qt::LeftButton) {
 
1065
    if (d->canHighlight(event) && !d->highlighted && event->button() == Qt::LeftButton) {
1066
1066
        // create style instance
1067
1067
        d->loadStyleItem();
1068
1068
        d->setHighlighted(true);
1090
1090
{
1091
1091
    UCListItem::mousePressEvent(event);
1092
1092
    if (shouldShowContextMenu(event)) {
 
1093
        Q_D(UCListItem);
 
1094
 
1093
1095
        // Highlight the Item while the menu is showing
1094
 
        setHighlighted(true);
 
1096
        d->setHighlighted(true);
 
1097
        // Reset the timer which otherwise is started with highlighting
 
1098
        d->pressAndHoldTimer.stop();
1095
1099
 
1096
 
        Q_D(UCListItem);
1097
1100
        quint16 version(d->getTheme()->version());
1098
1101
        QString versionString(QStringLiteral("%1.%2").arg(MAJOR_VERSION(version)).arg(MINOR_VERSION(version)));
1099
1102
        QUrl url(UbuntuComponentsPlugin::pluginUrl().resolved(versionString + "/ListItemPopover.qml"));
1118
1121
 
1119
1122
void UCListItem13::popoverClosed()
1120
1123
{
1121
 
    setHighlighted(false);
1122
 
}
1123
 
 
1124
 
void UCListItem::setHighlighted(bool highlighted)
1125
 
{
1126
1124
    Q_D(UCListItem);
1127
 
    d->setHighlighted(highlighted);
 
1125
    d->setHighlighted(false);
1128
1126
}
1129
1127
 
1130
1128
void UCListItem::mouseReleaseEvent(QMouseEvent *event)
1131
1129
{
1132
1130
    UCStyledItemBase::mouseReleaseEvent(event);
1133
1131
    Q_D(UCListItem);
 
1132
    d->button = Qt::NoButton;
1134
1133
    // set released
1135
1134
    if (d->highlighted) {
1136
1135
        // unblock ascending Flickables
1152
1151
            // inform style about mouse/touch release
1153
1152
            d->swipeEvent(event->localPos(), UCSwipeEvent::Finished);
1154
1153
            d->suppressClick = false;
 
1154
            d->setHighlighted(false);
1155
1155
        }
1156
 
        d->setHighlighted(false);
1157
1156
    }
1158
1157
}
1159
1158
 
1174
1173
    }
1175
1174
 
1176
1175
    // accept the tugging only if the move is within the threshold
1177
 
    if (d->highlighted && !d->swiped && (d->leadingActions || d->trailingActions)) {
 
1176
    // use saved button because MouseMove has no button() and buttons() isn't reliable
 
1177
    if (d->button == Qt::LeftButton && d->highlighted && !d->swiped && (d->leadingActions || d->trailingActions)) {
1178
1178
        // check if we can initiate the drag at all
1179
1179
        // only X direction matters, if Y-direction leaves the threshold, but X not, the tug is not valid
1180
1180
        qreal threshold = UCUnits::instance().gu(d->xAxisMoveThresholdGU);