1. Add button to scan popup window to send translated word into main window

2. Add option to use main window instead of scan popup window
This commit is contained in:
Abs62 2011-11-16 16:52:25 +04:00
parent 35c103cd0b
commit 9a1ceff5d8
9 changed files with 68 additions and 0 deletions

View file

@ -107,6 +107,7 @@ Preferences::Preferences():
scanPopupUseUIAutomation( true ), scanPopupUseUIAutomation( true ),
scanPopupUseIAccessibleEx( true ), scanPopupUseIAccessibleEx( true ),
scanPopupUseGDMessage( true ), scanPopupUseGDMessage( true ),
scanToMainWindow( false ),
pronounceOnLoadMain( false ), pronounceOnLoadMain( false ),
pronounceOnLoadPopup( false ), pronounceOnLoadPopup( false ),
#ifdef Q_WS_WIN #ifdef Q_WS_WIN
@ -602,6 +603,7 @@ Class load() throw( exError )
c.preferences.scanPopupAltMode = ( preferences.namedItem( "scanPopupAltMode" ).toElement().text() == "1" ); c.preferences.scanPopupAltMode = ( preferences.namedItem( "scanPopupAltMode" ).toElement().text() == "1" );
if ( !preferences.namedItem( "scanPopupAltModeSecs" ).isNull() ) if ( !preferences.namedItem( "scanPopupAltModeSecs" ).isNull() )
c.preferences.scanPopupAltModeSecs = preferences.namedItem( "scanPopupAltModeSecs" ).toElement().text().toUInt(); c.preferences.scanPopupAltModeSecs = preferences.namedItem( "scanPopupAltModeSecs" ).toElement().text().toUInt();
c.preferences.scanToMainWindow = ( preferences.namedItem( "scanToMainWindow" ).toElement().text() == "1" );
c.preferences.scanPopupUseUIAutomation = ( preferences.namedItem( "scanPopupUseUIAutomation" ).toElement().text() == "1" ); c.preferences.scanPopupUseUIAutomation = ( preferences.namedItem( "scanPopupUseUIAutomation" ).toElement().text() == "1" );
c.preferences.scanPopupUseIAccessibleEx = ( preferences.namedItem( "scanPopupUseIAccessibleEx" ).toElement().text() == "1" ); c.preferences.scanPopupUseIAccessibleEx = ( preferences.namedItem( "scanPopupUseIAccessibleEx" ).toElement().text() == "1" );
c.preferences.scanPopupUseGDMessage = ( preferences.namedItem( "scanPopupUseGDMessage" ).toElement().text() == "1" ); c.preferences.scanPopupUseGDMessage = ( preferences.namedItem( "scanPopupUseGDMessage" ).toElement().text() == "1" );
@ -1114,6 +1116,10 @@ void save( Class const & c ) throw( exError )
opt.appendChild( dd.createTextNode( QString::number( c.preferences.scanPopupAltModeSecs ) ) ); opt.appendChild( dd.createTextNode( QString::number( c.preferences.scanPopupAltModeSecs ) ) );
preferences.appendChild( opt ); preferences.appendChild( opt );
opt = dd.createElement( "scanToMainWindow" );
opt.appendChild( dd.createTextNode( c.preferences.scanToMainWindow ? "1":"0" ) );
preferences.appendChild( opt );
opt = dd.createElement( "scanPopupUseUIAutomation" ); opt = dd.createElement( "scanPopupUseUIAutomation" );
opt.appendChild( dd.createTextNode( c.preferences.scanPopupUseUIAutomation ? "1":"0" ) ); opt.appendChild( dd.createTextNode( c.preferences.scanPopupUseUIAutomation ? "1":"0" ) );
preferences.appendChild( opt ); preferences.appendChild( opt );

View file

@ -162,6 +162,7 @@ struct Preferences
bool scanPopupUseUIAutomation; bool scanPopupUseUIAutomation;
bool scanPopupUseIAccessibleEx; bool scanPopupUseIAccessibleEx;
bool scanPopupUseGDMessage; bool scanPopupUseGDMessage;
bool scanToMainWindow;
// Whether the word should be pronounced on page load, in main window/popup // Whether the word should be pronounced on page load, in main window/popup
bool pronounceOnLoadMain, pronounceOnLoadPopup; bool pronounceOnLoadMain, pronounceOnLoadPopup;

View file

@ -806,6 +806,8 @@ void MainWindow::makeScanPopup()
connect( scanPopup.get(), SIGNAL(editGroupRequested( unsigned )), connect( scanPopup.get(), SIGNAL(editGroupRequested( unsigned )),
this,SLOT(editDictionaries( unsigned )), Qt::QueuedConnection ); this,SLOT(editDictionaries( unsigned )), Qt::QueuedConnection );
connect( scanPopup.get(), SIGNAL(sendWordToMainWindow( QString const & )),
this,SLOT(wordReceived( QString const & )), Qt::QueuedConnection );
} }
vector< sptr< Dictionary::Class > > const & MainWindow::getActiveDicts() vector< sptr< Dictionary::Class > > const & MainWindow::getActiveDicts()
@ -2465,3 +2467,10 @@ ArticleView * MainWindow::getCurrentArticleView()
} }
return 0; return 0;
} }
void MainWindow::wordReceived( const QString & word)
{
toggleMainWindow( true );
ui.translateLine->setText( word );
translateInputFinished();
}

View file

