mirror of
https://github.com/QuasarApp/CQtDeployer.git
synced 2025-04-28 18:54:33 +00:00
58 lines
1.2 KiB
C++
58 lines
1.2 KiB
C++
#include "qmlcreator.h"
|
|
|
|
#include <QFile>
|
|
#include <QFileInfo>
|
|
|
|
QMap<QString, QStringList> QmlCreator::getQmlImports() const {
|
|
return qmlImports;
|
|
}
|
|
|
|
QStringList QmlCreator::getCopyedQml() const {
|
|
return copyedQml;
|
|
}
|
|
|
|
void QmlCreator::createQml(const QString &qmlFile, const QStringList &imports) {
|
|
QFile qml(qmlFile);
|
|
|
|
if (qml.open(QIODevice::ReadOnly)) {
|
|
|
|
QFile target(path + "/" + QFileInfo(qmlFile).fileName());
|
|
|
|
if (target.open(QIODevice::ReadWrite)) {
|
|
|
|
auto data = qml.readAll();
|
|
target.write(data.data(), data.size());
|
|
|
|
target.close();
|
|
|
|
copyedQml.push_back(target.fileName());
|
|
qmlImports.insert(target.fileName(), imports);
|
|
}
|
|
|
|
qml.close();
|
|
}
|
|
}
|
|
|
|
void QmlCreator::initQml() {
|
|
createQml(":/qmlFile.qml", {
|
|
"2#QtQuick",
|
|
"2#QtQuick/Controls/Material",
|
|
"2#QtQuick/Controls",
|
|
"1#QtQuick/Layouts"
|
|
});
|
|
}
|
|
|
|
QmlCreator::QmlCreator(const QString &path) {
|
|
this->path = path;
|
|
initQml();
|
|
}
|
|
|
|
|
|
QmlCreator::~QmlCreator() {
|
|
|
|
for(auto &&lib : copyedQml) {
|
|
QFile::remove(lib);
|
|
}
|
|
|
|
}
|