Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Utilities
Konsole
Commits
fca89702
Commit
fca89702
authored
May 16, 2007
by
Robert Knight
Browse files
Better Qt-style signal/slot names in Session class.
svn path=/trunk/KDE/kdebase/apps/konsole/; revision=665439
parent
a41d3ec5
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/Session.cpp
View file @
fca89702
...
...
@@ -101,7 +101,7 @@ Session::Session() :
connect
(
_emulation
,
SIGNAL
(
zmodemDetected
()
),
this
,
SLOT
(
fireZModemDetected
()
)
);
connect
(
_emulation
,
SIGNAL
(
changeTabTextColor
(
int
)
),
this
,
SIGNAL
(
changeTabTextColor
(
int
)
)
);
this
,
SIGNAL
(
changeTabTextColor
Request
(
int
)
)
);
//connect teletype to emulation backend
...
...
@@ -131,9 +131,6 @@ bool Session::running() const
return
_shellProcess
->
isRunning
();
}
void
Session
::
setType
(
const
QString
&
type
)
{
_type
=
type
;
}
QString
Session
::
type
()
const
{
return
_type
;
}
void
Session
::
setProgram
(
const
QString
&
program
)
{
_program
=
program
;
...
...
@@ -146,7 +143,13 @@ void Session::setArguments(const QStringList& arguments)
void
Session
::
ptyError
()
{
// FIXME: _shellProcess->error() is always empty
// Mysterious errors about PTYs used to be shown even when there was nothing wrong
// with the PTY itself because the code which starts the session ( in ::run() ) assumes
// that if starting the shell process fails then a PTY error is the problem, when
// there are other things that can go wrong as well
#if 0
// FIXME: _shellProcess->error() is always empty
if ( _shellProcess->error().isEmpty() )
{
KMessageBox::error( QApplication::activeWindow() ,
...
...
@@ -160,6 +163,7 @@ void Session::ptyError()
KMessageBox::error(QApplication::activeWindow(), _shellProcess->error());
emit finished();
#endif
}
QList
<
TerminalDisplay
*>
Session
::
views
()
const
...
...
@@ -273,9 +277,10 @@ void Session::run()
(
QLatin1String
(
"/Sessions/"
)
+
QString
::
number
(
_sessionId
)).
toLatin1
());
if
(
result
<
0
)
{
// Error in opening pseudo teletype
kWarning
()
<<
"Unable to open a pseudo teletype!"
<<
endl
;
QTimer
::
singleShot
(
0
,
this
,
SLOT
(
ptyError
()));
if
(
result
<
0
)
{
return
;
//QTimer::singleShot(0, this, SLOT(ptyError()));
}
_shellProcess
->
setErase
(
_emulation
->
getErase
());
...
...
@@ -323,7 +328,7 @@ void Session::setUserTitle( int what, const QString &caption )
// and tested - just so we don't forget to do this.
Q_ASSERT
(
0
);
emit
changeBackgroundColor
(
backColor
);
emit
changeBackgroundColor
Request
(
backColor
);
}
}
}
...
...
@@ -350,7 +355,7 @@ void Session::setUserTitle( int what, const QString &caption )
}
if
(
modified
)
emit
updateTitle
();
emit
titleChanged
();
}
QString
Session
::
userTitle
()
const
...
...
@@ -385,11 +390,11 @@ void Session::monitorTimerDone()
KNotification
::
event
(
"Silence"
,
i18n
(
"Silence in session '%1'"
,
_title
),
QPixmap
(),
QApplication
::
activeWindow
(),
KNotification
::
CloseWhenWidgetActivated
);
emit
notifySessionState
(
NOTIFYSILENCE
);
emit
stateChanged
(
NOTIFYSILENCE
);
}
else
{
emit
notifySessionState
(
NOTIFYNORMAL
);
emit
stateChanged
(
NOTIFYNORMAL
);
}
_notifiedActivity
=
false
;
...
...
@@ -424,7 +429,7 @@ void Session::activityStateChanged(int state)
if
(
state
==
NOTIFYSILENCE
&&
!
_monitorSilence
)
state
=
NOTIFYNORMAL
;
emit
notifySessionState
(
state
);
emit
stateChanged
(
state
);
}
void
Session
::
onContentSizeChange
(
int
/*height*/
,
int
/*width*/
)
...
...
@@ -463,7 +468,7 @@ bool Session::sendSignal(int signal)
return
_shellProcess
->
kill
(
signal
);
}
bool
Session
::
close
Session
()
void
Session
::
close
()
{
_autoClose
=
true
;
_wantedClose
=
true
;
...
...
@@ -472,7 +477,6 @@ bool Session::closeSession()
// Forced close.
QTimer
::
singleShot
(
1
,
this
,
SIGNAL
(
finished
()));
}
return
true
;
}
void
Session
::
sendText
(
const
QString
&
text
)
const
...
...
@@ -487,12 +491,15 @@ Session::~Session()
delete
_zmodemProc
;
}
void
Session
::
setProfileKey
(
const
QString
&
key
)
{
_profileKey
=
key
;
}
QString
Session
::
profileKey
()
const
{
return
_profileKey
;
}
void
Session
::
done
(
int
exitStatus
)
{
if
(
!
_autoClose
)
{
_userTitle
=
i18n
(
"<Finished>"
);
emit
updateTitle
();
emit
titleChanged
();
return
;
}
if
(
!
_wantedClose
&&
(
exitStatus
||
_shellProcess
->
signalled
()))
...
...
@@ -554,7 +561,7 @@ void Session::setTitle(const QString& title)
if
(
title
!=
_title
)
{
_title
=
title
;
emit
updateTitle
();
emit
titleChanged
();
}
}
...
...
@@ -568,7 +575,7 @@ void Session::setIconName(const QString& iconName)
if
(
iconName
!=
_iconName
)
{
_iconName
=
iconName
;
emit
updateTitle
();
emit
titleChanged
();
}
}
...
...
@@ -799,13 +806,13 @@ void Session::setSize(QSize size)
if
((
size
.
width
()
<=
1
)
||
(
size
.
height
()
<=
1
))
return
;
emit
resize
Session
(
size
);
emit
resize
Request
(
size
);
}
int
Session
::
foregroundProcessId
()
const
{
return
_shellProcess
->
foregroundProcessGroup
();
}
int
Session
::
sessionP
rocessId
()
const
int
Session
::
p
rocessId
()
const
{
return
_shellProcess
->
pid
();
}
...
...
src/Session.h
View file @
fca89702
...
...
@@ -62,7 +62,7 @@ Q_OBJECT
public:
Q_PROPERTY
(
QString
sessionName
READ
title
)
Q_PROPERTY
(
int
sessionP
rocessId
READ
sessionP
rocessId
)
Q_PROPERTY
(
int
p
rocessId
READ
p
rocessId
)
Q_PROPERTY
(
QString
keytab
READ
keyBindings
WRITE
setKeyBindings
)
Q_PROPERTY
(
QSize
size
READ
size
WRITE
setSize
)
...
...
@@ -72,26 +72,33 @@ public:
* To start the terminal process, call the run() method,
* after specifying the program and arguments
* using setProgram() and setArguments()
*
* If no program or arguments are specified explicitly, the Session
* falls back to using the program specified in the SHELL environment
* variable.
*/
Session
();
~
Session
();
/**
* Returns true if the session is currently running. This will be true
* after run() has been called.
* after run() has been called
successfully
.
*/
bool
running
()
const
;
/**
* Sets the type of this session.
* TODO: More documentation
* Sets the profile associated with this session.
*
* @param profileKey A key which can be used to obtain the current
* profile settings from the SessionManager
*/
void
set
Type
(
const
QString
&
typ
eKey
);
void
set
ProfileKey
(
const
QString
&
profil
eKey
);
/**
* Returns the type of this session.
* TODO: More documentation
* Returns the profile key associated with this session.
* This can be passed to the SessionManager to obtain the current
* profile settings.
*/
QString
type
()
const
;
QString
profileKey
()
const
;
/**
* Adds a new view for this session.
...
...
@@ -297,7 +304,7 @@ public:
* Returns the process id of the terminal process.
* This is the id used by the system API to refer to the process.
*/
int
sessionP
rocessId
()
const
;
int
p
rocessId
()
const
;
/**
* Returns the process id of the terminal's foreground process.
...
...
@@ -334,7 +341,7 @@ public slots:
* (SIGHUP) to the terminal process and causes the done(Session*)
* signal to be emitted.
*/
bool
close
Session
();
void
close
();
/** TODO: Document me */
void
setUserTitle
(
int
,
const
QString
&
caption
);
...
...
@@ -352,7 +359,7 @@ signals:
void
receivedData
(
const
QString
&
text
);
/** Emitted when the session's title has changed. */
void
updateTitle
();
void
titleChanged
();
/**
* Emitted when the activity state of this session changes.
...
...
@@ -360,7 +367,7 @@ signals:
* @param state The new state of the session. This may be one
* of NOTIFYNORMAL, NOTIFYSILENCE or NOTIFYACTIVITY
*/
void
notifySessionState
(
int
state
);
void
stateChanged
(
int
state
);
/** Emitted when a bell event occurs in the session. */
void
bellRequest
(
const
QString
&
message
);
...
...
@@ -371,13 +378,13 @@ signals:
*
* TODO: Document what the parameter does
*/
void
changeTabTextColor
(
int
);
void
changeTabTextColor
Request
(
int
);
/**
* Requests that the background color of views on this session
* should be changed.
*/
void
changeBackgroundColor
(
const
QColor
&
);
void
changeBackgroundColor
Request
(
const
QColor
&
);
void
openUrlRequest
(
const
QString
&
url
);
...
...
@@ -390,7 +397,7 @@ signals:
*
* @param size The requested window size in terms of lines and columns.
*/
void
resize
Session
(
const
QSize
&
size
);
void
resize
Request
(
const
QSize
&
size
);
private
slots
:
void
done
(
int
);
...
...
@@ -465,7 +472,7 @@ private:
QColor
_modifiedBackground
;
// as set by: echo -en '\033]11;Color\007
QString
_
type
;
QString
_
profileKey
;
static
int
lastSessionId
;
...
...
src/SessionController.cpp
View file @
fca89702
...
...
@@ -90,11 +90,11 @@ SessionController::SessionController(Session* session , TerminalDisplay* view, Q
SLOT
(
showDisplayContextMenu
(
TerminalDisplay
*
,
int
,
int
,
int
))
);
// listen to activity / silence notifications from session
connect
(
_session
,
SIGNAL
(
notifySessionState
(
int
))
,
this
,
connect
(
_session
,
SIGNAL
(
stateChanged
(
int
))
,
this
,
SLOT
(
sessionStateChanged
(
int
)
));
// listen to title and icon changes
connect
(
_session
,
SIGNAL
(
updateTitle
())
,
this
,
SLOT
(
sessionTitleChanged
())
);
connect
(
_session
,
SIGNAL
(
titleChanged
())
,
this
,
SLOT
(
sessionTitleChanged
())
);
// take a snapshot of the session state every so often when
// user activity occurs
...
...
@@ -123,7 +123,7 @@ void SessionController::snapshot()
ProcessInfo
*
process
=
0
;
ProcessInfo
*
snapshot
=
ProcessInfo
::
newInstance
(
_session
->
sessionP
rocessId
());
ProcessInfo
*
snapshot
=
ProcessInfo
::
newInstance
(
_session
->
p
rocessId
());
snapshot
->
update
();
// use foreground process information if available
...
...
@@ -170,7 +170,7 @@ void SessionController::snapshot()
KUrl
SessionController
::
url
()
const
{
ProcessInfo
*
info
=
ProcessInfo
::
newInstance
(
_session
->
sessionP
rocessId
());
ProcessInfo
*
info
=
ProcessInfo
::
newInstance
(
_session
->
p
rocessId
());
info
->
update
();
QString
path
;
...
...
@@ -475,7 +475,7 @@ void SessionController::debugProcess()
{
// testing facility to retrieve process information about
// currently active process in the shell
ProcessInfo
*
sessionProcess
=
ProcessInfo
::
newInstance
(
_session
->
sessionP
rocessId
());
ProcessInfo
*
sessionProcess
=
ProcessInfo
::
newInstance
(
_session
->
p
rocessId
());
sessionProcess
->
update
();
bool
ok
=
false
;
...
...
@@ -514,7 +514,7 @@ void SessionController::editCurrentProfile()
{
EditProfileDialog
*
dialog
=
new
EditProfileDialog
(
QApplication
::
activeWindow
()
);
dialog
->
setProfile
(
_session
->
type
());
dialog
->
setProfile
(
_session
->
profileKey
());
dialog
->
show
();
}
void
SessionController
::
renameSession
()
...
...
@@ -536,7 +536,7 @@ void SessionController::saveSession()
}
void
SessionController
::
closeSession
()
{
_session
->
close
Session
();
_session
->
close
();
}
void
SessionController
::
copy
()
...
...
src/SessionManager.cpp
View file @
fca89702
...
...
@@ -184,7 +184,7 @@ Session* SessionManager::createSession(const QString& key )
//configuration information found, create a new session based on this
session
=
new
Session
();
session
->
set
Type
(
key
);
session
->
set
ProfileKey
(
key
);
applyProfile
(
session
,
info
,
false
);
...
...
@@ -307,13 +307,13 @@ void SessionManager::applyProfile(const QString& key , bool modifiedPropertiesOn
while
(
iter
.
hasNext
()
)
{
Session
*
next
=
iter
.
next
();
if
(
next
->
type
()
==
key
)
if
(
next
->
profileKey
()
==
key
)
applyProfile
(
next
,
info
,
modifiedPropertiesOnly
);
}
}
void
SessionManager
::
applyProfile
(
Session
*
session
,
const
Profile
*
info
,
bool
modifiedPropertiesOnly
)
{
session
->
set
Type
(
_types
.
key
((
Profile
*
)
info
)
);
session
->
set
ProfileKey
(
_types
.
key
((
Profile
*
)
info
)
);
// Basic session settings
if
(
!
modifiedPropertiesOnly
||
info
->
isPropertySet
(
Profile
::
Name
)
)
...
...
src/ViewManager.cpp
View file @
fca89702
...
...
@@ -305,7 +305,7 @@ void ViewManager::splitView(Qt::Orientation orientation)
{
Session
*
session
=
_sessionMap
[(
TerminalDisplay
*
)
existingViewIter
.
next
()];
TerminalDisplay
*
display
=
createTerminalDisplay
();
applyProfile
(
display
,
session
->
type
());
applyProfile
(
display
,
session
->
profileKey
());
ViewProperties
*
properties
=
createController
(
session
,
display
);
_sessionMap
[
display
]
=
session
;
...
...
@@ -402,7 +402,7 @@ void ViewManager::createView(Session* session)
{
ViewContainer
*
container
=
containerIter
.
next
();
TerminalDisplay
*
display
=
createTerminalDisplay
();
applyProfile
(
display
,
session
->
type
());
applyProfile
(
display
,
session
->
profileKey
());
// set initial size
// temporary default used for now
...
...
@@ -463,7 +463,7 @@ void ViewManager::viewCloseRequest(QWidget* view)
display
->
deleteLater
();
if
(
session
->
views
().
count
()
==
0
)
session
->
close
Session
();
session
->
close
();
}
focusActiveView
();
...
...
@@ -561,7 +561,7 @@ void ViewManager::profileChanged(const QString& key)
iter
.
next
();
// if session uses this profile, update the display
if
(
iter
.
value
()
!=
0
&&
iter
.
value
()
->
type
()
==
key
)
if
(
iter
.
value
()
!=
0
&&
iter
.
value
()
->
profileKey
()
==
key
)
{
applyProfile
(
iter
.
key
(),
key
);
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment