Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 3f730b6067
Fetching contributors…

Cannot retrieve contributors at this time

file 104 lines (87 sloc) 3.168 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
#include <QtGui/QApplication>
#include <QtGui/QBoxLayout>
#include <QtGui/QProgressBar>
#include <QtGui/QPixmap>
//#include <QtGui/QLabel>
//#include <QtGui/QWidget>
//#include <QtWebKit/QWebView>

#include <iostream>
#include <fstream>
#include <sstream>
//#include <cctype>

#include "browser.h"
#include "linkedit.h"
#include "locationedit.h"
#include "commandedit.h"
#include "insertlabel.h"

void parseBindings(std::string file) {
std::string line, cmd, function, args;
std::ifstream myfile("config/bindings");
if (myfile.is_open()) {
while (! myfile.eof() ) {
cmd = function = args = "";
std::getline( myfile, line );
std::istringstream iss(line, std::istringstream::in);
iss >> cmd;
if (cmd != "" && cmd[0] != '#') {
iss >> function >> args;
if (function != "") {
if (cmd.length() == 1) {
// std::cout << cmd << " " << function << " " << args << std::endl;
// shortcuts[ QPair<uint, char>(Qt::NoModifier, cmd[0]) ] = commands[QString::fromStdString(function)];
}
}
else {
std::cerr << "No function for command: [" << cmd << "]" << std::endl;
continue;
}
}
}
myfile.close();
}
else std::cerr << "Unable to open bindings" << std::endl;
}

int main(int argc, char * argv[]) {
QApplication app(argc, argv);
QWidget *widget = new QWidget;

CommandEdit *command = new CommandEdit;

InsertLabel *insertLabel = new InsertLabel;

LocationEdit *address = new LocationEdit(widget); //(QString("http://www.google.com"));
address->setFocusPolicy(Qt::ClickFocus);

LinkEdit *link_target = new LinkEdit(widget);
link_target->setFocusPolicy(Qt::NoFocus);

QHBoxLayout *statusBar = new QHBoxLayout;
QVBoxLayout *vlayout = new QVBoxLayout;

statusBar->setContentsMargins(0,0,0,0);
statusBar->addWidget(insertLabel);
statusBar->addWidget(address);
statusBar->addWidget(link_target);

Browser *browser = new Browser;

vlayout->setContentsMargins(0,0,0,0);
vlayout->setSpacing(0);

vlayout->addLayout(statusBar);
vlayout->addWidget(command);
vlayout->addWidget(browser);

widget->setLayout(vlayout);
widget->show();

////////////////////////////////////////////////////////////////////
//////////////////////// SIGNALS & SLOTS ///////////////////////////
////////////////////////////////////////////////////////////////////

// command text
// QObject::connect(browser, SIGNAL(commandChanged(const QString &)),
// command, SLOT(setText(const QString &)));
// display hovered link
QObject::connect(browser->page(), SIGNAL(linkHovered(const QString &, const QString &, const QString &)),
link_target, SLOT(setLink(const QString &, const QString &, const QString &)));
QObject::connect(browser, SIGNAL(urlChanged(const QUrl &)),
address, SLOT(setUrl(const QUrl &)));
QObject::connect(browser, SIGNAL(modeChanged(bool)),
insertLabel, SLOT(modeChanged(bool)));
QObject::connect(browser, SIGNAL(editUrl(bool)),
address, SLOT(editUrl(bool)));
QObject::connect(address, SIGNAL(urlChanged(const QUrl &)),
browser, SLOT(loadUrl(const QUrl &)));
QObject::connect(address, SIGNAL(focusBrowser(void)),
browser, SLOT(receiveFocus(void)));

return app.exec();
}
Something went wrong with that request. Please try again.