Commit c4ea075e authored by kenneth@webkit.org's avatar kenneth@webkit.org

Rubberstamped by Simon Hausmann.

[Qt] Separate implementation from class definition.

* QtLauncher/main.cpp:
(LauncherWindow::webView):
(LauncherWindow::LauncherWindow):
(LauncherWindow::~LauncherWindow):
(LauncherWindow::keyPressEvent):
(LauncherWindow::grabZoomKeys):
(LauncherWindow::sendTouchEvent):
(LauncherWindow::eventFilter):
(LauncherWindow::loadStarted):
(LauncherWindow::loadFinished):
(LauncherWindow::showLinkHover):
(LauncherWindow::zoomIn):
(LauncherWindow::zoomOut):
(LauncherWindow::resetZoom):
(LauncherWindow::toggleZoomTextOnly):
(LauncherWindow::print):
(LauncherWindow::screenshot):
(LauncherWindow::setEditable):
(LauncherWindow::dumpHtml):
(LauncherWindow::selectElements):
(LauncherWindow::setTouchMocking):
(LauncherWindow::newWindow):
(LauncherWindow::setupUI):

git-svn-id: svn://svn.chromium.org/blink/trunk@54077 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 03061356
......@@ -7,6 +7,36 @@
* Scripts/prepare-ChangeLog:
2010-01-29 Kenneth Rohde Christiansen <kenneth@webkit.org>
Rubberstamped by Simon Hausmann.
[Qt] Separate implementation from class definition.
* QtLauncher/main.cpp:
(LauncherWindow::webView):
(LauncherWindow::LauncherWindow):
(LauncherWindow::~LauncherWindow):
(LauncherWindow::keyPressEvent):
(LauncherWindow::grabZoomKeys):
(LauncherWindow::sendTouchEvent):
(LauncherWindow::eventFilter):
(LauncherWindow::loadStarted):
(LauncherWindow::loadFinished):
(LauncherWindow::showLinkHover):
(LauncherWindow::zoomIn):
(LauncherWindow::zoomOut):
(LauncherWindow::resetZoom):
(LauncherWindow::toggleZoomTextOnly):
(LauncherWindow::print):
(LauncherWindow::screenshot):
(LauncherWindow::setEditable):
(LauncherWindow::dumpHtml):
(LauncherWindow::selectElements):
(LauncherWindow::setTouchMocking):
(LauncherWindow::newWindow):
(LauncherWindow::setupUI):
2010-01-29 Kenneth Rohde Christiansen <kenneth@webkit.org>
Reviewed by Ariya Hidayat.
......
......@@ -74,10 +74,69 @@ class LauncherWindow : public MainWindow {
Q_OBJECT
public:
LauncherWindow(QString url = QString())
LauncherWindow(QString url = QString());
virtual ~LauncherWindow();
virtual void keyPressEvent(QKeyEvent* event);
void grabZoomKeys(bool grab);
#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
void sendTouchEvent();
bool eventFilter(QObject* obj, QEvent* event);
#endif
QWebView* webView() const { return view; }
protected slots:
void loadStarted();
void loadFinished();
void showLinkHover(const QString &link, const QString &toolTip);
void zoomIn();
void zoomOut();
void resetZoom();
void toggleZoomTextOnly(bool on);
void print();
void screenshot();
void setEditable(bool on);
/* void dumpPlugins() */
void dumpHtml();
void selectElements();
void setTouchMocking(bool on);
public slots:
void newWindow(const QString& url = QString());
private:
// create the status bar, tool bar & menu
void setupUI();
private:
QVector<int> zoomLevels;
int currentZoom;
QWebView* view;
WebInspector* inspector;
QAction* formatMenuAction;
#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
QList<QTouchEvent::TouchPoint> touchPoints;
bool touchMocking;
#endif
};
LauncherWindow::LauncherWindow(QString url)
: MainWindow(url)
, currentZoom(100)
{
{
QSplitter* splitter = new QSplitter(Qt::Vertical, this);
setCentralWidget(splitter);
......@@ -109,15 +168,15 @@ public:
grabZoomKeys(true);
load(url);
}
}
~LauncherWindow()
{
LauncherWindow::~LauncherWindow()
{
grabZoomKeys(false);
}
}
void keyPressEvent(QKeyEvent* event)
{
void LauncherWindow::keyPressEvent(QKeyEvent* event)
{
#ifdef Q_WS_MAEMO_5
switch (event->key()) {
case Qt::Key_F7:
......@@ -131,10 +190,10 @@ public:
}
#endif
MainWindow::keyPressEvent(event);
}
}
void grabZoomKeys(bool grab)
{
void LauncherWindow::grabZoomKeys(bool grab)
{
#ifdef Q_WS_MAEMO_5
if (!winId()) {
qWarning("Can't grab keys unless we have a window id");
......@@ -150,11 +209,11 @@ public:
unsigned long val = (grab) ? 1 : 0;
XChangeProperty(QX11Info::display(), winId(), atom, XA_INTEGER, 32, PropModeReplace, reinterpret_cast<unsigned char*>(&val), 1);
#endif
}
}
#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
void sendTouchEvent()
{
void LauncherWindow::sendTouchEvent()
{
if (touchPoints.isEmpty())
return;
......@@ -175,10 +234,10 @@ public:
touchPoints.removeAt(0);
if (touchPoints.size() > 1 && touchPoints[1].state() == Qt::TouchPointReleased)
touchPoints.removeAt(1);
}
}
bool eventFilter(QObject* obj, QEvent* event)
{
bool LauncherWindow::eventFilter(QObject* obj, QEvent* event)
{
if (!touchMocking || obj != view)
return QObject::eventFilter(obj, event);
......@@ -241,29 +300,23 @@ public:
}
}
return false;
}
}
#endif // QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
QWebView* webView() const
{
return view;
}
protected slots:
void loadStarted()
{
void LauncherWindow::loadStarted()
{
view->setFocus(Qt::OtherFocusReason);
}
}
void loadFinished()
{
void LauncherWindow::loadFinished()
{
QUrl url = page()->mainFrame()->url();
setAddressUrl(url.toString());
addCompleterEntry(url);
}
}
void showLinkHover(const QString &link, const QString &toolTip)
{
void LauncherWindow::showLinkHover(const QString &link, const QString &toolTip)
{
#ifndef Q_WS_MAEMO_5
statusBar()->showMessage(link);
#endif
......@@ -271,51 +324,51 @@ protected slots:
if (!toolTip.isEmpty())
QToolTip::showText(QCursor::pos(), toolTip);
#endif
}
}
void zoomIn()
{
void LauncherWindow::zoomIn()
{
int i = zoomLevels.indexOf(currentZoom);
Q_ASSERT(i >= 0);
if (i < zoomLevels.count() - 1)
currentZoom = zoomLevels[i + 1];
page()->mainFrame()->setZoomFactor(qreal(currentZoom) / 100.0);
}
}
void zoomOut()
{
void LauncherWindow::zoomOut()
{
int i = zoomLevels.indexOf(currentZoom);
Q_ASSERT(i >= 0);
if (i > 0)
currentZoom = zoomLevels[i - 1];
page()->mainFrame()->setZoomFactor(qreal(currentZoom) / 100.0);
}
}
void resetZoom()
{
void LauncherWindow::resetZoom()
{
currentZoom = 100;
page()->mainFrame()->setZoomFactor(1.0);
}
}
void toggleZoomTextOnly(bool b)
{
void LauncherWindow::toggleZoomTextOnly(bool b)
{
page()->settings()->setAttribute(QWebSettings::ZoomTextOnly, b);
}
}
void print()
{
void LauncherWindow::print()
{
#if !defined(QT_NO_PRINTER)
QPrintPreviewDialog dlg(this);
connect(&dlg, SIGNAL(paintRequested(QPrinter *)),
view, SLOT(print(QPrinter *)));
connect(&dlg, SIGNAL(paintRequested(QPrinter*)),
view, SLOT(print(QPrinter*)));
dlg.exec();
#endif
}
}
void screenshot()
{
void LauncherWindow::screenshot()
{
QPixmap pixmap = QPixmap::grabWidget(view);
QLabel* label = new QLabel;
label->setAttribute(Qt::WA_DeleteOnClose);
......@@ -328,16 +381,16 @@ protected slots:
pixmap.save(fileName, "png");
label->setWindowTitle(QString("Screenshot - Saved at %1").arg(fileName));
}
}
}
void setEditable(bool on)
{
void LauncherWindow::setEditable(bool on)
{
view->page()->setContentEditable(on);
formatMenuAction->setVisible(on);
}
}
/*
void dumpPlugins() {
/*
void LauncherWindow::dumpPlugins() {
QList<QWebPluginInfo> plugins = QWebSettings::pluginDatabase()->plugins();
foreach (const QWebPluginInfo plugin, plugins) {
qDebug() << "Plugin:" << plugin.name();
......@@ -345,16 +398,16 @@ protected slots:
qDebug() << " " << mime.name;
}
}
}
*/
}
*/
void dumpHtml()
{
void LauncherWindow::dumpHtml()
{
qDebug() << "HTML: " << page()->mainFrame()->toHtml();
}
}
void selectElements()
{
void LauncherWindow::selectElements()
{
bool ok;
QString str = QInputDialog::getText(this, "Select elements", "Choose elements",
QLineEdit::Normal, "a", &ok);
......@@ -367,31 +420,23 @@ protected slots:
statusBar()->showMessage(QString("%1 element(s) selected").arg(result.count()), 5000);
#endif
}
}
}
void setTouchMocking(bool on)
{
void LauncherWindow::setTouchMocking(bool on)
{
#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
touchMocking = on;
#endif
}
public slots:
}
void newWindow(const QString& url = QString())
{
void LauncherWindow::newWindow(const QString& url)
{
LauncherWindow* mw = new LauncherWindow(url);
mw->show();
}
private:
QVector<int> zoomLevels;
int currentZoom;
}
// create the status bar, tool bar & menu
void setupUI()
{
void LauncherWindow::setupUI()
{
QMenu* fileMenu = menuBar()->addMenu("&File");
fileMenu->addAction("New Window", this, SLOT(newWindow()), QKeySequence::New);
fileMenu->addAction(tr("Open File..."), this, SLOT(openFile()), QKeySequence::Open);
......@@ -453,20 +498,7 @@ private:
touchMockAction->setCheckable(true);
touchMockAction->setShortcut(QKeySequence(Qt::CTRL | Qt::ALT | Qt::Key_T));
#endif
}
private:
QWebView* view;
WebInspector* inspector;
QAction* formatMenuAction;
#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
QList<QTouchEvent::TouchPoint> touchPoints;
bool touchMocking;
#endif
};
}
QWebPage* WebPage::createWindow(QWebPage::WebWindowType)
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment