mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-23 20:14:05 +00:00
Compare commits
11 commits
4631a59d6f
...
7626855556
Author | SHA1 | Date | |
---|---|---|---|
7626855556 | |||
608016208b | |||
1e3b22ebd0 | |||
720f66c781 | |||
acbfef0870 | |||
d4db51f278 | |||
160402e1d0 | |||
fb48f66370 | |||
15b918eb6a | |||
27cbb7351b | |||
c787a08d2f |
|
@ -26,6 +26,7 @@ Checks: >
|
||||||
-google-default-arguments,
|
-google-default-arguments,
|
||||||
-google-readability-casting,
|
-google-readability-casting,
|
||||||
-hicpp-deprecated-headers,
|
-hicpp-deprecated-headers,
|
||||||
|
-hicpp-no-array-decay,
|
||||||
-misc-const-correctness,
|
-misc-const-correctness,
|
||||||
-misc-include-cleaner,
|
-misc-include-cleaner,
|
||||||
-misc-non-private-member-variables-in-classes,
|
-misc-non-private-member-variables-in-classes,
|
||||||
|
|
|
@ -1,79 +1,79 @@
|
||||||
issue: https://github.com/goldendict/goldendict/issues/1441
|
issue: https://github.com/goldendict/goldendict/issues/1441
|
||||||
|
|
||||||
http://tango.freedesktop.org/Tango_Desktop_Project GPLv3
|
http://tango.freedesktop.org/Tango_Desktop_Project GPLv3
|
||||||
list:
|
list:
|
||||||
internet.svg
|
internet.svg
|
||||||
home.svg
|
home.svg
|
||||||
configure.svg
|
configure.svg
|
||||||
fileopen.svg
|
fileopen.svg
|
||||||
addtab.svg
|
addtab.svg
|
||||||
wizard.svg
|
wizard.svg
|
||||||
fulltext
|
fulltext
|
||||||
text2speech
|
text2speech
|
||||||
reload
|
reload
|
||||||
icons/print.svg
|
icons/print.svg
|
||||||
icons/programs.svg
|
icons/programs.svg
|
||||||
error
|
error
|
||||||
star.svg
|
star.svg
|
||||||
star_blue.svg
|
star_blue.svg
|
||||||
network.svg
|
network.svg
|
||||||
hotkeys
|
hotkeys
|
||||||
previous
|
previous
|
||||||
next
|
next
|
||||||
advanced
|
advanced
|
||||||
windows-list
|
windows-list
|
||||||
filesave
|
filesave
|
||||||
playsound_color
|
playsound_color
|
||||||
interface
|
interface
|
||||||
webdict
|
webdict
|
||||||
transliteration
|
transliteration
|
||||||
closetab
|
closetab
|
||||||
folder
|
folder
|
||||||
reload
|
reload
|
||||||
menu.svg
|
menu.svg
|
||||||
|
|
||||||
https://packages.debian.org/bullseye/gnome-icon-theme GPLv3
|
https://packages.debian.org/bullseye/gnome-icon-theme GPLv3
|
||||||
lists:
|
lists:
|
||||||
clear
|
clear
|
||||||
|
|
||||||
https://commons.wikimedia.org/wiki/File:Accessories-dictionary.svg
|
https://commons.wikimedia.org/wiki/File:Accessories-dictionary.svg
|
||||||
lists:
|
lists:
|
||||||
icon32_sdict.svg
|
icon32_sdict.svg
|
||||||
|
|
||||||
|
|
||||||
https://freesvg.org/pushpin-vector-image public domain
|
https://freesvg.org/pushpin-vector-image public domain
|
||||||
lists:
|
lists:
|
||||||
pushbin
|
pushbin
|
||||||
|
|
||||||
|
|
||||||
https://commons.wikimedia.org/wiki/File:Arrow_bottom_svg.svg license:public domain
|
https://commons.wikimedia.org/wiki/File:Arrow_bottom_svg.svg license:public domain
|
||||||
lists:
|
lists:
|
||||||
1downarrow
|
1downarrow
|
||||||
|
|
||||||
|
|
||||||
these two icons from sertoli @ https://forum.freemdict.com/u/sertoli/summary
|
these two icons from sertoli @ https://forum.freemdict.com/u/sertoli/summary
|
||||||
playsound.png
|
playsound.png
|
||||||
playsound_full.png
|
playsound_full.png
|
||||||
|
|
||||||
|
|
||||||
LGPL
|
LGPL
|
||||||
icon32_zoombase.png https://icons.iconarchive.com/icons/oxygen-icons.org/oxygen/128/Actions-page-zoom-icon.png
|
icon32_zoombase.png https://icons.iconarchive.com/icons/oxygen-icons.org/oxygen/128/Actions-page-zoom-icon.png
|
||||||
icon32_zoomout.png https://icons.iconarchive.com/icons/oxygen-icons.org/oxygen/128/Actions-zoom-out-icon.png
|
icon32_zoomout.png https://icons.iconarchive.com/icons/oxygen-icons.org/oxygen/128/Actions-zoom-out-icon.png
|
||||||
icon32_zoomin.png https://icons.iconarchive.com/icons/oxygen-icons.org/oxygen/128/Actions-zoom-in-icon.png
|
icon32_zoomin.png https://icons.iconarchive.com/icons/oxygen-icons.org/oxygen/128/Actions-zoom-in-icon.png
|
||||||
reload.png https://iconarchive.com/show/oxygen-icons-by-oxygen-icons.org/Actions-edit-redo-icon.html
|
reload.png https://iconarchive.com/show/oxygen-icons-by-oxygen-icons.org/Actions-edit-redo-icon.html
|
||||||
advanced.png https://icons.iconarchive.com/icons/oxygen-icons.org/oxygen/128/Actions-system-run-icon.png
|
advanced.png https://icons.iconarchive.com/icons/oxygen-icons.org/oxygen/128/Actions-system-run-icon.png
|
||||||
sources.png https://icons.iconarchive.com/icons/oxygen-icons.org/oxygen/128/Apps-plasma-icon.png
|
sources.png https://icons.iconarchive.com/icons/oxygen-icons.org/oxygen/128/Apps-plasma-icon.png
|
||||||
|
|
||||||
book.svg https://github.com/johnfactotum/foliate
|
book.svg https://github.com/johnfactotum/foliate
|
||||||
|
|
||||||
|
|
||||||
lingualibre.svg https://en.m.wikipedia.org/wiki/File:Lingualibre-logo-no-text.svg
|
lingualibre.svg https://en.m.wikipedia.org/wiki/File:Lingualibre-logo-no-text.svg
|
||||||
|
|
||||||
|
|
||||||
Apache License Version 2.0
|
Apache License Version 2.0
|
||||||
1downarrow.svg
|
1downarrow.svg
|
||||||
system-search.svg
|
system-search.svg
|
||||||
Modified from https://github.com/google/material-design-icons
|
Modified from https://github.com/google/material-design-icons
|
||||||
|
|
||||||
add-anki-icon.svg MIT license
|
add-anki-icon.svg MIT license
|
||||||
https://www.svgrepo.com/svg/435992/add-card
|
https://www.svgrepo.com/svg/435992/add-card
|
3
src/audio/README.md
Normal file
3
src/audio/README.md
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
Code to support GD's internal/external audio players.
|
||||||
|
|
||||||
|
Only `audioplayerinterface.hh` is supposed to be used outside this folder.
|
|
@ -197,13 +197,11 @@ Preferences::Preferences():
|
||||||
hideSingleTab( false ),
|
hideSingleTab( false ),
|
||||||
mruTabOrder( false ),
|
mruTabOrder( false ),
|
||||||
hideMenubar( false ),
|
hideMenubar( false ),
|
||||||
enableTrayIcon( true ),
|
|
||||||
startToTray( false ),
|
|
||||||
closeToTray( true ),
|
|
||||||
autoStart( false ),
|
autoStart( false ),
|
||||||
doubleClickTranslates( true ),
|
doubleClickTranslates( true ),
|
||||||
selectWordBySingleClick( false ),
|
selectWordBySingleClick( false ),
|
||||||
autoScrollToTargetArticle( true ),
|
autoScrollToTargetArticle( true ),
|
||||||
|
targetArticleAtFirst( false ),
|
||||||
escKeyHidesMainWindow( false ),
|
escKeyHidesMainWindow( false ),
|
||||||
alwaysOnTop( false ),
|
alwaysOnTop( false ),
|
||||||
searchInDock( false ),
|
searchInDock( false ),
|
||||||
|
@ -903,10 +901,11 @@ Class load()
|
||||||
c.preferences.hideSingleTab = ( preferences.namedItem( "hideSingleTab" ).toElement().text() == "1" );
|
c.preferences.hideSingleTab = ( preferences.namedItem( "hideSingleTab" ).toElement().text() == "1" );
|
||||||
c.preferences.mruTabOrder = ( preferences.namedItem( "mruTabOrder" ).toElement().text() == "1" );
|
c.preferences.mruTabOrder = ( preferences.namedItem( "mruTabOrder" ).toElement().text() == "1" );
|
||||||
c.preferences.hideMenubar = ( preferences.namedItem( "hideMenubar" ).toElement().text() == "1" );
|
c.preferences.hideMenubar = ( preferences.namedItem( "hideMenubar" ).toElement().text() == "1" );
|
||||||
|
#ifndef Q_OS_MACOS // // macOS uses the dock menu instead of the tray icon
|
||||||
c.preferences.enableTrayIcon = ( preferences.namedItem( "enableTrayIcon" ).toElement().text() == "1" );
|
c.preferences.enableTrayIcon = ( preferences.namedItem( "enableTrayIcon" ).toElement().text() == "1" );
|
||||||
c.preferences.startToTray = ( preferences.namedItem( "startToTray" ).toElement().text() == "1" );
|
c.preferences.startToTray = ( preferences.namedItem( "startToTray" ).toElement().text() == "1" );
|
||||||
c.preferences.closeToTray = ( preferences.namedItem( "closeToTray" ).toElement().text() == "1" );
|
c.preferences.closeToTray = ( preferences.namedItem( "closeToTray" ).toElement().text() == "1" );
|
||||||
|
#endif
|
||||||
c.preferences.autoStart = ( preferences.namedItem( "autoStart" ).toElement().text() == "1" );
|
c.preferences.autoStart = ( preferences.namedItem( "autoStart" ).toElement().text() == "1" );
|
||||||
c.preferences.alwaysOnTop = ( preferences.namedItem( "alwaysOnTop" ).toElement().text() == "1" );
|
c.preferences.alwaysOnTop = ( preferences.namedItem( "alwaysOnTop" ).toElement().text() == "1" );
|
||||||
c.preferences.searchInDock = ( preferences.namedItem( "searchInDock" ).toElement().text() == "1" );
|
c.preferences.searchInDock = ( preferences.namedItem( "searchInDock" ).toElement().text() == "1" );
|
||||||
|
@ -931,6 +930,11 @@ Class load()
|
||||||
( preferences.namedItem( "autoScrollToTargetArticle" ).toElement().text() == "1" );
|
( preferences.namedItem( "autoScrollToTargetArticle" ).toElement().text() == "1" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( !preferences.namedItem( "targetArticleAtFirst" ).isNull() ) {
|
||||||
|
c.preferences.targetArticleAtFirst =
|
||||||
|
( preferences.namedItem( "targetArticleAtFirst" ).toElement().text() == "1" );
|
||||||
|
}
|
||||||
|
|
||||||
if ( !preferences.namedItem( "escKeyHidesMainWindow" ).isNull() ) {
|
if ( !preferences.namedItem( "escKeyHidesMainWindow" ).isNull() ) {
|
||||||
c.preferences.escKeyHidesMainWindow =
|
c.preferences.escKeyHidesMainWindow =
|
||||||
( preferences.namedItem( "escKeyHidesMainWindow" ).toElement().text() == "1" );
|
( preferences.namedItem( "escKeyHidesMainWindow" ).toElement().text() == "1" );
|
||||||
|
@ -1868,6 +1872,10 @@ void save( Class const & c )
|
||||||
opt.appendChild( dd.createTextNode( c.preferences.autoScrollToTargetArticle ? "1" : "0" ) );
|
opt.appendChild( dd.createTextNode( c.preferences.autoScrollToTargetArticle ? "1" : "0" ) );
|
||||||
preferences.appendChild( opt );
|
preferences.appendChild( opt );
|
||||||
|
|
||||||
|
opt = dd.createElement( "targetArticleAtFirst" );
|
||||||
|
opt.appendChild( dd.createTextNode( c.preferences.targetArticleAtFirst ? "1" : "0" ) );
|
||||||
|
preferences.appendChild( opt );
|
||||||
|
|
||||||
opt = dd.createElement( "escKeyHidesMainWindow" );
|
opt = dd.createElement( "escKeyHidesMainWindow" );
|
||||||
opt.appendChild( dd.createTextNode( c.preferences.escKeyHidesMainWindow ? "1" : "0" ) );
|
opt.appendChild( dd.createTextNode( c.preferences.escKeyHidesMainWindow ? "1" : "0" ) );
|
||||||
preferences.appendChild( opt );
|
preferences.appendChild( opt );
|
||||||
|
|
|
@ -341,13 +341,22 @@ struct Preferences
|
||||||
bool hideSingleTab;
|
bool hideSingleTab;
|
||||||
bool mruTabOrder;
|
bool mruTabOrder;
|
||||||
bool hideMenubar;
|
bool hideMenubar;
|
||||||
bool enableTrayIcon;
|
|
||||||
bool startToTray;
|
#ifdef Q_OS_MACOS // macOS uses the dock menu instead of the tray icon
|
||||||
bool closeToTray;
|
bool closeToTray = false;
|
||||||
|
bool enableTrayIcon = false;
|
||||||
|
bool startToTray = false;
|
||||||
|
#else
|
||||||
|
bool enableTrayIcon = true;
|
||||||
|
bool closeToTray = true;
|
||||||
|
bool startToTray = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
bool autoStart;
|
bool autoStart;
|
||||||
bool doubleClickTranslates;
|
bool doubleClickTranslates;
|
||||||
bool selectWordBySingleClick;
|
bool selectWordBySingleClick;
|
||||||
bool autoScrollToTargetArticle;
|
bool autoScrollToTargetArticle;
|
||||||
|
bool targetArticleAtFirst;
|
||||||
bool escKeyHidesMainWindow;
|
bool escKeyHidesMainWindow;
|
||||||
bool alwaysOnTop;
|
bool alwaysOnTop;
|
||||||
|
|
||||||
|
|
|
@ -264,14 +264,12 @@ bool MdictParser::parseCompressedBlock( qint64 compressedBlockSize,
|
||||||
|
|
||||||
case 0x02000000:
|
case 0x02000000:
|
||||||
// zlib compression
|
// zlib compression
|
||||||
decompressedBlock = zlibDecompress( buf, size );
|
decompressedBlock = zlibDecompress( buf, size, checksum );
|
||||||
|
if ( decompressedBlock.isEmpty() ) {
|
||||||
if ( !checkAdler32( decompressedBlock.constData(), decompressedBlock.size(), checksum ) ) {
|
gdWarning( "MDict: parseCompressedBlock: zlib: failed to decompress or checksum does not match" );
|
||||||
gdWarning( "MDict: parseCompressedBlock: zlib: checksum does not match" );
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
gdWarning( "MDict: parseCompressedBlock: unknown type" );
|
gdWarning( "MDict: parseCompressedBlock: unknown type" );
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -3,20 +3,21 @@
|
||||||
#include <bzlib.h>
|
#include <bzlib.h>
|
||||||
#include <lzma.h>
|
#include <lzma.h>
|
||||||
|
|
||||||
#define CHUNK_SIZE 2048
|
using std::string;
|
||||||
|
|
||||||
QByteArray zlibDecompress( const char * bufptr, unsigned length )
|
static constexpr qsizetype CHUNK_SIZE = 2048;
|
||||||
|
|
||||||
|
QByteArray zlibDecompress( const char * bufptr, unsigned length, uLong adler32_checksum )
|
||||||
{
|
{
|
||||||
z_stream zs;
|
z_stream zs{};
|
||||||
char buf[ CHUNK_SIZE ];
|
|
||||||
QByteArray str;
|
QByteArray str;
|
||||||
int res;
|
int res = Z_OK;
|
||||||
memset( &zs, 0, sizeof( zs ) );
|
|
||||||
zs.next_in = (Bytef *)bufptr;
|
zs.next_in = (Bytef *)bufptr;
|
||||||
zs.avail_in = length;
|
zs.avail_in = length;
|
||||||
res = inflateInit( &zs );
|
res = inflateInit( &zs );
|
||||||
|
|
||||||
if ( res == Z_OK ) {
|
if ( res == Z_OK ) {
|
||||||
|
char buf[ CHUNK_SIZE ];
|
||||||
while ( res != Z_STREAM_END ) {
|
while ( res != Z_STREAM_END ) {
|
||||||
zs.next_out = (Bytef *)buf;
|
zs.next_out = (Bytef *)buf;
|
||||||
zs.avail_out = CHUNK_SIZE;
|
zs.avail_out = CHUNK_SIZE;
|
||||||
|
@ -27,9 +28,7 @@ QByteArray zlibDecompress( const char * bufptr, unsigned length )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ( inflateEnd( &zs ) != Z_OK || res != Z_STREAM_END || ( adler32_checksum != 0 && zs.adler != adler32_checksum ) ) {
|
||||||
inflateEnd( &zs );
|
|
||||||
if ( res != Z_STREAM_END ) {
|
|
||||||
str.clear();
|
str.clear();
|
||||||
}
|
}
|
||||||
return str;
|
return str;
|
||||||
|
@ -37,7 +36,7 @@ QByteArray zlibDecompress( const char * bufptr, unsigned length )
|
||||||
|
|
||||||
string decompressZlib( const char * bufptr, unsigned length )
|
string decompressZlib( const char * bufptr, unsigned length )
|
||||||
{
|
{
|
||||||
QByteArray b = zlibDecompress( bufptr, length );
|
QByteArray b = zlibDecompress( bufptr, length, 0 );
|
||||||
return string( b.constData(), b.size() );
|
return string( b.constData(), b.size() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,12 +3,11 @@
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
using std::string;
|
/// @param adler32_checksum 0 to skip checksum
|
||||||
|
QByteArray zlibDecompress( const char * bufptr, unsigned length, unsigned long adler32_checksum );
|
||||||
|
|
||||||
QByteArray zlibDecompress( const char * bufptr, unsigned length );
|
std::string decompressZlib( const char * bufptr, unsigned length );
|
||||||
|
|
||||||
string decompressZlib( const char * bufptr, unsigned length );
|
std::string decompressBzip2( const char * bufptr, unsigned length );
|
||||||
|
|
||||||
string decompressBzip2( const char * bufptr, unsigned length );
|
std::string decompressLzma2( const char * bufptr, unsigned length, bool raw_decoder = false );
|
||||||
|
|
||||||
string decompressLzma2( const char * bufptr, unsigned length, bool raw_decoder = false );
|
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
#include <QWebEngineView>
|
#include <QWebEngineView>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include "article_netmgr.hh"
|
#include "article_netmgr.hh"
|
||||||
#include "audioplayerinterface.hh"
|
#include "audio/audioplayerinterface.hh"
|
||||||
#include "instances.hh"
|
#include "instances.hh"
|
||||||
#include "groupcombobox.hh"
|
#include "groupcombobox.hh"
|
||||||
#include "globalbroadcaster.hh"
|
#include "globalbroadcaster.hh"
|
||||||
|
|
|
@ -401,15 +401,18 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
|
||||||
connect( wordsZoomOut, &QAction::triggered, this, &MainWindow::doWordsZoomOut );
|
connect( wordsZoomOut, &QAction::triggered, this, &MainWindow::doWordsZoomOut );
|
||||||
connect( wordsZoomBase, &QAction::triggered, this, &MainWindow::doWordsZoomBase );
|
connect( wordsZoomBase, &QAction::triggered, this, &MainWindow::doWordsZoomBase );
|
||||||
|
|
||||||
// tray icon
|
// tray icon
|
||||||
connect( trayIconMenu.addAction( tr( "Show &Main Window" ) ),
|
#ifndef Q_OS_MACOS // macOS uses the dock menu instead of the tray icon
|
||||||
&QAction::triggered,
|
connect( trayIconMenu.addAction( tr( "Show &Main Window" ) ), &QAction::triggered, this, [ this ] {
|
||||||
this,
|
this->toggleMainWindow( true );
|
||||||
&MainWindow::showMainWindow );
|
} );
|
||||||
|
#endif
|
||||||
trayIconMenu.addAction( enableScanningAction );
|
trayIconMenu.addAction( enableScanningAction );
|
||||||
|
|
||||||
|
#ifndef Q_OS_MACOS // macOS uses the dock menu instead of the tray icon
|
||||||
trayIconMenu.addSeparator();
|
trayIconMenu.addSeparator();
|
||||||
connect( trayIconMenu.addAction( tr( "&Quit" ) ), &QAction::triggered, this, &MainWindow::quitApp );
|
connect( trayIconMenu.addAction( tr( "&Quit" ) ), &QAction::triggered, this, &MainWindow::quitApp );
|
||||||
|
#endif
|
||||||
|
|
||||||
addGlobalAction( &escAction, [ this ]() {
|
addGlobalAction( &escAction, [ this ]() {
|
||||||
handleEsc();
|
handleEsc();
|
||||||
|
@ -1421,6 +1424,11 @@ void MainWindow::updateAppearances( QString const & addonStyle,
|
||||||
|
|
||||||
void MainWindow::trayIconUpdateOrInit()
|
void MainWindow::trayIconUpdateOrInit()
|
||||||
{
|
{
|
||||||
|
#ifdef Q_OS_MACOS
|
||||||
|
trayIconMenu.setAsDockMenu();
|
||||||
|
ui.actionCloseToTray->setVisible( false );
|
||||||
|
#else
|
||||||
|
|
||||||
if ( !cfg.preferences.enableTrayIcon ) {
|
if ( !cfg.preferences.enableTrayIcon ) {
|
||||||
if ( trayIcon ) {
|
if ( trayIcon ) {
|
||||||
delete trayIcon;
|
delete trayIcon;
|
||||||
|
@ -1444,6 +1452,7 @@ void MainWindow::trayIconUpdateOrInit()
|
||||||
// The 'Close to tray' action is associated with the tray icon, so we hide
|
// The 'Close to tray' action is associated with the tray icon, so we hide
|
||||||
// or show it here.
|
// or show it here.
|
||||||
ui.actionCloseToTray->setVisible( cfg.preferences.enableTrayIcon );
|
ui.actionCloseToTray->setVisible( cfg.preferences.enableTrayIcon );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::wheelEvent( QWheelEvent * ev )
|
void MainWindow::wheelEvent( QWheelEvent * ev )
|
||||||
|
@ -2532,7 +2541,7 @@ void MainWindow::handleEsc()
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( cfg.preferences.escKeyHidesMainWindow ) {
|
if ( cfg.preferences.escKeyHidesMainWindow ) {
|
||||||
toggleMainWindow();
|
toggleMainWindow( false );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
focusTranslateLine();
|
focusTranslateLine();
|
||||||
|
@ -2873,7 +2882,7 @@ void MainWindow::showTranslationForDicts( QString const & inWord,
|
||||||
ignoreDiacritics );
|
ignoreDiacritics );
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::toggleMainWindow( bool onlyShow )
|
void MainWindow::toggleMainWindow( bool ensureShow )
|
||||||
{
|
{
|
||||||
bool shown = false;
|
bool shown = false;
|
||||||
|
|
||||||
|
@ -2906,7 +2915,7 @@ void MainWindow::toggleMainWindow( bool onlyShow )
|
||||||
}
|
}
|
||||||
shown = true;
|
shown = true;
|
||||||
}
|
}
|
||||||
else if ( !onlyShow ) {
|
else if ( !ensureShow ) {
|
||||||
|
|
||||||
// On Windows and Linux, a hidden window won't show a task bar icon
|
// On Windows and Linux, a hidden window won't show a task bar icon
|
||||||
// When trayicon is enabled, the duplication is unneeded
|
// When trayicon is enabled, the duplication is unneeded
|
||||||
|
@ -2990,7 +2999,7 @@ void MainWindow::installHotKeys()
|
||||||
void MainWindow::hotKeyActivated( int hk )
|
void MainWindow::hotKeyActivated( int hk )
|
||||||
{
|
{
|
||||||
if ( !hk ) {
|
if ( !hk ) {
|
||||||
toggleMainWindow();
|
toggleMainWindow( false );
|
||||||
}
|
}
|
||||||
else if ( scanPopup ) {
|
else if ( scanPopup ) {
|
||||||
#ifdef HAVE_X11
|
#ifdef HAVE_X11
|
||||||
|
@ -3075,7 +3084,7 @@ void MainWindow::trayIconActivated( QSystemTrayIcon::ActivationReason r )
|
||||||
switch ( r ) {
|
switch ( r ) {
|
||||||
case QSystemTrayIcon::Trigger:
|
case QSystemTrayIcon::Trigger:
|
||||||
// Left click toggles the visibility of main window
|
// Left click toggles the visibility of main window
|
||||||
toggleMainWindow();
|
toggleMainWindow( false );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case QSystemTrayIcon::MiddleClick:
|
case QSystemTrayIcon::MiddleClick:
|
||||||
|
@ -3088,10 +3097,6 @@ void MainWindow::trayIconActivated( QSystemTrayIcon::ActivationReason r )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::showMainWindow()
|
|
||||||
{
|
|
||||||
toggleMainWindow( true );
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::visitHomepage()
|
void MainWindow::visitHomepage()
|
||||||
{
|
{
|
||||||
|
@ -3730,13 +3735,6 @@ void MainWindow::wordReceived( const QString & word )
|
||||||
respondToTranslationRequest( word, false );
|
respondToTranslationRequest( word, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::headwordReceived( const QString & word, const QString & ID )
|
|
||||||
{
|
|
||||||
toggleMainWindow( true );
|
|
||||||
setInputLineText( word, WildcardPolicy::EscapeWildcards, NoPopupChange );
|
|
||||||
respondToTranslationRequest( word, false, ArticleView::scrollToFromDictionaryId( ID ), false );
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::updateFavoritesMenu()
|
void MainWindow::updateFavoritesMenu()
|
||||||
{
|
{
|
||||||
if ( ui.favoritesPane->isVisible() ) {
|
if ( ui.favoritesPane->isVisible() ) {
|
||||||
|
@ -4141,7 +4139,13 @@ void MainWindow::showDictionaryHeadwords( Dictionary::Class * dict )
|
||||||
headwordsDlg = new DictHeadwords( this, cfg, dict );
|
headwordsDlg = new DictHeadwords( this, cfg, dict );
|
||||||
addGlobalActionsToDialog( headwordsDlg );
|
addGlobalActionsToDialog( headwordsDlg );
|
||||||
addGroupComboBoxActionsToDialog( headwordsDlg, groupList );
|
addGroupComboBoxActionsToDialog( headwordsDlg, groupList );
|
||||||
connect( headwordsDlg, &DictHeadwords::headwordSelected, this, &MainWindow::headwordReceived );
|
connect( headwordsDlg,
|
||||||
|
&DictHeadwords::headwordSelected,
|
||||||
|
this,
|
||||||
|
[ this ]( QString const & headword, QString const & dictID ) {
|
||||||
|
setInputLineText( headword, WildcardPolicy::EscapeWildcards, NoPopupChange );
|
||||||
|
respondToTranslationRequest( headword, false, ArticleView::scrollToFromDictionaryId( dictID ), false );
|
||||||
|
} );
|
||||||
connect( headwordsDlg,
|
connect( headwordsDlg,
|
||||||
&DictHeadwords::closeDialog,
|
&DictHeadwords::closeDialog,
|
||||||
this,
|
this,
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
#include "config.hh"
|
#include "config.hh"
|
||||||
#include "dict/dictionary.hh"
|
#include "dict/dictionary.hh"
|
||||||
#include "article_netmgr.hh"
|
#include "article_netmgr.hh"
|
||||||
#include "audioplayerfactory.hh"
|
#include "audio/audioplayerfactory.hh"
|
||||||
#include "instances.hh"
|
#include "instances.hh"
|
||||||
#include "article_maker.hh"
|
#include "article_maker.hh"
|
||||||
#include "scanpopup.hh"
|
#include "scanpopup.hh"
|
||||||
|
@ -67,7 +67,6 @@ public slots:
|
||||||
void messageFromAnotherInstanceReceived( QString const & );
|
void messageFromAnotherInstanceReceived( QString const & );
|
||||||
void showStatusBarMessage( QString const &, int, QPixmap const & );
|
void showStatusBarMessage( QString const &, int, QPixmap const & );
|
||||||
void wordReceived( QString const & );
|
void wordReceived( QString const & );
|
||||||
void headwordReceived( QString const &, QString const & );
|
|
||||||
void headwordFromFavorites( QString const &, QString const & );
|
void headwordFromFavorites( QString const &, QString const & );
|
||||||
void quitApp();
|
void quitApp();
|
||||||
|
|
||||||
|
@ -226,9 +225,8 @@ private:
|
||||||
/// group, or to all dictionaries if there are no groups.
|
/// group, or to all dictionaries if there are no groups.
|
||||||
vector< sptr< Dictionary::Class > > const & getActiveDicts();
|
vector< sptr< Dictionary::Class > > const & getActiveDicts();
|
||||||
|
|
||||||
/// Brings the main window to front if it's not currently, or hides it
|
/// @param ensureShow only ensure the window will be shown and no "toggling"
|
||||||
/// otherwise. The hiding part is omitted if onlyShow is true.
|
void toggleMainWindow( bool ensureShow );
|
||||||
void toggleMainWindow( bool onlyShow = false );
|
|
||||||
|
|
||||||
/// Creates hotkeyWrapper and hooks the currently set keys for it
|
/// Creates hotkeyWrapper and hooks the currently set keys for it
|
||||||
void installHotKeys();
|
void installHotKeys();
|
||||||
|
@ -398,8 +396,6 @@ private slots:
|
||||||
|
|
||||||
void setAutostart( bool );
|
void setAutostart( bool );
|
||||||
|
|
||||||
void showMainWindow();
|
|
||||||
|
|
||||||
void visitHomepage();
|
void visitHomepage();
|
||||||
void visitForum();
|
void visitForum();
|
||||||
void openConfigFolder();
|
void openConfigFolder();
|
||||||
|
|
|
@ -174,12 +174,18 @@ Preferences::Preferences( QWidget * parent, Config::Class & cfg_ ):
|
||||||
ui.hideSingleTab->setChecked( p.hideSingleTab );
|
ui.hideSingleTab->setChecked( p.hideSingleTab );
|
||||||
ui.mruTabOrder->setChecked( p.mruTabOrder );
|
ui.mruTabOrder->setChecked( p.mruTabOrder );
|
||||||
ui.enableTrayIcon->setChecked( p.enableTrayIcon );
|
ui.enableTrayIcon->setChecked( p.enableTrayIcon );
|
||||||
|
|
||||||
|
#ifdef Q_OS_MACOS // macOS uses the dock menu instead of the tray icon
|
||||||
|
ui.enableTrayIcon->hide();
|
||||||
|
#endif
|
||||||
|
|
||||||
ui.startToTray->setChecked( p.startToTray );
|
ui.startToTray->setChecked( p.startToTray );
|
||||||
ui.closeToTray->setChecked( p.closeToTray );
|
ui.closeToTray->setChecked( p.closeToTray );
|
||||||
ui.cbAutostart->setChecked( p.autoStart );
|
ui.cbAutostart->setChecked( p.autoStart );
|
||||||
ui.doubleClickTranslates->setChecked( p.doubleClickTranslates );
|
ui.doubleClickTranslates->setChecked( p.doubleClickTranslates );
|
||||||
ui.selectBySingleClick->setChecked( p.selectWordBySingleClick );
|
ui.selectBySingleClick->setChecked( p.selectWordBySingleClick );
|
||||||
ui.autoScrollToTargetArticle->setChecked( p.autoScrollToTargetArticle );
|
ui.autoScrollToTargetArticle->setChecked( p.autoScrollToTargetArticle );
|
||||||
|
ui.targetArticleAtFirst->setChecked( p.targetArticleAtFirst );
|
||||||
ui.escKeyHidesMainWindow->setChecked( p.escKeyHidesMainWindow );
|
ui.escKeyHidesMainWindow->setChecked( p.escKeyHidesMainWindow );
|
||||||
|
|
||||||
ui.darkMode->addItem( tr( "On" ), QVariant::fromValue( Config::Dark::On ) );
|
ui.darkMode->addItem( tr( "On" ), QVariant::fromValue( Config::Dark::On ) );
|
||||||
|
@ -436,6 +442,7 @@ Config::Preferences Preferences::getPreferences()
|
||||||
p.doubleClickTranslates = ui.doubleClickTranslates->isChecked();
|
p.doubleClickTranslates = ui.doubleClickTranslates->isChecked();
|
||||||
p.selectWordBySingleClick = ui.selectBySingleClick->isChecked();
|
p.selectWordBySingleClick = ui.selectBySingleClick->isChecked();
|
||||||
p.autoScrollToTargetArticle = ui.autoScrollToTargetArticle->isChecked();
|
p.autoScrollToTargetArticle = ui.autoScrollToTargetArticle->isChecked();
|
||||||
|
p.targetArticleAtFirst = ui.targetArticleAtFirst->isChecked();
|
||||||
p.escKeyHidesMainWindow = ui.escKeyHidesMainWindow->isChecked();
|
p.escKeyHidesMainWindow = ui.escKeyHidesMainWindow->isChecked();
|
||||||
|
|
||||||
p.darkMode = ui.darkMode->currentData().value< Config::Dark >();
|
p.darkMode = ui.darkMode->currentData().value< Config::Dark >();
|
||||||
|
|
|
@ -169,6 +169,16 @@ however, the article from the topmost dictionary is shown.</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="4" column="1">
|
||||||
|
<widget class="QCheckBox" name="targetArticleAtFirst">
|
||||||
|
<property name="text">
|
||||||
|
<string>Place the target article at the first place.</string>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QGroupBox" name="enableTrayIcon">
|
<widget class="QGroupBox" name="enableTrayIcon">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
|
|
Loading…
Reference in a new issue