[Konsole-devel] [Bug 107329] Konsole doesn't save Encoding setting

Kurt V.Hindenburg kurt.hindenburg at kdemail.net
Sun Nov 13 09:47:56 UTC 2005


------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
         
http://bugs.kde.org/show_bug.cgi?id=107329         
kurt.hindenburg kdemail net changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|                            |FIXED



------- Additional Comments From kurt.hindenburg kdemail net  2005-11-13 10:47 -------
SVN commit 480099 by hindenburg:

The saving and loading of the Encoding should (finally) be fixed now.  This should be in KDE 3.5rc2 (I hope).

BUG: 107329


 M  +27 -27    konsole.cpp  


--- branches/KDE/3.5/kdebase/konsole/konsole/konsole.cpp #480098:480099
 @ -634,6 +634,8  @
       list.prepend( i18n( "Default" ) );
 
       // BR114535 : Remove jis7 due to infinite loop.
+      // If you fix this issue and remove the line below,  remember to 
+      // remove the line in setSessionEncoding() (search for jis7).
       list.remove( i18n( "Japanese ( jis7 )" ) );
       selectSetEncoding->setItems(list);
       selectSetEncoding->setCurrentItem (0);
 @ -1485,8 +1487,15  @
   config->writeEntry("DynamicTabHide", b_dynamicTabHide);
   config->writeEntry("AutoResizeTabs", b_autoResizeTabs);
 
+  if (selectSetEncoding)
+  {
+    QString encoding = KGlobal::charsets()->encodingForName(selectSetEncoding->currentText());
+    config->writeEntry("EncodingName", encoding);
+  } else {    // This will not always work (ie 'winsami' saves as 'ws2')
+    if (se) config->writeEntry("EncodingName", se->encoding());
+  }
+
   if (se) {
-    config->writeEntry("EncodingName", se->encoding());
     config->writeEntry("history", se->history().getSize());
     config->writeEntry("historyenabled", b_histEnabled);
   }
 @ -2604,37 +2613,28  @
     if ( !session )
         session = se;
 
-    // availableEncodingNames and descriptEncodingNames are NOT returned
-    // in the same order.
-    QStringList items = KGlobal::charsets()->descriptiveEncodingNames();
-    QString enc;
+    bool found = false;
+    QString enc = KGlobal::charsets()->encodingForName(encoding);
+    QTextCodec * qtc = KGlobal::charsets()->codecForName(enc, found);
+    if ( !found || !qtc )
+        return;
 
-    // For purposes of using 'find' add a space after name,
-    // otherwise 'iso 8859-1' will find 'iso 8859-13'
-    QString t_enc = encoding + " ";
-    unsigned int i = 0;
-
-    for( QStringList::ConstIterator it = items.begin(); it != items.end();
-         ++it, ++i)
+    // Encoding was found; now try to figure out which Encoding menu item
+    // it corresponds to.
+    int i = 0;
+    QStringList encodingNames = KGlobal::charsets()->descriptiveEncodingNames();
+    QStringList::Iterator it = encodingNames.begin();
+    while ( it != encodingNames.end() && 
+            KGlobal::charsets()->encodingForName(*it) != encoding )
     {
-        if ( (*it).find( t_enc ) != -1 )
-        {
-            enc = *it;
-            break;
-        }
+      i++; it++;
     }
-    if (i >= items.count())
-        return;
 
-    bool found = false;
-    enc = KGlobal::charsets()->encodingForName(enc);
-    QTextCodec * qtc = KGlobal::charsets()->codecForName(enc, found);
+    i++;                 // Take into account the first entry: Default
+    if ( i > 24 ) i--;   // Handle the removed jis7 entry
+    //kdDebug()<<"setSessionEncoding="<<encoding<<"; "<<i<<endl;
 
-    //kdDebug()<<"setSessionEncoding="<<enc<<"; "<<i<<"; found="<<found<<endl;
-    if ( !found )
-        return;
-
-    session->setEncodingNo( i + 1 );    // Take into account Default
+    session->setEncodingNo( i );
     session->getEmulation()->setCodec(qtc);
     if (se == session)
         activateSession(se);



More information about the konsole-devel mailing list