diff --git a/deepin-ocr.pro b/deepin-ocr.pro index c99e4c6..556b2d0 100644 --- a/deepin-ocr.pro +++ b/deepin-ocr.pro @@ -28,7 +28,8 @@ HEADERS += src/mainwindow.h \ src/textloadwidget.h \ src/view/imageview.h \ src/tessocrutils/tessocrutils.h \ - src/loadingwidget.h + src/loadingwidget.h \ + src/frame.h SOURCES += src/main.cpp \ src/mainwindow.cpp \ @@ -40,7 +41,8 @@ SOURCES += src/main.cpp \ src/resulttextview.cpp \ src/view/imageview.cpp \ src/tessocrutils/tessocrutils.cpp \ - src/loadingwidget.cpp + src/loadingwidget.cpp \ + src/frame.cpp LIBS += -llept -ltesseract\ diff --git a/src/frame.cpp b/src/frame.cpp new file mode 100644 index 0000000..da1c20e --- /dev/null +++ b/src/frame.cpp @@ -0,0 +1,13 @@ +#include "frame.h" + +Frame::Frame(QWidget *parent, Qt::WindowFlags f) + : QFrame(parent, f) +{ + +} + +void Frame::resizeEvent(QResizeEvent *event) +{ + emit sigFrameResize(); + return QFrame::resizeEvent(event); +} diff --git a/src/frame.h b/src/frame.h new file mode 100644 index 0000000..9a17774 --- /dev/null +++ b/src/frame.h @@ -0,0 +1,17 @@ +#ifndef FRAME_H +#define FRAME_H + +#include + +class Frame : public QFrame +{ + Q_OBJECT +public: + Frame(QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags()); +signals: + void sigFrameResize(); +protected: + void resizeEvent(QResizeEvent *event) override; +}; + +#endif // FRAME_H diff --git a/src/mainwidget.cpp b/src/mainwidget.cpp index 88c794b..18683df 100644 --- a/src/mainwidget.cpp +++ b/src/mainwidget.cpp @@ -1,6 +1,7 @@ #include "mainwidget.h" #include "view/imageview.h" #include "loadingwidget.h" +#include "frame.h" #include #include @@ -119,7 +120,7 @@ void MainWidget::setupUi(QWidget *Widget) m_frameLayout->setContentsMargins(10, 10, 10, 10); //后面加一层窗口,左边空间间距20 - m_frameStack = new QFrame(this); + m_frameStack = new Frame(this); m_frameStack->setFrameShape(QFrame::StyledPanel); m_frameStack->setFrameShadow(QFrame::Raised); m_frameStack->setLineWidth(0); @@ -146,6 +147,10 @@ void MainWidget::setupUi(QWidget *Widget) //宽度最大值为440 m_frameStack->setMaximumWidth(440); + connect(m_frameStack, &Frame::sigFrameResize, this, [ = ] { + m_resultWidget->resize(QSize(m_frameStack->width() - 25, m_frameStack->height())); + }); + m_loadingOcr = new loadingWidget(this); m_loadingOcr->setAlignment(Qt::AlignCenter); @@ -294,8 +299,8 @@ void MainWidget::deleteLoadingUi() void MainWidget::loadingUi() { - if (m_loadingWidget && m_loadingTip && m_resultWidget) { - int x = this->width() - m_resultWidget->width() / 2; + if (m_loadingWidget && m_loadingTip && m_frameStack) { + int x = this->width() - m_frameStack->width() / 2; int y = this->height() / 2 - 50; qDebug() << m_loadingWidget->width(); m_loadingWidget->setFixedSize(QSize(24, 24)); diff --git a/src/mainwidget.h b/src/mainwidget.h index 8142a3d..65acaf4 100644 --- a/src/mainwidget.h +++ b/src/mainwidget.h @@ -14,9 +14,11 @@ #include #include "resulttextview.h" + #include "textloadwidget.h" #include "tessocrutils/tessocrutils.h" +class Frame; class QThread; class QGridLayout; class QHBoxLayout; @@ -77,7 +79,7 @@ private: QFrame *m_frame{nullptr}; QHBoxLayout *m_frameStackLayout{nullptr}; - QFrame *m_frameStack{nullptr}; + Frame *m_frameStack{nullptr}; DLabel *m_tipIconLabel{nullptr}; DHorizontalLine *m_line{nullptr};