[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-core-devel
Subject: PATCH: cleanup in konsolepart, caption stuff
From: David Faure <david () mandrakesoft ! com>
Date: 2002-03-19 12:50:48
[Download RAW message or body]
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.
It also fixes caption stuff, emitting the current dir as caption, and preventing
KParts::ReadOnlyPart from overwriting this caption in guiActivateEvent.
Quite straightforward IMHO.
Ok to commit?
--
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/konsole.cpp
===================================================================
RCS file: /home/kde/kdebase/konsole/konsole/konsole.cpp,v
retrieving revision 1.257
diff -u -p -r1.257 konsole.cpp
--- konsole/konsole.cpp 2002/03/02 14:23:49 1.257
+++ konsole/konsole.cpp 2002/03/19 12:41:24
@@ -146,7 +146,7 @@ template class QPtrDict<KRadioAction>;
const char *fonts[] = {
- "13",
+ "13",
"7", // tiny font, never used
"10", // small font
"13", // medium
@@ -280,7 +280,7 @@ DCOPObject( "konsole" )
toolBar()->hide();
toolBar()->setText(i18n("Session Toolbar"));
if (!frameon) {
- b_framevis=false;
+ b_framevis=false;
te->setFrameStyle( QFrame::NoFrame );
}
if (!scrollbaron) {
@@ -528,10 +528,10 @@ void Konsole::makeGUI()
save_settings->plug(m_options);
m_options->insertSeparator();
-
+
KAction *configure = KStdAction::preferences(this, SLOT(slotConfigure()), \
actions); configure->plug(m_options);
-
+
m_options->insertTearOffHandle();
connect(m_options, SIGNAL(activated(int)), SLOT(opt_menu_activated(int)));
@@ -670,7 +670,7 @@ bool Konsole::queryClose()
"Are you sure you want to quit?" ),
i18n("Are you sure you want to quit?"),
i18n("Quit"), i18n("Cancel") )
-
+
== KMessageBox::No )
) {
return false;
@@ -826,7 +826,7 @@ void Konsole::readProperties(KConfig* co
// If --type option was given, load the corresponding schema instead of
// default
//
-// When globalConfigOnly is true only the options that are shared among all
+// When globalConfigOnly is true only the options that are shared among all
// konsoles are being read.
void Konsole::readProperties(KConfig* config, const QString &schema, bool \
globalConfigOnly) {
@@ -987,7 +987,7 @@ void Konsole::slotSelectFont() {
assert(se);
int item = selectFont->currentItem();
// KONSOLEDEBUG << "slotSelectFont " << item << endl;
- if (item == DEFAULTFONT)
+ if (item == DEFAULTFONT)
{
if ( KFontDialog::getFont(defaultFont, true) == QDialog::Rejected )
{
@@ -1263,7 +1263,7 @@ void Konsole::clearAllListenToKeyPress()
for (TESession *ses = sessions.first(); ses; ses = sessions.next())
ses->setListenToKeyPress(false);
}
-
+
void Konsole::restoreAllListenToKeyPress()
{
if(se->isMasterMode())
@@ -1357,7 +1357,7 @@ void Konsole::addSession(TESession* s)
ra->plug(m_view);
int button_id=ra->itemId( ra->plug(toolBar()) );
- KToolBarButton* ktb=toolBar()->getButton(button_id);
+ KToolBarButton* ktb=toolBar()->getButton(button_id);
connect(ktb,SIGNAL(doubleClicked(int)), this,SLOT(slotRenameSession(int)));
session2button.insert(s,ktb);
}
@@ -1371,7 +1371,7 @@ QString Konsole::sessionId(const int pos
{
if (position<=0 || position>sessions.count())
return "";
-
+
return sessions.at(position-1)->SessionId();
}
@@ -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);
@@ -1869,7 +1880,7 @@ void Konsole::addSessionCommand(const QS
if (typ.isEmpty() || txt.isEmpty() || typ != "KonsoleApplication")
{
if (!path.isEmpty())
- delete co;
+ delete co;
return; // ignore
}
QString icon = co->readEntry("Icon", "openterm");
@@ -2229,7 +2240,7 @@ void Konsole::slotFind()
}
}
else
- KMessageBox::information( this,
+ KMessageBox::information( this,
i18n( "Search string '%1' not found." \
).arg(KStringHandler::csqueeze(m_find_pattern)), i18n( "Find" ) );
}
@@ -2358,7 +2369,7 @@ void Konsole::currentDesktopChanged(int
//Get window info
NETWinInfo info( qt_xdisplay(), winId(), qt_xrootwin(), NET::WMDesktop );
bool bNeedUpdate = false;
-
+
if( info.desktop()==NETWinInfo::OnAllDesktops ) {
//This is a sticky window so it will always need updating
bNeedUpdate = true;
@@ -2373,7 +2384,7 @@ void Konsole::currentDesktopChanged(int
//Check to see if we are transparent too
ColorSchema* s = colors->find(curr_schema);
- if (s==0)
+ if (s==0)
return;
//This window is transparent, update the root pixmap
Index: konsole/konsole_part.cpp
===================================================================
RCS file: /home/kde/kdebase/konsole/konsole/konsole_part.cpp,v
retrieving revision 1.45
diff -u -p -r1.45 konsole_part.cpp
--- konsole/konsole_part.cpp 2002/02/09 21:22:36 1.45
+++ konsole/konsole_part.cpp 2002/03/19 12:41:24
@@ -27,7 +27,7 @@
#include <qfile.h>
#include <qlayout.h>
-#include <qwmatrix.h>
+#include <qwmatrix.h>
#include <kaboutdata.h>
#include <kdebug.h>
@@ -49,7 +49,6 @@ extern "C"
*/
void *init_libkonsolepart()
{
- kdDebug(1211) << "Konsole in actions!!!" << endl;
return new konsoleFactory;
}
};
@@ -125,7 +124,7 @@ void KonsoleFontSelectAction::slotActiva
//////////////////////////////////////////////////////////////////////
const char *fonts[] = {
- "13",
+ "13",
"7", // tiny font, never used
"10", // small font
"13", // medium
@@ -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(clearAllListenToKeyPress()),
+ this, SLOT(clearAllListenToKeyPress()) );
+ connect( se, SIGNAL(restoreAllListenToKeyPress()),
+ this, SLOT(restoreAllListenToKeyPress()) );
+ connect( se, SIGNAL( updateTitle() ),
+ this, SLOT( updateTitle() ) );
+ // 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";
@@ -267,6 +277,7 @@ bool konsolePart::openURL( const KURL &
QString text = ( S_ISDIR( buff.st_mode ) ? url.path() : url.directory() );
KRun::shellQuote(text);
text = QString::fromLatin1("cd ") + text + '\n';
+ kdDebug() << "konsolePart::openURL entering text: " << text << endl;
QKeyEvent e(QEvent::KeyPress, 0,-1,0, text);
se->getEmulation()->onKeyPress(&e);
}
@@ -523,13 +534,13 @@ void konsolePart::closeCurrentSession()
sendSignal(SIGHUP);
}
-void konsolePart::slotToggleFrame()
+void konsolePart::slotToggleFrame()
{
b_framevis = showFrame->isChecked();
te->setFrameStyle( b_framevis?(QFrame::WinPanel|QFrame::Sunken):QFrame::NoFrame);
}
-void konsolePart::slotSelectScrollbar()
+void konsolePart::slotSelectScrollbar()
{
n_scroll = selectScrollbar->currentItem();
te->setScrollbarLocation(n_scroll);
@@ -707,7 +718,7 @@ void konsolePart::slotHistoryType()
se->setHistory(HistoryTypeBuffer(dlg.nbLines()));
m_histSize = dlg.nbLines();
b_histEnabled = true;
- }
+ }
else {
se->setHistory(HistoryTypeFile());
m_histSize = 0;
@@ -744,6 +755,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/konsole_part.h
===================================================================
RCS file: /home/kde/kdebase/konsole/konsole/konsole_part.h,v
retrieving revision 1.10
diff -u -p -r1.10 konsole_part.h
--- konsole/konsole_part.h 2001/11/28 01:55:28 1.10
+++ konsole/konsole_part.h 2002/03/19 12:41:24
@@ -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: konsole/session.cpp
===================================================================
RCS file: /home/kde/kdebase/konsole/konsole/session.cpp,v
retrieving revision 1.58
diff -u -p -r1.58 session.cpp
--- konsole/session.cpp 2002/02/11 05:39:09 1.58
+++ konsole/session.cpp 2002/03/19 12:41:24
@@ -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 & ) ) );
@@ -68,7 +58,7 @@ TESession::TESession(KMainWindow* main,
this, SLOT( notifySessionState(int) ) );
monitorTimer = new QTimer(this);
connect(monitorTimer, SIGNAL(timeout()), this, SLOT(monitorTimerDone()));
-
+
connect( sh,SIGNAL(done(int)), this,SLOT(done(int)) );
//kdDebug(1211)<<"TESession ctor() done"<<endl;
}
@@ -80,7 +70,7 @@ void TESession::run()
//kdDebug(1211) << "Running the session!" << pgm << "\n";
//pgm = "pine";
QString appId=kapp->dcopClient()->appId();
-
+
QString cwd_save = QDir::currentDirPath();
if (!cwd.isEmpty())
QDir::setCurrent(cwd);
@@ -318,7 +308,7 @@ bool TESession::isMonitorSilence() { ret
bool TESession::isMasterMode() { return masterMode; }
void TESession::setMonitorActivity(bool _monitor) { monitorActivity=_monitor; }
-void TESession::setMonitorSilence(bool _monitor)
+void TESession::setMonitorSilence(bool _monitor)
{
if (monitorSilence==_monitor)
return;
Index: konsole/session.h
===================================================================
RCS file: /home/kde/kdebase/konsole/konsole/session.h,v
retrieving revision 1.31
diff -u -p -r1.31 session.h
--- konsole/session.h 2002/02/11 05:39:09 1.31
+++ konsole/session.h 2002/03/19 12:41:24
@@ -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