Make settings accessible directly from C++
This commit is contained in:
parent
137eb965bf
commit
cb6f836282
10 changed files with 112 additions and 7 deletions
|
@ -27,6 +27,7 @@ system(lrelease $$PWD/translations/*.ts)
|
||||||
|
|
||||||
CONFIG += sailfishapp
|
CONFIG += sailfishapp
|
||||||
QT += svg
|
QT += svg
|
||||||
|
PKGCONFIG += mlite5
|
||||||
|
|
||||||
# Write version file
|
# Write version file
|
||||||
VERSION_H = \
|
VERSION_H = \
|
||||||
|
@ -45,6 +46,7 @@ SOURCES += src/harbour-seaprint.cpp \
|
||||||
ppm2pwg/ppm2pwg.cpp \
|
ppm2pwg/ppm2pwg.cpp \
|
||||||
ppm2pwg/bytestream/bytestream.cpp \
|
ppm2pwg/bytestream/bytestream.cpp \
|
||||||
src/overrider.cpp \
|
src/overrider.cpp \
|
||||||
|
src/settings.cpp \
|
||||||
src/svgprovider.cpp
|
src/svgprovider.cpp
|
||||||
|
|
||||||
DISTFILES += qml/harbour-seaprint.qml \
|
DISTFILES += qml/harbour-seaprint.qml \
|
||||||
|
@ -93,6 +95,7 @@ HEADERS += \
|
||||||
ppm2pwg/bytestream/codable.h \
|
ppm2pwg/bytestream/codable.h \
|
||||||
src/overrider.h \
|
src/overrider.h \
|
||||||
src/papersizes.h \
|
src/papersizes.h \
|
||||||
|
src/settings.h \
|
||||||
src/svgprovider.h
|
src/svgprovider.h
|
||||||
|
|
||||||
INCLUDEPATH += ppm2pwg \
|
INCLUDEPATH += ppm2pwg \
|
||||||
|
|
|
@ -4,6 +4,7 @@ import QtQuick.LocalStorage 2.0
|
||||||
import Nemo.Notifications 1.0
|
import Nemo.Notifications 1.0
|
||||||
import Nemo.Configuration 1.0
|
import Nemo.Configuration 1.0
|
||||||
import seaprint.mimer 1.0
|
import seaprint.mimer 1.0
|
||||||
|
import seaprint.settings 1.0
|
||||||
import "pages"
|
import "pages"
|
||||||
import "components"
|
import "components"
|
||||||
|
|
||||||
|
@ -146,10 +147,14 @@ ApplicationWindow
|
||||||
ConfigurationValue
|
ConfigurationValue
|
||||||
{
|
{
|
||||||
id: alwaysUseMediaColSetting
|
id: alwaysUseMediaColSetting
|
||||||
key: "/apps/harbour-seaprint/settings/always-use-media-col"
|
key: SeaPrintSettings.alwaysUseMediaColPath
|
||||||
defaultValue: false
|
defaultValue: SeaPrintSettings.alwaysUseMediaColDefault
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Component.onCompleted:
|
||||||
|
{
|
||||||
|
console.log(SeaPrintSettings.ignoreSslErrorsPath, SeaPrintSettings.ignoreSslErrorsDefault)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,8 +63,7 @@ Page {
|
||||||
console.log(JSON.stringify(jobParams))
|
console.log(JSON.stringify(jobParams))
|
||||||
pageStack.replace(Qt.resolvedUrl("BusyPage.qml"),{printer:printer},
|
pageStack.replace(Qt.resolvedUrl("BusyPage.qml"),{printer:printer},
|
||||||
PageStackAction.Immediate)
|
PageStackAction.Immediate)
|
||||||
printer.print(jobParams, page.selectedFile,
|
printer.print(jobParams, page.selectedFile)
|
||||||
alwaysUseMediaColSetting.value)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ BuildRequires: pkgconfig(sailfishapp) >= 1.0.2
|
||||||
BuildRequires: pkgconfig(Qt5Core)
|
BuildRequires: pkgconfig(Qt5Core)
|
||||||
BuildRequires: pkgconfig(Qt5Qml)
|
BuildRequires: pkgconfig(Qt5Qml)
|
||||||
BuildRequires: pkgconfig(Qt5Quick)
|
BuildRequires: pkgconfig(Qt5Quick)
|
||||||
|
BuildRequires: pkgconfig(mlite5)
|
||||||
BuildRequires: desktop-file-utils
|
BuildRequires: desktop-file-utils
|
||||||
|
|
||||||
%description
|
%description
|
||||||
|
|
|
@ -26,6 +26,7 @@ PkgConfigBR:
|
||||||
- Qt5Core
|
- Qt5Core
|
||||||
- Qt5Qml
|
- Qt5Qml
|
||||||
- Qt5Quick
|
- Qt5Quick
|
||||||
|
- mlite5
|
||||||
|
|
||||||
# Build dependencies without a pkgconfig setup can be listed here
|
# Build dependencies without a pkgconfig setup can be listed here
|
||||||
# PkgBR:
|
# PkgBR:
|
||||||
|
@ -33,7 +34,7 @@ PkgConfigBR:
|
||||||
|
|
||||||
# Runtime dependencies which are not automatically detected
|
# Runtime dependencies which are not automatically detected
|
||||||
Requires:
|
Requires:
|
||||||
- sailfishsilica-qt5 >= 0.10.9
|
- sailfishsilica-qt5 >= 0.10.9
|
||||||
|
|
||||||
# All installed files
|
# All installed files
|
||||||
Files:
|
Files:
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include <src/mimer.h>
|
#include <src/mimer.h>
|
||||||
#include <src/convertchecker.h>
|
#include <src/convertchecker.h>
|
||||||
#include <src/svgprovider.h>
|
#include <src/svgprovider.h>
|
||||||
|
#include <src/settings.h>
|
||||||
|
|
||||||
#define PPM2PWG_MAIN ppm2pwg_main
|
#define PPM2PWG_MAIN ppm2pwg_main
|
||||||
#include <ppm2pwg/ppm2pwg.cpp>
|
#include <ppm2pwg/ppm2pwg.cpp>
|
||||||
|
@ -39,6 +40,7 @@ int main(int argc, char *argv[])
|
||||||
qmlRegisterSingletonType<IppDiscovery>("seaprint.ippdiscovery", 1, 0, "IppDiscovery", singletontype_provider<IppDiscovery>);
|
qmlRegisterSingletonType<IppDiscovery>("seaprint.ippdiscovery", 1, 0, "IppDiscovery", singletontype_provider<IppDiscovery>);
|
||||||
qmlRegisterSingletonType<Mimer>("seaprint.mimer", 1, 0, "Mimer", singletontype_provider<Mimer>);
|
qmlRegisterSingletonType<Mimer>("seaprint.mimer", 1, 0, "Mimer", singletontype_provider<Mimer>);
|
||||||
qmlRegisterSingletonType<ConvertChecker>("seaprint.convertchecker", 1, 0, "ConvertChecker", singletontype_provider<ConvertChecker>);
|
qmlRegisterSingletonType<ConvertChecker>("seaprint.convertchecker", 1, 0, "ConvertChecker", singletontype_provider<ConvertChecker>);
|
||||||
|
qmlRegisterSingletonType<ConvertChecker>("seaprint.settings", 1, 0, "SeaPrintSettings", singletontype_provider<Settings>);
|
||||||
qmlRegisterType<IppPrinter>("seaprint.ippprinter", 1, 0, "IppPrinter");
|
qmlRegisterType<IppPrinter>("seaprint.ippprinter", 1, 0, "IppPrinter");
|
||||||
qmlRegisterUncreatableType<IppMsg>("seaprint.ippmsg", 1, 0, "IppMsg", "Only used to supply an enum type");
|
qmlRegisterUncreatableType<IppMsg>("seaprint.ippmsg", 1, 0, "IppMsg", "Only used to supply an enum type");
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include "mimer.h"
|
#include "mimer.h"
|
||||||
#include "papersizes.h"
|
#include "papersizes.h"
|
||||||
#include "overrider.h"
|
#include "overrider.h"
|
||||||
|
#include "settings.h"
|
||||||
|
|
||||||
IppPrinter::IppPrinter()
|
IppPrinter::IppPrinter()
|
||||||
{
|
{
|
||||||
|
@ -339,7 +340,7 @@ QString targetFormatIfAuto(QString documentFormat, QString mimeType, QJsonArray
|
||||||
return documentFormat;
|
return documentFormat;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IppPrinter::print(QJsonObject attrs, QString filename, bool alwaysUseMediaCol)
|
void IppPrinter::print(QJsonObject attrs, QString filename)
|
||||||
{
|
{
|
||||||
qDebug() << "printing" << filename << attrs;
|
qDebug() << "printing" << filename << attrs;
|
||||||
|
|
||||||
|
@ -372,6 +373,7 @@ void IppPrinter::print(QJsonObject attrs, QString filename, bool alwaysUseMediaC
|
||||||
o.insert("job-name", QJsonObject {{"tag", IppMsg::NameWithoutLanguage}, {"value", fileinfo.fileName()}});
|
o.insert("job-name", QJsonObject {{"tag", IppMsg::NameWithoutLanguage}, {"value", fileinfo.fileName()}});
|
||||||
|
|
||||||
QString PaperSize = getAttrOrDefault(attrs, "media").toString();
|
QString PaperSize = getAttrOrDefault(attrs, "media").toString();
|
||||||
|
bool alwaysUseMediaCol = Settings::instance()->alwaysUseMediaCol();
|
||||||
|
|
||||||
if((attrs.contains("media-col") || alwaysUseMediaCol) && attrs.contains("media"))
|
if((attrs.contains("media-col") || alwaysUseMediaCol) && attrs.contains("media"))
|
||||||
{
|
{
|
||||||
|
|
|
@ -63,7 +63,7 @@ signals:
|
||||||
void progressChanged();
|
void progressChanged();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void print(QJsonObject attrs, QString file, bool alwaysUseMediaCol);
|
void print(QJsonObject attrs, QString file);
|
||||||
|
|
||||||
|
|
||||||
void onUrlChanged();
|
void onUrlChanged();
|
||||||
|
|
52
src/settings.cpp
Normal file
52
src/settings.cpp
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
#include "settings.h"
|
||||||
|
#include <QMutex>
|
||||||
|
|
||||||
|
|
||||||
|
Settings::Settings() : _alwaysUseMediaColSetting("/apps/harbour-seaprint/settings/always-use-media-col", this),
|
||||||
|
_ignoreSslErrorsSetting("/apps/harbour-seaprint/settings/ignore-ssl-errors", this)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Settings::~Settings() {
|
||||||
|
}
|
||||||
|
|
||||||
|
Settings* Settings::m_Instance = nullptr;
|
||||||
|
|
||||||
|
Settings* Settings::instance()
|
||||||
|
{
|
||||||
|
static QMutex mutex;
|
||||||
|
if (!m_Instance)
|
||||||
|
{
|
||||||
|
mutex.lock();
|
||||||
|
|
||||||
|
if (!m_Instance)
|
||||||
|
m_Instance = new Settings;
|
||||||
|
|
||||||
|
mutex.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_Instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Settings::alwaysUseMediaCol()
|
||||||
|
{
|
||||||
|
return _alwaysUseMediaColSetting.value(_alwaysUseMediaColDefault).toBool();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Settings::ignoreSslErrors()
|
||||||
|
{
|
||||||
|
return _ignoreSslErrorsSetting.value(_ignoreSslErrorsDefault).toBool();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString Settings::alwaysUseMediaColPath()
|
||||||
|
{
|
||||||
|
return _alwaysUseMediaColSetting.key();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString Settings::ignoreSslErrorsPath()
|
||||||
|
{
|
||||||
|
return _ignoreSslErrorsSetting.key();
|
||||||
|
}
|
40
src/settings.h
Normal file
40
src/settings.h
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
#ifndef SETTINGS_H
|
||||||
|
#define SETTINGS_H
|
||||||
|
|
||||||
|
#include <mlite5/MGConfItem>
|
||||||
|
|
||||||
|
class Settings : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
Q_PROPERTY(QString alwaysUseMediaColPath READ alwaysUseMediaColPath CONSTANT)
|
||||||
|
Q_PROPERTY(bool alwaysUseMediaColDefault MEMBER _alwaysUseMediaColDefault CONSTANT)
|
||||||
|
|
||||||
|
Q_PROPERTY(QString ignoreSslErrorsPath READ ignoreSslErrorsPath CONSTANT)
|
||||||
|
Q_PROPERTY(bool ignoreSslErrorsDefault MEMBER _ignoreSslErrorsDefault CONSTANT)
|
||||||
|
|
||||||
|
public:
|
||||||
|
static Settings* instance();
|
||||||
|
|
||||||
|
bool alwaysUseMediaCol();
|
||||||
|
bool ignoreSslErrors();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Settings();
|
||||||
|
~Settings();
|
||||||
|
Settings(const Settings &);
|
||||||
|
Settings& operator=(const Settings &);
|
||||||
|
|
||||||
|
static Settings* m_Instance;
|
||||||
|
|
||||||
|
MGConfItem _alwaysUseMediaColSetting;
|
||||||
|
MGConfItem _ignoreSslErrorsSetting;
|
||||||
|
|
||||||
|
QString alwaysUseMediaColPath();
|
||||||
|
QString ignoreSslErrorsPath();
|
||||||
|
|
||||||
|
bool _alwaysUseMediaColDefault = false;
|
||||||
|
bool _ignoreSslErrorsDefault = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SETTINGS_H
|
Loading…
Reference in a new issue