mirror of
https://github.com/Fishwaldo/qt-openzwave.git
synced 2025-03-15 19:41:24 +00:00
Move Config Resource File to the Library
This commit is contained in:
parent
4093f321c7
commit
a52be34151
5 changed files with 58 additions and 2 deletions
|
@ -9,4 +9,5 @@ TEMPLATE = subdirs
|
|||
CONFIG += ordered silent
|
||||
|
||||
SUBDIRS = qt-openzwave simpleclient \
|
||||
qt-openzwavedatabase \
|
||||
qt-ozwdaemon
|
||||
|
|
|
@ -429,9 +429,11 @@ QByteArray QTOZWManager_Internal::GetMetaDataProductPic(quint8 _node) {
|
|||
if (!this->checkHomeId() || !this->checkNodeId(_node))
|
||||
return QByteArray();
|
||||
try {
|
||||
QString path("config/");
|
||||
this->m_options->GetOptionAsString("ConfigPath");
|
||||
QString path(this->m_options->GetOptionAsString("ConfigPath"));
|
||||
path.append(QString::fromStdString(this->m_manager->GetMetaData(this->homeId(), _node, OpenZWave::Node::MetaDataFields::MetaData_ProductPic)));
|
||||
if (path == "config/")
|
||||
qCDebug(manager) << "ProductPic Path: " << path;
|
||||
if (path == this->m_options->GetOptionAsString("ConfigPath"))
|
||||
return QByteArray();
|
||||
QFile file(path);
|
||||
if (!file.open(QIODevice::ReadOnly)) return QByteArray();
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
#ifndef QTOPENZWAVEDATABASE_H
|
||||
#define QTOPENZWAVEDATABASE_H
|
||||
#include <QDir>
|
||||
|
||||
bool copyConfigDatabase(QDir configpath);
|
||||
|
||||
#endif // QTOPENZWAVEDATABASE_H
|
26
qt-openzwavedatabase/qt-openzwavedatabase.pro
Normal file
26
qt-openzwavedatabase/qt-openzwavedatabase.pro
Normal file
|
@ -0,0 +1,26 @@
|
|||
QT -= gui
|
||||
|
||||
TEMPLATE = lib
|
||||
|
||||
VERSION = 1.0.0
|
||||
|
||||
CONFIG += silent file_copies
|
||||
|
||||
!versionAtLeast(QT_VERSION, 5.11.2):error("Use at least Qt version 5.11.2")
|
||||
|
||||
ozwconfig.target=config/qrc_ozwconfig.cpp
|
||||
ozwconfig.commands=cp -R ../../open-zwave/config config/ && cd config && $$[QT_INSTALL_BINS]/rcc -project -o ozwconfig.qrc && $$[QT_INSTALL_BINS]/rcc --name="ozwconfig" --root="/config/" ozwconfig.qrc -o qrc_ozwconfig.cpp
|
||||
|
||||
QMAKE_EXTRA_TARGETS += ozwconfig
|
||||
PRE_TARGETDEPS += config/qrc_ozwconfig.cpp
|
||||
SOURCES += config/qrc_ozwconfig.cpp \
|
||||
source/qt-openzwavedatabase.cpp
|
||||
|
||||
macx {
|
||||
QMAKE_LFLAGS_SONAME = -Wl,-install_name,@rpath/
|
||||
}
|
||||
|
||||
HEADERS += \
|
||||
include/qt-openzwave/qt-openzwavedatabase.h
|
||||
|
||||
INCLUDEPATH += include/
|
20
qt-openzwavedatabase/source/qt-openzwavedatabase.cpp
Normal file
20
qt-openzwavedatabase/source/qt-openzwavedatabase.cpp
Normal file
|
@ -0,0 +1,20 @@
|
|||
#include <QDirIterator>
|
||||
#include <QDebug>
|
||||
#include "qt-openzwave/qt-openzwavedatabase.h"
|
||||
|
||||
bool copyConfigDatabase(QDir configpath)
|
||||
{
|
||||
QDirIterator it(":/config/", QStringList() << "*.xml" << "*.png" << "*.xsd", QDir::NoFilter, QDirIterator::Subdirectories);
|
||||
while (it.hasNext()) {
|
||||
QFileInfo fi(it.next());
|
||||
QString dirname = fi.dir().path().remove(0, 2);
|
||||
configpath.mkpath(dirname);
|
||||
if (!QFileInfo::exists(configpath.path()+fi.filePath().remove(0,1))) {
|
||||
qDebug() << "Copying " << fi.filePath() << " to " << configpath.filePath(fi.filePath().remove(0, 2));
|
||||
QFile::copy(fi.filePath(), configpath.filePath(fi.filePath().remove(0, 2)));
|
||||
} else {
|
||||
qDebug() << "Skipping " << fi.filePath() << " as it exists";
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
Loading…
Add table
Reference in a new issue