feat(frontend): Add keypress event.

Description: 添加esc按键监听隐藏主界面

Log: 添加esc按键监听隐藏主界面
This commit is contained in:
zhangjiaping 2021-01-21 14:20:44 +08:00
parent db3e947e95
commit c93292bf4b
5 changed files with 50 additions and 38 deletions

View File

@ -330,6 +330,16 @@ bool MainWindow::nativeEvent(const QByteArray &eventType, void *message, long *r
return false;
}
void MainWindow::keyPressEvent(QKeyEvent *event)
{
if (event->key() == Qt::Key_Escape) {
this->hide();
m_search_result_thread->requestInterruption();
m_search_result_thread->quit();
}
return QWidget::keyPressEvent(event);
}
void MainWindow::paintEvent(QPaintEvent *event) {
Q_UNUSED(event)
@ -345,6 +355,6 @@ void MainWindow::paintEvent(QPaintEvent *event) {
p.setOpacity(trans);
p.setPen(Qt::NoPen);
p.drawRoundedRect(rect, 6, 6);
QWidget::paintEvent(event);
return QWidget::paintEvent(event);
}

View File

@ -36,6 +36,7 @@
#include <QLabel>
#include <QFrame>
#include <QPushButton>
#include <QKeyEvent>
#include <QGSettings/QGSettings>
#include <QSystemTrayIcon>
#include "content-widget.h"
@ -94,6 +95,7 @@ private:
protected:
void paintEvent(QPaintEvent *);
void keyPressEvent(QKeyEvent *event);
void initUi();
public Q_SLOTS:

View File

@ -19,37 +19,37 @@
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/content-widget.cpp" line="585"/>
<location filename="../../src/content-widget.cpp" line="586"/>
<source>Apps</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/content-widget.cpp" line="587"/>
<location filename="../../src/content-widget.cpp" line="588"/>
<source>Settings</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/content-widget.cpp" line="589"/>
<location filename="../../src/content-widget.cpp" line="590"/>
<source>Files</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/content-widget.cpp" line="591"/>
<location filename="../../src/content-widget.cpp" line="592"/>
<source>Dirs</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/content-widget.cpp" line="593"/>
<location filename="../../src/content-widget.cpp" line="594"/>
<source>File Contents</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/content-widget.cpp" line="595"/>
<location filename="../../src/content-widget.cpp" line="596"/>
<source>Best Matches</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/content-widget.cpp" line="597"/>
<location filename="../../src/content-widget.cpp" line="598"/>
<source>Unknown</source>
<translation type="unfinished"></translation>
</message>
@ -65,12 +65,12 @@
<context>
<name>MainWindow</name>
<message>
<location filename="../../src/mainwindow.cpp" line="108"/>
<location filename="../../src/mainwindow.cpp" line="110"/>
<source>Global Search</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/mainwindow.cpp" line="161"/>
<location filename="../../src/mainwindow.cpp" line="163"/>
<source>Search</source>
<translation type="unfinished"></translation>
</message>
@ -106,7 +106,7 @@
<context>
<name>QObject</name>
<message>
<location filename="../../src/main.cpp" line="104"/>
<location filename="../../src/main.cpp" line="106"/>
<source>ukui-search is already running!</source>
<translation type="unfinished"></translation>
</message>
@ -122,12 +122,12 @@
<context>
<name>SearchDetailView</name>
<message>
<location filename="../../src/control/search-detail-view.cpp" line="346"/>
<location filename="../../src/control/search-detail-view.cpp" line="340"/>
<source>Path</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/control/search-detail-view.cpp" line="354"/>
<location filename="../../src/control/search-detail-view.cpp" line="348"/>
<source>Last time modified</source>
<translation type="unfinished"></translation>
</message>

View File

@ -19,37 +19,37 @@
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/content-widget.cpp" line="585"/>
<location filename="../../src/content-widget.cpp" line="586"/>
<source>Apps</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/content-widget.cpp" line="587"/>
<location filename="../../src/content-widget.cpp" line="588"/>
<source>Settings</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/content-widget.cpp" line="589"/>
<location filename="../../src/content-widget.cpp" line="590"/>
<source>Files</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/content-widget.cpp" line="591"/>
<location filename="../../src/content-widget.cpp" line="592"/>
<source>Dirs</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/content-widget.cpp" line="593"/>
<location filename="../../src/content-widget.cpp" line="594"/>
<source>File Contents</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/content-widget.cpp" line="595"/>
<location filename="../../src/content-widget.cpp" line="596"/>
<source>Best Matches</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/content-widget.cpp" line="597"/>
<location filename="../../src/content-widget.cpp" line="598"/>
<source>Unknown</source>
<translation type="unfinished"></translation>
</message>
@ -65,12 +65,12 @@
<context>
<name>MainWindow</name>
<message>
<location filename="../../src/mainwindow.cpp" line="108"/>
<location filename="../../src/mainwindow.cpp" line="110"/>
<source>Global Search</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/mainwindow.cpp" line="161"/>
<location filename="../../src/mainwindow.cpp" line="163"/>
<source>Search</source>
<translation type="unfinished"></translation>
</message>
@ -106,7 +106,7 @@
<context>
<name>QObject</name>
<message>
<location filename="../../src/main.cpp" line="104"/>
<location filename="../../src/main.cpp" line="106"/>
<source>ukui-search is already running!</source>
<translation type="unfinished"></translation>
</message>
@ -122,12 +122,12 @@
<context>
<name>SearchDetailView</name>
<message>
<location filename="../../src/control/search-detail-view.cpp" line="346"/>
<location filename="../../src/control/search-detail-view.cpp" line="340"/>
<source>Path</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/control/search-detail-view.cpp" line="354"/>
<location filename="../../src/control/search-detail-view.cpp" line="348"/>
<source>Last time modified</source>
<translation type="unfinished"></translation>
</message>

View File

@ -19,37 +19,37 @@
<translation></translation>
</message>
<message>
<location filename="../../src/content-widget.cpp" line="585"/>
<location filename="../../src/content-widget.cpp" line="586"/>
<source>Apps</source>
<translation></translation>
</message>
<message>
<location filename="../../src/content-widget.cpp" line="587"/>
<location filename="../../src/content-widget.cpp" line="588"/>
<source>Settings</source>
<translation></translation>
</message>
<message>
<location filename="../../src/content-widget.cpp" line="589"/>
<location filename="../../src/content-widget.cpp" line="590"/>
<source>Files</source>
<translation></translation>
</message>
<message>
<location filename="../../src/content-widget.cpp" line="591"/>
<location filename="../../src/content-widget.cpp" line="592"/>
<source>Dirs</source>
<translation></translation>
</message>
<message>
<location filename="../../src/content-widget.cpp" line="593"/>
<location filename="../../src/content-widget.cpp" line="594"/>
<source>File Contents</source>
<translation></translation>
</message>
<message>
<location filename="../../src/content-widget.cpp" line="595"/>
<location filename="../../src/content-widget.cpp" line="596"/>
<source>Best Matches</source>
<translation></translation>
</message>
<message>
<location filename="../../src/content-widget.cpp" line="597"/>
<location filename="../../src/content-widget.cpp" line="598"/>
<source>Unknown</source>
<translation></translation>
</message>
@ -65,14 +65,14 @@
<context>
<name>MainWindow</name>
<message>
<location filename="../../src/mainwindow.cpp" line="108"/>
<location filename="../../src/mainwindow.cpp" line="110"/>
<source>Global Search</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/mainwindow.cpp" line="161"/>
<location filename="../../src/mainwindow.cpp" line="163"/>
<source>Search</source>
<translation></translation>
<translation></translation>
</message>
</context>
<context>
@ -106,7 +106,7 @@
<context>
<name>QObject</name>
<message>
<location filename="../../src/main.cpp" line="104"/>
<location filename="../../src/main.cpp" line="106"/>
<source>ukui-search is already running!</source>
<translation></translation>
</message>
@ -122,12 +122,12 @@
<context>
<name>SearchDetailView</name>
<message>
<location filename="../../src/control/search-detail-view.cpp" line="346"/>
<location filename="../../src/control/search-detail-view.cpp" line="340"/>
<source>Path</source>
<translation></translation>
</message>
<message>
<location filename="../../src/control/search-detail-view.cpp" line="354"/>
<location filename="../../src/control/search-detail-view.cpp" line="348"/>
<source>Last time modified</source>
<translation></translation>
</message>