From fc357ae28f6a13cf7116916cff1d260b92865059 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Sat, 10 Apr 2021 21:54:51 +0300 Subject: [PATCH] Removed Q_OBJECT from FlatLabel. --- ui/widgets/labels.cpp | 20 ++++++++++---------- ui/widgets/labels.h | 10 ++++------ 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/ui/widgets/labels.cpp b/ui/widgets/labels.cpp index 5fa7eed..d64d859 100644 --- a/ui/widgets/labels.cpp +++ b/ui/widgets/labels.cpp @@ -231,7 +231,7 @@ FlatLabel::FlatLabel( : RpWidget(parent) , _text(st.minWidth ? st.minWidth : QFIXED_MAX) , _st(st) -, _touchSelectTimer([=] { onTouchSelect(); }) { +, _touchSelectTimer([=] { touchSelect(); }) { textUpdated(); std::move( text @@ -518,7 +518,7 @@ void FlatLabel::keyPressEvent(QKeyEvent *e) { e->ignore(); if (e->key() == Qt::Key_Copy || (e->key() == Qt::Key_C && e->modifiers().testFlag(Qt::ControlModifier))) { if (!_selection.empty()) { - onCopySelectedText(); + copySelectedText(); e->accept(); } #ifdef Q_OS_MAC @@ -631,15 +631,15 @@ void FlatLabel::showContextMenu(QContextMenuEvent *e, ContextMenuReason reason) if (fullSelection && !_contextCopyText.isEmpty()) { _contextMenu->addAction( _contextCopyText, - [=] { onCopyContextText(); }); + [=] { copyContextText(); }); } else if (uponSelection && !fullSelection) { _contextMenu->addAction( Integration::Instance().phraseContextCopySelected(), - [=] { onCopySelectedText(); }); + [=] { copySelectedText(); }); } else if (_selectable && !hasSelection && !_contextCopyText.isEmpty()) { _contextMenu->addAction( _contextCopyText, - [=] { onCopyContextText(); }); + [=] { copyContextText(); }); } if (const auto link = ClickHandler::getActive()) { @@ -661,23 +661,23 @@ void FlatLabel::showContextMenu(QContextMenuEvent *e, ContextMenuReason reason) } } -void FlatLabel::onCopySelectedText() { +void FlatLabel::copySelectedText() { const auto selection = _selection.empty() ? (_contextMenu ? _savedSelection : _selection) : _selection; if (!selection.empty()) { TextUtilities::SetClipboardText(_text.toTextForMimeData(selection)); } } -void FlatLabel::onCopyContextText() { +void FlatLabel::copyContextText() { TextUtilities::SetClipboardText(_text.toTextForMimeData()); } -void FlatLabel::onTouchSelect() { +void FlatLabel::touchSelect() { _touchSelect = true; dragActionStart(_touchPos, Qt::LeftButton); } -void FlatLabel::onExecuteDrag() { +void FlatLabel::executeDrag() { if (_dragAction != Dragging) return; auto state = getTextState(_dragStartPosition); @@ -754,7 +754,7 @@ Text::StateResult FlatLabel::dragActionUpdate() { if (_dragAction == PrepareDrag && (m - _dragStartPosition).manhattanLength() >= QApplication::startDragDistance()) { _dragAction = Dragging; - InvokeQueued(this, [=] { onExecuteDrag(); }); + InvokeQueued(this, [=] { executeDrag(); }); } return state; diff --git a/ui/widgets/labels.h b/ui/widgets/labels.h index 0dbe992..ddc2edf 100644 --- a/ui/widgets/labels.h +++ b/ui/widgets/labels.h @@ -94,7 +94,6 @@ private: }; class FlatLabel : public RpWidget, public ClickHandlerHost { - Q_OBJECT public: FlatLabel(QWidget *parent, const style::FlatLabel &st = st::defaultFlatLabel); @@ -166,13 +165,12 @@ protected: int resizeGetHeight(int newWidth) override; -private Q_SLOTS: - void onCopySelectedText(); - void onCopyContextText(); + void copySelectedText(); + void copyContextText(); - void onTouchSelect(); + void touchSelect(); - void onExecuteDrag(); + void executeDrag(); private: void init();