mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-30 13:24: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 ()
|
||||
|
||||
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")
|
||||
|
||||
#### installation or assemble redistribution
|
||||
|
|
|
@ -83,6 +83,12 @@ endif ()
|
|||
if (WITH_ZIM)
|
||||
pkg_check_modules(ZIM REQUIRED IMPORTED_TARGET libzim)
|
||||
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 ()
|
||||
|
||||
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 "dictionary.hh"
|
||||
|
||||
#include <QCryptographicHash>
|
||||
|
||||
// For needToRebuildIndex(), read below
|
||||
#include <QFileInfo>
|
||||
#include <QDateTime>
|
||||
|
||||
#include "config.hh"
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
#include <QCryptographicHash>
|
||||
#include <QDateTime>
|
||||
#include <QImage>
|
||||
#include <QPixmap>
|
||||
#include <QPainter>
|
||||
#include <QRegularExpression>
|
||||
#include "utils.hh"
|
||||
|
@ -238,6 +235,11 @@ void Class::loadIcon() noexcept
|
|||
dictionaryIconLoaded = true;
|
||||
}
|
||||
|
||||
int Class::getOptimalIconSize()
|
||||
{
|
||||
return 64 * qGuiApp->devicePixelRatio();
|
||||
}
|
||||
|
||||
bool Class::loadIconFromFile( QString const & _filename, bool isFullName )
|
||||
{
|
||||
QFileInfo info;
|
||||
|
@ -266,33 +268,14 @@ bool Class::loadIconFromFile( QString const & _filename, bool isFullName )
|
|||
}
|
||||
|
||||
if ( info.isFile() ) {
|
||||
QImage img( fileName );
|
||||
auto iconSize = getOptimalIconSize();
|
||||
QPixmap img( fileName );
|
||||
|
||||
if ( !img.isNull() ) {
|
||||
// Load successful
|
||||
|
||||
//some icon is very large ,will crash the application.
|
||||
img = img.scaledToWidth( 64 );
|
||||
// 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 ) );
|
||||
auto result = img.scaled( { iconSize, iconSize }, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation );
|
||||
dictionaryIcon = QIcon( result );
|
||||
|
||||
return !dictionaryIcon.isNull();
|
||||
}
|
||||
|
@ -307,18 +290,12 @@ bool Class::loadIconFromText( QString iconUrl, QString const & text )
|
|||
QImage img( iconUrl );
|
||||
|
||||
if ( !img.isNull() ) {
|
||||
int iconSize = 64;
|
||||
//some icon is very large ,will crash the application.
|
||||
img = img.scaledToWidth( iconSize );
|
||||
QImage result( iconSize, iconSize, QImage::Format_ARGB32 );
|
||||
result.fill( 0 ); // Black transparent
|
||||
int max = img.width() > img.height() ? img.width() : img.height();
|
||||
auto iconSize = getOptimalIconSize();
|
||||
|
||||
QImage result = img.scaled( { iconSize, iconSize }, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation );
|
||||
|
||||
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.setRenderHints( QPainter::Antialiasing | QPainter::TextAntialiasing );
|
||||
painter.setCompositionMode( QPainter::CompositionMode_SourceAtop );
|
||||
|
||||
QFont font = painter.font();
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QWaitCondition>
|
||||
#include <QGuiApplication>
|
||||
|
||||
#include "config.hh"
|
||||
#include "ex.hh"
|
||||
|
@ -316,11 +317,12 @@ protected:
|
|||
bool synonymSearchEnabled;
|
||||
string dictionaryName;
|
||||
std::optional< bool > metadata_enable_fts = std::nullopt;
|
||||
|
||||
// Load user icon if it exist
|
||||
// By default set icon to empty
|
||||
virtual void loadIcon() noexcept;
|
||||
|
||||
static int getOptimalIconSize();
|
||||
|
||||
// Load icon from filename directly if isFullName == true
|
||||
// else treat filename as name without extension
|
||||
bool loadIconFromFile( QString const & filename, bool isFullName = false );
|
||||
|
|
|
@ -75,6 +75,7 @@ private:
|
|||
{ "tk_TM", QT_TR_NOOP( "Turkmen" ) },
|
||||
{ "ie_001", QT_TR_NOOP( "Interlingue" ) },
|
||||
{ "jbo_EN", QT_TR_NOOP( "Lojban" ) },
|
||||
{ "hu_HU", QT_TR_NOOP( "Hungarian" ) },
|
||||
{ "en_US", QT_TR_NOOP( "English" ) } };
|
||||
|
||||
Db();
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <QMenu>
|
||||
#include <QContextMenuEvent>
|
||||
#include <QProcess>
|
||||
#include <QStyle>
|
||||
|
||||
|
||||
using std::vector;
|
||||
|
@ -18,6 +19,8 @@ DictionaryBar::DictionaryBar( QWidget * parent,
|
|||
editDictionaryCommand( _editDictionaryCommand ),
|
||||
maxDictionaryRefsInContextMenu( maxDictionaryRefsInContextMenu_ )
|
||||
{
|
||||
normalIconSize = { this->iconSize().height(), this->iconSize().height() };
|
||||
|
||||
setObjectName( "dictionaryBar" );
|
||||
|
||||
maxDictionaryRefsAction =
|
||||
|
@ -72,14 +75,24 @@ void DictionaryBar::setDictionaries( vector< sptr< Dictionary::Class > > const &
|
|||
dictActions.append( action );
|
||||
}
|
||||
|
||||
setDictionaryIconSize( 21 );
|
||||
|
||||
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 )
|
||||
|
@ -87,6 +100,7 @@ void DictionaryBar::contextMenuEvent( QContextMenuEvent * event )
|
|||
showContextMenu( event );
|
||||
}
|
||||
|
||||
|
||||
void DictionaryBar::showContextMenu( QContextMenuEvent * event, bool extended )
|
||||
{
|
||||
QMenu menu( this );
|
||||
|
|
|
@ -34,7 +34,14 @@ public:
|
|||
{
|
||||
return mutedDictionaries;
|
||||
}
|
||||
void setDictionaryIconSize( int extent );
|
||||
|
||||
enum class IconSize {
|
||||
Small,
|
||||
Normal,
|
||||
// TODO: implement something to have an Large option
|
||||
};
|
||||
|
||||
void setDictionaryIconSize( IconSize size );
|
||||
|
||||
signals:
|
||||
|
||||
|
@ -69,6 +76,8 @@ private:
|
|||
QList< QAction * > dictActions;
|
||||
QAction * maxDictionaryRefsAction;
|
||||
|
||||
QSize normalIconSize; // cache icon size set by stylesheet provided by user
|
||||
|
||||
protected:
|
||||
|
||||
void contextMenuEvent( QContextMenuEvent * event );
|
||||
|
|
|
@ -1655,11 +1655,8 @@ void MainWindow::updateDictionaryBar()
|
|||
|
||||
dictionaryBar.setDictionaries( grp->dictionaries );
|
||||
|
||||
int extent = useSmallIconsInToolbarsAction.isChecked() ?
|
||||
QApplication::style()->pixelMetric( QStyle::PM_SmallIconSize ) :
|
||||
QApplication::style()->pixelMetric( QStyle::PM_ToolBarIconSize );
|
||||
|
||||
dictionaryBar.setDictionaryIconSize( extent );
|
||||
dictionaryBar.setDictionaryIconSize( useSmallIconsInToolbarsAction.isChecked() ? DictionaryBar::IconSize::Small :
|
||||
DictionaryBar::IconSize::Normal );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1110,9 +1110,8 @@ void ScanPopup::on_goForwardButton_clicked() const
|
|||
|
||||
void ScanPopup::setDictionaryIconSize()
|
||||
{
|
||||
int extent = cfg.usingSmallIconsInToolbars ? QApplication::style()->pixelMetric( QStyle::PM_SmallIconSize ) :
|
||||
QApplication::style()->pixelMetric( QStyle::PM_ToolBarIconSize );
|
||||
dictionaryBar.setDictionaryIconSize( extent );
|
||||
dictionaryBar.setDictionaryIconSize( cfg.usingSmallIconsInToolbars ? DictionaryBar::IconSize::Small :
|
||||
DictionaryBar::IconSize::Normal );
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
```
|
||||
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.
|
||||
|
|
Loading…
Reference in a new issue