Commit 07fa804a authored by Gustavo Carneiro's avatar Gustavo Carneiro Committed by Kurt Hindenburg
Browse files

Separates the connection between session and display

parent 7826979e
......@@ -110,6 +110,7 @@ set(konsoleprivate_SRCS ${sessionadaptors_SRCS}
CharacterWidth.cpp
CompositeWidgetFocusWatcher.cpp
AutoScrollHandler.cpp
SessionDisplayConnection.cpp
${CMAKE_CURRENT_BINARY_DIR}/org.kde.konsole.Window.xml
${CMAKE_CURRENT_BINARY_DIR}/org.kde.konsole.Session.xml)
......
/*
Copyright 2020-2020 by Gustavo Carneiro <gcarneiroa@hotmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
*/
// Own
#include "SessionDisplayConnection.h"
// Konsole
#include "Session.h"
#include "widgets/TerminalDisplay.h"
namespace Konsole
{
SessionDisplayConnection::SessionDisplayConnection(Session *session, TerminalDisplay *view, QObject *parent)
: QObject(parent)
{
mSession = session;
mView = view;
}
QPointer<Session> SessionDisplayConnection::session()
{
return mSession;
}
QPointer<TerminalDisplay> SessionDisplayConnection::view()
{
return mView;
}
bool SessionDisplayConnection::isValid() const
{
return !mSession.isNull() && !mView.isNull();
}
} // namespace Konsole
/*
Copyright 2020-2020 by Gustavo Carneiro <gcarneiroa@hotmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
*/
#ifndef SESSIONDISPLAYCONNECTION_H
#define SESSIONDISPLAYCONNECTION_H
// Qt
#include <QPointer>
// Konsole
#include "konsoleprivate_export.h"
namespace Konsole
{
class Session;
class TerminalDisplay;
class KONSOLEPRIVATE_EXPORT SessionDisplayConnection : public QObject
{
Q_OBJECT
public:
SessionDisplayConnection(Session *session, TerminalDisplay *view, QObject *parent = nullptr);
~SessionDisplayConnection() = default;
QPointer<Session> session();
QPointer<TerminalDisplay> view();
/**
* Returns true if the controller is valid.
* A valid controller is one which has a non-null session() and view().
*
* Equivalent to "!session().isNull() && !view().isNull()"
*/
bool isValid() const;
private:
QPointer<Session> mSession;
QPointer<TerminalDisplay> mView;
};
}
#endif
This diff is collapsed.
......@@ -31,6 +31,7 @@
#include <KXMLGUIClient>
// Konsole
#include "SessionDisplayConnection.h"
#include "ViewProperties.h"
#include "Profile.h"
#include "Enumeration.h"
......@@ -96,13 +97,13 @@ public:
/** Returns the session associated with this controller */
QPointer<Session> session()
{
return _session;
return _sessionDisplayConnection->session();
}
/** Returns the view associated with this controller */
QPointer<TerminalDisplay> view()
{
return _view;
return _sessionDisplayConnection->view();
}
/**
......@@ -315,6 +316,8 @@ private:
QPointer<TerminalDisplay> _view;
SessionGroup *_copyToGroup;
SessionDisplayConnection *_sessionDisplayConnection;
ProfileList *_profileList;
QIcon _sessionIcon;
......@@ -361,10 +364,6 @@ private:
QString _previousForegroundProcessName;
bool _monitorProcessFinish;
};
inline bool SessionController::isValid() const
{
return !_session.isNull() && !_view.isNull();
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment