2012-11-07 09:57:38 +00:00
|
|
|
/*! @file
|
|
|
|
|
|
|
|
|
|
@id $Id$
|
|
|
|
|
*/
|
|
|
|
|
// 1 2 3 4 5 6 7 8
|
|
|
|
|
// 45678901234567890123456789012345678901234567890123456789012345678901234567890
|
|
|
|
|
|
2012-11-07 11:43:29 +00:00
|
|
|
#ifndef __SWISSWEBWIDGET_HXX__
|
|
|
|
|
#define __SWISSWEBWIDGET_HXX__
|
|
|
|
|
|
|
|
|
|
#include <qbrowserlib/ui_swisswebwidget.h>
|
|
|
|
|
|
|
|
|
|
#include <QtGui/QMainWindow>
|
2012-11-08 08:34:18 +00:00
|
|
|
#include <QtGui/QToolBar>
|
|
|
|
|
#include <QtGui/QStatusBar>
|
2012-11-07 11:43:29 +00:00
|
|
|
|
2012-11-08 09:27:52 +00:00
|
|
|
#include <QtDebug>
|
|
|
|
|
|
2012-11-13 14:50:58 +00:00
|
|
|
#ifndef CREATE_QT_PROPERTY
|
|
|
|
|
#define CREATE_QT_PROPERTY(type, name) \
|
|
|
|
|
Q_PROPERTY(type _##name READ name WRITE name USER true) \
|
|
|
|
|
public: \
|
|
|
|
|
void name(const type& v) { \
|
|
|
|
|
_##name = v; \
|
|
|
|
|
} \
|
|
|
|
|
type name() { \
|
|
|
|
|
return _##name; \
|
|
|
|
|
} \
|
|
|
|
|
private: \
|
|
|
|
|
type _##name
|
|
|
|
|
#endif
|
|
|
|
|
|
2012-11-07 09:57:38 +00:00
|
|
|
//! @addtogroup qbrowserlib
|
|
|
|
|
//! @{
|
|
|
|
|
|
2012-11-07 11:43:29 +00:00
|
|
|
namespace qbrowserlib {
|
2012-11-07 09:57:38 +00:00
|
|
|
|
|
|
|
|
//! Window Widget for complete page witghin a webbrowser.
|
|
|
|
|
/*! Contains a toolbar, a status bar and @refs
|
|
|
|
|
SwissWebView. Instanciate this and you have a complete
|
|
|
|
|
browser. To be used inside a QTabBar, as main window or as
|
|
|
|
|
docking widget. */
|
2012-11-07 14:32:43 +00:00
|
|
|
class SwissWebWidget: public QWidget, private Ui::SwissWebWidget {
|
2012-11-12 08:57:37 +00:00
|
|
|
|
2012-11-07 13:07:38 +00:00
|
|
|
Q_OBJECT;
|
2012-11-12 08:57:37 +00:00
|
|
|
|
2012-11-13 14:50:58 +00:00
|
|
|
CREATE_QT_PROPERTY(QUrl, homeUrl);
|
|
|
|
|
|
2012-11-07 09:57:38 +00:00
|
|
|
public:
|
2012-11-12 08:57:37 +00:00
|
|
|
|
2012-11-07 14:32:43 +00:00
|
|
|
SwissWebWidget(QWidget* p=0): QWidget(p) {
|
2012-11-07 09:57:38 +00:00
|
|
|
setupUi(this);
|
2012-11-12 08:57:37 +00:00
|
|
|
/*! Within a QMainWindow, the widget automatically reparents
|
|
|
|
|
the top buttons to the toolbar and the bottom status
|
|
|
|
|
line to the window's status bar. */
|
|
|
|
|
moveToMain(qobject_cast<QMainWindow*>(p?p->parentWidget():p));
|
|
|
|
|
connects();
|
2012-11-07 09:57:38 +00:00
|
|
|
}
|
2012-11-13 14:50:58 +00:00
|
|
|
|
2012-11-12 08:57:37 +00:00
|
|
|
//! Moves status widgets to status bar, tool widgets to toolbar
|
|
|
|
|
/*! You can use this method to reparent the tools and the status
|
|
|
|
|
part of the widget into the toolbar and statusbar of your
|
|
|
|
|
main window.
|
|
|
|
|
|
|
|
|
|
@note If used as central widget of a QMainWindow, status and
|
|
|
|
|
tools are automatically reparented in the constructor. */
|
|
|
|
|
void moveToMain(QMainWindow* w) {
|
2012-11-13 14:50:58 +00:00
|
|
|
if (!w || !_statusbar || !_tools) return;
|
2012-11-12 08:57:37 +00:00
|
|
|
QToolBar* t(w->addToolBar(trUtf8("Browser Tools",
|
|
|
|
|
"name of the browser's toolbar")));
|
|
|
|
|
while (_tools->count())
|
|
|
|
|
t->addWidget(_tools->itemAt(0)->widget());
|
|
|
|
|
delete _tools; _tools=0;
|
|
|
|
|
_statusbar->removeWidget(_status); delete _status; _status=0;
|
|
|
|
|
while (_statusbar->count())
|
|
|
|
|
w->statusBar()->addWidget(_statusbar->itemAt(0)->widget());
|
|
|
|
|
delete _statusbar; _statusbar=0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Q_SLOTS:
|
|
|
|
|
|
|
|
|
|
void load() {
|
|
|
|
|
_webview->load(_url->text());
|
|
|
|
|
}
|
2012-11-13 14:50:58 +00:00
|
|
|
|
|
|
|
|
void goHome() {
|
|
|
|
|
_webview->load(_homeUrl);
|
|
|
|
|
}
|
2012-11-12 08:57:37 +00:00
|
|
|
|
2012-11-07 09:57:38 +00:00
|
|
|
protected:
|
2012-11-12 08:57:37 +00:00
|
|
|
|
|
|
|
|
void connects() {
|
|
|
|
|
connect(_url, SIGNAL(returnPressed()), SLOT(load()));
|
2012-11-13 14:50:58 +00:00
|
|
|
connect(_home, SIGNAL(pressed()), SLOT(goHome()));
|
2012-11-12 08:57:37 +00:00
|
|
|
}
|
|
|
|
|
|
2012-11-07 09:57:38 +00:00
|
|
|
};
|
2012-11-07 11:43:29 +00:00
|
|
|
|
2012-11-07 09:57:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//! @}
|
2012-11-07 11:43:29 +00:00
|
|
|
|
|
|
|
|
#endif
|