-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 337be26
Showing
4 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
*.o | ||
*.exe | ||
.qmake.stash | ||
Makefile | ||
qml-validator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# QML Validator | ||
|
||
QML Validator is a small utility which simply loads the input file and show any | ||
errors that could occur when doing so. It uses QCoreApplication, and as such it | ||
doesn't require a graphical environment to run, as opposed to qmlscene for | ||
example, and as such may be used in situation where a graphical environment | ||
isn't available, such as a continuous integration script. | ||
|
||
## Usage | ||
|
||
``` | ||
qml-validator <input-file> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include <iostream> | ||
#include <QQmlComponent> | ||
#include <QQmlEngine> | ||
#include <QCoreApplication> | ||
|
||
std::ostream& operator<<(std::ostream& os, const QString s){ | ||
return os << s.toStdString(); | ||
} | ||
|
||
int main(int argc, char** argv){ | ||
if(argc < 2){ | ||
std::cout << "Usage: qml-validator <qmlfile>" << std::endl; | ||
return 1; | ||
} | ||
|
||
QCoreApplication app(argc, argv); | ||
QQmlEngine engine; | ||
QQmlComponent component(&engine); | ||
QObject::connect(&component, &QQmlComponent::statusChanged, | ||
[&component, argv](QQmlComponent::Status status){ | ||
if(status == QQmlComponent::Status::Null){ | ||
std::cout << "Component is Null." << std::endl; | ||
}else if(status == QQmlComponent::Status::Ready){ | ||
// OK! | ||
}else if(status == QQmlComponent::Status::Loading){ | ||
std::cout << "Component is Loading." << std::endl; | ||
}else if(status == QQmlComponent::Status::Error){ | ||
std::cout << "Errors happened while loading " << argv[1] | ||
<< ": " << std::endl; | ||
for(QQmlError error : component.errors()){ | ||
std::cout << error.toString() << std::endl; | ||
} | ||
exit(1); | ||
} | ||
}); | ||
component.loadUrl(QUrl(argv[1])); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
QT += qml | ||
|
||
SOURCES += main.cpp |