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
00034
00035
00036
00037 #include <QPushButton>
00038 #include <QFont>
00039 #include <QFileDialog>
00040 #include <QVBoxLayout>
00041 #include "header_widget.h"
00042
00043 namespace moveit_setup_assistant
00044 {
00045
00046
00047
00048
00049
00050
00051
00052 HeaderWidget::HeaderWidget( const std::string &title, const std::string &instructions, QWidget *parent )
00053 : QWidget(parent)
00054 {
00055
00056 QVBoxLayout *layout = new QVBoxLayout(this);
00057 layout->setAlignment( Qt::AlignTop);
00058
00059
00060 QLabel *page_title = new QLabel( this );
00061 page_title->setText( title.c_str() );
00062 QFont page_title_font( "Arial", 18, QFont::Bold );
00063 page_title->setFont(page_title_font);
00064 page_title->setWordWrap(true);
00065 layout->addWidget( page_title);
00066 layout->setAlignment( page_title, Qt::AlignTop);
00067
00068
00069 QLabel *page_instructions = new QLabel( this );
00070 page_instructions->setText( instructions.c_str() );
00071 page_instructions->setWordWrap(true);
00072
00073 page_instructions->setMinimumWidth(1);
00074 layout->addWidget( page_instructions );
00075 layout->setAlignment( page_instructions, Qt::AlignTop);
00076
00077
00078 layout->setContentsMargins( 0, 0, 0, 0);
00079
00080 this->setLayout(layout);
00081
00082 }
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094 LoadPathWidget::LoadPathWidget( const std::string &title, const std::string &instructions,
00095 const bool dir_only, const bool load_only, QWidget* parent )
00096 : QFrame(parent), dir_only_(dir_only), load_only_(load_only)
00097 {
00098
00099 setFrameShape(QFrame::StyledPanel);
00100 setFrameShadow(QFrame::Raised);
00101 setLineWidth(1);
00102 setMidLineWidth(0);
00103
00104
00105 QVBoxLayout *layout = new QVBoxLayout(this);
00106
00107
00108 QHBoxLayout *hlayout = new QHBoxLayout();
00109
00110
00111 QLabel * widget_title = new QLabel(this);
00112 widget_title->setText( title.c_str() );
00113 QFont widget_title_font( "Arial", 12, QFont::Bold );
00114 widget_title->setFont(widget_title_font);
00115 layout->addWidget( widget_title);
00116 layout->setAlignment( widget_title, Qt::AlignTop);
00117
00118
00119 QLabel * widget_instructions = new QLabel(this);
00120 widget_instructions->setText( instructions.c_str() );
00121 widget_instructions->setWordWrap(true);
00122 widget_instructions->setTextFormat( Qt::RichText );
00123 layout->addWidget( widget_instructions);
00124 layout->setAlignment( widget_instructions, Qt::AlignTop);
00125
00126
00127 path_box_ = new QLineEdit(this);
00128 hlayout->addWidget(path_box_);
00129
00130
00131 QPushButton *browse_button = new QPushButton(this);
00132 browse_button->setText("Browse");
00133 connect( browse_button, SIGNAL( clicked() ), this, SLOT( btn_file_dialog() ) );
00134 hlayout->addWidget(browse_button);
00135
00136
00137 layout->addLayout(hlayout);
00138
00139 setLayout(layout);
00140 }
00141
00142
00143
00144
00145 void LoadPathWidget::btn_file_dialog()
00146 {
00147 QString path;
00148 if( dir_only_ )
00149 {
00150 path = QFileDialog::getExistingDirectory(this, "Open Package Directory", path_box_->text(),
00151 QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
00152 }
00153 else
00154 {
00155 QString start_path;
00156
00157 start_path = path_box_->text();
00158
00159 if( load_only_ )
00160 {
00161 path = QFileDialog::getOpenFileName(this, "Open File", start_path, "");
00162 }
00163 else
00164 {
00165 path = QFileDialog::getSaveFileName(this, "Create/Load File", start_path, "" );
00166 }
00167 }
00168
00169
00170 if (path != NULL)
00171 path_box_->setText( path );
00172 }
00173
00174
00175
00176
00177 const QString LoadPathWidget::getQPath()
00178 {
00179 return path_box_->text();
00180 }
00181
00182
00183
00184
00185 const std::string LoadPathWidget::getPath()
00186 {
00187 return getQPath().toStdString();
00188 }
00189
00190
00191
00192
00193 void LoadPathWidget::setPath( const QString &path )
00194 {
00195 path_box_->setText( path );
00196 }
00197
00198
00199
00200
00201 void LoadPathWidget::setPath( const std::string &path )
00202 {
00203 path_box_->setText( QString( path.c_str() ) );
00204 }
00205
00206
00207 }