output_save_dir_input_config_widget.cpp
Go to the documentation of this file.
1 //
2 // Created by yijiangh on 9/9/17.
3 //
4 
5 #include <QString>
6 #include <QFileDialog>
7 
9 #include <ui_output_save_dir_input_config.h>
10 
11 choreo_gui::OutputSaveDirInputConfigWidget::OutputSaveDirInputConfigWidget(choreo_msgs::OutputSaveDirInputParameters params)
12  : params_(params)
13 {
14  ui_ = new Ui::OutputSaveDirInputConfigWindow();
15  ui_->setupUi(this);
16 
17  connect(ui_->pushbutton_accept, SIGNAL(clicked()), this, SLOT(accept_changes_handler()));
18  connect(ui_->pushbutton_cancel, SIGNAL(clicked()), this, SLOT(cancel_changes_handler()));
19  connect(ui_->pushbutton_save, SIGNAL(clicked()), this, SLOT(save_changes_handler()));
20 
21  connect(ui_->pushbutton_output_save_dir, SIGNAL(clicked()), this, SLOT(get_file_path_handler()));
22 
23  last_filepath_ = "/home";
24 }
25 
26 static void checkFileExtension(std::string& str)
27 {
28  if(str.empty())
29  {
30  return;
31  }
32 
33  std::string json_suffix = ".json";
34  std::size_t found = str.find_last_of(json_suffix);
35 
36  while(str.size()-1 == found)
37  {
38  str = str.substr(0, found - json_suffix.size() + 1);
39  found = str.find_last_of(json_suffix);
40  }
41 
42  str = str + json_suffix;
43 }
44 
46 {
47  checkFileExtension(params_.file_path);
48  ui_->lineedit_filepath->setText(QString(params_.file_path.c_str()));
49 }
50 
52 {
53  params_.file_path = ui_->lineedit_filepath->text().toLocal8Bit().constData();
54  checkFileExtension(params_.file_path);
55  last_filepath_ = params_.file_path;
56 }
57 
59 {
60  QString filename = QFileDialog::getSaveFileName(
61  this,
62  tr("Output File"),
63  QString::fromStdString(last_filepath_),
64  tr("mpp-format json file (*.json)"));
65 
66  params_.file_path = filename.toLocal8Bit().constData();
67  checkFileExtension(params_.file_path);
68  last_filepath_ = params_.file_path;
69 
71 }
filename
virtual void update_internal_fields()
Reads the fields of the GUI to update the internal data structure.
choreo_msgs::OutputSaveDirInputParameters params_
static void checkFileExtension(std::string &str)
OutputSaveDirInputConfigWidget(choreo_msgs::OutputSaveDirInputParameters params)
virtual void update_display_fields()
Reads the internal data structure to update the fields of the GUI.


choreo_gui
Author(s): Yijiang Huang
autogenerated on Thu Jul 18 2019 03:58:56