opt: let qt handle the language direction (#709)

* opt: let qt handle the language direction

* 🎨 apply clang-format changes

* action: modify auto clang format action

---------

Co-authored-by: xiaoyifang <xiaoyifang@users.noreply.github.com>
This commit is contained in:
xiaoyifang 2023-05-19 19:41:27 +08:00 committed by GitHub
parent 1e328e0727
commit d08d5fe576
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 37 deletions

View file

@ -28,10 +28,7 @@ jobs:
- name: ubuntu install clang-format
run: |
sudo apt-get install git lsb-release wget software-properties-common
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh
rm -f llvm.sh
wget -qO - https://apt.llvm.org/llvm.sh| sudo bash
sudo apt-get update
sudo apt-get install -y clang-format
git-clang-format --style=file HEAD^

View file

@ -221,17 +221,13 @@ std::string ArticleMaker::makeNotFoundBody( QString const & word,
{
string result( "<div class=\"gdnotfound\"><p>" );
QString str( word );
if( str.isRightToLeft() )
{
str.insert( 0, (ushort)0x202E ); // RLE, Right-to-Left Embedding
str.append( (ushort)0x202C ); // PDF, POP DIRECTIONAL FORMATTING
}
if ( word.size() )
result += tr( "No translation for <b>%1</b> was found in group <b>%2</b>." ).
arg( QString::fromUtf8( Html::escape( str.toUtf8().data() ).c_str() ), QString::fromUtf8( Html::escape( group.toUtf8().data() ).c_str() ) ).
toUtf8().data();
result += tr( "No translation for <b dir=\"%3\">%1</b> was found in group <b>%2</b>." )
.arg( QString::fromUtf8( Html::escape( word.toUtf8().data() ).c_str() ),
QString::fromUtf8( Html::escape( group.toUtf8().data() ).c_str() ),
word.isRightToLeft() ? "rtl" : "ltr" )
.toUtf8()
.data();
else
result += tr( "No translation was found in group <b>%1</b>." ).
arg( QString::fromUtf8( Html::escape( group.toUtf8().data() ).c_str() ) ).

View file

@ -1789,12 +1789,6 @@ void ArticleView::contextMenuRequested( QPoint const & pos )
// We don't prompt for selections larger or equal to 60 chars, since
// it ruins the menu and it's hardly a single word anyway.
if( text.isRightToLeft() )
{
text.insert( 0, (ushort)0x202E ); // RLE, Right-to-Left Embedding
text.append( (ushort)0x202C ); // PDF, POP DIRECTIONAL FORMATTING
}
lookupSelection = new QAction( tr( "&Look up \"%1\"" ).
arg( text ),
&menu );

View file

@ -1844,12 +1844,6 @@ void MainWindow::titleChanged( ArticleView * view, QString const & title )
}
escaped.replace( "&", "&&" );
if( escaped.isRightToLeft() )
{
escaped.insert( 0, (ushort)0x202E ); // RLE, Right-to-Left Embedding
escaped.append( (ushort)0x202C ); // PDF, POP DIRECTIONAL FORMATTING
}
int index = ui.tabWidget->indexOf( view );
if( !escaped.isEmpty() )
ui.tabWidget->setTabText( index, escaped );
@ -1883,13 +1877,7 @@ void MainWindow::updateWindowTitle()
if ( view )
{
QString str = view->getTitle();
if( !str.isEmpty() )
{
if( str.isRightToLeft() )
{
str.insert( 0, (ushort)0x202E ); // RLE, Right-to-Left Embedding
str.append( (ushort)0x202C ); // PDF, POP DIRECTIONAL FORMATTING
}
if ( !str.isEmpty() ) {
if( !blockUpdateWindowTitle )
setWindowTitle( tr( "%1 - %2" ).arg( str, "GoldenDict-ng" ) );
blockUpdateWindowTitle = false;
@ -4423,10 +4411,6 @@ QString MainWindow::unescapeTabHeader(QString const & header )
QString escaped = header;
escaped.replace( "&&", "&" );
if( escaped.startsWith( QChar( 0x202E ) ) )
escaped = escaped.mid( 1 );
if( escaped.endsWith( QChar( 0x202C ) ) )
escaped.chop( 1 );
return escaped;
}