Add close after Escape pressed on info and config windows

This commit is contained in:
lupoDharkael
2017-05-25 15:11:14 +02:00
parent bc1f442d21
commit 3718a45394
4 changed files with 21 additions and 0 deletions

View File

@@ -23,6 +23,7 @@
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QGroupBox> #include <QGroupBox>
#include <QLabel> #include <QLabel>
#include <QKeyEvent>
// ConfigWindow contains the menus where you can configure the application // ConfigWindow contains the menus where you can configure the application
@@ -47,5 +48,12 @@ ConfigWindow::ConfigWindow(QWidget *parent) : QWidget(parent) {
m_buttonListView->setFlow(QListWidget::TopToBottom); m_buttonListView->setFlow(QListWidget::TopToBottom);
baseLayout->addWidget(m_buttonListView); baseLayout->addWidget(m_buttonListView);
show(); show();
} }
void ConfigWindow::keyPressEvent(QKeyEvent *e) {
if (e->key() == Qt::Key_Escape) {
close();
}
}

View File

@@ -31,6 +31,9 @@ public:
signals: signals:
void setDefaults(); void setDefaults();
protected:
void keyPressEvent(QKeyEvent *);
private: private:
}; };

View File

@@ -21,6 +21,7 @@
#include <QTableWidget> #include <QTableWidget>
#include <QHeaderView> #include <QHeaderView>
#include <QLabel> #include <QLabel>
#include <QKeyEvent>
// InfoWindow show basic information about the usage of Flameshot // InfoWindow show basic information about the usage of Flameshot
@@ -90,3 +91,9 @@ void InfoWindow::initInfoTable() {
table->horizontalHeader()->setSizePolicy(QSizePolicy::Expanding, table->horizontalHeader()->setSizePolicy(QSizePolicy::Expanding,
QSizePolicy::Expanding); QSizePolicy::Expanding);
} }
void InfoWindow::keyPressEvent(QKeyEvent *e) {
if (e->key() == Qt::Key_Escape) {
close();
}
}

View File

@@ -27,6 +27,9 @@ class InfoWindow : public QWidget {
public: public:
explicit InfoWindow(QWidget *parent = 0); explicit InfoWindow(QWidget *parent = 0);
protected:
void keyPressEvent(QKeyEvent *);
private: private:
void initInfoTable(); void initInfoTable();
QVBoxLayout *layout; QVBoxLayout *layout;