From kde-commits Sat Sep 15 10:01:05 2018 From: Amish Naidu Date: Sat, 15 Sep 2018 10:01:05 +0000 To: kde-commits Subject: [kdevelop] kdevplatform/shell: Create action to jump to the current execution line in debug mode. Message-Id: X-MARC-Message: https://marc.info/?l=kde-commits&m=153700567806273 Git commit 59d823957de8f685d4cf94919bca2738328aa197 by Amish Naidu. Committed on 15/09/2018 at 10:00. Pushed by anaidu into branch 'master'. Create action to jump to the current execution line in debug mode. Summary: Added new action called "Show Current Line" that will jump to the execution position of the debugging program. This allows setting a shortcut to it, while the previous workaround of clicking on the active frame in the frame stack didn't. FEATURE: 361411 Reviewers: #kdevelop, brauch Reviewed By: #kdevelop, brauch Subscribers: kossebau, brauch, kdevelop-devel Tags: #kdevelop Differential Revision: https://phabricator.kde.org/D14618 M +19 -0 kdevplatform/shell/debugcontroller.cpp M +5 -3 kdevplatform/shell/debugcontroller.h M +10 -6 kdevplatform/shell/debugger/kdevdebuggershellui.rc https://commits.kde.org/kdevelop/59d823957de8f685d4cf94919bca2738328aa197 diff --git a/kdevplatform/shell/debugcontroller.cpp b/kdevplatform/shell/de= bugcontroller.cpp index dd2549cb07..2bac8d531a 100644 --- a/kdevplatform/shell/debugcontroller.cpp +++ b/kdevplatform/shell/debugcontroller.cpp @@ -273,6 +273,12 @@ void DebugController::setupActions() action->setWhatsThis(i18n("Toggles the breakpoint at the current line = in editor.")); connect(action, &QAction::triggered, this, &DebugController::toggleBre= akpoint); ac->addAction(QStringLiteral("debug_toggle_breakpoint"), action); + + m_showCurrentLine =3D action =3D new QAction(QIcon::fromTheme(QStringL= iteral("go-jump")), i18n("Show Current Line"), this); + action->setToolTip(i18n("Show the current execution position")); + action->setWhatsThis(i18n("Jumps to the execution line in the editor."= )); + connect(action, &QAction::triggered, this, &DebugController::showCurre= ntLine); + ac->addAction(QStringLiteral("debug_showcurrentline"), action); } = void DebugController::addSession(IDebugSession* session) @@ -546,6 +552,19 @@ void DebugController::toggleBreakpoint() } } = +void DebugController::showCurrentLine() +{ + const auto location =3D qMakePair(m_currentSession->currentUrl(), m_cu= rrentSession->currentLine()); + + if (location.second !=3D -1) { + const auto localLocation =3D m_currentSession->convertToLocalUrl(l= ocation); + ICore::self()->documentController()->openDocument(localLocation.fi= rst, + KTextEditor::Cur= sor(localLocation.second, 0), + IDocumentControl= ler::DefaultMode); + } + +} + const QPixmap* DebugController::executionPointPixmap() { static QPixmap pixmap=3DQIcon::fromTheme(QStringLiteral("go-next")).pixm= ap(QSize(22,22), QIcon::Normal, QIcon::Off); diff --git a/kdevplatform/shell/debugcontroller.h b/kdevplatform/shell/debu= gcontroller.h index cc87363800..6834086546 100644 --- a/kdevplatform/shell/debugcontroller.h +++ b/kdevplatform/shell/debugcontroller.h @@ -78,11 +78,12 @@ private Q_SLOTS: void stepOverInstruction(); void stepOut(); void toggleBreakpoint(); + void showCurrentLine(); = void debuggerStateChanged(KDevelop::IDebugSession::DebuggerState state= ); void showStepInSource(const QUrl &file, int line); void clearExecutionPoint(); - = + void partAdded(KParts::Part* part); void areaChanged(Sublime::Area* newArea); = @@ -108,11 +109,12 @@ private: QAction* m_stepOverInstruction =3D nullptr; QAction* m_stepOut =3D nullptr; QAction* m_toggleBreakpoint =3D nullptr; + QAction* m_showCurrentLine =3D nullptr; = QPointer m_currentSession; BreakpointModel *m_breakpointModel; - VariableCollection *m_variableCollection; = - = + VariableCollection *m_variableCollection; + bool m_uiInitialized =3D false; }; = diff --git a/kdevplatform/shell/debugger/kdevdebuggershellui.rc b/kdevplatf= orm/shell/debugger/kdevdebuggershellui.rc index 669c3a4eb5..b82f24634c 100644 --- a/kdevplatform/shell/debugger/kdevdebuggershellui.rc +++ b/kdevplatform/shell/debugger/kdevdebuggershellui.rc @@ -1,11 +1,11 @@ - + - = + @@ -13,14 +13,14 @@ - = + - = + - = + Debugger Toolbar @@ -29,7 +29,7 @@ - = + @@ -43,6 +43,7 @@ + @@ -55,6 +56,7 @@ + @@ -70,6 +72,7 @@ + @@ -85,6 +88,7 @@ +