qbrowserlib::Executor as singleton; refs #167

This commit is contained in:
Marc Wäckerlin
2012-11-12 08:57:37 +00:00
parent db352a329b
commit d191d8cc68
12 changed files with 129 additions and 117 deletions

View File

@@ -27,35 +27,52 @@ namespace qbrowserlib {
browser. To be used inside a QTabBar, as main window or as
docking widget. */
class SwissWebWidget: public QWidget, private Ui::SwissWebWidget {
Q_OBJECT;
public:
SwissWebWidget(QWidget* p=0): QWidget(p) {
setupUi(this);
QMainWindow* w(qobject_cast<QMainWindow*>(p?p->parentWidget():p));
qDebug()<<"Parent "<<p<<(w?"is":"is not")<<" a QMainWindow";
if (w) {
/*! Within a QMainWindow, the widget automatically reparents
the top buttons to the toolbar and the bottom status
line to the window's status bar. */
qDebug()<<"Rearranging";
QToolBar* t(w->addToolBar(trUtf8("Browser Tools",
"name of the browser's toolbar")));
while (_tools->count()) {
qDebug()<<"Rearranging tool item "<<(0)<<_tools->itemAt(0);
t->addWidget(_tools->itemAt(0)->widget());
}
delete _tools; _tools=0;
t->show();
_statusbar->removeWidget(_status);
delete _status; _status=0;
while (_statusbar->count()) {
qDebug()<<"Rearranging stat item "<<(0)<<_statusbar->itemAt(0);
w->statusBar()->addWidget(_statusbar->itemAt(0)->widget());
}
delete _statusbar; _statusbar=0;
}
/*! 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();
}
//! 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) {
if (!w) return;
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());
}
protected:
void connects() {
connect(_url, SIGNAL(returnPressed()), SLOT(load()));
}
};
}