mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 14:45:14 +00:00
@@ -2467,6 +2467,24 @@ void InputArea::Inner::contextMenuEvent(QContextMenuEvent *e) {
|
||||
}
|
||||
}
|
||||
|
||||
bool InputArea::Inner::canInsertFromMimeData(const QMimeData *source) const {
|
||||
if (source
|
||||
&& f()->_mimeDataHook
|
||||
&& f()->_mimeDataHook(source, MimeAction::Check)) {
|
||||
return true;
|
||||
}
|
||||
return QTextEdit::canInsertFromMimeData(source);
|
||||
}
|
||||
|
||||
void InputArea::Inner::insertFromMimeData(const QMimeData *source) {
|
||||
if (source
|
||||
&& f()->_mimeDataHook
|
||||
&& f()->_mimeDataHook(source, MimeAction::Insert)) {
|
||||
return;
|
||||
}
|
||||
return QTextEdit::insertFromMimeData(source);
|
||||
}
|
||||
|
||||
void InputArea::resizeEvent(QResizeEvent *e) {
|
||||
refreshPlaceholder();
|
||||
_inner->setGeometry(rect().marginsRemoved(_st.textMargins));
|
||||
|
@@ -387,6 +387,17 @@ public:
|
||||
_inner->clearFocus();
|
||||
}
|
||||
|
||||
enum class MimeAction {
|
||||
Check,
|
||||
Insert,
|
||||
};
|
||||
using MimeDataHook = base::lambda<bool(
|
||||
not_null<const QMimeData*> data,
|
||||
MimeAction action)>;
|
||||
void setMimeDataHook(MimeDataHook hook) {
|
||||
_mimeDataHook = std::move(hook);
|
||||
}
|
||||
|
||||
private slots:
|
||||
void onTouchTimer();
|
||||
|
||||
@@ -441,6 +452,8 @@ private:
|
||||
void keyPressEvent(QKeyEvent *e) override;
|
||||
void contextMenuEvent(QContextMenuEvent *e) override;
|
||||
|
||||
bool canInsertFromMimeData(const QMimeData *source) const override;
|
||||
void insertFromMimeData(const QMimeData *source) override;
|
||||
QMimeData *createMimeDataFromSelection() const override;
|
||||
|
||||
private:
|
||||
@@ -504,6 +517,7 @@ private:
|
||||
QPoint _touchStart;
|
||||
|
||||
bool _correcting = false;
|
||||
MimeDataHook _mimeDataHook;
|
||||
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user