mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-12-02 19:14:05 +00:00
Compare commits
8 commits
34e9ad5654
...
78173e3c5d
Author | SHA1 | Date | |
---|---|---|---|
78173e3c5d | |||
a36f218df2 | |||
b392c83e86 | |||
39836dc143 | |||
9a73931d69 | |||
11717fbf62 | |||
5e62b1c567 | |||
aaaeb585b6 |
|
@ -239,7 +239,9 @@ else ()
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
qt_add_translations(${GOLDENDICT} TS_FILES ${TRANS_FILES}
|
qt_add_translations(${GOLDENDICT} TS_FILES ${TRANS_FILES}
|
||||||
QM_FILES_OUTPUT_VARIABLE qm_files)
|
QM_FILES_OUTPUT_VARIABLE qm_files
|
||||||
|
LUPDATE_OPTIONS "-no-ui-lines -locations none -no-obsolete")
|
||||||
|
|
||||||
add_dependencies(${GOLDENDICT} "release_translations")
|
add_dependencies(${GOLDENDICT} "release_translations")
|
||||||
|
|
||||||
#### installation or assemble redistribution
|
#### installation or assemble redistribution
|
||||||
|
|
|
@ -83,6 +83,12 @@ endif ()
|
||||||
if (WITH_ZIM)
|
if (WITH_ZIM)
|
||||||
pkg_check_modules(ZIM REQUIRED IMPORTED_TARGET libzim)
|
pkg_check_modules(ZIM REQUIRED IMPORTED_TARGET libzim)
|
||||||
target_link_libraries(${GOLDENDICT} PRIVATE PkgConfig::ZIM)
|
target_link_libraries(${GOLDENDICT} PRIVATE PkgConfig::ZIM)
|
||||||
|
if (APPLE)
|
||||||
|
# For some reason, icu4c as transitive dependency of libzim may not be copied into app bundle,
|
||||||
|
# so we directly depends on it to help macdeployqt or whatever
|
||||||
|
pkg_check_modules(BREW_ICU_FOR_LIBZIM_FORCE_LINK REQUIRED IMPORTED_TARGET icu-i18n icu-uc)
|
||||||
|
target_link_libraries(${GOLDENDICT} PUBLIC PkgConfig::BREW_ICU_FOR_LIBZIM_FORCE_LINK)
|
||||||
|
endif ()
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
if (USE_SYSTEM_FMT)
|
if (USE_SYSTEM_FMT)
|
||||||
|
|
4000
locale/ar_SA.ts
4000
locale/ar_SA.ts
File diff suppressed because it is too large
Load diff
4196
locale/ay_BO.ts
4196
locale/ay_BO.ts
File diff suppressed because it is too large
Load diff
3990
locale/be_BY.ts
3990
locale/be_BY.ts
File diff suppressed because it is too large
Load diff
3988
locale/bg_BG.ts
3988
locale/bg_BG.ts
File diff suppressed because it is too large
Load diff
5458
locale/crowdin.ts
5458
locale/crowdin.ts
File diff suppressed because it is too large
Load diff
4000
locale/cs_CZ.ts
4000
locale/cs_CZ.ts
File diff suppressed because it is too large
Load diff
3984
locale/de_CH.ts
3984
locale/de_CH.ts
File diff suppressed because it is too large
Load diff
3990
locale/de_DE.ts
3990
locale/de_DE.ts
File diff suppressed because it is too large
Load diff
4004
locale/el_GR.ts
4004
locale/el_GR.ts
File diff suppressed because it is too large
Load diff
4002
locale/eo_UY.ts
4002
locale/eo_UY.ts
File diff suppressed because it is too large
Load diff
4004
locale/es_AR.ts
4004
locale/es_AR.ts
File diff suppressed because it is too large
Load diff
3992
locale/es_BO.ts
3992
locale/es_BO.ts
File diff suppressed because it is too large
Load diff
4000
locale/es_ES.ts
4000
locale/es_ES.ts
File diff suppressed because it is too large
Load diff
4000
locale/fa_IR.ts
4000
locale/fa_IR.ts
File diff suppressed because it is too large
Load diff
4002
locale/fi_FI.ts
4002
locale/fi_FI.ts
File diff suppressed because it is too large
Load diff
3996
locale/fr_FR.ts
3996
locale/fr_FR.ts
File diff suppressed because it is too large
Load diff
3982
locale/hi_IN.ts
3982
locale/hi_IN.ts
File diff suppressed because it is too large
Load diff
4287
locale/hu_HU.ts
Normal file
4287
locale/hu_HU.ts
Normal file
File diff suppressed because it is too large
Load diff
4002
locale/ie_001.ts
4002
locale/ie_001.ts
File diff suppressed because it is too large
Load diff
4004
locale/it_IT.ts
4004
locale/it_IT.ts
File diff suppressed because it is too large
Load diff
3998
locale/ja_JP.ts
3998
locale/ja_JP.ts
File diff suppressed because it is too large
Load diff
4008
locale/jbo_EN.ts
4008
locale/jbo_EN.ts
File diff suppressed because it is too large
Load diff
3998
locale/ko_KR.ts
3998
locale/ko_KR.ts
File diff suppressed because it is too large
Load diff
3998
locale/lt_LT.ts
3998
locale/lt_LT.ts
File diff suppressed because it is too large
Load diff
4006
locale/mk_MK.ts
4006
locale/mk_MK.ts
File diff suppressed because it is too large
Load diff
3994
locale/nl_NL.ts
3994
locale/nl_NL.ts
File diff suppressed because it is too large
Load diff
4006
locale/pl_PL.ts
4006
locale/pl_PL.ts
File diff suppressed because it is too large
Load diff
4014
locale/pt_BR.ts
4014
locale/pt_BR.ts
File diff suppressed because it is too large
Load diff
4002
locale/pt_PT.ts
4002
locale/pt_PT.ts
File diff suppressed because it is too large
Load diff
3994
locale/qu_PE.ts
3994
locale/qu_PE.ts
File diff suppressed because it is too large
Load diff
4016
locale/ru_RU.ts
4016
locale/ru_RU.ts
File diff suppressed because it is too large
Load diff
3994
locale/sk_SK.ts
3994
locale/sk_SK.ts
File diff suppressed because it is too large
Load diff
3994
locale/sq_AL.ts
3994
locale/sq_AL.ts
File diff suppressed because it is too large
Load diff
4006
locale/sr_SP.ts
4006
locale/sr_SP.ts
File diff suppressed because it is too large
Load diff
4006
locale/sv_SE.ts
4006
locale/sv_SE.ts
File diff suppressed because it is too large
Load diff
4002
locale/tg_TJ.ts
4002
locale/tg_TJ.ts
File diff suppressed because it is too large
Load diff
3996
locale/tk_TM.ts
3996
locale/tk_TM.ts
File diff suppressed because it is too large
Load diff
3994
locale/tr_TR.ts
3994
locale/tr_TR.ts
File diff suppressed because it is too large
Load diff
4004
locale/uk_UA.ts
4004
locale/uk_UA.ts
File diff suppressed because it is too large
Load diff
3988
locale/vi_VN.ts
3988
locale/vi_VN.ts
File diff suppressed because it is too large
Load diff
3988
locale/zh_CN.ts
3988
locale/zh_CN.ts
File diff suppressed because it is too large
Load diff
3992
locale/zh_TW.ts
3992
locale/zh_TW.ts
File diff suppressed because it is too large
Load diff
|
@ -6,18 +6,15 @@
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include "dictionary.hh"
|
#include "dictionary.hh"
|
||||||
|
|
||||||
#include <QCryptographicHash>
|
|
||||||
|
|
||||||
// For needToRebuildIndex(), read below
|
// For needToRebuildIndex(), read below
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
|
|
||||||
#include "config.hh"
|
#include "config.hh"
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QFileInfo>
|
|
||||||
#include <QCryptographicHash>
|
#include <QCryptographicHash>
|
||||||
#include <QDateTime>
|
|
||||||
#include <QImage>
|
#include <QImage>
|
||||||
|
#include <QPixmap>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include "utils.hh"
|
#include "utils.hh"
|
||||||
|
@ -238,6 +235,11 @@ void Class::loadIcon() noexcept
|
||||||
dictionaryIconLoaded = true;
|
dictionaryIconLoaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Class::getOptimalIconSize()
|
||||||
|
{
|
||||||
|
return 64 * qGuiApp->devicePixelRatio();
|
||||||
|
}
|
||||||
|
|
||||||
bool Class::loadIconFromFile( QString const & _filename, bool isFullName )
|
bool Class::loadIconFromFile( QString const & _filename, bool isFullName )
|
||||||
{
|
{
|
||||||
QFileInfo info;
|
QFileInfo info;
|
||||||
|
@ -266,33 +268,14 @@ bool Class::loadIconFromFile( QString const & _filename, bool isFullName )
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( info.isFile() ) {
|
if ( info.isFile() ) {
|
||||||
QImage img( fileName );
|
auto iconSize = getOptimalIconSize();
|
||||||
|
QPixmap img( fileName );
|
||||||
|
|
||||||
if ( !img.isNull() ) {
|
if ( !img.isNull() ) {
|
||||||
// Load successful
|
// Load successful
|
||||||
|
|
||||||
//some icon is very large ,will crash the application.
|
auto result = img.scaled( { iconSize, iconSize }, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation );
|
||||||
img = img.scaledToWidth( 64 );
|
dictionaryIcon = QIcon( result );
|
||||||
// Apply the color key
|
|
||||||
#if ( QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 ) )
|
|
||||||
img.setAlphaChannel( img.createMaskFromColor( QColor( 192, 192, 192 ).rgb(), Qt::MaskOutColor ) );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Transform it to be square
|
|
||||||
int max = img.width() > img.height() ? img.width() : img.height();
|
|
||||||
|
|
||||||
QImage result( max, max, QImage::Format_ARGB32 );
|
|
||||||
result.fill( 0 ); // Black transparent
|
|
||||||
|
|
||||||
QPainter painter( &result );
|
|
||||||
painter.setRenderHint( QPainter::RenderHint::Antialiasing );
|
|
||||||
painter.drawImage( QPoint( img.width() == max ? 0 : ( max - img.width() ) / 2,
|
|
||||||
img.height() == max ? 0 : ( max - img.height() ) / 2 ),
|
|
||||||
img );
|
|
||||||
|
|
||||||
painter.end();
|
|
||||||
|
|
||||||
dictionaryIcon = QIcon( QPixmap::fromImage( result ) );
|
|
||||||
|
|
||||||
return !dictionaryIcon.isNull();
|
return !dictionaryIcon.isNull();
|
||||||
}
|
}
|
||||||
|
@ -307,18 +290,12 @@ bool Class::loadIconFromText( QString iconUrl, QString const & text )
|
||||||
QImage img( iconUrl );
|
QImage img( iconUrl );
|
||||||
|
|
||||||
if ( !img.isNull() ) {
|
if ( !img.isNull() ) {
|
||||||
int iconSize = 64;
|
auto iconSize = getOptimalIconSize();
|
||||||
//some icon is very large ,will crash the application.
|
|
||||||
img = img.scaledToWidth( iconSize );
|
QImage result = img.scaled( { iconSize, iconSize }, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation );
|
||||||
QImage result( iconSize, iconSize, QImage::Format_ARGB32 );
|
|
||||||
result.fill( 0 ); // Black transparent
|
|
||||||
int max = img.width() > img.height() ? img.width() : img.height();
|
|
||||||
|
|
||||||
QPainter painter( &result );
|
QPainter painter( &result );
|
||||||
painter.setRenderHint( QPainter::RenderHint::Antialiasing );
|
painter.setRenderHints( QPainter::Antialiasing | QPainter::TextAntialiasing );
|
||||||
painter.drawImage( QPoint( img.width() == max ? 0 : ( max - img.width() ) / 2,
|
|
||||||
img.height() == max ? 0 : ( max - img.height() ) / 2 ),
|
|
||||||
img );
|
|
||||||
painter.setCompositionMode( QPainter::CompositionMode_SourceAtop );
|
painter.setCompositionMode( QPainter::CompositionMode_SourceAtop );
|
||||||
|
|
||||||
QFont font = painter.font();
|
QFont font = painter.font();
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QWaitCondition>
|
#include <QWaitCondition>
|
||||||
|
#include <QGuiApplication>
|
||||||
|
|
||||||
#include "config.hh"
|
#include "config.hh"
|
||||||
#include "ex.hh"
|
#include "ex.hh"
|
||||||
|
@ -316,11 +317,12 @@ protected:
|
||||||
bool synonymSearchEnabled;
|
bool synonymSearchEnabled;
|
||||||
string dictionaryName;
|
string dictionaryName;
|
||||||
std::optional< bool > metadata_enable_fts = std::nullopt;
|
std::optional< bool > metadata_enable_fts = std::nullopt;
|
||||||
|
|
||||||
// Load user icon if it exist
|
// Load user icon if it exist
|
||||||
// By default set icon to empty
|
// By default set icon to empty
|
||||||
virtual void loadIcon() noexcept;
|
virtual void loadIcon() noexcept;
|
||||||
|
|
||||||
|
static int getOptimalIconSize();
|
||||||
|
|
||||||
// Load icon from filename directly if isFullName == true
|
// Load icon from filename directly if isFullName == true
|
||||||
// else treat filename as name without extension
|
// else treat filename as name without extension
|
||||||
bool loadIconFromFile( QString const & filename, bool isFullName = false );
|
bool loadIconFromFile( QString const & filename, bool isFullName = false );
|
||||||
|
|
|
@ -75,6 +75,7 @@ private:
|
||||||
{ "tk_TM", QT_TR_NOOP( "Turkmen" ) },
|
{ "tk_TM", QT_TR_NOOP( "Turkmen" ) },
|
||||||
{ "ie_001", QT_TR_NOOP( "Interlingue" ) },
|
{ "ie_001", QT_TR_NOOP( "Interlingue" ) },
|
||||||
{ "jbo_EN", QT_TR_NOOP( "Lojban" ) },
|
{ "jbo_EN", QT_TR_NOOP( "Lojban" ) },
|
||||||
|
{ "hu_HU", QT_TR_NOOP( "Hungarian" ) },
|
||||||
{ "en_US", QT_TR_NOOP( "English" ) } };
|
{ "en_US", QT_TR_NOOP( "English" ) } };
|
||||||
|
|
||||||
Db();
|
Db();
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QContextMenuEvent>
|
#include <QContextMenuEvent>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
|
#include <QStyle>
|
||||||
|
|
||||||
|
|
||||||
using std::vector;
|
using std::vector;
|
||||||
|
@ -18,6 +19,8 @@ DictionaryBar::DictionaryBar( QWidget * parent,
|
||||||
editDictionaryCommand( _editDictionaryCommand ),
|
editDictionaryCommand( _editDictionaryCommand ),
|
||||||
maxDictionaryRefsInContextMenu( maxDictionaryRefsInContextMenu_ )
|
maxDictionaryRefsInContextMenu( maxDictionaryRefsInContextMenu_ )
|
||||||
{
|
{
|
||||||
|
normalIconSize = { this->iconSize().height(), this->iconSize().height() };
|
||||||
|
|
||||||
setObjectName( "dictionaryBar" );
|
setObjectName( "dictionaryBar" );
|
||||||
|
|
||||||
maxDictionaryRefsAction =
|
maxDictionaryRefsAction =
|
||||||
|
@ -72,14 +75,24 @@ void DictionaryBar::setDictionaries( vector< sptr< Dictionary::Class > > const &
|
||||||
dictActions.append( action );
|
dictActions.append( action );
|
||||||
}
|
}
|
||||||
|
|
||||||
setDictionaryIconSize( 21 );
|
|
||||||
|
|
||||||
setUpdatesEnabled( true );
|
setUpdatesEnabled( true );
|
||||||
}
|
}
|
||||||
|
|
||||||
void DictionaryBar::setDictionaryIconSize( int extent )
|
void DictionaryBar::setDictionaryIconSize( IconSize size )
|
||||||
{
|
{
|
||||||
setIconSize( QSize( extent, extent ) );
|
switch ( size ) {
|
||||||
|
case IconSize::Small: {
|
||||||
|
auto smallSize = QApplication::style()->pixelMetric( QStyle::PM_SmallIconSize );
|
||||||
|
setIconSize( { smallSize, smallSize } );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case IconSize::Normal: {
|
||||||
|
setIconSize( normalIconSize );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DictionaryBar::contextMenuEvent( QContextMenuEvent * event )
|
void DictionaryBar::contextMenuEvent( QContextMenuEvent * event )
|
||||||
|
@ -87,6 +100,7 @@ void DictionaryBar::contextMenuEvent( QContextMenuEvent * event )
|
||||||
showContextMenu( event );
|
showContextMenu( event );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DictionaryBar::showContextMenu( QContextMenuEvent * event, bool extended )
|
void DictionaryBar::showContextMenu( QContextMenuEvent * event, bool extended )
|
||||||
{
|
{
|
||||||
QMenu menu( this );
|
QMenu menu( this );
|
||||||
|
|
|
@ -34,7 +34,14 @@ public:
|
||||||
{
|
{
|
||||||
return mutedDictionaries;
|
return mutedDictionaries;
|
||||||
}
|
}
|
||||||
void setDictionaryIconSize( int extent );
|
|
||||||
|
enum class IconSize {
|
||||||
|
Small,
|
||||||
|
Normal,
|
||||||
|
// TODO: implement something to have an Large option
|
||||||
|
};
|
||||||
|
|
||||||
|
void setDictionaryIconSize( IconSize size );
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
|
@ -69,6 +76,8 @@ private:
|
||||||
QList< QAction * > dictActions;
|
QList< QAction * > dictActions;
|
||||||
QAction * maxDictionaryRefsAction;
|
QAction * maxDictionaryRefsAction;
|
||||||
|
|
||||||
|
QSize normalIconSize; // cache icon size set by stylesheet provided by user
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void contextMenuEvent( QContextMenuEvent * event );
|
void contextMenuEvent( QContextMenuEvent * event );
|
||||||
|
|
|
@ -1655,11 +1655,8 @@ void MainWindow::updateDictionaryBar()
|
||||||
|
|
||||||
dictionaryBar.setDictionaries( grp->dictionaries );
|
dictionaryBar.setDictionaries( grp->dictionaries );
|
||||||
|
|
||||||
int extent = useSmallIconsInToolbarsAction.isChecked() ?
|
dictionaryBar.setDictionaryIconSize( useSmallIconsInToolbarsAction.isChecked() ? DictionaryBar::IconSize::Small :
|
||||||
QApplication::style()->pixelMetric( QStyle::PM_SmallIconSize ) :
|
DictionaryBar::IconSize::Normal );
|
||||||
QApplication::style()->pixelMetric( QStyle::PM_ToolBarIconSize );
|
|
||||||
|
|
||||||
dictionaryBar.setDictionaryIconSize( extent );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1110,9 +1110,8 @@ void ScanPopup::on_goForwardButton_clicked() const
|
||||||
|
|
||||||
void ScanPopup::setDictionaryIconSize()
|
void ScanPopup::setDictionaryIconSize()
|
||||||
{
|
{
|
||||||
int extent = cfg.usingSmallIconsInToolbars ? QApplication::style()->pixelMetric( QStyle::PM_SmallIconSize ) :
|
dictionaryBar.setDictionaryIconSize( cfg.usingSmallIconsInToolbars ? DictionaryBar::IconSize::Small :
|
||||||
QApplication::style()->pixelMetric( QStyle::PM_ToolBarIconSize );
|
DictionaryBar::IconSize::Normal );
|
||||||
dictionaryBar.setDictionaryIconSize( extent );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScanPopup::setGroupByName( QString const & name ) const
|
void ScanPopup::setGroupByName( QString const & name ) const
|
||||||
|
|
|
@ -3,7 +3,7 @@ This project uses crowdin to organize all the transactions.When some new transac
|
||||||
# how to update the crowdin.ts file
|
# how to update the crowdin.ts file
|
||||||
|
|
||||||
```
|
```
|
||||||
lupdate-pro.exe -no-obsolete -no-ui-lines -locations none goldendict.pro -ts locale\crowdin.ts
|
lupdate.exe -no-obsolete -no-ui-lines -locations none .\src\ -ts .\locale\crowdin.ts
|
||||||
```
|
```
|
||||||
|
|
||||||
the option `-no-obsolete` will remove obsolete items from crowdin.ts file.
|
the option `-no-obsolete` will remove obsolete items from crowdin.ts file.
|
||||||
|
|
Loading…
Reference in a new issue