WIP moving actions for toolbar to module system.

This commit is contained in:
eelke 2018-08-05 09:07:12 +02:00
parent f5e9c4b74e
commit 78a6666839
8 changed files with 225 additions and 114 deletions

View file

@ -1,9 +1,11 @@
#include "QueryTab.h"

#include "QueryTab.h"
#include "ui_QueryTab.h"
#include "SqlSyntaxHighlighter.h"
#include <QStandardPaths>
#include <QPushButton>
#include <QAction>
#include <QFileDialog>
#include <QStatusBar>
#include <QMessageBox>
@ -604,13 +606,52 @@ void QueryTab::focusEditor()
ui->queryEdit->setFocus();
}
std::vector<QAction*> QueryTab::getToolbarActions()
{
if (actions.empty()) {
QAction *action = new QAction(QIcon(":/icons/script_go.png"), tr("Execute"), this);
QAction *action;
// New
// action = new QAction(QIcon(":/icons/new_query_tab.png"), tr("New"), this);
// action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_N));
// connect(action, &QAction::triggered, this, &QueryTab::);
// actions.push_back(action);
// Load
// Save
action = new QAction(QIcon(":/icons/script_save.png"), tr("Save SQL"), this);
action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_S));
connect(action, &QAction::triggered, this, &QueryTab::save);
actions.push_back(action);
// Save as
action = new QAction(QIcon(":/icons/script_go.png"), tr("Save SQL as"), this);
//action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_S));
connect(action, &QAction::triggered, this, &QueryTab::saveAs);
actions.push_back(action);
// Save copy as
// Copy
// Copy as C-string
// Copy as raw cpp string
// Execute SQL
action = new QAction(QIcon(":/icons/script_go.png"), tr("Execute"), this);
action->setShortcut(QKeySequence(Qt::Key_F5));
connect(action, &QAction::triggered, this, &QueryTab::execute);
actions.push_back(action);
// Explain
action = new QAction(QIcon(":/icons/lightbulb_off.png"), tr("Explain"), this);
action->setShortcut(QKeySequence(Qt::Key_F7));
connect(action, &QAction::triggered, this, [this] () { explain(false); });
actions.push_back(action);
// Explain Anaylze
action = new QAction(QIcon(":/icons/lightbulb.png"), tr("Analyze"), this);
action->setShortcut(QKeySequence(Qt::SHIFT + Qt::Key_F7));
connect(action, &QAction::triggered, this, [this] () { explain(true); });
actions.push_back(action);
// Cancel
action = new QAction(QIcon(":/icons/script_delete.png"), tr("Cancel"), this);
action->setShortcut(QKeySequence(Qt::ALT + Qt::Key_Pause));
connect(action, &QAction::triggered, this, &QueryTab::cancel);
actions.push_back(action);
}
return actions;
}