diff --git a/qml/pages/ReaderPage.qml b/qml/pages/ReaderPage.qml index 742dfa8..d8c3cb9 100644 --- a/qml/pages/ReaderPage.qml +++ b/qml/pages/ReaderPage.qml @@ -57,7 +57,10 @@ Page { text: qsTr("Close book") onClicked: { page.maybeSave(true) - pageStack.popTo(null) + // torna alla prima pagina dello stack (MainPage): + // popTo(null) non è affidabile su questa Silica + while (pageStack.depth > 1) + pageStack.pop() } } } diff --git a/qml/pages/SettingsPage.qml b/qml/pages/SettingsPage.qml index 19326bd..eba925d 100644 --- a/qml/pages/SettingsPage.qml +++ b/qml/pages/SettingsPage.qml @@ -7,6 +7,7 @@ Page { property string testResult: "" property bool testOk: false property bool testing: false + property string languageNotice: "" SilicaFlickable { anchors.fill: parent @@ -111,6 +112,43 @@ Page { visible: text.length > 0 } + SectionHeader { text: qsTr("Language") } + + ComboBox { + id: langBox + width: parent.width + label: qsTr("Language") + currentIndex: appSettings.language === "it" ? 2 : (appSettings.language === "en" ? 1 : 0) + menu: ContextMenu { + MenuItem { text: qsTr("System (default)") } + MenuItem { text: "English" } + MenuItem { text: "Italiano" } + } + onCurrentIndexChanged: { + var v = currentIndex === 2 ? "it" : (currentIndex === 1 ? "en" : "system") + if (v !== appSettings.language) { + appSettings.language = v + page.languageNotice = qsTr("Language will be applied after restarting the app") + langNoticeTimer.restart() + } + } + } + + Label { + x: Theme.horizontalPageMargin + width: parent.width - 2 * Theme.horizontalPageMargin + text: page.languageNotice + color: Theme.highlightColor + wrapMode: Text.Wrap + visible: text.length > 0 + } + + Timer { + id: langNoticeTimer + interval: 4000 + onTriggered: page.languageNotice = "" + } + Item { width: 1; height: Theme.paddingLarge } } } diff --git a/rpm/harbour-calibreweb.spec b/rpm/harbour-calibreweb.spec index c19c3c0..be2404a 100644 --- a/rpm/harbour-calibreweb.spec +++ b/rpm/harbour-calibreweb.spec @@ -25,6 +25,9 @@ in locale. %changelog * Wed Aug 19 2026 Carlo Baratto - 0.2.0-1 +- Selettore lingua nelle impostazioni (System/English/Italiano, applicata al + riavvio; QTranslator in main.cpp, pattern quill) +- Fix 'Close book': pop fino alla prima pagina (popTo(null) non affidabile) - Localizzazione: lingua di default inglese (qsTr ovunque), catalogo italiano harbour-calibreweb_it.ts/.qm installato in /usr/share/translations - Fix configurazione persa: file di configurazione unico e fisso diff --git a/src/main.cpp b/src/main.cpp index adb5e73..ed04d35 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include #include "apiclient.h" @@ -12,13 +13,36 @@ Q_DECL_EXPORT int main(int argc, char *argv[]) { QGuiApplication *app = SailfishApp::application(argc, argv); + + Settings settings; + + // User-chosen language (Settings -> Language). "system" = Sailfish UI + // language (libsailfishapp already installed its translator). "en" = + // force English (remove all translators). "it" = force Italian. + const QString lang = settings.language(); + if (lang == "en" || lang == "it") { + const QList trs = app->findChildren(); + foreach (QTranslator *t, trs) { + app->removeTranslator(t); + t->deleteLater(); + } + if (lang == "it") { + QTranslator *translator = new QTranslator(app); + if (translator->load(QStringLiteral("harbour-calibreweb_it"), + QStringLiteral("/usr/share/translations"))) { + app->installTranslator(translator); + } else { + qWarning() << "harbour-calibreweb: cannot load harbour-calibreweb_it.qm"; + } + } + } + QQuickView *view = SailfishApp::createView(); qDebug() << "harbour-calibreweb v0.2.0 build" << __DATE__ << __TIME__; qmlRegisterType("harbour.calibreweb", 1, 0, "EpubBook"); - Settings settings; ApiClient apiClient(&settings); Downloader downloader(&settings); diff --git a/src/settings.cpp b/src/settings.cpp index 356d014..53fd952 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -152,6 +152,20 @@ void Settings::setReaderMarginV(int value) emit readerMarginVChanged(); } +QString Settings::language() const +{ + return m_settings.value(QStringLiteral("language"), QStringLiteral("system")).toString(); +} + +void Settings::setLanguage(const QString &value) +{ + if (value == language()) + return; + m_settings.setValue(QStringLiteral("language"), value); + m_settings.sync(); + emit languageChanged(); +} + QString Settings::downloadDir() const { QString dir = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation); diff --git a/src/settings.h b/src/settings.h index 9de5083..8e99104 100644 --- a/src/settings.h +++ b/src/settings.h @@ -14,6 +14,8 @@ class Settings : public QObject Q_PROPERTY(bool ignoreSslErrors READ ignoreSslErrors WRITE setIgnoreSslErrors NOTIFY ignoreSslErrorsChanged) Q_PROPERTY(int readerMargin READ readerMargin WRITE setReaderMargin NOTIFY readerMarginChanged) Q_PROPERTY(int readerMarginV READ readerMarginV WRITE setReaderMarginV NOTIFY readerMarginVChanged) + // lingua scelta dall'utente: "system" (predefinita, lingua UI Sailfish), "en", "it" + Q_PROPERTY(QString language READ language WRITE setLanguage NOTIFY languageChanged) Q_PROPERTY(QString downloadDir READ downloadDir CONSTANT) // derivata da serverUrl (senza slash finale): accesso QML come appSettings.baseUrl Q_PROPERTY(QString baseUrl READ baseUrl NOTIFY baseUrlChanged) @@ -41,6 +43,10 @@ public: int readerMarginV() const; void setReaderMarginV(int value); + // lingua dell'interfaccia: "system" (default) | "en" | "it" + QString language() const; + void setLanguage(const QString &value); + QString downloadDir() const; // Header "Authorization: Basic ..." pronto da usare, vuoto se utente non impostato @@ -63,6 +69,7 @@ signals: void ignoreSslErrorsChanged(); void readerMarginChanged(); void readerMarginVChanged(); + void languageChanged(); void baseUrlChanged(); private: diff --git a/translations/harbour-calibreweb_it.ts b/translations/harbour-calibreweb_it.ts index ad6e8d5..4004c57 100644 --- a/translations/harbour-calibreweb_it.ts +++ b/translations/harbour-calibreweb_it.ts @@ -5,27 +5,27 @@ Read (EPUB) - Leggi (EPUB) + Leggi (EPUB) Formats - Formati + Formati Downloading… - Download in corso… + Download in corso… Saved to - Salvato in + Salvato in Error: - Errore: + Errore: @@ -33,12 +33,12 @@ Table of contents - Indice capitoli + Indice capitoli No chapters - Nessun capitolo + Nessun capitolo @@ -46,7 +46,7 @@ Calibre Web - Calibre Web + Calibre Web @@ -54,18 +54,18 @@ Refresh - Aggiorna + Aggiorna Settings - Impostazioni + Impostazioni No results - Nessun risultato + Nessun risultato @@ -73,37 +73,37 @@ Calibre Web - Calibre Web + Calibre Web Search - Cerca + Cerca Settings - Impostazioni + Impostazioni Refresh - Aggiorna + Aggiorna Open the settings and enter your Calibre Web address - Apri le impostazioni e inserisci l'indirizzo del tuo Calibre Web + Apri le impostazioni e inserisci l'indirizzo del tuo Calibre Web Server not configured - Server non configurato + Server non configurato No sections found in the OPDS feed - Nessuna sezione trovata nel feed OPDS + Nessuna sezione trovata nel feed OPDS @@ -111,27 +111,27 @@ Text margins - Margini del testo + Margini del testo Apply - Applica + Applica Side margins - Margini laterali + Margini laterali Top and bottom - Alto e basso + Alto e basso Changes apply immediately. Confirm to save them for all books. - Le modifiche si applicano subito al testo. Conferma per salvarle per tutti i libri. + Le modifiche si applicano subito al testo. Conferma per salvarle per tutti i libri. @@ -139,37 +139,37 @@ Table of contents - Indice capitoli + Indice capitoli Text margins - Margini del testo + Margini del testo Settings - Impostazioni + Impostazioni Close book - Chiudi libro + Chiudi libro - + The reader is not responding (WebView). The EPUB file may be damaged. - Il lettore non risponde (WebView). Il file EPUB potrebbe essere danneggiato. + Il lettore non risponde (WebView). Il file EPUB potrebbe essere danneggiato. - + Chapter unreadable - Capitolo non leggibile + Capitolo non leggibile - + Unable to open the EPUB file - Impossibile aprire il libro EPUB + Impossibile aprire il libro EPUB @@ -178,100 +178,116 @@ Search - Cerca + Cerca Title or author… - Titolo o autore… + Titolo o autore… Search uses the server engine (OPDS search). - La ricerca usa il motore del server (OPDS search). + La ricerca usa il motore del server (OPDS search). Results: - Risultati: + Risultati: SettingsPage - + Settings - Impostazioni + Impostazioni - + Server - Server + Server - + Calibre Web address - Indirizzo Calibre Web + Indirizzo Calibre Web - + User (empty = anonymous access) - Utente (vuoto = accesso anonimo) + Utente (vuoto = accesso anonimo) - + Password - Password - - - - Ignore SSL certificate errors - Ignora errori certificato SSL + Password + Ignore SSL certificate errors + Ignora errori certificato SSL + + + Enable if the server uses a self-signed certificate - Da attivare se il server usa un certificato autofirmato + Da attivare se il server usa un certificato autofirmato - + Reader - Lettore + Lettore - + Side margins - Margini laterali + Margini laterali - + Top and bottom margin - Margine alto e basso + Margine alto e basso - + Connection - Connessione + Connessione - + Test connection - Prova connessione + Prova connessione - + + + Language + Lingua + + + + System (default) + Sistema (predefinita) + + + + Language will be applied after restarting the app + La lingua verrà applicata al riavvio dell'app + + + Enter the server address - Inserisci l'indirizzo del server + Inserisci l'indirizzo del server - + Testing… - Verifica in corso… + Verifica in corso… - + Connection OK: %1 sections found - Connessione OK: %1 sezioni trovate + Connessione OK: %1 sezioni trovate \ No newline at end of file