diff --git a/.github/workflows/ubuntu-6.2.yml b/.github/workflows/ubuntu-6.2.yml index 2b12c07b..5ffcd5ba 100644 --- a/.github/workflows/ubuntu-6.2.yml +++ b/.github/workflows/ubuntu-6.2.yml @@ -54,6 +54,7 @@ jobs: 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 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 #build opencc diff --git a/article-style-st-classic.css b/article-style-st-classic.css index 9a5155ca..fd7d9c57 100644 --- a/article-style-st-classic.css +++ b/article-style-st-classic.css @@ -390,7 +390,7 @@ div.xdxf display:inline; } -.dsl_article font[color=c_default_color] +.dsl_article .c_default_color { color: green; } diff --git a/article-style.css b/article-style.css index 99e88dff..ee6cc077 100644 --- a/article-style.css +++ b/article-style.css @@ -396,7 +396,7 @@ div.xdxf display:inline; } -.dsl_article font[color=c_default_color] +.dsl_article .c_default_color { color: green; } diff --git a/articleview.cc b/articleview.cc index 54fb14db..4dfd0aab 100644 --- a/articleview.cc +++ b/articleview.cc @@ -2149,9 +2149,9 @@ void ArticleView::resourceDownloadFinished() if ( resourceDownloadRequests.empty() ) { - emit statusBarMessage( - tr("WARNING: %1").arg(tr("The referenced resource failed to download.")), - 10000, QPixmap(":/icons/error.svg")); + // emit statusBarMessage( + // tr("WARNING: %1").arg(tr("The referenced resource failed to download.")), + // 10000, QPixmap(":/icons/error.svg")); } } diff --git a/config.cc b/config.cc index 0dd18f01..48ca3103 100644 --- a/config.cc +++ b/config.cc @@ -219,6 +219,7 @@ Preferences::Preferences(): selectWordBySingleClick( false ), autoScrollToTargetArticle( true ), escKeyHidesMainWindow( false ), + darkMode( false ), alwaysOnTop ( false ), searchInDock ( false ), @@ -869,6 +870,9 @@ Class load() if ( !preferences.namedItem( "escKeyHidesMainWindow" ).isNull() ) 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() ) 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" ) ); preferences.appendChild( opt ); + opt = dd.createElement( "darkMode" ); + opt.appendChild( dd.createTextNode( c.preferences.darkMode ? "1":"0" ) ); + preferences.appendChild( opt ); + opt = dd.createElement( "zoomFactor" ); opt.appendChild( dd.createTextNode( QString::number( c.preferences.zoomFactor ) ) ); preferences.appendChild( opt ); diff --git a/config.hh b/config.hh index 402723c9..b2ce2d7c 100644 --- a/config.hh +++ b/config.hh @@ -307,6 +307,7 @@ struct Preferences bool selectWordBySingleClick; bool autoScrollToTargetArticle; bool escKeyHidesMainWindow; + bool darkMode; bool alwaysOnTop; /// An old UI mode when tranlateLine and wordList diff --git a/dsl.cc b/dsl.cc index a808b48b..32eab1f9 100644 --- a/dsl.cc +++ b/dsl.cc @@ -809,9 +809,17 @@ string DslDictionary::nodeToHtml( ArticleDom::Node const & node ) } else if( node.tagName == U"c" ) { - result += "" + processNodeChildren( node ) + ""; + if( node.tagAttrs.empty() ) + { + result += "" + + processNodeChildren( node ) + ""; + } + else + { + result += "" + + processNodeChildren( node ) + ""; + } } else if( node.tagName == U"*" ) { diff --git a/ffmpegaudio.cc b/ffmpegaudio.cc index 60e21213..5674b432 100644 --- a/ffmpegaudio.cc +++ b/ffmpegaudio.cc @@ -186,7 +186,7 @@ bool DecoderContext::openCodec( QString & errorString ) int ret = 0; avformatOpened_ = true; - ret = avformat_open_input( &formatContext_, "_STREAM_", NULL, NULL ); + ret = avformat_open_input( &formatContext_, NULL, NULL, NULL ); if ( ret < 0 ) { errorString = QObject::tr( "avformat_open_input() failed: %1." ).arg( avErrorString( ret ) ); diff --git a/mainwindow.cc b/mainwindow.cc index 743af1a0..6511c672 100644 --- a/mainwindow.cc +++ b/mainwindow.cc @@ -834,7 +834,7 @@ MainWindow::MainWindow( Config::Class & cfg_ ): translateLine->setFocus(); - applyQtStyleSheet( cfg.preferences.displayStyle, cfg.preferences.addonStyle ); + applyQtStyleSheet( cfg.preferences.displayStyle, cfg.preferences.addonStyle, cfg.preferences.darkMode ); makeScanPopup(); @@ -1175,8 +1175,45 @@ QPrinter & MainWindow::getPrinter() 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" ); builtInCssFile.open( QFile::ReadOnly ); QByteArray css = builtInCssFile.readAll(); @@ -1210,6 +1247,10 @@ void MainWindow::applyQtStyleSheet( QString const & displayStyle, QString const css += addonCss.readAll(); } + if(darkMode){ + css += "QToolTip { color: #ffffff; background-color: #2a82da; border: 1px solid white; }"; + } + setStyleSheet( css ); } @@ -2237,9 +2278,9 @@ void MainWindow::editPreferences() bool needReload = false; // 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 ); needReload = true; } diff --git a/mainwindow.hh b/mainwindow.hh index b57c1ba1..346e0c5b 100644 --- a/mainwindow.hh +++ b/mainwindow.hh @@ -184,7 +184,7 @@ private: ResourceSchemeHandler * resourceSchemeHandler; /// 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 /// current configuration and situation. diff --git a/preferences.cc b/preferences.cc index 96d693d7..f08380b5 100644 --- a/preferences.cc +++ b/preferences.cc @@ -181,6 +181,7 @@ Preferences::Preferences( QWidget * parent, Config::Class & cfg_ ): ui.selectBySingleClick->setChecked( p.selectWordBySingleClick); ui.autoScrollToTargetArticle->setChecked( p.autoScrollToTargetArticle ); ui.escKeyHidesMainWindow->setChecked( p.escKeyHidesMainWindow ); + ui.darkMode->setChecked(p.darkMode); ui.enableMainWindowHotkey->setChecked( p.enableMainWindowHotkey ); ui.mainWindowHotkey->setHotKey( p.mainWindowHotkey ); @@ -400,6 +401,7 @@ Config::Preferences Preferences::getPreferences() p.autoScrollToTargetArticle = ui.autoScrollToTargetArticle->isChecked(); p.escKeyHidesMainWindow = ui.escKeyHidesMainWindow->isChecked(); + p.darkMode = ui.darkMode->isChecked(); p.enableMainWindowHotkey = ui.enableMainWindowHotkey->isChecked(); p.mainWindowHotkey = ui.mainWindowHotkey->getHotKey(); p.enableClipboardHotkey = ui.enableClipboardHotkey->isChecked(); diff --git a/preferences.ui b/preferences.ui index a9e9c159..f3c0403b 100644 --- a/preferences.ui +++ b/preferences.ui @@ -412,6 +412,13 @@ be the last ones. + + + + dark mode + + +