Added paste lang option for pasting programming code.
Expects you to paste only string literals with possible concatenation operators like . or +
This commit is contained in:
parent
35d1e75d35
commit
fbd630489e
8 changed files with 302 additions and 2 deletions
|
|
@ -141,14 +141,14 @@ void DatabaseWindow::createActions()
|
|||
icon.addFile(QString::fromUtf8(":/icons/token_shortland_character.png"), QSize(), QIcon::Normal, QIcon::On);
|
||||
auto action = actionCopyAsCString = new QAction(icon, tr("Copy as C string"), this);
|
||||
action->setObjectName("actionCopyAsCString");
|
||||
action->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_C));
|
||||
action->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_C));
|
||||
}
|
||||
{
|
||||
QIcon icon;
|
||||
icon.addFile(QString::fromUtf8(":/icons/token_shortland_character.png"), QSize(), QIcon::Normal, QIcon::On);
|
||||
auto action = actionCopyAsRawCppString = new QAction(icon, tr("Copy as raw C++-string"), this);
|
||||
action->setObjectName("actionCopyAsRawCppString");
|
||||
action->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_C));
|
||||
|
||||
}
|
||||
{
|
||||
QIcon icon;
|
||||
|
|
@ -213,6 +213,13 @@ void DatabaseWindow::createActions()
|
|||
action->setObjectName("actionOpenSql");
|
||||
action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_O));
|
||||
}
|
||||
{
|
||||
QIcon icon;
|
||||
//icon.addFile(QString::fromUtf8(":/icons/folder.png"), QSize(), QIcon::Normal, QIcon::On);
|
||||
auto action = actionPasteLangString = new QAction(icon, tr("Paste lang string"), this);
|
||||
action->setObjectName("actionPasteLangString");
|
||||
action->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_V));
|
||||
}
|
||||
{
|
||||
QIcon icon;
|
||||
icon.addFile(QString::fromUtf8(":/icons/script_save.png"), QSize(), QIcon::Normal, QIcon::On);
|
||||
|
|
@ -257,6 +264,8 @@ void DatabaseWindow::initMenus()
|
|||
actionCopy,
|
||||
actionCopyAsCString,
|
||||
actionCopyAsRawCppString,
|
||||
// standard Paste missing Ctrl+V works however by default
|
||||
actionPasteLangString,
|
||||
actionGenerateCode
|
||||
});
|
||||
|
||||
|
|
@ -482,6 +491,14 @@ void DatabaseWindow::on_actionOpenSql_triggered()
|
|||
}
|
||||
}
|
||||
|
||||
void DatabaseWindow::on_actionPasteLangString_triggered()
|
||||
{
|
||||
auto query_tool = GetActiveQueryTool();
|
||||
if (query_tool) {
|
||||
query_tool->pasteLangString();
|
||||
}
|
||||
}
|
||||
|
||||
void DatabaseWindow::on_actionSaveSql_triggered()
|
||||
{
|
||||
auto query_tool = GetActiveQueryTool();
|
||||
|
|
|
|||
|
|
@ -77,6 +77,7 @@ private:
|
|||
QAction *actionInspectUserSchemas = nullptr; ///< Create or switch to pgcatalog tab
|
||||
QAction *actionNewSql = nullptr;
|
||||
QAction *actionOpenSql = nullptr;
|
||||
QAction *actionPasteLangString = nullptr;
|
||||
QAction *actionSaveSql = nullptr;
|
||||
QAction *actionSaveSqlAs = nullptr;
|
||||
QAction *actionSaveCopyOfSqlAs = nullptr;
|
||||
|
|
@ -138,6 +139,7 @@ private slots:
|
|||
void on_actionInspectUserSchemas_triggered();
|
||||
void on_actionNewSql_triggered();
|
||||
void on_actionOpenSql_triggered();
|
||||
void on_actionPasteLangString_triggered();
|
||||
void on_actionSaveSql_triggered();
|
||||
void on_actionSaveSqlAs_triggered();
|
||||
void on_actionSaveCopyOfSqlAs_triggered();
|
||||
|
|
|
|||
|
|
@ -559,6 +559,13 @@ void QueryTool::copyQueryAsRawCppString()
|
|||
QApplication::clipboard()->setText(cs);
|
||||
}
|
||||
|
||||
void QueryTool::pasteLangString()
|
||||
{
|
||||
QString s = QApplication::clipboard()->text();
|
||||
s = ConvertLangToSqlString(s);
|
||||
ui->queryEdit->insertPlainText(s);
|
||||
}
|
||||
|
||||
void QueryTool::generateCode()
|
||||
{
|
||||
QString command = getCommand();
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ public slots:
|
|||
void saveCopyAs();
|
||||
void copyQueryAsCString();
|
||||
void copyQueryAsRawCppString();
|
||||
void pasteLangString();
|
||||
void cancel();
|
||||
void exportData();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue