29 lines
757 B
C++
29 lines
757 B
C++
#include <QApplication>
|
|
#include "piqt_connection_edit.h"
|
|
#include <QFileDialog>
|
|
#include <qpiconfig.h>
|
|
|
|
|
|
int main(int argc, char * argv[]) {
|
|
QApplication a(argc, argv);
|
|
ConnectionEdit w;
|
|
if (a.arguments().size() > 1) {
|
|
QPIConfig cfg(a.arguments()[1]);
|
|
QByteArray model = cfg.getValue("connectionmodel", QByteArray());
|
|
if (!model.isEmpty()) w.setModel(model);
|
|
}
|
|
if (w.exec() == QDialog::Accepted) {
|
|
QString c = QFileDialog::getSaveFileName(&w, "Save config to file", a.applicationDirPath(), "*.conf");
|
|
if (!c.isEmpty()) {
|
|
QFile f(c);
|
|
if (f.open(QIODevice::WriteOnly)) {
|
|
QTextStream ts(&f);
|
|
ts << w.configuration();
|
|
ts << "connectionmodel = " << QByteArray2QString(w.model()) << "\n";
|
|
f.close();
|
|
}
|
|
}
|
|
}
|
|
return 0;
|
|
}
|