new option --debug to enable debugging and debug window in info; refs #153

This commit is contained in:
Marc Wäckerlin
2012-05-09 14:26:55 +00:00
parent 40a926571c
commit ded89e5c43
29 changed files with 1089 additions and 560 deletions

View File

@@ -8,16 +8,13 @@
#ifndef __BUTTONLINEEDIT_HXX__
#define __BUTTONLINEEDIT_HXX__
#include <qbrowserlib/log.hxx>
#include <QtGui/QLineEdit>
#include <QtGui/QToolButton>
#include <QtGui/QAction>
#include <QtGui/QStyle>
#include <QtCore/QDebug>
#ifndef LOG
#define LOG qDebug()<<__PRETTY_FUNCTION__
#endif
//! @addtogroup qbrowserlib
//! @{
@@ -26,17 +23,17 @@ class ButtonLineEdit: public QLineEdit {
Q_OBJECT;
public:
ButtonLineEdit(QWidget* p=0): QLineEdit(p) {
LOG;
TRC;
}
QToolButton* add(QAction* a) {
LOG;
TRC;
QToolButton* b(new QToolButton(this));
b->setDefaultAction(a);
add(b);
return b;
}
ButtonLineEdit& add(QToolButton* b) {
LOG;
TRC;
b->setParent(this);
b->setStyleSheet("QToolButton { border: none; padding: 0; }");
b->setCursor(Qt::ArrowCursor);
@@ -45,7 +42,7 @@ class ButtonLineEdit: public QLineEdit {
return *this;
}
ButtonLineEdit& changeStyleSheet(QString s) {
LOG;
TRC;
_style = s;
resizeEvent(0);
return *this;

View File

@@ -8,6 +8,7 @@
#ifndef QBROWSERLIB_EXECUTOR_HXX
#define QBROWSERLIB_EXECUTOR_HXX
#include <qbrowserlib/log.hxx>
#include <qbrowserlib/settings.hxx>
#include <qbrowserlib/temporaryfile.hxx>
@@ -31,6 +32,7 @@ namespace qbrowserlib {
Executor(Settings* settings=0): _settings(settings) {}
~Executor() {
TRC;
for (DownloadProcesses::iterator it(_downloadProcesses.begin());
it!=_downloadProcesses.end(); ++it) {
LOG<<"cleanup:"<<it->second->fileName();
@@ -52,7 +54,7 @@ namespace qbrowserlib {
public Q_SLOTS:
void run(QNetworkReply* reply, QString filename, QString command) {
LOG<<filename<<command;
TRC; LOG<<filename<<command;
_reply = reply;
_filename = filename;
_command = command;
@@ -68,6 +70,7 @@ namespace qbrowserlib {
private Q_SLOTS:
void downloadFinished() {
TRC;
TemporaryFile *file(new TemporaryFile
(QDir::tempPath()+QDir::separator()
+QFileInfo(_filename).fileName()));
@@ -89,7 +92,7 @@ namespace qbrowserlib {
}
void processFinished() {
LOG;
TRC;
if (_downloadProcesses.find(qobject_cast<QProcess*>(sender()))
== _downloadProcesses.end()) return;
if (_downloadProcesses[qobject_cast<QProcess*>(sender())])

100
src/qbrowserlib/log.cxx Normal file
View File

@@ -0,0 +1,100 @@
/*! @file
@id $Id$
*/
// 1 2 3 4 5 6 7 8
// 45678901234567890123456789012345678901234567890123456789012345678901234567890
#include <qbrowserlib/log.hxx>
namespace qbrowserlib {
bool Log::DEBUG(false);
LogDialog* Log::_dialog(0);
unsigned int Log::_level(0);
Log::Log(const void* addr, const std::string& name,
const std::string& file, unsigned long line):
_debug(DEBUG), _addr(addr), _name(name), _file(file), _line(line) {
if (!_debug) return;
++_level;
std::stringstream ss;
init(ss);
indent(ss)<<"\\ "<<_name;
std::clog<<close(ss).str()<<std::endl;
}
Log::~Log() throw() {
if (!_debug) return;
std::stringstream ss;
init(ss);
indent(ss)<<"/ "<<_name;
std::clog<<close(ss).str()<<std::endl;
--_level;
}
void Log::show(QWidget* p) {
if (!_dialog)
_dialog = new LogDialog(p);
_dialog->_logs->resizeColumnsToContents();
_dialog->_logs->resizeRowsToContents();
_dialog->show();
}
std::stringstream& Log::init(std::stringstream& ss) {
if (_addr)
ss<<std::hex<<std::setw(15)<<_addr<<": "<<std::dec;
else
ss<<std::setw(17)<<' ';
return ss;
}
std::stringstream& Log::indent(std::stringstream& ss) {
ss<<std::setw(2+_level)<<std::setfill(' ');
return ss;
}
std::stringstream& Log::close(std::stringstream& ss) {
ss<<" ("<<_file<<':'<<_line<<')';
return ss;
}
template<> LogDialog& LogDialog::append
(const Log& log, std::string arg) {
return append(log, QString::fromStdString(arg));
}
template<> LogDialog& LogDialog::append
(const Log& log, const char* arg) {
return append(log, QString(arg));
}
template<> LogDialog& LogDialog::append
(const Log& log, unsigned long arg) {
return append(log, (qulonglong)arg);
}
std::ostream& operator<<(std::ostream& ss, QString arg) {
ss<<'"'<<arg.toStdString()<<'"';
return ss;
}
std::ostream& operator<<(std::ostream& ss, QStringList arg) {
ss<<"{ ";
for (QStringList::iterator item(arg.begin()); item!=arg.end();) {
ss<<*item;
if (++item!=arg.end()) ss<<", ";
}
ss<<" }";
return ss;
}
std::ostream& operator<<(std::ostream& ss, QUrl arg) {
ss<<arg.toString();
return ss;
}
std::ostream& operator<<(std::ostream& ss, QByteArray arg) {
ss<<QString::fromUtf8(arg);
return ss;
}
}

202
src/qbrowserlib/log.hxx Normal file
View File

@@ -0,0 +1,202 @@
/*! @file
@id $Id$
*/
// 1 2 3 4 5 6 7 8
// 45678901234567890123456789012345678901234567890123456789012345678901234567890
#ifndef QBROWSERLIB_LOG
#define QBROWSERLIB_LOG
#include <qbrowserlib/ui_log.h>
#include <QtGui/QDialog>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <typeinfo>
// supported Qt logging types
#include <QtCore/QString>
#include <QtCore/QStringList>
#include <QtCore/QUrl>
#include <QtCore/QByteArray>
namespace qbrowserlib {
#ifndef LOG
#define LOG \
QBROWSERLIB_LOCAL_TRACER
#endif
#ifndef TRC
#define TRC \
qbrowserlib::Log QBROWSERLIB_LOCAL_TRACER \
(this, __PRETTY_FUNCTION__, __FILE__, __LINE__)
#endif
#ifndef TRC_FN
#define TRC_FN \
qbrowserlib::Log QBROWSERLIB_LOCAL_TRACER \
(0, __PRETTY_FUNCTION__, __FILE__, __LINE__)
#endif
class LogDialog;
class Log {
public:
static bool DEBUG;
public:
Log(const void* addr, const std::string& name,
const std::string& file, unsigned long line);
template<typename TYPE> Log& operator<<(TYPE arg);
~Log() throw();
static void show(QWidget* p);
private:
std::stringstream& init(std::stringstream& ss);
std::stringstream& indent(std::stringstream& ss);
std::stringstream& close(std::stringstream& ss);
private:
friend class LogDialog;
static LogDialog* _dialog;
static unsigned int _level;
bool _debug;
const void* _addr;
const std::string _name;
const std::string _file;
unsigned long _line;
};
class LogDialog: public QDialog, public Ui::LogDialog {
Q_OBJECT;
public:
LogDialog(QWidget* p): QDialog(p) {
setupUi(this);
}
template<typename TYPE> LogDialog& append(const Log& log, TYPE* arg) {
std::ostringstream ss;
ss<<"("<<typeid(TYPE*).name()<<")"<<arg;
return append(log, ss.str());
}
template<typename TYPE> LogDialog& append(const Log& log, TYPE arg) {
int pos(_logs->rowCount());
_logs->insertRow(pos);
_logs->setItem
(pos, FILE,
new QTableWidgetItem(QString::fromStdString(log._file)));
_logs->setItem
(pos, LINE, new QTableWidgetItem(QString::number(log._line)));
if (log._addr) _logs->setItem
(pos, INSTANCE,
new QTableWidgetItem
(QString::number((qulonglong)log._addr)));
_logs->setItem
(pos, FUNCTION,
new QTableWidgetItem(QString::fromStdString(log._name)));
_logs->setItem
(pos, MESSAGE,
new QTableWidgetItem(QVariant(arg).toString()));
return *this;
}
protected Q_SLOTS:
void on__fileLine_toggled(bool checked) {
if (checked) {
_logs->showColumn(FILE);
_logs->showColumn(LINE);
} else {
_logs->hideColumn(FILE);
_logs->hideColumn(LINE);
}
}
void on__instance_toggled(bool checked) {
if (checked) {
_logs->showColumn(INSTANCE);
} else {
_logs->hideColumn(INSTANCE);
}
}
void on__function_toggled(bool checked) {
if (checked) {
_logs->showColumn(FUNCTION);
} else {
_logs->hideColumn(FUNCTION);
}
}
void on__buttons_clicked(QAbstractButton* button) {
if (_buttons->buttonRole(button)==QDialogButtonBox::ResetRole)
for (int i(_logs->rowCount()); i>1; --i)
_logs->removeRow(i-1);
}
void on__find_clicked(bool) {
setCursor(QCursor(Qt::BusyCursor));
QList<QTableWidgetItem*> items
(_logs->findItems(_search->text(),
Qt::MatchWrap|Qt::MatchContains
|Qt::MatchFixedString));
_logs->clearSelection();
foreach (QTableWidgetItem* item, items) {
item->setSelected(true);
}
if (!items.isEmpty()) _logs->scrollToItem(items[0]);
unsetCursor();
}
private:
friend class Log;
enum {FILE, LINE, INSTANCE, FUNCTION, MESSAGE} Columns;
};
// note: template class method must be defined in the header
template<typename TYPE> Log& Log::operator<<(TYPE arg) {
if (!_debug) return *this;
std::stringstream ss;
init(ss);
indent(ss)<<""<<arg;
std::clog<<close(ss).str()<<std::endl;
if (!_dialog) _dialog = new LogDialog(0);
_dialog->append(*this, arg);
return *this;
}
template<> LogDialog& LogDialog::append
(const Log& log, const char* arg);
template<> LogDialog& LogDialog::append
(const Log& log, std::string arg);
template<> LogDialog& LogDialog::append
(const Log& log, unsigned long arg);
std::ostream& operator<<(std::ostream& ss, QString arg);
std::ostream& operator<<(std::ostream& ss, QStringList arg);
std::ostream& operator<<(std::ostream& ss, QUrl arg);
std::ostream& operator<<(std::ostream& ss, QByteArray arg);
}
#endif

203
src/qbrowserlib/log.ui Normal file
View File

@@ -0,0 +1,203 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>LogDialog</class>
<widget class="QDialog" name="LogDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>957</width>
<height>736</height>
</rect>
</property>
<property name="windowTitle">
<string>Debug Log</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Show Columns</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QCheckBox" name="_fileLine">
<property name="text">
<string>File/Line</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="_instance">
<property name="text">
<string>Instance</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="_function">
<property name="text">
<string>Function</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Find Text</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLineEdit" name="_search"/>
</item>
<item>
<widget class="QPushButton" name="_find">
<property name="text">
<string>Find</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QTableWidget" name="_logs">
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="showDropIndicator" stdset="0">
<bool>false</bool>
</property>
<property name="dragDropOverwriteMode">
<bool>false</bool>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::NoSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<attribute name="horizontalHeaderCascadingSectionResizes">
<bool>true</bool>
</attribute>
<attribute name="horizontalHeaderShowSortIndicator" stdset="0">
<bool>false</bool>
</attribute>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<attribute name="verticalHeaderCascadingSectionResizes">
<bool>true</bool>
</attribute>
<column>
<property name="text">
<string>File</string>
</property>
<property name="textAlignment">
<set>AlignLeft|AlignTop</set>
</property>
</column>
<column>
<property name="text">
<string>Line</string>
</property>
<property name="textAlignment">
<set>AlignLeft|AlignTop</set>
</property>
</column>
<column>
<property name="text">
<string>Instance</string>
</property>
<property name="textAlignment">
<set>AlignLeft|AlignTop</set>
</property>
</column>
<column>
<property name="text">
<string>Function</string>
</property>
<property name="textAlignment">
<set>AlignLeft|AlignTop</set>
</property>
</column>
<column>
<property name="text">
<string>Message</string>
</property>
<property name="textAlignment">
<set>AlignJustify|AlignTop</set>
</property>
</column>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="_buttons">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Close|QDialogButtonBox::Reset</set>
</property>
<property name="centerButtons">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>_buttons</sender>
<signal>accepted()</signal>
<receiver>LogDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>227</x>
<y>640</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>_buttons</sender>
<signal>rejected()</signal>
<receiver>LogDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>295</x>
<y>646</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@@ -8,14 +8,10 @@
#ifndef __PLUGINFACTORY_HXX__
#define __PLUGINFACTORY_HXX__
#include <qbrowserlib/log.hxx>
#include <QtWebKit/QWebPluginFactory>
#include <qbrowserlib/saveorrun.hxx>
#include <QtCore/QDebug>
#ifndef LOG
#define LOG qDebug()<<__PRETTY_FUNCTION__
#endif
//! @addtogroup qbrowserlib
//! @{
@@ -31,7 +27,7 @@ namespace qbrowserlib {
PluginFactory(QNetworkAccessManager* net, Executor* executor,
QObject* p=0): QWebPluginFactory(p),
_net(net), _executor(executor) {
LOG;
TRC;
// Plugin plugin;
// plugin.name = "Show PDF-Document";
// plugin.description = "Plugin for PDF documents";
@@ -45,7 +41,7 @@ namespace qbrowserlib {
virtual QObject* create(const QString& mimeType, const QUrl& url,
const QStringList& argumentNames,
const QStringList& argumentValues ) const {
LOG<<"mimeType:"<<mimeType
TRC; LOG<<"mimeType:"<<mimeType
<<"url:"<<url
<<"argumentNames:"<<argumentNames.join(", ")
<<"argumentValues:"<<argumentValues.join(", ");
@@ -64,11 +60,11 @@ namespace qbrowserlib {
return 0;
}
virtual QList<Plugin> plugins() const {
LOG;
TRC;
return _plugins;
}
virtual void refreshPlugins() {
LOG;
TRC;
}
private:
QList<Plugin> _plugins;

View File

@@ -2,6 +2,61 @@
<!DOCTYPE TS>
<TS version="2.0" language="de_DE">
<defaultcodec>UTF-8</defaultcodec>
<context>
<name>LogDialog</name>
<message>
<location filename="log.ui" line="14"/>
<source>Debug Log</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="log.ui" line="22"/>
<source>Show Columns</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="log.ui" line="28"/>
<source>File/Line</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="log.ui" line="38"/>
<location filename="log.ui" line="129"/>
<source>Instance</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="log.ui" line="48"/>
<location filename="log.ui" line="137"/>
<source>Function</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="log.ui" line="61"/>
<source>Find Text</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="log.ui" line="70"/>
<source>Find</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="log.ui" line="113"/>
<source>File</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="log.ui" line="121"/>
<source>Line</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="log.ui" line="145"/>
<source>Message</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SaveOrRun</name>
<message>
@@ -523,12 +578,12 @@ p, li { white-space: pre-wrap; }
<context>
<name>qbrowserlib::SaveOrRun</name>
<message>
<location filename="saveorrun.hxx" line="132"/>
<location filename="saveorrun.hxx" line="131"/>
<source>File Exists</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="saveorrun.hxx" line="133"/>
<location filename="saveorrun.hxx" line="132"/>
<source>File already exists:
%1
@@ -537,12 +592,12 @@ Overwrite?</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="saveorrun.hxx" line="145"/>
<location filename="saveorrun.hxx" line="144"/>
<source>No Program</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="saveorrun.hxx" line="146"/>
<location filename="saveorrun.hxx" line="145"/>
<source>Not an executable Program:
%1
@@ -551,23 +606,23 @@ Specify full path to executable program</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="saveorrun.hxx" line="158"/>
<location filename="saveorrun.hxx" line="157"/>
<source>Save File As ...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="saveorrun.hxx" line="171"/>
<location filename="saveorrun.hxx" line="170"/>
<source>Open File With ...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="saveorrun.hxx" line="183"/>
<location filename="saveorrun.hxx" line="182"/>
<source>Dokumente</source>
<comment>Documents folder in local language</comment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="saveorrun.hxx" line="185"/>
<location filename="saveorrun.hxx" line="184"/>
<source>Arbeitsfläche</source>
<comment>Desktop folder in local language</comment>
<translation type="unfinished"></translation>
@@ -576,7 +631,7 @@ Specify full path to executable program</source>
<context>
<name>qbrowserlib::SaveOrRunDialog</name>
<message>
<location filename="saveorrun.hxx" line="237"/>
<location filename="saveorrun.hxx" line="236"/>
<source>Unknown File Type</source>
<translation type="unfinished"></translation>
</message>

View File

@@ -2,6 +2,61 @@
<!DOCTYPE TS>
<TS version="2.0" language="en_US">
<defaultcodec>UTF-8</defaultcodec>
<context>
<name>LogDialog</name>
<message>
<location filename="log.ui" line="14"/>
<source>Debug Log</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="log.ui" line="22"/>
<source>Show Columns</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="log.ui" line="28"/>
<source>File/Line</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="log.ui" line="38"/>
<location filename="log.ui" line="129"/>
<source>Instance</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="log.ui" line="48"/>
<location filename="log.ui" line="137"/>
<source>Function</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="log.ui" line="61"/>
<source>Find Text</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="log.ui" line="70"/>
<source>Find</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="log.ui" line="113"/>
<source>File</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="log.ui" line="121"/>
<source>Line</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="log.ui" line="145"/>
<source>Message</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SaveOrRun</name>
<message>
@@ -523,12 +578,12 @@ p, li { white-space: pre-wrap; }
<context>
<name>qbrowserlib::SaveOrRun</name>
<message>
<location filename="saveorrun.hxx" line="132"/>
<location filename="saveorrun.hxx" line="131"/>
<source>File Exists</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="saveorrun.hxx" line="133"/>
<location filename="saveorrun.hxx" line="132"/>
<source>File already exists:
%1
@@ -537,12 +592,12 @@ Overwrite?</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="saveorrun.hxx" line="145"/>
<location filename="saveorrun.hxx" line="144"/>
<source>No Program</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="saveorrun.hxx" line="146"/>
<location filename="saveorrun.hxx" line="145"/>
<source>Not an executable Program:
%1
@@ -551,23 +606,23 @@ Specify full path to executable program</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="saveorrun.hxx" line="158"/>
<location filename="saveorrun.hxx" line="157"/>
<source>Save File As ...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="saveorrun.hxx" line="171"/>
<location filename="saveorrun.hxx" line="170"/>
<source>Open File With ...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="saveorrun.hxx" line="183"/>
<location filename="saveorrun.hxx" line="182"/>
<source>Dokumente</source>
<comment>Documents folder in local language</comment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="saveorrun.hxx" line="185"/>
<location filename="saveorrun.hxx" line="184"/>
<source>Arbeitsfläche</source>
<comment>Desktop folder in local language</comment>
<translation type="unfinished"></translation>
@@ -576,7 +631,7 @@ Specify full path to executable program</source>
<context>
<name>qbrowserlib::SaveOrRunDialog</name>
<message>
<location filename="saveorrun.hxx" line="237"/>
<location filename="saveorrun.hxx" line="236"/>
<source>Unknown File Type</source>
<translation type="unfinished"></translation>
</message>

View File

@@ -2,6 +2,61 @@
<!DOCTYPE TS>
<TS version="2.0" language="fr_FR">
<defaultcodec>UTF-8</defaultcodec>
<context>
<name>LogDialog</name>
<message>
<location filename="log.ui" line="14"/>
<source>Debug Log</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="log.ui" line="22"/>
<source>Show Columns</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="log.ui" line="28"/>
<source>File/Line</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="log.ui" line="38"/>
<location filename="log.ui" line="129"/>
<source>Instance</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="log.ui" line="48"/>
<location filename="log.ui" line="137"/>
<source>Function</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="log.ui" line="61"/>
<source>Find Text</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="log.ui" line="70"/>
<source>Find</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="log.ui" line="113"/>
<source>File</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="log.ui" line="121"/>
<source>Line</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="log.ui" line="145"/>
<source>Message</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SaveOrRun</name>
<message>
@@ -523,12 +578,12 @@ p, li { white-space: pre-wrap; }
<context>
<name>qbrowserlib::SaveOrRun</name>
<message>
<location filename="saveorrun.hxx" line="132"/>
<location filename="saveorrun.hxx" line="131"/>
<source>File Exists</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="saveorrun.hxx" line="133"/>
<location filename="saveorrun.hxx" line="132"/>
<source>File already exists:
%1
@@ -537,12 +592,12 @@ Overwrite?</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="saveorrun.hxx" line="145"/>
<location filename="saveorrun.hxx" line="144"/>
<source>No Program</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="saveorrun.hxx" line="146"/>
<location filename="saveorrun.hxx" line="145"/>
<source>Not an executable Program:
%1
@@ -551,23 +606,23 @@ Specify full path to executable program</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="saveorrun.hxx" line="158"/>
<location filename="saveorrun.hxx" line="157"/>
<source>Save File As ...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="saveorrun.hxx" line="171"/>
<location filename="saveorrun.hxx" line="170"/>
<source>Open File With ...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="saveorrun.hxx" line="183"/>
<location filename="saveorrun.hxx" line="182"/>
<source>Dokumente</source>
<comment>Documents folder in local language</comment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="saveorrun.hxx" line="185"/>
<location filename="saveorrun.hxx" line="184"/>
<source>Arbeitsfläche</source>
<comment>Desktop folder in local language</comment>
<translation type="unfinished"></translation>
@@ -576,7 +631,7 @@ Specify full path to executable program</source>
<context>
<name>qbrowserlib::SaveOrRunDialog</name>
<message>
<location filename="saveorrun.hxx" line="237"/>
<location filename="saveorrun.hxx" line="236"/>
<source>Unknown File Type</source>
<translation type="unfinished"></translation>
</message>

View File

@@ -2,6 +2,61 @@
<!DOCTYPE TS>
<TS version="2.0" language="it_IT">
<defaultcodec>UTF-8</defaultcodec>
<context>
<name>LogDialog</name>
<message>
<location filename="log.ui" line="14"/>
<source>Debug Log</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="log.ui" line="22"/>
<source>Show Columns</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="log.ui" line="28"/>
<source>File/Line</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="log.ui" line="38"/>
<location filename="log.ui" line="129"/>
<source>Instance</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="log.ui" line="48"/>
<location filename="log.ui" line="137"/>
<source>Function</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="log.ui" line="61"/>
<source>Find Text</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="log.ui" line="70"/>
<source>Find</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="log.ui" line="113"/>
<source>File</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="log.ui" line="121"/>
<source>Line</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="log.ui" line="145"/>
<source>Message</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SaveOrRun</name>
<message>
@@ -523,12 +578,12 @@ p, li { white-space: pre-wrap; }
<context>
<name>qbrowserlib::SaveOrRun</name>
<message>
<location filename="saveorrun.hxx" line="132"/>
<location filename="saveorrun.hxx" line="131"/>
<source>File Exists</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="saveorrun.hxx" line="133"/>
<location filename="saveorrun.hxx" line="132"/>
<source>File already exists:
%1
@@ -537,12 +592,12 @@ Overwrite?</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="saveorrun.hxx" line="145"/>
<location filename="saveorrun.hxx" line="144"/>
<source>No Program</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="saveorrun.hxx" line="146"/>
<location filename="saveorrun.hxx" line="145"/>
<source>Not an executable Program:
%1
@@ -551,23 +606,23 @@ Specify full path to executable program</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="saveorrun.hxx" line="158"/>
<location filename="saveorrun.hxx" line="157"/>
<source>Save File As ...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="saveorrun.hxx" line="171"/>
<location filename="saveorrun.hxx" line="170"/>
<source>Open File With ...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="saveorrun.hxx" line="183"/>
<location filename="saveorrun.hxx" line="182"/>
<source>Dokumente</source>
<comment>Documents folder in local language</comment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="saveorrun.hxx" line="185"/>
<location filename="saveorrun.hxx" line="184"/>
<source>Arbeitsfläche</source>
<comment>Desktop folder in local language</comment>
<translation type="unfinished"></translation>
@@ -576,7 +631,7 @@ Specify full path to executable program</source>
<context>
<name>qbrowserlib::SaveOrRunDialog</name>
<message>
<location filename="saveorrun.hxx" line="237"/>
<location filename="saveorrun.hxx" line="236"/>
<source>Unknown File Type</source>
<translation type="unfinished"></translation>
</message>

View File

@@ -32,9 +32,10 @@ TRANSLATIONS = @srcdir@/qbrowserlib_en.ts \
@srcdir@/qbrowserlib_fr.ts \
@srcdir@/qbrowserlib_it.ts
SOURCES = @srcdir@/certs.cxx
SOURCES = @srcdir@/log.cxx @srcdir@/certs.cxx
HEADERS = @srcdir@/swisswebview.hxx @srcdir@/swisswebpage.hxx \
HEADERS = @srcdir@/log.hxx \
@srcdir@/swisswebview.hxx @srcdir@/swisswebpage.hxx \
@srcdir@/pluginfactory.hxx @srcdir@/saveorrun.hxx \
@srcdir@/settings.hxx \
@srcdir@/buttonlineedit.hxx \
@@ -42,7 +43,7 @@ HEADERS = @srcdir@/swisswebview.hxx @srcdir@/swisswebpage.hxx \
@srcdir@/executor.hxx \
@srcdir@/temporaryfile.hxx
FORMS = @srcdir@/saveorrun.ui @srcdir@/settings.ui
FORMS = @srcdir@/saveorrun.ui @srcdir@/settings.ui @srcdir@/log.ui
RESOURCES = languages.qrc

View File

@@ -8,6 +8,7 @@
#ifndef __SAVEORRUN_HXX__
#define __SAVEORRUN_HXX__
#include <qbrowserlib/log.hxx>
#include <qbrowserlib/ui_saveorrun.h>
#include <qbrowserlib/executor.hxx>
@@ -21,10 +22,6 @@
#include <memory>
#include <cassert>
#include <QtCore/QDebug>
#ifndef LOG
#define LOG qDebug()<<__PRETTY_FUNCTION__
#endif
//! @addtogroup qbrowserlib
//! @{
@@ -44,7 +41,7 @@ namespace qbrowserlib {
SaveOrRun(QNetworkReply* reply, Executor* executor,
QString type, QString src,
QWidget* p=0): QWidget(p), _reply(reply), _executor(executor) {
LOG;
TRC;
setupUi(this);
QString obj(remoteFilename());
_rememberPath->setVisible(false);
@@ -59,6 +56,7 @@ namespace qbrowserlib {
//! Run configured application if mime type is preconfigured.
bool handlePreconfigured() {
TRC;
QString filename(remoteFilename());
QStringList type
(_executor->settings()->mimetype
@@ -78,6 +76,7 @@ namespace qbrowserlib {
}
QString remoteFilename() {
TRC;
QString filename
(QString::fromUtf8(_reply->rawHeader("Content-Disposition")));
if (filename.contains
@@ -98,19 +97,19 @@ namespace qbrowserlib {
}
QString filename() {
LOG;
TRC;
return _filename->text();
}
QString program() {
LOG;
TRC;
return _program->text();
}
public Q_SLOTS:
void save() {
LOG;
TRC;
QFile file(filename());
file.open(QIODevice::WriteOnly);
file.write(_reply->readAll());
@@ -119,7 +118,7 @@ namespace qbrowserlib {
}
void run() {
LOG<<program()<<filename();
TRC; LOG<<program()<<filename();
_executor->run(_reply, filename(), program()+" %1");
accept();
}
@@ -127,7 +126,7 @@ namespace qbrowserlib {
protected Q_SLOTS:
void on__saveFileAs_clicked(bool=true) {
LOG;
TRC;
if (QFileInfo(filename()).exists()
&& QMessageBox::question(this, tr("File Exists"),
tr("File already exists:\n\n"
@@ -139,7 +138,7 @@ namespace qbrowserlib {
}
void on__openFileIn_clicked(bool=true) {
LOG;
TRC;
if (!QFile::exists(program())
|| !QFileInfo(program()).isExecutable()) {
QMessageBox::warning(this, tr("No Program"),
@@ -153,7 +152,7 @@ namespace qbrowserlib {
}
void on__browseSaveAs_clicked(bool) {
LOG;
TRC;
QString saveFile
(QFileDialog::getSaveFileName(this, tr("Save File As ..."),
_filename->text(), QString(), 0,
@@ -166,7 +165,7 @@ namespace qbrowserlib {
}
void on__browseOpenWith_clicked(bool) {
LOG;
TRC;
QString openFile
(QFileDialog::getOpenFileName(this, tr("Open File With ..."),
_program->text()));
@@ -176,7 +175,7 @@ namespace qbrowserlib {
}
QString savePath() {
LOG;
TRC;
QString path(QDir::homePath());
QStringList defpaths;
defpaths<<"downloads"<<"Downloads"<<"Documents"
@@ -209,7 +208,7 @@ namespace qbrowserlib {
bool kiosk=false, QWidget* p=0):
SaveOrRun(reply, executor,
mime, url.toString(), p) {
LOG;
TRC;
setAutoFillBackground(true);
_type->setText(mime);
_source->setText(url.host());
@@ -233,7 +232,7 @@ namespace qbrowserlib {
QString type, QString src,
bool kiosk=false, QWidget* p=0):
QDialog(p), _sor(new SaveOrRun(reply, executor, type, src)) {
LOG;
TRC;
setWindowTitle(tr("Unknown File Type"));
QVBoxLayout* l(new QVBoxLayout(this));
l->addWidget(_sor);

View File

@@ -8,6 +8,7 @@
#ifndef QBROWSERLIB_SETTINGS_HXX
#define QBROWSERLIB_SETTINGS_HXX
#include <qbrowserlib/log.hxx>
#include <qbrowserlib/ui_settings.h>
#include <QtWebKit/QWebSettings>
@@ -17,10 +18,6 @@
#include <QtGui/QLineEdit>
#include <cassert>
#include <QtCore/QDebug>
#ifndef LOG
#define LOG qDebug()<<__PRETTY_FUNCTION__
#endif
namespace qbrowserlib {
@@ -117,7 +114,7 @@ namespace qbrowserlib {
}
void setAttribute(QWebSettings::WebAttribute attr, bool state) {
//LOG;
//TRC;
QWebSettings::globalSettings()->setAttribute(attr, state);
_attributes[attr]->setChecked(state);
}
@@ -147,7 +144,7 @@ namespace qbrowserlib {
}
QString& replaceSearchEngine(QString& url) {
LOG;
TRC;
int len(url.indexOf(QRegExp("[ :]")));
if (len<=0) return url;
QString scheme(url.left(len));
@@ -165,7 +162,7 @@ namespace qbrowserlib {
}
bool save() {
LOG;
TRC;
if (!_settings || !_settings->isWritable()) return false;
// Attributes
for (Attributes::iterator it(_attributes.begin());
@@ -191,7 +188,7 @@ namespace qbrowserlib {
}
bool load(bool overwriteMimeTypes=true) {
LOG;
TRC;
if (!_settings) return false;
// Attributes
for (Attributes::iterator it(_attributes.begin());
@@ -242,7 +239,7 @@ namespace qbrowserlib {
private Q_SLOTS:
void on__buttons_accepted() {
LOG;
TRC;
// Attributes
for (Attributes::iterator it(_attributes.begin());
it!=_attributes.end(); ++it)
@@ -274,7 +271,7 @@ namespace qbrowserlib {
}
void on__buttons_rejected() {
LOG;
TRC;
// Attributes
for (Attributes::iterator it(_attributes.begin());
it!=_attributes.end(); ++it)

View File

@@ -8,17 +8,13 @@
#ifndef __SWISSWEBPAGE_HXX__
#define __SWISSWEBPAGE_HXX__
#include <qbrowserlib/log.hxx>
#include <qbrowserlib/pluginfactory.hxx>
#include <QtWebKit/QWebPage>
#include <QtWebKit/QWebHistory>
#include <QtCore/QProcessEnvironment>
#include <QtCore/QDebug>
#ifndef LOG
#define LOG qDebug()<<__PRETTY_FUNCTION__
#endif
//! @addtogroup qbrowserlib
//! @{
@@ -72,7 +68,7 @@ namespace qbrowserlib {
QObject* createPlugin(const QString& classid, const QUrl& url,
const QStringList& paramNames,
const QStringList& paramValues) {
LOG<<"classid:"<<classid
TRC; LOG<<"classid:"<<classid
<<"url:"<<url
<<"paramNames:"<<paramNames.join(", ")
<<"paramValues:"<<paramValues.join(", ");