mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-23 20:14:05 +00:00
clean: delete most Qt5 & <=6.3 conditional compiled code (QT_VERSION)
Some checks are pending
SonarCloud / Build and analyze (push) Waiting to run
Some checks are pending
SonarCloud / Build and analyze (push) Waiting to run
This commit is contained in:
parent
ccf70cdfb6
commit
beef6dd138
|
@ -6,11 +6,7 @@
|
||||||
#include <QWaitCondition>
|
#include <QWaitCondition>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QThreadPool>
|
#include <QThreadPool>
|
||||||
#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
|
#include <QAudioSink>
|
||||||
#include <QAudioOutput>
|
|
||||||
#else
|
|
||||||
#include <QAudioSink>
|
|
||||||
#endif
|
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
#include <QBuffer>
|
#include <QBuffer>
|
||||||
|
|
||||||
|
@ -23,18 +19,7 @@ static QAudioFormat format( int sampleRate, int channelCount )
|
||||||
|
|
||||||
out.setSampleRate( sampleRate );
|
out.setSampleRate( sampleRate );
|
||||||
out.setChannelCount( channelCount );
|
out.setChannelCount( channelCount );
|
||||||
#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
|
|
||||||
out.setByteOrder( QAudioFormat::LittleEndian );
|
|
||||||
out.setCodec( QLatin1String( "audio/pcm" ) );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
|
|
||||||
out.setSampleSize( 16 );
|
|
||||||
out.setSampleType( QAudioFormat::SignedInt );
|
|
||||||
#else
|
|
||||||
out.setSampleFormat( QAudioFormat::Int16 );
|
out.setSampleFormat( QAudioFormat::Int16 );
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
@ -50,11 +35,8 @@ public:
|
||||||
|
|
||||||
QFuture< void > audioPlayFuture;
|
QFuture< void > audioPlayFuture;
|
||||||
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
|
|
||||||
using AudioOutput = QAudioOutput;
|
|
||||||
#else
|
|
||||||
using AudioOutput = QAudioSink;
|
using AudioOutput = QAudioSink;
|
||||||
#endif
|
|
||||||
AudioOutput * audioOutput = nullptr;
|
AudioOutput * audioOutput = nullptr;
|
||||||
QByteArray buffer;
|
QByteArray buffer;
|
||||||
qint64 offset = 0;
|
qint64 offset = 0;
|
||||||
|
@ -185,11 +167,7 @@ AudioOutput::AudioOutput( QObject * parent ):
|
||||||
QObject( parent ),
|
QObject( parent ),
|
||||||
d_ptr( new AudioOutputPrivate )
|
d_ptr( new AudioOutputPrivate )
|
||||||
{
|
{
|
||||||
#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
|
|
||||||
d_ptr->audioPlayFuture = QtConcurrent::run( &d_ptr->threadPool, d_ptr.data(), &AudioOutputPrivate::doPlayAudio );
|
|
||||||
#else
|
|
||||||
d_ptr->audioPlayFuture = QtConcurrent::run( &d_ptr->threadPool, &AudioOutputPrivate::doPlayAudio, d_ptr.data() );
|
d_ptr->audioPlayFuture = QtConcurrent::run( &d_ptr->threadPool, &AudioOutputPrivate::doPlayAudio, d_ptr.data() );
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioOutput::setAudioFormat( int sampleRate, int channels )
|
void AudioOutput::setAudioFormat( int sampleRate, int channels )
|
||||||
|
|
|
@ -2,27 +2,14 @@
|
||||||
|
|
||||||
#include "audiooutput.hh"
|
#include "audiooutput.hh"
|
||||||
#include "ffmpegaudio.hh"
|
#include "ffmpegaudio.hh"
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
extern "C" {
|
|
||||||
#include <libavcodec/avcodec.h>
|
|
||||||
#include <libavformat/avformat.h>
|
|
||||||
#include <libavutil/avutil.h>
|
|
||||||
#include "libswresample/swresample.h"
|
|
||||||
}
|
|
||||||
|
|
||||||
#include <QString>
|
|
||||||
#include <QDataStream>
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#if ( QT_VERSION >= QT_VERSION_CHECK( 6, 2, 0 ) )
|
|
||||||
#include <QMediaDevices>
|
|
||||||
|
|
||||||
#include <QAudioDevice>
|
|
||||||
#endif
|
|
||||||
#include "gddebug.hh"
|
#include "gddebug.hh"
|
||||||
#include "utils.hh"
|
#include "utils.hh"
|
||||||
|
#include <QAudioDevice>
|
||||||
|
#include <QDataStream>
|
||||||
|
#include <QMediaDevices>
|
||||||
|
#include <QString>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
using std::vector;
|
using std::vector;
|
||||||
|
|
||||||
|
@ -284,14 +271,11 @@ void DecoderContext::closeCodec()
|
||||||
|
|
||||||
bool DecoderContext::openOutputDevice( QString & errorString )
|
bool DecoderContext::openOutputDevice( QString & errorString )
|
||||||
{
|
{
|
||||||
// only check device when qt version is greater than 6.2
|
|
||||||
#if ( QT_VERSION >= QT_VERSION_CHECK( 6, 2, 0 ) )
|
|
||||||
QAudioDevice m_outputDevice = QMediaDevices::defaultAudioOutput();
|
QAudioDevice m_outputDevice = QMediaDevices::defaultAudioOutput();
|
||||||
if ( m_outputDevice.isNull() ) {
|
if ( m_outputDevice.isNull() ) {
|
||||||
errorString += QString( "Can not found default audio output device" );
|
errorString += QString( "Can not found default audio output device" );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
if ( audioOutput == nullptr ) {
|
if ( audioOutput == nullptr ) {
|
||||||
errorString += QStringLiteral( "Failed to create audioOutput." );
|
errorString += QStringLiteral( "Failed to create audioOutput." );
|
||||||
|
|
|
@ -1,27 +1,24 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifdef MAKE_FFMPEG_PLAYER
|
#ifdef MAKE_FFMPEG_PLAYER
|
||||||
#include "audiooutput.hh"
|
|
||||||
#include <QObject>
|
|
||||||
#include <QMutex>
|
|
||||||
#include <QByteArray>
|
|
||||||
#include <QThread>
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include <libavcodec/avcodec.h>
|
#include <libavcodec/avcodec.h>
|
||||||
#include <libavformat/avformat.h>
|
#include <libavformat/avformat.h>
|
||||||
#include <libavutil/avutil.h>
|
#include <libavutil/avutil.h>
|
||||||
#include "libswresample/swresample.h"
|
#include "libswresample/swresample.h"
|
||||||
}
|
}
|
||||||
|
#include "audiooutput.hh"
|
||||||
#include <QString>
|
#include <QObject>
|
||||||
#include <QDataStream>
|
#include <QMutex>
|
||||||
|
#include <QByteArray>
|
||||||
#include <vector>
|
#include <QThread>
|
||||||
#if ( QT_VERSION >= QT_VERSION_CHECK( 6, 2, 0 ) )
|
|
||||||
#include <QMediaDevices>
|
|
||||||
|
|
||||||
#include <QAudioDevice>
|
#include <QAudioDevice>
|
||||||
#endif
|
#include <QDataStream>
|
||||||
|
#include <QMediaDevices>
|
||||||
|
#include <QString>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
using std::vector;
|
using std::vector;
|
||||||
namespace Ffmpeg {
|
namespace Ffmpeg {
|
||||||
class DecoderThread;
|
class DecoderThread;
|
||||||
|
|
|
@ -4,29 +4,18 @@
|
||||||
#ifdef MAKE_QTMULTIMEDIA_PLAYER
|
#ifdef MAKE_QTMULTIMEDIA_PLAYER
|
||||||
|
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
#if ( QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) )
|
|
||||||
#include <QMediaContent>
|
|
||||||
#endif
|
|
||||||
#if ( QT_VERSION > QT_VERSION_CHECK( 6, 2, 0 ) )
|
|
||||||
#include <QAudioDevice>
|
#include <QAudioDevice>
|
||||||
#endif
|
|
||||||
#include "multimediaaudioplayer.hh"
|
#include "multimediaaudioplayer.hh"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
MultimediaAudioPlayer::MultimediaAudioPlayer()
|
MultimediaAudioPlayer::MultimediaAudioPlayer()
|
||||||
#if ( QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) )
|
|
||||||
:
|
|
||||||
player( 0, QMediaPlayer::StreamPlayback )
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
player.setAudioOutput( &audioOutput );
|
player.setAudioOutput( &audioOutput );
|
||||||
|
|
||||||
connect( &player, &QMediaPlayer::errorChanged, this, &MultimediaAudioPlayer::onMediaPlayerError );
|
connect( &player, &QMediaPlayer::errorChanged, this, &MultimediaAudioPlayer::onMediaPlayerError );
|
||||||
|
|
||||||
#if ( QT_VERSION > QT_VERSION_CHECK( 6, 2, 0 ) )
|
|
||||||
connect( &mediaDevices, &QMediaDevices::audioOutputsChanged, this, &MultimediaAudioPlayer::audioOutputChange );
|
connect( &mediaDevices, &QMediaDevices::audioOutputsChanged, this, &MultimediaAudioPlayer::audioOutputChange );
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultimediaAudioPlayer::audioOutputChange()
|
void MultimediaAudioPlayer::audioOutputChange()
|
||||||
|
@ -42,15 +31,11 @@ QString MultimediaAudioPlayer::play( const char * data, int size )
|
||||||
if ( !audioBuffer->open( QIODevice::ReadOnly ) ) {
|
if ( !audioBuffer->open( QIODevice::ReadOnly ) ) {
|
||||||
return tr( "Couldn't open audio buffer for reading." );
|
return tr( "Couldn't open audio buffer for reading." );
|
||||||
}
|
}
|
||||||
#if ( QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 ) )
|
|
||||||
player.setSourceDevice( audioBuffer );
|
player.setSourceDevice( audioBuffer );
|
||||||
#if ( QT_VERSION > QT_VERSION_CHECK( 6, 2, 0 ) )
|
|
||||||
audioOutput.setDevice( QMediaDevices::defaultAudioOutput() );
|
audioOutput.setDevice( QMediaDevices::defaultAudioOutput() );
|
||||||
player.setAudioOutput( &audioOutput );
|
player.setAudioOutput( &audioOutput );
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
player.setMedia( QMediaContent(), audioBuffer );
|
|
||||||
#endif
|
|
||||||
player.play();
|
player.play();
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
@ -58,9 +43,7 @@ QString MultimediaAudioPlayer::play( const char * data, int size )
|
||||||
void MultimediaAudioPlayer::stop()
|
void MultimediaAudioPlayer::stop()
|
||||||
{
|
{
|
||||||
player.stop();
|
player.stop();
|
||||||
#if ( QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) )
|
|
||||||
player.setMedia( QMediaContent() ); // Forget about audioBuffer.
|
|
||||||
#endif
|
|
||||||
if ( audioBuffer ) {
|
if ( audioBuffer ) {
|
||||||
audioBuffer->close();
|
audioBuffer->close();
|
||||||
audioBuffer->setData( QByteArray() ); // Free memory.
|
audioBuffer->setData( QByteArray() ); // Free memory.
|
||||||
|
|
|
@ -5,15 +5,11 @@
|
||||||
|
|
||||||
#ifdef MAKE_QTMULTIMEDIA_PLAYER
|
#ifdef MAKE_QTMULTIMEDIA_PLAYER
|
||||||
|
|
||||||
#include <QBuffer>
|
|
||||||
#include <QMediaPlayer>
|
|
||||||
#include "audioplayerinterface.hh"
|
#include "audioplayerinterface.hh"
|
||||||
#if ( QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 ) )
|
|
||||||
#include <QAudioOutput>
|
#include <QAudioOutput>
|
||||||
#endif
|
#include <QBuffer>
|
||||||
#if ( QT_VERSION >= QT_VERSION_CHECK( 6, 2, 0 ) )
|
|
||||||
#include <QMediaDevices>
|
#include <QMediaDevices>
|
||||||
#endif
|
#include <QMediaPlayer>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
|
|
||||||
class MultimediaAudioPlayer: public AudioPlayerInterface
|
class MultimediaAudioPlayer: public AudioPlayerInterface
|
||||||
|
@ -34,12 +30,8 @@ private slots:
|
||||||
private:
|
private:
|
||||||
QPointer< QBuffer > audioBuffer;
|
QPointer< QBuffer > audioBuffer;
|
||||||
QMediaPlayer player; ///< Depends on audioBuffer.
|
QMediaPlayer player; ///< Depends on audioBuffer.
|
||||||
#if ( QT_VERSION >= QT_VERSION_CHECK( 6, 2, 0 ) )
|
|
||||||
QAudioOutput audioOutput;
|
QAudioOutput audioOutput;
|
||||||
#endif
|
|
||||||
#if ( QT_VERSION >= QT_VERSION_CHECK( 6, 2, 0 ) )
|
|
||||||
QMediaDevices mediaDevices;
|
QMediaDevices mediaDevices;
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAKE_QTMULTIMEDIA_PLAYER
|
#endif // MAKE_QTMULTIMEDIA_PLAYER
|
||||||
|
|
|
@ -1,14 +1,10 @@
|
||||||
/* This file is (c) 2013 Abs62
|
/* This file is (c) 2013 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 */
|
||||||
|
|
||||||
#include <QString>
|
|
||||||
#include "gddebug.hh"
|
#include "gddebug.hh"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#if ( QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 ) )
|
#include <QString>
|
||||||
#include <QtCore5Compat/QTextCodec>
|
#include <QtCore5Compat/QTextCodec>
|
||||||
#else
|
|
||||||
#include <QTextCodec>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
QFile * logFilePtr;
|
QFile * logFilePtr;
|
||||||
|
|
||||||
|
|
|
@ -9,11 +9,6 @@
|
||||||
|
|
||||||
QString wildcardsToRegexp( const QString & wc_str )
|
QString wildcardsToRegexp( const QString & wc_str )
|
||||||
{
|
{
|
||||||
#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
|
// The "anchored" version will enclose the output with \A...\z.
|
||||||
//qt 5.X does not offer an unanchored version. the default output is enclosed between \A \z.
|
|
||||||
auto anchorPattern = QRegularExpression::wildcardToRegularExpression( wc_str );
|
|
||||||
return anchorPattern.mid( 2, anchorPattern.length() - 4 );
|
|
||||||
#else
|
|
||||||
return QRegularExpression::wildcardToRegularExpression( wc_str, QRegularExpression::UnanchoredWildcardConversion );
|
return QRegularExpression::wildcardToRegularExpression( wc_str, QRegularExpression::UnanchoredWildcardConversion );
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,11 +9,7 @@
|
||||||
#include <zlib.h>
|
#include <zlib.h>
|
||||||
#include "dictionary.hh"
|
#include "dictionary.hh"
|
||||||
#include "iconv.hh"
|
#include "iconv.hh"
|
||||||
#if ( QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 ) )
|
#include <QtCore5Compat/QTextCodec>
|
||||||
#include <QtCore5Compat/QTextCodec>
|
|
||||||
#else
|
|
||||||
#include <QTextCodec>
|
|
||||||
#endif
|
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
#include "utf8.hh"
|
#include "utf8.hh"
|
||||||
|
|
||||||
|
|
|
@ -541,11 +541,7 @@ bool EpwingBook::setSubBook( int book_nom )
|
||||||
QFile f( fileName );
|
QFile f( fileName );
|
||||||
if ( f.open( QFile::ReadOnly | QFile::Text ) ) {
|
if ( f.open( QFile::ReadOnly | QFile::Text ) ) {
|
||||||
QTextStream ts( &f );
|
QTextStream ts( &f );
|
||||||
#if ( QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) )
|
|
||||||
ts.setCodec( "UTF-8" );
|
|
||||||
#else
|
|
||||||
ts.setEncoding( QStringConverter::Utf8 );
|
ts.setEncoding( QStringConverter::Utf8 );
|
||||||
#endif
|
|
||||||
|
|
||||||
QString line = ts.readLine();
|
QString line = ts.readLine();
|
||||||
while ( !line.isEmpty() ) {
|
while ( !line.isEmpty() ) {
|
||||||
|
|
|
@ -16,12 +16,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#if ( QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 ) )
|
#include <QtCore5Compat/QTextCodec>
|
||||||
#include <QtCore5Compat/QTextCodec>
|
|
||||||
#else
|
|
||||||
#include <QTextCodec>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#include <stub_msvc.h>
|
#include <stub_msvc.h>
|
||||||
|
|
|
@ -32,11 +32,8 @@
|
||||||
#include <QBuffer>
|
#include <QBuffer>
|
||||||
|
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#if ( QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 ) )
|
#include <QtCore5Compat/QTextCodec>
|
||||||
#include <QtCore5Compat/QTextCodec>
|
|
||||||
#else
|
|
||||||
#include <QTextCodec>
|
|
||||||
#endif
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
|
@ -32,11 +32,8 @@
|
||||||
#include <QDomDocument>
|
#include <QDomDocument>
|
||||||
#include <QTextDocumentFragment>
|
#include <QTextDocumentFragment>
|
||||||
#include <QDataStream>
|
#include <QDataStream>
|
||||||
#if ( QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 ) )
|
#include <QtCore5Compat/QTextCodec>
|
||||||
#include <QtCore5Compat/QTextCodec>
|
|
||||||
#else
|
|
||||||
#include <QTextCodec>
|
|
||||||
#endif
|
|
||||||
#include "decompress.hh"
|
#include "decompress.hh"
|
||||||
#include "gddebug.hh"
|
#include "gddebug.hh"
|
||||||
#include "ripemd.hh"
|
#include "ripemd.hh"
|
||||||
|
|
|
@ -1,36 +1,31 @@
|
||||||
/* This file is (c) 2008-2012 Konstantin Isakov <ikm@goldendict.org>
|
/* This file is (c) 2008-2012 Konstantin Isakov <ikm@goldendict.org>
|
||||||
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */
|
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */
|
||||||
|
|
||||||
#include "sdict.hh"
|
|
||||||
#include "btreeidx.hh"
|
#include "btreeidx.hh"
|
||||||
#include "folding.hh"
|
|
||||||
#include "utf8.hh"
|
|
||||||
#include "chunkedstorage.hh"
|
#include "chunkedstorage.hh"
|
||||||
#include "langcoder.hh"
|
|
||||||
#include "gddebug.hh"
|
|
||||||
|
|
||||||
#include "decompress.hh"
|
#include "decompress.hh"
|
||||||
#include "htmlescape.hh"
|
#include "folding.hh"
|
||||||
#include "ftshelpers.hh"
|
#include "ftshelpers.hh"
|
||||||
|
#include "gddebug.hh"
|
||||||
|
#include "htmlescape.hh"
|
||||||
|
#include "langcoder.hh"
|
||||||
|
#include "sdict.hh"
|
||||||
|
#include "utf8.hh"
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <QAtomicInt>
|
||||||
|
#include <QRegularExpression>
|
||||||
|
#include <QSemaphore>
|
||||||
|
#include <QString>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include "utils.hh"
|
||||||
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#include <stub_msvc.h>
|
#include <stub_msvc.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <QString>
|
|
||||||
#include <QSemaphore>
|
|
||||||
#include <QAtomicInt>
|
|
||||||
#if ( QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 ) )
|
|
||||||
#include <QtCore5Compat>
|
|
||||||
#endif
|
|
||||||
#include <QRegularExpression>
|
|
||||||
|
|
||||||
#include "utils.hh"
|
|
||||||
|
|
||||||
namespace Sdict {
|
namespace Sdict {
|
||||||
|
|
||||||
using std::map;
|
using std::map;
|
||||||
|
|
|
@ -8,11 +8,8 @@
|
||||||
#include "utf8.hh"
|
#include "utf8.hh"
|
||||||
#include "iconv.hh"
|
#include "iconv.hh"
|
||||||
#include "wstring_qt.hh"
|
#include "wstring_qt.hh"
|
||||||
#if ( QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 ) )
|
#include <QtCore5Compat/QTextCodec>
|
||||||
#include <QtCore5Compat/QTextCodec>
|
|
||||||
#else
|
|
||||||
#include <QTextCodec>
|
|
||||||
#endif
|
|
||||||
#include <QMutexLocker>
|
#include <QMutexLocker>
|
||||||
|
|
||||||
using namespace BtreeIndexing;
|
using namespace BtreeIndexing;
|
||||||
|
|
|
@ -105,15 +105,8 @@ void IframeSchemeHandler::requestStarted( QWebEngineUrlRequestJob * requestJob )
|
||||||
|
|
||||||
buffer->setData( articleString.toUtf8() );
|
buffer->setData( articleString.toUtf8() );
|
||||||
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 )
|
|
||||||
requestJob->reply( "text/html; charset=utf-8", buffer );
|
requestJob->reply( "text/html; charset=utf-8", buffer );
|
||||||
#else
|
|
||||||
#if defined( Q_OS_WIN32 ) || defined( Q_OS_MAC )
|
|
||||||
requestJob->reply( contentType, buffer );
|
|
||||||
#else
|
|
||||||
requestJob->reply( "text/html", buffer );
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
connect( reply, &QNetworkReply::finished, requestJob, finishAction );
|
connect( reply, &QNetworkReply::finished, requestJob, finishAction );
|
||||||
|
|
||||||
|
|
12
src/main.cc
12
src/main.cc
|
@ -307,15 +307,7 @@ void processCommandLine( QCoreApplication * app, GDOptions * result )
|
||||||
// Handle cases where we get encoded URL
|
// Handle cases where we get encoded URL
|
||||||
if ( result->word.startsWith( QStringLiteral( "xn--" ) ) ) {
|
if ( result->word.startsWith( QStringLiteral( "xn--" ) ) ) {
|
||||||
// For `kde-open` or `gio` or others, URL are encoded into ACE or Punycode
|
// For `kde-open` or `gio` or others, URL are encoded into ACE or Punycode
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK( 6, 3, 0 )
|
|
||||||
result->word = QUrl::fromAce( result->word.toLatin1(), QUrl::IgnoreIDNWhitelist );
|
result->word = QUrl::fromAce( result->word.toLatin1(), QUrl::IgnoreIDNWhitelist );
|
||||||
#else
|
|
||||||
// Old Qt's fromAce only applies to whitelisted domains, so we add .com to bypass this restriction :)
|
|
||||||
// https://bugreports.qt.io/browse/QTBUG-29080
|
|
||||||
result->word.append( QStringLiteral( ".com" ) );
|
|
||||||
result->word = QUrl::fromAce( result->word.toLatin1() );
|
|
||||||
result->word.chop( 4 );
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else if ( result->word.startsWith( QStringLiteral( "%" ) ) ) {
|
else if ( result->word.startsWith( QStringLiteral( "%" ) ) ) {
|
||||||
// For Firefox or other browsers where URL are percent encoded
|
// For Firefox or other browsers where URL are percent encoded
|
||||||
|
@ -359,10 +351,6 @@ int main( int argc, char ** argv )
|
||||||
|
|
||||||
|
|
||||||
//high dpi screen support
|
//high dpi screen support
|
||||||
#if ( QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) )
|
|
||||||
QApplication::setAttribute( Qt::AA_EnableHighDpiScaling );
|
|
||||||
QApplication::setAttribute( Qt::AA_UseHighDpiPixmaps );
|
|
||||||
#endif
|
|
||||||
qputenv( "QT_ENABLE_HIGHDPI_SCALING", "1" );
|
qputenv( "QT_ENABLE_HIGHDPI_SCALING", "1" );
|
||||||
QApplication::setHighDpiScaleFactorRoundingPolicy( Qt::HighDpiScaleFactorRoundingPolicy::PassThrough );
|
QApplication::setHighDpiScaleFactorRoundingPolicy( Qt::HighDpiScaleFactorRoundingPolicy::PassThrough );
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
#include "article_inspect.hh"
|
#include "article_inspect.hh"
|
||||||
#include <QCloseEvent>
|
#include <QCloseEvent>
|
||||||
#if ( QT_VERSION > QT_VERSION_CHECK( 6, 0, 0 ) )
|
#include <QWebEngineContextMenuRequest>
|
||||||
#include <QWebEngineContextMenuRequest>
|
|
||||||
#endif
|
|
||||||
ArticleInspector::ArticleInspector( QWidget * parent ):
|
ArticleInspector::ArticleInspector( QWidget * parent ):
|
||||||
QWidget( parent, Qt::WindowType::Window )
|
QWidget( parent, Qt::WindowType::Window )
|
||||||
{
|
{
|
||||||
|
@ -39,9 +37,7 @@ void ArticleInspector::triggerAction( QWebEnginePage * page )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ( QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) || QT_VERSION > QT_VERSION_CHECK( 6, 3, 0 ) )
|
|
||||||
page->triggerAction( QWebEnginePage::InspectElement );
|
page->triggerAction( QWebEnginePage::InspectElement );
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArticleInspector::closeEvent( QCloseEvent * )
|
void ArticleInspector::closeEvent( QCloseEvent * )
|
||||||
|
|
|
@ -31,15 +31,9 @@
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QRandomGenerator>
|
#include <QRandomGenerator>
|
||||||
|
#include <QWebEngineContextMenuRequest>
|
||||||
#if ( QT_VERSION >= QT_VERSION_CHECK( 5, 0, 0 ) && QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) )
|
#include <QWebEngineFindTextResult>
|
||||||
#include <QWebEngineContextMenuData>
|
#include <utility>
|
||||||
#endif
|
|
||||||
#if ( QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 ) )
|
|
||||||
#include <QWebEngineContextMenuRequest>
|
|
||||||
#include <QWebEngineFindTextResult>
|
|
||||||
#include <utility>
|
|
||||||
#endif
|
|
||||||
#ifdef Q_OS_WIN32
|
#ifdef Q_OS_WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
@ -214,15 +208,7 @@ ArticleView::ArticleView( QWidget * parent,
|
||||||
|
|
||||||
QWebEngineSettings * settings = webview->settings();
|
QWebEngineSettings * settings = webview->settings();
|
||||||
settings->setUnknownUrlSchemePolicy( QWebEngineSettings::UnknownUrlSchemePolicy::DisallowUnknownUrlSchemes );
|
settings->setUnknownUrlSchemePolicy( QWebEngineSettings::UnknownUrlSchemePolicy::DisallowUnknownUrlSchemes );
|
||||||
#if ( QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) )
|
|
||||||
settings->defaultSettings()->setAttribute( QWebEngineSettings::LocalContentCanAccessRemoteUrls, true );
|
|
||||||
settings->defaultSettings()->setAttribute( QWebEngineSettings::LocalContentCanAccessFileUrls, true );
|
|
||||||
settings->defaultSettings()->setAttribute( QWebEngineSettings::ErrorPageEnabled, false );
|
|
||||||
settings->defaultSettings()->setAttribute( QWebEngineSettings::LinksIncludedInFocusChain, false );
|
|
||||||
settings->defaultSettings()->setAttribute( QWebEngineSettings::PlaybackRequiresUserGesture, false );
|
|
||||||
settings->defaultSettings()->setAttribute( QWebEngineSettings::JavascriptCanAccessClipboard, true );
|
|
||||||
settings->defaultSettings()->setAttribute( QWebEngineSettings::PrintElementBackgrounds, false );
|
|
||||||
#else
|
|
||||||
settings->setAttribute( QWebEngineSettings::LocalContentCanAccessRemoteUrls, true );
|
settings->setAttribute( QWebEngineSettings::LocalContentCanAccessRemoteUrls, true );
|
||||||
settings->setAttribute( QWebEngineSettings::LocalContentCanAccessFileUrls, true );
|
settings->setAttribute( QWebEngineSettings::LocalContentCanAccessFileUrls, true );
|
||||||
settings->setAttribute( QWebEngineSettings::ErrorPageEnabled, false );
|
settings->setAttribute( QWebEngineSettings::ErrorPageEnabled, false );
|
||||||
|
@ -230,7 +216,6 @@ ArticleView::ArticleView( QWidget * parent,
|
||||||
settings->setAttribute( QWebEngineSettings::PlaybackRequiresUserGesture, false );
|
settings->setAttribute( QWebEngineSettings::PlaybackRequiresUserGesture, false );
|
||||||
settings->setAttribute( QWebEngineSettings::JavascriptCanAccessClipboard, true );
|
settings->setAttribute( QWebEngineSettings::JavascriptCanAccessClipboard, true );
|
||||||
settings->setAttribute( QWebEngineSettings::PrintElementBackgrounds, false );
|
settings->setAttribute( QWebEngineSettings::PrintElementBackgrounds, false );
|
||||||
#endif
|
|
||||||
|
|
||||||
auto html = articleNetMgr.getHtml( ResourceType::UNTITLE );
|
auto html = articleNetMgr.getHtml( ResourceType::UNTITLE );
|
||||||
|
|
||||||
|
@ -1329,12 +1314,10 @@ void ArticleView::print( QPrinter * printer ) const
|
||||||
result = success;
|
result = success;
|
||||||
loop.quit();
|
loop.quit();
|
||||||
};
|
};
|
||||||
#if ( QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) )
|
|
||||||
webview->page()->print( printer, std::move( printPreview ) );
|
|
||||||
#else
|
|
||||||
connect( webview, &QWebEngineView::printFinished, &loop, std::move( printPreview ) );
|
connect( webview, &QWebEngineView::printFinished, &loop, std::move( printPreview ) );
|
||||||
webview->print( printer );
|
webview->print( printer );
|
||||||
#endif
|
|
||||||
loop.exec();
|
loop.exec();
|
||||||
if ( !result ) {
|
if ( !result ) {
|
||||||
qDebug() << "print failed";
|
qDebug() << "print failed";
|
||||||
|
@ -1363,11 +1346,7 @@ void ArticleView::contextMenuRequested( QPoint const & pos )
|
||||||
QAction * saveSoundAction = nullptr;
|
QAction * saveSoundAction = nullptr;
|
||||||
QAction * saveBookmark = nullptr;
|
QAction * saveBookmark = nullptr;
|
||||||
|
|
||||||
#if ( QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) )
|
|
||||||
const QWebEngineContextMenuData * menuData = &( r->contextMenuData() );
|
|
||||||
#else
|
|
||||||
QWebEngineContextMenuRequest * menuData = webview->lastContextMenuRequest();
|
QWebEngineContextMenuRequest * menuData = webview->lastContextMenuRequest();
|
||||||
#endif
|
|
||||||
QUrl targetUrl( menuData->linkUrl() );
|
QUrl targetUrl( menuData->linkUrl() );
|
||||||
Contexts contexts;
|
Contexts contexts;
|
||||||
|
|
||||||
|
@ -1392,12 +1371,8 @@ void ArticleView::contextMenuRequested( QPoint const & pos )
|
||||||
}
|
}
|
||||||
|
|
||||||
QUrl imageUrl;
|
QUrl imageUrl;
|
||||||
#if ( QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) )
|
|
||||||
if ( !popupView && menuData->mediaType() == QWebEngineContextMenuData::MediaTypeImage )
|
if ( !popupView && menuData->mediaType() == QWebEngineContextMenuRequest::MediaType::MediaTypeImage ) {
|
||||||
#else
|
|
||||||
if ( !popupView && menuData->mediaType() == QWebEngineContextMenuRequest::MediaType::MediaTypeImage )
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
imageUrl = menuData->mediaUrl();
|
imageUrl = menuData->mediaUrl();
|
||||||
if ( !imageUrl.isEmpty() ) {
|
if ( !imageUrl.isEmpty() ) {
|
||||||
menu.addAction( webview->pageAction( QWebEnginePage::CopyImageToClipboard ) );
|
menu.addAction( webview->pageAction( QWebEnginePage::CopyImageToClipboard ) );
|
||||||
|
@ -1955,19 +1930,12 @@ void ArticleView::findText( QString & text,
|
||||||
const QWebEnginePage::FindFlags & f,
|
const QWebEnginePage::FindFlags & f,
|
||||||
const std::function< void( bool match ) > & callback )
|
const std::function< void( bool match ) > & callback )
|
||||||
{
|
{
|
||||||
#if ( QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 ) )
|
|
||||||
webview->findText( text, f, [ callback ]( const QWebEngineFindTextResult & result ) {
|
webview->findText( text, f, [ callback ]( const QWebEngineFindTextResult & result ) {
|
||||||
auto r = result.numberOfMatches() > 0;
|
auto r = result.numberOfMatches() > 0;
|
||||||
if ( callback ) {
|
if ( callback ) {
|
||||||
callback( r );
|
callback( r );
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
#else
|
|
||||||
webview->findText( text, f, [ callback ]( bool result ) {
|
|
||||||
if ( callback )
|
|
||||||
callback( result );
|
|
||||||
} );
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ArticleView::closeSearch()
|
bool ArticleView::closeSearch()
|
||||||
|
@ -2099,7 +2067,6 @@ void ArticleView::performFtsFindOperation( bool backwards )
|
||||||
QWebEnginePage::FindFlags flags( 0 );
|
QWebEnginePage::FindFlags flags( 0 );
|
||||||
|
|
||||||
if ( backwards ) {
|
if ( backwards ) {
|
||||||
#if ( QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 ) )
|
|
||||||
webview->findText( firstAvailableText,
|
webview->findText( firstAvailableText,
|
||||||
flags | QWebEnginePage::FindBackward,
|
flags | QWebEnginePage::FindBackward,
|
||||||
[ this ]( const QWebEngineFindTextResult & result ) {
|
[ this ]( const QWebEngineFindTextResult & result ) {
|
||||||
|
@ -2114,16 +2081,8 @@ void ArticleView::performFtsFindOperation( bool backwards )
|
||||||
ftsSearchPanel->statusLabel->setText(
|
ftsSearchPanel->statusLabel->setText(
|
||||||
searchStatusMessage( result.activeMatch(), result.numberOfMatches() ) );
|
searchStatusMessage( result.activeMatch(), result.numberOfMatches() ) );
|
||||||
} );
|
} );
|
||||||
#else
|
|
||||||
webview->findText( firstAvailableText, flags | QWebEnginePage::FindBackward, [ this ]( bool res ) {
|
|
||||||
ftsSearchPanel->previous->setEnabled( res );
|
|
||||||
if ( !ftsSearchPanel->next->isEnabled() )
|
|
||||||
ftsSearchPanel->next->setEnabled( res );
|
|
||||||
} );
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
#if ( QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 ) )
|
|
||||||
webview->findText( firstAvailableText, flags, [ this ]( const QWebEngineFindTextResult & result ) {
|
webview->findText( firstAvailableText, flags, [ this ]( const QWebEngineFindTextResult & result ) {
|
||||||
if ( result.numberOfMatches() == 0 ) {
|
if ( result.numberOfMatches() == 0 ) {
|
||||||
return;
|
return;
|
||||||
|
@ -2135,15 +2094,6 @@ void ArticleView::performFtsFindOperation( bool backwards )
|
||||||
|
|
||||||
ftsSearchPanel->statusLabel->setText( searchStatusMessage( result.activeMatch(), result.numberOfMatches() ) );
|
ftsSearchPanel->statusLabel->setText( searchStatusMessage( result.activeMatch(), result.numberOfMatches() ) );
|
||||||
} );
|
} );
|
||||||
#else
|
|
||||||
|
|
||||||
webview->findText( firstAvailableText, flags, [ this ]( bool res ) {
|
|
||||||
ftsSearchPanel->next->setEnabled( res );
|
|
||||||
if ( !ftsSearchPanel->previous->isEnabled() )
|
|
||||||
ftsSearchPanel->previous->setEnabled( res );
|
|
||||||
} );
|
|
||||||
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -420,10 +420,6 @@ void DictHeadwords::saveHeadersToFile()
|
||||||
// Write UTF-8 BOM
|
// Write UTF-8 BOM
|
||||||
QTextStream out( &file );
|
QTextStream out( &file );
|
||||||
out.setGenerateByteOrderMark( true );
|
out.setGenerateByteOrderMark( true );
|
||||||
//qt 6 will use utf-8 default.
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
|
|
||||||
out.setCodec( "UTF-8" );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
exportAllWords( progress, out );
|
exportAllWords( progress, out );
|
||||||
|
|
||||||
|
|
|
@ -760,11 +760,7 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
|
||||||
|
|
||||||
|
|
||||||
#if defined( Q_OS_LINUX )
|
#if defined( Q_OS_LINUX )
|
||||||
#if ( QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 ) )
|
|
||||||
defaultInterfaceStyle = QApplication::style()->name();
|
defaultInterfaceStyle = QApplication::style()->name();
|
||||||
#else
|
|
||||||
defaultInterfaceStyle = QApplication::style()->objectName();
|
|
||||||
#endif
|
|
||||||
#elif defined( Q_OS_MAC )
|
#elif defined( Q_OS_MAC )
|
||||||
defaultInterfaceStyle = "Fusion";
|
defaultInterfaceStyle = "Fusion";
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -8,11 +8,6 @@
|
||||||
#include <QBitmap>
|
#include <QBitmap>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#if ( QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) )
|
|
||||||
#include <QDesktopWidget>
|
|
||||||
#include <QScreen>
|
|
||||||
#include <QStringList>
|
|
||||||
#endif
|
|
||||||
#include "gddebug.hh"
|
#include "gddebug.hh"
|
||||||
#include "gestures.hh"
|
#include "gestures.hh"
|
||||||
|
|
||||||
|
@ -846,11 +841,7 @@ void ScanPopup::leaveEvent( QEvent * event )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ( QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 ) )
|
|
||||||
void ScanPopup::enterEvent( QEnterEvent * event )
|
void ScanPopup::enterEvent( QEnterEvent * event )
|
||||||
#else
|
|
||||||
void ScanPopup::enterEvent( QEvent * event )
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
QMainWindow::enterEvent( event );
|
QMainWindow::enterEvent( event );
|
||||||
|
|
||||||
|
|
|
@ -174,11 +174,7 @@ private:
|
||||||
virtual void mouseMoveEvent( QMouseEvent * );
|
virtual void mouseMoveEvent( QMouseEvent * );
|
||||||
virtual void mouseReleaseEvent( QMouseEvent * );
|
virtual void mouseReleaseEvent( QMouseEvent * );
|
||||||
virtual void leaveEvent( QEvent * event );
|
virtual void leaveEvent( QEvent * event );
|
||||||
#if ( QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 ) )
|
|
||||||
virtual void enterEvent( QEnterEvent * event );
|
virtual void enterEvent( QEnterEvent * event );
|
||||||
#else
|
|
||||||
virtual void enterEvent( QEvent * event );
|
|
||||||
#endif
|
|
||||||
virtual void showEvent( QShowEvent * );
|
virtual void showEvent( QShowEvent * );
|
||||||
virtual void closeEvent( QCloseEvent * );
|
virtual void closeEvent( QCloseEvent * );
|
||||||
virtual void moveEvent( QMoveEvent * );
|
virtual void moveEvent( QMoveEvent * );
|
||||||
|
|
Loading…
Reference in a new issue