Commit 881b0d4b authored by Tomaz  Canabrava's avatar Tomaz Canabrava Committed by Kurt Hindenburg
Browse files

Access QPointer Directly

Don't call .data() for whenever we want to deal with the Smart
pointer. they have overloaded operators for those things, and we
should use them.

Makes the code much more pleasant.
parent 0ecf394e
......@@ -152,41 +152,41 @@ SessionController::SessionController(Session* session , TerminalDisplay* view, Q
connect(ProfileManager::instance(), &Konsole::ProfileManager::profileChanged, this, &Konsole::SessionController::updateFilterList);
// listen for session resize requests
connect(_session.data(), &Konsole::Session::resizeRequest, this, &Konsole::SessionController::sessionResizeRequest);
connect(_session, &Konsole::Session::resizeRequest, this, &Konsole::SessionController::sessionResizeRequest);
// listen for popup menu requests
connect(_view.data(), &Konsole::TerminalDisplay::configureRequest, this, &Konsole::SessionController::showDisplayContextMenu);
connect(_view, &Konsole::TerminalDisplay::configureRequest, this, &Konsole::SessionController::showDisplayContextMenu);
// move view to newest output when keystrokes occur
connect(_view.data(), &Konsole::TerminalDisplay::keyPressedSignal, this, &Konsole::SessionController::trackOutput);
connect(_view, &Konsole::TerminalDisplay::keyPressedSignal, this, &Konsole::SessionController::trackOutput);
// listen to activity / silence notifications from session
connect(_session.data(), &Konsole::Session::notificationsChanged, this, &Konsole::SessionController::sessionNotificationsChanged);
connect(_session, &Konsole::Session::notificationsChanged, this, &Konsole::SessionController::sessionNotificationsChanged);
// listen to title and icon changes
connect(_session.data(), &Konsole::Session::sessionAttributeChanged, this, &Konsole::SessionController::sessionAttributeChanged);
connect(_session.data(), &Konsole::Session::readOnlyChanged, this, &Konsole::SessionController::sessionReadOnlyChanged);
connect(_session, &Konsole::Session::sessionAttributeChanged, this, &Konsole::SessionController::sessionAttributeChanged);
connect(_session, &Konsole::Session::readOnlyChanged, this, &Konsole::SessionController::sessionReadOnlyChanged);
connect(this, &Konsole::SessionController::tabRenamedByUser, _session, &Konsole::Session::tabTitleSetByUser);
connect(this, &Konsole::SessionController::tabColoredByUser, _session, &Konsole::Session::tabColorSetByUser);
connect(_session.data() , &Konsole::Session::currentDirectoryChanged , this , &Konsole::SessionController::currentDirectoryChanged);
connect(_session , &Konsole::Session::currentDirectoryChanged , this , &Konsole::SessionController::currentDirectoryChanged);
// listen for color changes
connect(_session.data(), &Konsole::Session::changeBackgroundColorRequest, _view.data(), &Konsole::TerminalDisplay::setBackgroundColor);
connect(_session.data(), &Konsole::Session::changeForegroundColorRequest, _view.data(), &Konsole::TerminalDisplay::setForegroundColor);
connect(_session, &Konsole::Session::changeBackgroundColorRequest, _view, &Konsole::TerminalDisplay::setBackgroundColor);
connect(_session, &Konsole::Session::changeForegroundColorRequest, _view, &Konsole::TerminalDisplay::setForegroundColor);
// update the title when the session starts
connect(_session.data(), &Konsole::Session::started, this, &Konsole::SessionController::snapshot);
connect(_session, &Konsole::Session::started, this, &Konsole::SessionController::snapshot);
// listen for output changes to set activity flag
connect(_session->emulation(), &Konsole::Emulation::outputChanged, this, &Konsole::SessionController::fireActivity);
// listen for detection of ZModem transfer
connect(_session.data(), &Konsole::Session::zmodemDownloadDetected, this, &Konsole::SessionController::zmodemDownload);
connect(_session.data(), &Konsole::Session::zmodemUploadDetected, this, &Konsole::SessionController::zmodemUpload);
connect(_session, &Konsole::Session::zmodemDownloadDetected, this, &Konsole::SessionController::zmodemDownload);
connect(_session, &Konsole::Session::zmodemUploadDetected, this, &Konsole::SessionController::zmodemUpload);
// listen for flow control status changes
connect(_session.data(), &Konsole::Session::flowControlEnabledChanged, _view.data(), &Konsole::TerminalDisplay::setFlowControlWarningEnabled);
connect(_session, &Konsole::Session::flowControlEnabledChanged, _view, &Konsole::TerminalDisplay::setFlowControlWarningEnabled);
_view->setFlowControlWarningEnabled(_session->flowControlEnabled());
// take a snapshot of the session state every so often when
......@@ -198,9 +198,9 @@ SessionController::SessionController(Session* session , TerminalDisplay* view, Q
_interactionTimer->setSingleShot(true);
_interactionTimer->setInterval(500);
connect(_interactionTimer, &QTimer::timeout, this, &Konsole::SessionController::snapshot);
connect(_view.data(), &Konsole::TerminalDisplay::compositeFocusChanged,
connect(_view, &Konsole::TerminalDisplay::compositeFocusChanged,
this, [this](bool focused) { if (focused) { interactionHandler(); }});
connect(_view.data(), &Konsole::TerminalDisplay::keyPressedSignal,
connect(_view, &Konsole::TerminalDisplay::keyPressedSignal,
this, &Konsole::SessionController::interactionHandler);
// take a snapshot of the session state periodically in the background
......@@ -211,10 +211,10 @@ SessionController::SessionController(Session* session , TerminalDisplay* view, Q
backgroundTimer->start();
// xterm '10;?' request
connect(_session.data(), &Konsole::Session::getForegroundColor,
connect(_session, &Konsole::Session::getForegroundColor,
this, &Konsole::SessionController::sendForegroundColor);
// xterm '11;?' request
connect(_session.data(), &Konsole::Session::getBackgroundColor,
connect(_session, &Konsole::Session::getBackgroundColor,
this, &Konsole::SessionController::sendBackgroundColor);
_allControllers.insert(this);
......@@ -232,7 +232,7 @@ SessionController::~SessionController()
_allControllers.remove(this);
if (!_editProfileDialog.isNull()) {
delete _editProfileDialog.data();
_editProfileDialog->deleteLater();
}
if(factory() != nullptr) {
factory()->removeClient(this);
......@@ -280,9 +280,9 @@ void SessionController::viewFocusChangeHandler(bool focused)
// by the focused view
// first, disconnect any other views which are listening for bell signals from the session
disconnect(_session.data(), &Konsole::Session::bellRequest, nullptr, nullptr);
disconnect(_session, &Konsole::Session::bellRequest, nullptr, nullptr);
// second, connect the newly focused view to listen for the session's bell signal
connect(_session.data(), &Konsole::Session::bellRequest, _view.data(), &Konsole::TerminalDisplay::bell);
connect(_session, &Konsole::Session::bellRequest, _view, &Konsole::TerminalDisplay::bell);
if ((_copyInputToAllTabsAction != nullptr) && _copyInputToAllTabsAction->isChecked()) {
// A session with "Copy To All Tabs" has come into focus:
......@@ -561,14 +561,14 @@ void SessionController::removeSearchFilter()
void SessionController::setupSearchBar()
{
connect(_searchBar.data(), &Konsole::IncrementalSearchBar::unhandledMovementKeyPressed, this, &Konsole::SessionController::movementKeyFromSearchBarReceived);
connect(_searchBar.data(), &Konsole::IncrementalSearchBar::closeClicked, this, &Konsole::SessionController::searchClosed);
connect(_searchBar.data(), &Konsole::IncrementalSearchBar::searchFromClicked, this, &Konsole::SessionController::searchFrom);
connect(_searchBar.data(), &Konsole::IncrementalSearchBar::findNextClicked, this, &Konsole::SessionController::findNextInHistory);
connect(_searchBar.data(), &Konsole::IncrementalSearchBar::findPreviousClicked, this, &Konsole::SessionController::findPreviousInHistory);
connect(_searchBar.data(), &Konsole::IncrementalSearchBar::highlightMatchesToggled , this , &Konsole::SessionController::highlightMatches);
connect(_searchBar.data(), &Konsole::IncrementalSearchBar::matchCaseToggled, this, &Konsole::SessionController::changeSearchMatch);
connect(_searchBar.data(), &Konsole::IncrementalSearchBar::matchRegExpToggled, this, &Konsole::SessionController::changeSearchMatch);
connect(_searchBar, &Konsole::IncrementalSearchBar::unhandledMovementKeyPressed, this, &Konsole::SessionController::movementKeyFromSearchBarReceived);
connect(_searchBar, &Konsole::IncrementalSearchBar::closeClicked, this, &Konsole::SessionController::searchClosed);
connect(_searchBar, &Konsole::IncrementalSearchBar::searchFromClicked, this, &Konsole::SessionController::searchFrom);
connect(_searchBar, &Konsole::IncrementalSearchBar::findNextClicked, this, &Konsole::SessionController::findNextInHistory);
connect(_searchBar, &Konsole::IncrementalSearchBar::findPreviousClicked, this, &Konsole::SessionController::findPreviousInHistory);
connect(_searchBar, &Konsole::IncrementalSearchBar::highlightMatchesToggled , this , &Konsole::SessionController::highlightMatches);
connect(_searchBar, &Konsole::IncrementalSearchBar::matchCaseToggled, this, &Konsole::SessionController::changeSearchMatch);
connect(_searchBar, &Konsole::IncrementalSearchBar::matchRegExpToggled, this, &Konsole::SessionController::changeSearchMatch);
}
void SessionController::setShowMenuAction(QAction* action)
......@@ -692,7 +692,7 @@ void SessionController::setupCommonActions()
_codecAction->setIcon(QIcon::fromTheme(QStringLiteral("character-set")));
collection->addAction(QStringLiteral("set-encoding"), _codecAction);
_codecAction->setCurrentCodec(QString::fromUtf8(_session->codec()));
connect(_session.data(), &Konsole::Session::sessionCodecChanged, this, &Konsole::SessionController::updateCodecAction);
connect(_session, &Konsole::Session::sessionCodecChanged, this, &Konsole::SessionController::updateCodecAction);
connect(_codecAction,
QOverload<QTextCodec*>::of(&KCodecAction::triggered), this,
&Konsole::SessionController::changeCodec);
......@@ -877,12 +877,12 @@ void SessionController::editCurrentProfile()
// NOTE bug311270: For to prevent the crash, the profile must be reset.
if (!_editProfileDialog.isNull()) {
// exists but not visible
delete _editProfileDialog.data();
_editProfileDialog->deleteLater();
}
_editProfileDialog = new EditProfileDialog(QApplication::activeWindow());
_editProfileDialog.data()->setProfile(SessionManager::instance()->sessionProfile(_session));
_editProfileDialog.data()->show();
_editProfileDialog->setProfile(SessionManager::instance()->sessionProfile(_session));
_editProfileDialog->show();
}
void SessionController::renameSession()
......@@ -1264,7 +1264,7 @@ void SessionController::listenForScreenWindowUpdates()
connect(_view->screenWindow(), &Konsole::ScreenWindow::outputChanged, this, &Konsole::SessionController::updateSearchFilter);
connect(_view->screenWindow(), &Konsole::ScreenWindow::scrolled, this, &Konsole::SessionController::updateSearchFilter);
connect(_view->screenWindow(),
&Konsole::ScreenWindow::currentResultLineChanged, _view.data(),
&Konsole::ScreenWindow::currentResultLineChanged, _view,
QOverload<>::of(&Konsole::TerminalDisplay::update));
_listenForScreenWindowUpdates = true;
......@@ -1304,15 +1304,15 @@ void SessionController::enableSearchBar(bool showSearchBar)
_searchBar->setVisible(showSearchBar);
if (showSearchBar) {
connect(_searchBar.data(), &Konsole::IncrementalSearchBar::searchChanged, this, &Konsole::SessionController::searchTextChanged);
connect(_searchBar.data(), &Konsole::IncrementalSearchBar::searchReturnPressed, this, &Konsole::SessionController::findPreviousInHistory);
connect(_searchBar.data(), &Konsole::IncrementalSearchBar::searchShiftPlusReturnPressed, this, &Konsole::SessionController::findNextInHistory);
connect(_searchBar, &Konsole::IncrementalSearchBar::searchChanged, this, &Konsole::SessionController::searchTextChanged);
connect(_searchBar, &Konsole::IncrementalSearchBar::searchReturnPressed, this, &Konsole::SessionController::findPreviousInHistory);
connect(_searchBar, &Konsole::IncrementalSearchBar::searchShiftPlusReturnPressed, this, &Konsole::SessionController::findNextInHistory);
} else {
disconnect(_searchBar.data(), &Konsole::IncrementalSearchBar::searchChanged, this,
disconnect(_searchBar, &Konsole::IncrementalSearchBar::searchChanged, this,
&Konsole::SessionController::searchTextChanged);
disconnect(_searchBar.data(), &Konsole::IncrementalSearchBar::searchReturnPressed, this,
disconnect(_searchBar, &Konsole::IncrementalSearchBar::searchReturnPressed, this,
&Konsole::SessionController::findPreviousInHistory);
disconnect(_searchBar.data(), &Konsole::IncrementalSearchBar::searchShiftPlusReturnPressed, this,
disconnect(_searchBar, &Konsole::IncrementalSearchBar::searchShiftPlusReturnPressed, this,
&Konsole::SessionController::findNextInHistory);
if ((!_view.isNull()) && (_view->screenWindow() != nullptr)) {
_view->screenWindow()->setCurrentResultLine(-1);
......@@ -1552,7 +1552,7 @@ void SessionController::print_screen()
dialog->setOptionTabs(QList<QWidget*>() << options);
dialog->setWindowTitle(i18n("Print Shell"));
connect(dialog.data(),
connect(dialog,
QOverload<>::of(&QPrintDialog::accepted),
options,
&Konsole::PrintOptions::saveSettings);
......@@ -1719,7 +1719,7 @@ void SessionController::sessionReadOnlyChanged() {
// Update all views
const QList<TerminalDisplay *> viewsList = session()->views();
for (TerminalDisplay *terminalDisplay : viewsList) {
if (terminalDisplay != _view.data()) {
if (terminalDisplay != _view) {
terminalDisplay->updateReadOnlyState(isReadOnly());
}
emit readOnlyChanged(this);
......
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