Merge branch 'staged' into dev

This commit is contained in:
YiFang Xiao 2023-09-30 11:53:56 +08:00
commit be1768d36c
10 changed files with 59 additions and 22 deletions

View file

@ -78,8 +78,6 @@ jobs:
sudo make install
find /usr/local -name libzstd.1.dylib
find /usr/local -name liblzma.5.dylib
find /usr/local -name libhwy.1.dylib
find /opt -name libhwy.1.dylib
- name: version-file
shell: bash
env:
@ -113,23 +111,16 @@ jobs:
otool -L GoldenDict.app/Contents/Frameworks/libzim.8.dylib
# otool -L GoldenDict.app/Contents/Frameworks/libav*
# otool -L GoldenDict.app/Contents/Frameworks/libjxl.0.8.dylib
cp -r /usr/local/Cellar/icu4c/7*/lib/libicu*.dylib GoldenDict.app/Contents/Frameworks
cp -r /usr/local/Cellar/zstd/1.5.5/lib/libzstd.1.dylib GoldenDict.app/Contents/Frameworks
# dylibbundler -of -x GoldenDict.app/Contents/Frameworks/libzim.8.dylib -d GoldenDict.app/Contents/Frameworks/ -p @executable_path/../Frameworks
install_name_tool -change "@loader_path/../../../../opt/zstd/lib/libzstd.1.dylib" "@executable_path/../Frameworks/libzstd.1.dylib" GoldenDict.app/Contents/Frameworks/libzim.8.dylib
install_name_tool -change "@loader_path/../../../../opt/xz/lib/liblzma.5.dylib" "@executable_path/../Frameworks/liblzma.5.dylib" GoldenDict.app/Contents/Frameworks/libzim.8.dylib
install_name_tool -change "@loader_path/../../../../opt/xapian/lib/libxapian.30.dylib" "@executable_path/../Frameworks/libxapian.30.dylib" GoldenDict.app/Contents/Frameworks/libzim.8.dylib
install_name_tool -change "@loader_path/../../../../opt/icu4c/lib/libicui18n.73.dylib" "@executable_path/../Frameworks/libicui18n.73.dylib" GoldenDict.app/Contents/Frameworks/libzim.8.dylib
install_name_tool -change "@loader_path/../../../../opt/icu4c/lib/libicuuc.73.dylib" "@executable_path/../Frameworks/libicuuc.73.dylib" GoldenDict.app/Contents/Frameworks/libzim.8.dylib
dylibbundler -of -x GoldenDict.app/Contents/Frameworks/libicui18n.73.dylib -x GoldenDict.app/Contents/Frameworks/libicudata.73.dylib -x GoldenDict.app/Contents/Frameworks/libicuuc.73.dylib -d GoldenDict.app/Contents/Frameworks/ -p @executable_path/../Frameworks -s /usr/local
# cp -r /usr/local/Cellar/icu4c/7*/lib/libicu*.dylib GoldenDict.app/Contents/Frameworks
# cp -r /usr/local/Cellar/zstd/1.5.5/lib/libzstd.1.dylib GoldenDict.app/Contents/Frameworks
dylibbundler -of -b -x GoldenDict.app/Contents/Frameworks/libzim.8.dylib -d GoldenDict.app/Contents/Frameworks/ -p @executable_path/../Frameworks -s /usr/local/ -s /opt/
# dylibbundler -of -b -x GoldenDict.app/Contents/Frameworks/libicu* -d GoldenDict.app/Contents/Frameworks/ -p @executable_path/../Frameworks -s /usr/local/ -s /opt/
find GoldenDict.app/Contents/Frameworks/ -maxdepth 1 -type f -name "libicu*" -exec dylibbundler -of -b -x {} -d GoldenDict.app/Contents/Frameworks/ -p @executable_path/../Frameworks -s /usr/local/ -s /opt/ \;
# dylibbundler -of -x GoldenDict.app/Contents/Frameworks/libavformat.60.dylib -x GoldenDict.app/Contents/Frameworks/libavcodec.60.dylib -d GoldenDict.app/Contents/Frameworks/ -p @executable_path/../Frameworks -s /usr/local/ -s /opt/
# dylibbundler -of -b -x GoldenDict.app/Contents/Frameworks/libjxl.0.8.dylib -d GoldenDict.app/Contents/Frameworks/ -p @executable_path/../Frameworks -s /usr/local/ -s /opt/
# otool -L GoldenDict.app/Contents/Frameworks/libav*
# otool -L GoldenDict.app/Contents/Frameworks/libjxl.0.8.dylib
otool -L GoldenDict.app/Contents/Frameworks/libicu*
otool -L GoldenDict.app/Contents/Frameworks/libzim.8.dylib
otool -L GoldenDict.app/Contents/Frameworks/libxapian.30.dylib
otool -L GoldenDict.app/Contents/Frameworks/liblzma.5.dylib

View file

