WidgetNameDialog.cpp
Go to the documentation of this file.
1 /*
2 * This file is part of ArmarX.
3 *
4 * ArmarX is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * ArmarX is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * @package ArmarX::
17 * @author Mirko Waechter ( mirko.waechter at kit dot edu)
18 * @date 2012
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22 
23 #include "WidgetNameDialog.h"
24 
25 #include "../ArmarXMainWindow.h"
26 
27 #include <QLineEdit>
28 #include <QLabel>
29 #include <QPushButton>
30 #include <QDialogButtonBox>
31 #include <QGridLayout>
32 
33 namespace armarx
34 {
36  QDialog(parent),
37  parent(parent)
38  {
39  setWindowTitle("Insert new widget name");
40  layout = new QGridLayout(this);
41  labelWidgetName = new QLabel("Instance name of widget: ", this);
42  editWidgetName = new QLineEdit(widgetName, this);
43  layout->addWidget(labelWidgetName, 0, 0);
44  layout->addWidget(editWidgetName, 0, 1);
45  buttonBox = new QDialogButtonBox(this);
46  buttonBox->setObjectName(QString::fromUtf8("buttonBox"));
47  buttonBox->setOrientation(Qt::Horizontal);
48  buttonBox->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok);
49  layout->addWidget(buttonBox, 1, 0, 2, 2);
50 
51  connect(editWidgetName, SIGNAL(textChanged(QString)), this, SLOT(checkWidgetName(QString)));
52  QObject::connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
53  QObject::connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
54  resize(350, 80);
55 
56  }
57 
59  {
60  return editWidgetName->text();
61  }
62 
64  {
65  if (parent)
66  {
67  if (parent->listOpenWidgets.find(name) != parent->listOpenWidgets.end()
68  /*|| name == ARMARX_VIEWER_NAME*/ || name.length() == 0)
69  {
70  QPalette p(editWidgetName->palette());
71  p.setColor(QPalette::Base, QColor::fromRgb(255, 120, 120));
72  editWidgetName->setPalette(p);
73  buttonBox->button(QDialogButtonBox::Ok)->setDisabled(true);
74  return false;
75  }
76  else
77  {
78  QPalette p(editWidgetName->palette());
79  p.setColor(QPalette::Base, QColor::fromRgb(120, 255, 120));
80  p.setBrush(QPalette::Base, p.light());
81  editWidgetName->setPalette(p);
82  buttonBox->button(QDialogButtonBox::Ok)->setDisabled(false);
83  return true;
84  }
85 
86  }
87  return false;
88  }
89 }
armarx::WidgetNameDialog::layout
QGridLayout * layout
Definition: WidgetNameDialog.h:51
armarx::ArmarXMainWindow
The ArmarXMainWindow class.
Definition: ArmarXMainWindow.h:80
WidgetNameDialog.h
armarx::WidgetNameDialog::WidgetNameDialog
WidgetNameDialog(QString widgetName, ArmarXMainWindow *parent=0)
Definition: WidgetNameDialog.cpp:35
armarx::WidgetNameDialog::checkWidgetName
bool checkWidgetName(QString name)
Definition: WidgetNameDialog.cpp:63
armarx::WidgetNameDialog::parent
ArmarXMainWindow * parent
Definition: WidgetNameDialog.h:50
armarx::WidgetNameDialog::getWidgetName
QString getWidgetName() const
Definition: WidgetNameDialog.cpp:58
armarx::WidgetNameDialog::editWidgetName
QLineEdit * editWidgetName
Definition: WidgetNameDialog.h:53
armarx::WidgetNameDialog::buttonBox
QDialogButtonBox * buttonBox
Definition: WidgetNameDialog.h:54
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::WidgetNameDialog::labelWidgetName
QLabel * labelWidgetName
Definition: WidgetNameDialog.h:52