Device Emulation (contd.): Hide Device Detail view when Escape pressed or Refresh clicked

This commit is contained in:
Srivats P 2016-03-14 21:39:01 +05:30
parent 7561b09c1e
commit 26ceb2f9df
2 changed files with 14 additions and 0 deletions

View File

@ -24,6 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
#include "portgrouplist.h"
#include <QHeaderView>
#include <QKeyEvent>
DevicesWidget::DevicesWidget(QWidget *parent)
: QWidget(parent), portGroups_(NULL)
@ -87,6 +88,16 @@ void DevicesWidget::setPortGroupList(PortGroupList *portGroups)
updateDeviceViewActions();
}
void DevicesWidget::keyPressEvent(QKeyEvent *event)
{
if (event->key() == Qt::Key_Escape) {
deviceDetail->hide();
event->accept();
}
else
event->ignore();
}
void DevicesWidget::setCurrentPortIndex(const QModelIndex &portIndex)
{
Port *port = NULL;
@ -220,6 +231,7 @@ void DevicesWidget::on_refresh_clicked()
Q_ASSERT(curPortGroup.isValid());
Q_ASSERT(portGroups_->isPortGroup(curPortGroup));
deviceDetail->hide();
portGroups_->portGroup(curPortGroup)
.getDeviceInfo(portGroups_->port(currentPortIndex_).id());
}

View File

@ -33,6 +33,8 @@ public:
DevicesWidget(QWidget *parent = NULL);
void setPortGroupList(PortGroupList *portGroups);
virtual void keyPressEvent(QKeyEvent *event);
public slots:
void setCurrentPortIndex(const QModelIndex &portIndex);