2009-01-28 20:55:45 +00:00
|
|
|
/* This file is (c) 2008-2009 Konstantin Isakov <ikm@users.sf.net>
|
|
|
|
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */
|
|
|
|
|
|
|
|
#include "scanpopup.hh"
|
|
|
|
#include <QUrl>
|
|
|
|
|
|
|
|
ScanPopup::ScanPopup( QWidget * parent,
|
|
|
|
ArticleNetworkAccessManager & articleNetMgr_ ):
|
|
|
|
QDialog( parent ), articleNetMgr( articleNetMgr_ )
|
|
|
|
{
|
|
|
|
ui.setupUi( this );
|
|
|
|
|
|
|
|
//setWindowFlags( Qt::Tool );
|
|
|
|
|
|
|
|
ui.definition->page()->setNetworkAccessManager( &articleNetMgr );
|
|
|
|
|
2009-01-29 01:17:59 +00:00
|
|
|
#if 0 // Since this is unconditional this bugs a lot
|
2009-01-28 20:55:45 +00:00
|
|
|
connect( QApplication::clipboard(), SIGNAL( changed( QClipboard::Mode ) ),
|
|
|
|
this, SLOT( clipboardChanged( QClipboard::Mode ) ) );
|
2009-01-29 01:17:59 +00:00
|
|
|
#endif
|
2009-01-28 20:55:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ScanPopup::clipboardChanged( QClipboard::Mode m )
|
|
|
|
{
|
|
|
|
printf( "clipboard changed\n" );
|
|
|
|
|
|
|
|
QString subtype = "plain";
|
|
|
|
|
|
|
|
QString inWord = QApplication::clipboard()->text( subtype, m );
|
|
|
|
|
|
|
|
if ( !inWord.size() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
setWindowTitle( inWord );
|
|
|
|
|
|
|
|
show();
|
|
|
|
activateWindow();
|
|
|
|
//raise();
|
|
|
|
|
|
|
|
QUrl req;
|
|
|
|
|
|
|
|
req.setScheme( "gdlookup" );
|
|
|
|
req.setHost( "localhost" );
|
|
|
|
req.addQueryItem( "word", inWord );
|
|
|
|
req.addQueryItem( "group",
|
|
|
|
"whatever" );
|
|
|
|
|
|
|
|
ui.definition->load( req );
|
|
|
|
}
|
|
|
|
|