diff --git a/NEWS.md b/NEWS.md new file mode 100644 index 00000000..e69de29b diff --git a/RedPandaIDE/debugger.cpp b/RedPandaIDE/debugger.cpp index 256fcb39..f3aac1de 100644 --- a/RedPandaIDE/debugger.cpp +++ b/RedPandaIDE/debugger.cpp @@ -193,6 +193,24 @@ void Debugger::removeBreakpoint(int index) mBreakpointModel->removeBreakpoint(index); } +PBreakpoint Debugger::breakpointAt(int line, const QString& filename, int &index) +{ + const QList& breakpoints=mBreakpointModel->breakpoints(); + for (index=0;indexline == line + && breakpoint->filename == filename) + return breakpoint; + } + index=-1; + return PBreakpoint(); +} + +PBreakpoint Debugger::breakpointAt(int line, const Editor *editor, int &index) +{ + return breakpointAt(line,editor->filename(),index); +} + void Debugger::setBreakPointCondition(int index, const QString &condition) { PBreakpoint breakpoint=mBreakpointModel->setBreakPointCondition(index,condition); @@ -1441,6 +1459,21 @@ QVariant BreakpointModel::data(const QModelIndex &index, int role) const return QVariant(); switch (role) { case Qt::DisplayRole: + switch (index.column()) { + case 0: { + return baseFileName(breakpoint->filename); + } + case 1: + if (breakpoint->line>0) + return breakpoint->line; + else + return ""; + case 2: + return breakpoint->condition; + default: + return QVariant(); + } + case Qt::ToolTipRole: switch (index.column()) { case 0: return breakpoint->filename; diff --git a/RedPandaIDE/debugger.h b/RedPandaIDE/debugger.h index adcae679..a863d584 100644 --- a/RedPandaIDE/debugger.h +++ b/RedPandaIDE/debugger.h @@ -183,6 +183,8 @@ public: void removeBreakpoint(int line, const Editor* editor); void removeBreakpoint(int line, const QString& filename); void removeBreakpoint(int index); + PBreakpoint breakpointAt(int line, const QString& filename, int &index); + PBreakpoint breakpointAt(int line, const Editor* editor, int &index); void setBreakPointCondition(int index, const QString& condition); void sendAllBreakpointsToDebugger(); diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp index abc2013e..e10eac36 100644 --- a/RedPandaIDE/editor.cpp +++ b/RedPandaIDE/editor.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include "iconsmanager.h" #include "debugger.h" #include "editorlist.h" @@ -2550,6 +2551,13 @@ void Editor::toggleBreakpoint(int line) invalidateLine(line); } +void Editor::clearBreakpoints() +{ + pMainWindow->debugger()->deleteBreakpoints(this); + mBreakpointLines.clear(); + invalidate(); +} + bool Editor::hasBreakpoint(int line) { return mBreakpointLines.contains(line); @@ -2565,6 +2573,23 @@ void Editor::removeBreakpointFocus() } } +void Editor::modifyBreakpointProperty(int line) +{ + int index; + PBreakpoint breakpoint = pMainWindow->debugger()->breakpointAt(line,this,index); + if (!breakpoint) + return; + bool isOk; + QString s=QInputDialog::getText(this, + tr("Break point condition"), + tr("Enter the condition of the breakpoint:"), + QLineEdit::Normal, + breakpoint->condition,&isOk); + if (isOk) { + pMainWindow->debugger()->setBreakPointCondition(index,s); + } +} + void Editor::setActiveBreakpointFocus(int Line, bool setFocus) { if (Line != mActiveBreakpointLine) { diff --git a/RedPandaIDE/editor.h b/RedPandaIDE/editor.h index e7da8325..f6d916fa 100644 --- a/RedPandaIDE/editor.h +++ b/RedPandaIDE/editor.h @@ -132,8 +132,10 @@ public: PSyntaxIssue getSyntaxIssueAtPosition(const BufferCoord& pos); int gutterClickedLine() const; void toggleBreakpoint(int line); + void clearBreakpoints(); bool hasBreakpoint(int line); void removeBreakpointFocus(); + void modifyBreakpointProperty(int line); void setActiveBreakpointFocus(int Line, bool setFocus=true); QString getWordAtPosition(const BufferCoord& p, BufferCoord& pWordBegin, diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index c72f3e21..00ee33b1 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -1144,14 +1144,23 @@ void MainWindow::onEditorContextMenu(const QPoint &pos) if (!editor) return; QMenu menu(this); - menu.addAction(ui->actionCompile_Run); - menu.addAction(ui->actionDebug); - int line = editor->caretY(); - if (editor->hasBreakpoint(line)) { - //todo: breakpoint property + BufferCoord p; + mContextMenuPos = pos; + if (editor->GetPositionOfMouse(p)) { + //mouse on editing area + menu.addAction(ui->actionCompile_Run); + menu.addAction(ui->actionDebug); + menu.addSeparator(); + } else { + //mouse on gutter + int line; + if (!editor->GetLineOfMouse(line)) + line=-1; + menu.addAction(ui->actionToggle_Breakpoint); + menu.addAction(ui->actionBreakpoint_property); + menu.addAction(ui->actionClear_all_breakpoints); + ui->actionBreakpoint_property->setEnabled(editor->hasBreakpoint(line)); } - //todo: goto declaretion - //todo: goto definition menu.exec(editor->viewport()->mapToGlobal(pos)); } @@ -2138,3 +2147,39 @@ void MainWindow::on_actionPrevious_Editor_triggered() mEditorList->selectPreviousPage(); } + +void MainWindow::on_actionToggle_Breakpoint_triggered() +{ + Editor * editor = mEditorList->getEditor(); + int line; + if (editor && editor->PointToLine(mContextMenuPos,line)) + editor->toggleBreakpoint(line); +} + + +void MainWindow::on_actionClear_all_breakpoints_triggered() +{ + Editor *e=mEditorList->getEditor(); + if (!e) + return; + if (QMessageBox::question(this, + tr("Clear all breakpoints"), + tr("Do you really want to clear all breakpoints in this file?"), + QMessageBox::Yes | QMessageBox::No, + QMessageBox::No) == QMessageBox::Yes) { + e->clearBreakpoints(); + } +} + + +void MainWindow::on_actionBreakpoint_property_triggered() +{ + Editor * editor = mEditorList->getEditor(); + int line; + if (editor && editor->PointToLine(mContextMenuPos,line)) { + if (editor->hasBreakpoint(line)) + editor->modifyBreakpointProperty(line); + } + +} + diff --git a/RedPandaIDE/mainwindow.h b/RedPandaIDE/mainwindow.h index e97ebcc8..294bce4b 100644 --- a/RedPandaIDE/mainwindow.h +++ b/RedPandaIDE/mainwindow.h @@ -264,6 +264,12 @@ private slots: void on_actionPrevious_Editor_triggered(); + void on_actionToggle_Breakpoint_triggered(); + + void on_actionClear_all_breakpoints_triggered(); + + void on_actionBreakpoint_property_triggered(); + private: Ui::MainWindow *ui; EditorList *mEditorList; @@ -307,6 +313,7 @@ private: bool mClosing; bool mSystemTurnedOff; + QPoint mContextMenuPos; // QWidget interface diff --git a/RedPandaIDE/mainwindow.ui b/RedPandaIDE/mainwindow.ui index bfb5264e..d5dfb2ed 100644 --- a/RedPandaIDE/mainwindow.ui +++ b/RedPandaIDE/mainwindow.ui @@ -255,7 +255,7 @@ QTabWidget::South - 4 + 0 @@ -302,6 +302,9 @@ QAbstractItemView::SelectRows + + true + @@ -464,7 +467,7 @@ QTabWidget::North - 2 + 0 @@ -517,6 +520,9 @@ Qt::ElideNone + + true + @@ -543,6 +549,9 @@ Qt::ElideNone + + true + @@ -1505,6 +1514,29 @@ Ctrl+Shift+Tab + + + + :/icons/images/editor/breakpoint.png + + + + Toggle breakpoint + + + Ctrl+F4 + + + + + Clear all breakpoints + + + + + Breakpoint property... + + diff --git a/RedPandaIDE/themes/dark/style.qss b/RedPandaIDE/themes/dark/style.qss index 86fb108b..cbb51841 100644 --- a/RedPandaIDE/themes/dark/style.qss +++ b/RedPandaIDE/themes/dark/style.qss @@ -401,7 +401,7 @@ QMenu::separator { QMenu::item { background-color: #37414F; - padding: 4px 24px 4px 28px; + padding: 4px 8px 4px 8px; /* Reserve space for selection border */ border: 1px transparent #455364; } @@ -1574,7 +1574,7 @@ QTabBar::tab:right:!selected, QDockWidget QTabBar::tab:right:!selected { QTabBar::tab:top, QDockWidget QTabBar::tab:top { background-color: #455364; margin-left: 2px; - padding: 0.1em 0.5em 0.1em 0.5em; + padding: 4px 10px 4px 10px; min-width: 5px; border-bottom: 3px solid #455364; border-top-left-radius: 4px; @@ -1600,7 +1600,7 @@ QTabBar::tab:bottom, QDockWidget QTabBar::tab:bottom { border-top: 3px solid #455364; background-color: #455364; margin-left: 2px; - padding: 0.1em 0.5em 0.1em 0.5em; + padding: 4px 10px 4px 10px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; min-width: 5px; @@ -1624,7 +1624,7 @@ QTabBar::tab:bottom:!selected:hover, QDockWidget QTabBar::tab:bottom:!selected:h QTabBar::tab:left, QDockWidget QTabBar::tab:left { background-color: #455364; margin-top: 2px; - padding: 0.5em 0.1em 0.5em 0.1em; + padding: 10px 4px 10px 4px; border-top-left-radius: 4px; border-bottom-left-radius: 4px; min-height: 5px; @@ -1646,7 +1646,7 @@ QTabBar::tab:left:!selected:hover, QDockWidget QTabBar::tab:left:!selected:hover QTabBar::tab:right, QDockWidget QTabBar::tab:right { background-color: #455364; margin-top: 2px; - padding: 0.5em 0.1em 0.5em 0.1em; + padding: 10px 4px 10px 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; min-height: 5px; @@ -1949,7 +1949,7 @@ QHeaderView::section { color: #E0E1E3; border-radius: 0; text-align: left; - font-size: 13px; +/* font-size: 13px; */ } QHeaderView::section::horizontal { diff --git a/RedPandaIDE/themes/light/style.qss b/RedPandaIDE/themes/light/style.qss index 866b2d5e..a780d215 100644 --- a/RedPandaIDE/themes/light/style.qss +++ b/RedPandaIDE/themes/light/style.qss @@ -1575,10 +1575,7 @@ QTabBar::tab:right:!selected, QDockWidget QTabBar::tab:right:!selected { QTabBar::tab:top, QDockWidget QTabBar::tab:top { background-color: #C9CDD0; margin-left: 2px; - padding-left: 4px; - padding-right: 4px; - padding-top: 2px; - padding-bottom: 2px; + padding: 4px 10px 4px 10px; min-width: 5px; border-bottom: 3px solid #C9CDD0; border-top-left-radius: 4px; @@ -1596,18 +1593,15 @@ QTabBar::tab:top:!selected:hover, QDockWidget QTabBar::tab:top:!selected:hover { border: 1px solid #73C7FF; border-bottom: 3px solid #73C7FF; /* Fixes spyder-ide/spyder#9766 and #243 */ - padding-left: 3px; - padding-right: 3px; + /*padding-left: 3px*/; + /*padding-right: 3px*/; } QTabBar::tab:bottom, QDockWidget QTabBar::tab:bottom { border-top: 3px solid #C9CDD0; background-color: #C9CDD0; margin-left: 2px; - padding-left: 4px; - padding-right: 4px; - padding-top: 2px; - padding-bottom: 2px; + padding: 4px 10px 4px 10px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; min-width: 5px; @@ -1631,10 +1625,7 @@ QTabBar::tab:bottom:!selected:hover, QDockWidget QTabBar::tab:bottom:!selected:h QTabBar::tab:left, QDockWidget QTabBar::tab:left { background-color: #C9CDD0; margin-top: 2px; - padding-left: 2px; - padding-right: 2px; - padding-top: 4px; - padding-bottom: 4px; + padding: 10px 4px 10px 4px; border-top-left-radius: 4px; border-bottom-left-radius: 4px; min-height: 5px; @@ -1656,10 +1647,7 @@ QTabBar::tab:left:!selected:hover, QDockWidget QTabBar::tab:left:!selected:hover QTabBar::tab:right, QDockWidget QTabBar::tab:right { background-color: #C9CDD0; margin-top: 2px; - padding-left: 2px; - padding-right: 2px; - padding-top: 4px; - padding-bottom: 4px; + padding: 10px 4px 10px 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; min-height: 5px; @@ -1962,7 +1950,7 @@ QHeaderView::section { color: #19232D; border-radius: 0; text-align: left; - font-size: 13px; +/* font-size: 13px; */ } QHeaderView::section::horizontal { diff --git a/RedPandaIDE/utils.cpp b/RedPandaIDE/utils.cpp index 57f25710..cdd76ca8 100644 --- a/RedPandaIDE/utils.cpp +++ b/RedPandaIDE/utils.cpp @@ -603,3 +603,9 @@ void logToFile(const QString &s, const QString &filename, bool append) ts< parser); diff --git a/RedPandaIDE/widgets/cpudialog.ui b/RedPandaIDE/widgets/cpudialog.ui index 36dbcfdf..4b87ae6c 100644 --- a/RedPandaIDE/widgets/cpudialog.ui +++ b/RedPandaIDE/widgets/cpudialog.ui @@ -162,6 +162,9 @@ Qt::ElideNone + + true + diff --git a/RedPandaIDE/widgets/issuestable.cpp b/RedPandaIDE/widgets/issuestable.cpp index 816b9320..096d844e 100644 --- a/RedPandaIDE/widgets/issuestable.cpp +++ b/RedPandaIDE/widgets/issuestable.cpp @@ -1,5 +1,7 @@ #include "issuestable.h" +#include "../utils.h" #include +#include "../settings.h" IssuesTable::IssuesTable(QWidget *parent): @@ -7,7 +9,6 @@ IssuesTable::IssuesTable(QWidget *parent): { mModel = new IssuesModel(this); this->setModel(mModel); - this->horizontalHeader()->setSectionResizeMode(3,QHeaderView::Stretch); this->setColumnWidth(0,200); this->setColumnWidth(1,45); this->setColumnWidth(2,45); @@ -120,9 +121,14 @@ QVariant IssuesModel::data(const QModelIndex &index, int role) const return QVariant(); switch (role) { case Qt::DisplayRole: + case Qt::ToolTipRole: switch (index.column()) { - case 0: - return issue->filename; + case 0: { + if (role == Qt::DisplayRole) + return baseFileName(issue->filename); + else + return issue->filename; + } case 1: if (issue->line>0) return issue->line; @@ -168,16 +174,20 @@ QVariant IssuesModel::data(const QModelIndex &index, int role) const QVariant IssuesModel::headerData(int section, Qt::Orientation orientation, int role) const { - if (orientation == Qt::Horizontal && role == Qt::DisplayRole) { - switch(section) { - case 0: - return tr("Filename"); - case 1: - return tr("Line"); - case 2: - return tr("Col"); - case 3: - return tr("Description"); + if (orientation == Qt::Horizontal ) { + switch(role) { + case Qt::DisplayRole: + switch(section) { + case 0: + return tr("Filename"); + case 1: + return tr("Line"); + case 2: + return tr("Col"); + case 3: + return tr("Description"); + } + break; } } return QVariant();