Esempio n. 1
0
void HistoryManager::openLink(const QUrl &url, HistoryView::OpenBehavior openIn)
{
    if (openIn == HistoryView::OpenInNewTab) {
        getQupZilla()->tabWidget()->addView(url, WebSettings::newTabPosition);
    }
    else {
        getQupZilla()->weView()->load(url);
    }
}
Esempio n. 2
0
bool RSSManager::addRssFeed(const QUrl &url, const QString &title, const QIcon &icon)
{
    if (url.isEmpty()) {
        return false;
    }
    QSqlQuery query;
    query.prepare("SELECT id FROM rss WHERE address=?");
    query.addBindValue(url);
    query.exec();

    if (!query.next()) {
        QImage image = icon.pixmap(16, 16).toImage();

        if (image == IconProvider::emptyWebImage()) {
            image.load(":icons/menu/rss.png");
        }

        query.prepare("INSERT INTO rss (address, title, icon) VALUES(?,?,?)");
        query.bindValue(0, url);
        query.bindValue(1, title);
        QByteArray ba;
        QBuffer buffer(&ba);
        buffer.open(QIODevice::WriteOnly);
        image.save(&buffer, "PNG");
        query.bindValue(2, buffer.data());
        query.exec();
        return true;
    }

    QMessageBox::warning(getQupZilla(), tr("RSS feed duplicated"), tr("You already have this feed."));
    return false;
}
Esempio n. 3
0
void RSSManager::customContextMenuRequested(const QPoint &position)
{
    TreeWidget* treeWidget = qobject_cast<TreeWidget*>(ui->tabWidget->widget(ui->tabWidget->currentIndex()));
    if (!treeWidget) {
        return;
    }

    if (!treeWidget->itemAt(position)) {
        return;
    }

    QString link = treeWidget->itemAt(position)->toolTip(0);
    if (link.isEmpty()) {
        return;
    }

    QMenu menu;
    menu.addAction(tr("Open link in current tab"), getQupZilla(), SLOT(loadActionUrl()))->setData(link);
    menu.addAction(tr("Open link in new tab"), this, SLOT(loadFeedInNewTab()))->setData(link);
    menu.addAction(tr("Open link in &private window"), mApp, SLOT(startPrivateBrowsing()))->setData(link);

    //Prevent choosing first option with double rightclick
    QPoint pos = treeWidget->viewport()->mapToGlobal(position);
    QPoint p(pos.x(), pos.y() + 1);
    menu.exec(p);
}
Esempio n. 4
0
bool RSSManager::addRssFeed(const QString &address, const QString &title, const QIcon &icon)
{
    if (address.isEmpty()) {
        return false;
    }
    QSqlQuery query;
    query.exec("SELECT id FROM rss WHERE address='" + address + "'");
    if (!query.next()) {
        QImage image = icon.pixmap(16, 16).toImage();
        QByteArray iconData;
        if (image == QWebSettings::webGraphic(QWebSettings::DefaultFrameIconGraphic).toImage()) {
            image.load(":icons/other/feed.png");
        }

        query.prepare("INSERT INTO rss (address, title, icon) VALUES(?,?,?)");
        query.bindValue(0, address);
        query.bindValue(1, title);
        QByteArray ba;
        QBuffer buffer(&ba);
        buffer.open(QIODevice::WriteOnly);
        image.save(&buffer, "PNG");
        query.bindValue(2, buffer.data());
        mApp->dbWriter()->executeQuery(query);
        return true;
    }

    QMessageBox::warning(getQupZilla(), tr("RSS feed duplicated"), tr("You already have this feed."));
    return false;
}
Esempio n. 5
0
void RSSManager::controlLoadFeed(QTreeWidgetItem* item)
{
    if (!item || item->toolTip(0).isEmpty()) {
        return;
    }

    getQupZilla()->tabWidget()->addView(QUrl(item->toolTip(0)), qzSettings->newTabPosition);
}
Esempio n. 6
0
void HistoryManager::itemDoubleClicked(QTreeWidgetItem* item)
{
    if (!item || item->text(1).isEmpty()) {
        return;
    }

    QUrl url = QUrl::fromEncoded(item->text(1).toUtf8());
    getQupZilla()->tabWidget()->addView(url, item->text(0));
}
Esempio n. 7
0
void RSSManager::loadFeed(QTreeWidgetItem* item)
{
    if (!item) {
        return;
    }
    if (item->toolTip(0).isEmpty()) {
        return;
    }
    getQupZilla()->loadAddress(QUrl(item->toolTip(0)));
}
Esempio n. 8
0
void RSSManager::controlLoadFeed(QTreeWidgetItem* item)
{
    if (!item) {
        return;
    }
    if (item->whatsThis(0).isEmpty()) {
        return;
    }
    getQupZilla()->tabWidget()->addView(QUrl(item->whatsThis(0)), Qz::NT_NotSelectedTab);
}
Esempio n. 9
0
void HistoryManager::contextMenuRequested(const QPoint &position)
{
    if (!ui->historyTree->itemAt(position)) {
        return;
    }
    QUrl link = QUrl::fromEncoded(ui->historyTree->itemAt(position)->text(1).toUtf8());
    if (link.isEmpty()) {
        return;
    }

    QMenu menu;
    menu.addAction(tr("Open link in current tab"), getQupZilla(), SLOT(loadActionUrl()))->setData(link);
    menu.addAction(tr("Open link in new tab"), this, SLOT(loadInNewTab()))->setData(link);
    menu.addSeparator();
    menu.addAction(tr("Copy address"), this, SLOT(copyUrl()))->setData(link);

    //Prevent choosing first option with double rightclick
    QPoint pos = QCursor::pos();
    QPoint p(pos.x(), pos.y() + 1);
    menu.exec(p);
}
Esempio n. 10
0
void HistoryManager::loadInNewTab()
{
    if (QAction* action = qobject_cast<QAction*>(sender())) {
        getQupZilla()->tabWidget()->addView(action->data().toUrl(), Qz::NT_NotSelectedTab);
    }
}
Esempio n. 11
0
void RSSManager::loadFeedInNewTab()
{
    if (QAction* action = qobject_cast<QAction*>(sender())) {
        getQupZilla()->tabWidget()->addView(action->data().toUrl(), qzSettings->newTabPosition);
    }
}
Esempio n. 12
0
void BookmarksManager::openBookmarkInNewTab(BookmarkItem* item)
{
    item = item ? item : m_selectedBookmark;
    BookmarksTools::openBookmarkInNewTab(getQupZilla(), item);
}