!12 add limit resolution

Merge pull request !12 from likehomedream/my-2.0-devel
This commit is contained in:
KevinDuan 2023-08-29 07:57:58 +00:00 committed by Gitee
commit 612b22809f
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
35 changed files with 46 additions and 1 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

View File

@ -25,6 +25,16 @@ void CursorGraphicsView::wheelEvent(QWheelEvent* event)
{
if (QGuiApplication::keyboardModifiers() == Qt::ControlModifier) {
qreal scaleFactor = std::pow(qreal(2), event->delta() / 240.0);
qreal currentScale = transform().m11(); // 获取当前的缩放倍数
// 限制最大为1.1倍
qreal targetScale = currentScale * scaleFactor;
if (targetScale > 1.1) {
scaleFactor = 1.1 / currentScale;
}else if (targetScale < 0.3) {
scaleFactor = 0.3 / currentScale;
}
scale(scaleFactor, scaleFactor);
scale(scaleFactor, scaleFactor);
} else {
QGraphicsView::wheelEvent(event);
@ -147,6 +157,9 @@ CursorImageWidget::CursorImageWidget(QWidget *parent, const QMap<QString, QStrin
qDebug() << "Failed to load image:" << filePath;
}
}
// 设置初始缩放倍数为0.9倍
qreal initialScale = 0.8;
graphicsView->scale(initialScale, initialScale);
}
void CursorImageWidget::updateIcon(const QString& widgetName, const QString& newFilePath)

View File

@ -15,6 +15,14 @@ CustomGraphicsView::CustomGraphicsView(QGraphicsScene* scene) : QGraphicsView(sc
void CustomGraphicsView::wheelEvent(QWheelEvent* event) {
if (QGuiApplication::keyboardModifiers() == Qt::ControlModifier) {
qreal scaleFactor = std::pow(qreal(2), event->delta() / 240.0);
qreal currentScale = transform().m11(); // 获取当前的缩放倍数
// 限制最大为1.1倍
qreal targetScale = currentScale * scaleFactor;
if (targetScale > 1.1) {
scaleFactor = 1.1 / currentScale;
}else if (targetScale < 0.3) {
scaleFactor = 0.3 / currentScale;
}
scale(scaleFactor, scaleFactor);
} else {
QGraphicsView::wheelEvent(event);
@ -95,7 +103,6 @@ GlobalImageWidget::GlobalImageWidget(QWidget *parent, const QString& coverFilePa
m_mergedImage = QPixmap(m_image.size());
m_mergedImage.fill(Qt::transparent);
QPainter painter(&m_mergedImage);
painter.drawPixmap(0, 0, m_image);
QPixmap overlayImage(":/resource/background/panel-light.png");
@ -145,6 +152,9 @@ GlobalImageWidget::GlobalImageWidget(QWidget *parent, const QString& coverFilePa
m_proxy->setPos(800, 400);
m_scene->addItem(m_proxy);
// 设置初始缩放倍数为0.9倍
qreal initialScale = 0.9;
graphicsView->scale(initialScale, initialScale);
}
Globalthemefeature::Globalthemefeature(QWidget *parent, const QString& coverFilePath)

View File

@ -38,8 +38,25 @@ IconGraphicsView::IconGraphicsView(QGraphicsScene* scene) : QGraphicsView(scene)
void IconGraphicsView::wheelEvent(QWheelEvent* event)
{
// if (QGuiApplication::keyboardModifiers() == Qt::ControlModifier) {
// qreal scaleFactor = std::pow(qreal(2), event->delta() / 240.0);
// scale(scaleFactor, scaleFactor);
// } else {
// QGraphicsView::wheelEvent(event);
// }
if (QGuiApplication::keyboardModifiers() == Qt::ControlModifier) {
qreal scaleFactor = std::pow(qreal(2), event->delta() / 240.0);
qreal currentScale = transform().m11(); // 获取当前的缩放倍数
// 限制最大为1.1倍
qreal targetScale = currentScale * scaleFactor;
if (targetScale > 1.1) {
scaleFactor = 1.1 / currentScale;
}else if (targetScale < 0.3) {
scaleFactor = 0.3 / currentScale;
}
scale(scaleFactor, scaleFactor);
} else {
QGraphicsView::wheelEvent(event);
@ -58,6 +75,7 @@ ImageWidget::ImageWidget(QWidget *parent, const QMap<QString, QString>* iconMap)
layout->addWidget(graphicsView);
setLayout(layout);
int count = m_iconMap->size();
if(count == 11){
image = new QPixmap(":/resource/background/controlcenter-light.png");
@ -134,6 +152,10 @@ ImageWidget::ImageWidget(QWidget *parent, const QMap<QString, QString>* iconMap)
}
}
// 设置初始缩放倍数为0.9倍
qreal initialScale = 0.9;
graphicsView->scale(initialScale, initialScale);
}
void ImageWidget::updateImage(const QString& imagePath)