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