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

Kurt V.Hindenburg kurt.hindenburg at kdemail.net
Sat Jun 18 15:14:30 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|NEW                         |RESOLVED
         Resolution|                            |FIXED



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

Allow saving/loading of Encoding in 'Save as Default'.
Will backport to 3.4

BUG: 107329


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


--- trunk/KDE/kdebase/konsole/konsole/konsole.cpp #426783:426784
 @ -1469,6 +1469,7  @
   config->writeEntry("TabColor", tabwidget->tabColor(se->widget()));
 
   if (se) {
+    config->writeEntry("EncodingName", se->encoding());
     config->writeEntry("history", se->history().getSize());
     config->writeEntry("historyenabled", b_histEnabled);
   }
 @ -1595,6 +1596,8  @
       b_autoResizeTabs = config->readBoolEntry("AutoResizeTabs", false);
       m_tabColor = config->readColorEntry("TabColor");
       if ( !m_tabColor.isValid() ) m_tabColor = QColor( Qt::black );
+
+      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();
 @ -2541,6 +2545,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)
 @ -2567,7 +2619,7  @
   if(!found)
      return;
 
-  session->setEncodingNo(i);
+  session->setEncodingNo( i + 1 );    // Take into account Default
   session->getEmulation()->setCodec(qtc);
   if (se == session)
      activateSession(se);
 @ -2820,6 +2872,8  @
   else
     s->setHistory(HistoryTypeNone());
 
+  setSessionEncoding( s_encodingName, s );
+
   addSession(s);
   runSession(s); // activate and run
   return sessionId;
--- trunk/KDE/kdebase/konsole/konsole/konsole.h #426783:426784
 @ -86,6 +86,7  @
   void setSchema(const QString & path);
   void setEncoding(int);
   void setSessionTitle(QString&, TESession* = 0);
+  void setSessionEncoding(const QString&, TESession* = 0);
 
   void enableFullScripting(bool b);
   void enableFixedSize(bool b);
 @ -294,6 +295,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