mirror of
https://gitee.com/spark-store-project/spark-store
synced 2026-03-25 23:09:44 +08:00
Restore Patches
This commit is contained in:
@@ -1,13 +1,16 @@
|
|||||||
#include "image_show.h"
|
#include "image_show.h"
|
||||||
|
|
||||||
|
#include <QScreen> // Qt5 不再建议使用 QDesktopWidget
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QDebug>
|
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
|
||||||
#include <DDialog>
|
#include <DDialog>
|
||||||
#include <DBlurEffectWidget>
|
#include <DBlurEffectWidget>
|
||||||
#include <DWidgetUtil>
|
#include <DWidgetUtil>
|
||||||
#include <DApplication>
|
#include <DApplication>
|
||||||
#include <QDesktopWidget>
|
|
||||||
DWIDGET_USE_NAMESPACE
|
DWIDGET_USE_NAMESPACE
|
||||||
|
|
||||||
image_show::image_show(QWidget *parent) : QWidget(parent)
|
image_show::image_show(QWidget *parent) : QWidget(parent)
|
||||||
{
|
{
|
||||||
QHBoxLayout *layout = new QHBoxLayout;
|
QHBoxLayout *layout = new QHBoxLayout;
|
||||||
@@ -23,12 +26,18 @@ void image_show::setImage(QPixmap image)
|
|||||||
// QPainter painter(&screen0);
|
// QPainter painter(&screen0);
|
||||||
QImage re_screen1;
|
QImage re_screen1;
|
||||||
QImage re_screen0 = screen0.scaled(QSize(400, 300), Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
QImage re_screen0 = screen0.scaled(QSize(400, 300), Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||||
desktop_w=DApplication::desktop()->width();
|
|
||||||
desktop_h=DApplication::desktop()->height();
|
// 获取主屏幕尺寸
|
||||||
if(screen0.width()>(desktop_w-20) || screen0.height()>(desktop_h-20)){
|
desktop_w = DApplication::primaryScreen()->geometry().width();
|
||||||
|
desktop_h = DApplication::primaryScreen()->geometry().height();
|
||||||
|
|
||||||
|
if(screen0.width() > (desktop_w - 20) || screen0.height() > (desktop_h - 20))
|
||||||
|
{
|
||||||
re_screen1 = screen0.scaled(QSize(desktop_w - 20, desktop_h - 20), Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
re_screen1 = screen0.scaled(QSize(desktop_w - 20, desktop_h - 20), Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||||
m_image = QPixmap::fromImage(re_screen1);
|
m_image = QPixmap::fromImage(re_screen1);
|
||||||
}else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
m_image = image;
|
m_image = image;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,8 +48,10 @@ void image_show::mousePressEvent(QMouseEvent *)
|
|||||||
{
|
{
|
||||||
m_dialog->setimage(m_image);
|
m_dialog->setimage(m_image);
|
||||||
m_dialog->showFullScreen();
|
m_dialog->showFullScreen();
|
||||||
m_dialog->setFixedSize(desktop_w,desktop_h);
|
|
||||||
m_dialog->move(0,0);/*
|
|
||||||
moveToCenter(m_dialog);*/
|
|
||||||
|
|
||||||
|
// 识别主屏幕尺寸并设置 widget 大小
|
||||||
|
m_dialog->setFixedSize(desktop_w, desktop_h);
|
||||||
|
|
||||||
|
m_dialog->move(0,0);
|
||||||
|
// moveToCenter(m_dialog);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user