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

Kurt V.Hindenburg kurt.hindenburg at kdemail.net
Sat Jun 18 15:32:28 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         




------- Additional Comments From kurt.hindenburg kdemail net  2005-06-18 17:32 -------
SVN commit 426796 by hindenburg:

Allow saving/loading of Encoding in 'Save as Default'.

CCBUG: 107329


 M  +55 -1     konsole.cpp  
 M  +2 -0      konsole.h  


--- branches/KDE/3.4/kdebase/konsole/konsole/konsole.cpp #426795:426796
 @ -1470,6 +1470,7  @
   config->writeEntry("AutoResizeTabs", b_autoResizeTabs);
 
   if (se) {
+    config->writeEntry("EncodingName", se->encoding());
     config->writeEntry("history", se->history().getSize());
     config->writeEntry("historyenabled", b_histEnabled);
   }
 @ -1595,6 +1596,8  @
       m_tabViewMode = TabViewModes(config->readNumEntry("TabViewMode", ShowIconAndText));
       b_dynamicTabHide = config->readBoolEntry("DynamicTabHide", false);
       b_autoResizeTabs = config->readBoolEntry("AutoResizeTabs", false);
+
+      s_encodingName = config->readEntry( "EncodingName", "" ).lower();
    }
 
    if (m_menuCreated)
 @ -1615,6 +1618,7  @
       showMenubar->setChecked(!menuBar()->isHidden());
       selectScrollbar->setCurrentItem(n_scroll);
       selectBell->setCurrentItem(n_bell);
+      selectSetEncoding->setCurrentItem( se->encodingNo() );
       updateRMBMenu();
    }
    updateKeytabMenu();
 @ -2575,6 +2579,54  @
   activateSession(oldSession);
 }
 
+// Set session encoding; don't use any menu items.
+// System's encoding list may change, so search for encoding string.
+// FIXME: A lot of duplicate code from slotSetSessionEncoding
+void Konsole::setSessionEncoding( const QString &encoding, TESession *session )
+{
+    if ( encoding.isEmpty() )
+        return;
+
+    if ( !session )
+        session = se;
+
+    // availableEncodingNames and descriptEncodingNames are NOT returned
+    // in the same order.
+    QStringList items = KGlobal::charsets()->descriptiveEncodingNames();
+    QString enc;
+
+    // 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)
+    {
+        if ( (*it).find( t_enc ) != -1 )
+        {
+            enc = *it;
+            break;
+        }
+    }
+    if (i >= items.count())
+        return;
+
+    bool found = false;
+    enc = KGlobal::charsets()->encodingForName(enc);
+    QTextCodec * qtc = KGlobal::charsets()->codecForName(enc, found);
+
+    //kdDebug()<<"setSessionEncoding="<<enc<<"; "<<i<<"; found="<<found<<endl;
+    if ( !found )
+        return;
+
+    session->setEncodingNo( i + 1 );    // Take into account Default
+    session->getEmulation()->setCodec(qtc);
+    if (se == session)
+        activateSession(se);
+
+}
+
 void Konsole::slotSetSessionEncoding(TESession *session, const QString &encoding)
 {
   if (!selectSetEncoding)
 @ -2601,7 +2653,7  @
   if(!found)
      return;
 
-  session->setEncodingNo(i);
+  session->setEncodingNo( i + 1 );    // Take into account Default
   session->getEmulation()->setCodec(qtc);
   if (se == session)
      activateSession(se);
 @ -2855,6 +2907,8  @
   else
     s->setHistory(HistoryTypeNone());
 
+  setSessionEncoding( s_encodingName, s );
+
   addSession(s);
   runSession(s); // activate and run
   return sessionId;
--- branches/KDE/3.4/kdebase/konsole/konsole/konsole.h #426795:426796
 @ -83,6 +83,7  @
   void newSession(const QString &program, const QStrList &args, const QString &term, const QString &icon, const QString &title, const QString &cwd);
   void setSchema(const QString & path);
   void setEncoding(int);
+  void setSessionEncoding(const QString&, TESession* = 0);
 
   void enableFullScripting(bool b);
   void enableFixedSize(bool b);
 @ -289,6 +290,7  @
   TESession*     se_previous;
   TESession*     m_initialSession;
   ColorSchemaList* colors;
+  QString        s_encodingName;
 
   QPtrDict<KRootPixmap> rootxpms;
   KWinModule*    kWinModule;



More information about the konsole-devel mailing list