mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-12-18 03:14:06 +00:00
opt: clean clang tidy issues
This commit is contained in:
parent
a767f3f030
commit
fb0023abfc
|
@ -1727,7 +1727,6 @@ void MainWindow::fillWindowsMenu()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::switchToWindow( QAction * act )
|
void MainWindow::switchToWindow( QAction * act )
|
||||||
|
@ -1824,7 +1823,7 @@ void MainWindow::tabCloseRequested( int x )
|
||||||
// and only then remove the old one.
|
// and only then remove the old one.
|
||||||
|
|
||||||
//activate a tab in accordance with MRU
|
//activate a tab in accordance with MRU
|
||||||
if ( cfg.preferences.mruTabOrder && mruList.size() > 0 ) {
|
if ( cfg.preferences.mruTabOrder && !mruList.empty() ) {
|
||||||
ui.tabWidget->setCurrentWidget( mruList.at( 0 ) );
|
ui.tabWidget->setCurrentWidget( mruList.at( 0 ) );
|
||||||
}
|
}
|
||||||
else if ( ui.tabWidget->count() > 1 ) {
|
else if ( ui.tabWidget->count() > 1 ) {
|
||||||
|
@ -2231,7 +2230,7 @@ void MainWindow::editPreferences()
|
||||||
|
|
||||||
// Loop through all tabs and reload pages due to ArticleMaker's change.
|
// Loop through all tabs and reload pages due to ArticleMaker's change.
|
||||||
for ( int x = 0; x < ui.tabWidget->count(); ++x ) {
|
for ( int x = 0; x < ui.tabWidget->count(); ++x ) {
|
||||||
ArticleView & view = dynamic_cast< ArticleView & >( *( ui.tabWidget->widget( x ) ) );
|
auto & view = dynamic_cast< ArticleView & >( *( ui.tabWidget->widget( x ) ) );
|
||||||
|
|
||||||
view.setSelectionBySingleClick( p.selectWordBySingleClick );
|
view.setSelectionBySingleClick( p.selectWordBySingleClick );
|
||||||
view.syncBackgroundColorWithCfgDarkReader();
|
view.syncBackgroundColorWithCfgDarkReader();
|
||||||
|
@ -2253,9 +2252,9 @@ void MainWindow::editPreferences()
|
||||||
history.setMaxSize( cfg.preferences.maxStringsInHistory );
|
history.setMaxSize( cfg.preferences.maxStringsInHistory );
|
||||||
ui.historyPaneWidget->updateHistoryCounts();
|
ui.historyPaneWidget->updateHistoryCounts();
|
||||||
|
|
||||||
for ( unsigned x = 0; x < dictionaries.size(); x++ ) {
|
for ( const auto & dictionarie : dictionaries ) {
|
||||||
dictionaries[ x ]->setFTSParameters( cfg.preferences.fts );
|
dictionarie->setFTSParameters( cfg.preferences.fts );
|
||||||
dictionaries[ x ]->setSynonymSearchEnabled( cfg.preferences.synonymSearchEnabled );
|
dictionarie->setSynonymSearchEnabled( cfg.preferences.synonymSearchEnabled );
|
||||||
}
|
}
|
||||||
|
|
||||||
ui.fullTextSearchAction->setEnabled( cfg.preferences.fts.enabled );
|
ui.fullTextSearchAction->setEnabled( cfg.preferences.fts.enabled );
|
||||||
|
@ -2469,7 +2468,7 @@ bool MainWindow::handleBackForwardMouseButtons( QMouseEvent * event )
|
||||||
bool MainWindow::eventFilter( QObject * obj, QEvent * ev )
|
bool MainWindow::eventFilter( QObject * obj, QEvent * ev )
|
||||||
{
|
{
|
||||||
if ( ev->type() == QEvent::ShortcutOverride || ev->type() == QEvent::KeyPress ) {
|
if ( ev->type() == QEvent::ShortcutOverride || ev->type() == QEvent::KeyPress ) {
|
||||||
QKeyEvent * ke = dynamic_cast< QKeyEvent * >( ev );
|
auto * ke = dynamic_cast< QKeyEvent * >( ev );
|
||||||
// Handle F3/Shift+F3 shortcuts
|
// Handle F3/Shift+F3 shortcuts
|
||||||
int const key = ke->key();
|
int const key = ke->key();
|
||||||
if ( key == Qt::Key_F3 ) {
|
if ( key == Qt::Key_F3 ) {
|
||||||
|
@ -2504,7 +2503,7 @@ bool MainWindow::eventFilter( QObject * obj, QEvent * ev )
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ev->type() == QEvent::MouseButtonPress ) {
|
if ( ev->type() == QEvent::MouseButtonPress ) {
|
||||||
auto event = static_cast< QMouseEvent * >( ev );
|
auto event = dynamic_cast< QMouseEvent * >( ev );
|
||||||
|
|
||||||
return handleBackForwardMouseButtons( event );
|
return handleBackForwardMouseButtons( event );
|
||||||
}
|
}
|
||||||
|
@ -2536,7 +2535,7 @@ bool MainWindow::eventFilter( QObject * obj, QEvent * ev )
|
||||||
|
|
||||||
if ( obj == translateLine ) {
|
if ( obj == translateLine ) {
|
||||||
if ( ev->type() == QEvent::KeyPress ) {
|
if ( ev->type() == QEvent::KeyPress ) {
|
||||||
QKeyEvent * keyEvent = static_cast< QKeyEvent * >( ev );
|
QKeyEvent * keyEvent = dynamic_cast< QKeyEvent * >( ev );
|
||||||
|
|
||||||
if ( cfg.preferences.searchInDock ) {
|
if ( cfg.preferences.searchInDock ) {
|
||||||
if ( keyEvent->matches( QKeySequence::MoveToNextLine ) && ui.wordList->count() ) {
|
if ( keyEvent->matches( QKeySequence::MoveToNextLine ) && ui.wordList->count() ) {
|
||||||
|
@ -2558,7 +2557,7 @@ bool MainWindow::eventFilter( QObject * obj, QEvent * ev )
|
||||||
}
|
}
|
||||||
else if ( obj == ui.wordList ) {
|
else if ( obj == ui.wordList ) {
|
||||||
if ( ev->type() == QEvent::KeyPress ) {
|
if ( ev->type() == QEvent::KeyPress ) {
|
||||||
QKeyEvent * keyEvent = static_cast< QKeyEvent * >( ev );
|
QKeyEvent * keyEvent = dynamic_cast< QKeyEvent * >( ev );
|
||||||
|
|
||||||
if ( keyEvent->matches( QKeySequence::MoveToPreviousLine ) && !ui.wordList->currentRow() ) {
|
if ( keyEvent->matches( QKeySequence::MoveToPreviousLine ) && !ui.wordList->currentRow() ) {
|
||||||
ui.wordList->setCurrentRow( 0, QItemSelectionModel::Clear );
|
ui.wordList->setCurrentRow( 0, QItemSelectionModel::Clear );
|
||||||
|
@ -2612,7 +2611,7 @@ void MainWindow::wordListSelectionChanged()
|
||||||
{
|
{
|
||||||
QList< QListWidgetItem * > selected = ui.wordList->selectedItems();
|
QList< QListWidgetItem * > selected = ui.wordList->selectedItems();
|
||||||
|
|
||||||
if ( selected.size() ) {
|
if ( !selected.empty() ) {
|
||||||
wordListSelChanged = true;
|
wordListSelChanged = true;
|
||||||
showTranslationFor( selected.front()->text() );
|
showTranslationFor( selected.front()->text() );
|
||||||
}
|
}
|
||||||
|
@ -3069,10 +3068,10 @@ void MainWindow::on_newTab_triggered()
|
||||||
void MainWindow::setAutostart( bool autostart )
|
void MainWindow::setAutostart( bool autostart )
|
||||||
{
|
{
|
||||||
#if defined Q_OS_WIN32
|
#if defined Q_OS_WIN32
|
||||||
QSettings reg( "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run", QSettings::NativeFormat );
|
QSettings reg( R"(HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run)", QSettings::NativeFormat );
|
||||||
if ( autostart ) {
|
if ( autostart ) {
|
||||||
QString app_fname = QString( "\"%1\"" ).arg( QCoreApplication::applicationFilePath() );
|
QString app_fname = QString( R"("%1")" ).arg( QCoreApplication::applicationFilePath() );
|
||||||
app_fname.replace( "/", "\\" );
|
app_fname.replace( "/", R"(\)" );
|
||||||
reg.setValue( ApplicationSettingName, app_fname );
|
reg.setValue( ApplicationSettingName, app_fname );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -3111,8 +3110,8 @@ void MainWindow::on_pageSetup_triggered()
|
||||||
|
|
||||||
void MainWindow::on_printPreview_triggered()
|
void MainWindow::on_printPreview_triggered()
|
||||||
{
|
{
|
||||||
QPrinter printer;
|
QPrinter _printer;
|
||||||
QPrintPreviewDialog dialog( &printer, this );
|
QPrintPreviewDialog dialog( &_printer, this );
|
||||||
auto combox = dialog.findChild< QComboBox * >();
|
auto combox = dialog.findChild< QComboBox * >();
|
||||||
int index = combox->findText( "100%" );
|
int index = combox->findText( "100%" );
|
||||||
combox->setCurrentIndex( index );
|
combox->setCurrentIndex( index );
|
||||||
|
@ -3168,7 +3167,7 @@ static void filterAndCollectResources( QString & html,
|
||||||
|
|
||||||
if ( resourceIncluded.insert( hash.result() ).second ) {
|
if ( resourceIncluded.insert( hash.result() ).second ) {
|
||||||
// Gather resource information (url, filename) to be download later
|
// Gather resource information (url, filename) to be download later
|
||||||
downloadResources.push_back( pair< QUrl, QString >( url, folder + host + resourcePath ) );
|
downloadResources.emplace_back( url, folder + host + resourcePath );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Modify original url, set to the native one
|
// Modify original url, set to the native one
|
||||||
|
@ -3231,7 +3230,7 @@ void MainWindow::on_saveArticle_triggered()
|
||||||
|
|
||||||
// Convert internal links
|
// Convert internal links
|
||||||
|
|
||||||
QRegExp rx3( "href=\"(bword:|gdlookup://localhost/)([^\"]+)\"" );
|
QRegExp rx3( R"lit(href="(bword:|gdlookup://localhost/)([^"]+)")lit" );
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
QRegularExpression anchorRx( "(g[0-9a-f]{32}_)[0-9a-f]+_" );
|
QRegularExpression anchorRx( "(g[0-9a-f]{32}_)[0-9a-f]+_" );
|
||||||
while ( ( pos = rx3.indexIn( html, pos ) ) != -1 ) {
|
while ( ( pos = rx3.indexIn( html, pos ) ) != -1 ) {
|
||||||
|
@ -3245,7 +3244,7 @@ void MainWindow::on_saveArticle_triggered()
|
||||||
anchor.replace( anchorRx, "\\1" ); // MDict anchors
|
anchor.replace( anchorRx, "\\1" ); // MDict anchors
|
||||||
}
|
}
|
||||||
name.replace( rxName, "_" );
|
name.replace( rxName, "_" );
|
||||||
name = QString( "href=\"" ) + QUrl::toPercentEncoding( name ) + ".html" + anchor + "\"";
|
name = QString( R"(href=")" ) + QUrl::toPercentEncoding( name ) + ".html" + anchor + "\"";
|
||||||
html.replace( pos, rx3.cap().length(), name );
|
html.replace( pos, rx3.cap().length(), name );
|
||||||
pos += name.length();
|
pos += name.length();
|
||||||
}
|
}
|
||||||
|
@ -3258,7 +3257,7 @@ void MainWindow::on_saveArticle_triggered()
|
||||||
|
|
||||||
if ( complete ) {
|
if ( complete ) {
|
||||||
QString folder = fi.absoluteDir().absolutePath() + "/" + fi.baseName() + "_files";
|
QString folder = fi.absoluteDir().absolutePath() + "/" + fi.baseName() + "_files";
|
||||||
QRegExp rx1( "\"((?:bres|gico|gdau|qrcx|qrc|gdvideo)://[^\"]+)\"" );
|
QRegExp rx1( R"lit("((?:bres|gico|gdau|qrcx|qrc|gdvideo)://[^"]+)")lit" );
|
||||||
QRegExp rx2( "'((?:bres|gico|gdau|qrcx|qrc|gdvideo)://[^']+)'" );
|
QRegExp rx2( "'((?:bres|gico|gdau|qrcx|qrc|gdvideo)://[^']+)'" );
|
||||||
set< QByteArray > resourceIncluded;
|
set< QByteArray > resourceIncluded;
|
||||||
vector< pair< QUrl, QString > > downloadResources;
|
vector< pair< QUrl, QString > > downloadResources;
|
||||||
|
@ -3266,7 +3265,7 @@ void MainWindow::on_saveArticle_triggered()
|
||||||
filterAndCollectResources( html, rx1, "\"", folder, resourceIncluded, downloadResources );
|
filterAndCollectResources( html, rx1, "\"", folder, resourceIncluded, downloadResources );
|
||||||
filterAndCollectResources( html, rx2, "'", folder, resourceIncluded, downloadResources );
|
filterAndCollectResources( html, rx2, "'", folder, resourceIncluded, downloadResources );
|
||||||
|
|
||||||
ArticleSaveProgressDialog * progressDialog = new ArticleSaveProgressDialog( this );
|
auto * progressDialog = new ArticleSaveProgressDialog( this );
|
||||||
// reserve '1' for saving main html file
|
// reserve '1' for saving main html file
|
||||||
int maxVal = 1;
|
int maxVal = 1;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue