qbrowserlib::Executor as singleton; refs #167
This commit is contained in:
@@ -17,7 +17,9 @@
|
||||
#include <QtNetwork/QNetworkReply>
|
||||
|
||||
namespace qbrowserlib {
|
||||
|
||||
|
||||
//! Execute external processes
|
||||
/*! Implements a singleton pattern */
|
||||
class Executor: public QObject {
|
||||
|
||||
Q_OBJECT;
|
||||
@@ -27,9 +29,17 @@ namespace qbrowserlib {
|
||||
void applicationStarted();
|
||||
void applicationFinished();
|
||||
|
||||
private:
|
||||
|
||||
Executor(Settings* settings=0): _settings(settings) {} // singleton
|
||||
Executor(const Executor&); // singleton
|
||||
|
||||
public:
|
||||
|
||||
Executor(Settings* settings=0): _settings(settings) {}
|
||||
static Executor& instance(Settings* settings=0) {
|
||||
static Executor _instance(settings);
|
||||
return _instance;
|
||||
}
|
||||
|
||||
~Executor() {
|
||||
TRC;
|
||||
@@ -102,9 +112,9 @@ namespace qbrowserlib {
|
||||
_downloadProcesses.erase(qobject_cast<QProcess*>(sender()));
|
||||
applicationFinished();
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
private:
|
||||
|
||||
typedef std::map<QProcess*, TemporaryFile*> DownloadProcesses;
|
||||
DownloadProcesses _downloadProcesses;
|
||||
Settings* _settings;
|
||||
|
@@ -24,9 +24,8 @@ namespace qbrowserlib {
|
||||
signals:
|
||||
void done();
|
||||
public:
|
||||
PluginFactory(QNetworkAccessManager* net, Executor* executor,
|
||||
QObject* p=0): QWebPluginFactory(p),
|
||||
_net(net), _executor(executor) {
|
||||
PluginFactory(QNetworkAccessManager* net, QObject* p=0):
|
||||
QWebPluginFactory(p), _net(net) {
|
||||
TRC;
|
||||
// Plugin plugin;
|
||||
// plugin.name = "Show PDF-Document";
|
||||
@@ -50,8 +49,7 @@ namespace qbrowserlib {
|
||||
// }
|
||||
QNetworkRequest req(url);
|
||||
QNetworkReply* reply(_net->get(QNetworkRequest(url)));
|
||||
SaveOrRunPlugin* p(new SaveOrRunPlugin(reply, _executor,
|
||||
url, mimeType));
|
||||
SaveOrRunPlugin* p(new SaveOrRunPlugin(reply, url, mimeType));
|
||||
assert(connect(p, SIGNAL(accept()), SIGNAL(done())));
|
||||
if (p->handlePreconfigured()) {
|
||||
return p;
|
||||
@@ -69,7 +67,6 @@ namespace qbrowserlib {
|
||||
private:
|
||||
QList<Plugin> _plugins;
|
||||
QNetworkAccessManager* _net;
|
||||
Executor* _executor;
|
||||
};
|
||||
|
||||
}
|
||||
|
@@ -632,14 +632,14 @@ p, li { white-space: pre-wrap; }
|
||||
<context>
|
||||
<name>qbrowserlib::SaveOrRun</name>
|
||||
<message>
|
||||
<location filename="saveorrun.hxx" line="144"/>
|
||||
<location filename="saveorrun.hxx" line="156"/>
|
||||
<location filename="saveorrun.hxx" line="146"/>
|
||||
<location filename="saveorrun.hxx" line="158"/>
|
||||
<source>File Exists</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="saveorrun.hxx" line="145"/>
|
||||
<location filename="saveorrun.hxx" line="157"/>
|
||||
<location filename="saveorrun.hxx" line="147"/>
|
||||
<location filename="saveorrun.hxx" line="159"/>
|
||||
<source>File already exists:
|
||||
|
||||
%1
|
||||
@@ -648,12 +648,12 @@ Overwrite?</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="saveorrun.hxx" line="169"/>
|
||||
<location filename="saveorrun.hxx" line="171"/>
|
||||
<source>No Program</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="saveorrun.hxx" line="170"/>
|
||||
<location filename="saveorrun.hxx" line="172"/>
|
||||
<source>Not an executable Program:
|
||||
|
||||
%1
|
||||
@@ -662,23 +662,23 @@ Specify full path to executable program</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="saveorrun.hxx" line="182"/>
|
||||
<location filename="saveorrun.hxx" line="184"/>
|
||||
<source>Save File As ...</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="saveorrun.hxx" line="195"/>
|
||||
<location filename="saveorrun.hxx" line="197"/>
|
||||
<source>Open File With ...</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="saveorrun.hxx" line="207"/>
|
||||
<location filename="saveorrun.hxx" line="209"/>
|
||||
<source>Dokumente</source>
|
||||
<comment>Documents folder in local language</comment>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="saveorrun.hxx" line="209"/>
|
||||
<location filename="saveorrun.hxx" line="211"/>
|
||||
<source>Arbeitsfläche</source>
|
||||
<comment>Desktop folder in local language</comment>
|
||||
<translation type="unfinished"></translation>
|
||||
@@ -687,7 +687,7 @@ Specify full path to executable program</source>
|
||||
<context>
|
||||
<name>qbrowserlib::SaveOrRunDialog</name>
|
||||
<message>
|
||||
<location filename="saveorrun.hxx" line="261"/>
|
||||
<location filename="saveorrun.hxx" line="259"/>
|
||||
<source>Unknown File Type</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
@@ -695,7 +695,7 @@ Specify full path to executable program</source>
|
||||
<context>
|
||||
<name>qbrowserlib::SwissWebWidget</name>
|
||||
<message>
|
||||
<location filename="swisswebwidget.hxx" line="41"/>
|
||||
<location filename="swisswebwidget.hxx" line="53"/>
|
||||
<source>Browser Tools</source>
|
||||
<comment>name of the browser's toolbar</comment>
|
||||
<translation type="unfinished"></translation>
|
||||
|
@@ -632,14 +632,14 @@ p, li { white-space: pre-wrap; }
|
||||
<context>
|
||||
<name>qbrowserlib::SaveOrRun</name>
|
||||
<message>
|
||||
<location filename="saveorrun.hxx" line="144"/>
|
||||
<location filename="saveorrun.hxx" line="156"/>
|
||||
<location filename="saveorrun.hxx" line="146"/>
|
||||
<location filename="saveorrun.hxx" line="158"/>
|
||||
<source>File Exists</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="saveorrun.hxx" line="145"/>
|
||||
<location filename="saveorrun.hxx" line="157"/>
|
||||
<location filename="saveorrun.hxx" line="147"/>
|
||||
<location filename="saveorrun.hxx" line="159"/>
|
||||
<source>File already exists:
|
||||
|
||||
%1
|
||||
@@ -648,12 +648,12 @@ Overwrite?</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="saveorrun.hxx" line="169"/>
|
||||
<location filename="saveorrun.hxx" line="171"/>
|
||||
<source>No Program</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="saveorrun.hxx" line="170"/>
|
||||
<location filename="saveorrun.hxx" line="172"/>
|
||||
<source>Not an executable Program:
|
||||
|
||||
%1
|
||||
@@ -662,23 +662,23 @@ Specify full path to executable program</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="saveorrun.hxx" line="182"/>
|
||||
<location filename="saveorrun.hxx" line="184"/>
|
||||
<source>Save File As ...</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="saveorrun.hxx" line="195"/>
|
||||
<location filename="saveorrun.hxx" line="197"/>
|
||||
<source>Open File With ...</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="saveorrun.hxx" line="207"/>
|
||||
<location filename="saveorrun.hxx" line="209"/>
|
||||
<source>Dokumente</source>
|
||||
<comment>Documents folder in local language</comment>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="saveorrun.hxx" line="209"/>
|
||||
<location filename="saveorrun.hxx" line="211"/>
|
||||
<source>Arbeitsfläche</source>
|
||||
<comment>Desktop folder in local language</comment>
|
||||
<translation type="unfinished"></translation>
|
||||
@@ -687,7 +687,7 @@ Specify full path to executable program</source>
|
||||
<context>
|
||||
<name>qbrowserlib::SaveOrRunDialog</name>
|
||||
<message>
|
||||
<location filename="saveorrun.hxx" line="261"/>
|
||||
<location filename="saveorrun.hxx" line="259"/>
|
||||
<source>Unknown File Type</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
@@ -695,7 +695,7 @@ Specify full path to executable program</source>
|
||||
<context>
|
||||
<name>qbrowserlib::SwissWebWidget</name>
|
||||
<message>
|
||||
<location filename="swisswebwidget.hxx" line="41"/>
|
||||
<location filename="swisswebwidget.hxx" line="53"/>
|
||||
<source>Browser Tools</source>
|
||||
<comment>name of the browser's toolbar</comment>
|
||||
<translation type="unfinished"></translation>
|
||||
|
@@ -632,14 +632,14 @@ p, li { white-space: pre-wrap; }
|
||||
<context>
|
||||
<name>qbrowserlib::SaveOrRun</name>
|
||||
<message>
|
||||
<location filename="saveorrun.hxx" line="144"/>
|
||||
<location filename="saveorrun.hxx" line="156"/>
|
||||
<location filename="saveorrun.hxx" line="146"/>
|
||||
<location filename="saveorrun.hxx" line="158"/>
|
||||
<source>File Exists</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="saveorrun.hxx" line="145"/>
|
||||
<location filename="saveorrun.hxx" line="157"/>
|
||||
<location filename="saveorrun.hxx" line="147"/>
|
||||
<location filename="saveorrun.hxx" line="159"/>
|
||||
<source>File already exists:
|
||||
|
||||
%1
|
||||
@@ -648,12 +648,12 @@ Overwrite?</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="saveorrun.hxx" line="169"/>
|
||||
<location filename="saveorrun.hxx" line="171"/>
|
||||
<source>No Program</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="saveorrun.hxx" line="170"/>
|
||||
<location filename="saveorrun.hxx" line="172"/>
|
||||
<source>Not an executable Program:
|
||||
|
||||
%1
|
||||
@@ -662,23 +662,23 @@ Specify full path to executable program</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="saveorrun.hxx" line="182"/>
|
||||
<location filename="saveorrun.hxx" line="184"/>
|
||||
<source>Save File As ...</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="saveorrun.hxx" line="195"/>
|
||||
<location filename="saveorrun.hxx" line="197"/>
|
||||
<source>Open File With ...</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="saveorrun.hxx" line="207"/>
|
||||
<location filename="saveorrun.hxx" line="209"/>
|
||||
<source>Dokumente</source>
|
||||
<comment>Documents folder in local language</comment>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="saveorrun.hxx" line="209"/>
|
||||
<location filename="saveorrun.hxx" line="211"/>
|
||||
<source>Arbeitsfläche</source>
|
||||
<comment>Desktop folder in local language</comment>
|
||||
<translation type="unfinished"></translation>
|
||||
@@ -687,7 +687,7 @@ Specify full path to executable program</source>
|
||||
<context>
|
||||
<name>qbrowserlib::SaveOrRunDialog</name>
|
||||
<message>
|
||||
<location filename="saveorrun.hxx" line="261"/>
|
||||
<location filename="saveorrun.hxx" line="259"/>
|
||||
<source>Unknown File Type</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
@@ -695,7 +695,7 @@ Specify full path to executable program</source>
|
||||
<context>
|
||||
<name>qbrowserlib::SwissWebWidget</name>
|
||||
<message>
|
||||
<location filename="swisswebwidget.hxx" line="41"/>
|
||||
<location filename="swisswebwidget.hxx" line="53"/>
|
||||
<source>Browser Tools</source>
|
||||
<comment>name of the browser's toolbar</comment>
|
||||
<translation type="unfinished"></translation>
|
||||
|
@@ -632,14 +632,14 @@ p, li { white-space: pre-wrap; }
|
||||
<context>
|
||||
<name>qbrowserlib::SaveOrRun</name>
|
||||
<message>
|
||||
<location filename="saveorrun.hxx" line="144"/>
|
||||
<location filename="saveorrun.hxx" line="156"/>
|
||||
<location filename="saveorrun.hxx" line="146"/>
|
||||
<location filename="saveorrun.hxx" line="158"/>
|
||||
<source>File Exists</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="saveorrun.hxx" line="145"/>
|
||||
<location filename="saveorrun.hxx" line="157"/>
|
||||
<location filename="saveorrun.hxx" line="147"/>
|
||||
<location filename="saveorrun.hxx" line="159"/>
|
||||
<source>File already exists:
|
||||
|
||||
%1
|
||||
@@ -648,12 +648,12 @@ Overwrite?</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="saveorrun.hxx" line="169"/>
|
||||
<location filename="saveorrun.hxx" line="171"/>
|
||||
<source>No Program</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="saveorrun.hxx" line="170"/>
|
||||
<location filename="saveorrun.hxx" line="172"/>
|
||||
<source>Not an executable Program:
|
||||
|
||||
%1
|
||||
@@ -662,23 +662,23 @@ Specify full path to executable program</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="saveorrun.hxx" line="182"/>
|
||||
<location filename="saveorrun.hxx" line="184"/>
|
||||
<source>Save File As ...</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="saveorrun.hxx" line="195"/>
|
||||
<location filename="saveorrun.hxx" line="197"/>
|
||||
<source>Open File With ...</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="saveorrun.hxx" line="207"/>
|
||||
<location filename="saveorrun.hxx" line="209"/>
|
||||
<source>Dokumente</source>
|
||||
<comment>Documents folder in local language</comment>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="saveorrun.hxx" line="209"/>
|
||||
<location filename="saveorrun.hxx" line="211"/>
|
||||
<source>Arbeitsfläche</source>
|
||||
<comment>Desktop folder in local language</comment>
|
||||
<translation type="unfinished"></translation>
|
||||
@@ -687,7 +687,7 @@ Specify full path to executable program</source>
|
||||
<context>
|
||||
<name>qbrowserlib::SaveOrRunDialog</name>
|
||||
<message>
|
||||
<location filename="saveorrun.hxx" line="261"/>
|
||||
<location filename="saveorrun.hxx" line="259"/>
|
||||
<source>Unknown File Type</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
@@ -695,7 +695,7 @@ Specify full path to executable program</source>
|
||||
<context>
|
||||
<name>qbrowserlib::SwissWebWidget</name>
|
||||
<message>
|
||||
<location filename="swisswebwidget.hxx" line="41"/>
|
||||
<location filename="swisswebwidget.hxx" line="53"/>
|
||||
<source>Browser Tools</source>
|
||||
<comment>name of the browser's toolbar</comment>
|
||||
<translation type="unfinished"></translation>
|
||||
|
@@ -39,9 +39,8 @@ namespace qbrowserlib {
|
||||
|
||||
public:
|
||||
|
||||
SaveOrRun(QNetworkReply* reply, Executor* executor,
|
||||
QString type, QString src,
|
||||
QWidget* p=0): QWidget(p), _reply(reply), _executor(executor) {
|
||||
SaveOrRun(QNetworkReply* reply, QString type, QString src, QWidget* p=0):
|
||||
QWidget(p), _reply(reply) {
|
||||
TRC;
|
||||
setupUi(this);
|
||||
QString obj(remoteFilename());
|
||||
@@ -61,7 +60,7 @@ namespace qbrowserlib {
|
||||
TRC;
|
||||
QString filename(remoteFilename());
|
||||
QStringList type
|
||||
(_executor->settings()->mimetype
|
||||
(qbrowserlib::Executor::instance().settings()->mimetype
|
||||
(_reply->header(QNetworkRequest::ContentTypeHeader).toString(),
|
||||
filename));
|
||||
if (!type.isEmpty()) {
|
||||
@@ -69,9 +68,11 @@ namespace qbrowserlib {
|
||||
hide();
|
||||
filename.replace(QRegExp("^(.*)\\."+type.at(0)+"$"),
|
||||
"\\1"); // remove extension
|
||||
assert(connect(_executor, SIGNAL(applicationStarted()),
|
||||
assert(connect(&qbrowserlib::Executor::instance(),
|
||||
SIGNAL(applicationStarted()),
|
||||
SIGNAL(accept())));
|
||||
_executor->run(_reply, filename+"."+type.at(0), type.at(1));
|
||||
qbrowserlib::Executor::instance().run
|
||||
(_reply, filename+"."+type.at(0), type.at(1));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -132,7 +133,8 @@ namespace qbrowserlib {
|
||||
|
||||
void run() {
|
||||
TRC; LOG<<program()<<filename();
|
||||
_executor->run(_reply, filename(), program()+" %1");
|
||||
qbrowserlib::Executor::instance().run
|
||||
(_reply, filename(), program()+" %1");
|
||||
accept();
|
||||
}
|
||||
|
||||
@@ -219,8 +221,6 @@ namespace qbrowserlib {
|
||||
|
||||
friend class SaveOrRunDialog;
|
||||
QNetworkReply* _reply;
|
||||
Executor* _executor;
|
||||
|
||||
};
|
||||
|
||||
class SaveOrRunPlugin: public SaveOrRun {
|
||||
@@ -228,11 +228,10 @@ namespace qbrowserlib {
|
||||
|
||||
public:
|
||||
|
||||
SaveOrRunPlugin(QNetworkReply* reply, Executor* executor,
|
||||
SaveOrRunPlugin(QNetworkReply* reply,
|
||||
const QUrl& url, const QString& mime,
|
||||
bool kiosk=false, QWidget* p=0):
|
||||
SaveOrRun(reply, executor,
|
||||
mime, url.toString(), p) {
|
||||
SaveOrRun(reply, mime, url.toString(), p) {
|
||||
TRC;
|
||||
setAutoFillBackground(true);
|
||||
_type->setText(mime);
|
||||
@@ -253,10 +252,9 @@ namespace qbrowserlib {
|
||||
|
||||
public:
|
||||
|
||||
SaveOrRunDialog(QNetworkReply* reply, Executor* executor,
|
||||
QString type, QString src,
|
||||
SaveOrRunDialog(QNetworkReply* reply, QString type, QString src,
|
||||
bool kiosk=false, QWidget* p=0):
|
||||
QDialog(p), _sor(new SaveOrRun(reply, executor, type, src)) {
|
||||
QDialog(p), _sor(new SaveOrRun(reply, type, src)) {
|
||||
TRC;
|
||||
setWindowTitle(tr("Unknown File Type"));
|
||||
QVBoxLayout* l(new QVBoxLayout(this));
|
||||
|
@@ -34,11 +34,10 @@ namespace qbrowserlib {
|
||||
signals:
|
||||
void newPage(SwissWebPage*);
|
||||
public:
|
||||
SwissWebPage(QNetworkAccessManager* net,
|
||||
Executor* executor, QObject *parent = 0):
|
||||
QWebPage(parent), _net(net), _executor(executor) {
|
||||
SwissWebPage(QNetworkAccessManager* net, QObject *parent = 0):
|
||||
QWebPage(parent), _net(net) {
|
||||
setNetworkAccessManager(_net);
|
||||
PluginFactory* pf(new PluginFactory(_net, _executor, this));
|
||||
PluginFactory* pf(new PluginFactory(_net, this));
|
||||
assert(connect(pf, SIGNAL(done()), SLOT(back())));
|
||||
setPluginFactory(pf);
|
||||
setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
|
||||
@@ -53,7 +52,7 @@ namespace qbrowserlib {
|
||||
switch (type) {
|
||||
case QWebPage::WebBrowserWindow:
|
||||
case QWebPage::WebModalDialog: {
|
||||
SwissWebPage *page(new SwissWebPage(_net, _executor, parent()));
|
||||
SwissWebPage *page(new SwissWebPage(_net, parent()));
|
||||
newPage(page);
|
||||
return page;
|
||||
} break;
|
||||
@@ -76,7 +75,6 @@ namespace qbrowserlib {
|
||||
}
|
||||
private:
|
||||
QNetworkAccessManager* _net;
|
||||
Executor* _executor;
|
||||
};
|
||||
|
||||
}
|
||||
|
@@ -38,16 +38,12 @@ namespace qbrowserlib {
|
||||
public:
|
||||
//! Default construction, creates new @ref SwissWebView
|
||||
SwissWebView(QWidget *parent=0,
|
||||
QNetworkAccessManager* net=0,
|
||||
Executor* executor=0): QWebView(parent) {
|
||||
QNetworkAccessManager* net=0): QWebView(parent) {
|
||||
if (!net) net = (_fallbackNetworkAccessManager =
|
||||
std::auto_ptr<QNetworkAccessManager>
|
||||
(new QNetworkAccessManager)).get();
|
||||
if (!executor) executor = (_fallbackExecutor =
|
||||
std::auto_ptr<Executor>
|
||||
(new Executor)).get();
|
||||
//! @bugfix, gcc does not yet support constructor calling
|
||||
x(new SwissWebPage(net, executor, this));
|
||||
x(new SwissWebPage(net, this));
|
||||
}
|
||||
//! Construction with externally allocated @ref SwissWebPage
|
||||
/*! SwissWebView takes ownership of SwissWebPage. */
|
||||
@@ -76,7 +72,6 @@ namespace qbrowserlib {
|
||||
private:
|
||||
|
||||
std::auto_ptr<QNetworkAccessManager> _fallbackNetworkAccessManager;
|
||||
std::auto_ptr<Executor> _fallbackExecutor;
|
||||
};
|
||||
|
||||
}
|
||||
|
@@ -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()));
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user