Bug 234407

Summary: systemsettings iconview wordwrapping cause narrow icon in zhcn locale
Product: [Applications] systemsettings Reporter: pan shi zhu <pan.shizhu>
Component: iconviewAssignee: System Settings Bugs <sourtooth+ssbugs>
Status: RESOLVED FIXED    
Severity: normal CC: bbluldd, chaofeng111, jimhuyiwei, kde, nate, simonandric5, wengxt
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Ubuntu   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: For english text the iconview is good.
For Chinese text the iconview is too narrow and text may wrap to 3 lines.
the patch file
Screenshot on Plasma 5.4.0

Description pan shi zhu 2010-04-15 04:08:45 UTC
Version:            (using KDE 4.4.2)
OS:                Linux
Installed from:    Ubuntu Packages


KDE 4.4 sets wordwrap in systemsettings iconview.

The text under icon will be wrapped with the width of icon. This is no problem for latin texts, but for CJK text where all characters can wrap, it results in very narrow iconview.

KDE 4.3 has no such problem.
Comment 1 pan shi zhu 2010-04-15 04:10:43 UTC
Created attachment 42795 [details]
For english text the iconview is good.
Comment 2 pan shi zhu 2010-04-15 04:11:54 UTC
Created attachment 42796 [details]
For Chinese text the iconview is too narrow and text may wrap to 3 lines.
Comment 3 pan shi zhu 2010-04-15 04:13:17 UTC
This is the patch to solve this bug.


--- kdebase-workspace-4.4.2/systemsettings/icons/IconMode.cpp	2010-04-15 04:56:56.000000000 +0800
+++ kdebase-workspace-4.4.2/systemsettings/icons/IconMode.cpp	2010-04-15 05:18:11.000000000 +0800
@@ -177,7 +177,6 @@ void IconMode::initWidget()
         tv->setMouseTracking( true );
         tv->viewport()->setAttribute( Qt::WA_Hover );
         KFileItemDelegate *delegate = new KFileItemDelegate( tv );
-        delegate->setWrapMode( QTextOption::WordWrap );
         tv->setItemDelegate( delegate );
         tv->setFrameShape( QFrame::NoFrame );
         tv->setModel( proxyModel );
Comment 4 pan shi zhu 2010-04-15 04:15:53 UTC
Created attachment 42797 [details]
the patch file
Comment 5 pan shi zhu 2010-04-15 04:18:46 UTC
This patch rollback to KDE 4.3.

The better solution may be provide an option to set text width, or to set the default text width to something bigger than the icon width.

Hope someone can do that instead.
Comment 6 JimHu 2010-06-28 15:33:50 UTC
Totally agree with pan shi zhu.
Comment 7 bbloldd 2011-02-10 18:42:54 UTC
4.6.0 has the same problem.

A modified patch based on pan shi zhu's. 

Only set NoWrap for  CJK locale.

--- kdebase-workspace-4.6.0_orig/systemsettings/icons/IconMode.cpp  2011-01-20 06:04:38.000000000 +0800
+++ kdebase-workspace-4.6.0/systemsettings/icons/IconMode.cpp 2011-02-11 01:33:03.000000000 +0800
@@ -165,7 +165,12 @@
     d->categoryView->viewport()->setAttribute( Qt::WA_Hover );

     KFileItemDelegate *delegate = new KFileItemDelegate( d->categoryView );
-    delegate->setWrapMode( QTextOption::WordWrap );
+    QString curLang =  KGlobal::locale()->language ();
+    QString CJKLang ("zh_CN:zh_TW:ja:ko");
+    if( CJKLang.contains(curLang) )
+        delegate->setWrapMode( QTextOption::NoWrap );
+    else
+        delegate->setWrapMode( QTextOption::WordWrap );
     d->categoryView->setItemDelegate( delegate );

     d->categoryView->setFrameShape( QFrame::NoFrame );
Comment 8 Chao Feng 2013-01-12 04:36:58 UTC
The attempt  to apply bbloldd's patch is rejected. See https://git.reviewboard.kde.org/r/108285/. 

Another patch to set minimium width is still under evaluation but has its problems too. See https://git.reviewboard.kde.org/r/108328/.

New ideas from Thomas Lübking: 
Reimplemented ::paint() function of QItemDelegate, match the width of the remaining words against the textrect width, if it's "not much more" (tm), paint it ignoring clips, otherwise break at the flooring word, move to the next line and go on with the rest of the string.
Comment 9 Weng Xuetian 2015-09-15 01:57:12 UTC
Created attachment 94569 [details]
Screenshot on Plasma 5.4.0

I'd like to ping on this again, while it's already qt5/kf5 world. This problem isn't resolved yet and looks even worse (1 character wide if everything is translated).

So far, dolphin's view looks much better than systemsettings. Can't there be a reasonable size as a hint for systemsettings?
Comment 10 Shinjo Park 2020-05-05 12:24:23 UTC
Is this bug still relevant? At least for Korean locale, the text width in System Settings' icon view is adequate in Plasma 5.18.
Comment 11 Nate Graham 2020-05-05 13:43:30 UTC
Great, thanks for confirming!