@ -46,6 +46,7 @@ public slots:
void messageFromAnotherInstanceReceived( QString const & ); void messageFromAnotherInstanceReceived( QString const & );
void showStatusBarMessage ( QString const &, int, QPixmap const & ); void showStatusBarMessage ( QString const &, int, QPixmap const & );
void wordReceived( QString const & );
private: private:

View file

@ -118,6 +118,7 @@ Preferences::Preferences( QWidget * parent, Config::Preferences const & p ):
ui.scanPopupAltMode->setChecked( p.scanPopupAltMode ); ui.scanPopupAltMode->setChecked( p.scanPopupAltMode );
ui.scanPopupAltModeSecs->setValue( p.scanPopupAltModeSecs ); ui.scanPopupAltModeSecs->setValue( p.scanPopupAltModeSecs );
ui.scanToMainWindow->setChecked( p.scanToMainWindow );
ui.scanPopupUseUIAutomation->setChecked( p.scanPopupUseUIAutomation ); ui.scanPopupUseUIAutomation->setChecked( p.scanPopupUseUIAutomation );
ui.scanPopupUseIAccessibleEx->setChecked( p.scanPopupUseIAccessibleEx ); ui.scanPopupUseIAccessibleEx->setChecked( p.scanPopupUseIAccessibleEx );
ui.scanPopupUseGDMessage->setChecked( p.scanPopupUseGDMessage ); ui.scanPopupUseGDMessage->setChecked( p.scanPopupUseGDMessage );
@ -232,6 +233,7 @@ Config::Preferences Preferences::getPreferences()
p.scanPopupAltMode = ui.scanPopupAltMode->isChecked(); p.scanPopupAltMode = ui.scanPopupAltMode->isChecked();
p.scanPopupAltModeSecs = ui.scanPopupAltModeSecs->value(); p.scanPopupAltModeSecs = ui.scanPopupAltModeSecs->value();
p.scanToMainWindow = ui.scanToMainWindow->isChecked();
p.scanPopupUseUIAutomation = ui.scanPopupUseUIAutomation->isChecked(); p.scanPopupUseUIAutomation = ui.scanPopupUseUIAutomation->isChecked();
p.scanPopupUseIAccessibleEx = ui.scanPopupUseIAccessibleEx->isChecked(); p.scanPopupUseIAccessibleEx = ui.scanPopupUseIAccessibleEx->isChecked();
p.scanPopupUseGDMessage = ui.scanPopupUseGDMessage->isChecked(); p.scanPopupUseGDMessage = ui.scanPopupUseGDMessage->isChecked();

View file

@ -545,6 +545,16 @@ seconds, which is specified here.</string>
</item> </item>
</layout> </layout>
</item> </item>
<item>
<widget class="QCheckBox" name="scanToMainWindow">
<property name="toolTip">
<string>Send translated word to main window instead of to show it in popup window</string>
</property>
<property name="text">
<string>Send translated word to main window</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>

View file

@ -296,6 +296,13 @@ void ScanPopup::handleInputWord( QString const & str )
void ScanPopup::engagePopup( bool giveFocus ) void ScanPopup::engagePopup( bool giveFocus )
{ {
if( cfg.preferences.scanToMainWindow )
{
// Send translated word to main window istead of show popup
emit sendWordToMainWindow( inputWord );
return;
}
/// Too large strings make window expand which is probably not what user /// Too large strings make window expand which is probably not what user
/// wants /// wants
ui.word->setText( elideInputWord() ); ui.word->setText( elideInputWord() );
@ -776,3 +783,15 @@ void ScanPopup::mutedDictionariesChanged()
if ( dictionaryBar.toggleViewAction()->isChecked() ) if ( dictionaryBar.toggleViewAction()->isChecked() )
definition->updateMutedContents(); definition->updateMutedContents();
} }
void ScanPopup::on_sendWordButton_clicked()
{
if ( !isVisible() )
return;
if( !ui.pinButton->isChecked() )
{
definition->closeSearch();
hideWindow();
}
emit sendWordToMainWindow( definition->getTitle() );
}

View file

@ -47,6 +47,8 @@ signals:
/// Forwarded from the dictionary bar, so that main window could act on this. /// Forwarded from the dictionary bar, so that main window could act on this.
void editGroupRequested( unsigned id ); void editGroupRequested( unsigned id );
/// Send word to main window
void sendWordToMainWindow( QString const & word );
public slots: public slots:
@ -132,6 +134,7 @@ private slots:
void pinButtonClicked( bool checked ); void pinButtonClicked( bool checked );
void on_showDictionaryBar_clicked( bool checked ); void on_showDictionaryBar_clicked( bool checked );
void showStatusBarMessage ( QString const &, int, QPixmap const & ); void showStatusBarMessage ( QString const &, int, QPixmap const & );
void on_sendWordButton_clicked();
void hideTimerExpired(); void hideTimerExpired();
void altModeExpired(); void altModeExpired();

View file

@ -104,6 +104,23 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QToolButton" name="sendWordButton">
<property name="toolTip">
<string>Send word to main window (Alt+W)</string>
</property>
<property name="text">
<string notr="true">...</string>
</property>
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/icons/programicon.png</normaloff>:/icons/programicon.png</iconset>
</property>
<property name="shortcut">
<string>Alt+W</string>
</property>
</widget>
</item>
<item> <item>
<spacer name="horizontalSpacer"> <spacer name="horizontalSpacer">
<property name="orientation"> <property name="orientation">