feat: add dict:// handler to linux

* Remove any thing before first occurance of ://
* so that user may add custom handler by just changing the .desktop file
This commit is contained in:
shenleban tongying 2023-04-27 08:52:55 -04:00 committed by xiaoyifang
parent 81e1b5d9a6
commit 9716acb2ee
2 changed files with 3 additions and 3 deletions

View file

@ -7,4 +7,4 @@ GenericName=Multiformat Dictionary
Comment=A feature-rich dictionary lookup program
Icon=goldendict
Exec=goldendict %u
MimeType=x-scheme-handler/goldendict
MimeType=x-scheme-handler/goldendict;x-scheme-handler/dict;

View file

@ -175,8 +175,8 @@ void processCommandLine( QCoreApplication * app, GDOptions * result)
result->word = posArgs.at( 0 );
#if defined( Q_OS_LINUX ) || defined( Q_OS_WIN )
// handle url scheme like "goldendict://" on windows
result->word.remove( "goldendict://" );
// handle url scheme like "goldendict://" or "dict://" on windows/linux
result->word.remove( 0, result->word.indexOf( "://" ) + 3 );
// In microsoft Words, the / will be automatically appended
if ( result->word.endsWith( "/" ) ) {
result->word.chop( 1 );