From 2b15029be527f4559e69a513ddb1b51eb27e0d3f Mon Sep 17 00:00:00 2001 From: mgrojo Date: Fri, 23 Nov 2018 18:35:52 +0100 Subject: [PATCH] Button for new Un/Comment Block feature A new button has been added to the "Execute SQL" toolbar for invoking the new Un/Comment Block feature. See issue #1614 --- src/MainWindow.cpp | 9 +++++++++ src/MainWindow.h | 1 + src/MainWindow.ui | 36 ++++++++++++++++++++++++++++++++++++ src/icons/comment_block.png | Bin 0 -> 210 bytes src/icons/icons.qrc | 1 + src/sqltextedit.h | 2 -- 6 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 src/icons/comment_block.png diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 0e6543a9..af607264 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -3514,6 +3514,15 @@ void MainWindow::openFindReplaceDialog() sqlWidget->getEditor()->openFindReplaceDialog(); } +void MainWindow::toggleSqlBlockComment() +{ + // The slot for the shortcut must discover which sqltexedit widget has the focus + SqlExecutionArea* sqlWidget = qobject_cast(ui->tabSqlAreas->currentWidget()); + + if (sqlWidget) + sqlWidget->getEditor()->toggleBlockComment(); +} + void MainWindow::openSqlPrintDialog() { // The slot for the shortcut must discover which sqltexedit widget has the focus and then open its dialog. diff --git a/src/MainWindow.h b/src/MainWindow.h index eb6aae18..7d5d82e9 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -304,6 +304,7 @@ private slots: void renameSqlTab(int index); void setFindFrameVisibility(bool show); void openFindReplaceDialog(); + void toggleSqlBlockComment(); void openSqlPrintDialog(); void saveFilterAsView(); void exportFilteredTable(); diff --git a/src/MainWindow.ui b/src/MainWindow.ui index db61474a..c2c0e1f1 100644 --- a/src/MainWindow.ui +++ b/src/MainWindow.ui @@ -946,6 +946,8 @@ You can drag SQL statements from an object row and drop them into other applicat + + @@ -2364,6 +2366,24 @@ You can drag SQL statements from the Schema column and drop them into the SQL ed Qt::WidgetShortcut + + + + :/icons/comment_block:/icons/comment_block + + + Un/comment block of SQL code + + + Comment or uncomment current line or selected block of code + + + Comment or uncomment the selected lines or the current line, when there is no selection. All the block is toggled according to the first line. + + + Ctrl+Shift+/ + + @@ -3777,6 +3797,22 @@ You can drag SQL statements from the Schema column and drop them into the SQL ed + + actionSqlToggleComment + triggered() + MainWindow + toggleSqlBlockComment() + + + -1 + -1 + + + 518 + 314 + + + fileOpen() diff --git a/src/icons/comment_block.png b/src/icons/comment_block.png new file mode 100644 index 0000000000000000000000000000000000000000..3b3ee4c4861e100109712776801fb18ffcc2710e GIT binary patch literal 210 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Gd*1#Lo5W7|NQ^|zn+bYL727b zV3ej=1M4%Umy3H6o~54M&a>-!YvLh`m&>mS%r_2_Vw2FTNch(6_)tVTYprinter.png package_save.png cancel.png + comment_block.png diff --git a/src/sqltextedit.h b/src/sqltextedit.h index afba695f..796fd58c 100644 --- a/src/sqltextedit.h +++ b/src/sqltextedit.h @@ -22,8 +22,6 @@ public: public slots: void reloadSettings(); - -private slots: void toggleBlockComment(); };