mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 19:24:08 +00:00
Merge pull request #2 from VVSiz/review/select_on_click
Translate line should select all on mouse click that brings focus
This commit is contained in:
commit
7525e456fb
63
fixx11h.h
Normal file
63
fixx11h.h
Normal file
|
@ -0,0 +1,63 @@
|
|||
// This is a standard way (e.g., in KDE libs) of dealing
|
||||
// with X11 headers mess.
|
||||
|
||||
#ifdef Unsorted
|
||||
#undef Unsorted
|
||||
#endif
|
||||
|
||||
#ifdef None
|
||||
#undef None
|
||||
#endif
|
||||
|
||||
#ifdef Bool
|
||||
#undef Bool
|
||||
#endif
|
||||
|
||||
#ifdef FontChange
|
||||
#undef FontChange
|
||||
#endif
|
||||
|
||||
#ifdef KeyPress
|
||||
#undef KeyPress
|
||||
#endif
|
||||
|
||||
#ifdef KeyRelease
|
||||
#undef KeyRelease
|
||||
#endif
|
||||
|
||||
#ifdef Above
|
||||
#undef Above
|
||||
#endif
|
||||
|
||||
#ifdef Below
|
||||
#undef Below
|
||||
#endif
|
||||
|
||||
#ifdef FocusIn
|
||||
#undef FocusIn
|
||||
#endif
|
||||
|
||||
#ifdef FocusOut
|
||||
#undef FocusOut
|
||||
#endif
|
||||
|
||||
#ifdef Always
|
||||
#undef Always
|
||||
#endif
|
||||
|
||||
#ifdef Success
|
||||
#undef Success
|
||||
#endif
|
||||
|
||||
#ifdef GrayScale
|
||||
#undef GrayScale
|
||||
#endif
|
||||
|
||||
#ifdef Status
|
||||
#undef Status
|
||||
#endif
|
||||
|
||||
#ifdef CursorShape
|
||||
#undef CursorShape
|
||||
#endif
|
||||
|
|
@ -468,7 +468,7 @@ void MainWindow::mousePressEvent( QMouseEvent *event)
|
|||
QClipboard::Selection);
|
||||
ui.translateLine->setText(str);
|
||||
|
||||
QKeyEvent ev(QEvent::Type(6)/*QEvent::KeyPress*/, Qt::Key_Enter,
|
||||
QKeyEvent ev(QEvent::KeyPress, Qt::Key_Enter,
|
||||
Qt::NoModifier);
|
||||
QApplication::sendEvent(ui.translateLine, &ev);
|
||||
}
|
||||
|
@ -1413,7 +1413,7 @@ bool MainWindow::eventFilter( QObject * obj, QEvent * ev )
|
|||
|
||||
if ( obj == ui.translateLine )
|
||||
{
|
||||
if ( ev->type() == /*QEvent::KeyPress*/ 6 )
|
||||
if ( ev->type() == QEvent::KeyPress )
|
||||
{
|
||||
QKeyEvent * keyEvent = static_cast< QKeyEvent * >( ev );
|
||||
|
||||
|
@ -1424,11 +1424,21 @@ bool MainWindow::eventFilter( QObject * obj, QEvent * ev )
|
|||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
if ( ev->type() == QEvent::FocusIn ) {
|
||||
QFocusEvent * focusEvent = static_cast< QFocusEvent * >( ev );
|
||||
|
||||
// select all on mouse click
|
||||
if ( focusEvent->reason() == Qt::MouseFocusReason ) {
|
||||
QTimer::singleShot(0, this, SLOT(focusTranslateLine()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
if ( obj == ui.wordList )
|
||||
{
|
||||
if ( ev->type() == /*QEvent::KeyPress*/ 6 )
|
||||
if ( ev->type() == QEvent::KeyPress )
|
||||
{
|
||||
QKeyEvent * keyEvent = static_cast< QKeyEvent * >( ev );
|
||||
|
||||
|
@ -1475,7 +1485,7 @@ bool MainWindow::eventFilter( QObject * obj, QEvent * ev )
|
|||
}
|
||||
else
|
||||
if (obj == ui.dictsList) {
|
||||
if ( ev->type() == /*QEvent::KeyPress*/ 6 )
|
||||
if ( ev->type() == QEvent::KeyPress )
|
||||
{
|
||||
QKeyEvent * keyEvent = static_cast< QKeyEvent * >( ev );
|
||||
|
||||
|
|
|
@ -19,11 +19,14 @@
|
|||
#include "scanpopup.hh"
|
||||
#include "articleview.hh"
|
||||
#include "wordfinder.hh"
|
||||
#include "hotkeywrapper.hh"
|
||||
#include "dictionarybar.hh"
|
||||
#include "history.hh"
|
||||
#include "hotkeywrapper.hh"
|
||||
|
||||
#ifdef Q_WS_X11
|
||||
#include <fixx11h.h>
|
||||
#endif
|
||||
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
|
|
Loading…
Reference in a new issue