mirror of https://github.com/vitalif/openscad
Mac: Findbuffer support
parent
8d3d2fe9f4
commit
e533d2a71a
|
@ -146,6 +146,10 @@ private slots:
|
|||
void useSelectionForFind();
|
||||
void replace();
|
||||
void replaceAll();
|
||||
|
||||
// Mac OSX FindBuffer support
|
||||
void findBufferChanged();
|
||||
void updateFindBuffer(QString);
|
||||
protected:
|
||||
virtual bool eventFilter(QObject* obj, QEvent *event);
|
||||
|
||||
|
|
|
@ -84,6 +84,7 @@
|
|||
#include <QMutexLocker>
|
||||
#include <QTemporaryFile>
|
||||
#include <QDockWidget>
|
||||
#include <QClipboard>
|
||||
|
||||
#include <fstream>
|
||||
|
||||
|
@ -426,6 +427,13 @@ MainWindow::MainWindow(const QString &filename)
|
|||
connect(this->findInputField, SIGNAL(textChanged(QString)), this, SLOT(findString(QString)));
|
||||
connect(this->findInputField, SIGNAL(returnPressed()), this->nextButton, SLOT(animateClick()));
|
||||
find_panel->installEventFilter(this);
|
||||
if (QApplication::clipboard()->supportsFindBuffer()) {
|
||||
connect(this->findInputField, SIGNAL(textChanged(QString)), this, SLOT(updateFindBuffer(QString)));
|
||||
connect(QApplication::clipboard(), SIGNAL(findBufferChanged()), this, SLOT(findBufferChanged()));
|
||||
// With Qt 4.8.6, there seems to be a bug that often gives an incorrect findbuffer content when
|
||||
// the app receives focus for the first time
|
||||
this->findInputField->setText(QApplication::clipboard()->text(QClipboard::FindBuffer));
|
||||
}
|
||||
|
||||
connect(this->prevButton, SIGNAL(clicked()), this, SLOT(findPrev()));
|
||||
connect(this->nextButton, SIGNAL(clicked()), this, SLOT(findNext()));
|
||||
|
@ -1288,6 +1296,19 @@ void MainWindow::useSelectionForFind()
|
|||
findInputField->setText(editor->selectedText());
|
||||
}
|
||||
|
||||
void MainWindow::updateFindBuffer(QString s) {
|
||||
QApplication::clipboard()->setText(s, QClipboard::FindBuffer);
|
||||
}
|
||||
|
||||
void MainWindow::findBufferChanged() {
|
||||
QString t = QApplication::clipboard()->text(QClipboard::FindBuffer);
|
||||
// The convention seems to be to not update the search field if the findbuffer is empty
|
||||
if (!t.isEmpty()) {
|
||||
findInputField->setText(t);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool MainWindow::eventFilter(QObject* obj, QEvent *event)
|
||||
{
|
||||
if (obj == find_panel)
|
||||
|
|
Loading…
Reference in New Issue