!48 fix cursor

Merge pull request !48 from likehomedream/my-devel
This commit is contained in:
KevinDuan 2023-11-13 02:35:13 +00:00 committed by Gitee
commit 3c5d014049
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
67 changed files with 381 additions and 131 deletions

View File

@ -1,61 +1,5 @@
<RCC>
<qresource prefix="/">
<file>resource/cursor/all-scroll.png</file>
<file>resource/cursor/bd_double_arrow.png</file>
<file>resource/cursor/bottom_left_corner.png</file>
<file>resource/cursor/bottom_right_corner.png</file>
<file>resource/cursor/bottom_side.png</file>
<file>resource/cursor/bottom_tee.png</file>
<file>resource/cursor/circle.png</file>
<file>resource/cursor/color-picker.png</file>
<file>resource/cursor/copy.png</file>
<file>resource/cursor/cross.png</file>
<file>resource/cursor/crossed_circle.png</file>
<file>resource/cursor/crosshair.png</file>
<file>resource/cursor/dnd-ask.png</file>
<file>resource/cursor/dnd-copy.png</file>
<file>resource/cursor/dnd-link.png</file>
<file>resource/cursor/dnd-move.png</file>
<file>resource/cursor/dnd-none.png</file>
<file>resource/cursor/dotbox.png</file>
<file>resource/cursor/fd_double_arrow.png</file>
<file>resource/cursor/grabbing.png</file>
<file>resource/cursor/h_double_arrow.png</file>
<file>resource/cursor/hand1.png</file>
<file>resource/cursor/hand2.png</file>
<file>resource/cursor/kylin-move.png</file>
<file>resource/cursor/left_ptr.png</file>
<file>resource/cursor/left_side.png</file>
<file>resource/cursor/left_tee.png</file>
<file>resource/cursor/link.png</file>
<file>resource/cursor/ll_angle.png</file>
<file>resource/cursor/lr_angle.png</file>
<file>resource/cursor/move.png</file>
<file>resource/cursor/pencil.png</file>
<file>resource/cursor/plus.png</file>
<file>resource/cursor/question_arrow.png</file>
<file>resource/cursor/right_ptr.png</file>
<file>resource/cursor/right_side.png</file>
<file>resource/cursor/right_tee.png</file>
<file>resource/cursor/sb_down_arrow.png</file>
<file>resource/cursor/sb_h_double_arrow.png</file>
<file>resource/cursor/sb_left_arrow.png</file>
<file>resource/cursor/sb_right_arrow.png</file>
<file>resource/cursor/sb_up_arrow.png</file>
<file>resource/cursor/sb_v_double_arrow.png</file>
<file>resource/cursor/tcross.png</file>
<file>resource/cursor/top_left_corner.png</file>
<file>resource/cursor/top_right_corner.png</file>
<file>resource/cursor/top_side.png</file>
<file>resource/cursor/top_tee.png</file>
<file>resource/cursor/ul_angle.png</file>
<file>resource/cursor/ur_angle.png</file>
<file>resource/cursor/v_double_arrow.png</file>
<file>resource/cursor/vertical_text.png</file>
<file>resource/cursor/X_cursor.png</file>
<file>resource/cursor/xterm.png</file>
<file>resource/cursor/zoom-in.png</file>
<file>resource/cursor/zoom-out.png</file>
<file>resource/appicons/biometric-manager.png</file>
<file>resource/appicons/box-manager.png</file>
<file>resource/appicons/burner.png</file>
@ -100,20 +44,6 @@
<file>resource/systemicons/kylin-settings-update.png</file>
<file>resource/background/1-warty-final-ubuntukylin.jpg</file>
<file>resource/time-cursor/left_ptr_watch_1.png</file>
<file>resource/time-cursor/left_ptr_watch_2.png</file>
<file>resource/time-cursor/left_ptr_watch_3.png</file>
<file>resource/time-cursor/left_ptr_watch_4.png</file>
<file>resource/time-cursor/left_ptr_watch_5.png</file>
<file>resource/time-cursor/watch_1.png</file>
<file>resource/time-cursor/watch_2.png</file>
<file>resource/time-cursor/watch_3.png</file>
<file>resource/time-cursor/watch_4.png</file>
<file>resource/time-cursor/watch_5.png</file>
<file>resource/time-cursor/watch_6.png</file>
<file>resource/time-cursor/watch_7.png</file>
<file>resource/time-cursor/watch_8.png</file>
<file>resource/time-cursor/watch_9.png</file>
<file>resource/time-cursor/watch_10.png</file>
<file>resource/background/controlcenter-light.png</file>
<file>resource/background/controlcenter-dark.png</file>
<file>resource/background/background-glazing.png</file>
@ -135,5 +65,54 @@
<file>resource/background/grub-listview.png</file>
<file>resource/background/homepage-plymouth.png</file>
<file>resource/background/homepage-grub.png</file>
<file>resource/cursor/all-scroll.png</file>
<file>resource/cursor/bottom_tee.png</file>
<file>resource/cursor/circle.png</file>
<file>resource/cursor/left_ptr.png</file>
<file>resource/cursor/right_ptr.png</file>
<file>resource/cursor/color-picker.png</file>
<file>resource/cursor/cross.png</file>
<file>resource/cursor/dnd-ask.png</file>
<file>resource/cursor/dnd-copy.png</file>
<file>resource/cursor/dnd-link.png</file>
<file>resource/cursor/dnd-none.png</file>
<file>resource/cursor/dotbox.png</file>
<file>resource/cursor/h_double_arrow.png</file>
<file>resource/cursor/hand1.png</file>
<file>resource/cursor/hand2.png</file>
<file>resource/cursor/left_tee.png</file>
<file>resource/cursor/pencil.png</file>
<file>resource/cursor/plus.png</file>
<file>resource/cursor/right_tee.png</file>
<file>resource/cursor/sb_down_arrow.png</file>
<file>resource/cursor/sb_h_double_arrow.png</file>
<file>resource/cursor/sb_left_arrow.png</file>
<file>resource/cursor/sb_right_arrow.png</file>
<file>resource/cursor/sb_up_arrow.png</file>
<file>resource/cursor/sb_v_double_arrow.png</file>
<file>resource/cursor/tcross.png</file>
<file>resource/cursor/top_tee.png</file>
<file>resource/cursor/ul_angle.png</file>
<file>resource/cursor/ur_angle.png</file>
<file>resource/cursor/v_double_arrow.png</file>
<file>resource/cursor/vertical_text.png</file>
<file>resource/cursor/X_cursor.png</file>
<file>resource/cursor/xterm.png</file>
<file>resource/cursor/zoom-in.png</file>
<file>resource/cursor/zoom-out.png</file>
<file>resource/time-cursor/left_ptr_watch_2.png</file>
<file>resource/time-cursor/left_ptr_watch_3.png</file>
<file>resource/time-cursor/left_ptr_watch_4.png</file>
<file>resource/time-cursor/left_ptr_watch_5.png</file>
<file>resource/time-cursor/watch_1.png</file>
<file>resource/time-cursor/watch_2.png</file>
<file>resource/time-cursor/watch_3.png</file>
<file>resource/time-cursor/watch_4.png</file>
<file>resource/time-cursor/watch_5.png</file>
<file>resource/time-cursor/watch_6.png</file>
<file>resource/time-cursor/watch_7.png</file>
<file>resource/time-cursor/watch_8.png</file>
<file>resource/time-cursor/watch_9.png</file>
<file>resource/time-cursor/watch_10.png</file>
</qresource>
</RCC>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 650 B

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 886 B

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 886 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 736 B

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 686 B

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 694 B

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 713 B

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 621 B

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 557 B

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 682 B

