From ac8722dc7d1a6b2f7669b270d65c3ed834582d7e Mon Sep 17 00:00:00 2001 From: Frank Reininghaus Date: Fri, 15 Nov 2013 09:16:22 +0100 Subject: [PATCH] Update the Places Panel entries when switching the language MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Before this commit, we stored the translated "Places" in .kde4/share/apps/kfileplaces/bookmarks.xml. This was not intentional - it only happened because PlacesItem::updateBookmarkForRole(const QByteArray& role) always stored the translated text (returned by PlacesItem::text()) in the KBookmark. This is be fixed by first checking if the text() is equal to the translation of the text that is already stored in the KBookmark, and not updating it in that case. Note that we have to make sure that all "Places"-related use the same context "KFile System Bookmarks" to make that work. Thanks to Burkhard Lück and Albert Astals Cid for helping to fix this problem! BUG: 319282 FIXED-IN: 4.12.0 REVIEW: 113850 --- src/panels/places/placesitem.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/panels/places/placesitem.cpp b/src/panels/places/placesitem.cpp index 76b51e3aa..41f22cce4 100644 --- a/src/panels/places/placesitem.cpp +++ b/src/panels/places/placesitem.cpp @@ -120,6 +120,10 @@ Solid::Device PlacesItem::device() const void PlacesItem::setBookmark(const KBookmark& bookmark) { + if (bookmark == m_bookmark) { + return; + } + m_bookmark = bookmark; delete m_access; @@ -302,7 +306,15 @@ void PlacesItem::updateBookmarkForRole(const QByteArray& role) if (role == "iconName") { m_bookmark.setIcon(icon()); } else if (role == "text") { - m_bookmark.setFullText(text()); + // Only store the text in the KBookmark if it is not the translation of + // the current text. This makes sure that the text is re-translated if + // the user chooses another language, or the translation itself changes. + // + // NOTE: It is important to use "KFile System Bookmarks" as context + // (see PlacesItemModel::createSystemBookmarks()). + if (text() != i18nc("KFile System Bookmarks", m_bookmark.text().toUtf8().data())) { + m_bookmark.setFullText(text()); + } } else if (role == "url") { m_bookmark.setUrl(url()); } else if (role == "udi)") { -- 2.47.3