mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-28 12:04:08 +00:00
Merge branch 'staged' into dev
This commit is contained in:
commit
ffca14556c
1
.github/workflows/ubuntu-6.2.yml
vendored
1
.github/workflows/ubuntu-6.2.yml
vendored
|
@ -54,6 +54,7 @@ jobs:
|
||||||
sudo apt-get install libxtst-dev liblzo2-dev libbz2-dev
|
sudo apt-get install libxtst-dev liblzo2-dev libbz2-dev
|
||||||
sudo apt-get install libao-dev libavutil-dev libavformat-dev libtiff5-dev libeb16-dev
|
sudo apt-get install libao-dev libavutil-dev libavformat-dev libtiff5-dev libeb16-dev
|
||||||
sudo apt-get install doxygen libzstd-dev libxkbcommon-dev libgstreamer-plugins-base1.0-0 libgstreamer-gl1.0-0
|
sudo apt-get install doxygen libzstd-dev libxkbcommon-dev libgstreamer-plugins-base1.0-0 libgstreamer-gl1.0-0
|
||||||
|
sudo apt install libfuse2
|
||||||
sudo ln -sf /usr/bin/x86_64-linux-gnu-ld.gold /usr/bin/ld
|
sudo ln -sf /usr/bin/x86_64-linux-gnu-ld.gold /usr/bin/ld
|
||||||
|
|
||||||
#build opencc
|
#build opencc
|
||||||
|
|
|
@ -390,7 +390,7 @@ div.xdxf
|
||||||
display:inline;
|
display:inline;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dsl_article font[color=c_default_color]
|
.dsl_article .c_default_color
|
||||||
{
|
{
|
||||||
color: green;
|
color: green;
|
||||||
}
|
}
|
||||||
|
|
|
@ -396,7 +396,7 @@ div.xdxf
|
||||||
display:inline;
|
display:inline;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dsl_article font[color=c_default_color]
|
.dsl_article .c_default_color
|
||||||
{
|
{
|
||||||
color: green;
|
color: green;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2149,9 +2149,9 @@ void ArticleView::resourceDownloadFinished()
|
||||||
|
|
||||||
if ( resourceDownloadRequests.empty() )
|
if ( resourceDownloadRequests.empty() )
|
||||||
{
|
{
|
||||||
emit statusBarMessage(
|
// emit statusBarMessage(
|
||||||
tr("WARNING: %1").arg(tr("The referenced resource failed to download.")),
|
// tr("WARNING: %1").arg(tr("The referenced resource failed to download.")),
|
||||||
10000, QPixmap(":/icons/error.svg"));
|
// 10000, QPixmap(":/icons/error.svg"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -219,6 +219,7 @@ Preferences::Preferences():
|
||||||
selectWordBySingleClick( false ),
|
selectWordBySingleClick( false ),
|
||||||
autoScrollToTargetArticle( true ),
|
autoScrollToTargetArticle( true ),
|
||||||
escKeyHidesMainWindow( false ),
|
escKeyHidesMainWindow( false ),
|
||||||
|
darkMode( false ),
|
||||||
alwaysOnTop ( false ),
|
alwaysOnTop ( false ),
|
||||||
searchInDock ( false ),
|
searchInDock ( false ),
|
||||||
|
|
||||||
|
@ -869,6 +870,9 @@ Class load()
|
||||||
if ( !preferences.namedItem( "escKeyHidesMainWindow" ).isNull() )
|
if ( !preferences.namedItem( "escKeyHidesMainWindow" ).isNull() )
|
||||||
c.preferences.escKeyHidesMainWindow = ( preferences.namedItem( "escKeyHidesMainWindow" ).toElement().text() == "1" );
|
c.preferences.escKeyHidesMainWindow = ( preferences.namedItem( "escKeyHidesMainWindow" ).toElement().text() == "1" );
|
||||||
|
|
||||||
|
if ( !preferences.namedItem( "darkMode" ).isNull() )
|
||||||
|
c.preferences.darkMode = ( preferences.namedItem( "darkMode" ).toElement().text() == "1" );
|
||||||
|
|
||||||
if ( !preferences.namedItem( "zoomFactor" ).isNull() )
|
if ( !preferences.namedItem( "zoomFactor" ).isNull() )
|
||||||
c.preferences.zoomFactor = preferences.namedItem( "zoomFactor" ).toElement().text().toDouble();
|
c.preferences.zoomFactor = preferences.namedItem( "zoomFactor" ).toElement().text().toDouble();
|
||||||
|
|
||||||
|
@ -1711,6 +1715,10 @@ void save( Class const & c )
|
||||||
opt.appendChild( dd.createTextNode( c.preferences.escKeyHidesMainWindow ? "1":"0" ) );
|
opt.appendChild( dd.createTextNode( c.preferences.escKeyHidesMainWindow ? "1":"0" ) );
|
||||||
preferences.appendChild( opt );
|
preferences.appendChild( opt );
|
||||||
|
|
||||||
|
opt = dd.createElement( "darkMode" );
|
||||||
|
opt.appendChild( dd.createTextNode( c.preferences.darkMode ? "1":"0" ) );
|
||||||
|
preferences.appendChild( opt );
|
||||||
|
|
||||||
opt = dd.createElement( "zoomFactor" );
|
opt = dd.createElement( "zoomFactor" );
|
||||||
opt.appendChild( dd.createTextNode( QString::number( c.preferences.zoomFactor ) ) );
|
opt.appendChild( dd.createTextNode( QString::number( c.preferences.zoomFactor ) ) );
|
||||||
preferences.appendChild( opt );
|
preferences.appendChild( opt );
|
||||||
|
|
|
@ -307,6 +307,7 @@ struct Preferences
|
||||||
bool selectWordBySingleClick;
|
bool selectWordBySingleClick;
|
||||||
bool autoScrollToTargetArticle;
|
bool autoScrollToTargetArticle;
|
||||||
bool escKeyHidesMainWindow;
|
bool escKeyHidesMainWindow;
|
||||||
|
bool darkMode;
|
||||||
bool alwaysOnTop;
|
bool alwaysOnTop;
|
||||||
|
|
||||||
/// An old UI mode when tranlateLine and wordList
|
/// An old UI mode when tranlateLine and wordList
|
||||||
|
|
14
dsl.cc
14
dsl.cc
|
@ -809,9 +809,17 @@ string DslDictionary::nodeToHtml( ArticleDom::Node const & node )
|
||||||
}
|
}
|
||||||
else if( node.tagName == U"c" )
|
else if( node.tagName == U"c" )
|
||||||
{
|
{
|
||||||
result += "<font color=\"" + ( node.tagAttrs.size() ?
|
if( node.tagAttrs.empty() )
|
||||||
Html::escape( Utf8::encode( node.tagAttrs ) ) : string( "c_default_color" ) )
|
{
|
||||||
+ "\">" + processNodeChildren( node ) + "</font>";
|
result += "<span class=\"c_default_color\">"
|
||||||
|
+ processNodeChildren( node ) + "</span>";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result += "<font color=\""
|
||||||
|
+ Html::escape( Utf8::encode( node.tagAttrs ) ) + "\">"
|
||||||
|
+ processNodeChildren( node ) + "</font>";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if( node.tagName == U"*" )
|
else if( node.tagName == U"*" )
|
||||||
{
|
{
|
||||||
|
|
|
@ -186,7 +186,7 @@ bool DecoderContext::openCodec( QString & errorString )
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
avformatOpened_ = true;
|
avformatOpened_ = true;
|
||||||
|
|
||||||
ret = avformat_open_input( &formatContext_, "_STREAM_", NULL, NULL );
|
ret = avformat_open_input( &formatContext_, NULL, NULL, NULL );
|
||||||
if ( ret < 0 )
|
if ( ret < 0 )
|
||||||
{
|
{
|
||||||
errorString = QObject::tr( "avformat_open_input() failed: %1." ).arg( avErrorString( ret ) );
|
errorString = QObject::tr( "avformat_open_input() failed: %1." ).arg( avErrorString( ret ) );
|
||||||
|
|
|
@ -834,7 +834,7 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
|
||||||
|
|
||||||
translateLine->setFocus();
|
translateLine->setFocus();
|
||||||
|
|
||||||
applyQtStyleSheet( cfg.preferences.displayStyle, cfg.preferences.addonStyle );
|
applyQtStyleSheet( cfg.preferences.displayStyle, cfg.preferences.addonStyle, cfg.preferences.darkMode );
|
||||||
|
|
||||||
makeScanPopup();
|
makeScanPopup();
|
||||||
|
|
||||||
|
@ -1175,8 +1175,45 @@ QPrinter & MainWindow::getPrinter()
|
||||||
return *printer;
|
return *printer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::applyQtStyleSheet( QString const & displayStyle, QString const & addonStyle )
|
void MainWindow::applyQtStyleSheet( QString const & displayStyle, QString const & addonStyle, bool const & darkMode )
|
||||||
{
|
{
|
||||||
|
if( darkMode )
|
||||||
|
{
|
||||||
|
//https://forum.qt.io/topic/101391/windows-10-dark-theme
|
||||||
|
#ifdef Q_OS_WIN32
|
||||||
|
qApp->setStyle( QStyleFactory::create( "Fusion" ) );
|
||||||
|
#endif
|
||||||
|
QPalette darkPalette;
|
||||||
|
QColor darkColor = QColor( 45, 45, 45 );
|
||||||
|
QColor disabledColor = QColor( 127, 127, 127 );
|
||||||
|
darkPalette.setColor( QPalette::Window, darkColor );
|
||||||
|
darkPalette.setColor( QPalette::WindowText, Qt::white );
|
||||||
|
darkPalette.setColor( QPalette::Base, QColor( 18, 18, 18 ) );
|
||||||
|
darkPalette.setColor( QPalette::AlternateBase, darkColor );
|
||||||
|
darkPalette.setColor( QPalette::ToolTipBase, Qt::white );
|
||||||
|
darkPalette.setColor( QPalette::ToolTipText, Qt::white );
|
||||||
|
darkPalette.setColor( QPalette::Text, Qt::white );
|
||||||
|
darkPalette.setColor( QPalette::Disabled, QPalette::Text, disabledColor );
|
||||||
|
darkPalette.setColor( QPalette::Button, darkColor );
|
||||||
|
darkPalette.setColor( QPalette::ButtonText, Qt::white );
|
||||||
|
darkPalette.setColor( QPalette::Disabled, QPalette::ButtonText, disabledColor );
|
||||||
|
darkPalette.setColor( QPalette::BrightText, Qt::red );
|
||||||
|
darkPalette.setColor( QPalette::Link, QColor( 42, 130, 218 ) );
|
||||||
|
|
||||||
|
darkPalette.setColor( QPalette::Highlight, QColor( 42, 130, 218 ) );
|
||||||
|
darkPalette.setColor( QPalette::HighlightedText, Qt::black );
|
||||||
|
darkPalette.setColor( QPalette::Disabled, QPalette::HighlightedText, disabledColor );
|
||||||
|
|
||||||
|
qApp->setPalette( darkPalette );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#ifdef Q_OS_WIN32
|
||||||
|
qApp->setStyle( QStyleFactory::create( "Windows" ) );
|
||||||
|
#endif
|
||||||
|
qApp->setPalette( QPalette() );
|
||||||
|
}
|
||||||
|
|
||||||
QFile builtInCssFile( ":/qt-style.css" );
|
QFile builtInCssFile( ":/qt-style.css" );
|
||||||
builtInCssFile.open( QFile::ReadOnly );
|
builtInCssFile.open( QFile::ReadOnly );
|
||||||
QByteArray css = builtInCssFile.readAll();
|
QByteArray css = builtInCssFile.readAll();
|
||||||
|
@ -1210,6 +1247,10 @@ void MainWindow::applyQtStyleSheet( QString const & displayStyle, QString const
|
||||||
css += addonCss.readAll();
|
css += addonCss.readAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(darkMode){
|
||||||
|
css += "QToolTip { color: #ffffff; background-color: #2a82da; border: 1px solid white; }";
|
||||||
|
}
|
||||||
|
|
||||||
setStyleSheet( css );
|
setStyleSheet( css );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2237,9 +2278,9 @@ void MainWindow::editPreferences()
|
||||||
bool needReload = false;
|
bool needReload = false;
|
||||||
|
|
||||||
// See if we need to reapply stylesheets
|
// See if we need to reapply stylesheets
|
||||||
if ( cfg.preferences.displayStyle != p.displayStyle || cfg.preferences.addonStyle != p.addonStyle )
|
if ( cfg.preferences.displayStyle != p.displayStyle || cfg.preferences.addonStyle != p.addonStyle || cfg.preferences.darkMode != p.darkMode)
|
||||||
{
|
{
|
||||||
applyQtStyleSheet( p.displayStyle, p.addonStyle );
|
applyQtStyleSheet( p.displayStyle, p.addonStyle, p.darkMode );
|
||||||
articleMaker.setDisplayStyle( p.displayStyle, p.addonStyle );
|
articleMaker.setDisplayStyle( p.displayStyle, p.addonStyle );
|
||||||
needReload = true;
|
needReload = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -184,7 +184,7 @@ private:
|
||||||
ResourceSchemeHandler * resourceSchemeHandler;
|
ResourceSchemeHandler * resourceSchemeHandler;
|
||||||
|
|
||||||
/// Applies the qt's stylesheet, given the style's name.
|
/// Applies the qt's stylesheet, given the style's name.
|
||||||
void applyQtStyleSheet( QString const & displayStyle, QString const & addonStyle );
|
void applyQtStyleSheet( QString const & displayStyle, QString const & addonStyle, bool const & darkMode );
|
||||||
|
|
||||||
/// Creates, destroys or otherwise updates tray icon, according to the
|
/// Creates, destroys or otherwise updates tray icon, according to the
|
||||||
/// current configuration and situation.
|
/// current configuration and situation.
|
||||||
|
|
|
@ -181,6 +181,7 @@ Preferences::Preferences( QWidget * parent, Config::Class & cfg_ ):
|
||||||
ui.selectBySingleClick->setChecked( p.selectWordBySingleClick);
|
ui.selectBySingleClick->setChecked( p.selectWordBySingleClick);
|
||||||
ui.autoScrollToTargetArticle->setChecked( p.autoScrollToTargetArticle );
|
ui.autoScrollToTargetArticle->setChecked( p.autoScrollToTargetArticle );
|
||||||
ui.escKeyHidesMainWindow->setChecked( p.escKeyHidesMainWindow );
|
ui.escKeyHidesMainWindow->setChecked( p.escKeyHidesMainWindow );
|
||||||
|
ui.darkMode->setChecked(p.darkMode);
|
||||||
|
|
||||||
ui.enableMainWindowHotkey->setChecked( p.enableMainWindowHotkey );
|
ui.enableMainWindowHotkey->setChecked( p.enableMainWindowHotkey );
|
||||||
ui.mainWindowHotkey->setHotKey( p.mainWindowHotkey );
|
ui.mainWindowHotkey->setHotKey( p.mainWindowHotkey );
|
||||||
|
@ -400,6 +401,7 @@ Config::Preferences Preferences::getPreferences()
|
||||||
p.autoScrollToTargetArticle = ui.autoScrollToTargetArticle->isChecked();
|
p.autoScrollToTargetArticle = ui.autoScrollToTargetArticle->isChecked();
|
||||||
p.escKeyHidesMainWindow = ui.escKeyHidesMainWindow->isChecked();
|
p.escKeyHidesMainWindow = ui.escKeyHidesMainWindow->isChecked();
|
||||||
|
|
||||||
|
p.darkMode = ui.darkMode->isChecked();
|
||||||
p.enableMainWindowHotkey = ui.enableMainWindowHotkey->isChecked();
|
p.enableMainWindowHotkey = ui.enableMainWindowHotkey->isChecked();
|
||||||
p.mainWindowHotkey = ui.mainWindowHotkey->getHotKey();
|
p.mainWindowHotkey = ui.mainWindowHotkey->getHotKey();
|
||||||
p.enableClipboardHotkey = ui.enableClipboardHotkey->isChecked();
|
p.enableClipboardHotkey = ui.enableClipboardHotkey->isChecked();
|
||||||
|
|
|
@ -412,6 +412,13 @@ be the last ones.</string>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="12" column="0">
|
||||||
|
<widget class="QCheckBox" name="darkMode">
|
||||||
|
<property name="text">
|
||||||
|
<string>dark mode</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="tab_4">
|
<widget class="QWidget" name="tab_4">
|
||||||
|
|
Loading…
Reference in a new issue