|
|
|
@ -68,7 +68,6 @@ class Browser: public QMainWindow, protected Ui::Browser { |
|
|
|
|
_url(0), _find(new qbrowserlib::ButtonLineEdit), |
|
|
|
|
_kiosk(kiosk), |
|
|
|
|
_downloadManager(new DownloadManager), |
|
|
|
|
_settings(mimeTypes, this, settings, !kiosk), |
|
|
|
|
_errorLog(this), _logincertificate(this), |
|
|
|
|
_proxy("http://swisssign.com", this), |
|
|
|
|
_showErrorLog(0), |
|
|
|
@ -77,7 +76,7 @@ class Browser: public QMainWindow, protected Ui::Browser { |
|
|
|
|
_searchEngines(new QComboBox), |
|
|
|
|
_bookmarkfile(bookmarkfile) { |
|
|
|
|
TRC; LOG<<urls; |
|
|
|
|
qbrowserlib::Executor::instance(&_settings); |
|
|
|
|
qbrowserlib::Settings::instance(mimeTypes, this, settings, !kiosk); |
|
|
|
|
_home = "about:blank"; |
|
|
|
|
if (urls.size()) _home = urls.at(0); |
|
|
|
|
setupUi(this); |
|
|
|
@ -204,7 +203,8 @@ class Browser: public QMainWindow, protected Ui::Browser { |
|
|
|
|
SLOT(downloadError(QString)))); |
|
|
|
|
assert(connect(_downloadManager.data(), SIGNAL(metaDataChanged(QNetworkReply*)), |
|
|
|
|
SLOT(metaDataChanged(QNetworkReply*)))); |
|
|
|
|
assert(connect(&_settings, SIGNAL(newSettings()), SLOT(newSettings()))); |
|
|
|
|
assert(connect(&qbrowserlib::Settings::instance(), |
|
|
|
|
SIGNAL(newSettings()), SLOT(newSettings()))); |
|
|
|
|
newSettings(); |
|
|
|
|
on_actionNewTab_triggered(); |
|
|
|
|
|
|
|
|
@ -223,7 +223,9 @@ class Browser: public QMainWindow, protected Ui::Browser { |
|
|
|
|
delete _bookmarks; _bookmarks=0; |
|
|
|
|
} |
|
|
|
|
if (!_kiosk && |
|
|
|
|
((!_startUrl && _settings.flag("SaveWindowState") && _settings()) || |
|
|
|
|
((!_startUrl && |
|
|
|
|
qbrowserlib::Settings::instance().flag("SaveWindowState") && |
|
|
|
|
qbrowserlib::Settings::instance()()) || |
|
|
|
|
_bookmarkfile.readable())) |
|
|
|
|
loadWin(); |
|
|
|
|
if (urls.size()) load(urls.at(0)); |
|
|
|
@ -259,7 +261,9 @@ class Browser: public QMainWindow, protected Ui::Browser { |
|
|
|
|
void closeEvent(QCloseEvent *event) { |
|
|
|
|
TRC; |
|
|
|
|
if (!_kiosk && |
|
|
|
|
((!_startUrl && _settings.flag("SaveWindowState") && _settings()) || |
|
|
|
|
((!_startUrl && |
|
|
|
|
qbrowserlib::Settings::instance().flag("SaveWindowState") && |
|
|
|
|
qbrowserlib::Settings::instance()()) || |
|
|
|
|
_bookmarkfile.writeable())) |
|
|
|
|
saveWin(); |
|
|
|
|
QMainWindow::closeEvent(event); |
|
|
|
@ -285,7 +289,7 @@ class Browser: public QMainWindow, protected Ui::Browser { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void load(QString page) { |
|
|
|
|
_settings.replaceSearchEngine(page); |
|
|
|
|
qbrowserlib::Settings::instance().replaceSearchEngine(page); |
|
|
|
|
if (QUrl(page).scheme()=="") page = "http://"+page; |
|
|
|
|
if (qobject_cast<QComboBox*>(_url)) |
|
|
|
|
qobject_cast<QComboBox*>(_url)->lineEdit()->setText(page); |
|
|
|
@ -584,8 +588,8 @@ class Browser: public QMainWindow, protected Ui::Browser { |
|
|
|
|
void newSettings() { |
|
|
|
|
_searchEngines->clear(); |
|
|
|
|
for (qbrowserlib::Settings::SearchEngines::const_iterator |
|
|
|
|
it(_settings.searchEngines().begin()); |
|
|
|
|
it!=_settings.searchEngines().end(); it++) |
|
|
|
|
it(qbrowserlib::Settings::instance().searchEngines().begin()); |
|
|
|
|
it!=qbrowserlib::Settings::instance().searchEngines().end(); it++) |
|
|
|
|
if (QFile(":/icons/"+it.key()).exists()) |
|
|
|
|
_searchEngines->addItem(QIcon(":/icons/"+it.key()), "", it.value()); |
|
|
|
|
else |
|
|
|
@ -854,7 +858,7 @@ class Browser: public QMainWindow, protected Ui::Browser { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void on_actionSettings_triggered() { |
|
|
|
|
_settings.show(); |
|
|
|
|
qbrowserlib::Settings::instance().show(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void on_actionSaveWindowState_triggered() { |
|
|
|
@ -868,14 +872,17 @@ class Browser: public QMainWindow, protected Ui::Browser { |
|
|
|
|
void saveWin() { |
|
|
|
|
TRC; LOG<<"Save Window State"; |
|
|
|
|
saveBookmarks(); |
|
|
|
|
if (!_settings()) return; |
|
|
|
|
if (!qbrowserlib::Settings::instance()()) return; |
|
|
|
|
QStringList tabs; |
|
|
|
|
for (int i(0); i<_tabs->count(); ++i) |
|
|
|
|
tabs<<qobject_cast<QWebView*>(_tabs->widget(i))->url().toString(); |
|
|
|
|
_settings()->setValue("Window/Tabs", tabs); |
|
|
|
|
_settings()->setValue("Window/CurrentTab", _tabs->currentIndex()); |
|
|
|
|
_settings()->setValue("Window/Geometry", saveGeometry()); |
|
|
|
|
_settings()->setValue("Window/WindowState", saveState()); |
|
|
|
|
qbrowserlib::Settings::instance()()->setValue("Window/Tabs", tabs); |
|
|
|
|
qbrowserlib::Settings::instance()() |
|
|
|
|
->setValue("Window/CurrentTab", _tabs->currentIndex()); |
|
|
|
|
qbrowserlib::Settings::instance()() |
|
|
|
|
->setValue("Window/Geometry", saveGeometry()); |
|
|
|
|
qbrowserlib::Settings::instance()() |
|
|
|
|
->setValue("Window/WindowState", saveState()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void saveBookmarks() { |
|
|
|
@ -889,17 +896,17 @@ class Browser: public QMainWindow, protected Ui::Browser { |
|
|
|
|
if (_bookmarkfile.writeable()) { |
|
|
|
|
LOG<<"write to bookmark file"<<_bookmarkfile.name(); |
|
|
|
|
_bookmarkfile.write(urls); |
|
|
|
|
} else if (_settings()) { |
|
|
|
|
} else if (qbrowserlib::Settings::instance()()) { |
|
|
|
|
LOG<<"write to settings"; |
|
|
|
|
_settings()->setValue("Window/Urls", urls); |
|
|
|
|
qbrowserlib::Settings::instance()()->setValue("Window/Urls", urls); |
|
|
|
|
} else LOG<<"bookmarks not saved"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void loadWin() { |
|
|
|
|
TRC; |
|
|
|
|
loadBookmarks(); |
|
|
|
|
if (!_settings()) return; |
|
|
|
|
QStringList tabs(_settings()->value("Window/Tabs").toStringList()); |
|
|
|
|
if (!qbrowserlib::Settings::instance()()) return; |
|
|
|
|
QStringList tabs(qbrowserlib::Settings::instance()()->value("Window/Tabs").toStringList()); |
|
|
|
|
int oldCnt(_tabs->count()); |
|
|
|
|
for (QStringList::iterator it(tabs.begin()); it!=tabs.end(); ++it) { |
|
|
|
|
LOG<<"-------------------------------------------------------------"; |
|
|
|
@ -909,9 +916,12 @@ class Browser: public QMainWindow, protected Ui::Browser { |
|
|
|
|
for (int i(0); i<oldCnt && _tabs->count()>1; ++i) _tabs->removeTab(0); |
|
|
|
|
_tabs->setTabsClosable(_tabs->count()>1); |
|
|
|
|
//_tabs->tabBar()->setShown(_tabs->count()>1);
|
|
|
|
|
_tabs->setCurrentIndex(_settings()->value("Window/CurrentTab").toInt()); |
|
|
|
|
restoreGeometry(_settings()->value("Window/Geometry").toByteArray()); |
|
|
|
|
restoreState(_settings()->value("Window/WindowState").toByteArray()); |
|
|
|
|
_tabs->setCurrentIndex(qbrowserlib::Settings::instance()() |
|
|
|
|
->value("Window/CurrentTab").toInt()); |
|
|
|
|
restoreGeometry(qbrowserlib::Settings::instance()() |
|
|
|
|
->value("Window/Geometry").toByteArray()); |
|
|
|
|
restoreState(qbrowserlib::Settings::instance()() |
|
|
|
|
->value("Window/WindowState").toByteArray()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void loadBookmarks() { |
|
|
|
@ -920,9 +930,10 @@ class Browser: public QMainWindow, protected Ui::Browser { |
|
|
|
|
if (_bookmarkfile.readable()) { |
|
|
|
|
LOG<<"load from file"<<_bookmarkfile.name(); |
|
|
|
|
urls = _bookmarkfile.read(); |
|
|
|
|
} else if (_settings()) { |
|
|
|
|
} else if (qbrowserlib::Settings::instance()()) { |
|
|
|
|
LOG<<"load from settings"; |
|
|
|
|
urls = _settings()->value("Window/Urls").toStringList(); |
|
|
|
|
urls = qbrowserlib::Settings::instance()() |
|
|
|
|
->value("Window/Urls").toStringList(); |
|
|
|
|
} |
|
|
|
|
urls.removeAll(""); |
|
|
|
|
urls.removeDuplicates(); |
|
|
|
@ -1369,7 +1380,7 @@ class Browser: public QMainWindow, protected Ui::Browser { |
|
|
|
|
} |
|
|
|
|
LOG<<"Filename:"<<filename; |
|
|
|
|
QStringList type |
|
|
|
|
(_settings.mimetype |
|
|
|
|
(qbrowserlib::Settings::instance().mimetype |
|
|
|
|
(reply->header(QNetworkRequest::ContentTypeHeader).toString(), |
|
|
|
|
filename)); |
|
|
|
|
} |
|
|
|
@ -1524,7 +1535,6 @@ class Browser: public QMainWindow, protected Ui::Browser { |
|
|
|
|
QPrinter _printer; |
|
|
|
|
SslClientAuthNetworkAccessManager _networkManager; |
|
|
|
|
QSharedPointer<DownloadManager> _downloadManager; |
|
|
|
|
qbrowserlib::Settings _settings; |
|
|
|
|
ErrorLog _errorLog; |
|
|
|
|
LoginCertificate _logincertificate; |
|
|
|
|
gui::Proxy _proxy; |
|
|
|
|