clean: remove macOS unused code related to gestures (#1421)

* clean: remove macOS unused code related to gestures

We prefer native gestures and disabled gesture.cc long time ago, those are unused

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
shenleban tongying 2024-03-19 23:11:35 -04:00 committed by GitHub
parent b9e14f806c
commit 483381414f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 31 additions and 21 deletions

View file

@ -1,12 +1,12 @@
/* This file is (c) 2014 Abs62 /* This file is (c) 2014 Abs62
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */ * Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */
#ifndef __APPLE__
#include <QTouchEvent> #include <QTouchEvent>
#include <QSwipeGesture> #include <QSwipeGesture>
#include <QVariant> #include <QVariant>
#include <math.h> #include <math.h>
#include "ui/articleview.hh" #include "ui/articleview.hh"
#include "gestures.hh" #include "gestures.hh"
namespace Gestures { namespace Gestures {
@ -351,3 +351,5 @@ void unregisterRecognizers()
} }
} // namespace Gestures } // namespace Gestures
#endif

View file

@ -1,11 +1,11 @@
#ifndef __GESTURES_HH_INCLUDED__ #pragma once
#define __GESTURES_HH_INCLUDED__
#include <QGestureRecognizer> #ifndef __APPLE__
#include <QGesture> #include <QGestureRecognizer>
#include <QTimer> #include <QGesture>
#include <QEvent> #include <QTimer>
#include <QAction> #include <QEvent>
#include <QAction>
namespace Gestures { namespace Gestures {
@ -120,4 +120,5 @@ bool handleGestureEvent( QObject * obj, QEvent * event, GestureResult & result,
} // namespace Gestures } // namespace Gestures
#endif // __GESTURES_HH_INCLUDED__
#endif

View file

@ -250,10 +250,10 @@ ArticleView::ArticleView( QWidget * parent,
webview->setHtml( QString::fromStdString( html ) ); webview->setHtml( QString::fromStdString( html ) );
expandOptionalParts = cfg.preferences.alwaysExpandOptionalParts; expandOptionalParts = cfg.preferences.alwaysExpandOptionalParts;
#ifndef Q_OS_MACOS
webview->grabGesture( Gestures::GDPinchGestureType ); webview->grabGesture( Gestures::GDPinchGestureType );
webview->grabGesture( Gestures::GDSwipeGestureType ); webview->grabGesture( Gestures::GDSwipeGestureType );
#endif
// Variable name for store current selection range // Variable name for store current selection range
rangeVarName = QString( "sr_%1" ).arg( QString::number( (quint64)this, 16 ) ); rangeVarName = QString( "sr_%1" ).arg( QString::number( (quint64)this, 16 ) );
@ -300,8 +300,10 @@ ArticleView::~ArticleView()
cleanupTemp(); cleanupTemp();
audioPlayer->stop(); audioPlayer->stop();
//channel->deregisterObject(this); //channel->deregisterObject(this);
#ifndef Q_OS_MACOS
webview->ungrabGesture( Gestures::GDPinchGestureType ); webview->ungrabGesture( Gestures::GDPinchGestureType );
webview->ungrabGesture( Gestures::GDSwipeGestureType ); webview->ungrabGesture( Gestures::GDSwipeGestureType );
#endif
} }
void ArticleView::showDefinition( QString const & word, void ArticleView::showDefinition( QString const & word,
@ -724,7 +726,6 @@ bool ArticleView::eventFilter( QObject * obj, QEvent * ev )
return handled; return handled;
} }
#endif
if ( ev->type() == QEvent::MouseMove ) { if ( ev->type() == QEvent::MouseMove ) {
if ( Gestures::isFewTouchPointsPresented() ) { if ( Gestures::isFewTouchPointsPresented() ) {
@ -732,6 +733,7 @@ bool ArticleView::eventFilter( QObject * obj, QEvent * ev )
return true; return true;
} }
} }
#endif
if ( handleF3( obj, ev ) ) { if ( handleF3( obj, ev ) ) {
return true; return true;

View file

@ -905,9 +905,10 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
wasMaximized = isMaximized(); wasMaximized = isMaximized();
history.setSaveInterval( cfg.preferences.historyStoreInterval ); history.setSaveInterval( cfg.preferences.historyStoreInterval );
#ifndef Q_OS_MACOS
ui.centralWidget->grabGesture( Gestures::GDPinchGestureType ); ui.centralWidget->grabGesture( Gestures::GDPinchGestureType );
ui.centralWidget->grabGesture( Gestures::GDSwipeGestureType ); ui.centralWidget->grabGesture( Gestures::GDSwipeGestureType );
#endif
if ( layoutDirection() == Qt::RightToLeft ) { if ( layoutDirection() == Qt::RightToLeft ) {
// Adjust button icons for Right-To-Left layout // Adjust button icons for Right-To-Left layout
@ -1158,9 +1159,10 @@ MainWindow::~MainWindow()
closeHeadwordsDialog(); closeHeadwordsDialog();
ftsIndexing.stopIndexing(); ftsIndexing.stopIndexing();
#ifndef Q_OS_MACOS
ui.centralWidget->ungrabGesture( Gestures::GDPinchGestureType ); ui.centralWidget->ungrabGesture( Gestures::GDPinchGestureType );
ui.centralWidget->ungrabGesture( Gestures::GDSwipeGestureType ); ui.centralWidget->ungrabGesture( Gestures::GDSwipeGestureType );
#endif
// Gestures::unregisterRecognizers(); // Gestures::unregisterRecognizers();
// Close all tabs -- they should be destroyed before network managers // Close all tabs -- they should be destroyed before network managers

View file

@ -251,8 +251,10 @@ ScanPopup::ScanPopup( QWidget * parent,
ui.goBackButton->setEnabled( false ); ui.goBackButton->setEnabled( false );
ui.goForwardButton->setEnabled( false ); ui.goForwardButton->setEnabled( false );
#ifndef Q_OS_MACOS
grabGesture( Gestures::GDPinchGestureType ); grabGesture( Gestures::GDPinchGestureType );
grabGesture( Gestures::GDSwipeGestureType ); grabGesture( Gestures::GDSwipeGestureType );
#endif
#ifdef HAVE_X11 #ifdef HAVE_X11
scanFlag = new ScanFlag( this ); scanFlag = new ScanFlag( this );
@ -303,9 +305,10 @@ void ScanPopup::refresh()
ScanPopup::~ScanPopup() ScanPopup::~ScanPopup()
{ {
saveConfigData(); saveConfigData();
#ifndef Q_OS_MACOS
ungrabGesture( Gestures::GDPinchGestureType ); ungrabGesture( Gestures::GDPinchGestureType );
ungrabGesture( Gestures::GDSwipeGestureType ); ungrabGesture( Gestures::GDSwipeGestureType );
#endif
} }
void ScanPopup::saveConfigData() const void ScanPopup::saveConfigData() const