mirror of https://gitee.com/cxasm/notepad--.git
cmake-plugin: 处理在 Windows 中简转繁无法使用多线程实时转换问题
This commit is contained in:
parent
99e3db95ab
commit
0415bf2506
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include <QSplitter>
|
||||
#include <QThreadPool>
|
||||
#include <qpushbutton.h>
|
||||
#include <qsciscintilla.h>
|
||||
|
||||
NddPluginImplement::NddPluginImplement(QWidget *parent, QsciScintilla *pEdit) : QMainWindow (parent)
|
||||
|
@ -17,7 +18,20 @@ NddPluginImplement::NddPluginImplement(QWidget *parent, QsciScintilla *pEdit) :
|
|||
splitter->setChildrenCollapsible(false);
|
||||
splitter->setHandleWidth(5);
|
||||
|
||||
ui->horizontalLayout->addWidget(splitter);
|
||||
ui->horizontalLayout_2->addWidget(splitter);
|
||||
|
||||
#if WIN32
|
||||
connect(ui->pushButton, &QPushButton::clicked, this, [&](){
|
||||
task = new OpenCCTask(this, ui->textEdit->toPlainText());
|
||||
connect(task, &OpenCCTask::complete, this, [=](const QString text) {
|
||||
this->ui->textBrowser->setText(text);
|
||||
});
|
||||
task->run();
|
||||
task->deleteLater();
|
||||
});
|
||||
#else
|
||||
ui->pushButton->hide();
|
||||
#endif
|
||||
}
|
||||
|
||||
NddPluginImplement::~NddPluginImplement()
|
||||
|
@ -27,9 +41,12 @@ NddPluginImplement::~NddPluginImplement()
|
|||
|
||||
void NddPluginImplement::on_textEdit_textChanged()
|
||||
{
|
||||
#if WIN32
|
||||
#else
|
||||
task = new OpenCCTask(this, ui->textEdit->toPlainText());
|
||||
connect(task, &OpenCCTask::complete, this, [=](const QString text) {
|
||||
this->ui->textBrowser->setText(text);
|
||||
});
|
||||
QThreadPool::globalInstance()->start(task);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -14,12 +14,23 @@
|
|||
<string>简繁转换面板 - Demo</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QTextEdit" name="textEdit"/>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QTextBrowser" name="textBrowser"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTextEdit" name="textEdit"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTextBrowser" name="textBrowser"/>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="text">
|
||||
<string>Convert</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
@ -29,7 +40,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>554</width>
|
||||
<height>27</height>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
|
|
Loading…
Reference in New Issue