qbrowserlib::Executor as singleton; refs #167

master
Marc Wäckerlin 12 years ago
parent db352a329b
commit d191d8cc68
  1. 10
      src/browser.hxx
  2. 3
      src/designer/webviewwidgetifc.hxx
  3. 12
      src/qbrowserlib/executor.hxx
  4. 9
      src/qbrowserlib/pluginfactory.hxx
  5. 24
      src/qbrowserlib/qbrowserlib_de.ts
  6. 24
      src/qbrowserlib/qbrowserlib_en.ts
  7. 24
      src/qbrowserlib/qbrowserlib_fr.ts
  8. 24
      src/qbrowserlib/qbrowserlib_it.ts
  9. 28
      src/qbrowserlib/saveorrun.hxx
  10. 10
      src/qbrowserlib/swisswebpage.hxx
  11. 9
      src/qbrowserlib/swisswebview.hxx
  12. 43
      src/qbrowserlib/swisswebwidget.hxx

@ -75,9 +75,9 @@ class Browser: public QMainWindow, protected Ui::Browser {
_startUrl(urls.size()), _startUrl(urls.size()),
_quirks(quirks), _search(new qbrowserlib::ButtonLineEdit), _quirks(quirks), _search(new qbrowserlib::ButtonLineEdit),
_searchEngines(new QComboBox), _searchEngines(new QComboBox),
_bookmarkfile(bookmarkfile), _bookmarkfile(bookmarkfile) {
_executor(&_settings) {
TRC; LOG<<urls; TRC; LOG<<urls;
qbrowserlib::Executor::instance(&_settings);
_home = "about:blank"; _home = "about:blank";
if (urls.size()) _home = urls.at(0); if (urls.size()) _home = urls.at(0);
setupUi(this); setupUi(this);
@ -248,7 +248,7 @@ class Browser: public QMainWindow, protected Ui::Browser {
//! Create new empty tab. //! Create new empty tab.
qbrowserlib::SwissWebView* newTab() { qbrowserlib::SwissWebView* newTab() {
qbrowserlib::SwissWebView* browser qbrowserlib::SwissWebView* browser
(new qbrowserlib::SwissWebView(0, &_networkManager, &_executor)); (new qbrowserlib::SwissWebView(0, &_networkManager));
newTab(browser); newTab(browser);
return browser; return browser;
} }
@ -1391,8 +1391,7 @@ class Browser: public QMainWindow, protected Ui::Browser {
statusBar()->showMessage(tr("handling content ..."), 5000); statusBar()->showMessage(tr("handling content ..."), 5000);
LOG<<"Show SaveOrRunDialog"; LOG<<"Show SaveOrRunDialog";
qbrowserlib::SaveOrRunDialog dlg qbrowserlib::SaveOrRunDialog dlg
(reply, &_executor, (reply, reply->header(QNetworkRequest::ContentTypeHeader).toString(),
reply->header(QNetworkRequest::ContentTypeHeader).toString(),
reply->url().host(), _kiosk, this); reply->url().host(), _kiosk, this);
if (!dlg.handlePreconfigured()) dlg.exec(); if (!dlg.handlePreconfigured()) dlg.exec();
} }
@ -1536,7 +1535,6 @@ class Browser: public QMainWindow, protected Ui::Browser {
qbrowserlib::ButtonLineEdit* _search; qbrowserlib::ButtonLineEdit* _search;
QComboBox* _searchEngines; QComboBox* _searchEngines;
FileStorage _bookmarkfile; FileStorage _bookmarkfile;
qbrowserlib::Executor _executor;
}; };
//! @} //! @}

@ -76,7 +76,7 @@ class SwissWebViewWidgetIfc: public QObject,
} }
QWidget *createWidget(QWidget *parent) { QWidget *createWidget(QWidget *parent) {
TRC; TRC;
return new qbrowserlib::SwissWebView(parent, &_net, &_executor); return new qbrowserlib::SwissWebView(parent, &_net);
} }
bool isInitialized() { bool isInitialized() {
TRC; TRC;
@ -84,7 +84,6 @@ class SwissWebViewWidgetIfc: public QObject,
} }
private: private:
QNetworkAccessManager _net; QNetworkAccessManager _net;
qbrowserlib::Executor _executor;
}; };
//! @} //! @}

