Commit 96989f80 authored by Jan Möbius's avatar Jan Möbius
Browse files

Removed QSignalMapper

parent f34471e5
......@@ -51,7 +51,6 @@
#include <ACG/Scenegraph/MaterialNode.hh>
#include <QSignalMapper>
#include <QMessageBox>
#include <QMenu>
......@@ -133,8 +132,9 @@ void MaterialPicker::initializePlugin() {
stream << savedString[8].toStdString();
stream >> materialInfo.key;
if (materialInfo.key != Qt::Key_unknown)
if (materialInfo.key != Qt::Key_unknown) {
shortKeyRow_[materialInfo.key] = materialListWidget_->count();
}
materialListWidget_->addItem( itemName(savedString[0],materialInfo.key) );
materialList_.push_back(materialInfo);
......@@ -303,6 +303,7 @@ void MaterialPicker::slotMouseEvent(QMouseEvent* _event) {
// update list widget and material list
QString name = QString("material id: %1").arg(material->id());
materialListWidget_->addItem( itemName(name,materialInfo.key) );
materialListWidget_->setCurrentItem( materialListWidget_->item(materialListWidget_->count() - 1) );
materialList_.push_back(materialInfo);
......@@ -397,6 +398,7 @@ QString MaterialPicker::itemName(const QString &_name, int _key)
{
if (_key == Qt::Key_unknown)
return _name;
return QString(tr("(%1) ")).arg(QString::number(_key-Qt::Key_1+1)) +_name;
}
......@@ -549,23 +551,23 @@ void MaterialPicker::createContextMenu(const QPoint& _point)
menu->addSeparator();
//add hotkey selectors
QSignalMapper* signalMapper = new QSignalMapper(menu);
for (unsigned i = 0; i < supportedKeys_; ++i)
{
QAction* action = menu->addAction(tr("Key %1").arg(i+1));
connect(action,SIGNAL(triggered(bool)),signalMapper,SLOT(map()));
signalMapper->setMapping(action,Qt::Key_1+i);
std::map<int,size_t>::iterator iter = shortKeyRow_.find(Qt::Key_1+i);
connect(action,&QAction::triggered, [=]() { changeHotKey(Qt::Key_1+i); } );
std::map<int,size_t>::iterator iter = shortKeyRow_.find(Qt::Key_1 + i);
//Disable already selected hotkey number
if (iter != shortKeyRow_.end() && iter->second == static_cast<size_t>(materialListWidget_->currentRow()))
action->setDisabled(true);
}
connect(signalMapper, SIGNAL(mapped(const int &)),this, SLOT(changeHotKey(const int &)));
menu->exec(materialListWidget_->mapToGlobal(_point),0);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment