更新AI功能
This commit is contained in:
parent
73cab2c0a2
commit
afc35c2e69
|
@ -37,14 +37,23 @@ GlobalThemeWidget::GlobalThemeWidget(QWidget *parent) : QWidget(parent)
|
|||
initPreviewWidget();
|
||||
initRightWidget();
|
||||
|
||||
QPushButton *line = new QPushButton();
|
||||
line->setDisabled(true);
|
||||
line->setFixedWidth(1);
|
||||
line->setFixedHeight(2000);
|
||||
QPushButton *line1 = new QPushButton();
|
||||
line1->setDisabled(true);
|
||||
line1->setFixedWidth(1);
|
||||
line1->setFixedHeight(2000);
|
||||
|
||||
QPushButton *line2 = new QPushButton();
|
||||
line2->setDisabled(true);
|
||||
line2->setFixedWidth(1);
|
||||
line2->setFixedHeight(2000);
|
||||
|
||||
|
||||
m_globalthemelayout = new QHBoxLayout();
|
||||
m_globalthemelayout->addWidget(m_previewwidget);
|
||||
m_globalthemelayout->addWidget(line);
|
||||
m_globalthemelayout->addWidget(line1);
|
||||
m_globalthemelayout->addWidget(m_rightwidget);
|
||||
m_globalthemelayout->addWidget(line2);
|
||||
initAithemeBar();
|
||||
|
||||
m_globalthemelayout->setContentsMargins(0,0,0,0);
|
||||
m_globalthemelayout->setSpacing(0);
|
||||
|
@ -168,6 +177,34 @@ void GlobalThemeWidget::initPreviewWidget()
|
|||
m_previewwidget->setLayout(m_previewlayout);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 初始化Ai生图小部件
|
||||
* 创建一个新的 QWidget,设置固定高度,并添加到grub布局。
|
||||
* 连接 label 的 clicked 信号,当点击按钮时,传递图片到预览窗口。
|
||||
*/
|
||||
void GlobalThemeWidget::initAithemeBar()
|
||||
{
|
||||
// 创建 aithemebar 实例
|
||||
m_aithemebar = new aithemebar(this);
|
||||
m_aithemebar->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
|
||||
|
||||
// 设置最小和最大宽度
|
||||
m_aithemebar->setMinimumSize(250, 620);
|
||||
m_aithemebar->setMaximumWidth(250);
|
||||
m_aithemebar->setBackgroundRole(QPalette::Base);
|
||||
m_aithemebar->setAutoFillBackground(true);
|
||||
|
||||
// 设置 aithemebar 的固定宽度
|
||||
m_aithemebar->setFixedWidth(250);
|
||||
|
||||
// 在布局中为 aithemebar 分配足够的空间
|
||||
QSpacerItem *spacer = new QSpacerItem(15, 0, QSizePolicy::Fixed, QSizePolicy::Minimum);
|
||||
m_globalthemelayout->addItem(spacer);
|
||||
m_globalthemelayout->addWidget(m_aithemebar);
|
||||
connect(m_aithemebar, &aithemebar::imageClicked, this, &GlobalThemeWidget::updateAIImage);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 初始化右侧小部件
|
||||
*
|
||||
|
@ -903,6 +940,45 @@ void GlobalThemeWidget::setWindowRadius(int windowradius)
|
|||
}
|
||||
}
|
||||
|
||||
void GlobalThemeWidget::updateAIImage(const QPixmap &pixmap)
|
||||
{
|
||||
// 生成唯一的临时文件路径
|
||||
QString tempPath = QString("/tmp/temp_image_%1.png").arg(QUuid::createUuid().toString(QUuid::WithoutBraces));
|
||||
|
||||
// 固定预览窗口的尺寸为 3840x2160
|
||||
QSize previewSize(3840, 2160);
|
||||
|
||||
// 调整 QPixmap 的尺寸以适应预览窗口
|
||||
QPixmap scaledPixmap = pixmap.scaled(previewSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
|
||||
// 将调整后的 QPixmap 保存到临时文件
|
||||
scaledPixmap.save(tempPath);
|
||||
|
||||
// 将临时文件路径添加到列表中
|
||||
tempFilePaths.append(tempPath);
|
||||
m_preview->updateWallpaper(tempPath);
|
||||
emit wallpaperupdate(tempPath);
|
||||
emit newWallpaperFilePath(tempPath);
|
||||
|
||||
QPixmap pixmap1(tempPath);
|
||||
wallpaperbtn->setIcon(QIcon(pixmap1));
|
||||
wallpaperbtn->setIconSize(QSize(178,122));
|
||||
m_themeChangeMap->insert("wallpaper",true);
|
||||
emit globalthemeChange(m_themeChangeMap);
|
||||
|
||||
|
||||
// 更新预览窗口的背景图片
|
||||
// updateWallpaper(tempPath);
|
||||
|
||||
// 将 QPixmap 设置为按钮的图标
|
||||
// m_showBtn->setIcon(QIcon(pixmap));
|
||||
|
||||
// setWallpaper(tempPath);
|
||||
|
||||
// 设置按钮图标的大小
|
||||
// m_showBtn->setIconSize(QSize(178, 122));
|
||||
}
|
||||
|
||||
void GlobalThemeWidget::useMaximumScale()
|
||||
{
|
||||
m_preview->maxscale();
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#define GLOBALTHEMEWIDGET_H
|
||||
#include "globalthemefeature.h"
|
||||
#include "../fileProcess/datacollect.h"
|
||||
#include "../aithemebar.h"
|
||||
#include <QObject>
|
||||
#include <QWidget>
|
||||
#include <QPushButton>
|
||||
|
@ -53,6 +54,7 @@ public:
|
|||
QMap<QString, bool> *m_globalPresenceMap;
|
||||
void useMaximumScale();
|
||||
void useRestoreScale();
|
||||
void updateAIImage(const QPixmap &pixmap);
|
||||
signals:
|
||||
void wallpaperupdate(const QString& filePath);
|
||||
void newWallpaperFilePath(const QString& path);
|
||||
|
@ -66,6 +68,7 @@ signals:
|
|||
void build();
|
||||
private:
|
||||
void initPreviewWidget();
|
||||
void initAithemeBar();
|
||||
void initRightWidget();
|
||||
|
||||
void initCoverWidget();
|
||||
|
@ -111,6 +114,8 @@ private:
|
|||
EditButton *wallpaperbtn;
|
||||
BasePreviewWidget *m_previewwidget;
|
||||
GlobalImageWidget *m_preview;
|
||||
aithemebar *m_aithemebar;
|
||||
QList<QString> tempFilePaths;
|
||||
};
|
||||
|
||||
#endif // GLOBALTHEMEWIDGET_H
|
||||
|
|
Loading…
Reference in New Issue