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
This commit is contained in:
mgrojo
2018-11-23 18:35:52 +01:00
parent 33266b7707
commit 2b15029be5
6 changed files with 47 additions and 2 deletions

View File

@@ -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<SqlExecutionArea*>(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.

View File

@@ -304,6 +304,7 @@ private slots:
void renameSqlTab(int index);
void setFindFrameVisibility(bool show);
void openFindReplaceDialog();
void toggleSqlBlockComment();
void openSqlPrintDialog();
void saveFilterAsView();
void exportFilteredTable();

View File

@@ -946,6 +946,8 @@ You can drag SQL statements from an object row and drop them into other applicat
<addaction name="separator"/>
<addaction name="actionSqlFind"/>
<addaction name="actionSqlFindReplace"/>
<addaction name="separator"/>
<addaction name="actionSqlToggleComment"/>
</widget>
</item>
<item>
@@ -2364,6 +2366,24 @@ You can drag SQL statements from the Schema column and drop them into the SQL ed
<enum>Qt::WidgetShortcut</enum>
</property>
</action>
<action name="actionSqlToggleComment">
<property name="icon">
<iconset resource="icons/icons.qrc">
<normaloff>:/icons/comment_block</normaloff>:/icons/comment_block</iconset>
</property>
<property name="text">
<string>Un/comment block of SQL code</string>
</property>
<property name="toolTip">
<string>Comment or uncomment current line or selected block of code</string>
</property>
<property name="whatsThis">
<string>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.</string>
</property>
<property name="shortcut">
<string>Ctrl+Shift+/</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>
@@ -3777,6 +3797,22 @@ You can drag SQL statements from the Schema column and drop them into the SQL ed
</hint>
</hints>
</connection>
<connection>
<sender>actionSqlToggleComment</sender>
<signal>triggered()</signal>
<receiver>MainWindow</receiver>
<slot>toggleSqlBlockComment()</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>518</x>
<y>314</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>fileOpen()</slot>

BIN
src/icons/comment_block.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 210 B

View File

@@ -69,5 +69,6 @@
<file alias="print">printer.png</file>
<file alias="project_save">package_save.png</file>
<file alias="cancel">cancel.png</file>
<file alias="comment_block">comment_block.png</file>
</qresource>
</RCC>

View File

@@ -22,8 +22,6 @@ public:
public slots:
void reloadSettings();
private slots:
void toggleBlockComment();
};