Fix inadvertent losses of custom icon positions due to config handling.

The configChanged() implementation could unnecessarily schedule a
reload due to a bug in a has-this-config-element-changed comparison,
which would result in icon position losses in scenarios such as
changing the wallpaper or the workspace theme, without having touched
any sorting-related options. Further, OK'ing the config dialog could
undo the unsorted state entered by moving an icon while the dialog
was open; this is now handled by updating the sorting mode combo box
in the dialog after the icon is dropped.

The later relies on a preceding fix in kde-workspace.git to make
Applet::isUserConfiguring() work for containments if Folder View is
used as desktop containment.
This commit is contained in:
Eike Hein 2013-04-15 16:20:03 +02:00
parent f979fab6c8
commit ac18ec1712

View file

@ -385,7 +385,6 @@ void FolderView::init()
m_alignToGrid = cg.readEntry("alignToGrid", false); m_alignToGrid = cg.readEntry("alignToGrid", false);
m_clickToView = cg.readEntry("clickForFolderPreviews", true); m_clickToView = cg.readEntry("clickForFolderPreviews", true);
m_previewPlugins = cg.readEntry("previewPlugins", QStringList() << "imagethumbnail" << "jpegthumbnail"); m_previewPlugins = cg.readEntry("previewPlugins", QStringList() << "imagethumbnail" << "jpegthumbnail");
m_customIconSize = cg.readEntry("customIconSize", 0);
m_sortDirsFirst = cg.readEntry("sortDirsFirst", true); m_sortDirsFirst = cg.readEntry("sortDirsFirst", true);
m_sortColumn = cg.readEntry("sortColumn", int(KDirModel::Name)); m_sortColumn = cg.readEntry("sortColumn", int(KDirModel::Name));
m_sortOrder = sortOrderStringToEnum(cg.readEntry("sortOrder", "ascending")); m_sortOrder = sortOrderStringToEnum(cg.readEntry("sortOrder", "ascending"));
@ -491,9 +490,8 @@ void FolderView::configChanged()
needReload = true; needReload = true;
} }
//Reload m_customIconSize values //Reload m_customIconSize values
const int size = m_customIconSize;
m_customIconSize = cg.readEntry("customIconSize", m_customIconSize); m_customIconSize = cg.readEntry("customIconSize", m_customIconSize);
if (size != iconSize().width()) { if (m_customIconSize != iconSize().width()) {
needReload = true; needReload = true;
} }
@ -1969,6 +1967,15 @@ void FolderView::indexesMoved(const QModelIndexList &indexes)
updateSortActionsState(); updateSortActionsState();
config().writeEntry("sortColumn", m_sortColumn); config().writeEntry("sortColumn", m_sortColumn);
emit configNeedsSaving(); emit configNeedsSaving();
if (isUserConfiguring()) {
for (int i = 0; i < uiDisplay.sortCombo->maxCount(); i++) {
if (m_sortColumn == uiDisplay.sortCombo->itemData(i).toInt()) {
uiDisplay.sortCombo->setCurrentIndex(i);
break;
}
}
}
} }
m_delayedSaveTimer.start(5000, this); m_delayedSaveTimer.start(5000, this);