From 7eef001ecabbe8c8793b85ce8d72303ab410424f Mon Sep 17 00:00:00 2001 From: xiaoyifang Date: Fri, 9 Dec 2022 09:04:21 +0800 Subject: [PATCH 1/5] action:Ubuntu22 require libfuse2.so to create appimage --- .github/workflows/ubuntu-6.2.yml | 1 + 1 file changed, 1 insertion(+) 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 From f8ed6d2bc52b59551cada4aafc877e1dd37e2c2a Mon Sep 17 00:00:00 2001 From: xiaoyifang Date: Fri, 9 Dec 2022 15:37:33 +0800 Subject: [PATCH 2/5] ffmpeg , replace avformat_open_input's second parameter to NULL the 2nd parameter is useless when context->pd is not null --- ffmpegaudio.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 ) ); From d969b63c1e120a709e60643dac6d511c4e7446fd Mon Sep 17 00:00:00 2001 From: Xiao YiFang Date: Sun, 11 Dec 2022 09:22:54 +0800 Subject: [PATCH 3/5] add experimental darkmode relate #188 --- config.cc | 8 ++++++++ config.hh | 1 + mainwindow.cc | 49 +++++++++++++++++++++++++++++++++++++++++++++---- mainwindow.hh | 2 +- preferences.cc | 2 ++ preferences.ui | 7 +++++++ 6 files changed, 64 insertions(+), 5 deletions(-) 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/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 + + + From 2263dfc8dace1c875ef739e0eddd5dd68bf1d978 Mon Sep 17 00:00:00 2001 From: Xiao YiFang Date: Sun, 11 Dec 2022 12:43:48 +0800 Subject: [PATCH 4/5] fix: qt warning when parsing unknown color attribute related to goldendict/goldendict#1578 --- article-style-st-classic.css | 2 +- article-style.css | 2 +- dsl.cc | 14 +++++++++++--- 3 files changed, 13 insertions(+), 5 deletions(-) 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/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"*" ) { From 1507bf9c6c898881112df76472e995289b16962a Mon Sep 17 00:00:00 2001 From: Xiao YiFang Date: Sun, 11 Dec 2022 19:15:30 +0800 Subject: [PATCH 5/5] remove redundant logic these lines seems not needed --- articleview.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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")); } }