create separate library and designer plugin; refs #115
This commit is contained in:
8
src/qbrowserlib/languages.qrc.in
Normal file
8
src/qbrowserlib/languages.qrc.in
Normal file
@@ -0,0 +1,8 @@
|
||||
<RCC>
|
||||
<qresource prefix="/language">
|
||||
<file>qbrowserlib_de.qm</file>
|
||||
<file>qbrowserlib_fr.qm</file>
|
||||
<file>qbrowserlib_it.qm</file>
|
||||
<file>qbrowserlib_en.qm</file>
|
||||
</qresource>
|
||||
</RCC>
|
91
src/qbrowserlib/makefile.am
Normal file
91
src/qbrowserlib/makefile.am
Normal file
@@ -0,0 +1,91 @@
|
||||
## @file
|
||||
##
|
||||
## $Id: makefile.am 7 2010-03-01 14:55:44Z marc $
|
||||
##
|
||||
## 1 2 3 4 5 6 7 8
|
||||
## 45678901234567890123456789012345678901234567890123456789012345678901234567890
|
||||
|
||||
include_HEADERS =
|
||||
|
||||
if !MINGW32
|
||||
if MAC
|
||||
AM_CPPFLAGS += -I/opt/local/include
|
||||
# -I/Library/OpenSC/include
|
||||
AM_LDFLAGS = -L/opt/local/lib
|
||||
# -F/System/Library/Frameworks/PCSC.framework
|
||||
else
|
||||
# AM_CPPFLAGS += -I/usr/include/PCSC
|
||||
endif
|
||||
endif
|
||||
|
||||
EXTRA_DIST = @srcdir@/*.[ch]xx @srcdir@/*.ui @srcdir@/*.ts @srcdir@/*.qrc.in
|
||||
|
||||
LANGS = en de fr it
|
||||
ALL_SRC = @srcdir@/*.[ch]xx \
|
||||
*.qrc \
|
||||
@srcdir@/*.ui
|
||||
|
||||
QMAKE_PROJECT = @srcdir@/qmake.pro
|
||||
QMAKE_MAKEFILE = makefile.qmake
|
||||
|
||||
QMAKE_TARGET = libqbrowserlib.so
|
||||
|
||||
TARGETS = ${QMAKE_TARGET}
|
||||
|
||||
all: ${TARGETS} $(LANGS:%=@srcdir@/qbrowserlib_%.ts)
|
||||
|
||||
rebuild-ts: $(LANGS)
|
||||
${LUPDATE} @LUPDATE_ARGS@ ${QMAKE_PROJECT}
|
||||
|
||||
${LANGS}: ${ALL_SRC}
|
||||
-rm qbrowserlib_$@.qm
|
||||
svn revert @srcdir@/qbrowserlib_$@.ts
|
||||
mv @srcdir@/qbrowserlib_$@.ts translation.old
|
||||
${LUPDATE} @LUPDATE_ARGS@ ${QMAKE_PROJECT}
|
||||
mv @srcdir@/qbrowserlib_$@.ts translation.new
|
||||
echo '<?xml version="1.0" encoding="utf-8"?>' > @srcdir@/qbrowserlib_$@.ts
|
||||
echo '<!DOCTYPE TS>' >> @srcdir@/qbrowserlib_$@.ts
|
||||
echo '<TS version="2.0" language="'$@'">' >> @srcdir@/qbrowserlib_$@.ts
|
||||
xqilla merge-translation.xquery >> @srcdir@/qbrowserlib_$@.ts
|
||||
echo '</TS>' >> @srcdir@/qbrowserlib_$@.ts
|
||||
rm translation.old translation.new
|
||||
|
||||
print:
|
||||
@echo "LANGS=${LANGS}"
|
||||
@echo "ALL_SRC=${ALL_SRC}"
|
||||
@echo "QMAKE=${QMAKE}"
|
||||
@echo "QMAKE_OPTIONS=${QMAKE_OPTIONS}"
|
||||
@echo "QMAKE_MAKEFILE=${QMAKE_MAKEFILE}"
|
||||
@echo "QMAKE_TARGET=${QMAKE_TARGET}"
|
||||
@echo "TARGETS=${TARGETS}"
|
||||
|
||||
|
||||
qbrowserlib_%.qm: @srcdir@/qbrowserlib_%.ts
|
||||
${LRELEASE} $< -qm $@
|
||||
|
||||
%.xpm: resources/%.png
|
||||
convert $< $@ || cp $< $@
|
||||
|
||||
@srcdir@/%.ts: ${ALL_SRC}
|
||||
${LUPDATE} @LUPDATE_ARGS@ ${QMAKE_PROJECT}
|
||||
|
||||
${QMAKE_MAKEFILE}: ${QMAKE_PROJECT} ${ALL_SRC}
|
||||
${QMAKE} -o $@ $<
|
||||
|
||||
${QMAKE_TARGET}: ${QMAKE_MAKEFILE} ${ALL_SRC} $(LANGS:%=qbrowserlib_%.qm)
|
||||
make -f ${QMAKE_MAKEFILE}
|
||||
|
||||
install-data-local:
|
||||
${mkinstalldirs} ${DESTDIR}${libdir}
|
||||
${INSTALL} ${QMAKE_TARGET}* ${DESTDIR}${libdir}
|
||||
|
||||
uninstall-local:
|
||||
rm -r ${DESTDIR}${libdir}/${QMAKE_TARGET}*
|
||||
|
||||
clean-local:
|
||||
-rm -r ${QMAKE_TARGET}*
|
||||
|
||||
CLEANFILES = ${TARGETS} ${TARGETS:%=%.exe} $(LANGS:%=qbrowserlib_%.qm) \
|
||||
*.o *.obj qrc_*.cpp ui_*.h moc_*.cpp *.qrc \
|
||||
${QMAKE_TARGET} \
|
||||
MAINTAINERCLEANFILES = makefile.in ${QMAKE_MAKEFILE}
|
56
src/qbrowserlib/pluginfactory.hxx
Normal file
56
src/qbrowserlib/pluginfactory.hxx
Normal file
@@ -0,0 +1,56 @@
|
||||
/*! @file
|
||||
|
||||
@id $Id$
|
||||
*/
|
||||
// 1 2 3 4 5 6 7 8
|
||||
// 45678901234567890123456789012345678901234567890123456789012345678901234567890
|
||||
|
||||
#ifndef __PLUGINFACTORY_HXX__
|
||||
#define __PLUGINFACTORY_HXX__
|
||||
|
||||
#include <QtWebKit/QWebPluginFactory>
|
||||
#include <qbrowserlib/saveorrun.hxx>
|
||||
|
||||
#include <QtCore/QDebug>
|
||||
#ifndef LOG
|
||||
#define LOG qDebug()<<__PRETTY_FUNCTION__
|
||||
#endif
|
||||
|
||||
class PluginFactory: public QWebPluginFactory {
|
||||
public:
|
||||
PluginFactory(QObject* p=0): QWebPluginFactory(p) {
|
||||
LOG;
|
||||
Plugin plugin;
|
||||
plugin.name = "Show PDF-Document";
|
||||
plugin.description = "Plugin for PDF documents";
|
||||
MimeType mime;
|
||||
mime.fileExtensions<<"pdf";
|
||||
mime.name = "application/pdf";
|
||||
mime.description = "PDF-Document";
|
||||
plugin.mimeTypes<<mime;
|
||||
_plugins.push_back(plugin);
|
||||
}
|
||||
virtual QObject* create(const QString& mimeType, const QUrl& url,
|
||||
const QStringList& argumentNames,
|
||||
const QStringList& argumentValues ) const {
|
||||
LOG<<"mimeType:"<<mimeType
|
||||
<<"url:"<<url
|
||||
<<"argumentNames:"<<argumentNames.join(", ")
|
||||
<<"argumentValues:"<<argumentValues.join(", ");
|
||||
if (mimeType=="application/pdf") {
|
||||
return new SaveOrRunPlugin(url, mimeType);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
virtual QList<Plugin> plugins() const {
|
||||
LOG;
|
||||
return _plugins;
|
||||
}
|
||||
virtual void refreshPlugins() {
|
||||
LOG;
|
||||
}
|
||||
private:
|
||||
QList<Plugin> _plugins;
|
||||
};
|
||||
|
||||
#endif
|
86
src/qbrowserlib/qbrowserlib_de.ts
Normal file
86
src/qbrowserlib/qbrowserlib_de.ts
Normal file
@@ -0,0 +1,86 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.0" language="de_DE">
|
||||
<defaultcodec>UTF-8</defaultcodec>
|
||||
<context>
|
||||
<name>SaveOrRun</name>
|
||||
<message>
|
||||
<source>File Exists</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>File already exists:
|
||||
|
||||
%1
|
||||
|
||||
Overwrite?</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Save File As ...</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Open File With ...</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Dokumente</source>
|
||||
<comment>Documents folder in local language</comment>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Arbeitsfläche</source>
|
||||
<comment>Desktop folder in local language</comment>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Download</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>File:</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>...</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Type:</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Source</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Save File</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Save File As:</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>browse ...</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>remember save path</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Open in External Application</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Open File in:</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>remember tool for this type</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
86
src/qbrowserlib/qbrowserlib_en.ts
Normal file
86
src/qbrowserlib/qbrowserlib_en.ts
Normal file
@@ -0,0 +1,86 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.0" language="en_US">
|
||||
<defaultcodec>UTF-8</defaultcodec>
|
||||
<context>
|
||||
<name>SaveOrRun</name>
|
||||
<message>
|
||||
<source>File Exists</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>File already exists:
|
||||
|
||||
%1
|
||||
|
||||
Overwrite?</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Save File As ...</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Open File With ...</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Dokumente</source>
|
||||
<comment>Documents folder in local language</comment>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Arbeitsfläche</source>
|
||||
<comment>Desktop folder in local language</comment>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Download</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>File:</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>...</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Type:</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Source</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Save File</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Save File As:</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>browse ...</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>remember save path</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Open in External Application</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Open File in:</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>remember tool for this type</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
86
src/qbrowserlib/qbrowserlib_fr.ts
Normal file
86
src/qbrowserlib/qbrowserlib_fr.ts
Normal file
@@ -0,0 +1,86 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.0" language="fr_FR">
|
||||
<defaultcodec>UTF-8</defaultcodec>
|
||||
<context>
|
||||
<name>SaveOrRun</name>
|
||||
<message>
|
||||
<source>File Exists</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>File already exists:
|
||||
|
||||
%1
|
||||
|
||||
Overwrite?</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Save File As ...</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Open File With ...</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Dokumente</source>
|
||||
<comment>Documents folder in local language</comment>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Arbeitsfläche</source>
|
||||
<comment>Desktop folder in local language</comment>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Download</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>File:</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>...</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Type:</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Source</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Save File</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Save File As:</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>browse ...</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>remember save path</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Open in External Application</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Open File in:</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>remember tool for this type</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
86
src/qbrowserlib/qbrowserlib_it.ts
Normal file
86
src/qbrowserlib/qbrowserlib_it.ts
Normal file
@@ -0,0 +1,86 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.0" language="it_IT">
|
||||
<defaultcodec>UTF-8</defaultcodec>
|
||||
<context>
|
||||
<name>SaveOrRun</name>
|
||||
<message>
|
||||
<source>File Exists</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>File already exists:
|
||||
|
||||
%1
|
||||
|
||||
Overwrite?</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Save File As ...</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Open File With ...</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Dokumente</source>
|
||||
<comment>Documents folder in local language</comment>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Arbeitsfläche</source>
|
||||
<comment>Desktop folder in local language</comment>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Download</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>File:</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>...</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Type:</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Source</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Save File</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Save File As:</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>browse ...</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>remember save path</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Open in External Application</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Open File in:</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>remember tool for this type</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
55
src/qbrowserlib/qmake.pro.in
Normal file
55
src/qbrowserlib/qmake.pro.in
Normal file
@@ -0,0 +1,55 @@
|
||||
QT += webkit network gui
|
||||
QMAKE_LIBS += -lproxyface -lpcscxx -lssl -lcrypto
|
||||
QMAKE_CXXFLAGS += -Wno-parentheses -Wno-unused-parameter -std=c++0x
|
||||
QMAKE_INCDIR += BULLSHIT1 @srcdir@/.. BULLSHIT2 .. BULLSHIT3
|
||||
INCLUDEPATH += BULLSHIT4 .. BULLSHIT5
|
||||
QMAKE_CXXFLAGS += -IBULLSHIT6 -I.. -IBULLSHIT7
|
||||
|
||||
unix {
|
||||
!macx {
|
||||
CONFIG += debug
|
||||
QMAKE_INCDIR += /usr/include/PCSC
|
||||
QMAKE_INCDIR += /usr/local/include/PCSC
|
||||
QMAKE_LIBS += -lpcsclite -lproxy
|
||||
}
|
||||
}
|
||||
macx {
|
||||
QMAKE_INCDIR += /opt/local/include
|
||||
QMAKE_LIBDIR += /opt/local/lib
|
||||
QMAKE_LFLAGS += -F/System/Library/Frameworks/PCSC.framework
|
||||
LIBS += -framework PCSC
|
||||
QMAKE_INCDIR += /System/Library/Frameworks/PCSC.framework/Headers
|
||||
QMAKE_INFO_PLIST = Info.plist
|
||||
CONFIG += x86
|
||||
}
|
||||
win32 {
|
||||
QMAKE_LIBS += -lwinhttp -lgdi32 -lws2_32
|
||||
QMAKE_LIBS += /opt/local/i586-mingw32msvc/lib/winscard.a
|
||||
CONFIG += release
|
||||
}
|
||||
ICON = swissbrowser.icns
|
||||
|
||||
TRANSLATIONS = @srcdir@/qbrowserlib_en.ts \
|
||||
@srcdir@/qbrowserlib_de.ts \
|
||||
@srcdir@/qbrowserlib_fr.ts \
|
||||
@srcdir@/qbrowserlib_it.ts
|
||||
|
||||
SOURCES =
|
||||
|
||||
HEADERS = @srcdir@/webview.hxx @srcdir@/webpage.hxx \
|
||||
@srcdir@/pluginfactory.hxx @srcdir@/saveorrun.hxx
|
||||
|
||||
FORMS = @srcdir@/saveorrun.ui
|
||||
|
||||
RESOURCES = languages.qrc
|
||||
|
||||
TEMPLATE=lib
|
||||
TARGET = qbrowserlib
|
||||
|
||||
CODECFORSRC = UTF-8
|
||||
CODECFORTR = UTF-8
|
||||
|
||||
DEFINES += VERSION=\'\"@VERSION@\"\' BUILDDATE=\'\"@BUILDDATE@\"\'
|
||||
|
||||
## DEBUG
|
||||
# QMAKE_CXXFLAGS += -include iostream -D\"CRYPTOKI_LOG(X)=std::clog<<\\\"CRYPTOKI_\\\"<<X<<\\\"_@_\\\"<<__PRETTY_FUNCTION__<<std::endl\" -D\"PCSC_LOG(X)=std::clog<<\\\"PCSC_\\\"<<X<<\\\"_@_\\\"<<__PRETTY_FUNCTION__<<std::endl\" -D\"OPENSSL_LOG(X)=std::clog<<\\\"OPENSSL_\\\"<<X<<\\\"_@_\\\"<<__PRETTY_FUNCTION__<<std::endl'" @CPPFLAGS@ @CXXFLAGS@
|
209
src/qbrowserlib/saveorrun.hxx
Normal file
209
src/qbrowserlib/saveorrun.hxx
Normal file
@@ -0,0 +1,209 @@
|
||||
/*! @file
|
||||
|
||||
@id $Id$
|
||||
*/
|
||||
// 1 2 3 4 5 6 7 8
|
||||
// 45678901234567890123456789012345678901234567890123456789012345678901234567890
|
||||
|
||||
#ifndef __SAVEORRUN_HXX__
|
||||
#define __SAVEORRUN_HXX__
|
||||
|
||||
#include <qbrowserlib/ui_saveorrun.h>
|
||||
|
||||
#include <QtCore/QUrl>
|
||||
#include <QtGui/QDialog>
|
||||
#include <QtGui/QFileDialog>
|
||||
#include <QtGui/QFileSystemModel>
|
||||
#include <QtGui/QMessageBox>
|
||||
#include <memory>
|
||||
|
||||
#include <cassert>
|
||||
#include <QtCore/QDebug>
|
||||
#ifndef LOG
|
||||
#define LOG qDebug()<<__PRETTY_FUNCTION__
|
||||
#endif
|
||||
|
||||
class SaveOrRun: public QWidget, public Ui::SaveOrRun {
|
||||
Q_OBJECT;
|
||||
|
||||
Q_SIGNALS:
|
||||
|
||||
void save();
|
||||
void run();
|
||||
|
||||
public:
|
||||
|
||||
SaveOrRun(QWidget* p=0): QWidget(p) {
|
||||
LOG;
|
||||
setupUi(this);
|
||||
_filename->setText(savePath()+QDir::separator());
|
||||
_program->setText(QCoreApplication::applicationDirPath()
|
||||
+QDir::separator());
|
||||
}
|
||||
|
||||
void setup(QString obj, QString type, QString src) {
|
||||
LOG;
|
||||
_object->setText(obj);
|
||||
_type->setText(type);
|
||||
_source->setText(src);
|
||||
_filename->setText(savePath()+QDir::separator()+obj);
|
||||
}
|
||||
|
||||
QString filename() {
|
||||
LOG;
|
||||
return _filename->text();
|
||||
}
|
||||
|
||||
QString program() {
|
||||
LOG;
|
||||
return _program->text();
|
||||
}
|
||||
|
||||
protected Q_SLOTS:
|
||||
|
||||
void on__saveFileAs_clicked(bool=true) {
|
||||
LOG;
|
||||
if ((QFileInfo(filename()).exists()
|
||||
&& QMessageBox::question(this, tr("File Exists"),
|
||||
tr("File already exists:\n\n"
|
||||
"%1\n\n"
|
||||
"Overwrite?").arg(filename()),
|
||||
QMessageBox::Yes|QMessageBox::No)
|
||||
== QMessageBox::No)
|
||||
|| filename().size()==0)
|
||||
return; // reject
|
||||
save();
|
||||
}
|
||||
|
||||
void on__openFileIn_clicked(bool=true) {
|
||||
LOG;
|
||||
if ((!QFile::exists(program())
|
||||
|| !QFileInfo(program()).isExecutable()
|
||||
|| QFileInfo(program()).isDir())
|
||||
|| program().size()==0)
|
||||
return; // reject
|
||||
run();
|
||||
}
|
||||
|
||||
void on__browseSaveAs_clicked(bool) {
|
||||
LOG;
|
||||
QString saveFile
|
||||
(QFileDialog::getSaveFileName(this, tr("Save File As ..."),
|
||||
_filename->text(), QString(), 0,
|
||||
QFileDialog::DontConfirmOverwrite));
|
||||
if (!saveFile.size()) return;
|
||||
if (QFileInfo(saveFile).isDir())
|
||||
saveFile += QDir::separator()+_object->text();
|
||||
_filename->setText(saveFile);
|
||||
on__saveFileAs_clicked();
|
||||
}
|
||||
|
||||
void on__browseOpenWith_clicked(bool) {
|
||||
LOG;
|
||||
QString openFile
|
||||
(QFileDialog::getOpenFileName(this, tr("Open File With ..."),
|
||||
_program->text()));
|
||||
if (!openFile.size()) return;
|
||||
_program->setText(openFile);
|
||||
on__openFileIn_clicked();
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
QString savePath() {
|
||||
LOG;
|
||||
QString path(QDir::homePath());
|
||||
QStringList defpaths;
|
||||
defpaths<<"downloads"<<"Downloads"<<"Documents"
|
||||
<<tr("Dokumente", "Documents folder in local language")
|
||||
<<"Desktop"
|
||||
<<tr("Arbeitsfläche", "Desktop folder in local language");
|
||||
for (QStringList::iterator it(defpaths.begin()); it!=defpaths.end(); ++it)
|
||||
if (QFile::exists(QDir::homePath()+QDir::separator()+*it)) {
|
||||
path = QDir::homePath()+QDir::separator()+*it;
|
||||
break;
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
private:
|
||||
friend class SaveOrRunDialog;
|
||||
};
|
||||
|
||||
class SaveOrRunPlugin: public SaveOrRun {
|
||||
Q_OBJECT;
|
||||
|
||||
public:
|
||||
|
||||
SaveOrRunPlugin(const QUrl& url, const QString& mime,
|
||||
bool kiosk=false, QWidget* p=0):
|
||||
SaveOrRun(p) {
|
||||
LOG;
|
||||
setAutoFillBackground(true);
|
||||
_type->setText(mime);
|
||||
_source->setText(url.host());
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class SaveOrRunDialog: public QDialog {
|
||||
Q_OBJECT;
|
||||
|
||||
public:
|
||||
|
||||
SaveOrRunDialog(bool kiosk=false, QWidget* p=0):
|
||||
QDialog(p), _action(UNDEFINED), _sor(new SaveOrRun) {
|
||||
LOG;
|
||||
QVBoxLayout* l(new QVBoxLayout(this));
|
||||
l->addWidget(_sor);
|
||||
assert(connect(_sor, SIGNAL(save()), SLOT(doSave())));
|
||||
assert(connect(_sor, SIGNAL(run()), SLOT(doRun())));
|
||||
assert(connect(_sor->_buttons, SIGNAL(rejected()), SLOT(reject())));
|
||||
}
|
||||
|
||||
void setup(QString obj, QString type, QString src) {
|
||||
_sor->setup(obj, type, src);
|
||||
}
|
||||
|
||||
bool save() {
|
||||
LOG;
|
||||
return _action==SAVE;
|
||||
}
|
||||
|
||||
bool run() {
|
||||
LOG;
|
||||
return _action==RUN;
|
||||
}
|
||||
|
||||
SaveOrRun* sor() {
|
||||
LOG;
|
||||
return _sor;
|
||||
}
|
||||
|
||||
public Q_SLOTS:
|
||||
|
||||
void doSave() {
|
||||
LOG;
|
||||
_action = SAVE;
|
||||
accept();
|
||||
}
|
||||
|
||||
void doRun() {
|
||||
LOG;
|
||||
_action = RUN;
|
||||
accept();
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
enum Action {
|
||||
SAVE,
|
||||
RUN,
|
||||
UNDEFINED
|
||||
} _action;
|
||||
|
||||
SaveOrRun* _sor;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
277
src/qbrowserlib/saveorrun.ui
Normal file
277
src/qbrowserlib/saveorrun.ui
Normal file
@@ -0,0 +1,277 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>SaveOrRun</class>
|
||||
<widget class="QWidget" name="SaveOrRun">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>670</width>
|
||||
<height>294</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Download</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>File:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="_object">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Type:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="_type">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Source</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLabel" name="_source">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Save File</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0" rowspan="2">
|
||||
<widget class="QCommandLinkButton" name="_saveFileAs">
|
||||
<property name="text">
|
||||
<string>Save File As:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="_filename"/>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QPushButton" name="_browseSaveAs">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>browse ...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" colspan="2">
|
||||
<widget class="QCheckBox" name="checkBox_2">
|
||||
<property name="text">
|
||||
<string>remember save path</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Open in External Application</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0" rowspan="2">
|
||||
<widget class="QCommandLinkButton" name="_openFileIn">
|
||||
<property name="text">
|
||||
<string>Open File in:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="_program">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QPushButton" name="_browseOpenWith">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>browse ...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" colspan="2">
|
||||
<widget class="QCheckBox" name="checkBox">
|
||||
<property name="text">
|
||||
<string>remember tool for this type</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="_buttons">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel</set>
|
||||
</property>
|
||||
<property name="centerButtons">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>_filename</sender>
|
||||
<signal>returnPressed()</signal>
|
||||
<receiver>_saveFileAs</receiver>
|
||||
<slot>click()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>371</x>
|
||||
<y>113</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>94</x>
|
||||
<y>126</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>_program</sender>
|
||||
<signal>returnPressed()</signal>
|
||||
<receiver>_openFileIn</receiver>
|
||||
<slot>click()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>371</x>
|
||||
<y>207</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>94</x>
|
||||
<y>220</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
53
src/qbrowserlib/webpage.hxx
Normal file
53
src/qbrowserlib/webpage.hxx
Normal file
@@ -0,0 +1,53 @@
|
||||
/*! @file
|
||||
|
||||
@id $Id$
|
||||
*/
|
||||
// 1 2 3 4 5 6 7 8
|
||||
// 45678901234567890123456789012345678901234567890123456789012345678901234567890
|
||||
|
||||
#ifndef __WEBPAGE_HXX__
|
||||
#define __WEBPAGE_HXX__
|
||||
|
||||
#include <QtWebKit/QWebPage>
|
||||
#include <QtCore/QProcessEnvironment>
|
||||
|
||||
#include <QtCore/QDebug>
|
||||
#ifndef LOG
|
||||
#define LOG qDebug()<<__PRETTY_FUNCTION__
|
||||
#endif
|
||||
|
||||
class WebPage: public QWebPage {
|
||||
Q_OBJECT;
|
||||
signals:
|
||||
void newPage(WebPage*);
|
||||
public:
|
||||
WebPage(QObject *parent = 0): QWebPage(parent) {}
|
||||
protected:
|
||||
virtual QWebPage* createWindow(WebWindowType type) {
|
||||
switch (type) {
|
||||
case QWebPage::WebBrowserWindow:
|
||||
case QWebPage::WebModalDialog: {
|
||||
WebPage *page(new WebPage);
|
||||
newPage(page);
|
||||
return page;
|
||||
} break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
virtual QString userAgentForUrl(const QUrl& url) const {
|
||||
QString add(QProcessEnvironment::systemEnvironment()
|
||||
.value("SWISSSURFER_USERAGENT"));
|
||||
return QWebPage::userAgentForUrl(url)+(add.size()?" "+add:QString());
|
||||
}
|
||||
QObject* createPlugin(const QString& classid, const QUrl& url,
|
||||
const QStringList& paramNames,
|
||||
const QStringList& paramValues) {
|
||||
LOG<<"classid:"<<classid
|
||||
<<"url:"<<url
|
||||
<<"paramNames:"<<paramNames.join(", ")
|
||||
<<"paramValues:"<<paramValues.join(", ");
|
||||
return QWebPage::createPlugin(classid, url, paramNames, paramValues);
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
48
src/qbrowserlib/webview.hxx
Normal file
48
src/qbrowserlib/webview.hxx
Normal file
@@ -0,0 +1,48 @@
|
||||
/*! @file
|
||||
|
||||
@id $Id$
|
||||
*/
|
||||
// 1 2 3 4 5 6 7 8
|
||||
// 45678901234567890123456789012345678901234567890123456789012345678901234567890
|
||||
|
||||
#ifndef WEBVIEW_HXX
|
||||
#define WEBVIEW_HXX
|
||||
|
||||
#include <qbrowserlib/webpage.hxx>
|
||||
#include <qbrowserlib/pluginfactory.hxx>
|
||||
|
||||
#include <QtWebKit>
|
||||
|
||||
#include <memory>
|
||||
|
||||
class WebView: public QWebView {
|
||||
Q_OBJECT;
|
||||
signals:
|
||||
void newView(WebView*);
|
||||
public:
|
||||
WebView(WebPage* webpage) {
|
||||
x(webpage); //! @bugfix, gcc does not yet support constructor calling
|
||||
}
|
||||
WebView(QWidget *parent=0): QWebView(parent) {
|
||||
x(new WebPage); //! @bugfix, gcc does not yet support constructor calling
|
||||
}
|
||||
private:
|
||||
//! @bugfix, gcc does not yet support constructor calling
|
||||
/*! @see http://en.wikipedia.org/wiki/C++11#Object_construction_improvement
|
||||
*/
|
||||
void x(WebPage* webpage) {
|
||||
webpage->setParent(this);
|
||||
setPage(webpage);
|
||||
page()->setPluginFactory(new PluginFactory);
|
||||
page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
|
||||
page()->setForwardUnsupportedContent(true);
|
||||
assert(connect(page(), SIGNAL(newPage(WebPage*)),
|
||||
SLOT(newPage(WebPage*))));
|
||||
}
|
||||
private slots:
|
||||
void newPage(WebPage* p) {
|
||||
newView(new WebView(p));
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user