mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-07-22 13:32:20 +08:00
Try to fix bugs
尝试修复多屏幕下截图全屏预览的偏移问题。
This commit is contained in:
parent
b619d3cc7b
commit
405d3b6986
@ -1,16 +1,20 @@
|
||||
#include "image_show.h"
|
||||
|
||||
#include <QScreen> // Qt5 不再建议使用 QDesktopWidget
|
||||
#include <QHBoxLayout>
|
||||
#include <QDebug>
|
||||
#include <QPainter>
|
||||
|
||||
#include <DDialog>
|
||||
#include <DBlurEffectWidget>
|
||||
#include <DWidgetUtil>
|
||||
#include <DApplication>
|
||||
#include <QDesktopWidget>
|
||||
|
||||
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;
|
||||
layout->addWidget(m_label);
|
||||
setLayout(layout);
|
||||
m_label->setText("layout");
|
||||
@ -19,16 +23,22 @@ image_show::image_show(QWidget *parent) : QWidget(parent)
|
||||
void image_show::setImage(QPixmap image)
|
||||
{
|
||||
QImage screen0;
|
||||
screen0=image.toImage();
|
||||
// QPainter painter(&screen0);
|
||||
screen0 = image.toImage();
|
||||
// QPainter painter(&screen0);
|
||||
QImage re_screen1;
|
||||
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)){
|
||||
re_screen1=screen0.scaled(QSize(desktop_w-20,desktop_h-20),Qt::KeepAspectRatio,Qt::SmoothTransformation);
|
||||
m_image=QPixmap::fromImage(re_screen1);
|
||||
}else {
|
||||
QImage re_screen0 = screen0.scaled(QSize(400,300),Qt::KeepAspectRatio,Qt::SmoothTransformation);
|
||||
|
||||
// 获取主屏幕尺寸
|
||||
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);
|
||||
m_image = QPixmap::fromImage(re_screen1);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_image=image;
|
||||
}
|
||||
|
||||
@ -37,10 +47,12 @@ void image_show::setImage(QPixmap image)
|
||||
|
||||
void image_show::mousePressEvent(QMouseEvent *)
|
||||
{
|
||||
m_dialog->setimage(m_image);
|
||||
m_dialog->showFullScreen();
|
||||
m_dialog->setFixedSize(desktop_w,desktop_h);
|
||||
m_dialog->move(0,0);/*
|
||||
moveToCenter(m_dialog);*/
|
||||
m_dialog->setimage(m_image);
|
||||
m_dialog->showFullScreen();
|
||||
|
||||
// 识别主屏幕尺寸并设置 widget 大小
|
||||
m_dialog->setFixedSize(desktop_w, desktop_h);
|
||||
|
||||
m_dialog->move(0,0);
|
||||
// moveToCenter(m_dialog);
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ int main(int argc, char *argv[])
|
||||
a.setOrganizationName("spark-union");
|
||||
a.setOrganizationDomain("https://www.deepinos.org/");
|
||||
a.setApplicationName("Spark Store"); //不需要翻译,否则 ~/.local/share/ 下文件夹名称也被翻译为中文
|
||||
a.setApplicationVersion(DApplication::buildVersion("3.0~alpha0"));
|
||||
a.setApplicationVersion(DApplication::buildVersion("3.0~alpha1"));
|
||||
a.setApplicationAcknowledgementPage("https://gitee.com/deepin-community-store/spark-store");
|
||||
a.setApplicationDescription(
|
||||
QObject::tr(
|
||||
|
Loading…
x
Reference in New Issue
Block a user