Add ConvertChecker
This commit is contained in:
parent
aa6daa1d77
commit
16e6d8d766
12 changed files with 189 additions and 7 deletions
|
@ -22,6 +22,7 @@ VERSION_H = \
|
|||
write_file($$$$OUT_PWD/seaprint_version.h, VERSION_H)
|
||||
|
||||
SOURCES += src/harbour-seaprint.cpp \
|
||||
src/convertchecker.cpp \
|
||||
src/convertworker.cpp \
|
||||
src/ippdiscovery.cpp \
|
||||
src/ippmsg.cpp \
|
||||
|
@ -61,6 +62,7 @@ TRANSLATIONS += translations/harbour-seaprint-de.ts \
|
|||
translations/harbour-seaprint-es.ts
|
||||
|
||||
HEADERS += \
|
||||
src/convertchecker.h \
|
||||
src/convertworker.h \
|
||||
src/ippdiscovery.h \
|
||||
src/ippmsg.h \
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import QtQuick 2.0
|
||||
import Sailfish.Silica 1.0
|
||||
import seaprint.convertchecker 1.0
|
||||
import "../components"
|
||||
|
||||
Page {
|
||||
|
@ -90,7 +91,15 @@ Page {
|
|||
font.pixelSize: Theme.fontSizeSmall
|
||||
text: qsTr("Chinese")+" - dashinfantry\n"+
|
||||
qsTr("French")+" - ensag-dev, Quentí\n"+
|
||||
qsTr("Spanish")+" - carmenfdezb"
|
||||
qsTr("Spanish")+" - carmenfdezb\n"+
|
||||
qsTr("Polish")+" - atlochowski"
|
||||
}
|
||||
|
||||
SectionHeader { text: qsTr("Optional dependencies") }
|
||||
|
||||
AboutLabel {
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
text: qsTr("pdftoppm (from poppler-utils)")+" - "+(ConvertChecker.pdf ? qsTr("Installed") : qsTr("Not installed"))
|
||||
}
|
||||
|
||||
SectionHeader { text: qsTr("Licensing") }
|
||||
|
|
|
@ -2,6 +2,7 @@ import QtQuick 2.0
|
|||
import Sailfish.Silica 1.0
|
||||
import Sailfish.Pickers 1.0
|
||||
import seaprint.ippdiscovery 1.0
|
||||
import seaprint.convertchecker 1.0
|
||||
import seaprint.ippprinter 1.0
|
||||
import seaprint.mimer 1.0
|
||||
import "utils.js" as Utils
|
||||
|
@ -45,6 +46,7 @@ Page {
|
|||
signal refreshed()
|
||||
|
||||
Component.onCompleted: {
|
||||
console.log("Can convert from PDF:", ConvertChecker.pdf)
|
||||
IppDiscovery.discover();
|
||||
if(selectedFile != "")
|
||||
{
|
||||
|
@ -100,7 +102,7 @@ Page {
|
|||
visible: false
|
||||
|
||||
property string name: printer.attrs["printer-name"].value != "" ? printer.attrs["printer-name"].value : qsTr("Unknown")
|
||||
property bool canPrint: Utils.supported_formats(printer).mimetypes.indexOf(selectedFileType) != -1
|
||||
property bool canPrint: Utils.supported_formats(printer, ConvertChecker).mimetypes.indexOf(selectedFileType) != -1
|
||||
|
||||
Connections {
|
||||
target: printer
|
||||
|
@ -137,7 +139,8 @@ Page {
|
|||
property int debugCount: 0
|
||||
|
||||
onClicked: {
|
||||
console.log(Utils.supported_formats(printer).mimetypes, selectedFileType, Utils.supported_formats(printer).mimetypes.indexOf(selectedFileType) != -1)
|
||||
console.log(Utils.supported_formats(printer, ConvertChecker).mimetypes, selectedFileType,
|
||||
Utils.supported_formats(printer, ConvertChecker).mimetypes.indexOf(selectedFileType) != -1)
|
||||
|
||||
if(++debugCount == 5)
|
||||
{
|
||||
|
@ -215,14 +218,14 @@ Page {
|
|||
id: format_label
|
||||
color: selectedFile == "" ? Theme.secondaryColor : canPrint ? Theme.primaryColor : "red"
|
||||
font.pixelSize: Theme.fontSizeExtraSmall
|
||||
text: Utils.supported_formats(printer).supported
|
||||
text: Utils.supported_formats(printer, ConvertChecker).supported
|
||||
}
|
||||
Label {
|
||||
id: maybe_format_label
|
||||
color: selectedFile == "" ? Theme.secondaryColor : canPrint ? Theme.secondaryColor : "red"
|
||||
font.pixelSize: Theme.fontSizeExtraSmall
|
||||
font.italic: true
|
||||
text: Utils.supported_formats(printer).maybe
|
||||
text: Utils.supported_formats(printer, ConvertChecker).maybe
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
function supported_formats(printer)
|
||||
function supported_formats(printer, ConvertChecker)
|
||||
{
|
||||
var formats = printer.attrs["document-format-supported"].value;
|
||||
var mimetypes = [];
|
||||
var supported = [];
|
||||
if(has(formats, "application/pdf") || has(formats, "image/pwg-raster") || has(formats, "image/urf") )
|
||||
if(has(formats, "application/pdf") || (ConvertChecker.pdf && ( has(formats, "image/pwg-raster") || has(formats, "image/urf"))) )
|
||||
{
|
||||
mimetypes.push("application/pdf");
|
||||
supported.push("PDF");
|
||||
|
|
40
src/convertchecker.cpp
Normal file
40
src/convertchecker.cpp
Normal file
|
@ -0,0 +1,40 @@
|
|||
#include "convertchecker.h"
|
||||
#include <QProcess>
|
||||
|
||||
ConvertChecker::ConvertChecker()
|
||||
{
|
||||
_pdf = false;
|
||||
QProcess* pdftoppm = new QProcess(this);
|
||||
pdftoppm->setProgram("pdftoppm");
|
||||
pdftoppm->setArguments({"-h"});
|
||||
pdftoppm->start();
|
||||
if(pdftoppm->waitForFinished(2000))
|
||||
{
|
||||
if(pdftoppm->exitStatus() == QProcess::NormalExit && pdftoppm->exitCode() == 0)
|
||||
{
|
||||
_pdf = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ConvertChecker::~ConvertChecker() {
|
||||
|
||||
}
|
||||
|
||||
ConvertChecker* ConvertChecker::m_Instance = 0;
|
||||
|
||||
ConvertChecker* ConvertChecker::instance()
|
||||
{
|
||||
static QMutex mutex;
|
||||
if (!m_Instance)
|
||||
{
|
||||
mutex.lock();
|
||||
|
||||
if (!m_Instance)
|
||||
m_Instance = new ConvertChecker;
|
||||
|
||||
mutex.unlock();
|
||||
}
|
||||
|
||||
return m_Instance;
|
||||
}
|
26
src/convertchecker.h
Normal file
26
src/convertchecker.h
Normal file
|
@ -0,0 +1,26 @@
|
|||
#ifndef CONVERTCHECKER_H
|
||||
#define CONVERTCHECKER_H
|
||||
#include <QObject>
|
||||
#include <QMutex>
|
||||
|
||||
class ConvertChecker : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
static ConvertChecker* instance();
|
||||
Q_PROPERTY(bool pdf MEMBER _pdf)
|
||||
|
||||
signals:
|
||||
protected:
|
||||
private:
|
||||
static ConvertChecker* m_Instance;
|
||||
|
||||
ConvertChecker();
|
||||
~ConvertChecker();
|
||||
ConvertChecker(const ConvertChecker &);
|
||||
ConvertChecker& operator=(const ConvertChecker &);
|
||||
|
||||
bool _pdf;
|
||||
};
|
||||
|
||||
#endif // CONVERTCHECKER_H
|
|
@ -5,6 +5,7 @@
|
|||
#include <src/ippdiscovery.h>
|
||||
#include <src/ippprinter.h>
|
||||
#include <src/mimer.h>
|
||||
#include <src/convertchecker.h>
|
||||
|
||||
#define PPM2PWG_MAIN ppm2pwg_main
|
||||
#include <ppm2pwg/ppm2pwg.cpp>
|
||||
|
@ -34,6 +35,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
qmlRegisterSingletonType<IppDiscovery>("seaprint.ippdiscovery", 1, 0, "IppDiscovery", singletontype_provider<IppDiscovery>);
|
||||
qmlRegisterSingletonType<Mimer>("seaprint.mimer", 1, 0, "Mimer", singletontype_provider<Mimer>);
|
||||
qmlRegisterSingletonType<ConvertChecker>("seaprint.convertchecker", 1, 0, "ConvertChecker", singletontype_provider<ConvertChecker>);
|
||||
qmlRegisterType<IppPrinter>("seaprint.ippprinter", 1, 0, "IppPrinter");
|
||||
|
||||
QQuickView* view = SailfishApp::createView();
|
||||
|
|
|
@ -63,6 +63,26 @@
|
|||
<source>Spanish</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Polish</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Optional dependencies</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>pdftoppm (from poppler-utils)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Installed</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Not installed</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>AddPrinterDialog</name>
|
||||
|
|
|
@ -63,6 +63,26 @@
|
|||
<source>Spanish</source>
|
||||
<translation>Español</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Polish</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Optional dependencies</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>pdftoppm (from poppler-utils)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Installed</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Not installed</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>AddPrinterDialog</name>
|
||||
|
|
|
@ -63,6 +63,26 @@
|
|||
<source>Spanish</source>
|
||||
<translation>Espagnol</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Polish</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Optional dependencies</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>pdftoppm (from poppler-utils)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Installed</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Not installed</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>AddPrinterDialog</name>
|
||||
|
|
|
@ -63,6 +63,26 @@
|
|||
<source>Spanish</source>
|
||||
<translation>西班牙语</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Polish</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Optional dependencies</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>pdftoppm (from poppler-utils)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Installed</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Not installed</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>AddPrinterDialog</name>
|
||||
|
|
|
@ -63,6 +63,26 @@
|
|||
<source>Spanish</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Polish</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Optional dependencies</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>pdftoppm (from poppler-utils)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Installed</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Not installed</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>AddPrinterDialog</name>
|
||||
|
|
Loading…
Reference in a new issue