Remove ScanPopup Alt mode ("Keys may also be pressed afterwards").

The functionality of "select then press a key to get popup " has equivalent of using Ctrl+C+C on Hotkeys.
This commit is contained in:
shenleban tongying 2022-11-20 04:12:00 -05:00
parent 451fdb5c21
commit 664a1e87e4
6 changed files with 1 additions and 151 deletions

View file

@ -230,8 +230,6 @@ Preferences::Preferences():
startWithScanPopupOn( false ), startWithScanPopupOn( false ),
enableScanPopupModifiers( false ), enableScanPopupModifiers( false ),
scanPopupModifiers( 0 ), scanPopupModifiers( 0 ),
scanPopupAltMode( false ),
scanPopupAltModeSecs( 3 ),
ignoreOwnClipboardChanges( false ), ignoreOwnClipboardChanges( false ),
scanToMainWindow( false ), scanToMainWindow( false ),
ignoreDiacritics( false ), ignoreDiacritics( false ),
@ -890,9 +888,6 @@ Class load()
c.preferences.startWithScanPopupOn = ( preferences.namedItem( "startWithScanPopupOn" ).toElement().text() == "1" ); c.preferences.startWithScanPopupOn = ( preferences.namedItem( "startWithScanPopupOn" ).toElement().text() == "1" );
c.preferences.enableScanPopupModifiers = ( preferences.namedItem( "enableScanPopupModifiers" ).toElement().text() == "1" ); c.preferences.enableScanPopupModifiers = ( preferences.namedItem( "enableScanPopupModifiers" ).toElement().text() == "1" );
c.preferences.scanPopupModifiers = ( preferences.namedItem( "scanPopupModifiers" ).toElement().text().toULong() ); c.preferences.scanPopupModifiers = ( preferences.namedItem( "scanPopupModifiers" ).toElement().text().toULong() );
c.preferences.scanPopupAltMode = ( preferences.namedItem( "scanPopupAltMode" ).toElement().text() == "1" );
if ( !preferences.namedItem( "scanPopupAltModeSecs" ).isNull() )
c.preferences.scanPopupAltModeSecs = preferences.namedItem( "scanPopupAltModeSecs" ).toElement().text().toUInt();
c.preferences.ignoreOwnClipboardChanges = ( preferences.namedItem( "ignoreOwnClipboardChanges" ).toElement().text() == "1" ); c.preferences.ignoreOwnClipboardChanges = ( preferences.namedItem( "ignoreOwnClipboardChanges" ).toElement().text() == "1" );
c.preferences.scanToMainWindow = ( preferences.namedItem( "scanToMainWindow" ).toElement().text() == "1" ); c.preferences.scanToMainWindow = ( preferences.namedItem( "scanToMainWindow" ).toElement().text() == "1" );
c.preferences.ignoreDiacritics = ( preferences.namedItem( "ignoreDiacritics" ).toElement().text() == "1" ); c.preferences.ignoreDiacritics = ( preferences.namedItem( "ignoreDiacritics" ).toElement().text() == "1" );
@ -1756,14 +1751,6 @@ void save( Class const & c )
opt.appendChild( dd.createTextNode( QString::number( c.preferences.scanPopupModifiers ) ) ); opt.appendChild( dd.createTextNode( QString::number( c.preferences.scanPopupModifiers ) ) );
preferences.appendChild( opt ); preferences.appendChild( opt );
opt = dd.createElement( "scanPopupAltMode" );
opt.appendChild( dd.createTextNode( c.preferences.scanPopupAltMode ? "1":"0" ) );
preferences.appendChild( opt );
opt = dd.createElement( "scanPopupAltModeSecs" );
opt.appendChild( dd.createTextNode( QString::number( c.preferences.scanPopupAltModeSecs ) ) );
preferences.appendChild( opt );
opt = dd.createElement( "ignoreOwnClipboardChanges" ); opt = dd.createElement( "ignoreOwnClipboardChanges" );
opt.appendChild( dd.createTextNode( c.preferences.ignoreOwnClipboardChanges ? "1":"0" ) ); opt.appendChild( dd.createTextNode( c.preferences.ignoreOwnClipboardChanges ? "1":"0" ) );
preferences.appendChild( opt ); preferences.appendChild( opt );

View file

@ -321,8 +321,6 @@ struct Preferences
bool startWithScanPopupOn; bool startWithScanPopupOn;
bool enableScanPopupModifiers; bool enableScanPopupModifiers;
unsigned long scanPopupModifiers; // Combination of KeyboardState::Modifier unsigned long scanPopupModifiers; // Combination of KeyboardState::Modifier
bool scanPopupAltMode; // When you press modifier shortly after the selection
unsigned scanPopupAltModeSecs;
bool ignoreOwnClipboardChanges; bool ignoreOwnClipboardChanges;
bool scanToMainWindow; bool scanToMainWindow;

