mirror of
https://github.com/QuasarApp/CQtDeployer.git
synced 2025-05-01 04:04:34 +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", {
|
||
|
"QtQuick",
|
||
|
"QtQuick.Controls.Material",
|
||
|
"QtQuick.Controls2",
|
||
|
"QtQuick.Layouts"
|
||
|
});
|
||
|
}
|
||
|
|
||
|
QmlCreator::QmlCreator(const QString &path) {
|
||
|
this->path = path;
|
||
|
initQml();
|
||
|
}
|
||
|
|
||
|
|
||
|
QmlCreator::~QmlCreator() {
|
||
|
|
||
|
for(auto &&lib : copyedQml) {
|
||
|
QFile::remove(lib);
|
||
|
}
|
||
|
|
||
|
}
|