diff --git a/.gitignore b/.gitignore index a2ce144..f2bec9c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.user *.user.* +translations/*.qm diff --git a/Caesium.pro b/Caesium.pro index b26e333..aeb1085 100644 --- a/Caesium.pro +++ b/Caesium.pro @@ -46,20 +46,22 @@ RESOURCES += \ RC_FILE = caesium.rc -TRANSLATIONS = caesium_en.ts \ - caesium_it.ts \ - caesium_ja.ts \ - caesium_fr.ts \ - caesium_br.ts \ - caesium_de.ts \ - caesium_tw.ts \ - caesium_sv.ts \ - caesium_cn.ts \ - caesium_pt-br.ts \ - caesium_es.ts \ - caesium_kr.ts \ - caesium_gr.ts \ - caesium_ru.ts +TRANSLATIONS = \ + translations/caesium.ts \ + translations/caesium_en_US.ts \ + translations/caesium_it.ts \ + translations/caesium_ja.ts \ + translations/caesium_fr.ts \ + translations/caesium_br.ts \ + translations/caesium_de.ts \ + translations/caesium_zh_TW.ts \ + translations/caesium_sv.ts \ + translations/caesium_zh_CN.ts \ + translations/caesium_pt_BR.ts \ + translations/caesium_es.ts \ + translations/caesium_ko.ts \ + translations/caesium_el_GR.ts \ + translations/caesium_ru.ts LIBS += -lQt5Concurrent diff --git a/README.md b/README.md new file mode 100644 index 0000000..dae6b68 --- /dev/null +++ b/README.md @@ -0,0 +1,10 @@ +## Caesium (fork) + +based on Caesium 1.7.0. You can get the original source code at [here](https://sourceforge.net/projects/caesium/files/1.7.0/). Changes made by this fork listed below. + +### Resolved issues + + - Remove country/region flags since the original filename have encoding issue which can cause a build failure, and also to avoid some potential regional internationalization issues. (216e1a9) + - Resolution display as -1x-1 for some images with unregular filename (e.g. `2IGYT%BD]SYY77Q7R041(WD.jpg` and `G9E@W$_Y4GYMWJY)%R24X~2.jpg`): Recompile under newer Qt version should works. Original Caesium official binary comes with Qt 5.1.0, Recompiled and tested under Qt 5.15.2. + - Click "Auto preview" checkbox and then click any image item will lead a crash. (0e3d5c5) + diff --git a/lang/111.Espal.qm b/lang/111.Espal.qm deleted file mode 100644 index abf795f..0000000 Binary files a/lang/111.Espal.qm and /dev/null differ diff --git a/lang/114.Svenska.qm b/lang/114.Svenska.qm deleted file mode 100644 index 0e4bf91..0000000 Binary files a/lang/114.Svenska.qm and /dev/null differ diff --git a/lang/25.汉语.qm b/lang/25.汉语.qm deleted file mode 100644 index c662e1e..0000000 Binary files a/lang/25.汉语.qm and /dev/null differ diff --git a/lang/25.漢語.qm b/lang/25.漢語.qm deleted file mode 100644 index 8735a84..0000000 Binary files a/lang/25.漢語.qm and /dev/null differ diff --git a/lang/30.Deutsch.qm b/lang/30.Deutsch.qm deleted file mode 100644 index b6aada6..0000000 Binary files a/lang/30.Deutsch.qm and /dev/null differ diff --git a/lang/31.English.qm b/lang/31.English.qm deleted file mode 100644 index df61097..0000000 Binary files a/lang/31.English.qm and /dev/null differ diff --git a/lang/37.Fran嘺is.qm b/lang/37.Fran嘺is.qm deleted file mode 100644 index 6ff8053..0000000 Binary files a/lang/37.Fran嘺is.qm and /dev/null differ diff --git a/lang/43.Ελληνικά.qm b/lang/43.Ελληνικά.qm deleted file mode 100644 index dd8360b..0000000 Binary files a/lang/43.Ελληνικά.qm and /dev/null differ diff --git a/lang/58.Italiano.qm b/lang/58.Italiano.qm deleted file mode 100644 index d643d90..0000000 Binary files a/lang/58.Italiano.qm and /dev/null differ diff --git a/lang/59.日本語.qm b/lang/59.日本語.qm deleted file mode 100644 index a009948..0000000 Binary files a/lang/59.日本語.qm and /dev/null differ diff --git a/lang/66.한국어.qm b/lang/66.한국어.qm deleted file mode 100644 index 90f06f4..0000000 Binary files a/lang/66.한국어.qm and /dev/null differ diff --git a/lang/91.Portugu坰 (Brasil).qm b/lang/91.Portugu坰 (Brasil).qm deleted file mode 100644 index 6a64b28..0000000 Binary files a/lang/91.Portugu坰 (Brasil).qm and /dev/null differ diff --git a/lang/96.русский язык.qm b/lang/96.русский язык.qm deleted file mode 100644 index bcd7359..0000000 Binary files a/lang/96.русский язык.qm and /dev/null differ diff --git a/lupdate.bat b/lupdate.bat deleted file mode 100644 index 88724f6..0000000 --- a/lupdate.bat +++ /dev/null @@ -1,2 +0,0 @@ -C:\Qt\Qt5.1.0\5.1.0\mingw48_32\bin\lupdate.exe C:\Users\Matteo\Documents\Progetti\Qt4\Caesium\Source\caesium.pro -pause \ No newline at end of file diff --git a/main.cpp b/main.cpp index e15900b..ddfad18 100644 --- a/main.cpp +++ b/main.cpp @@ -1,6 +1,7 @@ /******************************************************************************* # # Copyright (C) 2010-2013 Matteo Paonessa +# 2021 Gary Wang # # This file is part of the Caesium distribution. # @@ -19,6 +20,7 @@ # Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA. # # Author: Matteo Paonessa +# Gary Wang # # ******************************************************************************/ @@ -30,37 +32,10 @@ #include #include -QString findLocaleN(int n, QString dir) -{ - QDir langDir(dir + "/language"); - QStringList list = langDir.entryList(QStringList("*.qm"), QDir::Files, QDir::Name); - for (int i = list.length() - 1; i >= 0; i--) - { - QString file = list.at(i); - QStringList name = file.split("."); - if (name[0] == QString::number(n)) - { - return QString::number(n) + "." + name[1]; - } - } - return QString("31.English"); -} - -QString findLocaleS(QString string, QString dir) -{ - QDir langDir(dir + "/language"); - QStringList list = langDir.entryList(QStringList("*.qm"), QDir::Files, QDir::Name); - for (int i = list.length() - 1; i >= 0; i--) - { - QString file = list.at(i); - QStringList name = file.split("."); - if (name[1] == string) - { - return name[0] + "." + string; - } - } - return QString("31.English"); -} +// QM_FILE_INSTALL_DIR should be defined from the CMakeLists file. +#ifndef QM_FILE_INSTALL_DIR +#define QM_FILE_INSTALL_DIR ":/i18n/" +#endif // QM_FILE_INSTALL_DIR int main(int argc, char *argv[]) { @@ -71,18 +46,24 @@ int main(int argc, char *argv[]) a.addLibraryPath(a.applicationDirPath() + "/lib/"); - int loc = QLocale::system().language(); - QString locale = settings.value("Preferences/lang").value(); + QString locale = settings.value("Preferences/language").value(); + + QString qmDir; +#ifdef _WIN32 + qmDir = QDir(QCoreApplication::applicationDirPath()).absoluteFilePath("translations"); +#else + qmDir = QT_STRINGIFY(QM_FILE_INSTALL_DIR); +#endif + QTranslator translator; - if(locale.isEmpty()) - { - translator.load(a.applicationDirPath() + "/language/" + findLocaleN(loc, a.applicationDirPath())); - a.installTranslator(&translator); - } - else - { - translator.load(a.applicationDirPath() + "/language/" + findLocaleS(locale, a.applicationDirPath())); - a.installTranslator(&translator); + if(locale.isEmpty()) { + if (translator.load(QString("caesium_%1").arg(QLocale::system().name()), qmDir)) { + a.installTranslator(&translator); + } + } else { + if (translator.load(QString("caesium_%1").arg(locale), qmDir)) { + a.installTranslator(&translator); + } } QPixmap pixmap(":icons/splash.png"); diff --git a/preferences.cpp b/preferences.cpp index a35c940..61afdcd 100644 --- a/preferences.cpp +++ b/preferences.cpp @@ -1,6 +1,7 @@ /******************************************************************************* # # Copyright (C) 2010-2013 Matteo Paonessa +# 2021 Gary Wang # # This file is part of the Caesium distribution. # @@ -19,6 +20,7 @@ # Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA. # # Author: Matteo Paonessa +# Gary Wang # # ******************************************************************************/ @@ -62,16 +64,17 @@ Preferences::~Preferences() void Preferences::loadLanguages() { - QDir langDir(QDir::currentPath() + "/language"); + QDir langDir(QDir::currentPath() + "/translations"); QStringList list = langDir.entryList(QStringList("*.qm"), QDir::Files, QDir::NoSort); for (int i = list.length() - 1; i >= 0; i--) { - QString file = list.at(i); - QStringList infoList; - QStringList name = file.split("."); - infoList << name[1]; - QTreeWidgetItem *item = new QTreeWidgetItem(infoList, 0); - item->setIcon(0, QIcon(":/icons/language/" + name[1] + ".png")); + QString fileName = QFileInfo(list.at(i)).baseName(); + if (!fileName.startsWith("caesium")) continue; + QString langCode = fileName.mid(8); + QString langName = QLocale(langCode).nativeLanguageName(); + if (langName.isEmpty() || langCode.isEmpty()) continue; + + QTreeWidgetItem *item = new QTreeWidgetItem({langName, langCode}, 0); ui->languageTreeWidget->insertTopLevelItem(0, item); } ui->languageTreeWidget->sortItems(0, Qt::AscendingOrder); @@ -171,7 +174,7 @@ void Preferences::on_applyButton_clicked() settings.setValue("Preferences/loadlastlist", ui->loadLastListCheckBox->isChecked()); if (ui->languageTreeWidget->selectedItems().count() != 0) { - settings.setValue("Preferences/lang", ui->languageTreeWidget->selectedItems().at(0)->text(0)); + settings.setValue("Preferences/language", ui->languageTreeWidget->selectedItems().at(0)->text(1)); QMessageBox::information(this, tr("Information"), tr("You need to restart the application before\nchanges take effect"), diff --git a/translations/caesium.ts b/translations/caesium.ts new file mode 100644 index 0000000..7f2fe6c --- /dev/null +++ b/translations/caesium.ts @@ -0,0 +1,1015 @@ + + + + + AboutDialog + + + About + + + + + Information + + + + + Thanks + + + + + License + + + + + Close + + + + + Name: + + + + + Version: + + + + + Author: + + + + + Website: + Website: + + + + + Translations: + + + + + For Metatag manipulation + + + + + Base of the icon set + + + + + Caesium + + + Caesium - Image Compressor + + + + + Name + + + + + Size + + + + + New Size + + + + + Ratio + + + + + Quality + + + + + Resolution + + + + + Full Path + + + + + Add + + + + + Remove + + + + + + Preview + + + + + A new version is available! + + + + + Compression Options + + + + + Quality: + + + + + Set Quality + + + + + Format: + + + + + JPG + + + + + PNG + + + + + BMP + + + + + Resize + + + + + Absolute + + + + + Percentage + + + + + Height: + + + + + Input + + + + + Width: + + + + + Keep Aspect Ratio + + + + + Do not enlarge images + + + + + Output Folder + + + + + ... + + + + + Suffix: + + + + + Not allowed! + + + + + Waiting... + + + + + + Cancel + + + + + The original files will be deleted! + + + + + Original Image + + + + + Compressed Image + + + + + Auto preview + + + + + File + + + + + Edit + + + + + Action + + + + + View + + + + + Toolbar Icon Size + + + + + Help + + + + + Tools + + + + + Add Pictures... + + + + + Ctrl+O + + + + + Open List... + + + + + Ctrl+L + + + + + Save List As... + + + + + Ctrl+S + + + + + Exit + + + + + Ctrl+Q + + + + + Remove Item + + + + + Del + + + + + Clear List + + + + + Ctrl+Del + + + + + Ctrl+P + + + + + Minimize to tray + + + + + Minimize the application to system tray + + + + + Ctrl+Alt+Q + + + + + + Compress! + + + + + New Resolution + + + + + + Same for all + + + + + Apply + + + + + Choose and output folder... + + + + + Keep Structure + + + + + Remember last folder + + + + + Same folder as input + + + + + Online Support + + + + + Website + + + + + Ctrl+W + + + + + Check for Updates + + + + + Donate to Caesium + + + + + About + + + + + + About Qt + + + + + Show Toolbar + + + + + Settings + + + + + Open Folder... + + + + + Ctrl+Shift+O + + + + + Remove Item From List and Hard Disk + + + + + Ctrl+Shift+D + + + + + 32x32 + + + + + 24x24 + + + + + Save Profile... + + + + + Load Profile... + + + + + Save List + + + + + Select file(s) + + + + + Supported Images (*.bmp *.jpg *.jpeg *.tif *.tiff *.png *.ppm *.xbm *.xpm);;PNG Files (*.png);;JPEG Files (*.jpg *.jpeg);;BMP Files (*.bmp);;TIFF Files (*.tif *.tiff);;PPM Files (*.ppm);;XBM Files (*.xbm);;XPM Files (*.xpm) + + + + + Compression finished! +- + + + + + compressed +- + + + + + skipped +- + + + + + Item count: + + + + + Open Directory + + + + + Select output directory + + + + + I can't set the quality! + + + + + Info + + + + + PNG and BMP are loseless formats, and +can't be compressed like JPG do. +Caesium will set the quality level automatically +for those formats. + + + + + + Save as... + + + + + + Caesium List (*.clf) + + + + + Open a list file... + + + + + + + + Error + + + + + Failed to create the directory. +Aborting. + + + + + The list is empty! Fill it! + + + + + Set an Output Directory first! + + + + + Deleting original files... + + + + + Compression done! + + + + + error(s) +Time elapsed: + + + + + +Saved space: + + + + + Processing: + + + + + - Caesium - Image Compressor + + + + + + Warning + + + + + This action will delete the selected files PERMANENTLY. +Are you sure you want to continue? + + + + + + Yes + + + + + No + + + + + The output folder doesn't exists. +Do you want to create it? + + + + + + Caesium Profile (*.cpf) + + + + + Select a profile file... + + + + + Restore + + + + + Close + + + + + Failed to create the directory structure. + + + + + Exit + + + Are you sure? + + + + + Do you really want to exit Caesium? + + + + + Always check + + + + + Yes + + + + + No + + + + + Preferences + + + Preferences + + + + + General + + + + + Default Path + + + + + Use a default output directory if none is specified + + + + + ... + + + + + Default Image View + + + + + Original Size + + + + + Fit Window + + + + + Scan subdirectories when you open a folder + + + + + Load the last used profile at startup + + + + + Prompt before exit + + + + + Check for updates at startup + Check for uptades at startup + + + + + Compression + + + + + Keep EXIF Information while compressing + + + + + Delete the original file from disk + + + + + Keep the original Date Information + + + + + + Language + + + + + Restore last used list at startup + + + + + Restore window size and layout at startup + + + + + Style + + + + + WindowsXP + + + + + Skip if the output size is greater than the original + + + + + Don't delete if input extension is different from output one + + + + + Optimize PNG files during compression + + + + + Level: + + + + + + Medium (Average) + + + + + OK + + + + + Cancel + + + + + Apply + + + + + Information + + + + + You need to restart the application before +changes take effect + + + + + Soft (Fastest) + + + + + Hard (Slowest) + + + + + Select default output directory + + + + + QDropTreeWidget + + + Clear list + + + + + Preview + + + + + Remove item + + + + + Add pictures... + + + + + Open folder... + + + + + Open destination folder + + + + + Open input folder + + + + + Remove from list and Hard Disk + + + + + Updater + + + Caesium updater + + + + + Your version is + + + + + Checking version... + + + + + Start + + + + + Close + + + + + Caesium current version is: + + + + + + + ERROR: Connection timed out... + + + + + + + An error occurred. Please check your internet connection. + + + + + Contacting server... + + + + + Downloading + + + + + Download completed. + + + + + Information + + + + + Caesium will exit now in order to allow the update to run + + + + diff --git a/caesium_br.ts b/translations/caesium_br.ts similarity index 100% rename from caesium_br.ts rename to translations/caesium_br.ts diff --git a/caesium_de.ts b/translations/caesium_de.ts similarity index 100% rename from caesium_de.ts rename to translations/caesium_de.ts diff --git a/caesium_gr.ts b/translations/caesium_el_GR.ts similarity index 100% rename from caesium_gr.ts rename to translations/caesium_el_GR.ts diff --git a/caesium_en.ts b/translations/caesium_en_US.ts similarity index 100% rename from caesium_en.ts rename to translations/caesium_en_US.ts diff --git a/caesium_es.ts b/translations/caesium_es.ts similarity index 100% rename from caesium_es.ts rename to translations/caesium_es.ts diff --git a/caesium_fr.ts b/translations/caesium_fr.ts similarity index 100% rename from caesium_fr.ts rename to translations/caesium_fr.ts diff --git a/caesium_it.ts b/translations/caesium_it.ts similarity index 100% rename from caesium_it.ts rename to translations/caesium_it.ts diff --git a/caesium_ja.ts b/translations/caesium_ja.ts similarity index 100% rename from caesium_ja.ts rename to translations/caesium_ja.ts diff --git a/caesium_kr.ts b/translations/caesium_ko.ts similarity index 100% rename from caesium_kr.ts rename to translations/caesium_ko.ts diff --git a/caesium_pt-br.ts b/translations/caesium_pt_BR.ts similarity index 100% rename from caesium_pt-br.ts rename to translations/caesium_pt_BR.ts diff --git a/caesium_ru.ts b/translations/caesium_ru.ts similarity index 100% rename from caesium_ru.ts rename to translations/caesium_ru.ts diff --git a/caesium_sv.ts b/translations/caesium_sv.ts similarity index 100% rename from caesium_sv.ts rename to translations/caesium_sv.ts diff --git a/caesium_cn.ts b/translations/caesium_zh_CN.ts similarity index 100% rename from caesium_cn.ts rename to translations/caesium_zh_CN.ts diff --git a/caesium_tw.ts b/translations/caesium_zh_TW.ts similarity index 100% rename from caesium_tw.ts rename to translations/caesium_zh_TW.ts