!58 FIX History Layout Issues

Merge pull request !58 from likehomedream/fixhistory
This commit is contained in:
likehomedream 2023-11-24 01:28:53 +00:00 committed by Gitee
commit 5d7093cf35
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 10 additions and 11 deletions

View File

@ -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));

View File

@ -142,7 +142,7 @@ void HistoryWidget::updateHistoryDir()
QVBoxLayout *alllayout = qobject_cast<QVBoxLayout*>(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);

View File

@ -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;
}
}
}