Commit afe0adbd authored by Friedrich W. H. Kossebau's avatar Friedrich W. H. Kossebau
Browse files

ScratchpadView: use this as context object in connection to lambdas

parent e8793ce3
...@@ -114,19 +114,19 @@ ScratchpadView::ScratchpadView(QWidget* parent, Scratchpad* scratchpad) ...@@ -114,19 +114,19 @@ ScratchpadView::ScratchpadView(QWidget* parent, Scratchpad* scratchpad)
connect(scratchView, &QListView::activated, this, &ScratchpadView::scratchActivated); connect(scratchView, &QListView::activated, this, &ScratchpadView::scratchActivated);
connect(m_scratchpad, &Scratchpad::actionFailed, [this](const QString& message) { connect(m_scratchpad, &Scratchpad::actionFailed, this, [this](const QString& message) {
KMessageBox::sorry(this, message); KMessageBox::sorry(this, message);
}); });
connect(commandWidget, &QLineEdit::returnPressed, this, &ScratchpadView::runSelectedScratch); connect(commandWidget, &QLineEdit::returnPressed, this, &ScratchpadView::runSelectedScratch);
connect(commandWidget, &QLineEdit::returnPressed, [this] { connect(commandWidget, &QLineEdit::returnPressed, this, [this] {
m_scratchpad->setCommand(proxyModel()->mapToSource(currentIndex()), commandWidget->text()); m_scratchpad->setCommand(proxyModel()->mapToSource(currentIndex()), commandWidget->text());
}); });
commandWidget->setToolTip(i18n("Command to run this scratch. $f will expand to the scratch path")); commandWidget->setToolTip(i18n("Command to run this scratch. $f will expand to the scratch path"));
commandWidget->setPlaceholderText(commandWidget->toolTip()); commandWidget->setPlaceholderText(commandWidget->toolTip());
// change active scratch when changing document // change active scratch when changing document
connect(KDevelop::ICore::self()->documentController(), &KDevelop::IDocumentController::documentActivated, connect(KDevelop::ICore::self()->documentController(), &KDevelop::IDocumentController::documentActivated, this,
[this](const KDevelop::IDocument* document) { [this](const KDevelop::IDocument* document) {
if (document->url().isLocalFile()) { if (document->url().isLocalFile()) {
const auto* model = scratchView->model(); const auto* model = scratchView->model();
...@@ -150,7 +150,7 @@ void ScratchpadView::setupActions() ...@@ -150,7 +150,7 @@ void ScratchpadView::setupActions()
addAction(action); addAction(action);
action = new QAction(QIcon::fromTheme(QStringLiteral("list-remove")), i18n("Remove Scratch"), this); action = new QAction(QIcon::fromTheme(QStringLiteral("list-remove")), i18n("Remove Scratch"), this);
connect(action, &QAction::triggered, [this] { connect(action, &QAction::triggered, this, [this] {
m_scratchpad->removeScratch(proxyModel()->mapToSource(currentIndex())); m_scratchpad->removeScratch(proxyModel()->mapToSource(currentIndex()));
validateItemActions(); validateItemActions();
}); });
...@@ -158,7 +158,7 @@ void ScratchpadView::setupActions() ...@@ -158,7 +158,7 @@ void ScratchpadView::setupActions()
m_itemActions.push_back(action); m_itemActions.push_back(action);
action = new QAction(QIcon::fromTheme(QStringLiteral("edit-rename")), i18n("Rename Scratch"), this); action = new QAction(QIcon::fromTheme(QStringLiteral("edit-rename")), i18n("Rename Scratch"), this);
connect(action, &QAction::triggered, [this] { connect(action, &QAction::triggered, this, [this] {
scratchView->edit(scratchView->currentIndex()); scratchView->edit(scratchView->currentIndex());
}); });
addAction(action); addAction(action);
......
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