After

Width:  |  Height:  |  Size: 1.2 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: 1.8 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

View File

@ -69,21 +69,16 @@ void Bridge::systemIconsMapChanged(QMap<QString, QString> *systemiconsmaps)
void Bridge::cursorMapChanged(QMap<QString, QString> *cursormap)
{
QMap<QString, QString>::const_iterator it;
for (it = cursormap->begin(); it != cursormap->end(); ++it) {
qDebug() << "Key:" << it.key() << "Value:" << it.value();
}
m_cursorpathmap = cursormap;
m_configfilemanager->copyIcontoCacheDir(cursormap,QDir::homePath()+"/.cache/theme-build/"
+FileProcess::g_date+"/src/cursorTheme/cursor");
}
void Bridge::timeCursorMapChanged(QMap<QString, QString> *timecursormap)
{
QMap<QString, QString>::const_iterator it;
for (it = timecursormap->begin(); it != timecursormap->end(); ++it) {
qDebug() << "Key:" << it.key() << "Value:" << it.value();
}
m_timecursorpathmap = timecursormap;
qDebug()<< "timeCursorMapChanged";
m_configfilemanager->copyIcontoCacheDir(timecursormap,QDir::homePath()+"/.cache/theme-build/"
+FileProcess::g_date+"/src/cursorTheme/timecursor");
}
void Bridge::plymouthPathChanged(QString path)
@ -130,6 +125,12 @@ void Bridge::updateIconCache(QMap<QString, QString> *iconsmaps, QString icontype
}else if(icontype == "systemicon"){
m_configfilemanager->copyIcontoCacheDir(iconsmaps,QDir::homePath()+"/.cache/theme-build/"
+FileProcess::g_date+"/src/iconTheme/systemicon");
}else if(icontype == "cursor"){
m_configfilemanager->copyIcontoCacheDir(iconsmaps,QDir::homePath()+"/.cache/theme-build/"
+FileProcess::g_date+"/src/cursorTheme/cursor");
}else if(icontype == "timecursor"){
m_configfilemanager->copyIcontoCacheDir(iconsmaps,QDir::homePath()+"/.cache/theme-build/"
+FileProcess::g_date+"/src/cursorTheme/timecursor");
}
}

