diff --git a/mozilla/embedding/browser/qt/tests/Makefile.in b/mozilla/embedding/browser/qt/tests/Makefile.in index 31f5781ce79..8c6a42c004a 100644 --- a/mozilla/embedding/browser/qt/tests/Makefile.in +++ b/mozilla/embedding/browser/qt/tests/Makefile.in @@ -28,6 +28,8 @@ MOCSRCS = \ moc_mainwindow.cpp \ $(NULL) +IMAGES = fileopen.png reload.png back.png forward.png stop.png + CXXFLAGS += $(MOZ_QT_CFLAGS) PROGRAM = $(CPPSRCS:.cpp=) @@ -40,6 +42,7 @@ LIBS += \ endif include $(topsrcdir)/config/config.mk +include $(srcdir)/../src/config/qtconfig.mk # Force applications to be built non-statically # when building the mozcomps meta component @@ -64,6 +67,7 @@ EXTRA_LIBS += $(MOZ_JS_LIBS) EXTRA_LIBS += $(MOZ_COMPONENT_LIBS) include $(topsrcdir)/config/rules.mk +include $(srcdir)/../src/config/qtrules.mk CXXFLAGS += $(MOZ_QT_CFLAGS) diff --git a/mozilla/embedding/browser/qt/tests/back.png b/mozilla/embedding/browser/qt/tests/back.png new file mode 100755 index 00000000000..e8d11504c94 Binary files /dev/null and b/mozilla/embedding/browser/qt/tests/back.png differ diff --git a/mozilla/embedding/browser/qt/tests/fileopen.png b/mozilla/embedding/browser/qt/tests/fileopen.png new file mode 100755 index 00000000000..667d2fe2aaf Binary files /dev/null and b/mozilla/embedding/browser/qt/tests/fileopen.png differ diff --git a/mozilla/embedding/browser/qt/tests/forward.png b/mozilla/embedding/browser/qt/tests/forward.png new file mode 100755 index 00000000000..418e5d74b77 Binary files /dev/null and b/mozilla/embedding/browser/qt/tests/forward.png differ diff --git a/mozilla/embedding/browser/qt/tests/mainwindow.cpp b/mozilla/embedding/browser/qt/tests/mainwindow.cpp index 851cfae7111..88c1f90e63d 100644 --- a/mozilla/embedding/browser/qt/tests/mainwindow.cpp +++ b/mozilla/embedding/browser/qt/tests/mainwindow.cpp @@ -1,28 +1,50 @@ #include "mainwindow.h" +#include #include #include #include #include #include -#include +#include +#include #include "qgeckoembed.h" MyMainWindow::MyMainWindow() { - QHBox *box = new QHBox(this); + QVBox *box = new QVBox(this); qecko = new QGeckoEmbed(box, "qgecko"); box->setFrameStyle(QFrame::Panel | QFrame::Sunken); setCentralWidget( box ); - //QToolBar *toolbar = new QToolBar(this); + QToolBar *toolbar = new QToolBar(this); + toolbar->setLabel("Location:"); + + QAction *action = new QAction(QPixmap::fromMimeSource( "back.png" ), tr( "Go Back"), CTRL + Key_B, + toolbar, "goback"); + connect(action, SIGNAL(activated()), this, SLOT(goBack())); + action->addTo(toolbar); + + action = new QAction(QPixmap::fromMimeSource( "forward.png" ), tr( "Go Forward"), CTRL + Key_F, + toolbar, "goforward"); + connect(action, SIGNAL(activated()), this, SLOT(goForward())); + action->addTo(toolbar); + + action = new QAction(QPixmap::fromMimeSource( "stop.png" ), tr("Stop"), CTRL + Key_S, + toolbar, "stop"); + connect(action, SIGNAL(activated()), this, SLOT(stopLoad())); + action->addTo(toolbar); + + location = new QLineEdit(toolbar); + toolbar->setStretchableWidget(location); QPopupMenu *menu = new QPopupMenu(this); menuBar()->insertItem( tr( "&File" ), menu ); - QAction *a = new QAction( QPixmap::fromMimeSource( "filenew.xpm" ), tr( "&Open..." ), CTRL + Key_O, this, "fileOpen" ); + QAction *a = new QAction( QPixmap::fromMimeSource( "fileopen.png" ), tr( "&Open..." ), CTRL + Key_O, + toolbar, "fileOpen" ); connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); //a->addTo( toolbar ); a->addTo( menu ); @@ -36,6 +58,15 @@ MyMainWindow::MyMainWindow() SLOT(setCaption(const QString &)) ); connect( qecko, SIGNAL(startURIOpen(const QString &, bool &)), SLOT(startURIOpen(const QString &, bool &)) ); + connect(qecko, SIGNAL(locationChanged(const QString&)), + location, SLOT(setText(const QString&))); + connect(qecko, SIGNAL(progress(int, int)), + SLOT(slotProgress(int, int))); + connect(qecko, SIGNAL(progressAll(const QString&, int, int)), + SLOT(slotProgress(const QString&, int, int))); + + + connect( location, SIGNAL(returnPressed()), SLOT(changeLocation())); } @@ -50,3 +81,33 @@ void MyMainWindow::startURIOpen(const QString &, bool &) { qDebug("XX in the signal"); } + +void MyMainWindow::changeLocation() +{ + qecko->loadURL( location->text() ); +} + +void MyMainWindow::goBack() +{ + qecko->goBack(); +} + +void MyMainWindow::goForward() +{ + qecko->goForward(); +} + +void MyMainWindow::stop() +{ + qecko->stopLoad(); +} + +void MyMainWindow::slotProgress(const QString &url, int current, int max) +{ + qDebug("progress %d / %d (%s)", current, max, url.latin1()); +} + +void MyMainWindow::slotProgress(int current, int max) +{ + qDebug("progress %d / %d ", current, max); +} diff --git a/mozilla/embedding/browser/qt/tests/mainwindow.h b/mozilla/embedding/browser/qt/tests/mainwindow.h index 8cce176ea00..4b9a5b3582f 100644 --- a/mozilla/embedding/browser/qt/tests/mainwindow.h +++ b/mozilla/embedding/browser/qt/tests/mainwindow.h @@ -4,6 +4,7 @@ #include class QGeckoEmbed; +class QLineEdit; class MyMainWindow : public QMainWindow { @@ -14,8 +15,20 @@ public: public slots: void fileOpen(); void startURIOpen(const QString &, bool &); + void changeLocation(); + void goBack(); + void goForward(); + void stop(); + public: QGeckoEmbed *qecko; + +private slots: + void slotProgress(int, int); + void slotProgress(const QString &, int, int); + +private: + QLineEdit *location; }; #endif diff --git a/mozilla/embedding/browser/qt/tests/reload.png b/mozilla/embedding/browser/qt/tests/reload.png new file mode 100755 index 00000000000..a1243d01743 Binary files /dev/null and b/mozilla/embedding/browser/qt/tests/reload.png differ diff --git a/mozilla/embedding/browser/qt/tests/stop.png b/mozilla/embedding/browser/qt/tests/stop.png new file mode 100755 index 00000000000..b3f5c9a8029 Binary files /dev/null and b/mozilla/embedding/browser/qt/tests/stop.png differ