diff options
author | 2023-01-27 02:13:28 +0530 | |
---|---|---|
committer | 2023-01-27 10:10:17 +0530 | |
commit | 56c55a949854f9dd73b60e353be35bd31407cee0 (patch) | |
tree | 130a8f826e46c4969828a73d62060f716f0a9c37 | |
parent | 7fc4ce386626cd5d2c1e68258b16263732ca318d (diff) | |
download | whatsie-56c55a949854f9dd73b60e353be35bd31407cee0.tar.gz whatsie-56c55a949854f9dd73b60e353be35bd31407cee0.zip |
chore: escape key to close child windows
-rw-r--r-- | src/about.cpp | 8 | ||||
-rw-r--r-- | src/about.h | 3 | ||||
-rw-r--r-- | src/downloadmanagerwidget.cpp | 8 | ||||
-rw-r--r-- | src/downloadmanagerwidget.h | 2 |
4 files changed, 21 insertions, 0 deletions
diff --git a/src/about.cpp b/src/about.cpp index ba54a7e..81657e8 100644 --- a/src/about.cpp +++ b/src/about.cpp @@ -92,6 +92,14 @@ void About::on_debugInfoButton_clicked() { } } +void About::keyPressEvent(QKeyEvent *e) +{ + if (e->key() == Qt::Key_Escape) + this->close(); + + QWidget::keyPressEvent(e); +} + void About::on_donate_2_clicked() { QDesktopServices::openUrl(QUrl("https://opencollective.com/whatsie")); } diff --git a/src/about.h b/src/about.h index 74bfe0d..cd9e978 100644 --- a/src/about.h +++ b/src/about.h @@ -2,6 +2,7 @@ #define ABOUT_H #include <QWidget> +#include <QKeyEvent> namespace Ui { class About; @@ -15,6 +16,8 @@ public: explicit About(QWidget *parent = nullptr); ~About(); +protected slots: + void keyPressEvent(QKeyEvent *e); private slots: void on_debugInfoButton_clicked(); diff --git a/src/downloadmanagerwidget.cpp b/src/downloadmanagerwidget.cpp index 2d75287..e9865c8 100644 --- a/src/downloadmanagerwidget.cpp +++ b/src/downloadmanagerwidget.cpp @@ -56,3 +56,11 @@ void DownloadManagerWidget::on_open_download_dir_clicked() { QApplication::applicationName())
.toString());
}
+
+void DownloadManagerWidget::keyPressEvent(QKeyEvent *e)
+{
+ if (e->key() == Qt::Key_Escape)
+ this->close();
+
+ QWidget::keyPressEvent(e);
+}
diff --git a/src/downloadmanagerwidget.h b/src/downloadmanagerwidget.h index 7fa0950..4a8d059 100644 --- a/src/downloadmanagerwidget.h +++ b/src/downloadmanagerwidget.h @@ -75,6 +75,8 @@ public: // will be shown on the screen.
void downloadRequested(QWebEngineDownloadItem *webItem);
+protected slots:
+ void keyPressEvent(QKeyEvent *e);
private slots:
void on_open_download_dir_clicked();
|