Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,40 @@ Build options:
- `BUILD_SERVER_STANDALONE=ON`: builds only `YACReaderLibraryServer` (headless), requires only Qt 6.4+
- `BUILD_TESTS=ON` (default): enables the test suite

## Translations

Use CMake translation targets (Qt LinguistTools integration), not ad-hoc `lupdate` calls.

Update `.ts` files from source code (C++ + QML):

```bash
cmake --build build --target update_translations
```

On multi-config generators (Visual Studio / Ninja Multi-Config), include config:

```bash
cmake --build build --config Release --target update_translations
```

Build `.qm` files:

```bash
cmake --build build --target release_translations
```

Multi-config variant:

```bash
cmake --build build --config Release --target release_translations
```

Important:
- Do not run `lupdate` only on `qml.qrc` (or only on a subset of files), because that can mark unrelated translations as obsolete.
- In `YACReaderLibrary`, `qt_add_translations(...)` is configured to scan full target sources and include QML from `qml.qrc`.
- `update_translations` updates both locale TS files and `*_source.ts` template files for all apps.
- `*_source.ts` files are translator base templates and must not be treated as shipped locales.

## Tests

```bash
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Version counting is based on semantic versioning (Major.Feature.Patch)
* Migrate Flow implementation from OpenGL to QRhi. This is a full new implementation with better performance and compatibility with operating systems and hardware.
* Add light/dark themes support that follow the system configuration.
* Add a theme editor and support for custom themes.
* Add an application language setting with a system default option in YACReader and YACReaderLibrary.

## 9.16.4

Expand Down
1 change: 1 addition & 0 deletions YACReader/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ qt_add_translations(YACReader
yacreader_zh_TW.ts
yacreader_zh_HK.ts
yacreader_it.ts
yacreader_source.ts
yacreader_en.ts
)

Expand Down
11 changes: 3 additions & 8 deletions YACReader/main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include <QApplication>
#include <QDir>
#include <QTranslator>
#include <QCommandLineParser>
#include <QImageReader>

Expand All @@ -10,6 +9,7 @@
#include "appearance_configuration.h"
#include "theme_manager.h"
#include "theme_repository.h"
#include "app_language_utils.h"
#include "yacreader_global.h"

#include "QsLog.h"
Expand Down Expand Up @@ -175,13 +175,8 @@ int main(int argc, char *argv[])
logger.addDestination(std::move(debugDestination));
logger.addDestination(std::move(fileDestination));

QTranslator translator;
#if defined Q_OS_UNIX && !defined Q_OS_MACOS
translator.load(QLocale(), "yacreader", "_", QString(DATADIR) + "/yacreader/languages");
#else
translator.load(QLocale(), "yacreader", "_", "languages");
#endif
app.installTranslator(&translator);
QSettings uiSettings(YACReader::getSettingsPath() + "/YACReader.ini", QSettings::IniFormat);
YACReader::UiLanguage::applyLanguage("yacreader", uiSettings.value(UI_LANGUAGE).toString());
auto mwv = new MainWindowViewer();

// some arguments need to be parsed after MainWindowViewer creation
Expand Down
31 changes: 29 additions & 2 deletions YACReader/options_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "theme_manager.h"
#include "theme_factory.h"
#include "appearance_tab_widget.h"
#include "app_language_utils.h"

#include "yacreader_spin_slider_widget.h"
#include "yacreader_3d_flow_config_widget.h"
Expand All @@ -40,6 +41,19 @@ OptionsDialog::OptionsDialog(QWidget *parent)
path->addWidget(pathFindButton = new QPushButton(""));
pathBox->setLayout(path);

auto *languageBox = new QGroupBox(tr("Language"));
auto *languageLayout = new QHBoxLayout();
languageLayout->addWidget(new QLabel(tr("Application language")));
languageCombo = new QComboBox(this);
languageCombo->addItem(tr("System default"), QString());
const auto availableLanguages = YACReader::UiLanguage::availableLanguages("yacreader");
for (const auto &language : availableLanguages) {
languageCombo->addItem(
QString("%1 (%2)").arg(language.displayName, language.code), language.code);
}
languageLayout->addWidget(languageCombo);
languageBox->setLayout(languageLayout);

QGroupBox *displayBox = new QGroupBox(tr("Display"));
auto displayLayout = new QHBoxLayout();
showTimeInInformationLabel = new QCheckBox(tr("Show time in current page information label"));
Expand Down Expand Up @@ -105,6 +119,7 @@ OptionsDialog::OptionsDialog(QWidget *parent)
mouseModeBox->setLayout(mouseModeLayout);

layoutGeneral->addWidget(pathBox);
layoutGeneral->addWidget(languageBox);
layoutGeneral->addWidget(displayBox);
layoutGeneral->addWidget(slideSizeBox);
// layoutGeneral->addWidget(fitBox);
Expand Down Expand Up @@ -178,7 +193,7 @@ OptionsDialog::OptionsDialog(QWidget *parent)
auto scaleLayout = new QVBoxLayout();
scaleCheckbox = new QCheckBox(tr("Enlarge images to fit width/height"));
connect(scaleCheckbox, &QCheckBox::clicked, scaleCheckbox,
[=](bool checked) {
[=, this](bool checked) {
Configuration::getConfiguration().setEnlargeImages(checked);
emit changedImageOptions();
});
Expand All @@ -191,7 +206,7 @@ OptionsDialog::OptionsDialog(QWidget *parent)
auto doublePageBoxLayout = new QVBoxLayout();
coverSPCheckBox = new QCheckBox(tr("Show covers as single page"));
connect(coverSPCheckBox, &QCheckBox::clicked, coverSPCheckBox,
[=](bool checked) {
[=, this](bool checked) {
settings->setValue(COVER_IS_SP, checked);
emit changedImageOptions();
});
Expand Down Expand Up @@ -315,6 +330,12 @@ void OptionsDialog::saveOptions()
Configuration::getConfiguration().setScalingMethod(static_cast<ScaleMethod>(scalingMethodCombo->currentIndex()));
emit changedImageOptions();

const auto selectedLanguage = languageCombo->currentData().toString().trimmed();
if (selectedLanguage.isEmpty())
settings->remove(UI_LANGUAGE);
else
settings->setValue(UI_LANGUAGE, selectedLanguage);

YACReaderOptionsDialog::saveOptions();
}

Expand All @@ -326,6 +347,12 @@ void OptionsDialog::restoreOptions(QSettings *settings)

pathEdit->setText(settings->value(PATH).toString());

const auto selectedLanguage = settings->value(UI_LANGUAGE).toString().trimmed();
int languageIndex = languageCombo->findData(selectedLanguage);
if (languageIndex < 0)
languageIndex = 0;
languageCombo->setCurrentIndex(languageIndex);

showTimeInInformationLabel->setChecked(Configuration::getConfiguration().getShowTimeInInformation());

updateColor(settings->value(BACKGROUND_COLOR, theme.viewer.defaultBackgroundColor).value<QColor>());
Expand Down
1 change: 1 addition & 0 deletions YACReader/options_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class OptionsDialog : public YACReaderOptionsDialog, protected Themable
// QLabel * pathLabel;
QLineEdit *pathEdit;
QPushButton *pathFindButton;
QComboBox *languageCombo;

QCheckBox *showTimeInInformationLabel;

Expand Down
Loading
Loading