2018-05-10 16:41:14 +00:00
|
|
|
#include "mainwindow.h"
|
|
|
|
#include "ui_mainwindow.h"
|
|
|
|
|
2018-05-15 11:11:40 +00:00
|
|
|
#include "testdata.h"
|
|
|
|
#include <QJsonObject>
|
|
|
|
#include <QJsonDocument>
|
|
|
|
#include <QFile>
|
|
|
|
#include <QFileDialog>
|
|
|
|
|
|
|
|
|
2018-05-10 16:41:14 +00:00
|
|
|
MainWindow::MainWindow(QWidget *parent)
|
2018-05-15 11:11:40 +00:00
|
|
|
: QMainWindow(parent), ui(new Ui::MainWindow)
|
2018-05-10 16:41:14 +00:00
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
2018-05-15 11:11:40 +00:00
|
|
|
|
|
|
|
ui->actionSave_as->setIcon(QIcon::fromTheme("document-save-as", QIcon("/usr/share/gtk-doc/html/gtk2/document-save-as.png")));
|
|
|
|
connect(ui->actionSave_as, SIGNAL(triggered()), this, SLOT(saveAs()));
|
2018-05-10 16:41:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MainWindow::~MainWindow()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
2018-05-15 11:11:40 +00:00
|
|
|
void MainWindow::saveAs()
|
|
|
|
{
|
|
|
|
QString filename = QFileDialog::getSaveFileName(this);
|
|
|
|
if (filename.isEmpty())
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2018-05-10 16:41:14 +00:00
|
|
|
|
2018-05-15 11:11:40 +00:00
|
|
|
TestData testData;
|
|
|
|
QJsonObject saveData;
|
|
|
|
testData.write(saveData);
|
|
|
|
|
|
|
|
QJsonDocument saveDoc(saveData);
|
|
|
|
|
|
|
|
QFile saveFile(filename);
|
|
|
|
saveFile.open(QFile::WriteOnly);
|
|
|
|
saveFile.write(saveDoc.toJson());
|
|
|
|
saveFile.close();
|
|
|
|
}
|