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
44fd6c0b
Commit
44fd6c0b
authored
Nov 13, 2020
by
Tomaz Canabrava
Browse files
Revert "Uses SessionDisplayConnection to connect sessions and displays."
This reverts commit
6971d531
.
parent
0f656a32
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/ViewManager.cpp
View file @
44fd6c0b
...
...
@@ -29,7 +29,6 @@
#include
"session/Session.h"
#include
"session/SessionController.h"
#include
"session/SessionManager.h"
#include
"session/SessionDisplayConnection.h"
#include
"terminalDisplay/TerminalDisplay.h"
#include
"widgets/ViewContainer.h"
...
...
@@ -43,7 +42,7 @@ ViewManager::ViewManager(QObject *parent, KActionCollection *collection) :
QObject
(
parent
),
_viewContainer
(
nullptr
),
_pluggedController
(
nullptr
),
_sessionMap
(
Q
Vector
<
SessionDisplayConnect
ion
*>
()),
_sessionMap
(
Q
Hash
<
TerminalDisplay
*
,
Sess
ion
*>
()),
_actionCollection
(
collection
),
_navigationMethod
(
NoNavigation
),
_navigationVisibility
(
NavigationNotSet
),
...
...
@@ -81,15 +80,6 @@ int ViewManager::managerId() const
return
_managerId
;
}
QList
<
Session
*>
ViewManager
::
sessions
()
{
QList
<
Session
*>
sessionList
;
for
(
auto
sdsp
:
_sessionMap
)
{
sessionList
.
append
(
sdsp
->
session
());
}
return
sessionList
;
}
QWidget
*
ViewManager
::
activeView
()
const
{
return
_viewContainer
->
currentWidget
();
...
...
@@ -444,14 +434,9 @@ Session* ViewManager::forgetTerminal(TerminalDisplay* terminal)
disconnect
(
terminal
,
&
TerminalDisplay
::
requestToggleExpansion
,
nullptr
,
nullptr
);
removeController
(
terminal
->
sessionController
());
Session
*
session
=
nullptr
;
for
(
auto
sdsp
:
_sessionMap
)
{
session
=
sdsp
->
view
()
==
terminal
?
sdsp
->
session
()
:
nullptr
;
if
(
session
!=
nullptr
)
{
_sessionMap
.
removeOne
(
sdsp
);
disconnect
(
session
,
&
Konsole
::
Session
::
finished
,
this
,
&
Konsole
::
ViewManager
::
sessionFinished
);
break
;
}
auto
session
=
_sessionMap
.
take
(
terminal
);
if
(
session
!=
nullptr
)
{
disconnect
(
session
,
&
Konsole
::
Session
::
finished
,
this
,
&
Konsole
::
ViewManager
::
sessionFinished
);
}
_viewContainer
->
disconnectTerminalDisplay
(
terminal
);
updateTerminalDisplayHistory
(
terminal
,
true
);
...
...
@@ -480,14 +465,8 @@ void ViewManager::sessionFinished()
auto
*
session
=
qobject_cast
<
Session
*>
(
sender
());
Q_ASSERT
(
session
);
TerminalDisplay
*
view
=
nullptr
;
for
(
auto
sdsp
:
_sessionMap
)
{
view
=
sdsp
->
session
()
==
session
?
sdsp
->
view
()
:
nullptr
;
if
(
view
!=
nullptr
)
{
_sessionMap
.
removeOne
(
sdsp
);
break
;
}
}
auto
view
=
_sessionMap
.
key
(
session
);
_sessionMap
.
remove
(
view
);
if
(
SessionManager
::
instance
()
->
isClosingAllSessions
()){
return
;
...
...
@@ -663,7 +642,7 @@ void ViewManager::attachView(TerminalDisplay *terminal, Session *session)
connect
(
terminal
,
&
TerminalDisplay
::
requestToggleExpansion
,
_viewContainer
,
&
TabbedViewContainer
::
toggleMaximizeCurrentTerminal
,
Qt
::
UniqueConnection
);
_sessionMap
.
append
(
new
SessionDisplayConnection
(
session
,
terminal
,
this
))
;
_sessionMap
[
terminal
]
=
session
;
createController
(
session
,
terminal
);
toggleActionsBasedOnState
();
_terminalDisplayHistory
.
append
(
terminal
);
...
...
@@ -688,7 +667,7 @@ TerminalDisplay *ViewManager::createView(Session *session)
display
->
setSize
(
preferredSize
.
width
(),
preferredSize
.
height
());
createController
(
session
,
display
);
_sessionMap
.
append
(
new
SessionDisplayConnection
(
session
,
display
,
this
))
;
_sessionMap
[
display
]
=
session
;
session
->
addView
(
display
);
_terminalDisplayHistory
.
append
(
display
);
...
...
@@ -790,14 +769,11 @@ void ViewManager::viewDestroyed(QWidget *view)
// 1. detach view from session
// 2. if the session has no views left, close it
Session
*
session
=
nullptr
;
for
(
auto
sdsp
:
_sessionMap
)
{
session
=
sdsp
->
view
()
==
display
?
sdsp
->
session
()
:
nullptr
;
_sessionMap
.
removeOne
(
sdsp
);
if
(
session
!=
nullptr
)
{
if
(
session
->
views
().
count
()
==
0
)
{
session
->
close
();
}
Session
*
session
=
_sessionMap
[
display
];
_sessionMap
.
remove
(
display
);
if
(
session
!=
nullptr
)
{
if
(
session
->
views
().
count
()
==
0
)
{
session
->
close
();
}
}
...
...
@@ -849,8 +825,8 @@ void ViewManager::updateViewsForSession(Session *session)
{
const
Profile
::
Ptr
profile
=
SessionManager
::
instance
()
->
sessionProfile
(
session
);
for
(
auto
sdsp
:
_sessionMap
)
{
TerminalDisplay
*
view
=
s
dsp
->
session
()
?
sdsp
->
view
()
:
nullptr
;
const
QList
<
TerminalDisplay
*>
sessionMapKeys
=
_sessionMap
.
keys
(
session
);
for
(
TerminalDisplay
*
view
:
s
essionMapKeys
)
{
applyProfileToView
(
view
,
profile
);
}
}
...
...
@@ -858,13 +834,15 @@ void ViewManager::updateViewsForSession(Session *session)
void
ViewManager
::
profileChanged
(
const
Profile
::
Ptr
&
profile
)
{
// update all views associated with this profile
Q
Vector
Iterator
<
SessionDisplayConnect
ion
*>
iter
(
_sessionMap
);
Q
Hash
Iterator
<
TerminalDisplay
*
,
Sess
ion
*>
iter
(
_sessionMap
);
while
(
iter
.
hasNext
())
{
iter
.
next
();
// if session uses this profile, update the display
SessionDisplayConnection
*
sdsp
=
iter
.
next
();
if
(
sdsp
!=
nullptr
&&
SessionManager
::
instance
()
->
sessionProfile
(
sdsp
->
session
())
==
profile
)
{
applyProfileToView
(
sdsp
->
view
(),
profile
);
if
(
iter
.
key
()
!=
nullptr
&&
iter
.
value
()
!=
nullptr
&&
SessionManager
::
instance
()
->
sessionProfile
(
iter
.
value
())
==
profile
)
{
applyProfileToView
(
iter
.
key
(),
profile
);
}
}
}
...
...
src/ViewManager.h
View file @
44fd6c0b
...
...
@@ -30,7 +30,6 @@ class TabbedViewContainer;
class
TerminalDisplay
;
class
ViewProperties
;
class
ViewSplitter
;
class
SessionDisplayConnection
;
/**
* Manages the terminal display widgets in a Konsole window or part.
...
...
@@ -164,7 +163,10 @@ public:
int
managerId
()
const
;
/** Returns a list of sessions in this ViewManager */
QList
<
Session
*>
sessions
();
QList
<
Session
*>
sessions
()
{
return
_sessionMap
.
values
();
}
/**
* Returns whether the @p profile has the blur setting enabled
...
...
@@ -416,9 +418,7 @@ private:
QPointer
<
TabbedViewContainer
>
_viewContainer
;
QPointer
<
SessionController
>
_pluggedController
;
// TODO: This map must be separated into a new class containing the global link map between sessions and displays used by the entire konsole
// The solution implemented so far is initial and should be reviewed
QVector
<
SessionDisplayConnection
*>
_sessionMap
;
QHash
<
TerminalDisplay
*
,
Session
*>
_sessionMap
;
KActionCollection
*
_actionCollection
;
...
...
Tomaz Canabrava
@tcanabrava
mentioned in commit
1b03adf7
·
Nov 14, 2020
mentioned in commit
1b03adf7
mentioned in commit 1b03adf74d0ee2267d8dd1a549c31fe3c770556b
Toggle commit list
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