2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 06:35:14 +00:00

Remove Qt MOC dependency for tabbed selector.

This commit is contained in:
John Preston
2018-11-21 22:14:48 +04:00
parent 9f5b09c263
commit ef4f0168f8
22 changed files with 552 additions and 476 deletions

View File

@@ -40,18 +40,14 @@ constexpr auto kInlineBotRequestDelay = 400;
} // namespace
Inner::Inner(QWidget *parent, not_null<Window::Controller*> controller) : TWidget(parent)
, _controller(controller) {
, _controller(controller)
, _updateInlineItems([=] { updateInlineItems(); })
, _previewTimer([=] { showPreview(); }) {
resize(st::emojiPanWidth - st::emojiScroll.width - st::buttonRadius, st::emojiPanMinHeight);
setMouseTracking(true);
setAttribute(Qt::WA_OpaquePaintEvent);
_previewTimer.setSingleShot(true);
connect(&_previewTimer, SIGNAL(timeout()), this, SLOT(onPreview()));
_updateInlineItems.setSingleShot(true);
connect(&_updateInlineItems, SIGNAL(timeout()), this, SLOT(onUpdateInlineItems()));
subscribe(Auth().downloaderTaskFinished(), [this] {
update();
});
@@ -194,11 +190,11 @@ void Inner::mousePressEvent(QMouseEvent *e) {
_pressed = _selected;
ClickHandler::pressed();
_previewTimer.start(QApplication::startDragTime());
_previewTimer.callOnce(QApplication::startDragTime());
}
void Inner::mouseReleaseEvent(QMouseEvent *e) {
_previewTimer.stop();
_previewTimer.cancel();
auto pressed = std::exchange(_pressed, -1);
auto activated = ClickHandler::unpressed();
@@ -572,7 +568,7 @@ void Inner::inlineItemRepaint(const ItemBase *layout) {
if (_lastScrolled + 100 <= ms) {
update();
} else {
_updateInlineItems.start(_lastScrolled + 100 - ms);
_updateInlineItems.callOnce(_lastScrolled + 100 - ms);
}
}
@@ -682,7 +678,7 @@ void Inner::updateSelected() {
}
}
void Inner::onPreview() {
void Inner::showPreview() {
if (_pressed < 0) return;
int row = _pressed / MatrixRowShift, col = _pressed % MatrixRowShift;
@@ -698,12 +694,12 @@ void Inner::onPreview() {
}
}
void Inner::onUpdateInlineItems() {
void Inner::updateInlineItems() {
auto ms = getms();
if (_lastScrolled + 100 <= ms) {
update();
} else {
_updateInlineItems.start(_lastScrolled + 100 - ms);
_updateInlineItems.callOnce(_lastScrolled + 100 - ms);
}
}