Ejemplo n.º 1
0
void WBTabBar::contextMenuRequested(const QPoint &position)
{
    QMenu menu;
    menu.addAction(tr("New &Tab"), this, SIGNAL(newTab()), QKeySequence::AddTab);
    int index = tabAt(position);
    if (-1 != index) {
        QAction *action = menu.addAction(tr("Clone Tab"), this, SLOT(cloneTab()));
        action->setData(index);

        menu.addSeparator();

        action = menu.addAction(tr("&Close Tab"), this, SLOT(closeTab()), QKeySequence::Close);
        action->setData(index);

        action = menu.addAction(tr("Close &Other Tabs"), this, SLOT(closeOtherTabs()));
        action->setData(index);

        menu.addSeparator();

        action = menu.addAction(tr("Reload Tab"), this, SLOT(reloadTab()), QKeySequence::Refresh);
        action->setData(index);
    }
    else {
        menu.addSeparator();
    }
    menu.addAction(tr("Reload All Tabs"), this, SIGNAL(reloadAllTabs()));
    menu.exec(QCursor::pos());
}
Ejemplo n.º 2
0
void WBTabBar::reloadTab()
{
    if (QAction *action = qobject_cast<QAction*>(sender())) {
        int index = action->data().toInt();
        emit reloadTab(index);
    }
}
Ejemplo n.º 3
0
void UserAgentManager::setUserAgent()
{
    QAction *sender = static_cast<QAction *>(QObject::sender());

    int uaIndex = sender->data().toInt();

    UserAgentInfo uaInfo;
    uaInfo.setUserAgentForHost(uaIndex, m_uaTab.data()->url().host());
    emit reloadTab();
}
Ejemplo n.º 4
0
void TabBar::contextMenuRequested(const QPoint &position)
{
    QMenu menu;
    TabWidget *tabWidget = qobject_cast<TabWidget *>(parentWidget());
    if (!tabWidget)
        return;

    menu.addAction(tabWidget->newTabAction());
    int index = tabAt(position);
    if (-1 != index) {
        QAction *action = menu.addAction(tr("Duplicate Tab"),
                                         this, SLOT(cloneTab()));
        action->setData(index);

        menu.addSeparator();

        action = menu.addAction(tr("&Close Tab"),
                                this, SLOT(closeTab()), QKeySequence::Close);
        action->setData(index);

        action = menu.addAction(tr("Close &Other Tabs"),
                                this, SLOT(closeOtherTabs()));
        action->setData(index);

        menu.addSeparator();

        action = menu.addAction(tr("Reload Tab"),
                                this, SLOT(reloadTab()), QKeySequence::Refresh);
        action->setData(index);
    } else {
        menu.addSeparator();
    }
    menu.addAction(tr("Reload All Tabs"), this, SIGNAL(reloadAllTabs()));
    menu.addSeparator();
    menu.addAction(tabWidget->bookmarkTabsAction());
    menu.exec(QCursor::pos());
}
Ejemplo n.º 5
0
void TabBar::reloadTab()
{
    emit reloadTab(m_actualIndex);
    m_actualIndex = -1;
}
Ejemplo n.º 6
0
void MainWindow::reloadCurrentTab() {
    reloadTab(m_tabWidget->currentIndex());
}
Ejemplo n.º 7
0
void UserAgentManager::populateUAMenuForTabUrl(KMenu *uaMenu, WebTab *uaTab)
{
    if (!m_uaTab.isNull())
    {
        disconnect(this, SIGNAL(reloadTab()), m_uaTab.data()->view(), SLOT(reload()));
        m_uaTab.clear();
    }

    m_uaTab = uaTab;
    connect(this, SIGNAL(reloadTab()), m_uaTab.data()->view(), SLOT(reload()));

    bool defaultUA = true;

    QAction *a, *defaultAction;

    // just to be sure...
    uaMenu->clear();

    defaultAction = new QAction(i18nc("Default rekonq user agent", "Default"), uaMenu);
    defaultAction->setData(-1);
    defaultAction->setCheckable(true);
    connect(defaultAction, SIGNAL(triggered(bool)), this, SLOT(setUserAgent()));

    uaMenu->addAction(defaultAction);
    uaMenu->addSeparator();

    // Main Browsers Menus
    KMenu *ffMenu = new KMenu(i18n("Firefox"), uaMenu);
    uaMenu->addMenu(ffMenu);

    KMenu *ieMenu = new KMenu(i18n("Internet Explorer"), uaMenu);
    uaMenu->addMenu(ieMenu);

    KMenu *nsMenu = new KMenu(i18n("Netscape"), uaMenu);
    uaMenu->addMenu(nsMenu);

    KMenu *opMenu = new KMenu(i18n("Opera"), uaMenu);
    uaMenu->addMenu(opMenu);

    KMenu *sfMenu = new KMenu(i18n("Safari"), uaMenu);
    uaMenu->addMenu(sfMenu);

    KMenu *otMenu = new KMenu(i18n("Other"), uaMenu);
    uaMenu->addMenu(otMenu);

    UserAgentInfo uaInfo;
    QStringList UAlist = uaInfo.availableUserAgents();
    const KService::List providers = uaInfo.availableProviders();
    int uaIndex = uaInfo.uaIndexForHost(m_uaTab.data()->url().host());

    for (int i = 0; i < UAlist.count(); ++i)
    {
        QString uaDesc = UAlist.at(i);

        a = new QAction(uaDesc, uaMenu);
        a->setData(i);
        a->setCheckable(true);
        connect(a, SIGNAL(triggered(bool)), this, SLOT(setUserAgent()));

        if (i == uaIndex)
        {
            a->setChecked(true);
            defaultUA = false;
        }

        QString tag = providers.at(i)->property("X-KDE-UA-TAG").toString();
        if (tag == QL1S("FF"))
        {
            ffMenu->addAction(a);
        }
        else if (tag == QL1S("IE"))
        {
            ieMenu->addAction(a);
        }
        else if (tag == QL1S("NN"))
        {
            nsMenu->addAction(a);
        }
        else if (tag == QL1S("OPR"))
        {
            opMenu->addAction(a);
        }
        else if (tag == QL1S("SAF"))
        {
            sfMenu->addAction(a);
        }
        else    // OTHERs
        {
            otMenu->addAction(a);
        }
    }
    defaultAction->setChecked(defaultUA);

    uaMenu->addSeparator();
    uaMenu->addAction(m_uaSettingsAction);
}
Ejemplo n.º 8
0
void TabBar::contextMenuRequested(const QPoint &position)
{
    int index = tabAt(position);
    m_clickedTab = index;

    QMenu menu;
    menu.addAction(QIcon(":/icons/menu/new-tab.png"), tr("&New tab"), p_QupZilla, SLOT(addTab()));
    menu.addSeparator();
    if (index != -1) {
        WebTab* webTab = qobject_cast<WebTab*>(m_tabWidget->widget(m_clickedTab));
        if (!webTab) {
            return;
        }
        if (p_QupZilla->weView(m_clickedTab)->isLoading()) {
            menu.addAction(qIconProvider->standardIcon(QStyle::SP_BrowserStop), tr("&Stop Tab"), this, SLOT(stopTab()));
        }
        else {
            menu.addAction(qIconProvider->standardIcon(QStyle::SP_BrowserReload), tr("&Reload Tab"), this, SLOT(reloadTab()));
        }

        menu.addAction(tr("&Duplicate Tab"), this, SLOT(duplicateTab()));
        menu.addAction(webTab->isPinned() ? tr("Un&pin Tab") : tr("&Pin Tab"), this, SLOT(pinTab()));
        menu.addSeparator();
        menu.addAction(tr("Re&load All Tabs"), m_tabWidget, SLOT(reloadAllTabs()));
        menu.addAction(tr("&Bookmark This Tab"), this, SLOT(bookmarkTab()));
        menu.addAction(tr("Bookmark &All Tabs"), p_QupZilla, SLOT(bookmarkAllTabs()));
        menu.addSeparator();
        QAction* action = p_QupZilla->actionRestoreTab();
        action->setEnabled(m_tabWidget->canRestoreTab());
        menu.addAction(action);
        menu.addSeparator();
        menu.addAction(tr("Close Ot&her Tabs"), this, SLOT(closeAllButCurrent()));
        menu.addAction(QIcon::fromTheme("window-close"), tr("Cl&ose"), this, SLOT(closeTab()));
        menu.addSeparator();
    }
    else {
        menu.addAction(tr("Reloa&d All Tabs"), m_tabWidget, SLOT(reloadAllTabs()));
        menu.addAction(tr("Bookmark &All Ta&bs"), p_QupZilla, SLOT(bookmarkAllTabs()));
        menu.addSeparator();
        QAction* action = menu.addAction(QIcon::fromTheme("user-trash"), tr("Restore &Closed Tab"), m_tabWidget, SLOT(restoreClosedTab()));
        action->setEnabled(m_tabWidget->canRestoreTab());
    }

    // Prevent choosing first option with double rightclick
    const QPoint &pos = mapToGlobal(position);
    QPoint p(pos.x(), pos.y() + 1);
    menu.exec(p);

    p_QupZilla->actionRestoreTab()->setEnabled(true);
}
Ejemplo n.º 9
0
void TabBar::contextMenuEvent(QContextMenuEvent* event)
{
    int index = tabAt(event->pos());
    m_clickedTab = index;

    QMenu menu;
    menu.addAction(IconProvider::newTabIcon(), tr("&New tab"), m_window, SLOT(addTab()));
    menu.addSeparator();
    if (index != -1) {
        WebTab* webTab = qobject_cast<WebTab*>(m_tabWidget->widget(m_clickedTab));
        if (!webTab) {
            return;
        }

        if (m_window->weView(m_clickedTab)->isLoading()) {
            menu.addAction(QIcon::fromTheme(QSL("process-stop")), tr("&Stop Tab"), this, SLOT(stopTab()));
        }
        else {
            menu.addAction(QIcon::fromTheme(QSL("view-refresh")), tr("&Reload Tab"), this, SLOT(reloadTab()));
        }

        menu.addAction(QIcon::fromTheme("tab-duplicate"), tr("&Duplicate Tab"), this, SLOT(duplicateTab()));

        if (count() > 1 && !webTab->isPinned()) {
            menu.addAction(QIcon::fromTheme("tab-detach"), tr("D&etach Tab"), this, SLOT(detachTab()));
        }

        menu.addAction(webTab->isPinned() ? tr("Un&pin Tab") : tr("&Pin Tab"), this, SLOT(pinTab()));
        menu.addSeparator();
        menu.addAction(tr("Re&load All Tabs"), m_tabWidget, SLOT(reloadAllTabs()));
        menu.addAction(tr("&Bookmark This Tab"), this, SLOT(bookmarkTab()));
        menu.addAction(tr("Bookmark &All Tabs"), m_window, SLOT(bookmarkAllTabs()));
        menu.addSeparator();
        menu.addAction(m_window->action(QSL("Other/RestoreClosedTab")));
        menu.addSeparator();
        menu.addAction(tr("Close Ot&her Tabs"), this, SLOT(closeAllButCurrent()));
        menu.addAction(QIcon::fromTheme("window-close"), tr("Cl&ose"), this, SLOT(closeTab()));
        menu.addSeparator();
    }
    else {
        menu.addAction(tr("Reloa&d All Tabs"), m_tabWidget, SLOT(reloadAllTabs()));
        menu.addAction(tr("Bookmark &All Tabs"), m_window, SLOT(bookmarkAllTabs()));
        menu.addSeparator();
        menu.addAction(m_window->action(QSL("Other/RestoreClosedTab")));
    }

    m_window->action(QSL("Other/RestoreClosedTab"))->setEnabled(m_tabWidget->canRestoreTab());

    // Prevent choosing first option with double rightclick
    const QPoint pos = event->globalPos();
    QPoint p(pos.x(), pos.y() + 1);
    menu.exec(p);

    m_window->action(QSL("Other/RestoreClosedTab"))->setEnabled(true);
}