making the embedding example actually do something nice

This commit is contained in:
zack%kde.org 2004-12-06 02:50:30 +00:00
Родитель 91808329af
Коммит c2ba5a61e4
8 изменённых файлов: 69 добавлений и 25 удалений

Просмотреть файл

@ -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)

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -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);
}

Просмотреть файл

@ -1,21 +0,0 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <qmainwindow.h>
class QGeckoEmbed;
class MyMainWindow : public QMainWindow
{
Q_OBJECT
public:
MyMainWindow();
public slots:
void fileOpen();
void startURIOpen(const QString &, bool &);
public:
QGeckoEmbed *qecko;
};
#endif

Просмотреть файл

Просмотреть файл