Ejemplo n.º 1
0
void Lvk::FE::ChatHistoryWidget::showRuleWithDialog(int row)
{
    //QString chatMsg = ui->conversationTable->item(row, MessageColumn)->text();

    //QString title = tr("Show rule definition");
    //QString text = QString(tr("Show rule definition for message: \"%1\" ?")).arg(chatMsg);

    //if (askConfirmation(title, text)) {
        quint64 ruleId = ui->conversationTable->item(row, StatusColumn)->data(EntryRuleIdRole)
                .toULongLong();

        emit showRule(ruleId);
    //}
}
Ejemplo n.º 2
0
void AdBlockIcon::createMenu(QMenu* menu)
{
    if (!menu) {
        menu = qobject_cast<QMenu*>(sender());
        if (!menu) {
            return;
        }
    }

    menu->clear();

    AdBlockManager* manager = AdBlockManager::instance();
    AdBlockCustomList* customList = manager->customList();

    WebPage* page = p_QupZilla->weView()->page();
    const QUrl &pageUrl = page->url();

    menu->addAction(tr("Show AdBlock &Settings"), manager, SLOT(showDialog()));
    menu->addSeparator();

    if (!pageUrl.host().isEmpty() && m_enabled && manager->canRunOnScheme(pageUrl.scheme())) {
        const QString &host = page->url().host().contains(QLatin1String("www.")) ? pageUrl.host().mid(4) : pageUrl.host();
        const QString &hostFilter = QString("@@||%1^$document").arg(host);
        const QString &pageFilter = QString("@@|%1|$document").arg(pageUrl.toString());

        QAction* act = menu->addAction(tr("Disable on %1").arg(host));
        act->setCheckable(true);
        act->setChecked(customList->containsFilter(hostFilter));
        act->setData(hostFilter);
        connect(act, SIGNAL(triggered()), this, SLOT(toggleCustomFilter()));

        act = menu->addAction(tr("Disable only on this page"));
        act->setCheckable(true);
        act->setChecked(customList->containsFilter(pageFilter));
        act->setData(pageFilter);
        connect(act, SIGNAL(triggered()), this, SLOT(toggleCustomFilter()));

        menu->addSeparator();
    }

    if (!m_blockedPopups.isEmpty()) {
        menu->addAction(tr("Blocked Popup Windows"))->setEnabled(false);
        for (int i = 0; i < m_blockedPopups.count(); i++) {
            const QPair<AdBlockRule, QUrl> &pair = m_blockedPopups.at(i);

            QString address = pair.second.toString().right(55);
            QString actionText = tr("%1 with (%2)").arg(address, pair.first.filter()).replace(QLatin1Char('&'), QLatin1String("&&"));

            QAction* action = menu->addAction(actionText, manager, SLOT(showRule()));
            action->setData(qVariantFromValue((void*)&pair.first));
        }
    }

    menu->addSeparator();
    QList<WebPage::AdBlockedEntry> entries = page->adBlockedEntries();
    if (entries.isEmpty()) {
        menu->addAction(tr("No content blocked"))->setEnabled(false);
    }
    else {
        menu->addAction(tr("Blocked URL (AdBlock Rule) - click to edit rule"))->setEnabled(false);
        foreach(const WebPage::AdBlockedEntry & entry, entries) {
            QString address = entry.url.toString().right(55);
            QString actionText = tr("%1 with (%2)").arg(address, entry.rule->filter()).replace(QLatin1Char('&'), QLatin1String("&&"));

            QAction* action = menu->addAction(actionText, manager, SLOT(showRule()));
            action->setData(qVariantFromValue((void*)entry.rule));
        }
    }
Ejemplo n.º 3
0
void AdBlockIcon::showMenu(const QPoint &pos)
{
    AdBlockManager* manager = AdBlockManager::instance();

    QMenu menu;
    menu.addAction(tr("Show AdBlock &Settings"), manager, SLOT(showDialog()));
    menu.addSeparator();
    QList<WebPage::AdBlockedEntry> entries = p_QupZilla->weView()->webPage()->adBlockedEntries();
    if (entries.isEmpty()) {
        menu.addAction(tr("No content blocked"))->setEnabled(false);
    }
    else {
        menu.addAction(tr("Blocked URL (AdBlock Rule) - click to edit rule"))->setEnabled(false);
        foreach(WebPage::AdBlockedEntry entry, entries) {
            QString address = entry.url.toString().right(55);
            menu.addAction(tr("%1 with (%2)").arg(address, entry.rule), manager, SLOT(showRule()))->setData(entry.rule);
        }
    }
Ejemplo n.º 4
0
void AdBlockIcon::createMenu(QMenu* menu)
{
    if (!menu) {
        menu = qobject_cast<QMenu*>(sender());
        if (!menu) {
            return;
        }
    }

    menu->clear();

    AdBlockManager* manager = AdBlockManager::instance();

    menu->addAction(tr("Show AdBlock &Settings"), manager, SLOT(showDialog()));
    menu->addSeparator();
    if (!m_blockedPopups.isEmpty()) {
        menu->addAction(tr("Blocked Popup Windows"))->setEnabled(false);
        for (int i = 0; i < m_blockedPopups.count(); i++) {
            const QPair<QString, QUrl> &pair = m_blockedPopups.at(i);
            QString address = pair.second.toString().right(55);
            menu->addAction(tr("%1 with (%2)").arg(address, pair.first).replace("&", "&&"), manager, SLOT(showRule()))->setData(pair.first);
        }
    }

    menu->addSeparator();
    QList<WebPage::AdBlockedEntry> entries = p_QupZilla->weView()->page()->adBlockedEntries();
    if (entries.isEmpty()) {
        menu->addAction(tr("No content blocked"))->setEnabled(false);
    }
    else {
        menu->addAction(tr("Blocked URL (AdBlock Rule) - click to edit rule"))->setEnabled(false);
        foreach(const WebPage::AdBlockedEntry & entry, entries) {
            QString address = entry.url.toString().right(55);
            menu->addAction(tr("%1 with (%2)").arg(address, entry.rule).replace("&", "&&"), manager, SLOT(showRule()))->setData(entry.rule);
        }
    }