diff options
author | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2018-10-18 17:21:33 +0300 |
---|---|---|
committer | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2018-10-19 10:19:34 +0000 |
commit | c5a7a92c58871b1de7019494e741db12e0d33727 (patch) | |
tree | acbb987987ae66011015905d78e32e0c8f87e6ca | |
parent | 445f6d99d7d59f597f643cee6d18feb8186e45d9 (diff) |
Make ESC key close various browser popups
Task-number: QT3DS-2510
Change-Id: Iaea12b44042ce10640f24c7a12f0b1d35463eb42
Reviewed-by: Janne Kangas <janne.kangas@qt.io>
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
14 files changed, 64 insertions, 1 deletions
diff --git a/src/Authoring/Studio/Application/DataInputSelectView.cpp b/src/Authoring/Studio/Application/DataInputSelectView.cpp index 1145f584..b476ddaf 100644 --- a/src/Authoring/Studio/Application/DataInputSelectView.cpp +++ b/src/Authoring/Studio/Application/DataInputSelectView.cpp @@ -137,6 +137,14 @@ void DataInputSelectView::showEvent(QShowEvent *event) QQuickWidget::showEvent(event); } +void DataInputSelectView::keyPressEvent(QKeyEvent *event) +{ + if (event->key() == Qt::Key_Escape) + QTimer::singleShot(0, this, &DataInputSelectView::close); + + QQuickWidget::keyPressEvent(event); +} + void DataInputSelectView::setSelection(int index) { if (m_selection != index) { diff --git a/src/Authoring/Studio/Application/DataInputSelectView.h b/src/Authoring/Studio/Application/DataInputSelectView.h index 8bc31961..0dfd6242 100644 --- a/src/Authoring/Studio/Application/DataInputSelectView.h +++ b/src/Authoring/Studio/Application/DataInputSelectView.h @@ -59,6 +59,7 @@ Q_SIGNALS: protected: void focusOutEvent(QFocusEvent *event) override; void showEvent(QShowEvent *event) override; + void keyPressEvent(QKeyEvent *event) override; private: void initialize(); diff --git a/src/Authoring/Studio/Palettes/Action/EventsBrowserView.cpp b/src/Authoring/Studio/Palettes/Action/EventsBrowserView.cpp index 891498cc..0806eb72 100644 --- a/src/Authoring/Studio/Palettes/Action/EventsBrowserView.cpp +++ b/src/Authoring/Studio/Palettes/Action/EventsBrowserView.cpp @@ -93,6 +93,14 @@ void EventsBrowserView::focusOutEvent(QFocusEvent *event) QTimer::singleShot(0, this, &EventsBrowserView::close); } +void EventsBrowserView::keyPressEvent(QKeyEvent *event) +{ + if (event->key() == Qt::Key_Escape) + QTimer::singleShot(0, this, &EventsBrowserView::close); + + QQuickWidget::keyPressEvent(event); +} + void EventsBrowserView::initialize() { CStudioPreferences::setQmlContextProperties(rootContext()); diff --git a/src/Authoring/Studio/Palettes/Action/EventsBrowserView.h b/src/Authoring/Studio/Palettes/Action/EventsBrowserView.h index cedea92f..f4e373b2 100644 --- a/src/Authoring/Studio/Palettes/Action/EventsBrowserView.h +++ b/src/Authoring/Studio/Palettes/Action/EventsBrowserView.h @@ -60,6 +60,7 @@ Q_SIGNALS: protected: void focusOutEvent(QFocusEvent *event) override; + void keyPressEvent(QKeyEvent *event) override; private: void initialize(); diff --git a/src/Authoring/Studio/Palettes/Inspector/FileChooserView.cpp b/src/Authoring/Studio/Palettes/Inspector/FileChooserView.cpp index ab211068..31ade555 100644 --- a/src/Authoring/Studio/Palettes/Inspector/FileChooserView.cpp +++ b/src/Authoring/Studio/Palettes/Inspector/FileChooserView.cpp @@ -94,6 +94,14 @@ void FileChooserView::focusOutEvent(QFocusEvent *event) QTimer::singleShot(0, this, &FileChooserView::close); } +void FileChooserView::keyPressEvent(QKeyEvent *event) +{ + if (event->key() == Qt::Key_Escape) + QTimer::singleShot(0, this, &FileChooserView::close); + + QQuickWidget::keyPressEvent(event); +} + void FileChooserView::showEvent(QShowEvent *event) { const auto doc = g_StudioApp.GetCore()->GetDoc(); diff --git a/src/Authoring/Studio/Palettes/Inspector/FileChooserView.h b/src/Authoring/Studio/Palettes/Inspector/FileChooserView.h index 400f9f1e..3ccbc7c0 100644 --- a/src/Authoring/Studio/Palettes/Inspector/FileChooserView.h +++ b/src/Authoring/Studio/Palettes/Inspector/FileChooserView.h @@ -55,6 +55,7 @@ Q_SIGNALS: protected: void focusOutEvent(QFocusEvent *event) override; + void keyPressEvent(QKeyEvent *event) override; private: void showEvent(QShowEvent *event) override; diff --git a/src/Authoring/Studio/Palettes/Inspector/ImageChooserView.cpp b/src/Authoring/Studio/Palettes/Inspector/ImageChooserView.cpp index b05a77ba..bca0c8bb 100644 --- a/src/Authoring/Studio/Palettes/Inspector/ImageChooserView.cpp +++ b/src/Authoring/Studio/Palettes/Inspector/ImageChooserView.cpp @@ -96,7 +96,7 @@ bool ImageChooserView::isFocused() const void ImageChooserView::focusInEvent(QFocusEvent *event) { - QQuickWidget::focusOutEvent(event); + QQuickWidget::focusInEvent(event); emit focusChanged(); } @@ -107,6 +107,14 @@ void ImageChooserView::focusOutEvent(QFocusEvent *event) QTimer::singleShot(0, this, &QQuickWidget::close); } +void ImageChooserView::keyPressEvent(QKeyEvent *event) +{ + if (event->key() == Qt::Key_Escape) + QTimer::singleShot(0, this, &ImageChooserView::close); + + QQuickWidget::keyPressEvent(event); +} + void ImageChooserView::showEvent(QShowEvent *event) { const auto doc = g_StudioApp.GetCore()->GetDoc(); diff --git a/src/Authoring/Studio/Palettes/Inspector/ImageChooserView.h b/src/Authoring/Studio/Palettes/Inspector/ImageChooserView.h index 1fd1260b..aab8afb5 100644 --- a/src/Authoring/Studio/Palettes/Inspector/ImageChooserView.h +++ b/src/Authoring/Studio/Palettes/Inspector/ImageChooserView.h @@ -57,6 +57,7 @@ Q_SIGNALS: protected: void focusInEvent(QFocusEvent *event) override; void focusOutEvent(QFocusEvent *event) override; + void keyPressEvent(QKeyEvent *event) override; Q_SIGNALS: void focusChanged(); diff --git a/src/Authoring/Studio/Palettes/Inspector/MeshChooserView.cpp b/src/Authoring/Studio/Palettes/Inspector/MeshChooserView.cpp index b32cd3fa..9ed6656d 100644 --- a/src/Authoring/Studio/Palettes/Inspector/MeshChooserView.cpp +++ b/src/Authoring/Studio/Palettes/Inspector/MeshChooserView.cpp @@ -116,6 +116,14 @@ void MeshChooserView::focusOutEvent(QFocusEvent *event) QTimer::singleShot(0, this, &QQuickWidget::close); } +void MeshChooserView::keyPressEvent(QKeyEvent *event) +{ + if (event->key() == Qt::Key_Escape) + QTimer::singleShot(0, this, &MeshChooserView::close); + + QQuickWidget::keyPressEvent(event); +} + void MeshChooserView::showEvent(QShowEvent *event) { const auto doc = g_StudioApp.GetCore()->GetDoc(); diff --git a/src/Authoring/Studio/Palettes/Inspector/MeshChooserView.h b/src/Authoring/Studio/Palettes/Inspector/MeshChooserView.h index b92de506..fb4673a6 100644 --- a/src/Authoring/Studio/Palettes/Inspector/MeshChooserView.h +++ b/src/Authoring/Studio/Palettes/Inspector/MeshChooserView.h @@ -59,6 +59,7 @@ Q_SIGNALS: protected: void focusInEvent(QFocusEvent *event) override; void focusOutEvent(QFocusEvent *event) override; + void keyPressEvent(QKeyEvent *event) override; Q_SIGNALS: void focusChanged(); diff --git a/src/Authoring/Studio/Palettes/Inspector/ObjectBrowserView.cpp b/src/Authoring/Studio/Palettes/Inspector/ObjectBrowserView.cpp index 18273ff4..1981c87a 100644 --- a/src/Authoring/Studio/Palettes/Inspector/ObjectBrowserView.cpp +++ b/src/Authoring/Studio/Palettes/Inspector/ObjectBrowserView.cpp @@ -140,6 +140,14 @@ void ObjectBrowserView::focusOutEvent(QFocusEvent *event) QTimer::singleShot(0, this, &QQuickWidget::close); } +void ObjectBrowserView::keyPressEvent(QKeyEvent *event) +{ + if (event->key() == Qt::Key_Escape) + QTimer::singleShot(0, this, &ObjectBrowserView::close); + + QQuickWidget::keyPressEvent(event); +} + void ObjectBrowserView::initialize() { CStudioPreferences::setQmlContextProperties(rootContext()); diff --git a/src/Authoring/Studio/Palettes/Inspector/ObjectBrowserView.h b/src/Authoring/Studio/Palettes/Inspector/ObjectBrowserView.h index faf92bef..bfe4af58 100644 --- a/src/Authoring/Studio/Palettes/Inspector/ObjectBrowserView.h +++ b/src/Authoring/Studio/Palettes/Inspector/ObjectBrowserView.h @@ -85,6 +85,7 @@ Q_SIGNALS: protected: void focusInEvent(QFocusEvent *event) override; void focusOutEvent(QFocusEvent *event) override; + void keyPressEvent(QKeyEvent *event) override; Q_SIGNALS: void focusChanged(); diff --git a/src/Authoring/Studio/Palettes/Inspector/TextureChooserView.cpp b/src/Authoring/Studio/Palettes/Inspector/TextureChooserView.cpp index 4ef7242c..b1c2bb4d 100644 --- a/src/Authoring/Studio/Palettes/Inspector/TextureChooserView.cpp +++ b/src/Authoring/Studio/Palettes/Inspector/TextureChooserView.cpp @@ -94,6 +94,14 @@ void TextureChooserView::focusOutEvent(QFocusEvent *event) QTimer::singleShot(0, this, &TextureChooserView::close); } +void TextureChooserView::keyPressEvent(QKeyEvent *event) +{ + if (event->key() == Qt::Key_Escape) + QTimer::singleShot(0, this, &TextureChooserView::close); + + QQuickWidget::keyPressEvent(event); +} + void TextureChooserView::showEvent(QShowEvent *event) { const auto doc = g_StudioApp.GetCore()->GetDoc(); diff --git a/src/Authoring/Studio/Palettes/Inspector/TextureChooserView.h b/src/Authoring/Studio/Palettes/Inspector/TextureChooserView.h index 5bd51367..e38db04a 100644 --- a/src/Authoring/Studio/Palettes/Inspector/TextureChooserView.h +++ b/src/Authoring/Studio/Palettes/Inspector/TextureChooserView.h @@ -55,6 +55,7 @@ Q_SIGNALS: protected: void focusOutEvent(QFocusEvent *event) override; + void keyPressEvent(QKeyEvent *event) override; private: void showEvent(QShowEvent *event) override; |