Skip to content

Commit

Permalink
add 'open in new window' feature to qtouchweb
Browse files Browse the repository at this point in the history
  • Loading branch information
penk committed Dec 30, 2010
1 parent b0c236d commit d8ba2f1
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
20 changes: 17 additions & 3 deletions skeleton/archive/qtouchweb/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,29 @@ void LineEdit::updateCloseButton(const QString& text)
clearButton->setVisible(!text.isEmpty());
}

QWebPage *WebPage::createWindow(QWebPage::WebWindowType)
{
MainWindow *mw = new MainWindow;
mw->show();
return mw->webPage();
}

QWebPage *MainWindow::webPage()
{
return view->page();
}

MainWindow::MainWindow()
{
progress = 0;

QNetworkProxyFactory::setUseSystemConfiguration(true);

view = new QWebView(this);
view->load(QUrl("http://www.google.com/ncr"));
WebPage* page = new WebPage(view);
view->setPage(page);
view->load(QUrl("http://www.google.com/ncr"));

FlickCharm *flickCharm = new FlickCharm(this);
flickCharm->activateOn(view);

Expand All @@ -104,10 +119,9 @@ MainWindow::MainWindow()
toolBar->addAction(view->pageAction(QWebPage::Back));
toolBar->addAction(view->pageAction(QWebPage::Forward));
toolBar->addWidget(locationEdit);
toolBar->addAction(view->pageAction(QWebPage::Reload));
toolBar->addAction(view->pageAction(QWebPage::Reload));

setCentralWidget(view);
setUnifiedTitleAndToolBarOnMac(true);
}

void MainWindow::adjustLocation()
Expand Down
10 changes: 10 additions & 0 deletions skeleton/archive/qtouchweb/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

#include <QtGui>
#include <QLineEdit>
#include <QtWebKit>

class QWebView;
QT_BEGIN_NAMESPACE
Expand All @@ -66,12 +67,20 @@ private slots:
QToolButton *clearButton;
};

class WebPage : public QWebPage {
public:
WebPage(QWidget *parent) : QWebPage(parent) {}
virtual QWebPage *createWindow(QWebPage::WebWindowType);
};


class MainWindow : public QMainWindow
{
Q_OBJECT

public:
MainWindow();
QWebPage *webPage();

protected slots:

Expand All @@ -83,6 +92,7 @@ protected slots:

private:
QWebView *view;
WebPage *page;
LineEdit *locationEdit;
int progress;
};

0 comments on commit d8ba2f1

Please sign in to comment.