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 <QDialogButtonBox>
26#include <QGridLayout>
27#include <QLabel>
28#include <QLineEdit>
29#include <QPushButton>
30
31#include "../ArmarXMainWindow.h"
32
33namespace armarx
34{
36 QDialog(parent), parent(parent)
37 {
38 setWindowTitle("Insert new widget name");
39 layout = new QGridLayout(this);
40 labelWidgetName = new QLabel("Instance name of widget: ", this);
41 editWidgetName = new QLineEdit(widgetName, this);
42 layout->addWidget(labelWidgetName, 0, 0);
43 layout->addWidget(editWidgetName, 0, 1);
44 buttonBox = new QDialogButtonBox(this);
45 buttonBox->setObjectName(QString::fromUtf8("buttonBox"));
46 buttonBox->setOrientation(Qt::Horizontal);
47 buttonBox->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok);
48 layout->addWidget(buttonBox, 1, 0, 2, 2);
49
50 connect(editWidgetName, SIGNAL(textChanged(QString)), this, SLOT(checkWidgetName(QString)));
51 QObject::connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
52 QObject::connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
53 resize(350, 80);
54 }
55
56 QString
58 {
59 return editWidgetName->text();
60 }
61
62 bool
64 {
65 if (parent)
66 {
67 if (parent->listOpenWidgets.find(name) != parent->listOpenWidgets.end()
68 /*|| name == ARMARX_VIEWER_NAME*/
69 || name.length() == 0)
70 {
71 QPalette p(editWidgetName->palette());
72 p.setColor(QPalette::Base, QColor::fromRgb(255, 120, 120));
73 editWidgetName->setPalette(p);
74 buttonBox->button(QDialogButtonBox::Ok)->setDisabled(true);
75 return false;
76 }
77 else
78 {
79 QPalette p(editWidgetName->palette());
80 p.setColor(QPalette::Base, QColor::fromRgb(120, 255, 120));
81 p.setBrush(QPalette::Base, p.light());
82 editWidgetName->setPalette(p);
83 buttonBox->button(QDialogButtonBox::Ok)->setDisabled(false);
84 return true;
85 }
86 }
87 return false;
88 }
89} // namespace armarx
The ArmarXMainWindow class.
bool checkWidgetName(QString name)
WidgetNameDialog(QString widgetName, ArmarXMainWindow *parent=0)
QDialogButtonBox * buttonBox
ArmarXMainWindow * parent
This file offers overloads of toIce() and fromIce() functions for STL container types.