feat: 改造了复制按钮,按照需求,新增默认文件名称
Description: 改造了复制按钮,按照需求,新增默认文件名称 Log: 改造了复制按钮,按照需求,新增默认文件名称 Change-Id: Ia6a84937bc49c4399fb3ab915a978d89504a8ce3
This commit is contained in:
parent
acd6ab1600
commit
40c90fc3c7
|
@ -13,6 +13,7 @@
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QMutexLocker>
|
#include <QMutexLocker>
|
||||||
#include <QSplitter>
|
#include <QSplitter>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
#include <DGuiApplicationHelper>
|
#include <DGuiApplicationHelper>
|
||||||
#include <DMainWindow>
|
#include <DMainWindow>
|
||||||
|
@ -112,6 +113,7 @@ void MainWidget::setupUi(QWidget *Widget)
|
||||||
|
|
||||||
m_resultWidget = new DStackedWidget(this);
|
m_resultWidget = new DStackedWidget(this);
|
||||||
m_resultWidget->setFocusPolicy(Qt::NoFocus);
|
m_resultWidget->setFocusPolicy(Qt::NoFocus);
|
||||||
|
m_resultWidget->setMinimumWidth(220);
|
||||||
|
|
||||||
|
|
||||||
m_loadingOcr = new loadingWidget(this);
|
m_loadingOcr = new loadingWidget(this);
|
||||||
|
@ -261,20 +263,14 @@ void MainWidget::loadingUi()
|
||||||
m_pwidget->move(0, 0);
|
m_pwidget->move(0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#include <QTimer>
|
|
||||||
void MainWidget::openImage(const QString &path)
|
void MainWidget::openImage(const QString &path)
|
||||||
{
|
{
|
||||||
if (m_imageview) {
|
if (m_imageview) {
|
||||||
QImage img(path);
|
QImage img(path);
|
||||||
m_imageview->openFilterImage(img);
|
|
||||||
QTimer::singleShot(100, [ = ] {
|
|
||||||
m_imageview->fitWindow();
|
|
||||||
});
|
|
||||||
m_imgName = path;
|
m_imgName = path;
|
||||||
openImage(img);
|
openImage(img);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWidget::openImage(const QImage &img)
|
void MainWidget::openImage(const QImage &img)
|
||||||
|
@ -350,12 +346,18 @@ void MainWidget::resizeEvent(QResizeEvent *event)
|
||||||
|
|
||||||
void MainWidget::slotCopy()
|
void MainWidget::slotCopy()
|
||||||
{
|
{
|
||||||
//复制所有内容
|
//选中内容则复制,未选中内容则不复制
|
||||||
QTextDocument *document = m_plainTextEdit->document();
|
if (!m_plainTextEdit->textCursor().selectedText().isEmpty()) {
|
||||||
DPlainTextEdit *tempTextEdit = new DPlainTextEdit(this);
|
m_plainTextEdit->copy();
|
||||||
tempTextEdit->setDocument(document);
|
} else {
|
||||||
tempTextEdit->selectAll();
|
QTextDocument *document = m_plainTextEdit->document();
|
||||||
tempTextEdit->copy();
|
DPlainTextEdit *tempTextEdit = new DPlainTextEdit(this);
|
||||||
|
tempTextEdit->setDocument(document);
|
||||||
|
tempTextEdit->selectAll();
|
||||||
|
tempTextEdit->copy();
|
||||||
|
tempTextEdit->deleteLater();
|
||||||
|
tempTextEdit = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
QIcon icon(":/assets/icon_toast_sucess_new.svg");
|
QIcon icon(":/assets/icon_toast_sucess_new.svg");
|
||||||
DFloatingMessage *pDFloatingMessage = new DFloatingMessage(DFloatingMessage::MessageType::TransientType, m_pwidget);
|
DFloatingMessage *pDFloatingMessage = new DFloatingMessage(DFloatingMessage::MessageType::TransientType, m_pwidget);
|
||||||
|
@ -364,8 +366,7 @@ void MainWidget::slotCopy()
|
||||||
pDFloatingMessage->setIcon(icon);
|
pDFloatingMessage->setIcon(icon);
|
||||||
pDFloatingMessage->raise();
|
pDFloatingMessage->raise();
|
||||||
DMessageManager::instance()->sendMessage(m_pwidget, pDFloatingMessage);
|
DMessageManager::instance()->sendMessage(m_pwidget, pDFloatingMessage);
|
||||||
tempTextEdit->deleteLater();
|
|
||||||
tempTextEdit = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWidget::slotExport()
|
void MainWidget::slotExport()
|
||||||
|
@ -381,7 +382,13 @@ void MainWidget::slotExport()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString fileName = QFileInfo(m_imgName).completeBaseName();
|
QString fileName;
|
||||||
|
if (!m_imgName.isEmpty()) {
|
||||||
|
fileName = QFileInfo(m_imgName).completeBaseName();
|
||||||
|
} else {
|
||||||
|
fileName = tr("Results");
|
||||||
|
}
|
||||||
|
|
||||||
QString file_path = QFileDialog::getSaveFileName(this, "save as", download + "/" + fileName, "*.txt");
|
QString file_path = QFileDialog::getSaveFileName(this, "save as", download + "/" + fileName, "*.txt");
|
||||||
qDebug() << file_path;
|
qDebug() << file_path;
|
||||||
|
|
||||||
|
|
|
@ -73,19 +73,12 @@ void ImageView::openFilterImage(QImage img)
|
||||||
}
|
}
|
||||||
qreal ImageView::windowRelativeScale() const
|
qreal ImageView::windowRelativeScale() const
|
||||||
{
|
{
|
||||||
|
//替换撑满方案
|
||||||
QRectF bf = sceneRect();
|
QRectF bf = sceneRect();
|
||||||
if (this->window()->isFullScreen()) {
|
if (1.0 * width() / height() > 1.0 * bf.width() / bf.height()) {
|
||||||
if (1.0 * (width()) / (height() + 15) > 1.0 * bf.width() / bf.height()) {
|
return 1.0 * height() / bf.height();
|
||||||
return 1.0 * (height() + 15) / bf.height();
|
|
||||||
} else {
|
|
||||||
return 1.0 * (width()) / bf.width();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (1.0 * (width() - 20) / (height() - 180) > 1.0 * bf.width() / bf.height()) {
|
return 1.0 * width() / bf.width();
|
||||||
return 1.0 * (height() - 180) / bf.height();
|
|
||||||
} else {
|
|
||||||
return 1.0 * (width() - 20) / bf.width();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void ImageView::fitWindow()
|
void ImageView::fitWindow()
|
||||||
|
@ -95,11 +88,6 @@ void ImageView::fitWindow()
|
||||||
resetTransform();
|
resetTransform();
|
||||||
scale(wrs, wrs);
|
scale(wrs, wrs);
|
||||||
|
|
||||||
// if (wrs - 1 > -0.01 && wrs - 1 < 0.01) {
|
|
||||||
// emit checkAdaptImageBtn();
|
|
||||||
// } else {
|
|
||||||
// emit disCheckAdaptImageBtn();
|
|
||||||
// }
|
|
||||||
m_isFitImage = false;
|
m_isFitImage = false;
|
||||||
m_isFitWindow = true;
|
m_isFitWindow = true;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user