mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-23 20:14:05 +00:00
Implement "goldendict://nice" url scheme handler for windows and linux (#227)
* windows: add url scheme goldendict:// * linux: add url scheme goldendict:// handler
This commit is contained in:
parent
53d443357b
commit
5a284d5c66
8
main.cc
8
main.cc
|
@ -183,6 +183,14 @@ logFile( false )
|
|||
}
|
||||
else
|
||||
word = arguments[ i ];
|
||||
#if defined(Q_OS_LINUX) || defined (Q_OS_WIN)
|
||||
// handle url scheme like "goldendict://" on windows
|
||||
word.remove("goldendict://");
|
||||
// In microsoft Words, the / will be automatically appended
|
||||
if(word.endsWith("/")){
|
||||
word.chop(1);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -912,6 +912,21 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
|
|||
inspector.reset( new ArticleInspector( this ));
|
||||
|
||||
connect( QApplication::clipboard(), &QClipboard::changed, this, &MainWindow::clipboardChange );
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
// Regiser and update URL Scheme for windows
|
||||
// https://learn.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/aa767914(v=vs.85)
|
||||
|
||||
// Windows will automatically map registry key to Computer\HKEY_CLASSES_ROOT\ */
|
||||
QSettings urlRegistry(R"(HKEY_CURRENT_USER\Software\Classes)", QSettings::NativeFormat);
|
||||
|
||||
urlRegistry.beginGroup("goldendict");
|
||||
urlRegistry.setValue("Default", "URL: goldendict Protocol");
|
||||
urlRegistry.setValue("URL Protocol", "");
|
||||
urlRegistry.setValue("shell/open/command/Default",
|
||||
QString("\"%1\"").arg( QDir::toNativeSeparators(QApplication::applicationFilePath())) + " \"%1\"");
|
||||
urlRegistry.endGroup();
|
||||
#endif
|
||||
}
|
||||
|
||||
void MainWindow::clipboardChange( QClipboard::Mode m)
|
||||
|
|
|
@ -6,4 +6,5 @@ Name=GoldenDict
|
|||
GenericName=Multiformat Dictionary
|
||||
Comment=A feature-rich dictionary lookup program
|
||||
Icon=goldendict
|
||||
Exec=goldendict
|
||||
Exec=goldendict %u
|
||||
MimeType=x-scheme-handler/goldendict
|
||||
|
|
Loading…
Reference in a new issue