From d6b3771524a5c7c9bdb4f6d6c9ad38a075778052 Mon Sep 17 00:00:00 2001 From: Zhang Yong Date: Tue, 15 Jun 2021 11:34:49 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E8=AF=86=E5=88=AB?= =?UTF-8?q?=E7=BB=93=E6=9E=9C=E5=B1=95=E7=A4=BA=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加识别结果展示接口 Log: 识别展示接口方面 Change-Id: I8ae47b70b404e69d79a36f9ada9c4e476316cfdc --- src/mainwidget.cpp | 34 ++++++++++++++++++++++++++++++---- src/mainwidget.h | 4 ++++ src/mainwindow.cpp | 2 ++ 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/src/mainwidget.cpp b/src/mainwidget.cpp index 9871128..6a6153c 100644 --- a/src/mainwidget.cpp +++ b/src/mainwidget.cpp @@ -24,7 +24,6 @@ MainWidget::MainWidget(QWidget *parent) : setIcons(themeType); setupConnect(); - } MainWidget::~MainWidget() @@ -234,23 +233,50 @@ void MainWidget::openImage(const QImage &img) } } +void MainWidget::loadHtml(const QString &html) +{ + if (!html.isEmpty()) { + m_plainTextEdit->appendHtml(html); + } +} + +void MainWidget::loadString(const QString &string) +{ + if (!string.isEmpty()) { + QStringList templist = string.split("\r\n", QString::KeepEmptyParts); + for (int i = 0; i < templist.size(); i++) { + m_plainTextEdit->appendPlainText(templist.at(i)); + } + } +} + void MainWidget::resizeEvent(QResizeEvent *event) { loadingUi(); + m_pwidget->setFixedSize(this->width(), this->height() - 48); + m_pwidget->move(0, 0); return DWidget::resizeEvent(event); } void MainWidget::slotCopy() { + //复制所有内容 + QTextDocument *document = m_plainTextEdit->document(); + DPlainTextEdit *tempTextEdit = new DPlainTextEdit(this); + tempTextEdit->setDocument(document); + tempTextEdit->selectAll(); + tempTextEdit->copy(); + QIcon icon(":/assets/icon_toast_sucess_new.svg"); - DFloatingMessage *pDFloatingMessage = new DFloatingMessage(DFloatingMessage::MessageType::TransientType, this); + DFloatingMessage *pDFloatingMessage = new DFloatingMessage(DFloatingMessage::MessageType::TransientType, m_pwidget); pDFloatingMessage->setBlurBackgroundEnabled(true); pDFloatingMessage->setMessage(tr("Copied")); pDFloatingMessage->setIcon(icon); pDFloatingMessage->raise(); - DMessageManager::instance()->sendMessage(this, pDFloatingMessage); - m_plainTextEdit->copy(); + DMessageManager::instance()->sendMessage(m_pwidget, pDFloatingMessage); + tempTextEdit->deleteLater(); + tempTextEdit = nullptr; } void MainWidget::slotExport() diff --git a/src/mainwidget.h b/src/mainwidget.h index 59c523c..3e6aabd 100644 --- a/src/mainwidget.h +++ b/src/mainwidget.h @@ -34,6 +34,10 @@ public: void openImage(const QString &path); void openImage(const QImage &img); + + void loadHtml(const QString &html); + void loadString(const QString &string); + protected: void resizeEvent(QResizeEvent *event); private slots: diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 4d41393..617b96a 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -35,6 +35,8 @@ MainWindow::MainWindow(QWidget *parent) m_mainWidget = new MainWidget(this); } this->setCentralWidget(m_mainWidget); + this->resize(840, 550); + this->setMinimumSize(840, 550); } MainWindow::~MainWindow()