[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-core-devel
Subject: Re: PATCH: cleanup in konsolepart, caption stuff
From: David Faure <david () mandrakesoft ! com>
Date: 2002-03-19 16:00:53
[Download RAW message or body]
On Tuesday 19 March 2002 15:39, Stephan Binner wrote:
> On Tuesday 19 March 2002 13:50, David Faure wrote:
>
> > The attached patch fixes the signal/slot connect warnings when using
> > konsolepart, finally fixing the small design flaw that TESession had
> > to know about a KMainWindow. [..] Ok to commit?
>
> Look OK, but there is one "kdDebug()" and you don't need/have to connect
>
> + void clearAllListenToKeyPress();
> + void restoreAllListenToKeyPress();
>
> in konsole_part. 1st is waste, 2nd afaik too as konsole_part doesn't DCOP.
Hmm, indeed it doesn't, but I see now what that stuff is for...
sendSession() is exactly what we need to issue that "cd" command,
instead of the current fake-QKeyEvent hack in konsolePart::openURL().
What about this then?
I left the clear/restore above because they are used now ;), and because
one could write a dcop interface to konsolepart in the future ;-)
--
David FAURE, david@mandrakesoft.com, faure@kde.org
http://people.mandrakesoft.com/~david/, http://www.konqueror.org/
KDE, Making The Future of Computing Available Today
["konsole.diff" (text/x-diff)]
Index: konsole.cpp
===================================================================
RCS file: /home/kde/kdebase/konsole/konsole/konsole.cpp,v
retrieving revision 1.257
diff -u -p -b -r1.257 konsole.cpp
--- konsole.cpp 2002/03/02 14:23:49 1.257
+++ konsole.cpp 2002/03/19 15:59:49
@@ -1589,7 +1589,8 @@ QString Konsole::newSession(KSimpleConfi
int schmno = schema->numb();
QString sessionId="session-"+QString::number(++sessionIdCounter);
- TESession* s = new TESession(this,te, \
QFile::encodeName(program),cmdArgs,emu,sessionId,cwd); + TESession* s = new \
TESession(te, QFile::encodeName(program),cmdArgs,emu,sessionId,cwd); + // If you add \
any new signal-slot connection below, think about doing it in konsolePart too \
connect( s,SIGNAL(done(TESession*,int)), this,SLOT(doneSession(TESession*,int)) );
connect( te, SIGNAL(configureRequest(TEWidget*, int, int, int)),
@@ -1598,6 +1599,16 @@ QString Konsole::newSession(KSimpleConfi
this, SLOT( updateTitle() ) );
connect( s, SIGNAL( notifySessionState(TESession*, int) ),
this, SLOT( notifySessionState(TESession*, int)) );
+ connect( s, SIGNAL(clearAllListenToKeyPress()),
+ this, SLOT(clearAllListenToKeyPress()) );
+ connect( s, SIGNAL(restoreAllListenToKeyPress()),
+ this, SLOT(restoreAllListenToKeyPress()) );
+ connect( s, SIGNAL(renameSession(TESession*,const QString&)),
+ this, SLOT(slotRenameSession(TESession*, const QString&)) );
+ connect( s->getEmulation(), SIGNAL(changeColumns(int)),
+ this, SLOT(changeColumns(int)) );
+ connect( s->getEmulation(), SIGNAL(ImageSizeChanged(int,int)),
+ this, SLOT(notifySize(int,int)));
s->setFontNo(QMIN(fno, TOPFONT));
s->setSchemaNo(schmno);
Index: konsole_part.cpp
===================================================================
RCS file: /home/kde/kdebase/konsole/konsole/konsole_part.cpp,v
retrieving revision 1.45
diff -u -p -b -r1.45 konsole_part.cpp
--- konsole_part.cpp 2002/02/09 21:22:36 1.45
+++ konsole_part.cpp 2002/03/19 15:59:50
@@ -49,7 +49,6 @@ extern "C"
*/
void *init_libkonsolepart()
{
- kdDebug(1211) << "Konsole in actions!!!" << endl;
return new konsoleFactory;
}
};
@@ -152,7 +151,7 @@ konsolePart::konsolePart(QWidget *_paren
setInstance(konsoleFactory::instance());
// This is needed since only konsole.cpp does it
- // Without those two -> crash on keypress... (David)
+ // Without this -> crash on keypress... (David)
KeyTrans::loadAll();
QStrList eargs;
@@ -164,12 +163,22 @@ konsolePart::konsolePart(QWidget *_paren
te->setMinimumSize(150,70); // allow resizing, cause resize in TEWidget
setWidget(te);
- // faking a KMainwindow - TESession assumes that (wrong design!)
- se = new TESession((KMainWindow*)parentWidget,te,shell,eargs,"xterm");
+ se = new TESession(te,shell,eargs,"xterm");
connect( se,SIGNAL(done(TESession*,int)),
this,SLOT(doneSession(TESession*,int)) );
connect( te,SIGNAL(configureRequest(TEWidget*,int,int,int)),
this,SLOT(configureRequest(TEWidget*,int,int,int)) );
+ connect( se, SIGNAL( updateTitle() ),
+ this, SLOT( updateTitle() ) );
+ connect( se, SIGNAL(clearAllListenToKeyPress()),
+ this, SLOT(clearAllListenToKeyPress()) );
+ connect( se, SIGNAL(restoreAllListenToKeyPress()),
+ this, SLOT(restoreAllListenToKeyPress()) );
+ // We ignore the following signals
+ //connect( se, SIGNAL(renameSession(TESession*,const QString&)),
+ // this, SLOT(slotRenameSession(TESession*, const QString&)) );
+ //connect( se->getEmulation(), SIGNAL(changeColumns(int)),
+ // this, SLOT(changeColumns(int)) );
se->setConnect(TRUE);
te->currentSession = se;
@@ -256,6 +265,7 @@ konsolePart::~konsolePart()
bool konsolePart::openURL( const KURL & url )
{
+ //kdDebug(1211) << "konsolePart::openURL " << url.prettyURL() << endl;
m_url = url;
emit setWindowCaption( url.prettyURL() );
kdDebug(1211) << "Set Window Caption to " << url.prettyURL() << "\n";
@@ -266,9 +276,8 @@ bool konsolePart::openURL( const KURL &
stat( QFile::encodeName( url.path() ), &buff );
QString text = ( S_ISDIR( buff.st_mode ) ? url.path() : url.directory() );
KRun::shellQuote(text);
- text = QString::fromLatin1("cd ") + text + '\n';
- QKeyEvent e(QEvent::KeyPress, 0,-1,0, text);
- se->getEmulation()->onKeyPress(&e);
+ text = QString::fromLatin1("cd ") + text;
+ se->sendSession( text );
}
emit completed();
@@ -744,6 +753,26 @@ void konsolePart::slotWordSeps() {
s_word_seps = dlg.text();
te->setWordCharacters(s_word_seps);
}
+}
+
+void konsolePart::clearAllListenToKeyPress()
+{
+ se->setListenToKeyPress(false);
+}
+
+void konsolePart::restoreAllListenToKeyPress()
+{
+ se->setListenToKeyPress(true);
+}
+
+void konsolePart::updateTitle()
+{
+ emit setWindowCaption( se->fullTitle() );
+}
+
+void konsolePart::guiActivateEvent( KParts::GUIActivateEvent * )
+{
+ // Don't let ReadOnlyPart::guiActivateEvent reset the window caption
}
//////////////////////////////////////////////////////////////////////
Index: konsole_part.h
===================================================================
RCS file: /home/kde/kdebase/konsole/konsole/konsole_part.h,v
retrieving revision 1.10
diff -u -p -b -r1.10 konsole_part.h
--- konsole_part.h 2001/11/28 01:55:28 1.10
+++ konsole_part.h 2002/03/19 15:59:50
@@ -37,6 +37,7 @@
#include "session.h"
class KInstance;
+namespace KParts { class GUIActivateEvent; }
class konsoleFactory : public KParts::Factory
{
@@ -70,11 +71,15 @@ class konsolePart: public KParts::ReadOn
virtual bool openURL( const KURL & url );
virtual bool openFile() {return false;} // never used
virtual bool closeURL() {return true;}
+ virtual void guiActivateEvent( KParts::GUIActivateEvent * event );
protected slots:
void doneSession(TESession*,int);
void sessionDestroyed();
void configureRequest(TEWidget*,int,int x,int y);
+ void updateTitle();
+ void clearAllListenToKeyPress();
+ void restoreAllListenToKeyPress();
private slots:
void readProperties();
Index: session.cpp
===================================================================
RCS file: /home/kde/kdebase/konsole/konsole/session.cpp,v
retrieving revision 1.58
diff -u -p -b -r1.58 session.cpp
--- session.cpp 2002/02/11 05:39:09 1.58
+++ session.cpp 2002/03/19 15:59:50
@@ -22,7 +22,7 @@
of the abilities of the framework - multible sessions.
*/
-TESession::TESession(KMainWindow* main, TEWidget* _te, const QString &_pgm, QStrList \
& _args, const QString &_term,const QString &_sessionId, const QString &_cwd) \
+TESession::TESession(TEWidget* _te, const QString &_pgm, QStrList & _args, const \
QString &_term,const QString &_sessionId, const QString &_cwd) : DCOPObject( \
_sessionId.latin1() ) , monitorActivity(false)
, monitorSilence(false)
@@ -49,17 +49,7 @@ TESession::TESession(KMainWindow* main,
//kdDebug(1211)<<"TESession ctor() connecting"<<endl;
connect( sh,SIGNAL(block_in(const char*,int)),em,SLOT(onRcvBlock(const char*,int)) \
); connect( em,SIGNAL(ImageSizeChanged(int,int)),sh,SLOT(setSize(int,int)));
-
- // 'main' should do those connects itself, somehow.
- // These aren't KTMW's slots, but konsole's.(David)
-
- connect( em,SIGNAL(ImageSizeChanged(int,int)),main,SLOT(notifySize(int,int)));
connect( em,SIGNAL(sndBlock(const char*,int)),sh,SLOT(send_bytes(const char*,int)) \
);
- connect( em,SIGNAL(changeColumns(int)),main,SLOT(changeColumns(int)) );
-
- connect( this, SIGNAL(clearAllListenToKeyPress()),main,SLOT(clearAllListenToKeyPress()) \
);
- connect( this, SIGNAL(restoreAllListenToKeyPress()),main,SLOT(restoreAllListenToKeyPress()) \
);
- connect( this, SIGNAL(renameSession(TESession*,const \
QString&)),main,SLOT(slotRenameSession(TESession*, const QString&)) );
connect( em, SIGNAL( changeTitle( int, const QString & ) ),
this, SLOT( setUserTitle( int, const QString & ) ) );
Index: session.h
===================================================================
RCS file: /home/kde/kdebase/konsole/konsole/session.h,v
retrieving revision 1.31
diff -u -p -b -r1.31 session.h
--- session.h 2002/02/11 05:39:09 1.31
+++ session.h 2002/03/19 15:59:50
@@ -28,7 +28,7 @@ class TESession : public QObject, virtua
public:
- TESession(KMainWindow* main, TEWidget* w,
+ TESession(TEWidget* w,
const QString &pgm, QStrList & _args,
const QString &term, const QString &sessionId="session-1",
const QString &cwd = QString::null);
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic