save as dialog cleanups, #refs 145; rearrangements for debug; refs #153

master
Marc Wäckerlin 13 years ago
parent 427db75c68
commit 40a926571c
  1. 7
      src/browser.hxx
  2. 122
      src/main.cxx
  3. 34
      src/qbrowserlib/qbrowserlib_de.ts
  4. 34
      src/qbrowserlib/qbrowserlib_en.ts
  5. 34
      src/qbrowserlib/qbrowserlib_fr.ts
  6. 34
      src/qbrowserlib/qbrowserlib_it.ts
  7. 3
      src/qbrowserlib/saveorrun.hxx
  8. 36
      src/qbrowserlib/saveorrun.ui
  9. 683
      src/qbrowserlib/settings.hxx
  10. 1
      src/swissbrowser_de.ts
  11. 1
      src/swissbrowser_en.ts
  12. 1
      src/swissbrowser_fr.ts
  13. 1
      src/swissbrowser_it.ts

@ -65,7 +65,8 @@ class Browser: public QMainWindow, protected Ui::Browser {
Browser(const QString& actlib, const QStringList& urls = QStringList(), Browser(const QString& actlib, const QStringList& urls = QStringList(),
QSettings* settings=0, QSettings* settings=0,
Settings::MimeTypes mimeTypes = Settings::MimeTypes(), qbrowserlib::Settings::MimeTypes mimeTypes =
qbrowserlib::Settings::MimeTypes(),
bool kiosk = false, bool login = true, bool quirks=true, bool kiosk = false, bool login = true, bool quirks=true,
QString bookmarkfile=QString()): QString bookmarkfile=QString()):
_url(0), _find(new ButtonLineEdit), _url(0), _find(new ButtonLineEdit),
@ -583,7 +584,7 @@ class Browser: public QMainWindow, protected Ui::Browser {
void newSettings() { void newSettings() {
_searchEngines->clear(); _searchEngines->clear();
for (Settings::SearchEngines::const_iterator for (qbrowserlib::Settings::SearchEngines::const_iterator
it(_settings.searchEngines().begin()); it(_settings.searchEngines().begin());
it!=_settings.searchEngines().end(); it++) it!=_settings.searchEngines().end(); it++)
if (QFile(":/icons/"+it.key()).exists()) if (QFile(":/icons/"+it.key()).exists())
@ -1499,7 +1500,7 @@ class Browser: public QMainWindow, protected Ui::Browser {
QPrinter _printer; QPrinter _printer;
SslClientAuthNetworkAccessManager _networkManager; SslClientAuthNetworkAccessManager _networkManager;
QSharedPointer<DownloadManager> _downloadManager; QSharedPointer<DownloadManager> _downloadManager;
Settings _settings; qbrowserlib::Settings _settings;
ErrorLog _errorLog; ErrorLog _errorLog;
LoginCertificate _logincertificate; LoginCertificate _logincertificate;
gui::Proxy _proxy; gui::Proxy _proxy;

@ -239,6 +239,60 @@ void notrace(QtMsgType, const char*) {
extern QWEBKIT_EXPORT void qt_drt_overwritePluginDirectories(); extern QWEBKIT_EXPORT void qt_drt_overwritePluginDirectories();
QMap<QString, QString>& env() {
static QStringList l(QProcess::systemEnvironment());
static QMap<QString, QString> env;
if (env.isEmpty())
for (QStringList::iterator it(l.begin()); it!=l.end(); ++it) {
QStringList v(it->split('='));
QString key(*v.begin());
QString value((v.pop_front(), v.join("=")));
env.insert(key, value);
}
return env;
}
QString helptext() {
return QObject::trUtf8
("Usage: %1 [OPTIONS...] [<url> ...]\n"
"Options:\n"
" -h, --help show this help text\n"
" -d, --debug enable verbose debug mode\n"
" -t --tmp path temporary folder for data caching\n"
" -k, --kiosk no url bar\n"
" if you sepcify -k and -s, -k must be first\n"
" -q, --quirks alternate user interface\n"
" -n, --no-settings don't load or store any settings\n"
" --login ask for smartcard password at startup\n"
" -l, --lib <file> path to file libengine_act.so\n"
" -s, --settings <file>\n"
" load settings from <file>\n"
" if you sepcify -k and -s, -k must be first\n"
" -c, --cert <file> load local client certificate from <file>\n"
" -y, --key <file> load local certificate key from <file>\n"
" -m, --mime <mime> <ext> <tool>\n"
" start <tool> for mimetype <mime>\n"
" -b, --bookmarks <file>\n"
" load and save bookmarks from and to <file>\n"
" -e, --edit-bookmarks\n"
" start in bookmark-edition mode\n"
" <url> optional full URL\n"
"Environment:\n"
" LANGUAGE \"de\", \"en\", ... "
"(actual: %5)\n"
" PROXY_TYPE \"http\" or \"socks\" or \"\" "
"(actual: %2)\n"
" PROXY_PORT proxy port number (actual: %3)\n"
" PROXY_HOST proxy host name (actual: %4)\n"
" SWISS_USERAGENT fake user agent (actual: %6)\n"
" QT_PLUGIN_PATH path to plugins dir (actual: %7)\n"
" QTWEBKIT_PLUGIN_PATH path to netscape plugins (actual: %8)\n")
.arg(QFileInfo(QCoreApplication::arguments().at(0)).fileName())
.arg(env()["PROXY_TYPE"]).arg(env()["PROXY_PORT"]).arg(env()["PROXY_HOST"])
.arg(env()["LANGUAGE"]).arg(env()["SWISS_USERAGENT"])
.arg(env()["QT_PLUGIN_PATH"]).arg(env()["QTWEBKIT_PLUGIN_PATH"]);
}
int main(int argv, char** argc) try { int main(int argv, char** argc) try {
// qInstallMsgHandler(notrace); // qInstallMsgHandler(notrace);
// std::cout.rdbuf((new std::stringstream)->rdbuf()); // std::cout.rdbuf((new std::stringstream)->rdbuf());
@ -264,16 +318,6 @@ int main(int argv, char** argc) try {
// certs.push_back(QSslCertificate(SWISSSIGN_PLATINUM_CA_G2)); // certs.push_back(QSslCertificate(SWISSSIGN_PLATINUM_CA_G2));
// sslConfig.setCaCertificates(certs); // sslConfig.setCaCertificates(certs);
//............................................................................ //............................................................................
QStringList l(QProcess::systemEnvironment());
QMap<QString, QString> env;
for (QStringList::iterator it(l.begin()); it!=l.end(); ++it) {
QStringList v(it->split('='));
QString key(*v.begin());
QString value((v.pop_front(), v.join("=")));
env.insert(key, value);
qDebug()<<"env:"<<key<<"="<<value;
}
//............................................................................
QTextCodec* utf8(QTextCodec::codecForName("UTF-8")); QTextCodec* utf8(QTextCodec::codecForName("UTF-8"));
QTextCodec::setCodecForCStrings(utf8); QTextCodec::setCodecForCStrings(utf8);
QTextCodec::setCodecForLocale(utf8); QTextCodec::setCodecForLocale(utf8);
@ -283,23 +327,23 @@ int main(int argv, char** argc) try {
app.setApplicationName(QObject::trUtf8("SwissBrowser", "application name")); app.setApplicationName(QObject::trUtf8("SwissBrowser", "application name"));
app.setApplicationVersion(VERSION); app.setApplicationVersion(VERSION);
QTranslator qtTranslator; QTranslator qtTranslator;
if (env.contains("LANGUAGE")) QLocale::setDefault(env["LANGUAGE"]); if (env().contains("LANGUAGE")) QLocale::setDefault(env()["LANGUAGE"]);
qtTranslator.load(":/language/qt_" + QLocale().name()); qtTranslator.load(":/language/qt_" + QLocale().name());
app.installTranslator(&qtTranslator); app.installTranslator(&qtTranslator);
QTranslator appTranslator; QTranslator appTranslator;
appTranslator.load(":/language/swissbrowser_"+ QLocale().name()); appTranslator.load(":/language/swissbrowser_"+ QLocale().name());
app.installTranslator(&appTranslator); app.installTranslator(&appTranslator);
//............................................................................ //............................................................................
if (env["PROXY_TYPE"]=="http") if (env()["PROXY_TYPE"]=="http")
QNetworkProxy::setApplicationProxy QNetworkProxy::setApplicationProxy
(QNetworkProxy (QNetworkProxy
(QNetworkProxy::HttpProxy, (QNetworkProxy::HttpProxy,
env["PROXY_HOST"], env["PROXY_PORT"].toInt())); env()["PROXY_HOST"], env()["PROXY_PORT"].toInt()));
if (env["PROXY_TYPE"]=="socks") if (env()["PROXY_TYPE"]=="socks")
QNetworkProxy::setApplicationProxy QNetworkProxy::setApplicationProxy
(QNetworkProxy (QNetworkProxy
(QNetworkProxy::Socks5Proxy, (QNetworkProxy::Socks5Proxy,
env["PROXY_HOST"], env["PROXY_PORT"].toInt())); env()["PROXY_HOST"], env()["PROXY_PORT"].toInt()));
else else
QNetworkProxyFactory::setUseSystemConfiguration(true); QNetworkProxyFactory::setUseSystemConfiguration(true);
qDebug()<<"***************************************************************"; qDebug()<<"***************************************************************";
@ -332,7 +376,7 @@ int main(int argv, char** argc) try {
bool silent(false); bool silent(false);
bool quirks(false); bool quirks(false);
bool login(false); bool login(false);
Settings::MimeTypes mimetypes; qbrowserlib::Settings::MimeTypes mimetypes;
QString bookmarks; QString bookmarks;
bool editbookmarks(false); bool editbookmarks(false);
QStringList args(app.arguments()); QStringList args(app.arguments());
@ -340,44 +384,7 @@ int main(int argv, char** argc) try {
(std::auto_ptr<QSettings>(new QSettings("SwissSign", "SwissBrowser"))); (std::auto_ptr<QSettings>(new QSettings("SwissSign", "SwissBrowser")));
for (QStringList::iterator it(args.begin()); ++it!=args.end();) for (QStringList::iterator it(args.begin()); ++it!=args.end();)
if (*it=="-h" || *it=="--help" || *it=="-help" || *it=="/?") { if (*it=="-h" || *it=="--help" || *it=="-help" || *it=="/?") {
std::cout<<QObject::trUtf8 std::cout<<helptext().toStdString()<<std::endl;
("Usage: %1 [OPTIONS...] [<url> ...]\n"
"Options:\n"
" -h, --help show this help text\n"
" -t --tmp path temporary folder for data caching\n"
" -k, --kiosk no url bar\n"
" if you sepcify -k and -s, -k must be first\n"
" -q, --quirks alternate user interface\n"
" -n, --no-settings don't load or store any settings\n"
" --login ask for smartcard password at startup\n"
" -l, --lib <file> path to file libengine_act.so\n"
" -s, --settings <file>\n"
" load settings from <file>\n"
" if you sepcify -k and -s, -k must be first\n"
" -c, --cert <file> load local client certificate from <file>\n"
" -y, --key <file> load local certificate key from <file>\n"
" -m, --mime <mime> <ext> <tool>\n"
" start <tool> for mimetype <mime>\n"
" -b, --bookmarks <file>\n"
" load and save bookmarks from and to <file>\n"
" -e, --edit-bookmarks\n"
" start in bookmark-edition mode\n"
" <url> optional full URL\n"
"Environment:\n"
" LANGUAGE \"de\", \"en\", ... "
"(actual: %5)\n"
" PROXY_TYPE \"http\" or \"socks\" or \"\" "
"(actual: %2)\n"
" PROXY_PORT proxy port number (actual: %3)\n"
" PROXY_HOST proxy host name (actual: %4)\n"
" SWISS_USERAGENT fake user agent (actual: %6)\n"
" QT_PLUGIN_PATH path to plugins dir (actual: %7)\n"
" QTWEBKIT_PLUGIN_PATH path to netscape plugins (actual: %8)\n")
.arg(QFileInfo(argc[0]).fileName())
.arg(env["PROXY_TYPE"]).arg(env["PROXY_PORT"]).arg(env["PROXY_HOST"])
.arg(env["LANGUAGE"]).arg(env["SWISS_USERAGENT"])
.toStdString()
<<std::endl;
return 0; return 0;
} else if ((*it=="-t" || *it=="--tmp") && ++it!=args.end()) { } else if ((*it=="-t" || *it=="--tmp") && ++it!=args.end()) {
TMP=*it; TMP=*it;
@ -441,8 +448,8 @@ int main(int argv, char** argc) try {
//............................................................................ //............................................................................
std::cerr<<"LIBRARY PATHES:\n"<<app.libraryPaths().join("\n").toStdString() std::cerr<<"LIBRARY PATHES:\n"<<app.libraryPaths().join("\n").toStdString()
<<std::endl; <<std::endl;
if (env.contains("QT_PLUGIN_PATH")) { if (env().contains("QT_PLUGIN_PATH")) {
foreach (QString path, env["QT_PLUGIN_PATH"].split(":")) { foreach (QString path, env()["QT_PLUGIN_PATH"].split(":")) {
std::cerr<<"**** Setting: PLUGIN-PATH to "<<path.toStdString()<<std::endl; std::cerr<<"**** Setting: PLUGIN-PATH to "<<path.toStdString()<<std::endl;
app.addLibraryPath(path); app.addLibraryPath(path);
} }
@ -450,7 +457,8 @@ int main(int argv, char** argc) try {
std::cerr<<"**** Error: PLUGIN-PATH is not defined"<<std::endl; std::cerr<<"**** Error: PLUGIN-PATH is not defined"<<std::endl;
abort(); abort();
} }
if (env.contains("QTWEBKIT_PLUGIN_PATH")) qt_drt_overwritePluginDirectories(); if (env().contains("QTWEBKIT_PLUGIN_PATH"))
qt_drt_overwritePluginDirectories();
Browser browser(actlib, urls, settings.get(), mimetypes, silent, Browser browser(actlib, urls, settings.get(), mimetypes, silent,
login, quirks, bookmarks); login, quirks, bookmarks);
if (editbookmarks) browser.on_actionEditBookmarks_triggered(); if (editbookmarks) browser.on_actionEditBookmarks_triggered();

@ -16,7 +16,7 @@
</message> </message>
<message> <message>
<location filename="saveorrun.ui" line="52"/> <location filename="saveorrun.ui" line="52"/>
<location filename="saveorrun.ui" line="99"/> <location filename="saveorrun.ui" line="109"/>
<source>browse ...</source> <source>browse ...</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -36,13 +36,13 @@
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="saveorrun.ui" line="106"/> <location filename="saveorrun.ui" line="83"/>
<source>Run</source> <source>remember tool for this type</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="saveorrun.ui" line="113"/> <location filename="saveorrun.ui" line="116"/>
<source>remember tool for this type</source> <source>Run</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
@ -523,12 +523,12 @@ p, li { white-space: pre-wrap; }
<context> <context>
<name>qbrowserlib::SaveOrRun</name> <name>qbrowserlib::SaveOrRun</name>
<message> <message>
<location filename="saveorrun.hxx" line="130"/> <location filename="saveorrun.hxx" line="132"/>
<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="131"/> <location filename="saveorrun.hxx" line="133"/>
<source>File already exists: <source>File already exists:
%1 %1
@ -537,12 +537,12 @@ Overwrite?</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="saveorrun.hxx" line="143"/> <location filename="saveorrun.hxx" line="145"/>
<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="144"/> <location filename="saveorrun.hxx" line="146"/>
<source>Not an executable Program: <source>Not an executable Program:
%1 %1
@ -551,26 +551,34 @@ Specify full path to executable program</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="saveorrun.hxx" line="156"/> <location filename="saveorrun.hxx" line="158"/>
<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="169"/> <location filename="saveorrun.hxx" line="171"/>
<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="181"/> <location filename="saveorrun.hxx" line="183"/>
<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="183"/> <location filename="saveorrun.hxx" line="185"/>
<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>
</message> </message>
</context> </context>
<context>
<name>qbrowserlib::SaveOrRunDialog</name>
<message>
<location filename="saveorrun.hxx" line="237"/>
<source>Unknown File Type</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS> </TS>

@ -16,7 +16,7 @@
</message> </message>
<message> <message>
<location filename="saveorrun.ui" line="52"/> <location filename="saveorrun.ui" line="52"/>
<location filename="saveorrun.ui" line="99"/> <location filename="saveorrun.ui" line="109"/>
<source>browse ...</source> <source>browse ...</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -36,13 +36,13 @@
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="saveorrun.ui" line="106"/> <location filename="saveorrun.ui" line="83"/>
<source>Run</source> <source>remember tool for this type</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="saveorrun.ui" line="113"/> <location filename="saveorrun.ui" line="116"/>
<source>remember tool for this type</source> <source>Run</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
@ -523,12 +523,12 @@ p, li { white-space: pre-wrap; }
<context> <context>
<name>qbrowserlib::SaveOrRun</name> <name>qbrowserlib::SaveOrRun</name>
<message> <message>
<location filename="saveorrun.hxx" line="130"/> <location filename="saveorrun.hxx" line="132"/>
<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="131"/> <location filename="saveorrun.hxx" line="133"/>
<source>File already exists: <source>File already exists:
%1 %1
@ -537,12 +537,12 @@ Overwrite?</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="saveorrun.hxx" line="143"/> <location filename="saveorrun.hxx" line="145"/>
<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="144"/> <location filename="saveorrun.hxx" line="146"/>
<source>Not an executable Program: <source>Not an executable Program:
%1 %1
@ -551,26 +551,34 @@ Specify full path to executable program</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="saveorrun.hxx" line="156"/> <location filename="saveorrun.hxx" line="158"/>
<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="169"/> <location filename="saveorrun.hxx" line="171"/>
<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="181"/> <location filename="saveorrun.hxx" line="183"/>
<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="183"/> <location filename="saveorrun.hxx" line="185"/>
<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>
</message> </message>
</context> </context>
<context>
<name>qbrowserlib::SaveOrRunDialog</name>
<message>
<location filename="saveorrun.hxx" line="237"/>
<source>Unknown File Type</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS> </TS>

@ -16,7 +16,7 @@
</message> </message>
<message> <message>
<location filename="saveorrun.ui" line="52"/> <location filename="saveorrun.ui" line="52"/>
<location filename="saveorrun.ui" line="99"/> <location filename="saveorrun.ui" line="109"/>
<source>browse ...</source> <source>browse ...</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -36,13 +36,13 @@
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="saveorrun.ui" line="106"/> <location filename="saveorrun.ui" line="83"/>
<source>Run</source> <source>remember tool for this type</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="saveorrun.ui" line="113"/> <location filename="saveorrun.ui" line="116"/>
<source>remember tool for this type</source> <source>Run</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
@ -523,12 +523,12 @@ p, li { white-space: pre-wrap; }
<context> <context>
<name>qbrowserlib::SaveOrRun</name> <name>qbrowserlib::SaveOrRun</name>
<message> <message>
<location filename="saveorrun.hxx" line="130"/> <location filename="saveorrun.hxx" line="132"/>
<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="131"/> <location filename="saveorrun.hxx" line="133"/>
<source>File already exists: <source>File already exists:
%1 %1
@ -537,12 +537,12 @@ Overwrite?</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="saveorrun.hxx" line="143"/> <location filename="saveorrun.hxx" line="145"/>
<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="144"/> <location filename="saveorrun.hxx" line="146"/>
<source>Not an executable Program: <source>Not an executable Program:
%1 %1
@ -551,26 +551,34 @@ Specify full path to executable program</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="saveorrun.hxx" line="156"/> <location filename="saveorrun.hxx" line="158"/>
<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="169"/> <location filename="saveorrun.hxx" line="171"/>
<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="181"/> <location filename="saveorrun.hxx" line="183"/>
<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="183"/> <location filename="saveorrun.hxx" line="185"/>
<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>
</message> </message>
</context> </context>
<context>
<name>qbrowserlib::SaveOrRunDialog</name>
<message>
<location filename="saveorrun.hxx" line="237"/>
<source>Unknown File Type</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS> </TS>

@ -16,7 +16,7 @@
</message> </message>
<message> <message>
<location filename="saveorrun.ui" line="52"/> <location filename="saveorrun.ui" line="52"/>
<location filename="saveorrun.ui" line="99"/> <location filename="saveorrun.ui" line="109"/>
<source>browse ...</source> <source>browse ...</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -36,13 +36,13 @@
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="saveorrun.ui" line="106"/> <location filename="saveorrun.ui" line="83"/>
<source>Run</source> <source>remember tool for this type</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="saveorrun.ui" line="113"/> <location filename="saveorrun.ui" line="116"/>
<source>remember tool for this type</source> <source>Run</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
@ -523,12 +523,12 @@ p, li { white-space: pre-wrap; }
<context> <context>
<name>qbrowserlib::SaveOrRun</name> <name>qbrowserlib::SaveOrRun</name>
<message> <message>
<location filename="saveorrun.hxx" line="130"/> <location filename="saveorrun.hxx" line="132"/>
<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="131"/> <location filename="saveorrun.hxx" line="133"/>
<source>File already exists: <source>File already exists:
%1 %1
@ -537,12 +537,12 @@ Overwrite?</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="saveorrun.hxx" line="143"/> <location filename="saveorrun.hxx" line="145"/>
<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="144"/> <location filename="saveorrun.hxx" line="146"/>
<source>Not an executable Program: <source>Not an executable Program:
%1 %1
@ -551,26 +551,34 @@ Specify full path to executable program</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="saveorrun.hxx" line="156"/> <location filename="saveorrun.hxx" line="158"/>
<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="169"/> <location filename="saveorrun.hxx" line="171"/>
<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="181"/> <location filename="saveorrun.hxx" line="183"/>
<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="183"/> <location filename="saveorrun.hxx" line="185"/>
<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>
</message> </message>
</context> </context>
<context>
<name>qbrowserlib::SaveOrRunDialog</name>
<message>
<location filename="saveorrun.hxx" line="237"/>
<source>Unknown File Type</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS> </TS>

@ -47,6 +47,8 @@ namespace qbrowserlib {
LOG; LOG;
setupUi(this); setupUi(this);
QString obj(remoteFilename()); QString obj(remoteFilename());
_rememberPath->setVisible(false);
_rememberTool->setVisible(false);
_program->setText(QCoreApplication::applicationDirPath() _program->setText(QCoreApplication::applicationDirPath()
+QDir::separator()); +QDir::separator());
_object->setText(obj); _object->setText(obj);
@ -232,6 +234,7 @@ namespace qbrowserlib {
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, executor, type, src)) {
LOG; LOG;
setWindowTitle(tr("Unknown File Type"));
QVBoxLayout* l(new QVBoxLayout(this)); QVBoxLayout* l(new QVBoxLayout(this));
l->addWidget(_sor); l->addWidget(_sor);
l->addWidget(_buttons = new QDialogButtonBox(QDialogButtonBox::Cancel)); l->addWidget(_buttons = new QDialogButtonBox(QDialogButtonBox::Cancel));

@ -77,6 +77,16 @@
<string>Open in External Application</string> <string>Open in External Application</string>
</attribute> </attribute>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="1" column="0" colspan="2">
<widget class="QCheckBox" name="_rememberTool">
<property name="text">
<string>remember tool for this type</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLineEdit" name="_program"> <widget class="QLineEdit" name="_program">
<property name="enabled"> <property name="enabled">
@ -107,16 +117,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0" colspan="2">
<widget class="QCheckBox" name="_rememberTool">
<property name="text">
<string>remember tool for this type</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="tab_3"> <widget class="QWidget" name="tab_3">
@ -279,12 +279,12 @@
<slot>click()</slot> <slot>click()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>371</x> <x>320</x>
<y>113</y> <y>78</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>94</x> <x>430</x>
<y>126</y> <y>108</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
@ -295,12 +295,12 @@
<slot>click()</slot> <slot>click()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>371</x> <x>320</x>
<y>207</y> <y>78</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>94</x> <x>430</x>
<y>220</y> <y>108</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>

@ -22,350 +22,357 @@
#define LOG qDebug()<<__PRETTY_FUNCTION__ #define LOG qDebug()<<__PRETTY_FUNCTION__
#endif #endif
class Settings: public QDialog, protected Ui::Settings { namespace qbrowserlib {
Q_OBJECT; class Settings: public QDialog, protected Ui::Settings {
public: Q_OBJECT;
typedef QMap<QString, QVariant> MimeTypes; public:
typedef QMap<QString, QVariant> SearchEngines;
typedef QMap<QString, QVariant> MimeTypes;
Q_SIGNALS: typedef QMap<QString, QVariant> SearchEngines;
void newSettings(); Q_SIGNALS:
public: void newSettings();
Settings(MimeTypes mimetypes, QWidget* p=0, public:
QSettings* settings=0, bool autoWrite=true):
QDialog(p), _settings(settings), Settings(MimeTypes mimetypes, QWidget* p=0,
_autoWrite(autoWrite), _mimetypes(mimetypes) { QSettings* settings=0, bool autoWrite=true):
QDialog(p), _settings(settings),
setupUi(this); _autoWrite(autoWrite), _mimetypes(mimetypes) {
// Web Attributes setupUi(this);
_attributes[QWebSettings::AutoLoadImages] =
_settingAutoLoadImages; // Web Attributes
_attributes[QWebSettings::DnsPrefetchEnabled] = _attributes[QWebSettings::AutoLoadImages] =
_settingDnsPrefetchEnabled; _settingAutoLoadImages;
_attributes[QWebSettings::JavascriptEnabled] = _attributes[QWebSettings::DnsPrefetchEnabled] =
_settingJavascriptEnabled; _settingDnsPrefetchEnabled;
_attributes[QWebSettings::JavaEnabled] = _attributes[QWebSettings::JavascriptEnabled] =
_settingJavaEnabled; _settingJavascriptEnabled;
_attributes[QWebSettings::PluginsEnabled] = _attributes[QWebSettings::JavaEnabled] =
_settingPluginsEnabled; _settingJavaEnabled;
_attributes[QWebSettings::PrivateBrowsingEnabled] = _attributes[QWebSettings::PluginsEnabled] =
_settingPrivateBrowsingEnabled; _settingPluginsEnabled;
_attributes[QWebSettings::JavascriptCanOpenWindows] = _attributes[QWebSettings::PrivateBrowsingEnabled] =
_settingJavascriptCanOpenWindows; _settingPrivateBrowsingEnabled;
_attributes[QWebSettings::JavascriptCanAccessClipboard] = _attributes[QWebSettings::JavascriptCanOpenWindows] =
_settingJavascriptCanAccessClipboard; _settingJavascriptCanOpenWindows;
_attributes[QWebSettings::DeveloperExtrasEnabled] = _attributes[QWebSettings::JavascriptCanAccessClipboard] =
_settingDeveloperExtrasEnabled; _settingJavascriptCanAccessClipboard;
_attributes[QWebSettings::SpatialNavigationEnabled] = _attributes[QWebSettings::DeveloperExtrasEnabled] =
_settingSpatialNavigationEnabled; _settingDeveloperExtrasEnabled;
_attributes[QWebSettings::LinksIncludedInFocusChain] = _attributes[QWebSettings::SpatialNavigationEnabled] =
_settingLinksIncludedInFocusChain; _settingSpatialNavigationEnabled;
_attributes[QWebSettings::ZoomTextOnly] = _attributes[QWebSettings::LinksIncludedInFocusChain] =
_settingZoomTextOnly; _settingLinksIncludedInFocusChain;
_attributes[QWebSettings::PrintElementBackgrounds] = _attributes[QWebSettings::ZoomTextOnly] =
_settingPrintElementBackgrounds; _settingZoomTextOnly;
_attributes[QWebSettings::OfflineStorageDatabaseEnabled] = _attributes[QWebSettings::PrintElementBackgrounds] =
_settingOfflineStorageDatabaseEnabled; _settingPrintElementBackgrounds;
_attributes[QWebSettings::OfflineWebApplicationCacheEnabled] = _attributes[QWebSettings::OfflineStorageDatabaseEnabled] =
_settingOfflineWebApplicationCacheEnabled; _settingOfflineStorageDatabaseEnabled;
_attributes[QWebSettings::LocalStorageEnabled] = _attributes[QWebSettings::OfflineWebApplicationCacheEnabled] =
_settingLocalStorageEnabled; _settingOfflineWebApplicationCacheEnabled;
_attributes[QWebSettings::LocalContentCanAccessRemoteUrls] = _attributes[QWebSettings::LocalStorageEnabled] =
_settingLocalContentCanAccessRemoteUrls; _settingLocalStorageEnabled;
_attributes[QWebSettings::LocalContentCanAccessFileUrls] = _attributes[QWebSettings::LocalContentCanAccessRemoteUrls] =
_settingLocalContentCanAccessFileUrls; _settingLocalContentCanAccessRemoteUrls;
// not in qt 4.7.0 (mac) _attributes[QWebSettings::LocalContentCanAccessFileUrls] =
// _attributes[QWebSettings::XSSAuditingEnabled] = _settingLocalContentCanAccessFileUrls;
// _settingXSSAuditingEnabled; // not in qt 4.7.0 (mac)
_attributes[QWebSettings::AcceleratedCompositingEnabled] = // _attributes[QWebSettings::XSSAuditingEnabled] =
_settingAcceleratedCompositingEnabled; // _settingXSSAuditingEnabled;
_attributes[QWebSettings::TiledBackingStoreEnabled] = _attributes[QWebSettings::AcceleratedCompositingEnabled] =
_settingTiledBackingStoreEnabled; _settingAcceleratedCompositingEnabled;
_attributes[QWebSettings::FrameFlatteningEnabled] = _attributes[QWebSettings::TiledBackingStoreEnabled] =
_settingFrameFlatteningEnabled; _settingTiledBackingStoreEnabled;
// not in qt 4.7.0 (mac) _attributes[QWebSettings::FrameFlatteningEnabled] =
// _attributes[QWebSettings::SiteSpecificQuirksEnabled] = _settingFrameFlatteningEnabled;
// _settingSiteSpecificQuirksEnabled; // not in qt 4.7.0 (mac)
// _attributes[QWebSettings::SiteSpecificQuirksEnabled] =
// CheckBoxes // _settingSiteSpecificQuirksEnabled;
_checkboxes["SaveWindowState"] =
std::make_pair(_saveWindowState, _saveWindowState->isChecked()); // CheckBoxes
_checkboxes["CloseApps"] = _checkboxes["SaveWindowState"] =
std::make_pair(_closeApps, _closeApps->isChecked()); std::make_pair(_saveWindowState, _saveWindowState->isChecked());
_checkboxes["CloseApps"] =
load(!_mimetypes.size()); std::make_pair(_closeApps, _closeApps->isChecked());
on__buttons_rejected();
} load(!_mimetypes.size());
on__buttons_rejected();
void setSettings(QSettings* settings) {
_settings = settings;
}
QSettings* operator()() {
return _settings;
}
void setAttribute(QWebSettings::WebAttribute attr, bool state) {
//LOG;
QWebSettings::globalSettings()->setAttribute(attr, state);
_attributes[attr]->setChecked(state);
}
bool flag(const QString& name) {
assert(_checkboxes.find(name)!=_checkboxes.end());
return _checkboxes[name].second;
}
const QString& text(const QString& name) {
assert(_lineedits.find(name)!=_lineedits.end());
return _lineedits[name].second;
}
const MimeTypes& mimetypes() const {
return _mimetypes;
}
QStringList mimetype(QString mimetype, QString filename) const {
Settings::MimeTypes::const_iterator
it(_mimetypes.find(mimetype.split(';')[0]));
if (it!=_mimetypes.end()) return it.value().toStringList();
for (it=_mimetypes.begin(); it!=_mimetypes.end(); ++it)
if (filename.endsWith("."+it.value().toStringList().at(0)))
return it.value().toStringList();
return QStringList();
}
QString& replaceSearchEngine(QString& url) {
LOG;
int len(url.indexOf(QRegExp("[ :]")));
if (len<=0) return url;
QString scheme(url.left(len));
LOG<<"scheme:"<<scheme;
if (!_searchEngines.contains(scheme)) return url;
QString query(url.right(url.size()-len-1));
LOG<<"query:"<<query;
url = QString(_searchEngines[scheme].toString())
.arg(query).arg(QLocale::system().name().left(2));
return url;
}
const SearchEngines& searchEngines() const {
return _searchEngines;
}
bool save() {
LOG;
if (!_settings || !_settings->isWritable()) return false;
// Attributes
for (Attributes::iterator it(_attributes.begin());
it!=_attributes.end(); ++it)
_settings->setValue
(QString("QWebSettings/%1").arg(it->first),
QWebSettings::globalSettings()->testAttribute(it->first));
// CheckBoxes
for (CheckBoxes::iterator it(_checkboxes.begin());
it!=_checkboxes.end(); ++it)
_settings->setValue
(QString("Flags/%1").arg(it->first), it->second.second);
// LineEdits
for (LineEdits::iterator it(_lineedits.begin());
it!=_lineedits.end(); ++it)
_settings->setValue
(QString("Texts/%1").arg(it->first), it->second.second);
// MimeTypes
_settings->setValue("QWebSettings/MimeTypes", _mimetypes);
// Search Engines
_settings->setValue("QWebSettings/SearchEngines", _searchEngines);
return true;
}
bool load(bool overwriteMimeTypes=true) {
LOG;
if (!_settings) return false;
// Attributes
for (Attributes::iterator it(_attributes.begin());
it!=_attributes.end(); ++it) {
QVariant val
(_settings->value
(QString("QWebSettings/%1").arg(it->first),
QWebSettings::globalSettings()->testAttribute(it->first)));
if (val.isValid() && val.canConvert(QVariant::Bool))
setAttribute(it->first, val.toBool());
} }
// CheckBoxes
for (CheckBoxes::iterator it(_checkboxes.begin()); static bool DEBUG;
it!=_checkboxes.end(); ++it) {
QVariant val void setSettings(QSettings* settings) {
(_settings->value _settings = settings;
(QString("Flags/%1").arg(it->first), it->second.second)); }
if (val.isValid() && val.canConvert(QVariant::Bool)) {
it->second.first->setChecked(val.toBool()); QSettings* operator()() {
it->second.second = val.toBool(); return _settings;
}
void setAttribute(QWebSettings::WebAttribute attr, bool state) {
//LOG;
QWebSettings::globalSettings()->setAttribute(attr, state);
_attributes[attr]->setChecked(state);
}
bool flag(const QString& name) {
assert(_checkboxes.find(name)!=_checkboxes.end());
return _checkboxes[name].second;
}
const QString& text(const QString& name) {
assert(_lineedits.find(name)!=_lineedits.end());
return _lineedits[name].second;
}
const MimeTypes& mimetypes() const {
return _mimetypes;
}
QStringList mimetype(QString mimetype, QString filename) const {
Settings::MimeTypes::const_iterator
it(_mimetypes.find(mimetype.split(';')[0]));
if (it!=_mimetypes.end()) return it.value().toStringList();
for (it=_mimetypes.begin(); it!=_mimetypes.end(); ++it)
if (filename.endsWith("."+it.value().toStringList().at(0)))
return it.value().toStringList();
return QStringList();
}
QString& replaceSearchEngine(QString& url) {
LOG;
int len(url.indexOf(QRegExp("[ :]")));
if (len<=0) return url;
QString scheme(url.left(len));
LOG<<"scheme:"<<scheme;
if (!_searchEngines.contains(scheme)) return url;
QString query(url.right(url.size()-len-1));
LOG<<"query:"<<query;
url = QString(_searchEngines[scheme].toString())
.arg(query).arg(QLocale::system().name().left(2));
return url;
}
const SearchEngines& searchEngines() const {
return _searchEngines;
}
bool save() {
LOG;
if (!_settings || !_settings->isWritable()) return false;
// Attributes
for (Attributes::iterator it(_attributes.begin());
it!=_attributes.end(); ++it)
_settings->setValue
(QString("QWebSettings/%1").arg(it->first),
QWebSettings::globalSettings()->testAttribute(it->first));
// CheckBoxes
for (CheckBoxes::iterator it(_checkboxes.begin());
it!=_checkboxes.end(); ++it)
_settings->setValue
(QString("Flags/%1").arg(it->first), it->second.second);
// LineEdits
for (LineEdits::iterator it(_lineedits.begin());
it!=_lineedits.end(); ++it)
_settings->setValue
(QString("Texts/%1").arg(it->first), it->second.second);
// MimeTypes
_settings->setValue("QWebSettings/MimeTypes", _mimetypes);
// Search Engines
_settings->setValue("QWebSettings/SearchEngines", _searchEngines);
return true;
}
bool load(bool overwriteMimeTypes=true) {
LOG;
if (!_settings) return false;
// Attributes
for (Attributes::iterator it(_attributes.begin());
it!=_attributes.end(); ++it) {
QVariant val
(_settings->value
(QString("QWebSettings/%1").arg(it->first),
QWebSettings::globalSettings()->testAttribute(it->first)));
if (val.isValid() && val.canConvert(QVariant::Bool))
setAttribute(it->first, val.toBool());
}
// CheckBoxes
for (CheckBoxes::iterator it(_checkboxes.begin());
it!=_checkboxes.end(); ++it) {
QVariant val
(_settings->value
(QString("Flags/%1").arg(it->first), it->second.second));
if (val.isValid() && val.canConvert(QVariant::Bool)) {
it->second.first->setChecked(val.toBool());
it->second.second = val.toBool();
}
}
// LineEdits
for (LineEdits::iterator it(_lineedits.begin());
it!=_lineedits.end(); ++it) {
QVariant val
(_settings->value
(QString("Texts/%1").arg(it->first), it->second.second));
if (val.isValid() && val.canConvert(QVariant::String)) {
it->second.first->setText(val.toString());
it->second.second = val.toString();
}
} }
// MimeTypes
if (overwriteMimeTypes) {
QVariant val(_settings->value("QWebSettings/MimeTypes"));
if (val.isValid() && val.canConvert(QVariant::Map))
_mimetypes = val.toMap();
}
// SearchEngines
QVariant val(_settings->value("QWebSettings/SearchEngines"));
if (val.isValid() && val.canConvert(QVariant::Map))
_searchEngines = val.toMap();
newSettings();
return true;
} }
// LineEdits
for (LineEdits::iterator it(_lineedits.begin()); private Q_SLOTS:
it!=_lineedits.end(); ++it) {
QVariant val void on__buttons_accepted() {
(_settings->value LOG;
(QString("Texts/%1").arg(it->first), it->second.second)); // Attributes
if (val.isValid() && val.canConvert(QVariant::String)) { for (Attributes::iterator it(_attributes.begin());
it->second.first->setText(val.toString()); it!=_attributes.end(); ++it)
it->second.second = val.toString(); QWebSettings::globalSettings()
->setAttribute(it->first, it->second->isChecked());
// CheckBoxes
for (CheckBoxes::iterator it(_checkboxes.begin());
it!=_checkboxes.end(); ++it)
it->second.second = it->second.first->isChecked();
// LineEdits
for (LineEdits::iterator it(_lineedits.begin());
it!=_lineedits.end(); ++it)
it->second.second = it->second.first->text();
// MimeTypes
_mimetypes.clear();
for (int row(_mimeTypeTable->rowCount()); row--;)
_mimetypes[_mimeTypeTable->item(row, 0)->text()] =
QStringList()
<<_mimeTypeTable->item(row, 1)->text()
<<_mimeTypeTable->item(row, 2)->text();
// SearchEngines
_searchEngines.clear();
for (int row(_searchEngineTable->rowCount()); row--;)
_searchEngines[_searchEngineTable->item(row, 0)->text()] =
_searchEngineTable->item(row, 1)->text();
// Save
if (_autoWrite) save();
newSettings();
}
void on__buttons_rejected() {
LOG;
// Attributes
for (Attributes::iterator it(_attributes.begin());
it!=_attributes.end(); ++it)
it->second->setChecked
(QWebSettings::globalSettings()->testAttribute(it->first));
// CheckBoxes
for (CheckBoxes::iterator it(_checkboxes.begin());
it!=_checkboxes.end(); ++it)
it->second.first->setChecked(it->second.second);
// LineEdits
for (LineEdits::iterator it(_lineedits.begin());
it!=_lineedits.end(); ++it)
it->second.first->setText(it->second.second);
// MimeTypes
_mimeTypeTable->setRowCount(_mimetypes.size());
_mimeTypeTable->verticalHeader()->show();
_mimeTypeTable->horizontalHeader()->show();
_mimeTypeTable->horizontalHeader()->setStretchLastSection(true);
int row(0);
for (MimeTypes::iterator it(_mimetypes.begin());
it!=_mimetypes.end(); ++it, ++row) {
LOG<<"MimeType:"<<it.key()<<it.value().toStringList();
_mimeTypeTable->setItem
(row, 0, new QTableWidgetItem(it.key()));
_mimeTypeTable->setItem
(row, 1, new QTableWidgetItem(it.value().toStringList().at(0)));
_mimeTypeTable->setItem
(row, 2, new QTableWidgetItem(it.value().toStringList().at(1)));
}
// SearchEngines
_searchEngineTable->setRowCount(_searchEngines.size());
_searchEngineTable->verticalHeader()->show();
_searchEngineTable->horizontalHeader()->show();
_searchEngineTable->horizontalHeader()->setStretchLastSection(true);
row = 0;
for (MimeTypes::iterator it(_searchEngines.begin());
it!=_searchEngines.end(); ++it, ++row) {
LOG<<"SearchEngine:"<<it.key()<<it.value().toString();
_searchEngineTable->setItem
(row, 0, new QTableWidgetItem(it.key()));
_searchEngineTable->setItem
(row, 1, new QTableWidgetItem(it.value().toString()));
} }
} }
// MimeTypes
if (overwriteMimeTypes) { void on__addMimeType_pressed() {
QVariant val(_settings->value("QWebSettings/MimeTypes")); _mimeTypeTable->setRowCount(_mimeTypeTable->rowCount()+1);
if (val.isValid() && val.canConvert(QVariant::Map)) _mimeTypeTable->setItem(_mimeTypeTable->rowCount()-1, 0,
_mimetypes = val.toMap(); new QTableWidgetItem);
_mimeTypeTable->setItem(_mimeTypeTable->rowCount()-1, 1,
new QTableWidgetItem);
_mimeTypeTable->setItem(_mimeTypeTable->rowCount()-1, 2,
new QTableWidgetItem);
} }
// SearchEngines
QVariant val(_settings->value("QWebSettings/SearchEngines")); void on__removeMimeType_pressed() {
if (val.isValid() && val.canConvert(QVariant::Map)) QList<QTableWidgetSelectionRange> ranges
_searchEngines = val.toMap(); (_mimeTypeTable->selectedRanges());
newSettings(); if (ranges.isEmpty()) return;
return true; for (int begin(ranges.at(0).topRow()), count(ranges.at(0).rowCount());
} count; --count)
_mimeTypeTable->removeRow(begin);
private Q_SLOTS:
void on__buttons_accepted() {
LOG;
// Attributes
for (Attributes::iterator it(_attributes.begin());
it!=_attributes.end(); ++it)
QWebSettings::globalSettings()
->setAttribute(it->first, it->second->isChecked());
// CheckBoxes
for (CheckBoxes::iterator it(_checkboxes.begin());
it!=_checkboxes.end(); ++it)
it->second.second = it->second.first->isChecked();
// LineEdits
for (LineEdits::iterator it(_lineedits.begin());
it!=_lineedits.end(); ++it)
it->second.second = it->second.first->text();
// MimeTypes
_mimetypes.clear();
for (int row(_mimeTypeTable->rowCount()); row--;)
_mimetypes[_mimeTypeTable->item(row, 0)->text()] =
QStringList()
<<_mimeTypeTable->item(row, 1)->text()
<<_mimeTypeTable->item(row, 2)->text();
// SearchEngines
_searchEngines.clear();
for (int row(_searchEngineTable->rowCount()); row--;)
_searchEngines[_searchEngineTable->item(row, 0)->text()] =
_searchEngineTable->item(row, 1)->text();
// Save
if (_autoWrite) save();
newSettings();
}
void on__buttons_rejected() {
LOG;
// Attributes
for (Attributes::iterator it(_attributes.begin());
it!=_attributes.end(); ++it)
it->second->setChecked
(QWebSettings::globalSettings()->testAttribute(it->first));
// CheckBoxes
for (CheckBoxes::iterator it(_checkboxes.begin());
it!=_checkboxes.end(); ++it)
it->second.first->setChecked(it->second.second);
// LineEdits
for (LineEdits::iterator it(_lineedits.begin());
it!=_lineedits.end(); ++it)
it->second.first->setText(it->second.second);
// MimeTypes
_mimeTypeTable->setRowCount(_mimetypes.size());
_mimeTypeTable->verticalHeader()->show();
_mimeTypeTable->horizontalHeader()->show();
_mimeTypeTable->horizontalHeader()->setStretchLastSection(true);
int row(0);
for (MimeTypes::iterator it(_mimetypes.begin());
it!=_mimetypes.end(); ++it, ++row) {
LOG<<"MimeType:"<<it.key()<<it.value().toStringList();
_mimeTypeTable->setItem
(row, 0, new QTableWidgetItem(it.key()));
_mimeTypeTable->setItem
(row, 1, new QTableWidgetItem(it.value().toStringList().at(0)));
_mimeTypeTable->setItem
(row, 2, new QTableWidgetItem(it.value().toStringList().at(1)));
} }
// SearchEngines
_searchEngineTable->setRowCount(_searchEngines.size()); void on__addSearchEngine_pressed() {
_searchEngineTable->verticalHeader()->show(); _searchEngineTable->setRowCount(_searchEngineTable->rowCount()+1);
_searchEngineTable->horizontalHeader()->show(); _searchEngineTable->setItem(_searchEngineTable->rowCount()-1, 0,
_searchEngineTable->horizontalHeader()->setStretchLastSection(true); new QTableWidgetItem);
row = 0; _searchEngineTable->setItem(_searchEngineTable->rowCount()-1, 1,
for (MimeTypes::iterator it(_searchEngines.begin()); new QTableWidgetItem);
it!=_searchEngines.end(); ++it, ++row) { _searchEngineTable->setItem(_searchEngineTable->rowCount()-1, 2,
LOG<<"SearchEngine:"<<it.key()<<it.value().toString(); new QTableWidgetItem);
_searchEngineTable->setItem }
(row, 0, new QTableWidgetItem(it.key()));
_searchEngineTable->setItem void on__removeSearchEngine_pressed() {
(row, 1, new QTableWidgetItem(it.value().toString())); QList<QTableWidgetSelectionRange> ranges
(_searchEngineTable->selectedRanges());
if (ranges.isEmpty()) return;
for (int begin(ranges.at(0).topRow()), count(ranges.at(0).rowCount());
count; --count)
_searchEngineTable->removeRow(begin);
} }
}
private:
void on__addMimeType_pressed() {
_mimeTypeTable->setRowCount(_mimeTypeTable->rowCount()+1); typedef std::map<QWebSettings::WebAttribute, QCheckBox*> Attributes ;
_mimeTypeTable->setItem(_mimeTypeTable->rowCount()-1, 0, Attributes _attributes;
new QTableWidgetItem); typedef std::map<QString, std::pair<QCheckBox*, bool> > CheckBoxes;
_mimeTypeTable->setItem(_mimeTypeTable->rowCount()-1, 1, CheckBoxes _checkboxes;
new QTableWidgetItem); typedef std::map<QString, std::pair<QLineEdit*, QString> > LineEdits;
_mimeTypeTable->setItem(_mimeTypeTable->rowCount()-1, 2, LineEdits _lineedits;
new QTableWidgetItem); QSettings* _settings;
} bool _autoWrite;
MimeTypes _mimetypes;
void on__removeMimeType_pressed() { SearchEngines _searchEngines;
QList<QTableWidgetSelectionRange> ranges
(_mimeTypeTable->selectedRanges()); };
if (ranges.isEmpty()) return;
for (int begin(ranges.at(0).topRow()), count(ranges.at(0).rowCount()); }
count; --count)
_mimeTypeTable->removeRow(begin);
}
void on__addSearchEngine_pressed() {
_searchEngineTable->setRowCount(_searchEngineTable->rowCount()+1);
_searchEngineTable->setItem(_searchEngineTable->rowCount()-1, 0,
new QTableWidgetItem);
_searchEngineTable->setItem(_searchEngineTable->rowCount()-1, 1,
new QTableWidgetItem);
_searchEngineTable->setItem(_searchEngineTable->rowCount()-1, 2,
new QTableWidgetItem);
}
void on__removeSearchEngine_pressed() {
QList<QTableWidgetSelectionRange> ranges
(_searchEngineTable->selectedRanges());
if (ranges.isEmpty()) return;
for (int begin(ranges.at(0).topRow()), count(ranges.at(0).rowCount());
count; --count)
_searchEngineTable->removeRow(begin);
}
private:
typedef std::map<QWebSettings::WebAttribute, QCheckBox*> Attributes ;
Attributes _attributes;
typedef std::map<QString, std::pair<QCheckBox*, bool> > CheckBoxes;
CheckBoxes _checkboxes;
typedef std::map<QString, std::pair<QLineEdit*, QString> > LineEdits;
LineEdits _lineedits;
QSettings* _settings;
bool _autoWrite;
MimeTypes _mimetypes;
SearchEngines _searchEngines;
};
#endif #endif

@ -716,6 +716,7 @@ Try: %1 --help</source>
<source>Usage: %1 [OPTIONS...] [&lt;url&gt; ...] <source>Usage: %1 [OPTIONS...] [&lt;url&gt; ...]
Options: Options:
-h, --help show this help text -h, --help show this help text
-d, --debug enable verbose debug mode
-t --tmp path temporary folder for data caching -t --tmp path temporary folder for data caching
-k, --kiosk no url bar -k, --kiosk no url bar
if you sepcify -k and -s, -k must be first if you sepcify -k and -s, -k must be first

@ -716,6 +716,7 @@ Try: %1 --help</source>
<source>Usage: %1 [OPTIONS...] [&lt;url&gt; ...] <source>Usage: %1 [OPTIONS...] [&lt;url&gt; ...]
Options: Options:
-h, --help show this help text -h, --help show this help text
-d, --debug enable verbose debug mode
-t --tmp path temporary folder for data caching -t --tmp path temporary folder for data caching
-k, --kiosk no url bar -k, --kiosk no url bar
if you sepcify -k and -s, -k must be first if you sepcify -k and -s, -k must be first

@ -716,6 +716,7 @@ Try: %1 --help</source>
<source>Usage: %1 [OPTIONS...] [&lt;url&gt; ...] <source>Usage: %1 [OPTIONS...] [&lt;url&gt; ...]
Options: Options:
-h, --help show this help text -h, --help show this help text
-d, --debug enable verbose debug mode
-t --tmp path temporary folder for data caching -t --tmp path temporary folder for data caching
-k, --kiosk no url bar -k, --kiosk no url bar
if you sepcify -k and -s, -k must be first if you sepcify -k and -s, -k must be first

@ -716,6 +716,7 @@ Try: %1 --help</source>
<source>Usage: %1 [OPTIONS...] [&lt;url&gt; ...] <source>Usage: %1 [OPTIONS...] [&lt;url&gt; ...]
Options: Options:
-h, --help show this help text -h, --help show this help text
-d, --debug enable verbose debug mode
-t --tmp path temporary folder for data caching -t --tmp path temporary folder for data caching
-k, --kiosk no url bar -k, --kiosk no url bar
if you sepcify -k and -s, -k must be first if you sepcify -k and -s, -k must be first

Loading…
Cancel
Save