!142 开源之夏2024 - 247180565 - 结项
Merge pull request !142 from 杨胜毅/ai-module
|
@ -1,10 +1,15 @@
|
|||
QT += core gui svg KWindowSystem multimedia multimediawidgets concurrent
|
||||
QT += core gui svg KWindowSystem multimedia multimediawidgets concurrent dbus printsupport
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
|
||||
CONFIG += c++11 link_pkgconfig
|
||||
|
||||
PKGCONFIG += kysdk-qtwidgets kysdk-waylandhelper kysdk-sysinfo kysdk-datacollect gsettings-qt
|
||||
KF5 += i18n doctools guiaddons widgetsaddons kio xmlgui textwidgets jobwidgets
|
||||
|
||||
PKGCONFIG += kysdk-qtwidgets kysdk-waylandhelper kysdk-sysinfo kysdk-datacollect gsettings-qt kylin-ai-base jsoncpp json-glib-1.0
|
||||
|
||||
INCLUDEPATH += /usr/include/KF5
|
||||
INCLUDEPATH += /usr/include/KF5/KI18n
|
||||
|
||||
# The following define makes your compiler emit warnings if you use
|
||||
# any Qt feature that has been marked deprecated (the exact warnings
|
||||
|
@ -50,7 +55,8 @@ SOURCES += \
|
|||
src/module/plymouththemefeature.cpp \
|
||||
src/module/plymouththemewidget.cpp \
|
||||
src/module/savepathdialog.cpp \
|
||||
src/titlebar.cpp
|
||||
src/titlebar.cpp \
|
||||
src/aithemebar.cpp
|
||||
|
||||
HEADERS += \
|
||||
src/build/build.h \
|
||||
|
@ -84,7 +90,8 @@ HEADERS += \
|
|||
src/module/plymouththemefeature.h \
|
||||
src/module/plymouththemewidget.h \
|
||||
src/module/savepathdialog.h \
|
||||
src/titlebar.h
|
||||
src/titlebar.h \
|
||||
src/aithemebar.h
|
||||
|
||||
RESOURCES += \
|
||||
resource.qrc
|
||||
|
@ -103,4 +110,5 @@ appdesktop.files += kylin-theme-builder.desktop
|
|||
appdesktop.path = /usr/share/applications/
|
||||
|
||||
INSTALLS +=target qm_files appdesktop
|
||||
LIBS += -lukui-log4qt
|
||||
|
||||
LIBS += -lukui-log4qt -L/usr/lib/x86_64-linux-gnu -lKF5I18n
|
||||
|
|
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 89 KiB |
After Width: | Height: | Size: 25 KiB |
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 7.3 KiB |
After Width: | Height: | Size: 4.7 KiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 5.3 KiB |
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 5.1 KiB |
After Width: | Height: | Size: 19 KiB |
After Width: | Height: | Size: 4.8 KiB |
After Width: | Height: | Size: 16 KiB |
After Width: | Height: | Size: 4.7 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 4.7 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 4.7 KiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 4.9 KiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 4.2 KiB |
After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 5.1 KiB |
After Width: | Height: | Size: 19 KiB |
After Width: | Height: | Size: 4.6 KiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 4.6 KiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 4.8 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 7.5 KiB |
After Width: | Height: | Size: 29 KiB |
After Width: | Height: | Size: 4.4 KiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 3.9 KiB |
After Width: | Height: | Size: 13 KiB |
38
resource.qrc
|
@ -257,5 +257,43 @@
|
|||
<file>resource/places/user-trash-full.png</file>
|
||||
<file>resource/places/user-trash.png</file>
|
||||
<file>resource/theme.desktop</file>
|
||||
<file>pics/bg@2x.png</file>
|
||||
<file>pics/slogo-Drawing.svg</file>
|
||||
<file>pics/AI-Drawing@2x.png</file>
|
||||
<file>pics/loading.gif</file>
|
||||
<file>pics/style/style-lolita@2x.png</file>
|
||||
<file>pics/style/style-ancient@2x.png</file>
|
||||
<file>pics/style/style-low-poly@2x.png</file>
|
||||
<file>pics/style/style-watercolour.png</file>
|
||||
<file>pics/style/style-baroque@2x.png</file>
|
||||
<file>pics/style/style-surrealism@2x.png</file>
|
||||
<file>pics/style/style-watercolour@2x.png</file>
|
||||
<file>pics/style/style-futurism.png</file>
|
||||
<file>pics/style/style-surrealism.png</file>
|
||||
<file>pics/style/style-vaporwave.png</file>
|
||||
<file>pics/style/style-oil-painting@2x.png</file>
|
||||
<file>pics/style/style-ancient.png</file>
|
||||
<file>pics/style/style-realistic@2x.png</file>
|
||||
<file>pics/style/style-pixel@2x.png</file>
|
||||
<file>pics/style/style-pixel.png</file>
|
||||
<file>pics/style/style-futurism@2x.png</file>
|
||||
<file>pics/style/style-vaporwave@2x.png</file>
|
||||
<file>pics/style/style-baroque.png</file>
|
||||
<file>pics/style/style-all@2x.png</file>
|
||||
<file>pics/style/style-all.png</file>
|
||||
<file>pics/style/style-anime@2x.png</file>
|
||||
<file>pics/style/style-conceptual@2x.png</file>
|
||||
<file>pics/style/style-ukiyoe.png</file>
|
||||
<file>pics/style/style-cartoon@2x.png</file>
|
||||
<file>pics/style/style-cyberpunk.png</file>
|
||||
<file>pics/style/style-conceptual.png</file>
|
||||
<file>pics/style/style-cartoon.png</file>
|
||||
<file>pics/style/style-cyberpunk@2x.png</file>
|
||||
<file>pics/style/style-ukiyoe@2x.png</file>
|
||||
<file>pics/style/style-low-poly.png</file>
|
||||
<file>pics/style/style-realistic.png</file>
|
||||
<file>pics/style/style-oil-painting.png</file>
|
||||
<file>pics/style/style-anime.png</file>
|
||||
<file>pics/style/style-lolita.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
|
@ -0,0 +1,258 @@
|
|||
/*
|
||||
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef KP_AI_DRAWINGBAR_H
|
||||
#define KP_AI_DRAWINGBAR_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QWidget>
|
||||
#include <QPushButton>
|
||||
#include <QButtonGroup>
|
||||
#include <QLabel>
|
||||
#include <QCheckBox>
|
||||
#include <QVBoxLayout>
|
||||
#include <QDialog>
|
||||
#include <QPixmap>
|
||||
#include <QStackedWidget>
|
||||
#include <QScrollArea>
|
||||
#include <QScrollBar>
|
||||
#include <QPair>
|
||||
#include <QList>
|
||||
#include <QComboBox>
|
||||
#include <QThread>
|
||||
#include <QMouseEvent>
|
||||
#include <QDebug>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonArray>
|
||||
#include <QDir>
|
||||
#include <QGSettings>
|
||||
#include <ai-base/modelconfig.h>
|
||||
#include <ai-base/vision.h>
|
||||
#include <kylin-ai/config.h>
|
||||
|
||||
// #define LOADING_IMAGE "/usr/share/kolourpaint/pics/loading.gif"
|
||||
// #define BG_IMAGE "/usr/share/kolourpaint/pics/bg@2x.png"
|
||||
// #define SLOGO_IMAGE "/usr/share/kolourpaint/pics/slogo-Drawing.svg"
|
||||
// #define DRAWING_IMAGE "/usr/share/kolourpaint/pics/AI-Drawing@2x.png"
|
||||
#define KYLIN_AI_DBUS "com.kylin.aiassistant"
|
||||
#define KYLIN_AI_PATH "/com/kylin/aiassistant"
|
||||
#define AI_GSETTINGS "org.kylin.aiassistant.settings"
|
||||
#define AI_KEY "isVisionSetup"
|
||||
|
||||
const QString LOADING_IMAGE = ":/resource/loading.gif";
|
||||
const QString BG_IMAGE = ":/resource/bg@2x.png";
|
||||
const QString SLOGO_IMAGE = ":/resource/slogo-Drawing.svg";
|
||||
const QString DRAWING_IMAGE = ":/resource/AI-Drawing@2x.png";
|
||||
|
||||
|
||||
/**
|
||||
* @brief The AIModeDataThread class
|
||||
* 线程类,用于跑AI的服务
|
||||
*/
|
||||
class AIModeDataThread : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AIModeDataThread();
|
||||
~AIModeDataThread();
|
||||
|
||||
bool setSessionStatus();
|
||||
VisionSession getVisionSession(){
|
||||
return session;
|
||||
}
|
||||
bool someFunctionInThread();
|
||||
|
||||
void setAIData (QString str, QSize size, int quantity, VisionImageStyle Style){
|
||||
textBox = str;
|
||||
AIImageSize = size;
|
||||
quantityNum = quantity;
|
||||
ImageStyle = Style;
|
||||
}
|
||||
|
||||
signals:
|
||||
void finishedSignal(bool flag, QPixmap pixmap, int imageIndex, int imageSum, int errorCode);
|
||||
|
||||
private:
|
||||
void sendErrorSignal(int ret){
|
||||
emit finishedSignal(false, QPixmap(), 0, 1, ret);
|
||||
for(int i = 0; i < quantityNum; i++)
|
||||
emit finishedSignal(true, QPixmap(), i, quantityNum, ret);
|
||||
}
|
||||
static void generateImageCallback(VisionImageData imageData, void* userData);
|
||||
|
||||
private:
|
||||
QPixmap pixmap;
|
||||
int quantityNum = 1; //数量按钮
|
||||
QSize AIImageSize;
|
||||
QString textBox;
|
||||
VisionImageStyle ImageStyle;
|
||||
bool m_sessionFlag = false;
|
||||
VisionSession session;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The imageClickableLabel class
|
||||
* QLabel点击事件类,用于对图片做处理传输
|
||||
*/
|
||||
class imageClickableLabel : public QLabel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
signals:
|
||||
void labelClicked(const QPixmap &pixmap);
|
||||
|
||||
public:
|
||||
imageClickableLabel(const QPixmap &pixmap, QWidget *parent = nullptr) : QLabel(parent), pixmap(pixmap){}
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent *event) override
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
emit labelClicked(pixmap);
|
||||
}
|
||||
|
||||
private:
|
||||
QPixmap pixmap;
|
||||
};
|
||||
|
||||
|
||||
class aithemebar : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
signals:
|
||||
void imageClicked(const QPixmap &pixmap);
|
||||
|
||||
public:
|
||||
aithemebar(QWidget *parent);
|
||||
~aithemebar();
|
||||
|
||||
public:
|
||||
void initUI();
|
||||
bool getConfigStatus();
|
||||
void getconfigVersionData();
|
||||
void loginConfigurationPage();
|
||||
void setAiPixmap(QPixmap pixmap,int imageIndex, QGridLayout *pageLayout);
|
||||
void updatePageLabel();
|
||||
|
||||
QSize getImageLabelSize();
|
||||
|
||||
bool eventFilter(QObject *watched, QEvent *event);
|
||||
void handleLabelClicked(QObject *clickedObject);
|
||||
|
||||
QPixmap createPixmapWithText(const QString &text);
|
||||
QPixmap AIGeneratesErrorHandling(int errorCode);
|
||||
|
||||
private slots:
|
||||
void onConfigButtonClicked(); //配置按钮回调函数
|
||||
void onConfigSettingsChange(const QString &key); //AI配置成功后回调
|
||||
void onGenerateButtonClicked(); //生成按钮回调函数
|
||||
void handleInputTextChanged(); //文字变化回调函数
|
||||
|
||||
void showPreviousPage(); //显示上一页
|
||||
void showNextPage(); //显示下一页
|
||||
void deleteCurrentPage();
|
||||
void setEnabledDeleteButton();
|
||||
void handleLabelClick(const QPixmap &pixmap);
|
||||
|
||||
void addPageAndStoreImages();
|
||||
void onStyleMoreButtonClick();
|
||||
|
||||
void startThread() {
|
||||
if (m_AiMode->setSessionStatus()){
|
||||
m_AiMode->setAIData(textBox, AIImageSize, quantityNum, ImageStyle);
|
||||
m_AiMode->someFunctionInThread();
|
||||
}
|
||||
}
|
||||
void onThreadFinished(bool flag, QPixmap pixmap, int imageIndex, int imageSum, int errorCode);
|
||||
|
||||
private:
|
||||
void updateImageGrid();
|
||||
void updateResultGrid();
|
||||
void deleteImageGridWidget();
|
||||
|
||||
void addResolutionComboBox();
|
||||
void addQuantityComboBox();
|
||||
|
||||
QJsonArray readResolutionsFromJson(QString key);
|
||||
int readNumFromJson(QString key);
|
||||
QWidget *addAllStyleLabel(QString iconPath, QString labelText, int line);
|
||||
QWidget *addStyleLabel(QString iconPath, QString labelText, int line);
|
||||
|
||||
void addStyleWidget();
|
||||
void addStyleGrid(QWidget *widget, int line);
|
||||
|
||||
private:
|
||||
int imageColumn = 2;//显示列表列数
|
||||
int quantityNum = 1; //数量按钮
|
||||
int show_quantityNum = 1; //数量按钮
|
||||
int currentPageIndx = -1;//切换页第几页
|
||||
|
||||
bool styleFlag; //风格标志位,用于判断按下哪一个风格
|
||||
bool deleteButtonFlag = true;
|
||||
bool buildButtonFlag;
|
||||
|
||||
QGSettings *AiSettings; //监听配置信息
|
||||
QSize AIImageSize; //图片大小
|
||||
QSize showAIImageSize;
|
||||
QMovie *movie = nullptr;//生成等待图标
|
||||
QLabel *resultLabel; //生成结果 label
|
||||
QLabel *pageLabel; //第几页面label
|
||||
|
||||
QLabel *selectedIconLabel;//风格图片选择Label
|
||||
QLabel *selectedTextLabel;//风格文字选择Label
|
||||
|
||||
QWidget *configWidget; //立即配置页面
|
||||
QWidget *widget_low_poly; //多边形风格
|
||||
|
||||
QString textBox; //图像描述文字
|
||||
QString colorfulButtonStyle; //立即生成按钮渐变色
|
||||
QString colorGrayButtonStyle;//立即生成按钮置灰
|
||||
|
||||
QBoxLayout *vbox; //页面布局
|
||||
QHBoxLayout *resultGrid; //生成结果布局
|
||||
QGridLayout *styleGrid; //风格布局
|
||||
QPushButton *moreButton; //更多按钮
|
||||
|
||||
QScrollArea *scrollArea; //滚动窗口
|
||||
QPushButton *buildButton; //立即生成按钮
|
||||
QPushButton *deleteButton; //删除按钮
|
||||
|
||||
QComboBox *resolutionComboBox; //图像分辨率
|
||||
QComboBox *quantityComboBox; //生成数量
|
||||
|
||||
QStackedWidget *stackedWidget; //生成结果的换页窗口
|
||||
QVector<QVector<QPixmap>> imagesVector; //生成图像数据集成
|
||||
|
||||
VisionSession mSession = nullptr;
|
||||
VisionImageStyle ImageStyle; //风格样式
|
||||
AIModeDataThread *m_AiMode; //AI生成程序
|
||||
|
||||
};
|
||||
#endif
|
|
@ -153,8 +153,8 @@ void MainWindow::initUI()
|
|||
// this->setPalette(palette);
|
||||
this->setBackgroundRole(QPalette::Base);
|
||||
this->setAutoFillBackground(true);
|
||||
|
||||
this->setMinimumSize(1280, 720);
|
||||
// this->setMinimumSize(1280, 720);
|
||||
this->setMinimumSize(1600, 900);
|
||||
|
||||
m_maininterface = new MainInterface();
|
||||
m_entrywidget = new QWidget();
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
#include "grubthemewidget.h"
|
||||
#include "../fileProcess/filecheck.h"
|
||||
#include <QFileDialog>
|
||||
#include "../aithemebar.h"
|
||||
#include <QMainWindow>
|
||||
|
||||
bool GrubThemeWidget::g_themeChange;
|
||||
/**
|
||||
|
@ -33,20 +35,34 @@ GrubThemeWidget::GrubThemeWidget(QWidget *parent) : QWidget(parent)
|
|||
{
|
||||
initPreviewWidget();
|
||||
initRightWidget();
|
||||
QHBoxLayout *grubthemelayout = new QHBoxLayout();
|
||||
|
||||
QPushButton *line = new QPushButton();
|
||||
line->setDisabled(true);
|
||||
line->setFixedWidth(1);
|
||||
line->setFixedHeight(2000);
|
||||
grubthemelayout->addWidget(m_previewwidget);
|
||||
grubthemelayout->addWidget(line);
|
||||
grubthemelayout->addWidget(m_rightwidget);
|
||||
m_grubthemelayout = new QHBoxLayout();
|
||||
// grubthemelayout->setSizeConstraint(QLayout::SetMinimumSize);
|
||||
|
||||
grubthemelayout->setContentsMargins(0,0,0,0);
|
||||
grubthemelayout->setSpacing(0);
|
||||
QPushButton *line1 = new QPushButton();
|
||||
line1->setDisabled(true);
|
||||
line1->setFixedWidth(1);
|
||||
line1->setFixedHeight(2000);
|
||||
|
||||
this->setLayout(grubthemelayout);
|
||||
QPushButton *line2 = new QPushButton();
|
||||
line2->setDisabled(true);
|
||||
line2->setFixedWidth(1);
|
||||
line2->setFixedHeight(2000);
|
||||
|
||||
// 主布局添加控件
|
||||
// m_grubthemelayout->addStretch(1);
|
||||
m_grubthemelayout->addWidget(m_previewwidget);
|
||||
m_grubthemelayout->addWidget(line1); // 分割线
|
||||
m_grubthemelayout->addWidget(m_rightwidget);
|
||||
m_grubthemelayout->addWidget(line2); // 分割线
|
||||
initAithemeBar();
|
||||
// m_grubthemelayout->addWidget(m_aithemebar);
|
||||
// m_grubthemelayout->addStretch(1);
|
||||
|
||||
m_grubthemelayout->setContentsMargins(0,0,0,0);
|
||||
m_grubthemelayout->setSpacing(0);
|
||||
|
||||
this->setLayout(m_grubthemelayout);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -73,6 +89,35 @@ void GrubThemeWidget::initPreviewWidget()
|
|||
m_previewwidget->setLayout(m_previewlayout);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 初始化Ai生图小部件
|
||||
* 创建一个新的 QWidget,设置固定高度,并添加到grub布局。
|
||||
* 连接 label 的 clicked 信号,当点击按钮时,传递图片到预览窗口。
|
||||
*/
|
||||
void GrubThemeWidget::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_grubthemelayout->addItem(spacer);
|
||||
m_grubthemelayout->addWidget(m_aithemebar);
|
||||
connect(m_aithemebar, &aithemebar::imageClicked, this, &GrubThemeWidget::updateAIImage);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief 初始化右侧小部件
|
||||
*
|
||||
|
@ -88,6 +133,7 @@ void GrubThemeWidget::initRightWidget()
|
|||
m_rightwidget->setMaximumWidth(400);
|
||||
m_rightwidget->setBackgroundRole(QPalette::Base);
|
||||
m_rightwidget->setAutoFillBackground(true);
|
||||
|
||||
QVBoxLayout *layout = new QVBoxLayout(m_rightwidget);
|
||||
layout->setContentsMargins(0,0,0,0);
|
||||
initEditWidget();
|
||||
|
@ -229,6 +275,52 @@ void GrubThemeWidget::refresh()
|
|||
m_showBtn->setIconSize(QSize(178,122));
|
||||
}
|
||||
|
||||
// void GrubThemeWidget::updateAIImage(const QPixmap &pixmap)
|
||||
// {
|
||||
// m_preview->updateBackground(resourceGrubPath);
|
||||
// QPixmap pixmap(resourceGrubPath);
|
||||
// m_showBtn->setIcon(QIcon(pixmap));
|
||||
// m_showBtn->setIconSize(QSize(178,122));
|
||||
// }
|
||||
|
||||
void GrubThemeWidget::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->updateBackground(tempPath);
|
||||
|
||||
// 将 QPixmap 设置为按钮的图标
|
||||
m_showBtn->setIcon(QIcon(pixmap));
|
||||
|
||||
// 设置按钮图标的大小
|
||||
m_showBtn->setIconSize(QSize(178, 122));
|
||||
}
|
||||
|
||||
void GrubThemeWidget::clearTempFiles()
|
||||
{
|
||||
// 删除所有临时文件
|
||||
for (const QString &filePath : tempFilePaths) {
|
||||
QFile::remove(filePath);
|
||||
}
|
||||
|
||||
// 清空临时文件路径列表
|
||||
tempFilePaths.clear();
|
||||
}
|
||||
|
||||
void GrubThemeWidget::useMaximumScale()
|
||||
{
|
||||
m_preview->maxscale();
|
||||
|
@ -250,15 +342,5 @@ void GrubThemeWidget::setBuildBtnText(bool isglobal)
|
|||
|
||||
void GrubThemeWidget::addspaceritem()
|
||||
{
|
||||
QSpacerItem *spacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
QSpacerItem *spacer2 = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
spacer->changeSize(m_previewwidget->width(), 155, QSizePolicy::Maximum, QSizePolicy::Maximum);
|
||||
spacer2->changeSize(m_previewwidget->width(), 159, QSizePolicy::Maximum, QSizePolicy::Maximum);
|
||||
|
||||
// m_previewlayout->addItem(spacer);
|
||||
m_previewlayout->addWidget(m_preview);
|
||||
// m_previewlayout->addItem(spacer2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "grubthemefeature.h"
|
||||
#include "historywidget.h"
|
||||
#include "basewidget.h"
|
||||
#include "../aithemebar.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QWidget>
|
||||
|
@ -39,14 +40,18 @@ public:
|
|||
explicit GrubThemeWidget(QWidget *parent = nullptr);
|
||||
void initPreviewWidget();
|
||||
void initRightWidget();
|
||||
void initAithemeBar();
|
||||
void addspaceritem();
|
||||
void initEditWidget();
|
||||
void initBuildWidget();
|
||||
static bool g_themeChange;
|
||||
void eidtInitWidget(const HistoryInfo &InfoData);
|
||||
void refresh();
|
||||
void updateAIImage(const QPixmap &pixmap);
|
||||
// void updateAIImage();
|
||||
void useMaximumScale();
|
||||
void useRestoreScale();
|
||||
void clearTempFiles();
|
||||
void setBuildBtnText(bool isglobal);
|
||||
signals:
|
||||
void newGrubFilePath(const QString& path);
|
||||
|
@ -56,11 +61,15 @@ private:
|
|||
BasePreviewWidget *m_previewwidget;
|
||||
GrubImageWidget *m_preview;
|
||||
QWidget *m_rightwidget;
|
||||
QHBoxLayout *m_grubthemelayout;
|
||||
QWidget *m_grubwidget;
|
||||
QWidget *m_buildwidget;
|
||||
aithemebar *m_aithemebar;
|
||||
QVBoxLayout *m_previewlayout;
|
||||
GrubEditButton *m_showBtn;
|
||||
QPushButton *m_buildButton;
|
||||
// 声明并初始化 tempFilePaths 列表
|
||||
QList<QString> tempFilePaths;
|
||||
};
|
||||
|
||||
#endif // GRUBTHEMEWIDGET_H
|
||||
|
|
|
@ -32,15 +32,22 @@ PlymouthThemeWidget::PlymouthThemeWidget(QWidget *parent) : QWidget(parent)
|
|||
{
|
||||
initPreviewWidget();
|
||||
initRightWidget();
|
||||
QHBoxLayout *plymouththemelayout = new QHBoxLayout();
|
||||
plymouththemelayout = new QHBoxLayout();
|
||||
|
||||
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);
|
||||
plymouththemelayout->addWidget(m_previewwidget);
|
||||
plymouththemelayout->addWidget(line);
|
||||
plymouththemelayout->addWidget(line1);
|
||||
plymouththemelayout->addWidget(m_rightwidget);
|
||||
plymouththemelayout->addWidget(line2);
|
||||
initAithemeBar();
|
||||
|
||||
|
||||
plymouththemelayout->setContentsMargins(0,0,0,0);
|
||||
|
@ -72,6 +79,34 @@ void PlymouthThemeWidget::initPreviewWidget()
|
|||
m_previewwidget->setLayout(m_previewlayout);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 初始化Ai生图小部件
|
||||
* 创建一个新的 QWidget,设置固定高度,并添加到grub布局。
|
||||
* 连接 label 的 clicked 信号,当点击按钮时,传递图片到预览窗口。
|
||||
*/
|
||||
void PlymouthThemeWidget::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);
|
||||
plymouththemelayout->addItem(spacer);
|
||||
plymouththemelayout->addWidget(m_aithemebar);
|
||||
connect(m_aithemebar, &aithemebar::imageClicked, this, &PlymouthThemeWidget::updateAIImage);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 初始化右侧小部件
|
||||
*
|
||||
|
@ -313,6 +348,35 @@ void PlymouthThemeWidget::refresh()
|
|||
m_customLabel->setPixmap(QPixmap());
|
||||
}
|
||||
|
||||
void PlymouthThemeWidget::updateAIImage(const QPixmap &pixmap)
|
||||
{
|
||||
// 生成唯一的临时文件路径
|
||||
QString tempPath = QString("/tmp/temp_image_%1.png").arg(QUuid::createUuid().toString(QUuid::WithoutBraces));
|
||||
|
||||
// 固定预览窗口的尺寸为 400x400
|
||||
QSize previewSize(400, 400);
|
||||
|
||||
// 调整 QPixmap 的尺寸以适应预览窗口
|
||||
QPixmap scaledPixmap = pixmap.scaled(previewSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
|
||||
// 将调整后的 QPixmap 保存到临时文件
|
||||
scaledPixmap.save(tempPath);
|
||||
|
||||
// 将临时文件路径添加到列表中
|
||||
tempFilePaths.append(tempPath);
|
||||
|
||||
// 更新预览窗口的背景图片
|
||||
m_preview->updatePlymouth(tempPath);
|
||||
m_preview->showPlymouth();
|
||||
|
||||
// 将 QPixmap 设置为按钮的图标
|
||||
// m_showBtn->setIcon(QIcon(pixmap));
|
||||
m_customLabel->setPixmap(QPixmap(pixmap));
|
||||
|
||||
// 设置按钮图标的大小
|
||||
// m_showBtn->setIconSize(QSize(178, 122));
|
||||
}
|
||||
|
||||
void PlymouthThemeWidget::useMaximumScale()
|
||||
{
|
||||
m_preview->maxscale();
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "historywidget.h"
|
||||
#include "basewidget.h"
|
||||
#include "../fileProcess/filecheck.h"
|
||||
#include "../aithemebar.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QWidget>
|
||||
|
@ -39,6 +40,7 @@ class PlymouthThemeWidget : public QWidget
|
|||
public:
|
||||
explicit PlymouthThemeWidget(QWidget *parent = nullptr);
|
||||
void initPreviewWidget();
|
||||
void initAithemeBar();
|
||||
void initRightWidget();
|
||||
void addspaceritem();
|
||||
void initEditWidget();
|
||||
|
@ -48,6 +50,7 @@ public:
|
|||
void startShowPlymouth();
|
||||
void eidtInitWidget(const HistoryInfo &InfoData);
|
||||
void refresh();
|
||||
void updateAIImage(const QPixmap &pixmap);
|
||||
void useMaximumScale();
|
||||
void useRestoreScale();
|
||||
void setBuildBtnText(bool isglobal);
|
||||
|
@ -62,6 +65,7 @@ private:
|
|||
QWidget *m_plymouthwidget;
|
||||
QWidget *m_buildwidget;
|
||||
QVBoxLayout *m_previewlayout;
|
||||
QHBoxLayout *plymouththemelayout;
|
||||
PlymouthCustomLabel *m_customLabel;
|
||||
QString m_imagedirpath;
|
||||
QRadioButton *pic;
|
||||
|
@ -69,6 +73,8 @@ private:
|
|||
QRadioButton *video;
|
||||
QLabel *videoLabel;
|
||||
QPushButton *m_buildButton;
|
||||
aithemebar *m_aithemebar;
|
||||
QList<QString> tempFilePaths;
|
||||
};
|
||||
|
||||
#endif // PLYMOUTHMOUTHTHEMEWIDGET_H
|
||||
|
|