예제 #1
0
ViewToolBar::ViewToolBar(QWidget *parent) :
    QToolBar(parent)
{
    group = new QActionGroup(this);
    setIconSize(QSize(20,20));
    setToolButtonStyle(Qt::ToolButtonTextBesideIcon);

    // adding a dummy space widget appears to even out the toolbar
    addWidget(new QWidget(this));

    dbSelect = new QComboBox(this);
    dbSelect->setMinimumWidth(150);
    connect(dbSelect, SIGNAL(activated(int)), this, SLOT(dbComboModified(int)));
    addWidget(dbSelect);

    viewActions.append(addExclusiveAction(":content", "Content", SLOT(showContent())));
    viewActions.append(addExclusiveAction(":schema", "Schema", SLOT(showStructure())));
    viewActions.append(addExclusiveAction(":query", "Query", SLOT(showQuery())));

    QWidget* spacer = new QWidget(this);
    spacer->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
    addWidget(spacer);

    back = QToolBar::addAction("<", this, SIGNAL(historyBack()));
    back->setEnabled(false);
    forward = QToolBar::addAction(">", this, SIGNAL(historyForward()));
    forward->setEnabled(false);

    viewActions.append(addAction(QIcon(":disconnect"), "Disconnect", this, SIGNAL(disconnect())));
}
예제 #2
0
파일: editor.cpp 프로젝트: KDE/abakus
void Editor::keyPressEvent( QKeyEvent* e )
{
    if( e->key() == Key_Up )
    {
        historyBack();
        e->accept();
        return;
    }

    if( e->key() == Key_Down )
    {
        historyForward();
        e->accept();
        return;
    }

    if( e->key() == Key_Enter || e->key() == Key_Return )
    {
        emit returnPressed();
        return;
    }

    if( e->key() == Key_Left ||
            e->key() == Key_Right ||
            e->key() == Key_Home ||
            e->key() == Key_End )
    {
        checkMatching();
    }

    QTextEdit::keyPressEvent( e );
}
예제 #3
0
void Console::keyPressEvent(QKeyEvent* event)
{
    if(event->modifiers() == Qt::CTRL && event->key() == *QString("C").toAscii())
    {
        emit CommandInterrupted(_currentCommand);
        ConsoleWriteRequest("^Ctrl+C\n");
        CommandFinished();
//        emit onBreak("^Ctrl+C\n");
    }
    if(isLocked)
        return;
    //if(event->key() >= 0x20 && event->key() <= 0x7e
    if(event->key() >= Qt::Key_Space && event->key() <= Qt::Key_AsciiTilde
            && (event->modifiers() == Qt::NoModifier || event->modifiers() == Qt::ShiftModifier))
    {
        QPlainTextEdit::keyPressEvent(event);
    }
    if((event->key() == Qt::Key_Left ||
        event->key() == Qt::Key_Backspace) &&
        event->modifiers() == Qt::NoModifier &&
        textCursor().positionInBlock() > prompt.length())
    {
        QPlainTextEdit::keyPressEvent(event);
    }
    if((event->key() == Qt::Key_Right ||
        event->key() == Qt::Key_Delete ||
        event->key() == Qt::Key_End) &&
        event->modifiers() == Qt::NoModifier &&
        textCursor().positionInBlock() >= prompt.length())
    {
        QPlainTextEdit::keyPressEvent(event);
    }
//    if(event->key() == Qt::Key_Home && event->modifiers() == Qt::NoModifier)
    if(event->key() == Qt::Key_Return && event->modifiers() == Qt::NoModifier)
    {
        QTextCursor cursor = textCursor();
        cursor.movePosition(QTextCursor::End);
        setTextCursor(cursor);
        onEnter();
    }
    if(event->key() == Qt::Key_Up && event->modifiers() == Qt::NoModifier)
    {
        historyBack();
    }
    if(event->key() == Qt::Key_Down && event->modifiers() == Qt::NoModifier)
    {
        historyForward();
    }
    if(event->key() == Qt::Key_Question)
    {
        if (isConnected)
        {
            if (dev->GetType() == Device::dev_router)
            {
                onEnter();
            }
        }
    }
}
예제 #4
0
void Editor::wheelEvent(QWheelEvent* event)
{
    if (event->delta() > 0)
        historyBack();
    else if (event->delta() < 0)
        historyForward();
    event->accept();
}
예제 #5
0
void Console::keyPressEvent(QKeyEvent *event)
{
	if(isLocked)
	return;
	if(event->key() >= 0x20 && event->key() <= 0x7e
	   && (event->modifiers() == Qt::NoModifier || event->modifiers() == Qt::ShiftModifier))
	QPlainTextEdit::keyPressEvent(event);
	if(event->key() == Qt::Key_Backspace
	   && event->modifiers() == Qt::NoModifier
	   && textCursor().positionInBlock() > prompt.length())
	QPlainTextEdit::keyPressEvent(event);
	if(event->key() == Qt::Key_Return && event->modifiers() == Qt::NoModifier)
	onEnter();
	if(event->key() == Qt::Key_Up && event->modifiers() == Qt::NoModifier)
	historyBack();
	if(event->key() == Qt::Key_Down && event->modifiers() == Qt::NoModifier)
	historyForward();
	QString cmd = textCursor().block().text().mid(prompt.length());
	emit onChange(cmd);
}
예제 #6
0
ListPanelActions::ListPanelActions(QObject *parent, FileManagerWindow *mainWindow) :
        ActionsBase(parent, mainWindow)
{
    // set view type
    QSignalMapper *mapper = new QSignalMapper(this);
    connect(mapper, SIGNAL(mapped(int)), SLOT(setView(int)));
    QActionGroup *group = new QActionGroup(this);
    group->setExclusive(true);
    QList<KrViewInstance*> views = KrViewFactory::registeredViews();
    for(int i = 0; i < views.count(); i++) {
        KrViewInstance *inst = views[i];
        QAction *action = new QAction(QIcon::fromTheme(inst->icon()), inst->description(), group);
        action->setCheckable(true);
        connect(action, SIGNAL(triggered()), mapper, SLOT(map()));
        mapper->setMapping(action, inst->id());
        _mainWindow->actions()->addAction("view" + QString::number(i), action);
        _mainWindow->actions()->setDefaultShortcut(action, inst->shortcut());
        setViewActions.insert(inst->id(), action);
    }

    // standard actions
    actHistoryBackward = stdAction(KStandardAction::Back, _func, SLOT(historyBackward()));
    actHistoryForward = stdAction(KStandardAction::Forward, _func, SLOT(historyForward()));
    //FIXME: second shortcut for up: see actDirUp
    //   KStandardAction::up( this, SLOT( dirUp() ), actionCollection )->setShortcut(Qt::Key_Backspace);
    /* Shortcut disabled because of the Terminal Emulator bug. */
    actDirUp = stdAction(KStandardAction::Up, _func, SLOT(dirUp()));
    actHome = stdAction(KStandardAction::Home, _func, SLOT(home()));
    stdAction(KStandardAction::Cut, _func, SLOT(cut()));
    actCopy = stdAction(KStandardAction::Copy, _func, SLOT(copyToClipboard()));
    actPaste = stdAction(KStandardAction::Paste, _func, SLOT(pasteFromClipboard()));

    // Fn keys
    actF2 = action(i18n("Rename"), 0, Qt::Key_F2, _func, SLOT(rename()) , "F2_Rename");
    actF3 = action(i18n("View File"), 0, Qt::Key_F3, _func, SLOT(view()), "F3_View");
    actF4 = action(i18n("Edit File"), 0, Qt::Key_F4, _func, SLOT(edit()) , "F4_Edit");
    actF5 = action(i18n("Copy to other panel"), 0, Qt::Key_F5, _func, SLOT(copyFiles()) , "F5_Copy");
    actF6 = action(i18n("Move..."), 0, Qt::Key_F6, _func, SLOT(moveFiles()) , "F6_Move");
    actShiftF5 = action(i18n("Copy by queue..."), 0, Qt::SHIFT + Qt::Key_F5, _func, SLOT(copyFilesByQueue()) , "F5_Copy_Queue");
    actShiftF6 = action(i18n("Move by queue..."), 0, Qt::SHIFT + Qt::Key_F6, _func, SLOT(moveFilesByQueue()) , "F6_Move_Queue");
    actF7 = action(i18n("New Directory..."), "folder-new", Qt::Key_F7, _func, SLOT(mkdir()) , "F7_Mkdir");
    actF8 = action(i18n("Delete"), "edit-delete", Qt::Key_F8, _func, SLOT(deleteFiles()) , "F8_Delete");
    actF9 = action(i18n("Start Terminal Here"), "utilities-terminal", Qt::Key_F9, _func, SLOT(terminal()) , "F9_Terminal");
    action(i18n("&New Text File..."), "document-new", Qt::SHIFT + Qt::Key_F4, _func, SLOT(editNew()), "edit_new_file");
    action(i18n("F3 View Dialog"), 0, Qt::SHIFT + Qt::Key_F3, _func, SLOT(viewDlg()), "F3_ViewDlg");

    // file operations
    action(i18n("Right-click Menu"), 0, Qt::Key_Menu, _gui, SLOT(rightclickMenu()), "rightclick menu");
    actProperties = action(i18n("&Properties..."), 0, Qt::ALT + Qt::Key_Return, _func, SLOT(properties()), "properties");
    actCompDirs = action(i18n("&Compare Directories"), "kr_comparedirs", Qt::ALT + Qt::SHIFT + Qt::Key_C, _gui, SLOT(compareDirs()), "compare dirs");
    actCalculate = action(i18n("Calculate &Occupied Space"), "accessories-calculator", 0, _func, SLOT(calcSpace()), "calculate");
    actPack = action(i18n("Pac&k..."), "archive-insert", Qt::ALT + Qt::SHIFT + Qt::Key_P, _func, SLOT(pack()), "pack");
    actUnpack = action(i18n("&Unpack..."), "archive-extract", Qt::ALT + Qt::SHIFT + Qt::Key_U, _func, SLOT(unpack()), "unpack");
    actCreateChecksum = action(i18n("Create Checksum..."), "document-edit-sign", 0, _func, SLOT(createChecksum()), "create checksum");
    actMatchChecksum = action(i18n("Verify Checksum..."), "document-edit-decrypt-verify", 0, _func, SLOT(matchChecksum()), "match checksum");
    action(i18n("New Symlink..."), 0, Qt::CTRL + Qt::ALT + Qt::Key_S, _func, SLOT(krlink()), "new symlink");
    actTest = action(i18n("T&est Archive"), "archive-extract", Qt::ALT + Qt::SHIFT + Qt::Key_E, _func, SLOT(testArchive()), "test archives");

    // navigation
    actRoot = action(i18n("Root"), "folder-red", Qt::CTRL + Qt::Key_Backspace, _func, SLOT(root()), "root");
    actCdToOther = action(i18n("Go to Other Panel's Directory"), 0, Qt::CTRL + Qt::Key_Equal, _func, SLOT(cdToOtherPanel()), "cd to other panel");
    action(i18n("&Reload"), "view-refresh", Qt::CTRL + Qt::Key_R, _func, SLOT(refresh()), "std_redisplay");
    actCancelRefresh = action(i18n("Cancel Refresh of View"), "dialog-cancel", 0, _gui, SLOT(inlineRefreshCancel()), "cancel refresh");
    actFTPNewConnect = action(i18n("New Net &Connection..."), "network-connect", Qt::CTRL + Qt::Key_N, _func, SLOT(newFTPconnection()), "ftp new connection");
    actFTPDisconnect = action(i18n("Disconnect &from Net"), "network-disconnect", Qt::SHIFT + Qt::CTRL + Qt::Key_F, _func, SLOT(FTPDisconnect()), "ftp disconnect");
    action(i18n("Sync Panels"), 0, Qt::ALT + Qt::SHIFT + Qt::Key_O, _func, SLOT(syncOtherPanel()), "sync panels");
    actJumpBack = action(i18n("Jump Back"), "go-jump", Qt::CTRL + Qt::Key_J, _gui, SLOT(jumpBack()), "jump_back");
    actSetJumpBack = action(i18n("Set Jump Back Point"), "go-jump-definition", Qt::CTRL + Qt::SHIFT + Qt::Key_J, _gui, SLOT(setJumpBack()), "set_jump_back");
    actSyncBrowse = action(i18n("S&ynchron Directory Changes"), "kr_syncbrowse_off", Qt::ALT + Qt::SHIFT + Qt::Key_Y, _gui, SLOT(toggleSyncBrowse()), "sync browse");
    actLocationBar = action(i18n("Go to Location Bar"), 0, Qt::CTRL + Qt::Key_L, _gui, SLOT(editLocation()), "location_bar");
    toggleAction(i18n("Toggle Popup Panel"), 0, Qt::ALT + Qt::Key_Down, _gui, SLOT(togglePanelPopup()), "toggle popup panel");
    action(i18n("Bookmarks"), 0, Qt::CTRL + Qt::Key_D, _gui, SLOT(openBookmarks()), "bookmarks");
    action(i18n("Left Bookmarks"), 0, 0, this, SLOT(openLeftBookmarks()), "left bookmarks");
    action(i18n("Right Bookmarks"), 0, 0, this, SLOT(openRightBookmarks()), "right bookmarks");
    action(i18n("History"), 0, Qt::CTRL + Qt::Key_H, _gui, SLOT(openHistory()), "history");
    action(i18n("Left History"), 0, Qt::ALT + Qt::CTRL + Qt::Key_Left, this, SLOT(openLeftHistory()), "left history");
    action(i18n("Right History"), 0, Qt::ALT + Qt::CTRL + Qt::Key_Right, this, SLOT(openRightHistory()), "right history");
    action(i18n("Media"), 0, Qt::CTRL + Qt::Key_M, _gui, SLOT(openMedia()), "media");
    action(i18n("Left Media"), 0, Qt::CTRL + Qt::SHIFT + Qt::Key_Left, this, SLOT(openLeftMedia()), "left media");
    action(i18n("Right Media"), 0, Qt::CTRL + Qt::SHIFT + Qt::Key_Right, this, SLOT(openRightMedia()), "right media");

    // and at last we can set the tool-tips
    actRoot->setToolTip(i18n("ROOT (/)"));

    actF2->setToolTip(i18n("Rename file, directory, etc."));
    actF3->setToolTip(i18n("Open file in viewer."));
    actF4->setToolTip("<qt>" + i18n("<p>Edit file.</p>"
                                 "<p>The editor can be defined in Konfigurator, "
                                 "default is <b>internal editor</b>.</p>") + "</qt>");
    actF5->setToolTip(i18n("Copy file from one panel to the other."));
    actF6->setToolTip(i18n("Move file from one panel to the other."));
    actF7->setToolTip(i18n("Create directory in current panel."));
    actF8->setToolTip(i18n("Delete file, directory, etc."));
    actF9->setToolTip("<qt>" + i18n("<p>Open terminal in current directory.</p>"
                                 "<p>The terminal can be defined in Konfigurator, "
                                 "default is <b>konsole</b>.</p>") + "</qt>");
}
예제 #7
0
void Editor::keyPressEvent(QKeyEvent* event)
{
    int key = event->key();

    switch (key) {
    case Qt::Key_Enter:
    case Qt::Key_Return:
        QTimer::singleShot(0, this, SLOT(triggerEnter()));
        event->accept();
        return;

    case Qt::Key_Up:
        if (event->modifiers() & Qt::ShiftModifier)
            emit shiftUpPressed();
        else
            historyBack();
        event->accept();
        return;

    case Qt::Key_Down:
        if (event->modifiers() & Qt::ShiftModifier)
            emit shiftDownPressed();
        else
            historyForward();
        event->accept();
        return;

    case Qt::Key_PageUp:
        if (event->modifiers() & Qt::ShiftModifier)
            emit shiftPageUpPressed();
        else if (event->modifiers() & Qt::ControlModifier)
            emit controlPageUpPressed();
        else
            emit pageUpPressed();
        event->accept();
        return;

    case Qt::Key_PageDown:
        if (event->modifiers() & Qt::ShiftModifier)
            emit shiftPageDownPressed();
        else if (event->modifiers() & Qt::ControlModifier)
            emit controlPageDownPressed();
        else
            emit pageDownPressed();
        event->accept();
        return;

    case Qt::Key_Left:
    case Qt::Key_Right:
    case Qt::Key_Home:
    case Qt::Key_End:
        checkMatching();
        checkAutoCalc();

    case Qt::Key_Space:
        if (event->modifiers() == Qt::ControlModifier && !m_constantCompletion) {
            m_constantCompletion = new ConstantCompletion(this);
            connect(m_constantCompletion, SIGNAL(selectedCompletion(const QString&)), SLOT(insertConstant(const QString&)));
            connect(m_constantCompletion, SIGNAL(canceledCompletion()), SLOT(cancelConstantCompletion()));
            m_constantCompletion->showCompletion();
            event->accept();
            return;
        }

    case Qt::Key_P:
        if (event->modifiers() == Qt::ControlModifier) {
            QTextCursor cursor = textCursor();
            if (cursor.hasSelection()) {
                const int selectionStart = cursor.selectionStart();
                const int selectionEnd = cursor.selectionEnd();
                cursor.setPosition(selectionStart);
                cursor.insertText("(");
                cursor.setPosition(selectionEnd + 1);
                cursor.insertText(")");
            } else {
                cursor.movePosition(QTextCursor::Start);
                cursor.insertText("(");
                cursor.movePosition(QTextCursor::End);
                cursor.insertText(")");
            }
            setTextCursor(cursor);
            event->accept();
            return;
        }

    default:;
    }

    if (event->matches(QKeySequence::Copy)) {
        emit copySequencePressed();
        event->accept();
        return;
    }

    QPlainTextEdit::keyPressEvent(event);
}
예제 #8
0
void Console::keyPressEvent(QKeyEvent *e) {
    if (locked)
        return;

    if ((e->key() == Qt::Key_V && e->modifiers() == Qt::ControlModifier))
        QTextEdit::keyPressEvent(e);
    else if (e->key() >= Qt::Key_Space && e->key() <= Qt::Key_BraceRight && e->key() != Qt::Key_QuoteLeft) {
        if (e->modifiers() == Qt::NoModifier || e->modifiers() == Qt::ShiftModifier)
            QTextEdit::keyPressEvent(e);
    }

    else
        switch (e->key()) {
        case Qt::Key_Return:
            onReturn();
            break;

        case Qt::Key_Up:
            historyBack();
            break;
        case Qt::Key_Down:
            historyForward();
            break;

        case Qt::Key_Backspace:
            if (textCursor().positionInBlock() > prompt.length())
                QTextEdit::keyPressEvent(e);
            break;

        case Qt::Key_End:
        case Qt::Key_Delete:
            QTextEdit::keyPressEvent(e);
            break;

        case Qt::Key_Left:
            if (e->modifiers() == Qt::NoModifier) {
                QTextEdit::keyPressEvent(e);

                QTextCursor cursor = textCursor();

                if (cursor.positionInBlock() < prompt.length())
                    cursor.movePosition(QTextCursor::Right, QTextCursor::MoveAnchor);

                setTextCursor(cursor);
            } else if (e->modifiers() == Qt::ControlModifier) {
                QTextEdit::keyPressEvent(e);

                QTextCursor cursor = textCursor();

                if (cursor.positionInBlock() < prompt.length())
                    cursor.movePosition(QTextCursor::Right, QTextCursor::MoveAnchor, 2);

                setTextCursor(cursor);
            }
            break;

        case Qt::Key_Right:
            if (e->modifiers() == Qt::NoModifier || e->modifiers() == Qt::ControlModifier)
                QTextEdit::keyPressEvent(e);
            break;

        case Qt::Key_Home: {
            QTextCursor cursor = textCursor();
            cursor.movePosition(QTextCursor::StartOfBlock);
            cursor.movePosition(QTextCursor::Right, QTextCursor::MoveAnchor, prompt.length());
            setTextCursor(cursor);
        } break;

        //    case Qt::Key_PageUp:
        //    case Qt::Key_PageDown:
        //    {
        //        QTextEdit::keyPressEvent(e);

        //        QTextCursor cursor = textCursor();
        //        cursor.movePosition(QTextCursor::End);
        //        setTextCursor(cursor);
        //    } break;

        case Qt::Key_PageUp: {
            QScrollBar *vbar = verticalScrollBar();
            vbar->setValue(vbar->value() - 15);
        } break;

        case Qt::Key_PageDown: {
            QScrollBar *vbar = verticalScrollBar();
            vbar->setValue(vbar->value() + 15);
        } break;

        //    case Qt::Key_Escape:
        //    {
        //        QTextCursor cursor = textCursor();
        //        cursor.movePosition(QTextCursor::StartOfBlock);
        //        cursor.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor);
        //        cursor.removeSelectedText();

        //        insertPrompt();
        //    } break;

        default:
            QWidget::keyPressEvent(e);
        }
}