Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #include <QFileDialog>
00034 #include <QGridLayout>
00035 #include <QLabel>
00036 #include <QPushButton>
00037
00038 #include <rqt_rviz/config_dialog.h>
00039
00040 namespace rqt_rviz {
00041
00042 ConfigDialog::ConfigDialog()
00043 {
00044
00045 this->setWindowTitle(tr("Choose configuration"));
00046 this->setWindowFlags(Qt::Window | Qt::WindowCloseButtonHint |
00047 Qt::WindowStaysOnTopHint | Qt::CustomizeWindowHint);
00048
00049
00050 QLabel* file_label = new QLabel("File path");
00051 file_label->setToolTip("Full path to file");
00052
00053 file_edit_ = new QLineEdit;
00054 file_edit_->setMinimumWidth(300);
00055
00056 QPushButton* browse_button = new QPushButton(tr("Browse"));
00057 connect(browse_button, SIGNAL(clicked()), this, SLOT(OnBrowse()));
00058
00059
00060 QLabel* hide_label = new QLabel("Hide menu");
00061 hide_label->setToolTip("Check to hide RViz's top menu bar");
00062
00063 hide_box_ = new QCheckBox();
00064
00065
00066 QPushButton* cancel_button = new QPushButton(tr("&Cancel"));
00067 this->connect(cancel_button, SIGNAL(clicked()), this, SLOT(close()));
00068
00069 QPushButton* apply_button = new QPushButton(tr("&Apply"));
00070 apply_button->setDefault(true);
00071 this->connect(apply_button, SIGNAL(clicked()), this, SLOT(accept()));
00072
00073 QHBoxLayout* buttons_layout = new QHBoxLayout;
00074 buttons_layout->addWidget(cancel_button);
00075 buttons_layout->addWidget(apply_button);
00076
00077
00078 QGridLayout* main_layout = new QGridLayout();
00079
00080 main_layout->addWidget(file_label, 0, 0);
00081 main_layout->addWidget(file_edit_, 0, 1);
00082 main_layout->addWidget(browse_button, 0, 2);
00083
00084 main_layout->addWidget(hide_label, 1, 0);
00085 main_layout->addWidget(hide_box_, 1, 1);
00086 main_layout->setAlignment(hide_box_, Qt::AlignLeft);
00087
00088 main_layout->addLayout(buttons_layout, 2, 0, 1, 3);
00089 main_layout->setColumnStretch(1, 2);
00090
00091 this->setLayout(main_layout);
00092 }
00093
00094 ConfigDialog::~ConfigDialog()
00095 {
00096 }
00097
00098 void ConfigDialog::OnBrowse()
00099 {
00100 QString filename = QFileDialog::getOpenFileName(0,
00101 tr("Choose config file:"), "", tr("Rviz config file (*.rviz)"));
00102
00103 file_edit_->setText(filename);
00104 }
00105
00106 std::string ConfigDialog::GetFile() const
00107 {
00108 return file_edit_->text().toStdString();
00109 }
00110
00111 void ConfigDialog::SetFile(const std::string& file)
00112 {
00113 file_edit_->setText(QString::fromStdString(file));
00114 }
00115
00116 bool ConfigDialog::GetHide() const
00117 {
00118 return hide_box_->isChecked();
00119 }
00120
00121 void ConfigDialog::SetHide(const bool hide)
00122 {
00123 hide_box_->setChecked(hide);
00124 }
00125
00126 }
00127