- fix: can't paste contents copied from Clion/IDEA/PyCharm

This commit is contained in:
Roy Qu 2022-06-16 09:11:45 +08:00
parent 04311eb8e5
commit c4ca944a15
3 changed files with 45 additions and 43 deletions

View File

@ -3,6 +3,7 @@ Red Panda C++ Version 1.1.1
- change: swap position of problem case's output and expected input controls
- enhancement: when problem case panel is positioned at right, problem case's input, output and expected controls is layouted vertically
- enhancement: add ignore spaces checkbox in problem cases panel
- fix: can't paste contents copied from Clion/IDEA/PyCharm
Red Panda C++ Version 1.1.0
- enhancement: when ctrl+mouse cursor hovered an identifier or header name, use underline to highlight it

View File

@ -4852,7 +4852,13 @@ void MainWindow::on_actionPaste_triggered()
const QMimeData* data = clipboard->mimeData();
if (!data)
return;
if (data->hasUrls()) {
if (data->hasText()) {
Editor * editor = mEditorList->getEditor();
if (editor != NULL ) {
editor->pasteFromClipboard();
editor->activate();
}
} else if (data->hasUrls()) {
QStringList filesToOpen;
foreach (const QUrl& url, data->urls()) {
QString s = url.toLocalFile();
@ -4862,12 +4868,6 @@ void MainWindow::on_actionPaste_triggered()
}
if (!filesToOpen.isEmpty())
openFiles(filesToOpen);
} else {
Editor * editor = mEditorList->getEditor();
if (editor != NULL ) {
editor->pasteFromClipboard();
editor->activate();
}
}
}

View File

@ -38,6 +38,8 @@
#include <QDrag>
#include <QMimeData>
#include <QDesktopWidget>
#include <QTextEdit>
#include <QMimeData>
SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent),
mDropped(false)
@ -3016,7 +3018,8 @@ void SynEdit::doPasteFromClipboard()
if (mReadOnly)
return;
QClipboard* clipboard = QGuiApplication::clipboard();
if (clipboard->text().isEmpty())
QString text = clipboard->text();
if (text.isEmpty())
return;
doOnPaintTransient(SynTransientType::ttBefore);
mUndoList->BeginBlock();
@ -3031,7 +3034,6 @@ void SynEdit::doPasteFromClipboard()
SynSelectionMode::smNormal);
mUndoList->EndBlock();
});
if (!clipboard->text().isEmpty()) {
mUndoList->AddChange(
SynChangeReason::crPasteBegin,
blockBegin(),
@ -3053,7 +3055,7 @@ void SynEdit::doPasteFromClipboard()
BufferCoord vEndOfBlock = blockEnd();
mBlockBegin = vStartOfBlock;
mBlockEnd = vEndOfBlock;
setSelTextPrimitive(clipboard->text());
setSelTextPrimitive(text);
if (mActiveSelectionMode == SynSelectionMode::smColumn) {
mUndoList->AddChange(
SynChangeReason::crPaste,
@ -3072,7 +3074,6 @@ void SynEdit::doPasteFromClipboard()
mActiveSelectionMode);
}
}
}
void SynEdit::incPaintLock()
{