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
|
|
|
|
|
|
|
private:
|
|
|
|
|
2009-02-06 17:04:11 +00:00
|
|
|
Config::Class & cfg;
|
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;
|
|
|
|
|
|
|
|
vector< QString > diacriticMatches, prefixMatches;
|
|
|
|
|
2009-02-06 13:05:25 +00:00
|
|
|
bool mouseEnteredOnce;
|
|
|
|
|
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 13:05:25 +00:00
|
|
|
virtual void mouseMoveEvent( QMouseEvent * event );
|
2009-02-01 00:08:08 +00:00
|
|
|
virtual void leaveEvent( QEvent * event );
|
|
|
|
|
|
|
|
void popupWordlist( vector< QString > const &, QToolButton * button );
|
2009-01-28 20:55:45 +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 & );
|
|
|
|
void prefixMatchComplete( WordFinderResults r );
|
|
|
|
void diacriticButtonClicked();
|
|
|
|
void prefixButtonClicked();
|
|
|
|
void initialWordClicked();
|
|
|
|
void pinButtonClicked( bool checked );
|
2009-01-28 20:55:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|