fix: 解决bug85097
Description: 增加了一个缩放比例的小label Log: 与界面有关 Bug: https://pms.uniontech.com/zentao/bug-view-85097.html Change-Id: Ib5b003b4599044e7780adc78b6894b57c1a75264
This commit is contained in:
parent
6292e44721
commit
a72a11c17b
|
@ -21,6 +21,9 @@
|
||||||
#include <DTitlebar>
|
#include <DTitlebar>
|
||||||
#include <DMessageManager>
|
#include <DMessageManager>
|
||||||
#include <DToolButton>
|
#include <DToolButton>
|
||||||
|
#include <DFloatingWidget>
|
||||||
|
#include <DAnchors>
|
||||||
|
#include <DFontSizeManager>
|
||||||
|
|
||||||
#define App (static_cast<QApplication*>(QCoreApplication::instance()))
|
#define App (static_cast<QApplication*>(QCoreApplication::instance()))
|
||||||
MainWidget::MainWidget(QWidget *parent) :
|
MainWidget::MainWidget(QWidget *parent) :
|
||||||
|
@ -29,7 +32,7 @@ MainWidget::MainWidget(QWidget *parent) :
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
DGuiApplicationHelper::ColorType themeType = DGuiApplicationHelper::instance()->themeType();
|
DGuiApplicationHelper::ColorType themeType = DGuiApplicationHelper::instance()->themeType();
|
||||||
setIcons(themeType);
|
setIcons(themeType);
|
||||||
|
initScaleLabel();
|
||||||
setupConnect();
|
setupConnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -359,6 +362,42 @@ void MainWidget::resultEmpty()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWidget::initScaleLabel()
|
||||||
|
{
|
||||||
|
DAnchors<DFloatingWidget> scalePerc = new DFloatingWidget(this);
|
||||||
|
scalePerc->setBlurBackgroundEnabled(true);
|
||||||
|
|
||||||
|
QHBoxLayout *layout = new QHBoxLayout();
|
||||||
|
scalePerc->setLayout(layout);
|
||||||
|
DLabel *label = new DLabel();
|
||||||
|
layout->addWidget(label);
|
||||||
|
scalePerc->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||||
|
scalePerc.setAnchor(Qt::AnchorHorizontalCenter, this, Qt::AnchorHorizontalCenter);
|
||||||
|
scalePerc.setAnchor(Qt::AnchorBottom, this, Qt::AnchorBottom);
|
||||||
|
scalePerc.setBottomMargin(75 + 14);
|
||||||
|
label->setAlignment(Qt::AlignCenter);
|
||||||
|
// scalePerc->setFixedSize(82, 48);
|
||||||
|
scalePerc->setFixedWidth(90 + 10);
|
||||||
|
scalePerc->setFixedHeight(40 + 10);
|
||||||
|
scalePerc->adjustSize();
|
||||||
|
label->setText("100%");
|
||||||
|
DFontSizeManager::instance()->bind(label, DFontSizeManager::T6);
|
||||||
|
scalePerc->hide();
|
||||||
|
|
||||||
|
QTimer *hideT = new QTimer(this);
|
||||||
|
hideT->setSingleShot(true);
|
||||||
|
connect(hideT, &QTimer::timeout, scalePerc, &DLabel::hide);
|
||||||
|
|
||||||
|
connect(m_imageview, &ImageView::scaled, this, [ = ](qreal perc) {
|
||||||
|
label->setText(QString("%1%").arg(int(perc)));
|
||||||
|
});
|
||||||
|
connect(m_imageview, &ImageView::showScaleLabel, this, [ = ]() {
|
||||||
|
scalePerc->show();
|
||||||
|
scalePerc->move(m_imageview->width() / 2 - 50, m_imageview->height() - 48);
|
||||||
|
hideT->start(1000);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void MainWidget::resizeEvent(QResizeEvent *event)
|
void MainWidget::resizeEvent(QResizeEvent *event)
|
||||||
{
|
{
|
||||||
return DWidget::resizeEvent(event);
|
return DWidget::resizeEvent(event);
|
||||||
|
|
|
@ -49,6 +49,8 @@ public:
|
||||||
void loadString(const QString &string);
|
void loadString(const QString &string);
|
||||||
void resultEmpty();
|
void resultEmpty();
|
||||||
|
|
||||||
|
//缩放显示label
|
||||||
|
void initScaleLabel();
|
||||||
protected:
|
protected:
|
||||||
void resizeEvent(QResizeEvent *event);
|
void resizeEvent(QResizeEvent *event);
|
||||||
private slots:
|
private slots:
|
||||||
|
|
|
@ -303,7 +303,8 @@ void ImageView::setScaleValue(qreal v)
|
||||||
// } else {
|
// } else {
|
||||||
// emit disCheckAdaptImageBtn();
|
// emit disCheckAdaptImageBtn();
|
||||||
// }
|
// }
|
||||||
|
emit scaled(m_scal * 100);
|
||||||
|
emit showScaleLabel();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,9 @@ protected:
|
||||||
//二指捏合功能的触屏事件
|
//二指捏合功能的触屏事件
|
||||||
void handleGestureEvent(QGestureEvent *gesture);
|
void handleGestureEvent(QGestureEvent *gesture);
|
||||||
void pinchTriggered(QPinchGesture *gesture);
|
void pinchTriggered(QPinchGesture *gesture);
|
||||||
|
signals:
|
||||||
|
void scaled(qreal perc);
|
||||||
|
void showScaleLabel();
|
||||||
private:
|
private:
|
||||||
QString m_currentPath;//当前图片路径
|
QString m_currentPath;//当前图片路径
|
||||||
QGraphicsPixmapItem *m_pixmapItem{nullptr};//当前图像的item
|
QGraphicsPixmapItem *m_pixmapItem{nullptr};//当前图像的item
|
||||||
|
|
Loading…
Reference in New Issue
Block a user