fix: 修复ui的bug

Description: 修复ui的bug

Log: 修复ui的bug
Change-Id: I5f032d55197c1b99fd756f3684347d9f25cefe11
This commit is contained in:
liuminghang 2021-07-01 20:12:19 +08:00
parent eba098bf36
commit 8606ef1251
2 changed files with 49 additions and 3 deletions

View File

@ -154,7 +154,8 @@ void MainWidget::setupUi(QWidget *Widget)
mainSplitter->addWidget(m_frame);//把ui中拖出的各个控件拿走放到分割器里面 mainSplitter->addWidget(m_frame);//把ui中拖出的各个控件拿走放到分割器里面
mainSplitter->addWidget(m_resultWidget); mainSplitter->addWidget(m_resultWidget);
QList<int> list; QList<int> list;
list << 600 << 250; //默认右侧识栏目是220的宽度
list << 620 << 220;
mainSplitter->setSizes(list); mainSplitter->setSizes(list);
// m_horizontalLayout->addWidget(m_imageview); // m_horizontalLayout->addWidget(m_imageview);
// m_horizontalLayout->addWidget(m_plainTextEdit); // m_horizontalLayout->addWidget(m_plainTextEdit);
@ -192,7 +193,7 @@ void MainWidget::setupUi(QWidget *Widget)
m_copyBtn->setToolTip(tr("Copy text")); m_copyBtn->setToolTip(tr("Copy text"));
m_buttonHorizontalLayout->addWidget(m_copyBtn); m_buttonHorizontalLayout->addWidget(m_copyBtn);
m_buttonHorizontalLayout->setSpacing(20); m_buttonHorizontalLayout->setSpacing(30);
m_exportBtn = new DToolButton(Widget); m_exportBtn = new DToolButton(Widget);
m_exportBtn->setObjectName(QStringLiteral("Save as TXT")); m_exportBtn->setObjectName(QStringLiteral("Save as TXT"));
m_exportBtn->setMaximumSize(QSize(36, 36)); m_exportBtn->setMaximumSize(QSize(36, 36));
@ -284,7 +285,11 @@ void MainWidget::loadingUi()
int x = this->width() - m_resultWidget->width() / 2; int x = this->width() - m_resultWidget->width() / 2;
int y = this->height() / 2 - 50; int y = this->height() / 2 - 50;
m_loadingWidget->move(x, y); m_loadingWidget->move(x, y);
m_loadingTip->move(x - 17, y + 24); qDebug() << m_loadingTip->width();
// m_loadingTip->setAlignment(Qt::AlignCenter);
QFontMetrics fm(DFontSizeManager::instance()->get(DFontSizeManager::T8));
int mPoint = fm.boundingRect(tr("Recognizing")).width();
m_loadingTip->move(x - mPoint / 2 + 7, y + 24);
} }
if (m_pwidget) { if (m_pwidget) {
m_pwidget->setFixedSize(this->width(), this->height() - 48); m_pwidget->setFixedSize(this->width(), this->height() - 48);
@ -331,6 +336,9 @@ bool MainWidget::openImage(const QString &path)
void MainWidget::openImage(const QImage &img, const QString &name) void MainWidget::openImage(const QImage &img, const QString &name)
{ {
createLoadingUi(); createLoadingUi();
//新打开的窗口需要设置属性
DGuiApplicationHelper::ColorType themeType = DGuiApplicationHelper::instance()->themeType();
setIcons(themeType);
if (m_imageview) { if (m_imageview) {
m_imageview->openFilterImage(img); m_imageview->openFilterImage(img);
QTimer::singleShot(100, [ = ] { QTimer::singleShot(100, [ = ] {
@ -446,6 +454,12 @@ void MainWidget::resizeEvent(QResizeEvent *event)
return DWidget::resizeEvent(event); return DWidget::resizeEvent(event);
} }
void MainWidget::paintEvent(QPaintEvent *event)
{
loadingUi();
return DWidget::paintEvent(event);
}
void MainWidget::slotCopy() void MainWidget::slotCopy()
{ {
@ -550,6 +564,21 @@ void MainWidget::setIcons(DGuiApplicationHelper::ColorType themeType)
m_frame->setAutoFillBackground(true); m_frame->setAutoFillBackground(true);
m_frame->setPalette(pal); m_frame->setPalette(pal);
} }
if (m_tiplabel) {
QPalette pe;
pe.setColor(QPalette::WindowText, QColor(109, 124, 136));
m_tiplabel->setPalette(pe);
}
if (m_noResult) {
QPalette pe;
pe.setColor(QPalette::WindowText, QColor(192, 198, 212, 102));
m_noResult->setPalette(pe);
}
if (m_loadingTip) {
QPalette pe;
pe.setColor(QPalette::WindowText, QColor(192, 198, 212));
m_loadingTip->setPalette(pe);
}
} else { } else {
QPalette pal; QPalette pal;
@ -596,6 +625,22 @@ void MainWidget::setIcons(DGuiApplicationHelper::ColorType themeType)
m_frame->setAutoFillBackground(true); m_frame->setAutoFillBackground(true);
m_frame->setPalette(pal); m_frame->setPalette(pal);
} }
if (m_tiplabel) {
QPalette pe;
pe.setColor(QPalette::WindowText, QColor(138, 161, 180));
m_tiplabel->setPalette(pe);
}
if (m_noResult) {
QPalette pe;
pe.setColor(QPalette::WindowText, QColor(85, 85, 85, 102));
m_noResult->setPalette(pe);
}
if (m_loadingTip) {
QPalette pe;
pe.setColor(QPalette::WindowText, QColor(65, 77, 104));
m_loadingTip->setPalette(pe);
}
} }
} // setupUi } // setupUi

View File

@ -54,6 +54,7 @@ public:
void initScaleLabel(); void initScaleLabel();
protected: protected:
void resizeEvent(QResizeEvent *event); void resizeEvent(QResizeEvent *event);
void paintEvent(QPaintEvent *event);
private slots: private slots:
void setIcons(DGuiApplicationHelper::ColorType themeType); void setIcons(DGuiApplicationHelper::ColorType themeType);