Replaced QTimer with base::Timer in FlatLabel.
This commit is contained in:
parent
92fe8b138b
commit
86c1cce260
2 changed files with 10 additions and 15 deletions
|
|
@ -230,7 +230,8 @@ FlatLabel::FlatLabel(
|
||||||
const style::FlatLabel &st)
|
const style::FlatLabel &st)
|
||||||
: RpWidget(parent)
|
: RpWidget(parent)
|
||||||
, _text(st.minWidth ? st.minWidth : QFIXED_MAX)
|
, _text(st.minWidth ? st.minWidth : QFIXED_MAX)
|
||||||
, _st(st) {
|
, _st(st)
|
||||||
|
, _touchSelectTimer([=] { onTouchSelect(); }) {
|
||||||
textUpdated();
|
textUpdated();
|
||||||
std::move(
|
std::move(
|
||||||
text
|
text
|
||||||
|
|
@ -242,11 +243,6 @@ FlatLabel::FlatLabel(
|
||||||
|
|
||||||
void FlatLabel::init() {
|
void FlatLabel::init() {
|
||||||
_contextCopyText = Integration::Instance().phraseContextCopyText();
|
_contextCopyText = Integration::Instance().phraseContextCopyText();
|
||||||
|
|
||||||
_trippleClickTimer.setSingleShot(true);
|
|
||||||
|
|
||||||
_touchSelectTimer.setSingleShot(true);
|
|
||||||
connect(&_touchSelectTimer, SIGNAL(timeout()), this, SLOT(onTouchSelect()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FlatLabel::textUpdated() {
|
void FlatLabel::textUpdated() {
|
||||||
|
|
@ -406,7 +402,7 @@ Text::StateResult FlatLabel::dragActionStart(const QPoint &p, Qt::MouseButton bu
|
||||||
_dragAction = Selecting;
|
_dragAction = Selecting;
|
||||||
_selectionType = TextSelectType::Paragraphs;
|
_selectionType = TextSelectType::Paragraphs;
|
||||||
updateHover(state);
|
updateHover(state);
|
||||||
_trippleClickTimer.start(QApplication::doubleClickInterval());
|
_trippleClickTimer.callOnce(QApplication::doubleClickInterval());
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -486,7 +482,7 @@ void FlatLabel::mouseDoubleClickEvent(QMouseEvent *e) {
|
||||||
mouseMoveEvent(e);
|
mouseMoveEvent(e);
|
||||||
|
|
||||||
_trippleClickPoint = e->globalPos();
|
_trippleClickPoint = e->globalPos();
|
||||||
_trippleClickTimer.start(QApplication::doubleClickInterval());
|
_trippleClickTimer.callOnce(QApplication::doubleClickInterval());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -559,7 +555,7 @@ void FlatLabel::touchEvent(QTouchEvent *e) {
|
||||||
if (e->type() == QEvent::TouchCancel) { // cancel
|
if (e->type() == QEvent::TouchCancel) { // cancel
|
||||||
if (!_touchInProgress) return;
|
if (!_touchInProgress) return;
|
||||||
_touchInProgress = false;
|
_touchInProgress = false;
|
||||||
_touchSelectTimer.stop();
|
_touchSelectTimer.cancel();
|
||||||
_touchSelect = false;
|
_touchSelect = false;
|
||||||
_dragAction = NoDrag;
|
_dragAction = NoDrag;
|
||||||
return;
|
return;
|
||||||
|
|
@ -580,7 +576,7 @@ void FlatLabel::touchEvent(QTouchEvent *e) {
|
||||||
if (e->touchPoints().isEmpty()) return;
|
if (e->touchPoints().isEmpty()) return;
|
||||||
|
|
||||||
_touchInProgress = true;
|
_touchInProgress = true;
|
||||||
_touchSelectTimer.start(QApplication::startDragTime());
|
_touchSelectTimer.callOnce(QApplication::startDragTime());
|
||||||
_touchSelect = false;
|
_touchSelect = false;
|
||||||
_touchStart = _touchPrevPos = _touchPos;
|
_touchStart = _touchPrevPos = _touchPos;
|
||||||
} break;
|
} break;
|
||||||
|
|
@ -606,7 +602,7 @@ void FlatLabel::touchEvent(QTouchEvent *e) {
|
||||||
dragActionFinish(_touchPos, Qt::LeftButton);
|
dragActionFinish(_touchPos, Qt::LeftButton);
|
||||||
}
|
}
|
||||||
if (weak) {
|
if (weak) {
|
||||||
_touchSelectTimer.stop();
|
_touchSelectTimer.cancel();
|
||||||
_touchSelect = false;
|
_touchSelect = false;
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
//
|
//
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "base/timer.h"
|
||||||
#include "base/unique_qptr.h"
|
#include "base/unique_qptr.h"
|
||||||
#include "ui/rp_widget.h"
|
#include "ui/rp_widget.h"
|
||||||
#include "ui/wrap/padding_wrap.h"
|
#include "ui/wrap/padding_wrap.h"
|
||||||
|
|
@ -14,8 +15,6 @@
|
||||||
#include "ui/widgets/box_content_divider.h"
|
#include "ui/widgets/box_content_divider.h"
|
||||||
#include "styles/style_widgets.h"
|
#include "styles/style_widgets.h"
|
||||||
|
|
||||||
#include <QtCore/QTimer>
|
|
||||||
|
|
||||||
class QTouchEvent;
|
class QTouchEvent;
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
|
|
@ -227,7 +226,7 @@ private:
|
||||||
QPoint _lastMousePos;
|
QPoint _lastMousePos;
|
||||||
|
|
||||||
QPoint _trippleClickPoint;
|
QPoint _trippleClickPoint;
|
||||||
QTimer _trippleClickTimer;
|
base::Timer _trippleClickTimer;
|
||||||
|
|
||||||
base::unique_qptr<PopupMenu> _contextMenu;
|
base::unique_qptr<PopupMenu> _contextMenu;
|
||||||
QString _contextCopyText;
|
QString _contextCopyText;
|
||||||
|
|
@ -238,7 +237,7 @@ private:
|
||||||
bool _touchSelect = false;
|
bool _touchSelect = false;
|
||||||
bool _touchInProgress = false;
|
bool _touchInProgress = false;
|
||||||
QPoint _touchStart, _touchPrevPos, _touchPos;
|
QPoint _touchStart, _touchPrevPos, _touchPos;
|
||||||
QTimer _touchSelectTimer;
|
base::Timer _touchSelectTimer;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue