diff --git a/fixx11h.h b/fixx11h.h new file mode 100644 index 00000000..eb576901 --- /dev/null +++ b/fixx11h.h @@ -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 + diff --git a/mainwindow.cc b/mainwindow.cc index 215ba48a..9e35d0f6 100644 --- a/mainwindow.cc +++ b/mainwindow.cc @@ -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 ); diff --git a/mainwindow.hh b/mainwindow.hh index 97a7f533..fa686587 100644 --- a/mainwindow.hh +++ b/mainwindow.hh @@ -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 +#endif + using std::string; using std::vector;