Example #1
0
void LocationCompleter::indexCtrlActivated(const QModelIndex &index)
{
    Q_ASSERT(index.isValid());
    Q_ASSERT(m_window);

    closePopup();

    // Clear locationbar
    emit clearCompletion();

    // Load request in new tab
    m_window->tabWidget()->addView(createLoadRequest(index), Qz::NT_CleanSelectedTab);
}
Example #2
0
void LocationBar::requestLoadUrl()
{
    const LoadRequest req = createLoadRequest();
    const QString urlString = convertUrlToText(req.url());

    m_completer->closePopup();
    m_webView->setFocus();

    if (urlString != text()) {
        setText(urlString);
    }

    m_webView->userLoadAction(req);
}
Example #3
0
void LocationCompleter::indexShiftActivated(const QModelIndex &index)
{
    Q_ASSERT(index.isValid());

    closePopup();

    // Clear locationbar
    emit clearCompletion();

    // Load request
    if (index.data(LocationCompleterModel::VisitSearchItemRole).toBool()) {
        loadRequest(LoadRequest(QUrl(m_originalText)));
    } else {
        loadRequest(createLoadRequest(index));
    }
}
Example #4
0
void LocationCompleter::indexActivated(const QModelIndex &index)
{
    Q_ASSERT(index.isValid());

    closePopup();

    // Clear locationbar
    emit clearCompletion();

    bool ok;
    const int tabPos = index.data(LocationCompleterModel::TabPositionTabRole).toInt(&ok);

    // Switch to tab with simple index activation
    if (ok && tabPos > -1) {
        BrowserWindow* window = static_cast<BrowserWindow*>(index.data(LocationCompleterModel::TabPositionWindowRole).value<void*>());
        Q_ASSERT(window);
        switchToTab(window, tabPos);
        return;
    }

    loadRequest(createLoadRequest(index));
}
Example #5
0
void LocationBar::keyPressEvent(QKeyEvent* event)
{
    switch (event->key()) {
    case Qt::Key_V:
        if (event->modifiers() == (Qt::ControlModifier | Qt::ShiftModifier)) {
            pasteAndGo();
            event->accept();
            return;
        }
        break;

    case Qt::Key_Down:
        m_completer->complete(text());
        break;

    case Qt::Key_Left:
        m_completer->closePopup();
        break;

    case Qt::Key_Escape:
        m_webView->setFocus();
        showUrl(m_webView->url());
        event->accept();
        break;

    case Qt::Key_Alt:
        m_holdingAlt = true;
        break;

    case Qt::Key_Return:
    case Qt::Key_Enter:
        switch (event->modifiers()) {
        case Qt::ControlModifier:
            setText(text().append(QLatin1String(".com")));
            requestLoadUrl();
            m_holdingAlt = false;
            break;

        case Qt::AltModifier:
            m_completer->closePopup();
            m_window->tabWidget()->addView(createLoadRequest());
            m_holdingAlt = false;
            break;

        default:
            requestLoadUrl();
            m_holdingAlt = false;
        }

        break;

    case Qt::Key_0:
    case Qt::Key_1:
    case Qt::Key_2:
    case Qt::Key_3:
    case Qt::Key_4:
    case Qt::Key_5:
    case Qt::Key_6:
    case Qt::Key_7:
    case Qt::Key_8:
    case Qt::Key_9:
        if (event->modifiers() & Qt::AltModifier || event->modifiers() & Qt::ControlModifier) {
            event->ignore();
            m_holdingAlt = false;
            return;
        }
        break;

    default:
        m_holdingAlt = false;
    }

    LineEdit::keyPressEvent(event);
}