@ -18,6 +18,8 @@
namespace qbrowserlib { namespace qbrowserlib {
//! Execute external processes
/*! Implements a singleton pattern */
class Executor: public QObject { class Executor: public QObject {
Q_OBJECT; Q_OBJECT;
@ -27,9 +29,17 @@ namespace qbrowserlib {
void applicationStarted(); void applicationStarted();
void applicationFinished(); void applicationFinished();
private:
Executor(Settings* settings=0): _settings(settings) {} // singleton
Executor(const Executor&); // singleton
public: public:
Executor(Settings* settings=0): _settings(settings) {} static Executor& instance(Settings* settings=0) {
static Executor _instance(settings);
return _instance;
}
~Executor() { ~Executor() {
TRC; TRC;

@ -24,9 +24,8 @@ namespace qbrowserlib {
signals: signals:
void done(); void done();
public: public:
PluginFactory(QNetworkAccessManager* net, Executor* executor, PluginFactory(QNetworkAccessManager* net, QObject* p=0):
QObject* p=0): QWebPluginFactory(p), QWebPluginFactory(p), _net(net) {
_net(net), _executor(executor) {
TRC; TRC;
// Plugin plugin; // Plugin plugin;
// plugin.name = "Show PDF-Document"; // plugin.name = "Show PDF-Document";
@ -50,8 +49,7 @@ namespace qbrowserlib {
// } // }
QNetworkRequest req(url); QNetworkRequest req(url);
QNetworkReply* reply(_net->get(QNetworkRequest(url))); QNetworkReply* reply(_net->get(QNetworkRequest(url)));
SaveOrRunPlugin* p(new SaveOrRunPlugin(reply, _executor, SaveOrRunPlugin* p(new SaveOrRunPlugin(reply, url, mimeType));
url, mimeType));
assert(connect(p, SIGNAL(accept()), SIGNAL(done()))); assert(connect(p, SIGNAL(accept()), SIGNAL(done())));
if (p->handlePreconfigured()) { if (p->handlePreconfigured()) {
return p; return p;
@ -69,7 +67,6 @@ namespace qbrowserlib {
private: private:
QList<Plugin> _plugins; QList<Plugin> _plugins;
QNetworkAccessManager* _net; QNetworkAccessManager* _net;
Executor* _executor;
}; };
} }

@ -632,14 +632,14 @@ p, li { white-space: pre-wrap; }
<context> <context>
<name>qbrowserlib::SaveOrRun</name> <name>qbrowserlib::SaveOrRun</name>
<message> <message>
<location filename="saveorrun.hxx" line="144"/> <location filename="saveorrun.hxx" line="146"/>
<location filename="saveorrun.hxx" line="156"/> <location filename="saveorrun.hxx" line="158"/>
<source>File Exists</source> <source>File Exists</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="saveorrun.hxx" line="145"/> <location filename="saveorrun.hxx" line="147"/>
<location filename="saveorrun.hxx" line="157"/> <location filename="saveorrun.hxx" line="159"/>
<source>File already exists: <source>File already exists:
%1 %1
@ -648,12 +648,12 @@ Overwrite?</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="saveorrun.hxx" line="169"/> <location filename="saveorrun.hxx" line="171"/>
<source>No Program</source> <source>No Program</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="saveorrun.hxx" line="170"/> <location filename="saveorrun.hxx" line="172"/>
<source>Not an executable Program: <source>Not an executable Program:
%1 %1
@ -662,23 +662,23 @@ Specify full path to executable program</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="saveorrun.hxx" line="182"/> <location filename="saveorrun.hxx" line="184"/>
<source>Save File As ...</source> <source>Save File As ...</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="saveorrun.hxx" line="195"/> <location filename="saveorrun.hxx" line="197"/>
<source>Open File With ...</source> <source>Open File With ...</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="saveorrun.hxx" line="207"/> <location filename="saveorrun.hxx" line="209"/>
<source>Dokumente</source> <source>Dokumente</source>
<comment>Documents folder in local language</comment> <comment>Documents folder in local language</comment>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="saveorrun.hxx" line="209"/> <location filename="saveorrun.hxx" line="211"/>
<source>Arbeitsfläche</source> <source>Arbeitsfläche</source>
<comment>Desktop folder in local language</comment> <comment>Desktop folder in local language</comment>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
@ -687,7 +687,7 @@ Specify full path to executable program</source>
<context> <context>
<name>qbrowserlib::SaveOrRunDialog</name> <name>qbrowserlib::SaveOrRunDialog</name>
<message> <message>
<location filename="saveorrun.hxx" line="261"/> <location filename="saveorrun.hxx" line="259"/>
<source>Unknown File Type</source> <source>Unknown File Type</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -695,7 +695,7 @@ Specify full path to executable program</source>
<context> <context>
<name>qbrowserlib::SwissWebWidget</name> <name>qbrowserlib::SwissWebWidget</name>
<message> <message>
<location filename="swisswebwidget.hxx" line="41"/> <location filename="swisswebwidget.hxx" line="53"/>
<source>Browser Tools</source> <source>Browser Tools</source>
<comment>name of the browser&apos;s toolbar</comment> <comment>name of the browser&apos;s toolbar</comment>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>

@ -632,14 +632,14 @@ p, li { white-space: pre-wrap; }
<context> <context>
<name>qbrowserlib::SaveOrRun</name> <name>qbrowserlib::SaveOrRun</name>
<message> <message>
<location filename="saveorrun.hxx" line="144"/> <location filename="saveorrun.hxx" line="146"/>
<location filename="saveorrun.hxx" line="156"/> <location filename="saveorrun.hxx" line="158"/>
<source>File Exists</source> <source>File Exists</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="saveorrun.hxx" line="145"/> <location filename="saveorrun.hxx" line="147"/>
<location filename="saveorrun.hxx" line="157"/> <location filename="saveorrun.hxx" line="159"/>
<source>File already exists: <source>File already exists:
%1 %1
@ -648,12 +648,12 @@ Overwrite?</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="saveorrun.hxx" line="169"/> <location filename="saveorrun.hxx" line="171"/>
<source>No Program</source> <source>No Program</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="saveorrun.hxx" line="170"/> <location filename="saveorrun.hxx" line="172"/>
<source>Not an executable Program: <source>Not an executable Program:
%1 %1
@ -662,23 +662,23 @@ Specify full path to executable program</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="saveorrun.hxx" line="182"/> <location filename="saveorrun.hxx" line="184"/>
<source>Save File As ...</source> <source>Save File As ...</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="saveorrun.hxx" line="195"/> <location filename="saveorrun.hxx" line="197"/>
<source>Open File With ...</source> <source>Open File With ...</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="saveorrun.hxx" line="207"/> <location filename="saveorrun.hxx" line="209"/>
<source>Dokumente</source> <source>Dokumente</source>
<comment>Documents folder in local language</comment> <comment>Documents folder in local language</comment>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="saveorrun.hxx" line="209"/> <location filename="saveorrun.hxx" line="211"/>
<source>Arbeitsfläche</source> <source>Arbeitsfläche</source>
<comment>Desktop folder in local language</comment> <comment>Desktop folder in local language</comment>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
@ -687,7 +687,7 @@ Specify full path to executable program</source>
<context> <context>
<name>qbrowserlib::SaveOrRunDialog</name> <name>qbrowserlib::SaveOrRunDialog</name>
<message> <message>
<location filename="saveorrun.hxx" line="261"/> <location filename="saveorrun.hxx" line="259"/>
<source>Unknown File Type</source> <source>Unknown File Type</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -695,7 +695,7 @@ Specify full path to executable program</source>
<context> <context>
<name>qbrowserlib::SwissWebWidget</name> <name>qbrowserlib::SwissWebWidget</name>
<message> <message>
<location filename="swisswebwidget.hxx" line="41"/> <location filename="swisswebwidget.hxx" line="53"/>
<source>Browser Tools</source> <source>Browser Tools</source>
<comment>name of the browser&apos;s toolbar</comment> <comment>name of the browser&apos;s toolbar</comment>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>

@ -632,14 +632,14 @@ p, li { white-space: pre-wrap; }
<context> <context>
<name>qbrowserlib::SaveOrRun</name> <name>qbrowserlib::SaveOrRun</name>
<message> <message>
<location filename="saveorrun.hxx" line="144"/> <location filename="saveorrun.hxx" line="146"/>
<location filename="saveorrun.hxx" line="156"/> <location filename="saveorrun.hxx" line="158"/>
<source>File Exists</source> <source>File Exists</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="saveorrun.hxx" line="145"/> <location filename="saveorrun.hxx" line="147"/>
<location filename="saveorrun.hxx" line="157"/> <location filename="saveorrun.hxx" line="159"/>
<source>File already exists: <source>File already exists:
%1 %1
@ -648,12 +648,12 @@ Overwrite?</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="saveorrun.hxx" line="169"/> <location filename="saveorrun.hxx" line="171"/>
<source>No Program</source> <source>No Program</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="saveorrun.hxx" line="170"/> <location filename="saveorrun.hxx" line="172"/>
<source>Not an executable Program: <source>Not an executable Program:
%1 %1
@ -662,23 +662,23 @@ Specify full path to executable program</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="saveorrun.hxx" line="182"/> <location filename="saveorrun.hxx" line="184"/>
<source>Save File As ...</source> <source>Save File As ...</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="saveorrun.hxx" line="195"/> <location filename="saveorrun.hxx" line="197"/>
<source>Open File With ...</source> <source>Open File With ...</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="saveorrun.hxx" line="207"/> <location filename="saveorrun.hxx" line="209"/>
<source>Dokumente</source> <source>Dokumente</source>
<comment>Documents folder in local language</comment> <comment>Documents folder in local language</comment>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="saveorrun.hxx" line="209"/> <location filename="saveorrun.hxx" line="211"/>
<source>Arbeitsfläche</source> <source>Arbeitsfläche</source>
<comment>Desktop folder in local language</comment> <comment>Desktop folder in local language</comment>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
@ -687,7 +687,7 @@ Specify full path to executable program</source>
<context> <context>
<name>qbrowserlib::SaveOrRunDialog</name> <name>qbrowserlib::SaveOrRunDialog</name>
<message> <message>
<location filename="saveorrun.hxx" line="261"/> <location filename="saveorrun.hxx" line="259"/>
<source>Unknown File Type</source> <source>Unknown File Type</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -695,7 +695,7 @@ Specify full path to executable program</source>
<context> <context>
<name>qbrowserlib::SwissWebWidget</name> <name>qbrowserlib::SwissWebWidget</name>
<message> <message>
<location filename="swisswebwidget.hxx" line="41"/> <location filename="swisswebwidget.hxx" line="53"/>
<source>Browser Tools</source> <source>Browser Tools</source>
<comment>name of the browser&apos;s toolbar</comment> <comment>name of the browser&apos;s toolbar</comment>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>

@ -632,14 +632,14 @@ p, li { white-space: pre-wrap; }
<context> <context>
<name>qbrowserlib::SaveOrRun</name> <name>qbrowserlib::SaveOrRun</name>
<message> <message>
<location filename="saveorrun.hxx" line="144"/> <location filename="saveorrun.hxx" line="146"/>
<location filename="saveorrun.hxx" line="156"/> <location filename="saveorrun.hxx" line="158"/>
<source>File Exists</source> <source>File Exists</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="saveorrun.hxx" line="145"/> <location filename="saveorrun.hxx" line="147"/>
<location filename="saveorrun.hxx" line="157"/> <location filename="saveorrun.hxx" line="159"/>
<source>File already exists: <source>File already exists:
%1 %1
@ -648,12 +648,12 @@ Overwrite?</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="saveorrun.hxx" line="169"/> <location filename="saveorrun.hxx" line="171"/>
<source>No Program</source> <source>No Program</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="saveorrun.hxx" line="170"/> <location filename="saveorrun.hxx" line="172"/>
<source>Not an executable Program: <source>Not an executable Program:
%1 %1
@ -662,23 +662,23 @@ Specify full path to executable program</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="saveorrun.hxx" line="182"/> <location filename="saveorrun.hxx" line="184"/>
<source>Save File As ...</source> <source>Save File As ...</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="saveorrun.hxx" line="195"/> <location filename="saveorrun.hxx" line="197"/>
<source>Open File With ...</source> <source>Open File With ...</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="saveorrun.hxx" line="207"/> <location filename="saveorrun.hxx" line="209"/>
<source>Dokumente</source> <source>Dokumente</source>
<comment>Documents folder in local language</comment> <comment>Documents folder in local language</comment>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="saveorrun.hxx" line="209"/> <location filename="saveorrun.hxx" line="211"/>
<source>Arbeitsfläche</source> <source>Arbeitsfläche</source>
<comment>Desktop folder in local language</comment> <comment>Desktop folder in local language</comment>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
@ -687,7 +687,7 @@ Specify full path to executable program</source>
<context> <context>
<name>qbrowserlib::SaveOrRunDialog</name> <name>qbrowserlib::SaveOrRunDialog</name>
<message> <message>
<location filename="saveorrun.hxx" line="261"/> <location filename="saveorrun.hxx" line="259"/>
<source>Unknown File Type</source> <source>Unknown File Type</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -695,7 +695,7 @@ Specify full path to executable program</source>
<context> <context>
<name>qbrowserlib::SwissWebWidget</name> <name>qbrowserlib::SwissWebWidget</name>
<message> <message>
<location filename="swisswebwidget.hxx" line="41"/> <location filename="swisswebwidget.hxx" line="53"/>
<source>Browser Tools</source> <source>Browser Tools</source>
<comment>name of the browser&apos;s toolbar</comment> <comment>name of the browser&apos;s toolbar</comment>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>

@ -39,9 +39,8 @@ namespace qbrowserlib {
public: public:
SaveOrRun(QNetworkReply* reply, Executor* executor, SaveOrRun(QNetworkReply* reply, QString type, QString src, QWidget* p=0):
QString type, QString src, QWidget(p), _reply(reply) {
QWidget* p=0): QWidget(p), _reply(reply), _executor(executor) {
TRC; TRC;
setupUi(this); setupUi(this);
QString obj(remoteFilename()); QString obj(remoteFilename());
@ -61,7 +60,7 @@ namespace qbrowserlib {
TRC; TRC;
QString filename(remoteFilename()); QString filename(remoteFilename());
QStringList type QStringList type
(_executor->settings()->mimetype (qbrowserlib::Executor::instance().settings()->mimetype
(_reply->header(QNetworkRequest::ContentTypeHeader).toString(), (_reply->header(QNetworkRequest::ContentTypeHeader).toString(),
filename)); filename));
if (!type.isEmpty()) { if (!type.isEmpty()) {
@ -69,9 +68,11 @@ namespace qbrowserlib {
hide(); hide();
filename.replace(QRegExp("^(.*)\\."+type.at(0)+"$"), filename.replace(QRegExp("^(.*)\\."+type.at(0)+"$"),
"\\1"); // remove extension "\\1"); // remove extension
assert(connect(_executor, SIGNAL(applicationStarted()), assert(connect(&qbrowserlib::Executor::instance(),
SIGNAL(applicationStarted()),
SIGNAL(accept()))); 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 true;
} }
return false; return false;
@ -132,7 +133,8 @@ namespace qbrowserlib {
void run() { void run() {
TRC; LOG<<program()<<filename(); TRC; LOG<<program()<<filename();
_executor->run(_reply, filename(), program()+" %1"); qbrowserlib::Executor::instance().run
(_reply, filename(), program()+" %1");
accept(); accept();
} }
@ -219,8 +221,6 @@ namespace qbrowserlib {
friend class SaveOrRunDialog; friend class SaveOrRunDialog;
QNetworkReply* _reply; QNetworkReply* _reply;
Executor* _executor;
}; };
class SaveOrRunPlugin: public SaveOrRun { class SaveOrRunPlugin: public SaveOrRun {
@ -228,11 +228,10 @@ namespace qbrowserlib {
public: public:
SaveOrRunPlugin(QNetworkReply* reply, Executor* executor, SaveOrRunPlugin(QNetworkReply* reply,
const QUrl& url, const QString& mime, const QUrl& url, const QString& mime,
bool kiosk=false, QWidget* p=0): bool kiosk=false, QWidget* p=0):
SaveOrRun(reply, executor, SaveOrRun(reply, mime, url.toString(), p) {
mime, url.toString(), p) {
TRC; TRC;
setAutoFillBackground(true); setAutoFillBackground(true);
_type->setText(mime); _type->setText(mime);
@ -253,10 +252,9 @@ namespace qbrowserlib {
public: public:
SaveOrRunDialog(QNetworkReply* reply, Executor* executor, SaveOrRunDialog(QNetworkReply* reply, QString type, QString src,
QString type, QString src,
bool kiosk=false, QWidget* p=0): bool kiosk=false, QWidget* p=0):
QDialog(p), _sor(new SaveOrRun(reply, executor, type, src)) { QDialog(p), _sor(new SaveOrRun(reply, type, src)) {
TRC; TRC;
setWindowTitle(tr("Unknown File Type")); setWindowTitle(tr("Unknown File Type"));
QVBoxLayout* l(new QVBoxLayout(this)); QVBoxLayout* l(new QVBoxLayout(this));

@ -34,11 +34,10 @@ namespace qbrowserlib {
signals: signals:
void newPage(SwissWebPage*); void newPage(SwissWebPage*);
public: public:
SwissWebPage(QNetworkAccessManager* net, SwissWebPage(QNetworkAccessManager* net, QObject *parent = 0):
Executor* executor, QObject *parent = 0): QWebPage(parent), _net(net) {
QWebPage(parent), _net(net), _executor(executor) {
setNetworkAccessManager(_net); setNetworkAccessManager(_net);
PluginFactory* pf(new PluginFactory(_net, _executor, this)); PluginFactory* pf(new PluginFactory(_net, this));
assert(connect(pf, SIGNAL(done()), SLOT(back()))); assert(connect(pf, SIGNAL(done()), SLOT(back())));
setPluginFactory(pf); setPluginFactory(pf);
setLinkDelegationPolicy(QWebPage::DelegateAllLinks); setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
@ -53,7 +52,7 @@ namespace qbrowserlib {
switch (type) { switch (type) {
case QWebPage::WebBrowserWindow: case QWebPage::WebBrowserWindow:
case QWebPage::WebModalDialog: { case QWebPage::WebModalDialog: {
SwissWebPage *page(new SwissWebPage(_net, _executor, parent())); SwissWebPage *page(new SwissWebPage(_net, parent()));
newPage(page); newPage(page);
return page; return page;
} break; } break;
@ -76,7 +75,6 @@ namespace qbrowserlib {
} }
private: private:
QNetworkAccessManager* _net; QNetworkAccessManager* _net;
Executor* _executor;
}; };
} }

@ -38,16 +38,12 @@ namespace qbrowserlib {
public: public:
//! Default construction, creates new @ref SwissWebView //! Default construction, creates new @ref SwissWebView
SwissWebView(QWidget *parent=0, SwissWebView(QWidget *parent=0,
QNetworkAccessManager* net=0, QNetworkAccessManager* net=0): QWebView(parent) {
Executor* executor=0): QWebView(parent) {
if (!net) net = (_fallbackNetworkAccessManager = if (!net) net = (_fallbackNetworkAccessManager =
std::auto_ptr<QNetworkAccessManager> std::auto_ptr<QNetworkAccessManager>
(new QNetworkAccessManager)).get(); (new QNetworkAccessManager)).get();
if (!executor) executor = (_fallbackExecutor =
std::auto_ptr<Executor>
(new Executor)).get();
//! @bugfix, gcc does not yet support constructor calling //! @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 //! Construction with externally allocated @ref SwissWebPage
/*! SwissWebView takes ownership of SwissWebPage. */ /*! SwissWebView takes ownership of SwissWebPage. */
@ -76,7 +72,6 @@ namespace qbrowserlib {
private: private:
std::auto_ptr<QNetworkAccessManager> _fallbackNetworkAccessManager; 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 browser. To be used inside a QTabBar, as main window or as
docking widget. */ docking widget. */
class SwissWebWidget: public QWidget, private Ui::SwissWebWidget { class SwissWebWidget: public QWidget, private Ui::SwissWebWidget {
Q_OBJECT; Q_OBJECT;
public: public:
SwissWebWidget(QWidget* p=0): QWidget(p) { SwissWebWidget(QWidget* p=0): QWidget(p) {
setupUi(this); 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 /*! Within a QMainWindow, the widget automatically reparents
the top buttons to the toolbar and the bottom status the top buttons to the toolbar and the bottom status
line to the window's status bar. */ line to the window's status bar. */
qDebug()<<"Rearranging"; 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", QToolBar* t(w->addToolBar(trUtf8("Browser Tools",
"name of the browser's toolbar"))); "name of the browser's toolbar")));
while (_tools->count()) { while (_tools->count())
qDebug()<<"Rearranging tool item "<<(0)<<_tools->itemAt(0);
t->addWidget(_tools->itemAt(0)->widget()); t->addWidget(_tools->itemAt(0)->widget());
}
delete _tools; _tools=0; delete _tools; _tools=0;
t->show(); _statusbar->removeWidget(_status); delete _status; _status=0;
_statusbar->removeWidget(_status); while (_statusbar->count())
delete _status; _status=0;
while (_statusbar->count()) {
qDebug()<<"Rearranging stat item "<<(0)<<_statusbar->itemAt(0);
w->statusBar()->addWidget(_statusbar->itemAt(0)->widget()); w->statusBar()->addWidget(_statusbar->itemAt(0)->widget());
}
delete _statusbar; _statusbar=0; delete _statusbar; _statusbar=0;
} }
public Q_SLOTS:
void load() {
_webview->load(_url->text());
} }
protected: protected:
void connects() {
connect(_url, SIGNAL(returnPressed()), SLOT(load()));
}
}; };
} }

Loading…
Cancel
Save