NCL Composer  0.1.5
 All Classes Functions Variables Pages
WorkspaceSwitch.cpp
1 /* Copyright (c) 2011 Telemidia/PUC-Rio.
2  * All rights reserved. This program and the accompanying materials
3  * are made available under the terms of the Eclipse Public License v1.0
4  * which accompanies this distribution, and is available at
5  * http://www.eclipse.org/legal/epl-v10.html
6  *
7  * Contributors:
8  * Telemidia/PUC-Rio - initial API and implementation
9  */
10 #include "../include/WorkspaceSwitch.h"
11 
12 namespace composer {
13  namespace gui {
14 
15 WorkspaceSwitch::WorkspaceSwitch(QWidget *parent) :
16  QDialog(parent)
17 {
18  init();
19 }
20 
21 void WorkspaceSwitch::init()
22 {
23  QGridLayout *layout = new QGridLayout(this);
24  layout->addWidget(new QLabel(tr("Choose the workspace "
25  "path for this session"),this));
26  wsPath = new QLineEdit(this);
27  wsPath->setEnabled(false);
28  layout->addWidget(wsPath,1,0);
29  openDir = new QPushButton(tr("Choose Directory"),this);
30  connect(openDir,SIGNAL(clicked()),SLOT(openDirectory()));
31  layout->addWidget(openDir,1,1);
32  QFrame *line = new QFrame(this);
33  line->setFrameShape(QFrame::HLine);
34  line->setFrameShadow(QFrame::Sunken);
35  layout->addWidget(line,4,0,1,2);
36 
37  bOk = new QPushButton(tr("OK"),this);
38  connect(bOk,SIGNAL(clicked()),SLOT(accept()));
39  bCancel = new QPushButton(tr("Cancel"), this);
40  connect(bCancel,SIGNAL(clicked()),SLOT(reject()));
41 
42  QHBoxLayout *bL = new QHBoxLayout;
43  bL->addWidget(bCancel);
44  bL->addWidget(bOk);
45  layout->addLayout(bL,5,1);
46 
47 }
48 
49 void WorkspaceSwitch::openDirectory()
50 {
51  QFileDialog::Options options = QFileDialog::ShowDirsOnly;
52  QDir *dir = new QDir(QDir::homePath());
53  QString directoryURI = QFileDialog::getExistingDirectory(this,
54  tr("Select the target directory"),
55  dir->absolutePath(),
56  options);
57  wsPath->setText(directoryURI);
58 }
59 
60 }} //end namespace