From d520ea427d283875dece50ae7a113a5446e09b73 Mon Sep 17 00:00:00 2001 From: likehomedream Date: Thu, 23 Nov 2023 14:14:08 +0800 Subject: [PATCH] FIX History Layout Issues --- src/mainwindow.cpp | 3 ++- src/module/historywidget.cpp | 2 +- src/module/iconwidgetfeature.cpp | 16 +++++++--------- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 309255d..a5563fd 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -95,7 +95,7 @@ void MainWindow::initUI() m_guideWidget->setLayout(labellayout); m_historywidget = new HistoryWidget(); - m_historywidget->setMinimumHeight(2000); +// m_historywidget->setMinimumHeight(2000); QDir builderDir = QDir::homePath()+"/.cache/theme-build/"; if(builderDir.isEmpty()){ alllayout->addStretch(1); @@ -201,6 +201,7 @@ void MainWindow::initUI() QFileSystemWatcher* watcher = new QFileSystemWatcher(this); watcher->addPath(builderDir.absolutePath()); connect(watcher, &QFileSystemWatcher::directoryChanged, this, [=](const QString& path) { + m_historywidget->updateHistoryDir(); if (builderDir.isEmpty()) { alllayout->removeWidget(m_guideWidget); alllayout->removeItem(alllayout->itemAt(alllayout->count()-1)); diff --git a/src/module/historywidget.cpp b/src/module/historywidget.cpp index 0cefc2e..980aec3 100644 --- a/src/module/historywidget.cpp +++ b/src/module/historywidget.cpp @@ -142,7 +142,7 @@ void HistoryWidget::updateHistoryDir() QVBoxLayout *alllayout = qobject_cast(this->layout()); if (alllayout) { // 删除原来的widget - while (QWidget* w = alllayout->takeAt(1)->widget()) { // 从索引1开始,因为索引0是textWidget + while (QWidget* w = alllayout->takeAt(0)->widget()) { // 从索引0开始,因删除了所有的widget delete w; } alllayout->addWidget(widget); diff --git a/src/module/iconwidgetfeature.cpp b/src/module/iconwidgetfeature.cpp index 6591c2a..963ee49 100644 --- a/src/module/iconwidgetfeature.cpp +++ b/src/module/iconwidgetfeature.cpp @@ -421,15 +421,13 @@ void ImageWidget::updateIcon(const QString& widgetName, const QString& newFilePa newPixmapItem->setData(1, newFilePath); // 设置新的位图的位置为旧位置 newPixmapItem->setPos(oldPosition); - } - }else { - qDebug() << "Failed to load image:" << newFilePath; - } - } else { - qDebug() << "Failed to load image:" << newFilePath; - } - return; - } + } + } else { + qDebug() << "Failed to load image:" << newFilePath; + } + return; + } + } }