From 26ceb2f9df03e92fe1b9a9aa4e50bcab8554dabe Mon Sep 17 00:00:00 2001 From: Srivats P Date: Mon, 14 Mar 2016 21:39:01 +0530 Subject: [PATCH] Device Emulation (contd.): Hide Device Detail view when Escape pressed or Refresh clicked --- client/deviceswidget.cpp | 12 ++++++++++++ client/deviceswidget.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/client/deviceswidget.cpp b/client/deviceswidget.cpp index 789a150..7f84a2c 100644 --- a/client/deviceswidget.cpp +++ b/client/deviceswidget.cpp @@ -24,6 +24,7 @@ along with this program. If not, see #include "portgrouplist.h" #include +#include 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()); } diff --git a/client/deviceswidget.h b/client/deviceswidget.h index 8c7626e..d5ef524 100644 --- a/client/deviceswidget.h +++ b/client/deviceswidget.h @@ -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);