fix: current index is incorrect when starting for the first time

Log: current index is incorrect when starting for the first time
Signed-off-by: zorowk <near.kingzero@gmail.com>
This commit is contained in:
zorowk 2024-01-12 15:54:55 +08:00 committed by 爱折腾的小竹同学
parent b9f922ff53
commit 5e739d6da5
2 changed files with 3 additions and 2 deletions

View File

@ -68,6 +68,7 @@ void QuickPersonalizationManagerPrivate::updateCacheWallpaperPath(uid_t uid)
QString cache_location = QStandardPaths::writableLocation(QStandardPaths::CacheLocation);
m_cacheDirectory = cache_location + QString("/wallpaper/%1/").arg(uid);
m_settingFile = m_cacheDirectory + "wallpaper.ini";
m_currentWallpaper = "/usr/share/wallpapers/deepin/desktop.jpg";
}
void QuickPersonalizationManagerPrivate::loadWallpaperSettings()

View File

@ -40,6 +40,7 @@ void WallpaperCardModel::setCurrentIndex(int index)
{
d->currentIndex = index;
Q_EMIT currentIndexChanged(d->currentIndex);
Q_EMIT layoutChanged();
}
int WallpaperCardModel::currentIndex() const {
@ -109,11 +110,10 @@ void WallpaperCardModel::append(const QString& path)
{
beginInsertRows(QModelIndex(), 0, 0);
d->wallpapers.push_front("file://" + path);
setCurrentIndex(0);
endInsertRows();
setCurrentIndex(0);
Q_EMIT dataCountChanged(d->wallpapers.length());
Q_EMIT layoutChanged();
}
void WallpaperCardModel::remove(int index)