Skip to content

Commit

Permalink
fix: can not scroll view on DSettingDialog by touchscreen
Browse files Browse the repository at this point in the history
Change-Id: I0a14ea2571feeb16a40be061d7bb60e289b1cf57
  • Loading branch information
zccrs committed Jan 2, 2019
1 parent 0631278 commit 651dee2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/widgets/private/settings/content.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <QVBoxLayout>
#include <QCoreApplication>
#include <QScroller>
#include <QMouseEvent>

#include <DSettings>
#include <DSettingsGroup>
Expand Down Expand Up @@ -227,4 +228,16 @@ void Content::updateSettings(const QByteArray &translateContext, QPointer<DTK_CO
});
}

void Content::mouseMoveEvent(QMouseEvent *event)
{
// 事件来源为 MouseEventSynthesizedByQt 时认为此事件为Touch事件合成而来
// 由于支持触屏下对视图的滚动,所以此处接收没有被处理的move事件,防止事件泄露
// 到主窗口后触发窗口移动动作
if (event->source() == Qt::MouseEventSynthesizedByQt) {
event->accept();

return;
}
}

DWIDGET_END_NAMESPACE
2 changes: 2 additions & 0 deletions src/widgets/private/settings/content.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public Q_SLOTS:
void updateSettings(const QByteArray &translateContext, QPointer<DTK_CORE_NAMESPACE::DSettings> settings);

private:
void mouseMoveEvent(QMouseEvent *event) override;

QScopedPointer<ContentPrivate> d_ptr;
Q_DECLARE_PRIVATE_D(qGetPtrHelper(d_ptr), Content)
};
Expand Down

0 comments on commit 651dee2

Please sign in to comment.