gui: handle ESC (to quit) and CTRL+L (focus on searchbar and select content)

Šī revīzija ir iekļauta:
Albert S. 2018-12-29 20:21:13 +01:00
vecāks 5081f559df
revīzija 4b3b862e11
3 mainīti faili ar 25 papildinājumiem un 3 dzēšanām

Parādīt failu

@ -58,6 +58,26 @@ bool MainWindow::pdfTabActive()
return ui->tabWidget->currentIndex() == 1;
}
void MainWindow::keyPressEvent(QKeyEvent *event)
{
bool quit = ((event->modifiers() & Qt::ControlModifier && event->key() == Qt::Key_Q) || event->key() == Qt::Key_Escape);
if(quit)
{
qApp->quit();
}
if(event->modifiers() & Qt::ControlModifier)
{
if(event->key() == Qt::Key_L)
{
ui->txtSearch->setFocus();
ui->txtSearch->selectAll();
}
}
QWidget::keyPressEvent(event);
}
void MainWindow::tabChanged()
{
if(pdfTabActive())

Parādīt failu

@ -5,7 +5,7 @@
#include <QThread>
#include <QTreeWidgetItem>
#include <QFileIconProvider>
#include <QKeyEvent>
#include "searchworker.h"
#include "pdfworker.h"
namespace Ui {
@ -35,6 +35,7 @@ private:
void connectSignals();
void makePdfPreview();
bool pdfTabActive();
void keyPressEvent(QKeyEvent *event) override;
unsigned int processedPdfPreviews;
private slots:
void lineEditReturnPressed();
@ -46,6 +47,7 @@ private slots:
void tabChanged();
void pdfPreviewReceived(PdfPreview preview);
void comboScaleChanged(QString text);
};
#endif // MAINWINDOW_H

Parādīt failu

@ -101,7 +101,7 @@
<item>
<widget class="QComboBox" name="comboScale">
<property name="currentText">
<string>75%</string>
<string>25%</string>
</property>
<item>
<property name="text">
@ -157,7 +157,7 @@
<item>
<widget class="QLabel" name="lblSearchResults">
<property name="text">
<string>TextLabel</string>
<string/>
</property>
</widget>
</item>