mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-26 14:46:02 +00:00
making the embedding example actually do something nice
This commit is contained in:
parent
53603e83e7
commit
c42dbda58c
@ -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)
|
||||
|
||||
|
BIN
embedding/browser/qt/tests/back.png
Executable file
BIN
embedding/browser/qt/tests/back.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
BIN
embedding/browser/qt/tests/fileopen.png
Executable file
BIN
embedding/browser/qt/tests/fileopen.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
BIN
embedding/browser/qt/tests/forward.png
Executable file
BIN
embedding/browser/qt/tests/forward.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
@ -1,28 +1,50 @@
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include <qlineedit.h>
|
||||
#include <qaction.h>
|
||||
#include <qmenubar.h>
|
||||
#include <qtoolbar.h>
|
||||
#include <qfiledialog.h>
|
||||
#include <qstatusbar.h>
|
||||
#include <qhbox.h>
|
||||
#include <qvbox.h>
|
||||
#include <qlayout.h>
|
||||
|
||||
#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);
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <qmainwindow.h>
|
||||
|
||||
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
|
||||
|
BIN
embedding/browser/qt/tests/reload.png
Executable file
BIN
embedding/browser/qt/tests/reload.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
BIN
embedding/browser/qt/tests/stop.png
Executable file
BIN
embedding/browser/qt/tests/stop.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
Loading…
x
Reference in New Issue
Block a user