From 43cad455e1ac10d93d476472b6567ef12428e034 Mon Sep 17 00:00:00 2001 From: leutwe Date: Fri, 18 Feb 2022 21:24:07 +0100 Subject: [PATCH 01/11] At output window ensureCursorVisible() added. Through that change new added text to the output window is shown. --- kdbg/ttywnd.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/kdbg/ttywnd.cpp b/kdbg/ttywnd.cpp index 82ae80ad..31d6c91b 100644 --- a/kdbg/ttywnd.cpp +++ b/kdbg/ttywnd.cpp @@ -205,6 +205,7 @@ void TTYWindow::slotAppend(char* buffer, int count) m_pos.insertText(QString('\n')); } } + ensureCursorVisible(); } void TTYWindow::contextMenuEvent(QContextMenuEvent *event) From b3ab62cf4bab3ad353ff45fbdda791b8ca9f39ef Mon Sep 17 00:00:00 2001 From: leutwe Date: Fri, 18 Feb 2022 21:42:44 +0100 Subject: [PATCH 02/11] Goto line dialog added. --- kdbg/dbgmainwnd.cpp | 4 +++ kdbg/dbgmainwnd.h | 1 + kdbg/sourcewnd.cpp | 24 +++++++++++++++++ kdbg/sourcewnd.h | 6 +++++ kdbg/winstack.cpp | 64 +++++++++++++++++++++++++++++++++++++++++++++ kdbg/winstack.h | 26 ++++++++++++++++++ 6 files changed, 125 insertions(+) diff --git a/kdbg/dbgmainwnd.cpp b/kdbg/dbgmainwnd.cpp index e0c061b7..f0cefeb6 100644 --- a/kdbg/dbgmainwnd.cpp +++ b/kdbg/dbgmainwnd.cpp @@ -119,6 +119,7 @@ DebuggerMainWnd::DebuggerMainWnd() : connect(m_watches, SIGNAL(textDropped(const QString&)), SLOT(slotAddWatch(const QString&))); connect(&m_filesWindow->m_findDlg, SIGNAL(closed()), SLOT(updateUI())); + connect(&m_filesWindow->m_gotoDlg, SIGNAL(closed()), SLOT(updateUI())); connect(m_filesWindow, SIGNAL(newFileLoaded()), SLOT(slotNewFileLoaded())); connect(m_filesWindow, SIGNAL(toggleBreak(const QString&,int,const DbgAddr&,bool)), @@ -277,6 +278,7 @@ void DebuggerMainWnd::initKAction() m_findAction = KStandardAction::find(m_filesWindow, SLOT(slotViewFind()), actionCollection()); KStandardAction::findNext(m_filesWindow, SLOT(slotFindForward()), actionCollection()); KStandardAction::findPrev(m_filesWindow, SLOT(slotFindBackward()), actionCollection()); + m_gotoAction = KStandardAction::gotoLine(m_filesWindow, SLOT(slotViewGoto()), actionCollection()); struct { QWidget* w; QString id; QAction** act; } dw[] = { { m_btWindow, "view_stack", &m_btWindowAction }, @@ -516,6 +518,8 @@ void DebuggerMainWnd::updateUI() { m_findAction->setChecked(m_filesWindow->m_findDlg.isVisible()); m_findAction->setEnabled(m_filesWindow->hasWindows()); + m_gotoAction->setChecked(m_filesWindow->m_gotoDlg.isVisible()); + m_gotoAction->setEnabled(m_filesWindow->hasWindows()); m_bpSetAction->setEnabled(m_debugger->canChangeBreakpoints()); m_bpSetTempAction->setEnabled(m_debugger->canChangeBreakpoints()); m_bpEnableAction->setEnabled(m_debugger->canChangeBreakpoints()); diff --git a/kdbg/dbgmainwnd.h b/kdbg/dbgmainwnd.h index a1e4d6ff..f6ebcbbd 100644 --- a/kdbg/dbgmainwnd.h +++ b/kdbg/dbgmainwnd.h @@ -87,6 +87,7 @@ class DebuggerMainWnd : public KXmlGuiWindow QAction* m_coreDumpAction; QAction* m_settingsAction; QAction* m_findAction; + QAction* m_gotoAction; QAction* m_btWindowAction; QAction* m_localVariablesAction; QAction* m_watchesAction; diff --git a/kdbg/sourcewnd.cpp b/kdbg/sourcewnd.cpp index 6f70599b..562e41c2 100644 --- a/kdbg/sourcewnd.cpp +++ b/kdbg/sourcewnd.cpp @@ -339,6 +339,30 @@ void SourceWindow::find(const QString& text, bool caseSensitive, FindDirection d setTextCursor(cursor); } +void SourceWindow::gotoLine( const QString& text) +{ + bool isSuc_b; + + int lineGoto_i; /*< Line to go to. */ + { /* lineGoto_i */ + lineGoto_i = text.toInt( &isSuc_b ); + if ( ! isSuc_b ) + { + return; + } + } + + QTextDocument* document_po = document(); + QTextCursor cursor_o( document_po ); + cursor_o.setPosition( 0 ); /*< Goto file first line. */ + + lineGoto_i--; + isSuc_b = cursor_o.movePosition( QTextCursor::Down, + QTextCursor::MoveAnchor, lineGoto_i ); + + setTextCursor( cursor_o ); +} + void SourceWindow::infoMousePress(QMouseEvent* ev) { // we handle left and middle button diff --git a/kdbg/sourcewnd.h b/kdbg/sourcewnd.h index 8eb55661..a4094e36 100644 --- a/kdbg/sourcewnd.h +++ b/kdbg/sourcewnd.h @@ -35,6 +35,12 @@ class SourceWindow : public QPlainTextEdit void setPC(bool set, int lineNo, const DbgAddr& address, int frameNo); enum FindDirection { findForward = 1, findBackward = -1 }; void find(const QString& text, bool caseSensitive, FindDirection dir); + + /** Goto line. + + \param[in] text Line number as text. + */ + void gotoLine( const QString& text); bool wordAtPoint(const QPoint& p, QString& word, QRect& r); /** * Translates row number (zero-based) to zero-based source line number. diff --git a/kdbg/winstack.cpp b/kdbg/winstack.cpp index 45ea5a00..4d52e9a7 100644 --- a/kdbg/winstack.cpp +++ b/kdbg/winstack.cpp @@ -31,6 +31,9 @@ WinStack::WinStack(QWidget* parent) : connect(&m_findDlg.m_buttonBackward, SIGNAL(clicked()), SLOT(slotFindBackward())); + connect( &m_gotoDlg.m_lineText, + SIGNAL( returnPressed() ), SLOT(slotGotoLine() ) ); + connect(this, SIGNAL(setTabWidth(int)), this, SLOT(slotSetTabWidth(int))); connect(this, SIGNAL(tabCloseRequested(int)), this, SLOT(slotCloseTab(int))); @@ -245,6 +248,14 @@ void WinStack::slotFindBackward() SourceWindow::findBackward); } +void WinStack::slotGotoLine() +{ + if (activeWindow() != 0) + activeWindow()->gotoLine( m_gotoDlg.lineText() ); + + m_gotoDlg.done( 1 ); /*< Hide Dialog. */ +} + bool WinStack::event(QEvent* evt) { if (evt->type() != QEvent::ToolTip) @@ -335,6 +346,18 @@ void WinStack::slotViewFind() } } +void WinStack::slotViewGoto() +{ + if (m_gotoDlg.isVisible()) + { + m_gotoDlg.done(0); + } + else + { + m_gotoDlg.show(); + } +} + void WinStack::slotBrkptSet() { QString file; @@ -437,3 +460,44 @@ void FindDialog::done(int result) QDialog::done(result); emit closed(); } + + +GotoDialog::GotoDialog() : + QDialog( ), + m_lineText(this), + m_buttonClose(this) +{ + setWindowTitle(i18n("Goto line")); + setWindowModality( Qt::ApplicationModal ); + setWindowFlags( windowFlags() | Qt::WindowStaysOnTopHint ); + + m_lineText.setMinimumSize(100, 24); + m_lineText.setMaxLength(10000); + m_lineText.setFrame(true); + m_lineText.setFocus(); + + m_buttonClose.setText(i18n("Close")); + connect(&m_buttonClose, SIGNAL(clicked()), SLOT(reject())); + + m_layout.addWidget(&m_lineText); + m_layout.addWidget(&m_buttonClose); + + setLayout(&m_layout); +} + +GotoDialog::~GotoDialog() +{ +} + +void GotoDialog::closeEvent(QCloseEvent* ev) +{ + QDialog::closeEvent(ev); + emit closed(); +} + +void GotoDialog::done(int result) +{ + QDialog::done(result); + emit closed(); +} + diff --git a/kdbg/winstack.h b/kdbg/winstack.h index 173378e3..7554d344 100644 --- a/kdbg/winstack.h +++ b/kdbg/winstack.h @@ -50,6 +50,29 @@ class FindDialog : public QDialog }; +/** Class for goto line dialog. */ +class GotoDialog : public QDialog +{ + Q_OBJECT +public: + GotoDialog(); + ~GotoDialog(); + + QString lineText() const { return m_lineText.text(); } + void done(int result) override; + + QLineEdit m_lineText; + QPushButton m_buttonClose; + +signals: + void closed(); + +protected: + void closeEvent(QCloseEvent* ev) override; + QHBoxLayout m_layout; +}; + + class WinStack : public QTabWidget { Q_OBJECT @@ -84,6 +107,7 @@ class WinStack : public QTabWidget public slots: virtual void slotFindForward(); virtual void slotFindBackward(); + virtual void slotGotoLine(); virtual void activate(const QString& filename, int lineNo, const DbgAddr& address); void updatePC(const QString& filename, int lineNo, const DbgAddr& address, int frameNo); void reloadAllFiles(); @@ -92,6 +116,7 @@ public slots: void slotFileReload(); void slotViewFind(); + void slotViewGoto(); void slotBrkptSet(); void slotBrkptSetTemp(); void slotBrkptEnable(); @@ -137,6 +162,7 @@ public slots: public: // find dialog FindDialog m_findDlg; + GotoDialog m_gotoDlg; /**< Object goto dialog. */ }; #endif // WINSTACK_H From 1d4e901390873abdab9af81600919fbd92641bc5 Mon Sep 17 00:00:00 2001 From: leutwe Date: Fri, 18 Feb 2022 21:51:20 +0100 Subject: [PATCH 03/11] Preferences Back Timeout: 0 has now special meaning. Through setting the preference to 0 the program will not actively going into the background, but raise it in case of a stop of the debuge. --- kdbg/dbgmainwnd.cpp | 11 ++++++++--- kdbg/prefmisc.cpp | 7 ++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/kdbg/dbgmainwnd.cpp b/kdbg/dbgmainwnd.cpp index f0cefeb6..4d32d585 100644 --- a/kdbg/dbgmainwnd.cpp +++ b/kdbg/dbgmainwnd.cpp @@ -1085,9 +1085,14 @@ void DebuggerMainWnd::slotProgramStopped() void DebuggerMainWnd::intoBackground() { - if (m_popForeground) { - m_backTimer.setSingleShot(true); - m_backTimer.start(m_backTimeout); + if ( m_popForeground ) + { + const int backTimeout_Ci = this->m_backTimeout; + if ( backTimeout_Ci != 0 ) + { + m_backTimer.setSingleShot( true ); + m_backTimer.start( backTimeout_Ci ); + } } } diff --git a/kdbg/prefmisc.cpp b/kdbg/prefmisc.cpp index aba3c28d..d8d54d49 100644 --- a/kdbg/prefmisc.cpp +++ b/kdbg/prefmisc.cpp @@ -25,9 +25,14 @@ PrefMisc::PrefMisc(QWidget* parent) : m_grid.addWidget(&m_popForeground, 0, 0, 1, 2); m_grid.addItem(new QSpacerItem(0, m_popForeground.sizeHint().height()), 0, 0); - m_backTimeoutLabel.setText(i18n("Time until window goes &back (in milliseconds):")); + m_backTimeoutLabel.setText(i18n("Time until window goes &back [ms] (0 = off):")); + const QString backTimeoutTT_Cqs( i18n("Time in ms. 0 has the special " + "meaning of not actively going into the background, but raise it in " + "case of a stop of the debuge.") ); + m_backTimeoutLabel.setToolTip( backTimeoutTT_Cqs ); m_backTimeoutLabel.setMinimumSize(m_backTimeoutLabel.sizeHint()); m_backTimeoutLabel.setBuddy(&m_backTimeout); + m_backTimeout.setToolTip( backTimeoutTT_Cqs ); m_backTimeout.setMinimumSize(m_backTimeout.sizeHint()); m_grid.addWidget(&m_backTimeoutLabel, 1, 0); m_grid.addWidget(&m_backTimeout, 1, 1); From 4de13af77ec745c821702447ee64579aae52c06f Mon Sep 17 00:00:00 2001 From: leutwe Date: Fri, 18 Feb 2022 21:57:17 +0100 Subject: [PATCH 04/11] Remove of typeid check against XsldbgDriver. Through that rtti compiler option can be removed. I my option this leads to better runtime performance. --- kdbg/dbgmainwnd.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/kdbg/dbgmainwnd.cpp b/kdbg/dbgmainwnd.cpp index 4d32d585..e2f18d27 100644 --- a/kdbg/dbgmainwnd.cpp +++ b/kdbg/dbgmainwnd.cpp @@ -46,7 +46,6 @@ #include "gdbdriver.h" #include "xsldbgdriver.h" #include "mydebug.h" -#include #include /* mknod(2) */ #include /* getpid */ @@ -719,9 +718,6 @@ bool DebuggerMainWnd::startDriver(const QString& executable, QString lang) KMessageBox::sorry(this, msg.arg(lang)); return false; } - if (typeid(*driver) == typeid(XsldbgDriver)) { - KMessageBox::information(this, i18n("XSL debugging is no longer supported and will be removed in a future version of KDbg")); - } driver->setLogFileName(m_transcriptFile); From b79e229dd9675fb3c2f93070e7b0218d8ba7fbd7 Mon Sep 17 00:00:00 2001 From: leutwe Date: Wed, 23 Feb 2022 23:22:59 +0100 Subject: [PATCH 05/11] Lower window configurable If "Pop into foreground when program stops" is requested, it is now possible to disable the lowering of the window. --- kdbg/dbgmainwnd.cpp | 13 +++++++++---- kdbg/dbgmainwnd.h | 1 + kdbg/prefmisc.cpp | 18 ++++++++---------- kdbg/prefmisc.h | 22 +++++++++++++++++++--- 4 files changed, 37 insertions(+), 17 deletions(-) diff --git a/kdbg/dbgmainwnd.cpp b/kdbg/dbgmainwnd.cpp index e2f18d27..29b24f96 100644 --- a/kdbg/dbgmainwnd.cpp +++ b/kdbg/dbgmainwnd.cpp @@ -64,6 +64,7 @@ DebuggerMainWnd::DebuggerMainWnd() : m_outputTermProc(new QProcess), m_ttyLevel(-1), /* no tty yet */ m_popForeground(false), + m_lowerWindow(false), m_backTimeout(1000), m_tabWidth(0), m_sourceFilter(defaultSourceFilter), @@ -442,6 +443,7 @@ static const char DebuggerGroup[] = "Debugger"; static const char DebuggerCmdStr[] = "DebuggerCmdStr"; static const char PreferencesGroup[] = "Preferences"; static const char PopForeground[] = "PopForeground"; +static const char LowerWindow[] = "LowerWindow"; static const char BackTimeout[] = "BackTimeout"; static const char TabWidth[] = "TabWidth"; static const char SourceFileFilter[] = "SourceFileFilter"; @@ -465,6 +467,7 @@ void DebuggerMainWnd::saveSettings(KSharedConfigPtr config) KConfigGroup pg(config->group(PreferencesGroup)); pg.writeEntry(PopForeground, m_popForeground); + pg.writeEntry(LowerWindow, m_lowerWindow); pg.writeEntry(BackTimeout, m_backTimeout); pg.writeEntry(TabWidth, m_tabWidth); pg.writeEntry(SourceFileFilter, m_sourceFilter); @@ -502,6 +505,7 @@ void DebuggerMainWnd::restoreSettings(KSharedConfigPtr config) KConfigGroup pg(config->group(PreferencesGroup)); m_popForeground = pg.readEntry(PopForeground, false); + m_lowerWindow = pg.readEntry(LowerWindow, false); m_backTimeout = pg.readEntry(BackTimeout, 1000); m_tabWidth = pg.readEntry(TabWidth, 0); m_sourceFilter = pg.readEntry(SourceFileFilter, m_sourceFilter); @@ -858,6 +862,7 @@ void DebuggerMainWnd::slotFileGlobalSettings() PrefMisc prefMisc(&dlg); prefMisc.setPopIntoForeground(m_popForeground); + prefMisc.setLowerWindow(m_lowerWindow); prefMisc.setBackTimeout(m_backTimeout); prefMisc.setTabWidth(m_tabWidth); prefMisc.setSourceFilter(m_sourceFilter); @@ -871,6 +876,7 @@ void DebuggerMainWnd::slotFileGlobalSettings() setDebuggerCmdStr(prefDebugger.debuggerCmd()); setTerminalCmd(prefDebugger.terminal()); m_popForeground = prefMisc.popIntoForeground(); + m_lowerWindow = prefMisc.isLowerWindowRqed(); m_backTimeout = prefMisc.backTimeout(); m_tabWidth = prefMisc.tabWidth(); m_sourceFilter = prefMisc.sourceFilter(); @@ -1083,11 +1089,10 @@ void DebuggerMainWnd::intoBackground() { if ( m_popForeground ) { - const int backTimeout_Ci = this->m_backTimeout; - if ( backTimeout_Ci != 0 ) + if ( m_lowerWindow ) { - m_backTimer.setSingleShot( true ); - m_backTimer.start( backTimeout_Ci ); + m_backTimer.setSingleShot(true); + m_backTimer.start m_backTimeout); } } } diff --git a/kdbg/dbgmainwnd.h b/kdbg/dbgmainwnd.h index f6ebcbbd..e74341dc 100644 --- a/kdbg/dbgmainwnd.h +++ b/kdbg/dbgmainwnd.h @@ -150,6 +150,7 @@ class DebuggerMainWnd : public KXmlGuiWindow QString createOutputWindow(); bool m_popForeground; /* whether main wnd raises when prog stops */ + bool m_lowerWindow; /* whether m_backTimeout is used. */ int m_backTimeout; /* when wnd goes back */ int m_tabWidth; /* tab width in characters (can be 0) */ QString m_sourceFilter; diff --git a/kdbg/prefmisc.cpp b/kdbg/prefmisc.cpp index d8d54d49..58af36fe 100644 --- a/kdbg/prefmisc.cpp +++ b/kdbg/prefmisc.cpp @@ -11,7 +11,7 @@ PrefMisc::PrefMisc(QWidget* parent) : QWidget(parent), m_grid(this), m_popForeground(this), - m_backTimeoutLabel(this), + m_lowerWindow(this), m_backTimeout(this), m_tabWidthLabel(this), m_tabWidth(this), @@ -22,19 +22,17 @@ PrefMisc::PrefMisc(QWidget* parent) : { m_popForeground.setText(i18n("&Pop into foreground when program stops")); m_popForeground.setMinimumSize(m_popForeground.sizeHint()); + connect( &m_popForeground, SIGNAL(toggled(bool)), this, SLOT(setPopIntoForeground(bool)) ); m_grid.addWidget(&m_popForeground, 0, 0, 1, 2); m_grid.addItem(new QSpacerItem(0, m_popForeground.sizeHint().height()), 0, 0); - m_backTimeoutLabel.setText(i18n("Time until window goes &back [ms] (0 = off):")); - const QString backTimeoutTT_Cqs( i18n("Time in ms. 0 has the special " - "meaning of not actively going into the background, but raise it in " - "case of a stop of the debuge.") ); - m_backTimeoutLabel.setToolTip( backTimeoutTT_Cqs ); - m_backTimeoutLabel.setMinimumSize(m_backTimeoutLabel.sizeHint()); - m_backTimeoutLabel.setBuddy(&m_backTimeout); - m_backTimeout.setToolTip( backTimeoutTT_Cqs ); + m_lowerWindow.setText(i18n("&Lower window after [ms]:")); + const QString backTimeoutTT_Cqs( i18n("Lower the kdbg window with continuing execution of the debuge.") ); + m_lowerWindow.setToolTip( backTimeoutTT_Cqs ); + m_lowerWindow.setMinimumSize(m_lowerWindow.sizeHint()); + connect( &m_lowerWindow, SIGNAL(toggled(bool)), this, SLOT(setLowerWindow(bool)) ); m_backTimeout.setMinimumSize(m_backTimeout.sizeHint()); - m_grid.addWidget(&m_backTimeoutLabel, 1, 0); + m_grid.addWidget(&m_lowerWindow, 1, 0); m_grid.addWidget(&m_backTimeout, 1, 1); setupEditGroup(i18n("&Tabstop every (characters):"), diff --git a/kdbg/prefmisc.h b/kdbg/prefmisc.h index fc90cc5d..41ba4d70 100644 --- a/kdbg/prefmisc.h +++ b/kdbg/prefmisc.h @@ -14,6 +14,7 @@ class PrefMisc : public QWidget { + Q_OBJECT public: PrefMisc(QWidget* parent); @@ -21,8 +22,7 @@ class PrefMisc : public QWidget protected: QCheckBox m_popForeground; - - QLabel m_backTimeoutLabel; + QCheckBox m_lowerWindow; QLineEdit m_backTimeout; QLabel m_tabWidthLabel; @@ -37,7 +37,7 @@ class PrefMisc : public QWidget public: bool popIntoForeground() const { return m_popForeground.isChecked(); } - void setPopIntoForeground(bool pop) { m_popForeground.setChecked(pop); } + bool isLowerWindowRqed() const { return m_lowerWindow.isChecked(); } int backTimeout() const; void setBackTimeout(int to); int tabWidth() const; @@ -46,6 +46,22 @@ class PrefMisc : public QWidget void setSourceFilter(const QString& f) { m_sourceFilter.setText(f); } QString headerFilter() const { return m_headerFilter.text(); } void setHeaderFilter(const QString& f) { m_headerFilter.setText(f); } + +public slots: + void setPopIntoForeground(bool pop) + { + m_popForeground.setChecked(pop); + m_lowerWindow.setEnabled(pop); + if ( isLowerWindowRqed() ) + { + m_backTimeout.setEnabled(pop); + } + } + void setLowerWindow(bool is) + { + m_lowerWindow.setChecked(is); + m_backTimeout.setEnabled(is); + } }; #endif // PREFMISC_H From c937e4496b99db5797a16830f8764b1d42f40b37 Mon Sep 17 00:00:00 2001 From: leutwe Date: Thu, 24 Feb 2022 20:53:23 +0100 Subject: [PATCH 06/11] Lower window configurable If "Pop into foreground when program stops" is requested, it is now possible to disable the lowering of the window. --- kdbg/dbgmainwnd.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kdbg/dbgmainwnd.cpp b/kdbg/dbgmainwnd.cpp index 29b24f96..e112c14f 100644 --- a/kdbg/dbgmainwnd.cpp +++ b/kdbg/dbgmainwnd.cpp @@ -1087,12 +1087,12 @@ void DebuggerMainWnd::slotProgramStopped() void DebuggerMainWnd::intoBackground() { - if ( m_popForeground ) + if (m_popForeground) { - if ( m_lowerWindow ) + if (m_lowerWindow) { m_backTimer.setSingleShot(true); - m_backTimer.start m_backTimeout); + m_backTimer.start(m_backTimeout); } } } From b867e1ed0033ffdaa8a404e0d47130f945e94004 Mon Sep 17 00:00:00 2001 From: leutwe Date: Thu, 24 Feb 2022 21:00:53 +0100 Subject: [PATCH 07/11] Goto line dialog Label at dialog added. --- kdbg/winstack.cpp | 15 ++++++++++----- kdbg/winstack.h | 2 ++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/kdbg/winstack.cpp b/kdbg/winstack.cpp index 4d52e9a7..5e500819 100644 --- a/kdbg/winstack.cpp +++ b/kdbg/winstack.cpp @@ -463,14 +463,18 @@ void FindDialog::done(int result) GotoDialog::GotoDialog() : - QDialog( ), - m_lineText(this), - m_buttonClose(this) + QDialog(), + m_label(this), + m_lineText(this), + m_buttonClose(this) { - setWindowTitle(i18n("Goto line")); + const QString label(i18n("Goto line")); + setWindowTitle(label); setWindowModality( Qt::ApplicationModal ); setWindowFlags( windowFlags() | Qt::WindowStaysOnTopHint ); - + + m_label.setText(label); + m_lineText.setMinimumSize(100, 24); m_lineText.setMaxLength(10000); m_lineText.setFrame(true); @@ -479,6 +483,7 @@ GotoDialog::GotoDialog() : m_buttonClose.setText(i18n("Close")); connect(&m_buttonClose, SIGNAL(clicked()), SLOT(reject())); + m_layout.addWidget(&m_label); m_layout.addWidget(&m_lineText); m_layout.addWidget(&m_buttonClose); diff --git a/kdbg/winstack.h b/kdbg/winstack.h index 7554d344..8a71996a 100644 --- a/kdbg/winstack.h +++ b/kdbg/winstack.h @@ -8,6 +8,7 @@ #define WINSTACK_H #include +#include #include #include #include @@ -61,6 +62,7 @@ class GotoDialog : public QDialog QString lineText() const { return m_lineText.text(); } void done(int result) override; + QLabel m_label; QLineEdit m_lineText; QPushButton m_buttonClose; From a092fa4f23e736a327bd16b8e161b25cfda998f6 Mon Sep 17 00:00:00 2001 From: leutwe Date: Fri, 18 Feb 2022 21:42:44 +0100 Subject: [PATCH 08/11] WIP Add a Goto Line dialog. TODO: fix position in application menu, skip assembly lines, needs OK button --- kdbg/dbgmainwnd.cpp | 4 +++ kdbg/dbgmainwnd.h | 1 + kdbg/sourcewnd.cpp | 15 ++++++++++ kdbg/sourcewnd.h | 4 +++ kdbg/winstack.cpp | 68 +++++++++++++++++++++++++++++++++++++++++++++ kdbg/winstack.h | 28 +++++++++++++++++++ 6 files changed, 120 insertions(+) diff --git a/kdbg/dbgmainwnd.cpp b/kdbg/dbgmainwnd.cpp index e0c061b7..172b21b0 100644 --- a/kdbg/dbgmainwnd.cpp +++ b/kdbg/dbgmainwnd.cpp @@ -119,6 +119,7 @@ DebuggerMainWnd::DebuggerMainWnd() : connect(m_watches, SIGNAL(textDropped(const QString&)), SLOT(slotAddWatch(const QString&))); connect(&m_filesWindow->m_findDlg, SIGNAL(closed()), SLOT(updateUI())); + connect(&m_filesWindow->m_gotoDlg, SIGNAL(closed()), SLOT(updateUI())); connect(m_filesWindow, SIGNAL(newFileLoaded()), SLOT(slotNewFileLoaded())); connect(m_filesWindow, SIGNAL(toggleBreak(const QString&,int,const DbgAddr&,bool)), @@ -277,6 +278,7 @@ void DebuggerMainWnd::initKAction() m_findAction = KStandardAction::find(m_filesWindow, SLOT(slotViewFind()), actionCollection()); KStandardAction::findNext(m_filesWindow, SLOT(slotFindForward()), actionCollection()); KStandardAction::findPrev(m_filesWindow, SLOT(slotFindBackward()), actionCollection()); + m_gotoAction = KStandardAction::gotoLine(m_filesWindow, &WinStack::slotViewGoto, actionCollection()); struct { QWidget* w; QString id; QAction** act; } dw[] = { { m_btWindow, "view_stack", &m_btWindowAction }, @@ -516,6 +518,8 @@ void DebuggerMainWnd::updateUI() { m_findAction->setChecked(m_filesWindow->m_findDlg.isVisible()); m_findAction->setEnabled(m_filesWindow->hasWindows()); + m_gotoAction->setChecked(m_filesWindow->m_gotoDlg.isVisible()); + m_gotoAction->setEnabled(m_filesWindow->hasWindows()); m_bpSetAction->setEnabled(m_debugger->canChangeBreakpoints()); m_bpSetTempAction->setEnabled(m_debugger->canChangeBreakpoints()); m_bpEnableAction->setEnabled(m_debugger->canChangeBreakpoints()); diff --git a/kdbg/dbgmainwnd.h b/kdbg/dbgmainwnd.h index a1e4d6ff..f6ebcbbd 100644 --- a/kdbg/dbgmainwnd.h +++ b/kdbg/dbgmainwnd.h @@ -87,6 +87,7 @@ class DebuggerMainWnd : public KXmlGuiWindow QAction* m_coreDumpAction; QAction* m_settingsAction; QAction* m_findAction; + QAction* m_gotoAction; QAction* m_btWindowAction; QAction* m_localVariablesAction; QAction* m_watchesAction; diff --git a/kdbg/sourcewnd.cpp b/kdbg/sourcewnd.cpp index 6f70599b..9bc06302 100644 --- a/kdbg/sourcewnd.cpp +++ b/kdbg/sourcewnd.cpp @@ -339,6 +339,21 @@ void SourceWindow::find(const QString& text, bool caseSensitive, FindDirection d setTextCursor(cursor); } +void SourceWindow::gotoLine( const QString& text) +{ + bool isSuc; + int lineGoto = text.toInt(&isSuc); + if (!isSuc) + return; + + QTextCursor cursor(document()); + cursor.setPosition(0); // goto file first line + + isSuc = cursor.movePosition(QTextCursor::Down, QTextCursor::MoveAnchor, lineGoto - 1); + + setTextCursor( cursor ); +} + void SourceWindow::infoMousePress(QMouseEvent* ev) { // we handle left and middle button diff --git a/kdbg/sourcewnd.h b/kdbg/sourcewnd.h index 8eb55661..b5626f57 100644 --- a/kdbg/sourcewnd.h +++ b/kdbg/sourcewnd.h @@ -35,6 +35,10 @@ class SourceWindow : public QPlainTextEdit void setPC(bool set, int lineNo, const DbgAddr& address, int frameNo); enum FindDirection { findForward = 1, findBackward = -1 }; void find(const QString& text, bool caseSensitive, FindDirection dir); + /** + * Scrolls to the specified line number given as text + */ + void gotoLine( const QString& text); bool wordAtPoint(const QPoint& p, QString& word, QRect& r); /** * Translates row number (zero-based) to zero-based source line number. diff --git a/kdbg/winstack.cpp b/kdbg/winstack.cpp index 45ea5a00..7be217d2 100644 --- a/kdbg/winstack.cpp +++ b/kdbg/winstack.cpp @@ -31,6 +31,9 @@ WinStack::WinStack(QWidget* parent) : connect(&m_findDlg.m_buttonBackward, SIGNAL(clicked()), SLOT(slotFindBackward())); + connect( &m_gotoDlg.m_lineText, + SIGNAL(returnPressed()), SLOT(slotGotoLine())); + connect(this, SIGNAL(setTabWidth(int)), this, SLOT(slotSetTabWidth(int))); connect(this, SIGNAL(tabCloseRequested(int)), this, SLOT(slotCloseTab(int))); @@ -245,6 +248,14 @@ void WinStack::slotFindBackward() SourceWindow::findBackward); } +void WinStack::slotGotoLine() +{ + if (activeWindow() != 0) + activeWindow()->gotoLine(m_gotoDlg.lineText()); + + m_gotoDlg.done(1); // hide dialog +} + bool WinStack::event(QEvent* evt) { if (evt->type() != QEvent::ToolTip) @@ -335,6 +346,18 @@ void WinStack::slotViewFind() } } +void WinStack::slotViewGoto() +{ + if (m_gotoDlg.isVisible()) + { + m_gotoDlg.done(0); + } + else + { + m_gotoDlg.show(); + } +} + void WinStack::slotBrkptSet() { QString file; @@ -437,3 +460,48 @@ void FindDialog::done(int result) QDialog::done(result); emit closed(); } + + +GotoDialog::GotoDialog() : + QDialog(), + m_label(this), + m_lineText(this), + m_buttonClose(this) +{ + const QString label(i18n("Goto line")); + setWindowTitle(label); + setWindowModality( Qt::ApplicationModal ); + setWindowFlags( windowFlags() | Qt::WindowStaysOnTopHint ); + + m_label.setText(label); + + m_lineText.setMinimumSize(100, 24); + m_lineText.setMaxLength(10000); + m_lineText.setFrame(true); + m_lineText.setFocus(); + + m_buttonClose.setText(i18n("Close")); + connect(&m_buttonClose, SIGNAL(clicked()), SLOT(reject())); + + m_layout.addWidget(&m_label); + m_layout.addWidget(&m_lineText); + m_layout.addWidget(&m_buttonClose); + + setLayout(&m_layout); +} + +GotoDialog::~GotoDialog() +{ +} + +void GotoDialog::closeEvent(QCloseEvent* ev) +{ + QDialog::closeEvent(ev); + emit closed(); +} + +void GotoDialog::done(int result) +{ + QDialog::done(result); + emit closed(); +} diff --git a/kdbg/winstack.h b/kdbg/winstack.h index 173378e3..e75f3e3b 100644 --- a/kdbg/winstack.h +++ b/kdbg/winstack.h @@ -8,6 +8,7 @@ #define WINSTACK_H #include +#include #include #include #include @@ -50,6 +51,30 @@ class FindDialog : public QDialog }; +/** Class for Goto Line dialog. */ +class GotoDialog : public QDialog +{ + Q_OBJECT +public: + GotoDialog(); + ~GotoDialog(); + + QString lineText() const { return m_lineText.text(); } + void done(int result) override; + + QLabel m_label; + QLineEdit m_lineText; + QPushButton m_buttonClose; + +signals: + void closed(); + +protected: + void closeEvent(QCloseEvent* ev) override; + QHBoxLayout m_layout; +}; + + class WinStack : public QTabWidget { Q_OBJECT @@ -84,6 +109,7 @@ class WinStack : public QTabWidget public slots: virtual void slotFindForward(); virtual void slotFindBackward(); + virtual void slotGotoLine(); virtual void activate(const QString& filename, int lineNo, const DbgAddr& address); void updatePC(const QString& filename, int lineNo, const DbgAddr& address, int frameNo); void reloadAllFiles(); @@ -92,6 +118,7 @@ public slots: void slotFileReload(); void slotViewFind(); + void slotViewGoto(); void slotBrkptSet(); void slotBrkptSetTemp(); void slotBrkptEnable(); @@ -137,6 +164,7 @@ public slots: public: // find dialog FindDialog m_findDlg; + GotoDialog m_gotoDlg; }; #endif // WINSTACK_H From f915976da9b51e47f123812457582d9d5acfa59e Mon Sep 17 00:00:00 2001 From: leutwe Date: Fri, 18 Feb 2022 21:51:20 +0100 Subject: [PATCH 09/11] Preferences Back Timeout: 0 has now special meaning. Through setting the preference to 0 the program will not actively going into the background, but raise it in case of a stop of the debuge. --- kdbg/dbgmainwnd.cpp | 11 ++++++++--- kdbg/prefmisc.cpp | 7 ++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/kdbg/dbgmainwnd.cpp b/kdbg/dbgmainwnd.cpp index 172b21b0..72fc1f79 100644 --- a/kdbg/dbgmainwnd.cpp +++ b/kdbg/dbgmainwnd.cpp @@ -1085,9 +1085,14 @@ void DebuggerMainWnd::slotProgramStopped() void DebuggerMainWnd::intoBackground() { - if (m_popForeground) { - m_backTimer.setSingleShot(true); - m_backTimer.start(m_backTimeout); + if ( m_popForeground ) + { + const int backTimeout_Ci = this->m_backTimeout; + if ( backTimeout_Ci != 0 ) + { + m_backTimer.setSingleShot( true ); + m_backTimer.start( backTimeout_Ci ); + } } } diff --git a/kdbg/prefmisc.cpp b/kdbg/prefmisc.cpp index aba3c28d..d8d54d49 100644 --- a/kdbg/prefmisc.cpp +++ b/kdbg/prefmisc.cpp @@ -25,9 +25,14 @@ PrefMisc::PrefMisc(QWidget* parent) : m_grid.addWidget(&m_popForeground, 0, 0, 1, 2); m_grid.addItem(new QSpacerItem(0, m_popForeground.sizeHint().height()), 0, 0); - m_backTimeoutLabel.setText(i18n("Time until window goes &back (in milliseconds):")); + m_backTimeoutLabel.setText(i18n("Time until window goes &back [ms] (0 = off):")); + const QString backTimeoutTT_Cqs( i18n("Time in ms. 0 has the special " + "meaning of not actively going into the background, but raise it in " + "case of a stop of the debuge.") ); + m_backTimeoutLabel.setToolTip( backTimeoutTT_Cqs ); m_backTimeoutLabel.setMinimumSize(m_backTimeoutLabel.sizeHint()); m_backTimeoutLabel.setBuddy(&m_backTimeout); + m_backTimeout.setToolTip( backTimeoutTT_Cqs ); m_backTimeout.setMinimumSize(m_backTimeout.sizeHint()); m_grid.addWidget(&m_backTimeoutLabel, 1, 0); m_grid.addWidget(&m_backTimeout, 1, 1); From 41773a7fd326dc306b4acb95dc32900545dda427 Mon Sep 17 00:00:00 2001 From: leutwe Date: Wed, 23 Feb 2022 23:22:59 +0100 Subject: [PATCH 10/11] Lower window configurable If "Pop into foreground when program stops" is requested, it is now possible to disable the lowering of the window. --- kdbg/dbgmainwnd.cpp | 15 ++++++++++----- kdbg/dbgmainwnd.h | 1 + kdbg/prefmisc.cpp | 18 ++++++++---------- kdbg/prefmisc.h | 22 +++++++++++++++++++--- 4 files changed, 38 insertions(+), 18 deletions(-) diff --git a/kdbg/dbgmainwnd.cpp b/kdbg/dbgmainwnd.cpp index 72fc1f79..35d9832b 100644 --- a/kdbg/dbgmainwnd.cpp +++ b/kdbg/dbgmainwnd.cpp @@ -65,6 +65,7 @@ DebuggerMainWnd::DebuggerMainWnd() : m_outputTermProc(new QProcess), m_ttyLevel(-1), /* no tty yet */ m_popForeground(false), + m_lowerWindow(false), m_backTimeout(1000), m_tabWidth(0), m_sourceFilter(defaultSourceFilter), @@ -443,6 +444,7 @@ static const char DebuggerGroup[] = "Debugger"; static const char DebuggerCmdStr[] = "DebuggerCmdStr"; static const char PreferencesGroup[] = "Preferences"; static const char PopForeground[] = "PopForeground"; +static const char LowerWindow[] = "LowerWindow"; static const char BackTimeout[] = "BackTimeout"; static const char TabWidth[] = "TabWidth"; static const char SourceFileFilter[] = "SourceFileFilter"; @@ -466,6 +468,7 @@ void DebuggerMainWnd::saveSettings(KSharedConfigPtr config) KConfigGroup pg(config->group(PreferencesGroup)); pg.writeEntry(PopForeground, m_popForeground); + pg.writeEntry(LowerWindow, m_lowerWindow); pg.writeEntry(BackTimeout, m_backTimeout); pg.writeEntry(TabWidth, m_tabWidth); pg.writeEntry(SourceFileFilter, m_sourceFilter); @@ -503,6 +506,7 @@ void DebuggerMainWnd::restoreSettings(KSharedConfigPtr config) KConfigGroup pg(config->group(PreferencesGroup)); m_popForeground = pg.readEntry(PopForeground, false); + m_lowerWindow = pg.readEntry(LowerWindow, false); m_backTimeout = pg.readEntry(BackTimeout, 1000); m_tabWidth = pg.readEntry(TabWidth, 0); m_sourceFilter = pg.readEntry(SourceFileFilter, m_sourceFilter); @@ -862,6 +866,7 @@ void DebuggerMainWnd::slotFileGlobalSettings() PrefMisc prefMisc(&dlg); prefMisc.setPopIntoForeground(m_popForeground); + prefMisc.setLowerWindow(m_lowerWindow); prefMisc.setBackTimeout(m_backTimeout); prefMisc.setTabWidth(m_tabWidth); prefMisc.setSourceFilter(m_sourceFilter); @@ -875,6 +880,7 @@ void DebuggerMainWnd::slotFileGlobalSettings() setDebuggerCmdStr(prefDebugger.debuggerCmd()); setTerminalCmd(prefDebugger.terminal()); m_popForeground = prefMisc.popIntoForeground(); + m_lowerWindow = prefMisc.isLowerWindowRqed(); m_backTimeout = prefMisc.backTimeout(); m_tabWidth = prefMisc.tabWidth(); m_sourceFilter = prefMisc.sourceFilter(); @@ -1085,13 +1091,12 @@ void DebuggerMainWnd::slotProgramStopped() void DebuggerMainWnd::intoBackground() { - if ( m_popForeground ) + if (m_popForeground) { - const int backTimeout_Ci = this->m_backTimeout; - if ( backTimeout_Ci != 0 ) + if (m_lowerWindow) { - m_backTimer.setSingleShot( true ); - m_backTimer.start( backTimeout_Ci ); + m_backTimer.setSingleShot(true); + m_backTimer.start(m_backTimeout); } } } diff --git a/kdbg/dbgmainwnd.h b/kdbg/dbgmainwnd.h index f6ebcbbd..e74341dc 100644 --- a/kdbg/dbgmainwnd.h +++ b/kdbg/dbgmainwnd.h @@ -150,6 +150,7 @@ class DebuggerMainWnd : public KXmlGuiWindow QString createOutputWindow(); bool m_popForeground; /* whether main wnd raises when prog stops */ + bool m_lowerWindow; /* whether m_backTimeout is used. */ int m_backTimeout; /* when wnd goes back */ int m_tabWidth; /* tab width in characters (can be 0) */ QString m_sourceFilter; diff --git a/kdbg/prefmisc.cpp b/kdbg/prefmisc.cpp index d8d54d49..58af36fe 100644 --- a/kdbg/prefmisc.cpp +++ b/kdbg/prefmisc.cpp @@ -11,7 +11,7 @@ PrefMisc::PrefMisc(QWidget* parent) : QWidget(parent), m_grid(this), m_popForeground(this), - m_backTimeoutLabel(this), + m_lowerWindow(this), m_backTimeout(this), m_tabWidthLabel(this), m_tabWidth(this), @@ -22,19 +22,17 @@ PrefMisc::PrefMisc(QWidget* parent) : { m_popForeground.setText(i18n("&Pop into foreground when program stops")); m_popForeground.setMinimumSize(m_popForeground.sizeHint()); + connect( &m_popForeground, SIGNAL(toggled(bool)), this, SLOT(setPopIntoForeground(bool)) ); m_grid.addWidget(&m_popForeground, 0, 0, 1, 2); m_grid.addItem(new QSpacerItem(0, m_popForeground.sizeHint().height()), 0, 0); - m_backTimeoutLabel.setText(i18n("Time until window goes &back [ms] (0 = off):")); - const QString backTimeoutTT_Cqs( i18n("Time in ms. 0 has the special " - "meaning of not actively going into the background, but raise it in " - "case of a stop of the debuge.") ); - m_backTimeoutLabel.setToolTip( backTimeoutTT_Cqs ); - m_backTimeoutLabel.setMinimumSize(m_backTimeoutLabel.sizeHint()); - m_backTimeoutLabel.setBuddy(&m_backTimeout); - m_backTimeout.setToolTip( backTimeoutTT_Cqs ); + m_lowerWindow.setText(i18n("&Lower window after [ms]:")); + const QString backTimeoutTT_Cqs( i18n("Lower the kdbg window with continuing execution of the debuge.") ); + m_lowerWindow.setToolTip( backTimeoutTT_Cqs ); + m_lowerWindow.setMinimumSize(m_lowerWindow.sizeHint()); + connect( &m_lowerWindow, SIGNAL(toggled(bool)), this, SLOT(setLowerWindow(bool)) ); m_backTimeout.setMinimumSize(m_backTimeout.sizeHint()); - m_grid.addWidget(&m_backTimeoutLabel, 1, 0); + m_grid.addWidget(&m_lowerWindow, 1, 0); m_grid.addWidget(&m_backTimeout, 1, 1); setupEditGroup(i18n("&Tabstop every (characters):"), diff --git a/kdbg/prefmisc.h b/kdbg/prefmisc.h index fc90cc5d..41ba4d70 100644 --- a/kdbg/prefmisc.h +++ b/kdbg/prefmisc.h @@ -14,6 +14,7 @@ class PrefMisc : public QWidget { + Q_OBJECT public: PrefMisc(QWidget* parent); @@ -21,8 +22,7 @@ class PrefMisc : public QWidget protected: QCheckBox m_popForeground; - - QLabel m_backTimeoutLabel; + QCheckBox m_lowerWindow; QLineEdit m_backTimeout; QLabel m_tabWidthLabel; @@ -37,7 +37,7 @@ class PrefMisc : public QWidget public: bool popIntoForeground() const { return m_popForeground.isChecked(); } - void setPopIntoForeground(bool pop) { m_popForeground.setChecked(pop); } + bool isLowerWindowRqed() const { return m_lowerWindow.isChecked(); } int backTimeout() const; void setBackTimeout(int to); int tabWidth() const; @@ -46,6 +46,22 @@ class PrefMisc : public QWidget void setSourceFilter(const QString& f) { m_sourceFilter.setText(f); } QString headerFilter() const { return m_headerFilter.text(); } void setHeaderFilter(const QString& f) { m_headerFilter.setText(f); } + +public slots: + void setPopIntoForeground(bool pop) + { + m_popForeground.setChecked(pop); + m_lowerWindow.setEnabled(pop); + if ( isLowerWindowRqed() ) + { + m_backTimeout.setEnabled(pop); + } + } + void setLowerWindow(bool is) + { + m_lowerWindow.setChecked(is); + m_backTimeout.setEnabled(is); + } }; #endif // PREFMISC_H From cf1cff8485bd9d746d7c285634f32ebc15d9e588 Mon Sep 17 00:00:00 2001 From: leutwe Date: Wed, 6 Apr 2022 19:30:04 +0200 Subject: [PATCH 11/11] Goto line dialog Do not count assembly lines if visible. --- kdbg/sourcewnd.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/kdbg/sourcewnd.cpp b/kdbg/sourcewnd.cpp index 9bc06302..ebc9f9fb 100644 --- a/kdbg/sourcewnd.cpp +++ b/kdbg/sourcewnd.cpp @@ -344,12 +344,26 @@ void SourceWindow::gotoLine( const QString& text) bool isSuc; int lineGoto = text.toInt(&isSuc); if (!isSuc) - return; + { + return; + } + + { /* Because of assert at lineToRow(): */ + if ( m_rowToLine.size() == 0 ) + { + return; + } + if ( static_cast(lineGoto) >= m_rowToLine.size() ) + { + lineGoto = m_rowToLine.size() - 1; + } + } + int row = lineToRow(lineGoto); /*< if assembly is visible row != line. */ QTextCursor cursor(document()); cursor.setPosition(0); // goto file first line - isSuc = cursor.movePosition(QTextCursor::Down, QTextCursor::MoveAnchor, lineGoto - 1); + isSuc = cursor.movePosition(QTextCursor::Down, QTextCursor::MoveAnchor, row - 1); setTextCursor( cursor ); }