From 89b821d4731489fdced4420fd4ab5c6396a6e8a7 Mon Sep 17 00:00:00 2001 From: yifang Date: Sun, 26 Dec 2021 19:01:05 +0800 Subject: [PATCH 1/3] remove deprecated function --- articleview.cc | 12 ++++++------ articlewebview.cc | 4 ++-- goldendict.pro | 2 ++ 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/articleview.cc b/articleview.cc index a1f6db981..a6a8fa344 100644 --- a/articleview.cc +++ b/articleview.cc @@ -338,8 +338,8 @@ ArticleView::ArticleView( QWidget * parent, ArticleNetworkAccessManager & nm, ui.ftsSearchFrame->installEventFilter( this ); QWebEngineSettings * settings = ui.definition->page()->settings(); - settings->globalSettings()->setAttribute( QWebEngineSettings::WebAttribute::LocalContentCanAccessRemoteUrls, true ); - settings->globalSettings()->setAttribute( QWebEngineSettings::WebAttribute::LocalContentCanAccessFileUrls, true ); + settings->defaultSettings()->setAttribute( QWebEngineSettings::WebAttribute::LocalContentCanAccessRemoteUrls, true ); + settings->defaultSettings()->setAttribute( QWebEngineSettings::WebAttribute::LocalContentCanAccessFileUrls, true ); // Load the default blank page instantly, so there would be no flicker. QString contentType; @@ -646,7 +646,7 @@ unsigned ArticleView::getGroup( QUrl const & url ) QStringList ArticleView::getArticlesList() { return runJavaScriptSync( ui.definition->page(), "gdArticleContents" ) - .trimmed().split( ' ', QString::SkipEmptyParts ); + .trimmed().split( ' ', Qt::SkipEmptyParts ); } QString ArticleView::getActiveArticleId() @@ -1136,7 +1136,7 @@ void ArticleView::openLink( QUrl const & url, QUrl const & ref, if( Utils::Url::hasQueryItem( ref, "dictionaries" ) ) { QStringList dictsList = Utils::Url::queryItemValue( ref, "dictionaries" ) - .split( ",", QString::SkipEmptyParts ); + .split( ",", Qt::SkipEmptyParts ); showDefinition( url.path(), dictsList, QRegExp(), getGroup( ref ), false ); } @@ -1158,7 +1158,7 @@ void ArticleView::openLink( QUrl const & url, QUrl const & ref, { // Specific dictionary group from full-text search QStringList dictsList = Utils::Url::queryItemValue( ref, "dictionaries" ) - .split( ",", QString::SkipEmptyParts ); + .split( ",", Qt::SkipEmptyParts ); showDefinition( url.path().mid( 1 ), dictsList, QRegExp(), getGroup( ref ), false ); return; @@ -2240,7 +2240,7 @@ void ArticleView::doubleClicked( QPoint pos ) if( Utils::Url::hasQueryItem( ref, "dictionaries" ) ) { QStringList dictsList = Utils::Url::queryItemValue(ref, "dictionaries" ) - .split( ",", QString::SkipEmptyParts ); + .split( ",", Qt::SkipEmptyParts ); showDefinition( selectedText, dictsList, QRegExp(), getGroup( ref ), false ); } else diff --git a/articlewebview.cc b/articlewebview.cc index 497455062..68252527f 100644 --- a/articlewebview.cc +++ b/articlewebview.cc @@ -86,7 +86,7 @@ bool ArticleWebView::eventFilter(QObject *obj, QEvent *ev) void ArticleWebView::mousePressEvent(QMouseEvent *event) { - if (event->buttons() & Qt::MidButton) + if (event->buttons() & Qt::MiddleButton) midButtonPressed = true; //QWebEngineView::mousePressEvent(event); @@ -122,7 +122,7 @@ void ArticleWebView::singleClickAction( QMouseEvent * event ) void ArticleWebView::mouseReleaseEvent( QMouseEvent * event ) { - bool noMidButton = !( event->buttons() & Qt::MidButton ); + bool noMidButton = !( event->buttons() & Qt::MiddleButton ); //QWebEngineView::mouseReleaseEvent( event ); diff --git a/goldendict.pro b/goldendict.pro index 587fe1bed..b999f9e5f 100644 --- a/goldendict.pro +++ b/goldendict.pro @@ -29,6 +29,8 @@ QT += widgets \ printsupport \ help +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x050F00 + # QMediaPlayer is not available in Qt4. !CONFIG( no_qtmultimedia_player ) { QT += multimedia From 46b4151cc42f0867be5dedbac99a3568485cd807 Mon Sep 17 00:00:00 2001 From: yifang Date: Sat, 8 Jan 2022 21:16:22 +0800 Subject: [PATCH 2/3] improve: replace all the deprecated method before 5.15 --- aard.cc | 3 +-- article_netmgr.cc | 16 ++++++++-------- articleview.cc | 6 ++++-- btreeidx.cc | 9 +++++---- dictionary.cc | 6 +++--- dictionarybar.cc | 2 +- epwing.cc | 4 +--- epwing_book.cc | 5 ++--- extlineedit.cc | 10 ++++------ favoritespanewidget.cc | 4 +++- fulltextsearch.cc | 2 +- gddebug.cc | 4 ++-- goldendict.pro | 2 +- groups_widgets.cc | 4 ++-- helpwindow.cc | 9 ++++++--- hotkeyedit.cc | 2 +- mainstatusbar.cc | 4 ++-- maintabwidget.cc | 2 +- mainwindow.cc | 9 ++++----- mainwindow.hh | 2 +- mdictparser.cc | 2 +- preferences.cc | 4 ++-- scanflag.cc | 3 ++- scanpopup.cc | 2 +- slob.cc | 4 ++-- sources.cc | 2 +- translatebox.cc | 2 +- website.cc | 2 +- zipfile.cc | 4 ++-- 29 files changed, 66 insertions(+), 64 deletions(-) diff --git a/aard.cc b/aard.cc index f4ac6be1b..bef2e366c 100644 --- a/aard.cc +++ b/aard.cc @@ -941,8 +941,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( quint16 volumes = qFromBigEndian( dictHeader.totalVolumes ); if( volumes > 1 ) { - QString ss; - ss.sprintf( " (%i/%i)", qFromBigEndian( dictHeader.volume ), volumes ); + QString ss=QString( " (%1/%2)").arg( qFromBigEndian( dictHeader.volume ), volumes ); dictName += ss.toLocal8Bit().data(); } diff --git a/article_netmgr.cc b/article_netmgr.cc index cc8b8f40f..6f70c1d81 100644 --- a/article_netmgr.cc +++ b/article_netmgr.cc @@ -32,7 +32,7 @@ using std::string; connect( baseReply, SIGNAL( metaDataChanged() ), this, SLOT( applyMetaData() ) ); - connect( baseReply, SIGNAL( error( QNetworkReply::NetworkError) ), + connect( baseReply, SIGNAL( errorOccurred( QNetworkReply::NetworkError) ), this, SLOT( applyError( QNetworkReply::NetworkError ) ) ); connect( baseReply, SIGNAL( readyRead() ), this, SLOT( readDataFromBase() ) ); @@ -113,8 +113,8 @@ using std::string; baseReply->attribute( QNetworkRequest::HttpPipeliningWasUsedAttribute ) ); setAttribute( QNetworkRequest::BackgroundRequestAttribute, baseReply->attribute( QNetworkRequest::BackgroundRequestAttribute ) ); - setAttribute( QNetworkRequest::SpdyWasUsedAttribute, - baseReply->attribute( QNetworkRequest::SpdyWasUsedAttribute ) ); + setAttribute( QNetworkRequest::Http2WasUsedAttribute, + baseReply->attribute( QNetworkRequest::Http2WasUsedAttribute ) ); emit metaDataChanged(); } @@ -133,7 +133,7 @@ using std::string; void AllowFrameReply::applyError( QNetworkReply::NetworkError code ) { setError( code, baseReply->errorString() ); - emit error( code ); + emit errorOccurred( code ); } void AllowFrameReply::readDataFromBase() @@ -275,7 +275,7 @@ QNetworkReply * ArticleNetworkAccessManager::createRequest( Operation op, if ( hideGoldenDictHeader && req.url().scheme().startsWith("http", Qt::CaseInsensitive)) { QNetworkRequest newReq( req ); - newReq.setRawHeader("User-Agent", req.rawHeader("User-Agent").replace(qApp->applicationName(), "")); + newReq.setRawHeader("User-Agent", req.rawHeader("User-Agent").replace(qApp->applicationName().toUtf8(), "")); reply = QNetworkAccessManager::createRequest( op, newReq, outgoingData ); } @@ -332,8 +332,8 @@ sptr< Dictionary::DataRequest > ArticleNetworkAccessManager::getResource( // See if we have some dictionaries muted - QSet< QString > mutedDicts = - QSet< QString >::fromList( Utils::Url::queryItemValue( url, "muted" ).split( ',' ) ); + QStringList mutedDictLists=Utils::Url::queryItemValue( url, "muted" ).split( ',' ); + QSet< QString > mutedDicts ( mutedDictLists.begin(),mutedDictLists.end()); // Unpack contexts @@ -521,7 +521,7 @@ void ArticleResourceReply::readyReadSlot() void ArticleResourceReply::finishedSlot() { if (req->dataSize() < 0) { - emit error(ContentNotFoundError); + emit errorOccurred(ContentNotFoundError); setError(ContentNotFoundError, "content not found"); } diff --git a/articleview.cc b/articleview.cc index 2541643ba..d20a6ba65 100644 --- a/articleview.cc +++ b/articleview.cc @@ -864,15 +864,17 @@ bool ArticleView::eventFilter( QObject * obj, QEvent * ev ) int delta = result == Gestures::SWIPE_UP ? -120 : 120; QWidget *widget = static_cast< QWidget * >( obj ); + QPoint angleDelta(0, delta); + QPoint pixelDetal; QWidget *child = widget->childAt( widget->mapFromGlobal( pt ) ); if( child ) { - QWheelEvent whev( child->mapFromGlobal( pt ), pt, delta, Qt::NoButton, Qt::NoModifier ); + QWheelEvent whev( child->mapFromGlobal( pt ), pt, pixelDetal,angleDelta, Qt::NoButton, Qt::NoModifier,Qt::NoScrollPhase,false); qApp->sendEvent( child, &whev ); } else { - QWheelEvent whev( widget->mapFromGlobal( pt ), pt, delta, Qt::NoButton, Qt::NoModifier ); + QWheelEvent whev( widget->mapFromGlobal( pt ), pt,pixelDetal, angleDelta,Qt::NoButton, Qt::NoModifier,Qt::NoScrollPhase,false ); qApp->sendEvent( widget, &whev ); } } diff --git a/btreeidx.cc b/btreeidx.cc index d4ef84f3b..4c6b12d94 100644 --- a/btreeidx.cc +++ b/btreeidx.cc @@ -1437,16 +1437,17 @@ void BtreeIndex::getHeadwordsFromOffsets( QList & offsets, for( unsigned i = 0; i < result.size(); i++ ) { - QList< uint32_t >::Iterator it = qBinaryFind( begOffsets, endOffsets, - result.at( i ).articleOffset ); + uint32_t articleOffset = result.at(i).articleOffset; + QList::Iterator it = std::lower_bound( begOffsets, endOffsets, + articleOffset ); - if( it != offsets.end() ) + if( it!=offsets.end()) { if( isCancelled && Utils::AtomicInt::loadAcquire( *isCancelled ) ) return; headwords.append( QString::fromUtf8( ( result[ i ].prefix + result[ i ].word ).c_str() ) ); - offsets.erase( it ); + offsets.erase( it); begOffsets = offsets.begin(); endOffsets = offsets.end(); } diff --git a/dictionary.cc b/dictionary.cc index 53f616986..1a96a9e23 100644 --- a/dictionary.cc +++ b/dictionary.cc @@ -487,13 +487,13 @@ bool needToRebuildIndex( vector< string > const & dictionaryFiles, ZipFile::SplitZipFile zf( name ); if( !zf.exists() ) return true; - ts = zf.lastModified().toTime_t(); + ts = zf.lastModified().toSecsSinceEpoch(); } else { if ( !fileInfo.exists() ) return true; - ts = fileInfo.lastModified().toTime_t(); + ts = fileInfo.lastModified().toSecsSinceEpoch(); } if ( ts > lastModified ) @@ -505,7 +505,7 @@ bool needToRebuildIndex( vector< string > const & dictionaryFiles, if ( !fileInfo.exists() ) return true; - return fileInfo.lastModified().toTime_t() < lastModified; + return fileInfo.lastModified().toSecsSinceEpoch() < lastModified; } QString generateRandomDictionaryId() diff --git a/dictionarybar.cc b/dictionarybar.cc index 54753b453..104f0393c 100644 --- a/dictionarybar.cc +++ b/dictionarybar.cc @@ -211,7 +211,7 @@ void DictionaryBar::showContextMenu( QContextMenuEvent * event, bool extended ) { QString command( editDictionaryCommand ); command.replace( "%GDDICT%", "\"" + dictFilename + "\"" ); - if( !QProcess::startDetached( command ) ) + if( !QProcess::startDetached( command ,QStringList()) ) QApplication::beep(); } diff --git a/epwing.cc b/epwing.cc index fa61ed539..e3979ec5b 100644 --- a/epwing.cc +++ b/epwing.cc @@ -957,9 +957,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< sptr< Dictionary::Class > > dictionaries; vector< string > dictFiles; - QByteArray catName; - catName += QDir::separator(); - catName += "catalogs"; + QByteArray catName = QString("%1catalogs").arg(QDir::separator()).toUtf8(); for( vector< string >::const_iterator i = fileNames.begin(); i != fileNames.end(); ++i ) diff --git a/epwing_book.cc b/epwing_book.cc index 18f38298a..16d99353c 100644 --- a/epwing_book.cc +++ b/epwing_book.cc @@ -1732,8 +1732,7 @@ QByteArray EpwingBook::handleReference( EB_Hook_Code code, const unsigned int * if( refOpenCount > refCloseCount ) return QByteArray(); - QString str; - str.sprintf( "", refOpenCount ); + QString str=QString( "").arg( refOpenCount ); refOpenCount += 1; return str.toUtf8(); } @@ -1747,7 +1746,7 @@ QByteArray EpwingBook::handleReference( EB_Hook_Code code, const unsigned int * refOffsets.append( argv[ 2 ] ); QString str; - str.sprintf( "", refCloseCount ); + str.asprintf( "", refCloseCount ); refCloseCount += 1; return str.toUtf8(); diff --git a/extlineedit.cc b/extlineedit.cc index 1fb445fa6..6e4cc8f6e 100644 --- a/extlineedit.cc +++ b/extlineedit.cc @@ -109,14 +109,12 @@ void ExtLineEdit::updateButtonPositions() iconPos = (iconPos == Left ? Right : Left); if (iconPos == ExtLineEdit::Right) { - int right; - getTextMargins(0, 0, &right, 0); - const int iconoffset = right + 4; + QMargins qm=textMargins(); + const int iconoffset = qm.right() + 4; iconButtons[i]->setGeometry(contentRect.adjusted(width() - iconoffset, 0, 0, 0)); } else { - int left; - getTextMargins(&left, 0, 0, 0); - const int iconoffset = left + 4; + QMargins qm=textMargins(); + const int iconoffset = qm.left() + 4; iconButtons[i]->setGeometry(contentRect.adjusted(0, 0, -width() + iconoffset, 0)); } } diff --git a/favoritespanewidget.cc b/favoritespanewidget.cc index 0ac47c34a..973d88158 100644 --- a/favoritespanewidget.cc +++ b/favoritespanewidget.cc @@ -907,7 +907,9 @@ void FavoritesModel::removeItemsForIndexes( const QModelIndexList & idxList ) for( int i = lowestLevel; i >= 0; i-- ) { QModelIndexList idxSublist = itemsToDelete[ i ]; - std::sort( idxSublist.begin(), idxSublist.end(), qGreater< QModelIndex >() ); + //std::greater does not work ,operator < not implemented ,use std:less first ,then std::reverse. + std::sort(idxSublist.begin(), idxSublist.end(), std::less()); + std::reverse(idxSublist.begin(), idxSublist.end()); it = idxSublist.begin(); for( ; it != idxSublist.end(); ++it ) diff --git a/fulltextsearch.cc b/fulltextsearch.cc index a7ad45959..4c83f57f1 100644 --- a/fulltextsearch.cc +++ b/fulltextsearch.cc @@ -649,7 +649,7 @@ Q_UNUSED( parent ); for( int x = 0; x < hws.length(); x++ ) { - QList< FtsHeadword >::iterator it = qBinaryFind( headwords.begin(), headwords.end(), hws.at( x ) ); + QList< FtsHeadword >::iterator it = std::lower_bound( headwords.begin(), headwords.end(), hws.at( x ) ); if( it != headwords.end() ) { it->dictIDs.push_back( hws.at( x ).dictIDs.front() ); diff --git a/gddebug.cc b/gddebug.cc index 57cd7ab10..7c08f5c02 100644 --- a/gddebug.cc +++ b/gddebug.cc @@ -23,7 +23,7 @@ QTextCodec *localeCodec = 0; QTextCodec::setCodecForLocale( utf8Codec ); } - qWarning( "%s", QString().vsprintf( msg, ap ).toUtf8().data() ); + qWarning( "%s", QString().vasprintf( msg, ap ).toUtf8().data() ); if( logFilePtr && logFilePtr->isOpen() ) { @@ -48,7 +48,7 @@ QTextCodec *localeCodec = 0; QTextCodec::setCodecForLocale( utf8Codec ); } - qDebug( "%s", QString().vsprintf( msg, ap ).toUtf8().data() ); + qDebug( "%s", QString().vasprintf( msg, ap ).toUtf8().data() ); if( logFilePtr && logFilePtr->isOpen() ) { diff --git a/goldendict.pro b/goldendict.pro index 6782f3d45..6faba4489 100644 --- a/goldendict.pro +++ b/goldendict.pro @@ -29,7 +29,7 @@ QT += widgets \ printsupport \ help -#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x050F00 +DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x050F00 # QMediaPlayer is not available in Qt4. !CONFIG( no_qtmultimedia_player ) { diff --git a/groups_widgets.cc b/groups_widgets.cc index 5775aba3c..629c55215 100644 --- a/groups_widgets.cc +++ b/groups_widgets.cc @@ -744,8 +744,8 @@ void DictGroupsWidget::addAutoGroups() dictMap[ name ] = vd; } - QStringList groupList = dictMap.uniqueKeys(); - QStringList morphoList = morphoMap.uniqueKeys(); + QStringList groupList = dictMap.keys(); + QStringList morphoList = morphoMap.keys(); // Insert morphology dictionaries into corresponding lists diff --git a/helpwindow.cc b/helpwindow.cc index cdacc7697..921136d55 100644 --- a/helpwindow.cc +++ b/helpwindow.cc @@ -11,6 +11,7 @@ #include "helpwindow.hh" #include "gddebug.hh" +#include namespace Help { @@ -25,9 +26,11 @@ void HelpBrowser::showHelpForKeyword( QString const & id ) { if ( helpEngine ) { - QMap< QString, QUrl > links = helpEngine->linksForIdentifier( id ); - if( !links.isEmpty() ) - setSource( links.constBegin().value() ); + QList links = helpEngine->documentsForIdentifier(id); + if (!links.isEmpty()) { + QHelpLink link=links.constFirst(); + setSource(link.url); + } } } diff --git a/hotkeyedit.cc b/hotkeyedit.cc index cf255dde2..6ba4f27d1 100644 --- a/hotkeyedit.cc +++ b/hotkeyedit.cc @@ -87,7 +87,7 @@ void HotKeyEdit::keyPressEvent( QKeyEvent * event ) // Delete current combo currentKey1 = 0; currentKey2 = 0; - currentModifiers = 0; + currentModifiers = Qt::NoModifier; continuingCombo = false; } else diff --git a/mainstatusbar.cc b/mainstatusbar.cc index fe41655b2..47ea5f225 100644 --- a/mainstatusbar.cc +++ b/mainstatusbar.cc @@ -43,7 +43,7 @@ MainStatusBar::MainStatusBar( QWidget *parent ) : QWidget( parent ) bool MainStatusBar::hasImage() const { - return !picWidget->pixmap()->isNull(); + return !picWidget->pixmap().isNull(); } void MainStatusBar::clearMessage() @@ -92,7 +92,7 @@ void MainStatusBar::refresh() { adjustSize(); - if ( !picWidget->pixmap()->isNull() ) + if ( !picWidget->pixmap().isNull() ) { picWidget->setFixedSize( textWidget->height(), textWidget->height() ); } diff --git a/maintabwidget.cc b/maintabwidget.cc index fdf3ca151..0d15f9d18 100644 --- a/maintabwidget.cc +++ b/maintabwidget.cc @@ -67,7 +67,7 @@ bool MainTabWidget::eventFilter( QObject * obj, QEvent * ev ) if( obj == tabBar() && ev->type() == QEvent::MouseButtonPress ) { QMouseEvent * mev = static_cast< QMouseEvent *>( ev ); - if( mev->button() == Qt::MidButton ) + if( mev->button() == Qt::MiddleButton ) { emit tabCloseRequested( tabBar()->tabAt( mev->pos() ) ); return true; diff --git a/mainwindow.cc b/mainwindow.cc index 31a41cf7a..d5bceb305 100644 --- a/mainwindow.cc +++ b/mainwindow.cc @@ -980,7 +980,7 @@ void MainWindow::mousePressEvent( QMouseEvent *event) return; } - if (event->button() != Qt::MidButton) + if (event->button() != Qt::MiddleButton) return QMainWindow::mousePressEvent(event); // middle clicked @@ -1199,11 +1199,11 @@ void MainWindow::wheelEvent( QWheelEvent *ev ) { if ( ev->modifiers().testFlag( Qt::ControlModifier ) ) { - if ( ev->delta() > 0 ) + if ( ev->angleDelta().y() > 0 ) { zoomin(); } - else if ( ev->delta() < 0 ) + else if ( ev->angleDelta().y() < 0 ) { zoomout(); } @@ -4344,12 +4344,11 @@ void MainWindow::editDictionary( Dictionary::Class * dict ) QString headword = unescapeTabHeader( ui.tabWidget->tabText( ui.tabWidget->currentIndex() ) ); command.replace( "%GDWORD%", headword ); } - if( !QProcess::startDetached( command ) ) + if( !QProcess::startDetached( command,QStringList() ) ) QApplication::beep(); } } - void MainWindow::openDictionaryFolder( const QString & id ) { for( unsigned x = 0; x < dictionaries.size(); x++ ) diff --git a/mainwindow.hh b/mainwindow.hh index 36392790b..ffe4d0b0b 100644 --- a/mainwindow.hh +++ b/mainwindow.hh @@ -523,7 +523,7 @@ class ArticleSaveProgressDialog : public QProgressDialog Q_OBJECT public: - explicit ArticleSaveProgressDialog( QWidget * parent = 0, Qt::WindowFlags f = 0 ): + explicit ArticleSaveProgressDialog( QWidget * parent = 0, Qt::WindowFlags f = Qt::Widget ): QProgressDialog( parent, f ) { setAutoReset( false ); diff --git a/mdictparser.cc b/mdictparser.cc index 48869b462..ed31a9222 100644 --- a/mdictparser.cc +++ b/mdictparser.cc @@ -357,7 +357,7 @@ bool MdictParser::readHeader( QDataStream & in ) if ( headerAttributes.contains( "StyleSheet" ) ) { QString styleSheets = headerAttributes.namedItem( "StyleSheet" ).toAttr().value(); - QStringList lines = styleSheets.split( QRegularExpression( "[\r\n]" ), QString::KeepEmptyParts ); + QStringList lines = styleSheets.split( QRegularExpression( "[\r\n]" ), Qt::KeepEmptyParts ); for ( int i = 0; i < lines.size() - 3; i += 3 ) { diff --git a/preferences.cc b/preferences.cc index 1e83f78fe..fcd1a4aae 100644 --- a/preferences.cc +++ b/preferences.cc @@ -77,7 +77,7 @@ Preferences::Preferences( QWidget * parent, Config::Class & cfg_ ): if ( lang == "qt" ) continue; // We skip qt's own localizations - sortedLocs.insertMulti( + sortedLocs.insert( Language::localizedNameForId( LangCoder::code2toInt( lang.toLatin1().data() ) ), QPair< QIcon, QString >( QIcon( QString( ":/flags/%1.png" ).arg( i->mid( 3, 2 ).toLower() ) ), @@ -122,7 +122,7 @@ Preferences::Preferences( QWidget * parent, Config::Class & cfg_ ): reg = lang.toUpper(); } - sortedHelps.insertMulti( + sortedHelps.insert( Language::localizedNameForId( LangCoder::code2toInt( lang.toLatin1().data() ) ), QPair< QIcon, QString >( QIcon( QString( ":/flags/%1.png" ).arg( reg.toLower() ) ), lang + "_" + reg ) ); diff --git a/scanflag.cc b/scanflag.cc index 346f45cea..13982b42c 100644 --- a/scanflag.cc +++ b/scanflag.cc @@ -3,6 +3,7 @@ #include "scanflag.hh" #include "ui_scanflag.h" +#include static Qt::WindowFlags popupWindowFlags = @@ -53,7 +54,7 @@ void ScanFlag::showScanFlag() QPoint currentPos = QCursor::pos(); - QRect desktop = QApplication::desktop()->screenGeometry(); + QRect desktop = QGuiApplication::primaryScreen()->geometry(); QSize windowSize = geometry().size(); diff --git a/scanpopup.cc b/scanpopup.cc index e911d67cd..eb88f170c 100644 --- a/scanpopup.cc +++ b/scanpopup.cc @@ -629,7 +629,7 @@ void ScanPopup::engagePopup( bool forcePopup, bool giveFocus ) QPoint currentPos = QCursor::pos(); - QRect desktop = QApplication::desktop()->screenGeometry(); + QRect desktop = QGuiApplication::primaryScreen()->geometry(); QSize windowSize = geometry().size(); diff --git a/slob.cc b/slob.cc index a0e9c4101..1821fca3f 100644 --- a/slob.cc +++ b/slob.cc @@ -903,7 +903,7 @@ string SlobDictionary::convert( const string & in, RefEntry const & entry ) || list[ 1 ].endsWith( " tex" ) ) { QString name; - name.sprintf( "%04X%04X%04X.gif", entry.itemIndex, entry.binIndex, texCount ); + name.asprintf( "%04X%04X%04X.gif", entry.itemIndex, entry.binIndex, texCount ); imgName = texCachePath + "/" + name; if( !QFileInfo( imgName ).exists() ) @@ -986,7 +986,7 @@ string SlobDictionary::convert( const string & in, RefEntry const & entry ) QString command = texCgiPath + " -e " + imgName + " \"" + tex + "\""; - QProcess::execute( command ); + QProcess::execute( command,QStringList() ); } QString tag = QString( "resizeColumnToContents( 0 ); // Make sure this thing will be large enough ui.programs->setColumnWidth( 1, - QFontMetrics( QFont() ).width( + QFontMetrics( QFont() ).horizontalAdvance( ProgramTypeEditor::getNameForType( Config::Program::PrefixMatch ) ) + 16 ); ui.programs->resizeColumnToContents( 2 ); ui.programs->resizeColumnToContents( 3 ); diff --git a/translatebox.cc b/translatebox.cc index cc73762f4..a16cd7b3a 100644 --- a/translatebox.cc +++ b/translatebox.cc @@ -107,7 +107,7 @@ TranslateBox::TranslateBox(QWidget *parent) : QWidget(parent), QHBoxLayout *layout = new QHBoxLayout(this); setLayout(layout); - layout->setMargin(0); + layout->setContentsMargins(0,0,0,0); layout->addWidget(translate_line); QPixmap image(":/icons/system-search.png"); diff --git a/website.cc b/website.cc index a2bda352a..67880341b 100644 --- a/website.cc +++ b/website.cc @@ -371,7 +371,7 @@ sptr< DataRequest > WebSiteDictionary::getArticle( wstring const & str, { codec = QTextCodec::codecForName( QString( "ISO 8859-%1" ).arg( x ).toLatin1() ); if( codec ) - urlString.replace( QString( "%25GDISO%1%25" ).arg( x ), codec->fromUnicode( inputWord ).toPercentEncoding() ); + urlString.replace( QString( "%25GDISO%1%25" ).arg( x ).toUtf8(), codec->fromUnicode( inputWord ).toPercentEncoding() ); if ( x == 10 ) x = 12; // Skip encodings 11..12, they don't exist diff --git a/zipfile.cc b/zipfile.cc index 837eb497e..04a43b0cf 100644 --- a/zipfile.cc +++ b/zipfile.cc @@ -242,11 +242,11 @@ QDateTime SplitZipFile::lastModified() const unsigned long ts = 0; for( QVector< QFile * >::const_iterator i = files.begin(); i != files.end(); ++i ) { - unsigned long t = QFileInfo( (*i)->fileName() ).lastModified().toTime_t(); + unsigned long t = QFileInfo( (*i)->fileName() ).lastModified().toSecsSinceEpoch(); if( t > ts ) ts = t; } - return QDateTime::fromTime_t( ts ); + return QDateTime::fromSecsSinceEpoch( ts ); } qint64 SplitZipFile::calcAbsoluteOffset( qint64 offset, quint16 partNo ) From 3b4c1056554056d1f48facee4c03a7057b2aad25 Mon Sep 17 00:00:00 2001 From: xiaoyifang Date: Sat, 8 Jan 2022 22:02:29 +0800 Subject: [PATCH 3/3] improve:Win Specific, replace deprecated method --- articlewebview.cc | 2 +- fulltextsearch.cc | 4 ++-- initializing.cc | 4 ++-- mainwindow.cc | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/articlewebview.cc b/articlewebview.cc index 1d412386c..af5bedf5c 100644 --- a/articlewebview.cc +++ b/articlewebview.cc @@ -162,7 +162,7 @@ void ArticleWebView::wheelEvent( QWheelEvent *ev ) SystemParametersInfo( SPI_GETWHEELSCROLLLINES, 0, &nLines, 0 ); if( nLines == WHEEL_PAGESCROLL ) { - QKeyEvent kev( QEvent::KeyPress, ev->delta() > 0 ? Qt::Key_PageUp : Qt::Key_PageDown, + QKeyEvent kev( QEvent::KeyPress, ev->angleDelta ().y () > 0 ? Qt::Key_PageUp : Qt::Key_PageDown, Qt::NoModifier ); QApplication::sendEvent( this, &kev ); diff --git a/fulltextsearch.cc b/fulltextsearch.cc index 4c83f57f1..02b24dce3 100644 --- a/fulltextsearch.cc +++ b/fulltextsearch.cc @@ -17,6 +17,7 @@ #include "initializing.hh" #include #include +#include #endif @@ -248,8 +249,7 @@ FullTextSearchDialog::FullTextSearchDialog( QWidget * parent, oldBarStyle = 0; - if( QSysInfo::windowsVersion() >= QSysInfo::WV_VISTA - && ( QSysInfo::windowsVersion() & QSysInfo::WV_NT_based ) + if( QOperatingSystemVersion::current () >= QOperatingSystemVersion::Windows7 && !IsThemeActive() ) { QStyle * barStyle = WindowsStyle::instance().getStyle(); diff --git a/initializing.cc b/initializing.cc index e6d68b4f8..8d1d4a81a 100644 --- a/initializing.cc +++ b/initializing.cc @@ -8,6 +8,7 @@ #if defined( Q_OS_WIN32 ) #include #include +#include WindowsStyle::WindowsStyle() { @@ -41,8 +42,7 @@ Initializing::Initializing( QWidget * parent, bool showOnStartup ): QDialog( par oldBarStyle = 0; - if( QSysInfo::windowsVersion() >= QSysInfo::WV_VISTA - && ( QSysInfo::windowsVersion() & QSysInfo::WV_NT_based ) + if( QOperatingSystemVersion::current () >= QOperatingSystemVersion::Windows7 && !IsThemeActive() ) { QStyle * barStyle = WindowsStyle::instance().getStyle(); diff --git a/mainwindow.cc b/mainwindow.cc index d5bceb305..0e9344361 100644 --- a/mainwindow.cc +++ b/mainwindow.cc @@ -742,7 +742,7 @@ MainWindow::MainWindow( Config::Class & cfg_ ): #ifdef Q_OS_WIN if( cfg.normalMainWindowGeometry.width() <= 0 ) { - QRect r = QApplication::desktop()->availableGeometry(); + QRect r = QGuiApplication::primaryScreen ()->geometry (); cfg.normalMainWindowGeometry.setRect( r.width() / 4, r.height() / 4, r.width() / 2, r.height() / 2 ); } if( cfg.maximizedMainWindowGeometry.width() > 0 )