qbrowserlib::Settings as singleton; refs #167
This commit is contained in:
@@ -31,13 +31,13 @@ namespace qbrowserlib {
|
||||
|
||||
private:
|
||||
|
||||
Executor(Settings* settings=0): _settings(settings) {} // singleton
|
||||
Executor() {} // singleton
|
||||
Executor(const Executor&); // singleton
|
||||
|
||||
public:
|
||||
|
||||
static Executor& instance(Settings* settings=0) {
|
||||
static Executor _instance(settings);
|
||||
static Executor& instance() {
|
||||
static Executor _instance;
|
||||
return _instance;
|
||||
}
|
||||
|
||||
@@ -46,10 +46,11 @@ namespace qbrowserlib {
|
||||
for (DownloadProcesses::iterator it(_downloadProcesses.begin());
|
||||
it!=_downloadProcesses.end(); ++it) {
|
||||
LOG<<"cleanup:"<<it->second->fileName();
|
||||
it->second->setAutoRemove(_settings && _settings->flag("CloseApps"));
|
||||
it->second->setAutoRemove(qbrowserlib::Settings::instance()
|
||||
.flag("CloseApps"));
|
||||
delete it->second;
|
||||
it->second = 0;
|
||||
if (_settings && _settings->flag("CloseApps")) {
|
||||
if (qbrowserlib::Settings::instance().flag("CloseApps")) {
|
||||
LOG<<"terminate process";
|
||||
it->first->terminate();
|
||||
delete it->first;
|
||||
@@ -57,10 +58,6 @@ namespace qbrowserlib {
|
||||
}
|
||||
}
|
||||
|
||||
Settings* settings() {
|
||||
return _settings;
|
||||
}
|
||||
|
||||
public Q_SLOTS:
|
||||
|
||||
void run(QNetworkReply* reply, QString filename, QString command) {
|
||||
@@ -107,7 +104,8 @@ namespace qbrowserlib {
|
||||
== _downloadProcesses.end()) return;
|
||||
if (_downloadProcesses[qobject_cast<QProcess*>(sender())])
|
||||
_downloadProcesses[qobject_cast<QProcess*>(sender())]
|
||||
->setAutoRemove(_settings && _settings->flag("CloseApps"));
|
||||
->setAutoRemove(qbrowserlib::Settings::instance()
|
||||
.flag("CloseApps"));
|
||||
delete _downloadProcesses[qobject_cast<QProcess*>(sender())];
|
||||
_downloadProcesses.erase(qobject_cast<QProcess*>(sender()));
|
||||
applicationFinished();
|
||||
@@ -117,7 +115,6 @@ namespace qbrowserlib {
|
||||
|
||||
typedef std::map<QProcess*, TemporaryFile*> DownloadProcesses;
|
||||
DownloadProcesses _downloadProcesses;
|
||||
Settings* _settings;
|
||||
QNetworkReply* _reply;
|
||||
QString _filename;
|
||||
QString _command;
|
||||
|
@@ -60,7 +60,7 @@ namespace qbrowserlib {
|
||||
TRC;
|
||||
QString filename(remoteFilename());
|
||||
QStringList type
|
||||
(qbrowserlib::Executor::instance().settings()->mimetype
|
||||
(qbrowserlib::Settings::instance().mimetype
|
||||
(_reply->header(QNetworkRequest::ContentTypeHeader).toString(),
|
||||
filename));
|
||||
if (!type.isEmpty()) {
|
||||
|
@@ -36,6 +36,17 @@ namespace qbrowserlib {
|
||||
|
||||
public:
|
||||
|
||||
//! Singleton
|
||||
static Settings& instance(MimeTypes mimetypes=MimeTypes(), QWidget* p=0,
|
||||
QSettings* settings=0, bool autoWrite=true) {
|
||||
static Settings _instance(mimetypes, p, settings, autoWrite);
|
||||
return _instance;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
Settings(const Settings&); // singleton
|
||||
|
||||
Settings(MimeTypes mimetypes, QWidget* p=0,
|
||||
QSettings* settings=0, bool autoWrite=true):
|
||||
QDialog(p), _settings(settings),
|
||||
@@ -114,6 +125,8 @@ namespace qbrowserlib {
|
||||
on__buttons_rejected();
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
static bool DEBUG;
|
||||
|
||||
void setSettings(QSettings* settings) {
|
||||
|
Reference in New Issue
Block a user