View file

@ -201,8 +201,6 @@ Preferences::Preferences( QWidget * parent, Config::Class & cfg_ ):
ui.leftShift->setChecked( p.scanPopupModifiers & KeyboardState::LeftShift ); ui.leftShift->setChecked( p.scanPopupModifiers & KeyboardState::LeftShift );
ui.rightShift->setChecked( p.scanPopupModifiers & KeyboardState::RightShift ); ui.rightShift->setChecked( p.scanPopupModifiers & KeyboardState::RightShift );
ui.scanPopupAltMode->setChecked( p.scanPopupAltMode );
ui.scanPopupAltModeSecs->setValue( p.scanPopupAltModeSecs );
ui.ignoreOwnClipboardChanges->setChecked( p.ignoreOwnClipboardChanges ); ui.ignoreOwnClipboardChanges->setChecked( p.ignoreOwnClipboardChanges );
ui.scanToMainWindow->setChecked( p.scanToMainWindow ); ui.scanToMainWindow->setChecked( p.scanToMainWindow );
@ -421,8 +419,6 @@ Config::Preferences Preferences::getPreferences()
p.scanPopupModifiers += ui.leftShift->isChecked() ? KeyboardState::LeftShift: 0; p.scanPopupModifiers += ui.leftShift->isChecked() ? KeyboardState::LeftShift: 0;
p.scanPopupModifiers += ui.rightShift->isChecked() ? KeyboardState::RightShift: 0; p.scanPopupModifiers += ui.rightShift->isChecked() ? KeyboardState::RightShift: 0;
p.scanPopupAltMode = ui.scanPopupAltMode->isChecked();
p.scanPopupAltModeSecs = ui.scanPopupAltModeSecs->value();
p.ignoreOwnClipboardChanges = ui.ignoreOwnClipboardChanges->isChecked(); p.ignoreOwnClipboardChanges = ui.ignoreOwnClipboardChanges->isChecked();
p.scanToMainWindow = ui.scanToMainWindow->isChecked(); p.scanToMainWindow = ui.scanToMainWindow->isChecked();
#ifdef HAVE_X11 #ifdef HAVE_X11

View file

@ -24,7 +24,7 @@
<item> <item>
<widget class="QTabWidget" name="tabWidget"> <widget class="QTabWidget" name="tabWidget">
<property name="currentIndex"> <property name="currentIndex">
<number>1</number> <number>0</number>
</property> </property>
<property name="iconSize"> <property name="iconSize">
<size> <size>
@ -662,67 +662,6 @@ in the pressed state when the word selection changes.</string>
</property> </property>
</widget> </widget>
</item> </item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QCheckBox" name="scanPopupAltMode">
<property name="toolTip">
<string>Normally, in order to activate a popup you have to
maintain the chosen keys pressed while you select
a word. With this enabled, the chosen keys may also
be pressed shortly after the selection is done.</string>
</property>
<property name="text">
<string>Keys may also be pressed afterwards, within</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="scanPopupAltModeSecs">
<property name="toolTip">
<string>To avoid false positives, the keys are only monitored
after the selection's done for a limited amount of
seconds, which is specified here.</string>
</property>
<property name="wrapping">
<bool>false</bool>
</property>
<property name="frame">
<bool>true</bool>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>99</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_7">
<property name="text">
<string>secs</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item> <item>
<widget class="QCheckBox" name="ignoreOwnClipboardChanges"> <widget class="QCheckBox" name="ignoreOwnClipboardChanges">
<property name="toolTip"> <property name="toolTip">
@ -1858,8 +1797,6 @@ from Stardict, Babylon and GLS dictionaries</string>
<tabstop>rightCtrl</tabstop> <tabstop>rightCtrl</tabstop>
<tabstop>leftShift</tabstop> <tabstop>leftShift</tabstop>
<tabstop>winKey</tabstop> <tabstop>winKey</tabstop>
<tabstop>scanPopupAltMode</tabstop>
<tabstop>scanPopupAltModeSecs</tabstop>
<tabstop>useProxyServer</tabstop> <tabstop>useProxyServer</tabstop>
<tabstop>proxyType</tabstop> <tabstop>proxyType</tabstop>
<tabstop>proxyHost</tabstop> <tabstop>proxyHost</tabstop>

View file

