Example #1
0
void PgxConsole::createActions()
{
    cut_action = new QAction(QIcon(qApp->applicationDirPath().append("/icons/cut.png")), tr("Cut"), this);
    cut_action->setShortcuts(QKeySequence::Cut);
    cut_action->setStatusTip(tr("Cut selected text and copy to clipboard"));
    connect(cut_action, SIGNAL(triggered()), this, SLOT(cut()));

    copy_action = new QAction(QIcon(qApp->applicationDirPath().append("/icons/copy.png")), tr("Copy"), this);
    copy_action->setShortcuts(QKeySequence::Copy);
    copy_action->setStatusTip(tr("Copy selected text to clipboard"));
    connect(copy_action, SIGNAL(triggered()), this, SLOT(copy()));

    paste_action = new QAction(QIcon(qApp->applicationDirPath().append("/icons/paste.png")), tr("Paste"), this);
    paste_action->setShortcuts(QKeySequence::Paste);
    paste_action->setStatusTip(tr("Paste"));
    connect(paste_action, SIGNAL(triggered()), this, SLOT(pasteAsSingleFromClipboard()));

    clear_action = new QAction(QIcon(qApp->applicationDirPath().append("/icons/clear.png")), tr("&Clear"), this);
    clear_action->setStatusTip(tr("Clear the console"));
    connect(clear_action, SIGNAL(triggered()), this, SLOT(clear()));

    find_action = new QAction(QIcon(qApp->applicationDirPath().append("/icons/search.png")), tr("Find"), this);
    find_action->setShortcuts(QKeySequence::Find);
    find_action->setStatusTip(tr("Find/replace text"));
    find_action->setCheckable(true);
    connect(find_action, SIGNAL(triggered()), this, SLOT(toggleFindBar()));

    casesensitivity_action = new QAction(tr("Cs"), this);
    casesensitivity_action->setToolTip(tr("Case sensitive"));
    casesensitivity_action->setCheckable(true);
    casesensitivity_button = new QToolButton;
    casesensitivity_button->setDefaultAction(casesensitivity_action);
    casesensitivity_button->setVisible(false);

    wholeword_action = new QAction(tr("W"), this);
    wholeword_action->setToolTip(tr("Whole word"));
    wholeword_action->setCheckable(true);
    wholeword_button = new QToolButton;
    wholeword_button->setDefaultAction(wholeword_action);
    wholeword_button->setVisible(false);

    backwards_action = new QAction(tr("B"), this);
    backwards_action->setToolTip(tr("Backwards"));
    backwards_action->setCheckable(true);
    backwards_button = new QToolButton;
    backwards_button->setDefaultAction(backwards_action);
    backwards_button->setVisible(false);
}
Example #2
0
void PgxConsole::createActions()
{
    newpgxconsole_action = new QAction(QIcon(":/icons/console.png"), tr("New"), this);
    newpgxconsole_action->setShortcuts(QKeySequence::New);
    newpgxconsole_action->setStatusTip(tr("New console"));
    connect(newpgxconsole_action, SIGNAL(triggered()), this, SIGNAL(newPgxconsole()));

    cut_action = new QAction(QIcon(":/icons/cut.png"), tr("Cut"), this);
    cut_action->setShortcuts(QKeySequence::Cut);
    cut_action->setStatusTip(tr("Cut selected text and copy to clipboard"));
    connect(cut_action, SIGNAL(triggered()), SLOT(cut()));

    copy_action = new QAction(QIcon(":/icons/copy.png"), tr("Copy"), this);
    copy_action->setShortcuts(QKeySequence::Copy);
    copy_action->setStatusTip(tr("Copy selected text to clipboard"));
    connect(copy_action, SIGNAL(triggered()), SLOT(copy()));

    paste_action = new QAction(QIcon(":/icons/paste.png"), tr("Paste"), this);
    paste_action->setShortcuts(QKeySequence::Paste);
    paste_action->setStatusTip(tr("Paste"));
    connect(paste_action, SIGNAL(triggered()), SLOT(pasteAsSingleFromClipboard()));

    clear_action = new QAction(QIcon(":/icons/clear.png"), tr("&Clear"), this);
    clear_action->setStatusTip(tr("Clear the console"));
    connect(clear_action, SIGNAL(triggered()), SLOT(clear()));

    find_action = new QAction(QIcon(":/icons/search.png"), tr("Find"), this);
    find_action->setShortcuts(QKeySequence::Find);
    find_action->setStatusTip(tr("Find text"));
    find_action->setCheckable(true);
    connect(find_action, SIGNAL(triggered()), SLOT(toggleFindBar()));

    casesensitivity_action = new QAction(tr("Cs"), this);
    casesensitivity_action->setToolTip(tr("Case sensitive"));
    casesensitivity_action->setCheckable(true);
    casesensitivity_button = new QToolButton;
    casesensitivity_button->setDefaultAction(casesensitivity_action);
    casesensitivity_button->setVisible(false);

    wholeword_action = new QAction(tr("W"), this);
    wholeword_action->setToolTip(tr("Whole word"));
    wholeword_action->setCheckable(true);
    wholeword_button = new QToolButton;
    wholeword_button->setDefaultAction(wholeword_action);
    wholeword_button->setVisible(false);

    //backwards_action = new QAction(tr("B"), this);
    //backwards_action->setToolTip(tr("Backwards"));
    //backwards_action->setCheckable(true);
    //backwards_button = new QToolButton;
    //backwards_button->setDefaultAction(backwards_action);
    //backwards_button->setVisible(false);

    find_previous_action = new QAction(QIcon(":/icons/find_previous.png"), "", this);
    find_previous_action->setToolTip(tr("Find previous"));
    connect(find_previous_action, SIGNAL(triggered()), SLOT(findPrevious()));
    find_previous_button = new QToolButton;
    find_previous_button->setAutoRaise(true);
    find_previous_button->setDefaultAction(find_previous_action);
    find_previous_button->setVisible(false);

    find_next_action = new QAction(QIcon(":/icons/find_next.png"), "", this);
    find_next_action->setToolTip(tr("Find next"));
    connect(find_next_action, SIGNAL(triggered()), SLOT(findNext()));
    find_next_button = new QToolButton;
    find_next_button->setAutoRaise(true);
    find_next_button->setDefaultAction(find_next_action);
    find_next_button->setVisible(false);
}
Example #3
0
PgxConsole::PgxConsole(Database *database)
{
    this->database = database;
    insertPlainText("");
    setViewportMargins(10, 0, 0, 0);
    setTabStopWidth(40);
    setUndoRedoEnabled(false);
    setWindowTitle(QApplication::translate("PgxConsole", "SQL console", 0, QApplication::UnicodeUTF8));
    setStyleSheet("QPlainTextEdit{background-color: white; font: bold 14px 'Courier New';}");

    createActions();
    hit = 0;

    highlighter = new Highlighter(document());
    prompt = new Prompt(this);

    toolbar = new ToolBar;
    toolbar->setIconSize(QSize(36,36));
    toolbar->setObjectName("pgxeditor");
    toolbar->setMovable(false);
    toolbar->addAction(newpgxconsole_action);
    toolbar->addAction(cut_action);
    toolbar->addAction(copy_action);
    toolbar->addAction(paste_action);
    toolbar->addSeparator();
    toolbar->addAction(clear_action);
    toolbar->addAction(find_action);

    pgxconsole_mainwin = new PgxConsoleMainWindow;
    pgxconsole_mainwin->addToolBar(toolbar);
    pgxconsole_mainwin->setCentralWidget(this);
    pgxconsole_mainwin->setAttribute(Qt::WA_DeleteOnClose);

    find_bar = new QLineEdit;
    find_bar->setPlaceholderText(tr("Find"));
    find_bar->setMaximumSize(100,find_bar->height());
    find_bar->setVisible(false);
    pgxconsole_mainwin->statusBar()->setSizeGripEnabled(false);
    pgxconsole_mainwin->statusBar()->addPermanentWidget(casesensitivity_button, 0);
    pgxconsole_mainwin->statusBar()->addPermanentWidget(wholeword_button, 0);
    //pgxconsole_mainwin->statusBar()->addPermanentWidget(backwards_button, 0);
    pgxconsole_mainwin->statusBar()->addPermanentWidget(find_bar);
    pgxconsole_mainwin->statusBar()->addPermanentWidget(find_previous_button, 0);
    pgxconsole_mainwin->statusBar()->addPermanentWidget(find_next_button, 0);

    connect(find_bar, SIGNAL(returnPressed()), SLOT(findText()));

    QShortcut *shortcut_paste = new QShortcut(QKeySequence::Paste, this);
    connect(shortcut_paste, SIGNAL(activated()), SLOT(pasteFromClipboard()));

    QShortcut *shortcut_single_paste = new QShortcut(QKeySequence("Ctrl+Shift+V"), this);
    connect(shortcut_single_paste, SIGNAL(activated()), SLOT(pasteAsSingleFromClipboard()));

    connect(this, SIGNAL(cursorPositionChanged()), SLOT(makePreviousBlocksReadonly()));

    //Tie command with QueryView creation.
    connect(this, SIGNAL(commandSignal(QString)), SLOT(showView(QString)));

    //Tie up and down keys with command history scolling.
    connect(this, SIGNAL(historyUp()), SLOT(historyUpCommand()));
    connect(this, SIGNAL(historyDown()), SLOT(historyDownCommand()));

    //Console updates.
    connect(this, SIGNAL(updateRequest(QRect,int)), SLOT(updatePrompt(QRect,int)));
    connect(pgxconsole_mainwin, SIGNAL(pgxconsoleClosing()), SLOT(pgxconsoleClosing()));
}