Browse Source

Fixed some session's dcop calls in konsolepart. This relates to bug 2537.

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
pull/38/head
Michele Calgaro 1 month ago
parent
commit
1663e522eb
Signed by: Michele Calgaro <michele.calgaro@yahoo.it> GPG Key ID: 2A75B7CA8ADED5CF

+ 4
- 2
konsole/konsole/TECommon.h View File

@@ -149,8 +149,10 @@ inline bool operator != (cacol a, cacol b)
149 149
 inline const TQColor color256(UINT8 u, const ColorEntry* base)
150 150
 {
151 151
   //   0.. 16: system colors
152
-  if (u <   8) return base[u+2            ].color; u -= 8;
153
-  if (u <   8) return base[u+2+BASE_COLORS].color; u -= 8;
152
+  if (u <   8) return base[u+2            ].color;
153
+  u -= 8;
154
+  if (u <   8) return base[u+2+BASE_COLORS].color;
155
+  u -= 8;
154 156
 
155 157
   //  16..231: 6x6x6 rgb color cube
156 158
   if (u < 216) return TQColor(255*((u/36)%6)/5,

+ 81
- 8
konsole/konsole/konsole_part.cpp View File

@@ -78,10 +78,18 @@ konsoleFactory::~konsoleFactory()
78 78
 
79 79
 KParts::Part *konsoleFactory::createPartObject(TQWidget *parentWidget, const char *widgetName,
80 80
                                          TQObject *parent, const char *name, const char *classname,
81
-                                         const TQStringList&)
81
+                                         const TQStringList &args)
82 82
 {
83 83
 //  kdDebug(1211) << "konsoleFactory::createPart parentWidget=" << parentWidget << " parent=" << parent << endl;
84
-  KParts::Part *obj = new konsolePart(parentWidget, widgetName, parent, name, classname);
84
+  KParts::Part *obj;
85
+  if (args.count() > 0)
86
+  {
87
+    obj = new konsolePart(parentWidget, widgetName, parent, name, classname, args[0]);
88
+  }
89
+  else
90
+  {
91
+    obj = new konsolePart(parentWidget, widgetName, parent, name, classname);
92
+  }
85 93
   return obj;
86 94
 }
87 95
 
@@ -97,7 +105,8 @@ TDEInstance *konsoleFactory::instance()
97 105
 
98 106
 #define DEFAULT_HISTORY_SIZE 1000
99 107
 
100
-konsolePart::konsolePart(TQWidget *_parentWidget, const char *widgetName, TQObject *parent, const char *name, const char *classname)
108
+konsolePart::konsolePart(TQWidget *_parentWidget, const char *widgetName, TQObject *parent, const char *name,
109
+       const char *classname, const TQString &title)
101 110
   : KParts::ReadOnlyPart(parent, name)
102 111
 ,te(0)
103 112
 ,se(0)
@@ -115,6 +124,7 @@ konsolePart::konsolePart(TQWidget *_parentWidget, const char *widgetName, TQObje
115 124
 ,m_signals(0)
116 125
 ,m_options(0)
117 126
 ,m_popupMenu(0)
127
+,s_title(title)
118 128
 ,b_useKonsoleSettings(false)
119 129
 ,b_autoDestroy(true)
120 130
 ,b_autoStartShell(true)
@@ -899,19 +909,24 @@ void konsolePart::slotSelectBell() {
899 909
 
900 910
 void konsolePart::slotSetEncoding()
901 911
 {
912
+  setEncoding(selectSetEncoding->currentText());
913
+  n_encoding = selectSetEncoding->currentItem();
914
+  se->setEncodingNo(selectSetEncoding->currentItem());
915
+}
916
+
917
+void konsolePart::setEncoding(const TQString &encoding)
918
+{
902 919
   if (!se) return;
903 920
 
904 921
   bool found;
905
-  TQString enc = TDEGlobal::charsets()->encodingForName(selectSetEncoding->currentText());
922
+  TQString enc = TDEGlobal::charsets()->encodingForName(encoding);
906 923
   TQTextCodec * qtc = TDEGlobal::charsets()->codecForName(enc, found);
907 924
   if(!found)
908 925
   {
909
-    kdDebug() << "Codec " << selectSetEncoding->currentText() << " not found!" << endl;
926
+    kdDebug() << "Codec " << encoding << " not found!" << endl;
910 927
     qtc = TQTextCodec::codecForLocale();
911 928
   }
912 929
 
913
-  n_encoding = selectSetEncoding->currentItem();
914
-  se->setEncodingNo(selectSetEncoding->currentItem());
915 930
   se->getEmulation()->setCodec(qtc);
916 931
 }
917 932
 
@@ -1105,7 +1120,14 @@ bool konsolePart::setPtyFd( int master_pty )
1105 1120
 void konsolePart::newSession()
1106 1121
 {
1107 1122
   if ( se ) delete se;
1108
-  se = new TESession(te, "xterm", parentWidget->winId());
1123
+  if (!s_title.isEmpty())
1124
+  {
1125
+    se = new TESession(te, "xterm", parentWidget->winId(), s_title);
1126
+  }
1127
+  else
1128
+  {
1129
+    se = new TESession(te, "xterm", parentWidget->winId());
1130
+  }
1109 1131
   connect( se,TQT_SIGNAL(done(TESession*)),
1110 1132
            this,TQT_SLOT(doneSession(TESession*)) );
1111 1133
   connect( se,TQT_SIGNAL(openURLRequest(const TQString &)),
@@ -1120,6 +1142,14 @@ void konsolePart::newSession()
1120 1142
            this, TQT_SIGNAL( receivedData( const TQString& ) ) );
1121 1143
   connect( se, TQT_SIGNAL( forkedChild() ),
1122 1144
            this, TQT_SIGNAL( forkedChild() ));
1145
+  connect( se, TQT_SIGNAL(getSessionSchema(TESession*, TQString &)),
1146
+           this, TQT_SLOT(slotGetSessionSchema(TESession*, TQString &)));
1147
+  connect( se, TQT_SIGNAL(setSessionSchema(TESession*, const TQString &)),
1148
+           this, TQT_SLOT(slotSetSessionSchema(TESession*, const TQString &)));
1149
+  connect( se, TQT_SIGNAL(setSessionEncoding(TESession*, const TQString &)),
1150
+           this, TQT_SLOT(slotSetSessionEncoding(TESession*, const TQString &)));
1151
+  connect( se, TQT_SIGNAL(updateSessionKeytab(TESession *, const TQString &)),
1152
+           this, TQT_SLOT(slotUpdateSessionKeytab(TESession *, const TQString &)));
1123 1153
 
1124 1154
   // We ignore the following signals
1125 1155
   //connect( se, TQT_SIGNAL(renameSession(TESession*,const TQString&)),
@@ -1168,4 +1198,47 @@ void konsolePart::sendInput( const TQString& text )
1168 1198
     te->emitText( text );
1169 1199
 }
1170 1200
 
1201
+void konsolePart::slotGetSessionSchema(TESession *session, TQString &schema)
1202
+{
1203
+  int no = session->schemaNo();
1204
+  ColorSchema* s = colors->find( no );
1205
+  schema = s->relPath();
1206
+}
1207
+
1208
+void konsolePart::slotSetSessionSchema(TESession *session, const TQString &schema)
1209
+{
1210
+  ColorSchema* s = colors->find( schema );
1211
+  setSchema(s);
1212
+}
1213
+
1214
+void konsolePart::slotSetSessionEncoding(TESession *session, const TQString &encoding)
1215
+{
1216
+  setEncoding(encoding);
1217
+  const TQStringList &items = selectSetEncoding->items();
1218
+  int index = items.findIndex(encoding);
1219
+  if (index < 0)
1220
+  {
1221
+    TQString descriptiveEncoding = TDEGlobal::charsets()->descriptiveNameForEncoding(encoding.lower());
1222
+    if (!descriptiveEncoding.isEmpty())
1223
+    {
1224
+      index = items.findIndex(descriptiveEncoding);
1225
+    }
1226
+   if (index < 0)
1227
+   {
1228
+      if (encoding == TQTextCodec::codecForLocale()->name())
1229
+      {
1230
+        index = 0;
1231
+      }
1232
+    }
1233
+  }
1234
+  selectSetEncoding->setCurrentItem(index);
1235
+  n_encoding = index;
1236
+  se->setEncodingNo(index);
1237
+}
1238
+
1239
+void konsolePart::slotUpdateSessionKeytab(TESession *, const TQString &)
1240
+{
1241
+	updateKeytabMenu();
1242
+}
1243
+
1171 1244
 #include "konsole_part.moc"

+ 9
- 2
konsole/konsole/konsole_part.h View File

@@ -70,7 +70,8 @@ class konsolePart: public KParts::ReadOnlyPart, public TerminalInterface, public
70 70
 {
71 71
     Q_OBJECT
72 72
 	public:
73
-    konsolePart(TQWidget *parentWidget, const char *widgetName, TQObject * parent, const char *name, const char *classname = 0);
73
+    konsolePart(TQWidget *parentWidget, const char *widgetName, TQObject * parent, const char *name,
74
+                const char *classname = 0, const TQString &title = TQString::null);
74 75
     virtual ~konsolePart();
75 76
 
76 77
 signals:
@@ -122,6 +123,10 @@ signals:
122 123
     void slotUseKonsoleSettings();
123 124
     void slotWordSeps();
124 125
     void slotSetEncoding();
126
+    void slotGetSessionSchema(TESession *session, TQString &schema);
127
+    void slotSetSessionSchema(TESession *session, const TQString &schema);
128
+    void slotSetSessionEncoding(TESession *session, const TQString &encoding);
129
+    void slotUpdateSessionKeytab(TESession *session, const TQString &keytab);
125 130
     void biggerFont();
126 131
     void smallerFont();
127 132
 
@@ -136,6 +141,7 @@ signals:
136 141
 
137 142
     void setSchema(ColorSchema* s);
138 143
     void updateKeytabMenu();
144
+    void setEncoding(const TQString &encoding);
139 145
 
140 146
 	  bool doOpenStream( const TQString& );
141 147
   	bool doWriteStream( const TQByteArray& );
@@ -170,7 +176,8 @@ signals:
170 176
 
171 177
     TQFont       defaultFont;
172 178
 
173
-    TQString     pmPath; // pixmap path
179
+    TQString     pmPath;  // pixmap path
180
+    TQString     s_title; // session title
174 181
     TQString     s_schema;
175 182
     TQString     s_tdeconfigSchema;
176 183
     TQString     s_word_seps;			// characters that are considered part of a word

+ 1
- 0
konsole/konsole/session.cpp View File

@@ -825,6 +825,7 @@ TQString TESession::keytab()
825 825
 void TESession::setKeytab(const TQString &keytab)
826 826
 {
827 827
    setKeymap(keytab);
828
+   emit updateSessionKeytab(this, keytab);
828 829
    emit updateSessionConfig(this);
829 830
 }
830 831
 

+ 1
- 0
konsole/konsole/session.h View File

@@ -166,6 +166,7 @@ signals:
166 166
   void setSessionEncoding(TESession *session, const TQString &encoding);
167 167
   void getSessionSchema(TESession *session, TQString &schema);
168 168
   void setSessionSchema(TESession *session, const TQString &schema);
169
+  void updateSessionKeytab(TESession *session, const TQString &keytab);
169 170
 
170 171
 private slots:
171 172
   void onRcvBlock( const char* buf, int len );

Loading…
Cancel
Save