@ -289,18 +289,6 @@ ScanPopup::ScanPopup( QWidget * parent,
connect( &hideTimer, SIGNAL( timeout() ), connect( &hideTimer, SIGNAL( timeout() ),
this, SLOT( hideTimerExpired() ) ); this, SLOT( hideTimerExpired() ) );
altModeExpirationTimer.setSingleShot( true );
altModeExpirationTimer.setInterval( cfg.preferences.scanPopupAltModeSecs * 1000 );
connect( &altModeExpirationTimer, SIGNAL( timeout() ),
this, SLOT( altModeExpired() ) );
// This one polls constantly for modifiers while alt mode lasts
altModePollingTimer.setSingleShot( false );
altModePollingTimer.setInterval( 50 );
connect( &altModePollingTimer, SIGNAL( timeout() ),
this, SLOT( altModePoll() ) );
mouseGrabPollTimer.setSingleShot( false ); mouseGrabPollTimer.setSingleShot( false );
mouseGrabPollTimer.setInterval( 10 ); mouseGrabPollTimer.setInterval( 10 );
connect( &mouseGrabPollTimer, SIGNAL( timeout() ), connect( &mouseGrabPollTimer, SIGNAL( timeout() ),
@ -477,10 +465,6 @@ void ScanPopup::translateWord( QString const & word )
if ( !pendingInputPhrase.isValid() ) if ( !pendingInputPhrase.isValid() )
return; // Nothing there return; // Nothing there
// In case we had any timers engaged before, cancel them now.
altModePollingTimer.stop();
altModeExpirationTimer.stop();
#ifdef HAVE_X11 #ifdef HAVE_X11
emit hideScanFlag(); emit hideScanFlag();
#endif #endif
@ -555,17 +539,6 @@ void ScanPopup::handleInputWord( QString const & str, bool forcePopup )
pendingInputPhrase = sanitizedPhrase; pendingInputPhrase = sanitizedPhrase;
if ( !pendingInputPhrase.isValid() )
{
if ( cfg.preferences.scanPopupAltMode )
{
// In case we had any timers engaged before, cancel them now, since
// we're not going to translate anything anymore.
altModePollingTimer.stop();
altModeExpirationTimer.stop();
}
return;
}
#ifdef HAVE_X11 #ifdef HAVE_X11
if ( cfg.preferences.showScanFlag ) { if ( cfg.preferences.showScanFlag ) {
@ -575,19 +548,6 @@ void ScanPopup::handleInputWord( QString const & str, bool forcePopup )
} }
#endif #endif
// Check key modifiers
if ( cfg.preferences.enableScanPopupModifiers && !checkModifiersPressed( cfg.preferences.scanPopupModifiers ) )
{
if ( cfg.preferences.scanPopupAltMode )
{
altModePollingTimer.start();
altModeExpirationTimer.start();
}
return;
}
inputPhrase = pendingInputPhrase; inputPhrase = pendingInputPhrase;
engagePopup( forcePopup ); engagePopup( forcePopup );
} }
@ -1119,31 +1079,6 @@ void ScanPopup::hideTimerExpired()
hideWindow(); hideWindow();
} }
void ScanPopup::altModeExpired()
{
// The alt mode duration has expired, so there's no need to poll for modifiers
// anymore.
altModePollingTimer.stop();
}
void ScanPopup::altModePoll()
{
if ( !pendingInputPhrase.isValid() )
{
altModePollingTimer.stop();
altModeExpirationTimer.stop();
}
else
if ( checkModifiersPressed( cfg.preferences.scanPopupModifiers ) )
{
altModePollingTimer.stop();
altModeExpirationTimer.stop();
inputPhrase = pendingInputPhrase;
engagePopup( false );
}
}
void ScanPopup::pageLoaded( ArticleView * ) void ScanPopup::pageLoaded( ArticleView * )
{ {
if( !isVisible() ) if( !isVisible() )

View file

@ -157,7 +157,6 @@ private:
QTimer hideTimer; // When mouse leaves the window, a grace period is QTimer hideTimer; // When mouse leaves the window, a grace period is
// given for it to return back. If it doesn't before // given for it to return back. If it doesn't before
// this timer expires, the window gets hidden. // this timer expires, the window gets hidden.
QTimer altModeExpirationTimer, altModePollingTimer; // Timers for alt mode
QTimer mouseGrabPollTimer; QTimer mouseGrabPollTimer;
@ -209,8 +208,6 @@ private slots:
void on_goForwardButton_clicked(); void on_goForwardButton_clicked();
void hideTimerExpired(); void hideTimerExpired();
void altModeExpired();
void altModePoll();
/// Called repeatedly once the popup is initially engaged and we monitor the /// Called repeatedly once the popup is initially engaged and we monitor the
/// mouse as it may move away from the window. This simulates mouse grab, in /// mouse as it may move away from the window. This simulates mouse grab, in