Exemplo n.º 1
0
// --- LOAD BOOKMARK ---
// Loads a bookmark selected in the sidebar in the currently active window.
void MainWindow::loadBookmark(QTreeWidgetItem *item, int column) {
    QList<QVariant> data = item->data(0, Qt::UserRole).toList();
    QString url = data[0].toString();
    addressBar->setText(url);
    gotoURL();
    //gotoURL(url);
}
Exemplo n.º 2
0
// --- LOAD BOOKMARK ---
// Loads a selected bookmark into the currently active window.
void MainWindow::loadBookmark() {
    QAction* action = (QAction*) sender();
    QString url = action->data().toString();
    addressBar->setText(url);
    gotoURL();
    //gotoURL(url);
}
Exemplo n.º 3
0
// --- CONSTRUCTOR ---
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent) {
    setupUi(this);

    // menu connections
    connect(actionQuit, SIGNAL(triggered()), this, SLOT(quit()));
    connect(actionAbout_WildFox, SIGNAL(triggered()), this, SLOT(about()));
    connect(actionNewTab, SIGNAL(triggered()), this, SLOT(newTab()));
    connect(actionClose_Tab, SIGNAL(triggered()), this, SLOT(closeTab()));
    connect(actionOptions, SIGNAL(triggered()), this, SLOT(options()));
    connect(actionBookmarksSidebar, SIGNAL(triggered()), this, SLOT(sidebarBookmarks()));

    // other interface connections
    connect(backButton, SIGNAL(pressed()), this, SLOT(back()));
    connect(forwardButton, SIGNAL(pressed()), this, SLOT(forward()));
    connect(reloadButton, SIGNAL(pressed()), this, SLOT(loadInteraction()));
    tabWidget->addAction(actionReload);
    connect(actionReload, SIGNAL(triggered()), this, SLOT(reload()));
    connect(actionStop, SIGNAL(triggered()), this, SLOT(stop()));
    connect(addressBar, SIGNAL(returnPressed()), this, SLOT(gotoURL()));
    connect(addressBarGo, SIGNAL(pressed()), this, SLOT(gotoURL()));
    connect(tabWidget, SIGNAL(currentChanged(int)), this, SLOT(changeTab(int)));
    tabWidget->addAction(actionClose_Tab);
    connect(tabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int)));
    connect(bookmarksTree, SIGNAL(itemClicked(QTreeWidgetItem*,int)), this, SLOT(loadBookmark(QTreeWidgetItem*,int)));

    connect(actionBookmark_this_page, SIGNAL(triggered()), this, SLOT(bookmarkAdd()));

    addAction(actionGo_to_address_bar);
    connect(actionGo_to_address_bar, SIGNAL(triggered()), this, SLOT(gotoAddressBar()));

    // defaults
    QCoreApplication::setOrganizationName("Nyanko");
    QCoreApplication::setOrganizationDomain("nyanko.ws");
    QCoreApplication::setApplicationName("WildFox");
    QList<QNetworkProxy> proxies = QNetworkProxyFactory::systemProxyForQuery();
    QNetworkProxy::setApplicationProxy(proxies[0]);
    wv = 0;
    //icondb = "./";
    cookiejar = new CookieJar();
    bookmarks = new Bookmarks(this);
    nam = new QNetworkAccessManager(this);
    nam->setCookieJar(cookiejar);
    stopbutton = false;
    QApplication::setActiveWindow(this);
    //settings = new QSettings("Nyanko", "WildFox");
    settings = new QSettings();
    storagePath = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
    QDir dir(storagePath);
    if (!dir.exists()) {
        dir.mkpath(storagePath); // create path if it doesn't exist yet
    }

    qDebug() << "Storage path: " << storagePath;
    QWebSettings* ws = QWebSettings::globalSettings();
    ws->setAttribute(QWebSettings::PluginsEnabled, true);
    ws->setAttribute(QWebSettings::JavascriptCanOpenWindows, true);
    ws->setIconDatabasePath(storagePath);

    // load any extensions. For each found extension, read in the JSON manifest
    // and create a WebPage object for background scripts and load the extension
    // into it. Register URL filters.
    // TESTING: XMarks extension is at ./extensions/xmarks/manifest.json
    manifest.setFileName(QString("extensions/xmarks/manifest.json"));
    if (!manifest.exists() || !manifest.open(QIODevice::ReadOnly)) {
        qDebug() << "Failed to open the manifest file.";
    }
    else {
        QString manifestString = manifest.readAll();
        bool ok;
        QMap<QString, QVariant> result;
        result = QtJson::Json::parse(manifestString, ok).toMap();
        if (!ok) {
            qDebug() << "Parsing of manifest failed.";
        }

        if (result.contains("background_page")) {
            // load this extension into a webpage object.
            QWebPage* page = new QWebPage;
            page->mainFrame()->load(manifest.fileName());
            extPages.append(page);
        }

        if (result.contains("content_scripts")) {
            // add the content scripts in this list to the specified filters.
            QMap<QString, QVariant> scripts = result["content_scripts"].toMap();
            if (scripts.contains("matches")) {
                QList<QVariant> matches = scripts["matches"].toList();
                QList<QVariant> js = scripts["js"].toList();
                Filter filter;
                filter.extId = extPages.size() - 1;
                for (int i = 0; i < js.size(); ++i) {
                    filter.scripts.append(QString("extensions/xmarks/") + js[i].toString());
                }

                for (int i = 0; i < matches.size(); ++i) {
                    QStringList urlbit = matches[i].toString().split("://");
                    if (urlbit.size() < 2) {
                        continue;
                    }
                    filter.scheme = urlbit[0];
                    filter.segments = urlbit[1].split(".");
                    if (filter.scripts.size() < 1 || filter.segments.size() < 1) {
                        break; // empty/useless filter, skip
                    }

                    extFilters.append(filter);
                }
            }
        }
    }

    // pass extension filter data to the network access manager
    //nam->setFilters(extFilters);

    // open empty tab
    newTab();
}
Exemplo n.º 4
0
// --- GO TO URL ---
// Go to the URL in the addressbar in the currently open tab. If no tab is open,
// open a new tab.
void MainWindow::gotoURL() {
    QString url = addressBar->text();
    gotoURL(url);
}
Exemplo n.º 5
0
void VisionPipeLine::s_on_upgrade_clicked(void * data, int button, int x, int y)
{
    VisionPipeLine * This = reinterpret_cast<VisionPipeLine *>(data);

    gotoURL(This->_upgrade_url.c_str());
}
Exemplo n.º 6
0
void VisionPipeLine::s_on_rplogo_clicked(void * data, int button, int x, int y)
{
    gotoURL("http://www.robopeak.com");
}