Transfer from old project
This commit is contained in:
parent
3e406c67db
commit
c5ef6a6982
6 changed files with 261 additions and 34 deletions
|
@ -14,12 +14,18 @@ TARGET = harbour-seaprint
|
|||
|
||||
CONFIG += sailfishapp
|
||||
|
||||
SOURCES += src/harbour-seaprint.cpp
|
||||
SOURCES += src/harbour-seaprint.cpp \
|
||||
src/ippdiscovery.cpp \
|
||||
src/bytestream.cpp \
|
||||
src/ippmsg.cpp \
|
||||
src/ippprinter.cpp
|
||||
|
||||
|
||||
DISTFILES += qml/harbour-seaprint.qml \
|
||||
qml/cover/CoverPage.qml \
|
||||
qml/pages/FirstPage.qml \
|
||||
qml/pages/SecondPage.qml \
|
||||
qml/pages/*.qml \
|
||||
qml/pages/utils.js \
|
||||
qml/pages/printer.svg \
|
||||
rpm/harbour-seaprint.changes.in \
|
||||
rpm/harbour-seaprint.changes.run.in \
|
||||
rpm/harbour-seaprint.spec \
|
||||
|
@ -38,3 +44,9 @@ CONFIG += sailfishapp_i18n
|
|||
# following TRANSLATIONS line. And also do not forget to
|
||||
# modify the localized app name in the the .desktop file.
|
||||
TRANSLATIONS += translations/harbour-seaprint-de.ts
|
||||
|
||||
HEADERS += \
|
||||
src/ippdiscovery.h \
|
||||
src/bytestream.h \
|
||||
src/ippmsg.h \
|
||||
src/ippprinter.h
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
import QtQuick 2.0
|
||||
import Sailfish.Silica 1.0
|
||||
import QtQuick.LocalStorage 2.0
|
||||
import Nemo.Notifications 1.0
|
||||
import "pages"
|
||||
|
||||
ApplicationWindow
|
||||
|
@ -7,4 +9,49 @@ ApplicationWindow
|
|||
initialPage: Component { FirstPage { } }
|
||||
cover: Qt.resolvedUrl("cover/CoverPage.qml")
|
||||
allowedOrientations: defaultAllowedOrientations
|
||||
|
||||
Item {
|
||||
id: db
|
||||
property var db_conn
|
||||
|
||||
Component.onCompleted: {
|
||||
db_conn = LocalStorage.openDatabaseSync("TintDB", "1.0", "Tint storage", 100000)
|
||||
db_conn.transaction(function (tx) {
|
||||
tx.executeSql('CREATE TABLE IF NOT EXISTS Favourites (url STRING UNIQUE)');
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function addFavourite(url) {
|
||||
db_conn.transaction(function (tx) {
|
||||
tx.executeSql('REPLACE INTO Favourites VALUES(?)', [url] );
|
||||
});
|
||||
}
|
||||
|
||||
function getFavourites() {
|
||||
var favs = [];
|
||||
db_conn.transaction(function (tx) {
|
||||
var res = tx.executeSql('SELECT * FROM Favourites');
|
||||
if (res.rows.length !== 0) {
|
||||
console.log(res.rows.item(0).url)
|
||||
favs.push(res.rows.item(0).url);
|
||||
}
|
||||
});
|
||||
return favs
|
||||
}
|
||||
}
|
||||
|
||||
Notification {
|
||||
id: notifier
|
||||
|
||||
expireTimeout: 4000
|
||||
|
||||
function notify(data) {
|
||||
console.log("notifyMessage", data)
|
||||
body = data
|
||||
previewBody = data
|
||||
publish()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,32 @@
|
|||
import QtQuick 2.0
|
||||
import Sailfish.Silica 1.0
|
||||
import Sailfish.Pickers 1.0
|
||||
import seaprint.ippdiscovery 1.0
|
||||
import seaprint.ippprinter 1.0
|
||||
import "utils.js" as Utils
|
||||
import Nemo.DBus 2.0
|
||||
|
||||
Page {
|
||||
id: page
|
||||
|
||||
// The effective value will be restricted by ApplicationWindow.allowedOrientations
|
||||
allowedOrientations: Orientation.All
|
||||
|
||||
property string selectedFile: "/home/nemo/Downloads/1.pdf"
|
||||
|
||||
IppDiscovery {
|
||||
id: discovery
|
||||
}
|
||||
|
||||
DBusAdaptor {
|
||||
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
discovery.discover();
|
||||
var favourites = db.getFavourites();
|
||||
console.log(favourites);
|
||||
discovery.favourites = favourites;
|
||||
}
|
||||
|
||||
// To enable PullDownMenu, place our content in a SilicaFlickable
|
||||
SilicaFlickable {
|
||||
anchors.fill: parent
|
||||
|
@ -14,29 +34,126 @@ Page {
|
|||
// PullDownMenu and PushUpMenu must be declared in SilicaFlickable, SilicaListView or SilicaGridView
|
||||
PullDownMenu {
|
||||
MenuItem {
|
||||
text: qsTr("Show Page 2")
|
||||
onClicked: pageStack.push(Qt.resolvedUrl("SecondPage.qml"))
|
||||
text: qsTr("Add by URL")
|
||||
onClicked: {var dialog = pageStack.push(Qt.resolvedUrl("InputDialog.qml"),
|
||||
{value: qsTr("Add favourite"), title: qsTr("URL")});
|
||||
dialog.accepted.connect(function() {
|
||||
db.addFavourite(dialog.value);
|
||||
discovery.insert(dialog.value);
|
||||
})
|
||||
}
|
||||
}
|
||||
MenuItem {
|
||||
text: qsTr("Refresh")
|
||||
onClicked: discovery.discover()
|
||||
}
|
||||
}
|
||||
|
||||
// Tell SilicaFlickable the height of its content.
|
||||
contentHeight: column.height
|
||||
SilicaListView {
|
||||
anchors.fill: parent
|
||||
id: listView
|
||||
model: discovery
|
||||
spacing: Theme.paddingSmall
|
||||
|
||||
// Place our content in a Column. The PageHeader is always placed at the top
|
||||
// of the page, followed by our content.
|
||||
Column {
|
||||
id: column
|
||||
|
||||
width: page.width
|
||||
spacing: Theme.paddingLarge
|
||||
PageHeader {
|
||||
title: qsTr("UI Template")
|
||||
delegate: BackgroundItem {
|
||||
id: delegate
|
||||
height: visible ? Math.max(column.implicitHeight, Theme.itemSizeLarge+2*Theme.paddingMedium) : 0
|
||||
visible: printer.attrs["printer-name"] ? true : false
|
||||
enabled: Utils.can_print(printer, selectedFile)
|
||||
onClicked: {
|
||||
if(selectedFile != "")
|
||||
{
|
||||
pageStack.push(Qt.resolvedUrl("PrinterPage.qml"), {printer: printer, selectedFile: selectedFile})
|
||||
}
|
||||
else
|
||||
{
|
||||
notifier.notify(qsTr("No file selected"))
|
||||
}
|
||||
}
|
||||
|
||||
IppPrinter {
|
||||
id: printer
|
||||
url: model.display
|
||||
}
|
||||
|
||||
Image {
|
||||
id: icon
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
anchors.topMargin: Theme.paddingMedium
|
||||
anchors.leftMargin: Theme.paddingMedium
|
||||
|
||||
height: Theme.itemSizeLarge
|
||||
width: Theme.itemSizeLarge
|
||||
source: printer.attrs["printer-icons"] ? printer.attrs["printer-icons"].value[0] : "printer.svg"
|
||||
// Some printers serve their icons over https with invalid certs...
|
||||
onStatusChanged: if (status == Image.Error) source = "printer.svg"
|
||||
}
|
||||
|
||||
Column {
|
||||
id: column
|
||||
anchors.left: icon.right
|
||||
anchors.leftMargin: Theme.paddingMedium
|
||||
|
||||
Label {
|
||||
id: name_label
|
||||
color: delegate.enabled ? Theme.primaryColor : Theme.secondaryColor
|
||||
text: printer.attrs["printer-name"].value
|
||||
}
|
||||
|
||||
Label {
|
||||
id: mm_label
|
||||
color: delegate.enabled ? Theme.primaryColor : Theme.secondaryColor
|
||||
font.pixelSize: Theme.fontSizeExtraSmall
|
||||
text: printer.attrs["printer-make-and-model"].value
|
||||
}
|
||||
|
||||
Label {
|
||||
id: uri_label
|
||||
color: Theme.secondaryColor
|
||||
font.pixelSize: Theme.fontSizeTiny
|
||||
text: model.display
|
||||
}
|
||||
|
||||
Label {
|
||||
id: format_label
|
||||
color: delegate.enabled ? Theme.primaryColor : "red"
|
||||
font.pixelSize: Theme.fontSizeExtraSmall
|
||||
text: Utils.supported_formats(printer)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Label {
|
||||
x: Theme.horizontalPageMargin
|
||||
text: qsTr("Hello Sailors")
|
||||
color: Theme.secondaryHighlightColor
|
||||
font.pixelSize: Theme.fontSizeExtraLarge
|
||||
onCountChanged: {
|
||||
console.log("count", count)
|
||||
}
|
||||
}
|
||||
}
|
||||
DockedPanel {
|
||||
id: fileDock
|
||||
open: true
|
||||
height: fileButton.height*2
|
||||
width: parent.width
|
||||
dock: Dock.Bottom
|
||||
|
||||
ValueButton {
|
||||
id: fileButton
|
||||
width: parent.width
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
label: qsTr("Choose file")
|
||||
value: selectedFile != "" ? selectedFile : qsTr("None")
|
||||
onClicked: pageStack.push(filePickerPage)
|
||||
}
|
||||
Component {
|
||||
id: filePickerPage
|
||||
FilePickerPage {
|
||||
title: fileButton.label
|
||||
nameFilters: ["*.pdf", "*.jpg", "*.jpeg"]
|
||||
|
||||
onSelectedContentPropertiesChanged: {
|
||||
page.selectedFile = selectedContentProperties.filePath
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,10 +3,15 @@
|
|||
#endif
|
||||
|
||||
#include <sailfishapp.h>
|
||||
#include <src/ippdiscovery.h>
|
||||
#include <src/ippprinter.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
// SailfishApp::main() will display "qml/harbour-seaprint.qml", if you need more
|
||||
qmlRegisterType<IppDiscovery>("seaprint.ippdiscovery", 1, 0, "IppDiscovery");
|
||||
qmlRegisterType<IppPrinter>("seaprint.ippprinter", 1, 0, "IppPrinter");
|
||||
|
||||
// SailfishApp::main() will display "qml/harbour-printtool.qml", if you need more
|
||||
// control over initialization, you can use:
|
||||
//
|
||||
// - SailfishApp::application(int, char *[]) to get the QGuiApplication *
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.0">
|
||||
<TS version="2.1">
|
||||
<context>
|
||||
<name>CoverPage</name>
|
||||
<message>
|
||||
|
@ -11,16 +11,39 @@
|
|||
<context>
|
||||
<name>FirstPage</name>
|
||||
<message>
|
||||
<source>Show Page 2</source>
|
||||
<translation>Zur Seite 2</translation>
|
||||
<source>Add by URL</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>UI Template</source>
|
||||
<translation>UI-Vorlage</translation>
|
||||
<source>Add favourite</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Hello Sailors</source>
|
||||
<translation>Hallo Matrosen</translation>
|
||||
<source>URL</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Refresh</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>No file selected</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Choose file</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>None</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>PrinterPage</name>
|
||||
<message>
|
||||
<source>Print</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.0">
|
||||
<TS version="2.1">
|
||||
<context>
|
||||
<name>CoverPage</name>
|
||||
<message>
|
||||
|
@ -11,15 +11,38 @@
|
|||
<context>
|
||||
<name>FirstPage</name>
|
||||
<message>
|
||||
<source>Show Page 2</source>
|
||||
<source>Add by URL</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>UI Template</source>
|
||||
<source>Add favourite</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Hello Sailors</source>
|
||||
<source>URL</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Refresh</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>No file selected</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Choose file</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>None</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>PrinterPage</name>
|
||||
<message>
|
||||
<source>Print</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
|
|
Loading…
Reference in a new issue