Removed Q_OBJECT from FlatLabel.

This commit is contained in:
23rd 2021-04-10 21:54:51 +03:00
parent 86c1cce260
commit fc357ae28f
2 changed files with 14 additions and 16 deletions

View file

@ -231,7 +231,7 @@ FlatLabel::FlatLabel(
: RpWidget(parent) : RpWidget(parent)
, _text(st.minWidth ? st.minWidth : QFIXED_MAX) , _text(st.minWidth ? st.minWidth : QFIXED_MAX)
, _st(st) , _st(st)
, _touchSelectTimer([=] { onTouchSelect(); }) { , _touchSelectTimer([=] { touchSelect(); }) {
textUpdated(); textUpdated();
std::move( std::move(
text text
@ -518,7 +518,7 @@ void FlatLabel::keyPressEvent(QKeyEvent *e) {
e->ignore(); e->ignore();
if (e->key() == Qt::Key_Copy || (e->key() == Qt::Key_C && e->modifiers().testFlag(Qt::ControlModifier))) { if (e->key() == Qt::Key_Copy || (e->key() == Qt::Key_C && e->modifiers().testFlag(Qt::ControlModifier))) {
if (!_selection.empty()) { if (!_selection.empty()) {
onCopySelectedText(); copySelectedText();
e->accept(); e->accept();
} }
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
@ -631,15 +631,15 @@ void FlatLabel::showContextMenu(QContextMenuEvent *e, ContextMenuReason reason)
if (fullSelection && !_contextCopyText.isEmpty()) { if (fullSelection && !_contextCopyText.isEmpty()) {
_contextMenu->addAction( _contextMenu->addAction(
_contextCopyText, _contextCopyText,
[=] { onCopyContextText(); }); [=] { copyContextText(); });
} else if (uponSelection && !fullSelection) { } else if (uponSelection && !fullSelection) {
_contextMenu->addAction( _contextMenu->addAction(
Integration::Instance().phraseContextCopySelected(), Integration::Instance().phraseContextCopySelected(),
[=] { onCopySelectedText(); }); [=] { copySelectedText(); });
} else if (_selectable && !hasSelection && !_contextCopyText.isEmpty()) { } else if (_selectable && !hasSelection && !_contextCopyText.isEmpty()) {
_contextMenu->addAction( _contextMenu->addAction(
_contextCopyText, _contextCopyText,
[=] { onCopyContextText(); }); [=] { copyContextText(); });
} }
if (const auto link = ClickHandler::getActive()) { 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; const auto selection = _selection.empty() ? (_contextMenu ? _savedSelection : _selection) : _selection;
if (!selection.empty()) { if (!selection.empty()) {
TextUtilities::SetClipboardText(_text.toTextForMimeData(selection)); TextUtilities::SetClipboardText(_text.toTextForMimeData(selection));
} }
} }
void FlatLabel::onCopyContextText() { void FlatLabel::copyContextText() {
TextUtilities::SetClipboardText(_text.toTextForMimeData()); TextUtilities::SetClipboardText(_text.toTextForMimeData());
} }
void FlatLabel::onTouchSelect() { void FlatLabel::touchSelect() {
_touchSelect = true; _touchSelect = true;
dragActionStart(_touchPos, Qt::LeftButton); dragActionStart(_touchPos, Qt::LeftButton);
} }
void FlatLabel::onExecuteDrag() { void FlatLabel::executeDrag() {
if (_dragAction != Dragging) return; if (_dragAction != Dragging) return;
auto state = getTextState(_dragStartPosition); auto state = getTextState(_dragStartPosition);
@ -754,7 +754,7 @@ Text::StateResult FlatLabel::dragActionUpdate() {
if (_dragAction == PrepareDrag && (m - _dragStartPosition).manhattanLength() >= QApplication::startDragDistance()) { if (_dragAction == PrepareDrag && (m - _dragStartPosition).manhattanLength() >= QApplication::startDragDistance()) {
_dragAction = Dragging; _dragAction = Dragging;
InvokeQueued(this, [=] { onExecuteDrag(); }); InvokeQueued(this, [=] { executeDrag(); });
} }
return state; return state;

View file

@ -94,7 +94,6 @@ private:
}; };
class FlatLabel : public RpWidget, public ClickHandlerHost { class FlatLabel : public RpWidget, public ClickHandlerHost {
Q_OBJECT
public: public:
FlatLabel(QWidget *parent, const style::FlatLabel &st = st::defaultFlatLabel); FlatLabel(QWidget *parent, const style::FlatLabel &st = st::defaultFlatLabel);
@ -166,13 +165,12 @@ protected:
int resizeGetHeight(int newWidth) override; int resizeGetHeight(int newWidth) override;
private Q_SLOTS: void copySelectedText();
void onCopySelectedText(); void copyContextText();
void onCopyContextText();
void onTouchSelect(); void touchSelect();
void onExecuteDrag(); void executeDrag();
private: private:
void init(); void init();