Merge remote-tracking branch 'origin/staged' into dev
Some checks failed
Release AutoTag / Build (push) Has been cancelled
Release macOS / Build (macos-12, clang_64, 6.6.3) (push) Has been cancelled
Release macOS / Build (macos-12, clang_64, 6.7.2) (push) Has been cancelled
Release macOS / Build (macos-14, clang_64, 6.6.3) (push) Has been cancelled
Release macOS / Build (macos-14, clang_64, 6.7.2) (push) Has been cancelled
Release Windows CMake / Build (windows-2022, win64_msvc2019_64, 6.6.3) (push) Has been cancelled
Release Windows CMake / Build (windows-2022, win64_msvc2019_64, 6.7.2) (push) Has been cancelled

This commit is contained in:
Xiao Yi Fang 2024-09-07 08:47:43 +08:00
commit 22b1c04345
8 changed files with 29 additions and 66 deletions

View file

@ -73,7 +73,7 @@ jobs:
- name: compile
run: |
mkdir build_dir
cmake -S . -B build_dir -G Ninja -DWITH_FFMPEG_PLAYER=OFF -DWITH_TTS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_DEPLOYMENT_TARGET="12.0"
cmake -S . -B build_dir -G Ninja -DWITH_FFMPEG_PLAYER=OFF -DWITH_TTS=OFF -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_OSX_DEPLOYMENT_TARGET="12.0"
cmake --build build_dir
- name: package

View file

@ -6,7 +6,6 @@
#include "htmlescape.hh"
#include "utf8.hh"
#include "wstring_qt.hh"
#include "parsecmdline.hh"
#include "iconv.hh"
#include "utils.hh"
#include "globalbroadcaster.hh"
@ -142,7 +141,7 @@ RunInstance::RunInstance():
bool RunInstance::start( Config::Program const & prg, QString const & word, QString & error )
{
QStringList args = parseCommandLine( prg.commandLine );
QStringList args = QProcess::splitCommand( prg.commandLine );
if ( !args.empty() ) {
QString programName = args.first();
@ -164,7 +163,7 @@ bool RunInstance::start( Config::Program const & prg, QString const & word, QStr
process.start( programName, args );
if ( writeToStdInput ) {
process.write( word.toLocal8Bit() );
process.write( word.toUtf8() );
process.closeWriteChannel();
}

View file

@ -4,7 +4,6 @@
#include <QDir>
#include <QTimer>
#include "externalviewer.hh"
#include "parsecmdline.hh"
#include "gddebug.hh"
ExternalViewer::ExternalViewer(
@ -34,18 +33,18 @@ void ExternalViewer::start()
connect( &viewer, &QProcess::finished, this, &QObject::deleteLater );
connect( &viewer, &QProcess::errorOccurred, this, &QObject::deleteLater );
QStringList args = parseCommandLine( viewerCmdLine );
QStringList args = QProcess::splitCommand( viewerCmdLine );
if ( !args.isEmpty() ) {
QString program = args.first();
args.pop_front();
const QString program = args.takeFirst();
args.push_back( tempFileName );
viewer.start( program, args, QIODevice::NotOpen );
if ( !viewer.waitForStarted() )
if ( !viewer.waitForStarted() ) {
throw exCantRunViewer( viewerCmdLine.toUtf8().data() );
}
}
else
else {
throw exCantRunViewer( tr( "the viewer program name is empty" ).toUtf8().data() );
}
}
bool ExternalViewer::stop()

View file

@ -370,7 +370,10 @@ int main( int argc, char ** argv )
QHotkeyApplication::setApplicationName( "GoldenDict-ng" );
QHotkeyApplication::setOrganizationDomain( "https://github.com/xiaoyifang/goldendict-ng" );
#ifndef Q_OS_MACOS
// macOS icon is defined in Info.plist
QHotkeyApplication::setWindowIcon( QIcon( ":/icons/programicon.png" ) );
#endif
#ifdef Q_OS_WIN
// TODO: Force fusion because Qt6.7's "ModernStyle"'s dark theme have problems, need to test / reconsider in future

View file

@ -1,42 +0,0 @@
#include "parsecmdline.hh"
QStringList parseCommandLine( QString const & commandLine )
{
// Parse arguments. Handle quotes correctly.
QStringList args;
bool openQuote = false;
bool possibleDoubleQuote = false;
bool startNew = true;
for ( QString::const_iterator c = commandLine.begin(), e = commandLine.end(); c != e; ) {
if ( *c == '"' && !possibleDoubleQuote ) {
++c;
if ( !openQuote ) {
openQuote = true;
if ( startNew ) {
args.push_back( QString() );
startNew = false;
}
}
else
possibleDoubleQuote = true;
}
else if ( possibleDoubleQuote && *c != '"' ) {
openQuote = false;
possibleDoubleQuote = false;
}
else if ( *c == ' ' && !openQuote ) {
++c;
startNew = true;
}
else {
if ( startNew ) {
args.push_back( QString() );
startNew = false;
}
args.last().push_back( *c++ );
possibleDoubleQuote = false;
}
}
return args;
}

View file

@ -1,11 +0,0 @@
#ifndef PARSECMDLINE_HH
#define PARSECMDLINE_HH
#include <QStringList>
/// Given a command line (name of the executable with optional arguments),
/// separates-out the name and all the arguments into a list. Supports quotes
/// and double-quotes.
QStringList parseCommandLine( QString const & );
#endif // PARSECMDLINE_HH

View file

@ -68,9 +68,10 @@ In the "Icon" column you can set custom icon for every server. If you add icon f
## Programs
Here you can add external applications. To add such application, you should set command line for its launch, name for the dictionary list and application type.
Here you can add external applications. To add such an application, you should set the command line for its launch, name for the dictionary list and application type.
The `%GDWORD%` in command line will be replaced by word from search line.
The `%GDWORD%` in command line will be replaced by word from search line. If the command line doesn't contain such `%GDWORD%` the word will be fed into standard input stream in 8-bit current locale encoding.
| Program type | Purpose |
|--------------|---------------------------------------------------------------------------------------|
@ -83,6 +84,20 @@ Other than "Audio", the program should print the content to standard output.
In the "Icon" column, you can set a custom icon for every application. If you add icon file name without a path, GoldenDict will search this file in the configuration folder.
!!!note
The word will be written to `stdin` in UTF-8 if the command line doesn't contain `%GDWORD%`.
In rare situations on Windows, some programs may not read `stdin` as UTF-8. In this case, you need to do some adjustments.
For Python3.6+, reading `stdin` as UTF-8 is the default behaviour. For older versions, you may need to change [PYTHONIOENCODING](https://docs.python.org/3/using/cmdline.html#envvar-PYTHONIOENCODING).
For Node.js, try `process.stdin.setEncoding('utf8');`.
If you cannot change how your language handles stdin's encoding, try store the data read from the `stdin` as bytes and call related methods that interpret bytes as UTF-8 strings.
If you cannot access the source code, try enable "Beta: Use Unicode UTF-8 for worldwide language support." in Windows settings.
## Transliteration
Here you can add transliteration algorithms. To add algorithm into dictionaries list just set mark beside it. When such dictionary added into current dictionaries group GoldenDict will search word in the input line as well as result of its handling by corresponding transliteration algorithm.