View File

@ -246,7 +246,7 @@ void HistoryInfoLoad::getWindowRadius()
HistoryInfo HistoryInfoLoad::getInfoData()
{
qDebug()<<m_historyInfo.accentcolor<<m_historyInfo.wallpaperpath<<m_historyInfo.filepath<<m_historyInfo.windowradius<<"+++++++++++++++++++++++++++++++++++++++++";
qDebug()<<m_historyInfo.accentcolor<<m_historyInfo.wallpaperpath<<m_historyInfo.filepath<<m_historyInfo.windowradius;
return m_historyInfo;
}

View File

@ -238,6 +238,7 @@ void MainInterface::getThemeInfo(const HistoryInfo &InfoData)
m_globalthemewidget->eidtInitWidget(InfoData);
}else if(InfoData.themetype == "cursorTheme"){
setCursorTheme();
m_cursorthemewidget->eidtInitWidget(InfoData);
}else if(InfoData.themetype == "iconTheme"){
setIconTheme();
m_iconthemewidget->eidtInitWidget(InfoData);
@ -255,6 +256,16 @@ QMap<QString, QString> *MainInterface::getSystemIconsMap()
return m_iconthemewidget->getSystemIconsMap();
}
QMap<QString, QString> *MainInterface::getCurosrMap()
{
return m_cursorthemewidget->getCursorMap();
}
QMap<QString, QString> *MainInterface::getTimeCurosrMap()
{
return m_cursorthemewidget->getTimeCursorMap();
}
void MainInterface::updateButtonGroup(bool isGlobalTheme)
{
if(isGlobalTheme){

View File

@ -40,8 +40,11 @@ public:
void getThemeInfo(const HistoryInfo &InfoData);
void updateButtonGroup(bool isGlobalTheme);
//初始化和刷新时使用
QMap<QString, QString>* getAppIconsMap();
QMap<QString, QString>* getSystemIconsMap();
QMap<QString, QString>* getCurosrMap();
QMap<QString, QString>* getTimeCurosrMap();
signals:
void wallpaperupdate(const QString& filePath);

View File

@ -160,6 +160,8 @@ void MainWindow::initUI()
InfoCreateWidget* m_infoCreateWidget = new InfoCreateWidget(nullptr, m_fileProcess.FileCreate("cursorTheme"), "recognise");
m_infoCreateWidget->show();
m_bridge->createFileManager(false,FileProcess::g_date);
m_bridge->updateIconCache(m_maininterface->getCurosrMap(),"cursor");
m_bridge->updateIconCache(m_maininterface->getTimeCurosrMap(),"timecursor");
}else if (button == m_plymouthbtn) {
m_maininterface->setPlymouthTheme();
InfoCreateWidget* m_infoCreateWidget = new InfoCreateWidget(nullptr, m_fileProcess.FileCreate("plymouthTheme"), "recognise");

View File

@ -98,43 +98,48 @@ void CursorImageWidget::updateImage(const QString& imagePath)
graphicsView->viewport()->update();
}
CursorImageWidget::CursorImageWidget(QWidget *parent, const QMap<QString, QString>* iconMap)
: QWidget(parent), m_iconMap(iconMap)
void CursorImageWidget::updateIconMap(const QMap<QString, QString> *newIconMap)
{
QGraphicsScene* scene = new QGraphicsScene(this);
graphicsView = new CursorGraphicsView(scene);
QVBoxLayout* layout = new QVBoxLayout(this);
layout->addWidget(graphicsView);
setLayout(layout);
QPixmap image(":/resource/background/background-light.png");
if (image.isNull()) {
qDebug() << "Failed to load image.";
// 创建有序的键值对列表
QList<QPair<QString, QString>> sortedList;
for (auto it = newIconMap->begin(); it != newIconMap->end(); ++it) {
sortedList.append(qMakePair(it.key(), it.value()));
}
std::sort(sortedList.begin(), sortedList.end(), [this, newIconMap](const QPair<QString, QString>& pair1, const QPair<QString, QString>& pair2) {
QStringList order1 = QStringList() << "left_ptr" << "dnd-none" << "hand1" << "hand2" << "right_ptr"
<< "dnd-ask"<< "dnd-copy" << "dnd-link"
<< "h_double_arrow" << "v_double_arrow" << "ul_angle" << "ur_angle"
<< "left_tee" << "bottom_tee"<< "top_tee" << "right_tee" << "cross" << "tcross"
<< "sb_up_arrow" << "sb_left_arrow" << "sb_down_arrow" << "sb_right_arrow" << "all-scroll"
<< "sb_h_double_arrow" << "sb_v_double_arrow" << "vertical_text" << "xterm"
<< "zoom-in" << "zoom-out"
<< "circle" << "color-picker" << "pencil" << "dotbox" << "X_cursor" << "plus";
// 创建 QGraphicsPixmapItem 并添加到 QGraphicsScene
QGraphicsPixmapItem* backgroundItem = scene->addPixmap(image);
QStringList order2 = QStringList() << "left_ptr_watch_1" << "left_ptr_watch_2" << "left_ptr_watch_3" << "left_ptr_watch_4" << "left_ptr_watch_5"
<< "watch_1" << "watch_2" << "watch_3" << "watch_4" << "watch_5" << "watch_6" << "watch_7" << "watch_8" << "watch_9" << "watch_10";
// 创建 QGraphicsBlurEffect 并设置模糊半径
QGraphicsBlurEffect* blurEffect = new QGraphicsBlurEffect;
blurEffect->setBlurRadius(10); // 设置模糊半径,可以根据需要调整
if (newIconMap->contains("left_ptr_watch_1")) {
return order2.indexOf(pair1.first) < order2.indexOf(pair2.first);
} else {
return order1.indexOf(pair1.first) < order1.indexOf(pair2.first);
}
});
// 将模糊效果应用到 QGraphicsPixmapItem 上
backgroundItem->setGraphicsEffect(blurEffect);
graphicsView->fitInView(scene->sceneRect(), Qt::KeepAspectRatio);
graphicsView->setScene(scene);
graphicsView->fitInView(scene->sceneRect(), Qt::KeepAspectRatio);
graphicsView->show();
// 更新 m_iconMap
m_iconMap = newIconMap;
// 清空场景
QGraphicsScene* scene = graphicsView->scene();
scene->clear();
int columnCount = 15;
int row = 1;
int col = 0;
for (auto it = m_iconMap->begin(); it != m_iconMap->end(); ++it) {
const QString& widgetName = it.key();
const QString& filePath = it.value();
// 添加新的图像项到场景中
for (const auto& pair : sortedList) {
const QString& widgetName = pair.first;
const QString& filePath = pair.second;
QPixmap pixmap(filePath);
if (!pixmap.isNull()) {
@ -153,9 +158,93 @@ CursorImageWidget::CursorImageWidget(QWidget *parent, const QMap<QString, QStrin
qDebug() << "Failed to load image:" << filePath;
}
}
// 设置初始缩放倍数为0.9倍
// qreal initialScale = 0.8;
// graphicsView->scale(initialScale, initialScale);
// 重新调整视图和显示场景
graphicsView->fitInView(scene->sceneRect(), Qt::KeepAspectRatio);
graphicsView->show();
}
CursorImageWidget::CursorImageWidget(QWidget *parent, const QMap<QString, QString>* iconMap)
: QWidget(parent), m_iconMap(iconMap)
{
QGraphicsScene* scene = new QGraphicsScene(this);
graphicsView = new CursorGraphicsView(scene);
QVBoxLayout* layout = new QVBoxLayout(this);
layout->addWidget(graphicsView);
setLayout(layout);
QPixmap image(":/resource/background/background-light.png");
if (image.isNull()) {
qDebug() << "Failed to load image.";
}
// 创建 QGraphicsPixmapItem 并添加到 QGraphicsScene
QGraphicsPixmapItem* backgroundItem = scene->addPixmap(image);
// 创建 QGraphicsBlurEffect 并设置模糊半径
QGraphicsBlurEffect* blurEffect = new QGraphicsBlurEffect;
blurEffect->setBlurRadius(10); // 设置模糊半径,可以根据需要调整
// 将模糊效果应用到 QGraphicsPixmapItem 上
backgroundItem->setGraphicsEffect(blurEffect);
graphicsView->fitInView(scene->sceneRect(), Qt::KeepAspectRatio);
graphicsView->setScene(scene);
graphicsView->fitInView(scene->sceneRect(), Qt::KeepAspectRatio);
graphicsView->show();
int columnCount = 15;
int row = 1;
int col = 0;
// 创建有序的键值对列表
QList<QPair<QString, QString>> sortedList;
for (auto it = m_iconMap->begin(); it != m_iconMap->end(); ++it) {
sortedList.append(qMakePair(it.key(), it.value()));
}
std::sort(sortedList.begin(), sortedList.end(), [this](const QPair<QString, QString>& pair1, const QPair<QString, QString>& pair2) {
QStringList order1 = QStringList() << "left_ptr" << "dnd-none" << "hand1" << "hand2" << "right_ptr"
<< "dnd-ask"<< "dnd-copy" << "dnd-link"
<< "h_double_arrow" << "v_double_arrow" << "ul_angle" << "ur_angle"
<< "left_tee" << "bottom_tee"<< "top_tee" << "right_tee" << "cross" << "tcross"
<< "sb_up_arrow" << "sb_left_arrow" << "sb_down_arrow" << "sb_right_arrow" << "all-scroll"
<< "sb_h_double_arrow" << "sb_v_double_arrow" << "vertical_text" << "xterm"
<< "zoom-in" << "zoom-out"
<< "circle" << "color-picker" << "pencil" << "dotbox" << "X_cursor" << "plus";
QStringList order2 = QStringList() << "left_ptr_watch_1" << "left_ptr_watch_2" << "left_ptr_watch_3" << "left_ptr_watch_4" << "left_ptr_watch_5"
<< "watch_1" << "watch_2" << "watch_3" << "watch_4" << "watch_5" << "watch_6" << "watch_7" << "watch_8" << "watch_9" << "watch_10";
if (m_iconMap->contains("left_ptr_watch_1")) {
return order2.indexOf(pair1.first) < order2.indexOf(pair2.first);
} else {
return order1.indexOf(pair1.first) < order1.indexOf(pair2.first);
}
});
for (const auto& pair : sortedList) {
const QString& widgetName = pair.first;
const QString& filePath = pair.second;
QPixmap pixmap(filePath);
if (!pixmap.isNull()) {
QGraphicsPixmapItem* item = scene->addPixmap(pixmap.scaled(128, 128));
item->setPos(col * 128, row * 128);
item->setScale(1.0);
item->setData(0, widgetName);
item->setData(1, filePath);
col++;
if (col >= columnCount) {
col = 0;
row++;
}
} else {
qDebug() << "Failed to load image:" << filePath;
}
}
qreal initialScale = 0.3;
QTransform transform;
transform.scale(initialScale, initialScale);
@ -176,7 +265,7 @@ void CursorImageWidget::updateIcon(const QString& widgetName, const QString& new
delete pixmapItem;
QPixmap newPixmap(newFilePath);
if (!newPixmap.isNull()) {
QGraphicsPixmapItem* newPixmapItem = scene->addPixmap(newPixmap.scaled(256, 256));
QGraphicsPixmapItem* newPixmapItem = scene->addPixmap(newPixmap.scaled(128, 128));
newPixmapItem->setData(0, widgetName);
newPixmapItem->setData(1, newFilePath);
newPixmapItem->setPos(oldPosition);

View File

@ -77,6 +77,7 @@ public:
void updateIcon(const QString& widgetName, const QString& newFilePath);
void updateImage(const QString& imagePath);
void updateIconMap(const QMap<QString, QString>* newIconMap);
void setIconMap(QMap<QString,QString>*);
private:

View File

@ -13,6 +13,27 @@ CursorThemeWidget::CursorThemeWidget(QWidget *parent) : QWidget(parent)
this->setLayout(m_cursorthemelayout);
}
QMap<QString, QString> *CursorThemeWidget::getCursorMap()
{
return m_iconpathmap;
}
QMap<QString, QString> *CursorThemeWidget::getTimeCursorMap()
{
return m_timeiconpathmap;
}
void CursorThemeWidget::eidtInitWidget(const HistoryInfo &InfoData)
{
m_info = InfoData;
setHistoryCursor("cursor");
setHistoryCursor("timecursor");
m_preview->updateIconMap(m_historyiconpathmap);
m_preview2->updateIconMap(m_historytimeiconpathmap);
updateCustomPathMap(m_historyiconpathmap,"cursor");
updateCustomPathMap(m_historytimeiconpathmap,"timecursor");
}
void CursorThemeWidget::initPreviewWidget()
{
m_previewwidget = new QWidget(this);
@ -84,7 +105,7 @@ void CursorThemeWidget::initTimeMaps()
}
m_timecustomiconpathmap= new QMap<QString, QString>;
m_pathWidgetMap = new QMap<QString, CursorEditWidget*>;
m_timepathWidgetMap = new QMap<QString, CursorEditWidget*>;
}
void CursorThemeWidget::initRightWidget()
@ -103,18 +124,47 @@ void CursorThemeWidget::initRightWidget()
QVBoxLayout *mainLayout = new QVBoxLayout(viewportWidget);
viewportWidget->setLayout(mainLayout);
QMap<QString, QString> *combinedMap = m_iconpathmap;
combinedMap->unite(*m_timeiconpathmap);
for (auto it = combinedMap->begin(); it != combinedMap->end(); ++it) {
const QString& widgetName = it.key();
const QString& filePath = it.value();
// 创建有序的键值对列表
QList<QPair<QString, QString>> sortedList1;
for (auto it = m_iconpathmap->begin(); it != m_iconpathmap->end(); ++it) {
sortedList1.append(qMakePair(it.key(), it.value()));
}
QList<QPair<QString, QString>> sortedList2;
for (auto it = m_timeiconpathmap->begin(); it != m_timeiconpathmap->end(); ++it) {
sortedList2.append(qMakePair(it.key(), it.value()));
}
std::sort(sortedList1.begin(), sortedList1.end(), [](const QPair<QString, QString>& pair1, const QPair<QString, QString>& pair2){
// 按照指定顺序进行排序
QStringList order = QStringList() << "left_ptr" << "dnd-none" << "hand1" << "hand2" << "right_ptr"
<< "dnd-ask"<< "dnd-copy" << "dnd-link"
<< "h_double_arrow" << "v_double_arrow" << "ul_angle" << "ur_angle"
<< "left_tee" << "bottom_tee"<< "top_tee" << "right_tee" << "cross" << "tcross"
<< "sb_up_arrow" << "sb_left_arrow" << "sb_down_arrow" << "sb_right_arrow" << "all-scroll"
<< "sb_h_double_arrow" << "sb_v_double_arrow" << "vertical_text" << "xterm"
<< "zoom-in" << "zoom-out"
<< "circle" << "color-picker" << "pencil" << "dotbox" << "X_cursor" << "plus";
return order.indexOf(pair1.first) < order.indexOf(pair2.first);
});
std::sort(sortedList2.begin(), sortedList2.end(), [](const QPair<QString, QString>& pair1, const QPair<QString, QString>& pair2){
QStringList order = QStringList() << "left_ptr_watch_1" << "left_ptr_watch_2" << "left_ptr_watch_3"
<< "left_ptr_watch_4" << "left_ptr_watch_5"
<< "watch_1" << "watch_2" << "watch_3" << "watch_4" << "watch_5"
<< "watch_6" << "watch_7" << "watch_8" << "watch_9" << "watch_10";;
return order.indexOf(pair1.first) < order.indexOf(pair2.first);
});
for (const auto& pair : sortedList1) {
const QString& widgetName = pair.first;
const QString& filePath = pair.second;
CursorEditWidget* widget = new CursorEditWidget(viewportWidget);
widget->setdefaulticon(filePath);
mainLayout->addWidget(widget);
m_pathWidgetMap->insert(widgetName, widget);
connect(widget->m_addiconbutton, &QPushButton::clicked, this, [=]() {
QPushButton* clickedButton = qobject_cast<QPushButton*>(sender());
@ -123,19 +173,36 @@ void CursorThemeWidget::initRightWidget()
if (clickedWidget) {
QString newFilePath = QFileDialog::getOpenFileName(this, tr("Select SVG file"), "", tr("SVG file (*.svg)"));
if (!newFilePath.isEmpty()) {
if (m_iconpathmap->contains(widgetName)) {
m_customiconpathmap->insert(widgetName, newFilePath);
emit newCursorMap(m_customiconpathmap);
} else if (m_timeiconpathmap->contains(widgetName)) {
m_timecustomiconpathmap->insert(widgetName, newFilePath);
emit newCursorMap(m_timecustomiconpathmap);
}
m_customiconpathmap->insert(widgetName, newFilePath);
m_preview->updateIcon(widgetName, newFilePath);
clickedWidget->setcustomicon(newFilePath);
emit newCursorMap(m_customiconpathmap);
}
}
}
});
}
for (const auto& pair : sortedList2) {
const QString& widgetName = pair.first;
const QString& filePath = pair.second;
CursorEditWidget* widget = new CursorEditWidget(viewportWidget);
widget->setdefaulticon(filePath);
mainLayout->addWidget(widget);
m_timepathWidgetMap->insert(widgetName, widget);
connect(widget->m_addiconbutton, &QPushButton::clicked, this, [=]() {
QPushButton* clickedButton = qobject_cast<QPushButton*>(sender());
if (clickedButton) {
CursorEditWidget* clickedWidget = qobject_cast<CursorEditWidget*>(clickedButton->parentWidget());
if (clickedWidget) {
QString newFilePath = QFileDialog::getOpenFileName(this, tr("Select SVG file"), "", tr("SVG file (*.svg)"));
if (!newFilePath.isEmpty()) {
m_timecustomiconpathmap->insert(widgetName, newFilePath);
m_preview2->updateIcon(widgetName, newFilePath);
clickedWidget->setcustomicon(newFilePath);
emit newTimeCursorMap(m_timecustomiconpathmap);
}
}
@ -147,3 +214,91 @@ void CursorThemeWidget::initRightWidget()
mainWidgetLayout->addWidget(m_scrollArea);
m_rightwidget->setLayout(mainWidgetLayout);
}
void CursorThemeWidget::setHistoryCursor(QString type)
{
if("cursor" == type){
QString directoryPath = m_info.filepath + "/src/cursorTheme/cursor/";
QDir directory(directoryPath);
QStringList filters;
filters << "*.png" << "*.svg";
QStringList fileList = directory.entryList(filters, QDir::Files);
m_historyiconpathmap = new QMap<QString, QString>;
foreach (const QString& fileName, fileList) {
QString filePath = directoryPath + fileName; // 使用文件名构建文件路径
QString name = fileName.left(fileName.lastIndexOf('.'));
m_historyiconpathmap->insert(name, filePath);
}
} else if ("timecursor" == type){
QString directoryPath = m_info.filepath + "/src/cursorTheme/timecursor/";
QDir directory(directoryPath);
QStringList filters;
filters << "*.png" << "*.svg";
QStringList fileList = directory.entryList(filters, QDir::Files);
m_historytimeiconpathmap = new QMap<QString, QString>;
foreach (const QString& fileName, fileList) {
QString filePath = directoryPath + fileName; // 使用文件名构建文件路径
QString name = fileName.left(fileName.lastIndexOf('.'));
m_historytimeiconpathmap->insert(name, filePath);
}
}
}
void CursorThemeWidget::updateCustomPathMap(QMap<QString, QString> *historyMap, QString type)
{
if("cursor" == type){
m_customiconpathmap->clear();
m_customiconpathmap = historyMap;
for (auto it = m_pathWidgetMap->begin(); it != m_pathWidgetMap->end(); ++it) {
const QString& widgetName = it.key();
CursorEditWidget* widget = it.value();
widget->setcustomicon(NULL);
if (m_customiconpathmap->contains(widgetName)) {
const QString& filePath = m_customiconpathmap->value(widgetName);
// 判断文件类型为svg才显示
QFileInfo fileInfo(filePath);
if (fileInfo.suffix().toLower() == "svg") {
widget->setcustomicon(filePath);
m_preview->updateIcon(widgetName, filePath);
}
else {
// 如果文件类型不是svg直接跳过并不显示
continue;
}
}
}
} else if ("timecursor" == type){
m_timecustomiconpathmap->clear();
m_timecustomiconpathmap = historyMap;
for (auto it = m_timepathWidgetMap->begin(); it != m_timepathWidgetMap->end(); ++it) {
const QString& widgetName = it.key();
CursorEditWidget* widget = it.value();
widget->setcustomicon(NULL);
if (m_timecustomiconpathmap->contains(widgetName)) {
const QString& filePath = m_timecustomiconpathmap->value(widgetName);
// 判断文件类型为svg才显示
QFileInfo fileInfo(filePath);
if (fileInfo.suffix().toLower() == "svg") {
widget->setcustomicon(filePath);
m_preview2->updateIcon(widgetName, filePath);
}
else {
// 如果文件类型不是svg直接跳过并不显示
continue;
}
}
}
}
}

View File

@ -2,6 +2,7 @@
#define CURSORTHEMEWIDGET_H
#include "cursorthemefeature.h"
#include "historywidget.h"
#include <QObject>
#include <QWidget>
@ -23,7 +24,10 @@ class CursorThemeWidget : public QWidget
Q_OBJECT
public:
explicit CursorThemeWidget(QWidget *parent = nullptr);
QMap<QString, QString>* getCursorMap();
QMap<QString, QString> *getTimeCursorMap();
void eidtInitWidget(const HistoryInfo &InfoData);
signals:
void wallpaperupdate(const QString& filePath);
void newCursorMap(QMap<QString, QString> *cursormap);
@ -34,6 +38,9 @@ private:
void initMaps();
void initTimeMaps();
void initRightWidget();
void setHistoryCursor(QString type);
void updateCustomPathMap(QMap<QString, QString>*historyMap,QString type);
void setHistoryTimeCursor();
QStringList getWidgetNamesFromFilesInDirectory(const QString& directoryPath);
QHBoxLayout *m_cursorthemelayout;
@ -41,15 +48,17 @@ private:
QVBoxLayout *m_rightwidgetlayout;
QMap<QString, CursorEditWidget*> *m_pathWidgetMap;
QMap<QString, CursorEditWidget*> *m_timepathWidgetMap;
QVBoxLayout *m_previewlayout;
QString m_coverfilepath = ":/resource/background/background-glazing.png";
QMap<QString, QString> *m_iconpathmap;
QMap<QString, QString> *m_historyiconpathmap;
QMap<QString, QString> *m_customiconpathmap;
QMap<QString, QString> *m_timeiconpathmap;
QMap<QString, QString> *m_historytimeiconpathmap;
QMap<QString, QString> *m_timecustomiconpathmap;
QWidget *m_previewwidget;
@ -57,7 +66,7 @@ private:
CursorImageWidget *m_preview2;
QWidget *m_editwidget;
HistoryInfo m_info;
};
#endif // CURSORTHEMEWIDGET_H