@ -148,6 +148,7 @@ struct GDOptions
bool logFile = false;
bool togglePopup = false;
QString word, groupName, popupGroupName;
QString window;
inline bool needSetGroup() const
{
@ -220,6 +221,14 @@ void processCommandLine( QCoreApplication * app, GDOptions * result )
QObject::tr( "Change the group of popup." ),
"popupGroupName" );
QCommandLineOption window_popupOption( QStringList() << "s"
<< "scanpopup",
QObject::tr( "Force the word to be translated in scanpopup" ) );
QCommandLineOption window_mainWindowOption( QStringList() << "m"
<< "main-window",
QObject::tr( "Force the word to be translated in the mainwindow" ) );
QCommandLineOption togglePopupOption( QStringList() << "t"
<< "toggle-scan-popup",
QObject::tr( "Toggle scan popup." ) );
@ -231,6 +240,8 @@ void processCommandLine( QCoreApplication * app, GDOptions * result )
qcmd.addOption( logFileOption );
qcmd.addOption( groupNameOption );
qcmd.addOption( popupGroupNameOption );
qcmd.addOption( window_popupOption );
qcmd.addOption( window_mainWindowOption );
qcmd.addOption( togglePopupOption );
qcmd.addOption( notts );
qcmd.addOption( resetState );
@ -253,7 +264,12 @@ void processCommandLine( QCoreApplication * app, GDOptions * result )
if ( qcmd.isSet( popupGroupNameOption ) ) {
result->popupGroupName = qcmd.value( popupGroupNameOption );
}
if ( qcmd.isSet( window_popupOption ) ) {
result->window = "popup";
}
if ( qcmd.isSet( window_mainWindowOption ) ) {
result->window = "main";
}
if ( qcmd.isSet( togglePopupOption ) ) {
result->togglePopup = true;
}
@ -414,6 +430,7 @@ int main( int argc, char ** argv )
if ( app.isRunning() ) {
bool wasMessage = false;
//TODO .all the following messages can be combined into one.
if ( gdcl.needSetGroup() ) {
app.sendMessage( QString( "setGroup: " ) + gdcl.getGroupName() );
wasMessage = true;
@ -424,6 +441,11 @@ int main( int argc, char ** argv )
wasMessage = true;
}
if ( !gdcl.window.isEmpty() ) {
app.sendMessage( QString( "window:" ) + gdcl.window );
wasMessage = true;
}
if ( gdcl.needTranslateWord() ) {
app.sendMessage( QString( "translateWord: " ) + gdcl.wordToTranslate() );
wasMessage = true;
@ -511,7 +533,8 @@ int main( int argc, char ** argv )
//System Font
auto font = QApplication::font();
if ( !cfg.preferences.interfaceFont.isEmpty() && font.family() != cfg.preferences.interfaceFont ) {
app.setFont( QFont( cfg.preferences.interfaceFont ) );
font.setFamily( cfg.preferences.interfaceFont );
app.setFont( font );
}
QLocale locale( localeName );

View file

@ -3548,11 +3548,28 @@ void MainWindow::messageFromAnotherInstanceReceived( QString const & message )
return;
}
QString prefix = "window:";
if ( message.left( prefix.size() ) == prefix ) {
consoleWindowOnce = message.mid( prefix.size() );
}
if ( message.left( 15 ) == "translateWord: " ) {
if ( scanPopup )
scanPopup->translateWord( message.mid( 15 ) );
else
wordReceived( message.mid( 15 ) );
auto word = message.mid( 15 );
if ( ( consoleWindowOnce == "popup" ) && scanPopup ) {
scanPopup->translateWord( word );
}
else if ( consoleWindowOnce == "main" ) {
wordReceived( word );
}
else {
//default logic
if ( scanPopup && enableScanningAction->isChecked() )
scanPopup->translateWord( word );
else
wordReceived( word );
}
consoleWindowOnce.clear();
}
else if ( message.left( 10 ) == "setGroup: " ) {
setGroupByName( message.mid( 10 ), true );

View file

@ -149,6 +149,9 @@ private:
ScanPopup * scanPopup = nullptr;
//only used once, when used ,reset to empty.
QString consoleWindowOnce;
sptr< HotkeyWrapper > hotkeyWrapper;
sptr< QPrinter > printer; // The printer we use for all printing operations

View file

@ -647,7 +647,9 @@ void Preferences::on_buttonBox_accepted()
//change interface font.
if ( ui.systemFont->currentText() != prevSysFont ) {
QApplication::setFont( QFont( ui.systemFont->currentText() ) );
auto font = QApplication::font();
font.setFamily( ui.systemFont->currentText() );
QApplication::setFont( font );
}
}

View file

@ -49,6 +49,7 @@ TranslateBox::TranslateBox( QWidget * parent ):
translate_line->setCompleter( completer );
completer->setCompletionMode( QCompleter::UnfilteredPopupCompletion );
completer->setMaxVisibleItems( 16 );
completer->popup()->setMinimumHeight( 256 );
connect( translate_line, &QLineEdit::returnPressed, [ this ]() {
emit returnPressed();

Binary file not shown.

Binary file not shown.

Binary file not shown.