Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Support setting QFileInfo properties from the command line.

  • Loading branch information...
commit b5e44c4580c998c246d8e08b341f7f06af6fc307 1 parent eae0854
Toke Høiland-Jørgensen authored
Showing with 17 additions and 2 deletions.
  1. +15 −2 code/src/processing-gui.cpp
  2. +2 −0  code/src/processing-gui.h
View
17 code/src/processing-gui.cpp
@@ -10,6 +10,7 @@
#include <QtCore/QFileInfo>
#include <QtCore/QTime>
#include <QtCore/QSettings>
+#include <QtCore/QMetaProperty>
#include <QDebug>
#include "processing-gui.h"
@@ -140,8 +141,20 @@ void ProcessingGUI::set_args(QMap<QString, QVariant> arguments) {
if(!properties.empty()) {
QMap<QString, QVariant>::iterator i;
for(i = properties.begin(); i != properties.end(); ++i) {
- if(!current_processor->setProperty(i.key().toLocal8Bit(), i.value())) {
- qWarning() << "Error setting property: " << i.key();
+ int idx = current_processor->metaObject()->indexOfProperty(i.key().toLocal8Bit().data());
+ if(idx == -1) {
+ qWarning() << "Non-existing property:" << i.key();
+ } else {
+ QMetaProperty property = current_processor->metaObject()->property(idx);
+ if(QString(property.typeName()) == "QFileInfo") {
+ QFileInfo info(i.value().toString());
+ qDebug() << info.canonicalFilePath();
+ if(!current_processor->setProperty(i.key().toLocal8Bit(), QVariant::fromValue(info))) {
+ qWarning() << "Error setting QFileInfo property: " << i.key() << info.filePath();
+ }
+ } else if(!current_processor->setProperty(i.key().toLocal8Bit(), i.value())) {
+ qWarning() << "Error setting property: " << i.key() << i.value();
+ }
}
}
}
View
2  code/src/processing-gui.h
@@ -2,6 +2,7 @@
#define PROCESSING_GUI_H
#include <QtGui/QApplication>
+#include <QtCore/QFileInfo>
#include <cv.h>
#include "ui_processing-gui.h"
#include "processor.h"
@@ -62,4 +63,5 @@ private slots:
void image_changed();
};
+Q_DECLARE_METATYPE(QFileInfo)
#endif
Please sign in to comment.
Something went wrong with that request. Please try again.