2009-02-05 14:21:47 +00:00
|
|
|
/* This file is (c) 2008-2009 Konstantin Isakov <ikm@users.berlios.de>
|
2009-01-28 20:55:45 +00:00
|
|
|
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */
|
|
|
|
|
|
|
|
#ifndef __SCANPOPUP_HH_INCLUDED__
|
|
|
|
#define __SCANPOPUP_HH_INCLUDED__
|
|
|
|
|
|
|
|
#include "article_netmgr.hh"
|
2009-02-01 00:08:08 +00:00
|
|
|
#include "articleview.hh"
|
|
|
|
#include "wordfinder.hh"
|
|
|
|
#include "keyboardstate.hh"
|
2009-02-05 20:55:00 +00:00
|
|
|
#include "config.hh"
|
2009-01-28 20:55:45 +00:00
|
|
|
#include "ui_scanpopup.h"
|
|
|
|
#include <QDialog>
|
|
|
|
#include <QClipboard>
|
|
|
|
|
2009-02-01 00:08:08 +00:00
|
|
|
/// This is a popup dialog to show translations when clipboard scanning mode
|
|
|
|
/// is enabled.
|
|
|
|
class ScanPopup: public QDialog, KeyboardState
|
2009-01-28 20:55:45 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2009-02-01 00:08:08 +00:00
|
|
|
ScanPopup( QWidget * parent,
|
2009-02-06 17:04:11 +00:00
|
|
|
Config::Class & cfg,
|
2009-02-01 00:08:08 +00:00
|
|
|
ArticleNetworkAccessManager &,
|
|
|
|
std::vector< sptr< Dictionary::Class > > const & allDictionaries,
|
|
|
|
Instances::Groups const & );
|
2009-01-28 20:55:45 +00:00
|
|
|
|
2009-02-08 20:20:02 +00:00
|
|
|
~ScanPopup();
|
|
|
|
|
|
|
|
/// Enables scanning. When the object is created, the scanning is disabled
|
|
|
|
/// initially.
|
|
|
|
void enableScanning();
|
|
|
|
/// Disables scanning.
|
|
|
|
void disableScanning();
|
|
|
|
|
2009-01-28 20:55:45 +00:00
|
|
|
private:
|
|
|
|
|
2009-02-06 17:04:11 +00:00
|
|
|
Config::Class & cfg;
|
2009-02-08 20:20:02 +00:00
|
|
|
bool isScanningEnabled;
|
2009-02-01 00:08:08 +00:00
|
|
|
std::vector< sptr< Dictionary::Class > > const & allDictionaries;
|
|
|
|
Instances::Groups const & groups;
|
2009-01-28 20:55:45 +00:00
|
|
|
Ui::ScanPopup ui;
|
2009-02-01 00:08:08 +00:00
|
|
|
ArticleView * definition;
|
|
|
|
QString inputWord;
|
|
|
|
WordFinder wordFinder;
|
|
|
|
|
2009-02-06 13:05:25 +00:00
|
|
|
bool mouseEnteredOnce;
|
|
|
|
|
2009-02-06 18:43:07 +00:00
|
|
|
QPoint startPos; // For window moving
|
|
|
|
|
2009-04-10 13:56:38 +00:00
|
|
|
QTimer hideTimer; // When mouse leaves the window, a grace period is
|
|
|
|
// given for it to return back. If it doesn't before
|
|
|
|
// this timer expires, the window gets hidden.
|
|
|
|
|
2009-02-02 20:28:53 +00:00
|
|
|
void handleInputWord( QString const & );
|
2009-02-01 00:08:08 +00:00
|
|
|
void initiateTranslation();
|
|
|
|
|
|
|
|
vector< sptr< Dictionary::Class > > const & getActiveDicts();
|
|
|
|
|
2009-02-06 18:43:07 +00:00
|
|
|
virtual void mousePressEvent( QMouseEvent * );
|
|
|
|
virtual void mouseMoveEvent( QMouseEvent * );
|
|
|
|
virtual void mouseReleaseEvent( QMouseEvent * );
|
2009-02-01 00:08:08 +00:00
|
|
|
virtual void leaveEvent( QEvent * event );
|
2009-04-10 13:56:38 +00:00
|
|
|
virtual void enterEvent( QEvent * event );
|
2009-02-06 17:16:33 +00:00
|
|
|
virtual void resizeEvent( QResizeEvent * event );
|
2009-02-08 21:26:35 +00:00
|
|
|
virtual void showEvent( QShowEvent * );
|
2009-02-01 00:08:08 +00:00
|
|
|
|
2009-02-05 20:55:00 +00:00
|
|
|
/// Returns inputWord, chopped with appended ... if it's too long/
|
|
|
|
QString elideInputWord();
|
|
|
|
|
2009-01-28 20:55:45 +00:00
|
|
|
private slots:
|
|
|
|
|
|
|
|
void clipboardChanged( QClipboard::Mode );
|
2009-02-02 20:28:53 +00:00
|
|
|
void mouseHovered( QString const & );
|
2009-02-01 00:08:08 +00:00
|
|
|
void currentGroupChanged( QString const & );
|
2009-03-26 19:00:08 +00:00
|
|
|
void prefixMatchFinished();
|
2009-04-10 15:52:08 +00:00
|
|
|
void on_wordListButton_clicked();
|
2009-02-01 00:08:08 +00:00
|
|
|
void pinButtonClicked( bool checked );
|
2009-04-10 13:56:38 +00:00
|
|
|
|
|
|
|
void hideTimerExpired();
|
2009-01-28 20:55:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|