From b72b00c2e4268ad47776f4e728aa002b50f91567 Mon Sep 17 00:00:00 2001 From: DavidLazarescu Date: Sun, 10 Dec 2023 11:23:22 +0100 Subject: [PATCH 01/20] Increased max zoom to 1000% --- src/presentation/readingPage/DocumentNavigation.js | 2 +- .../readingPage/readingToolbar/MReadingToolBar.qml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/presentation/readingPage/DocumentNavigation.js b/src/presentation/readingPage/DocumentNavigation.js index 5a76cdcdc..8de6267e9 100644 --- a/src/presentation/readingPage/DocumentNavigation.js +++ b/src/presentation/readingPage/DocumentNavigation.js @@ -56,7 +56,7 @@ function setMoveDirection(direction) { function zoom(newZoomFactor) { // Clamp to max / min zoom factors - newZoomFactor = Math.max(0.15, Math.min(newZoomFactor, 5)) + newZoomFactor = Math.max(0.15, Math.min(newZoomFactor, 10)) if (newZoomFactor === BookController.zoom) return diff --git a/src/presentation/readingPage/readingToolbar/MReadingToolBar.qml b/src/presentation/readingPage/readingToolbar/MReadingToolBar.qml index 35adc018e..7e8f76632 100644 --- a/src/presentation/readingPage/readingToolbar/MReadingToolBar.qml +++ b/src/presentation/readingPage/readingToolbar/MReadingToolBar.qml @@ -255,13 +255,13 @@ Pane { text: "250%" } ListElement { - text: "300%" + text: "500%" } ListElement { - text: "400%" + text: "750%" } ListElement { - text: "500%" + text: "1000%" } } From 70633a8d074ba678e3d8dde3f62406e6dc6ca418 Mon Sep 17 00:00:00 2001 From: DmitryFedorov Date: Tue, 21 Nov 2023 12:27:41 +0900 Subject: [PATCH 02/20] Added colorTheme field to Book --- src/domain/entities/book.cpp | 12 ++++++++++++ src/domain/entities/book.hpp | 2 ++ src/domain/value_objects/book_meta_data.hpp | 4 +++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/domain/entities/book.cpp b/src/domain/entities/book.cpp index b1e614a96..95cdee10c 100644 --- a/src/domain/entities/book.cpp +++ b/src/domain/entities/book.cpp @@ -354,6 +354,16 @@ int Book::getBookReadingProgress() const return std::round(percentageInDecimal * 100); } +QString Book::getColorTheme() const +{ + return m_metaData.colorTheme; +} + +void Book::setColorTheme(const QString& newColorTheme) +{ + m_metaData.colorTheme = newColorTheme; +} + const QList& Book::getTags() const { return m_tags; @@ -607,6 +617,7 @@ QByteArray Book::toJson() const getCoverLastModified().toString(dateTimeStringFormat) }, { "hasCover", hasCover() }, { "coverPath", getCoverPath() }, + { "colorTheme", getColorTheme() }, { "existsOnlyOnClient", existsOnlyOnClient() }, { "tags", serializeTags() }, { "highlights", serializeHighlights() }, @@ -667,6 +678,7 @@ Book Book::fromJson(const QJsonObject& jsonBook) Book book(filePath, metaData, currentPage, uuid); book.setProjectGutenbergId(projectGutenbergId); book.setExistsOnlyOnClient(existsOnlyOnClient); + book.setColorTheme(jsonBook["colorTheme"].toString()); addTagsToBook(book, jsonBook["tags"].toArray()); addHighlightsToBook(book, jsonBook["highlights"].toArray()); addBookmarksToBook(book, jsonBook["bookmarks"].toArray()); diff --git a/src/domain/entities/book.hpp b/src/domain/entities/book.hpp index 3bb586aaf..c085e2ef1 100644 --- a/src/domain/entities/book.hpp +++ b/src/domain/entities/book.hpp @@ -104,6 +104,8 @@ class DOMAIN_EXPORT Book int getBookReadingProgress() const; + QString getColorTheme() const; + void setColorTheme(const QString& newColorTheme); domain::entities::Tag* getTagByUuid(const QUuid& uuid); domain::entities::Tag* getTagByName(const QString& name); diff --git a/src/domain/value_objects/book_meta_data.hpp b/src/domain/value_objects/book_meta_data.hpp index 631253ea9..34fd4eeb7 100644 --- a/src/domain/value_objects/book_meta_data.hpp +++ b/src/domain/value_objects/book_meta_data.hpp @@ -25,6 +25,7 @@ struct DOMAIN_EXPORT BookMetaData bool hasCover = false; double bookMediaDownloadProgress = 0.0; QString coverPath; + QString colorTheme; bool operator==(const BookMetaData& rhs) const { @@ -45,7 +46,8 @@ struct DOMAIN_EXPORT BookMetaData rhs.lastModified.toSecsSinceEpoch() && coverLastModified.toSecsSinceEpoch() == rhs.coverLastModified.toSecsSinceEpoch() && - hasCover == rhs.hasCover && coverPath == coverPath; + hasCover == rhs.hasCover && coverPath == coverPath && + colorTheme == rhs.colorTheme; } }; From c36517c3c91e7124c3cf282d8624e2f30fdd1bc2 Mon Sep 17 00:00:00 2001 From: DmitryFedorov Date: Sat, 25 Nov 2023 22:22:52 +0900 Subject: [PATCH 03/20] Added setting color theme for books on server --- src/adapters/controllers/book_controller.cpp | 5 +++++ src/adapters/controllers/book_controller.hpp | 2 ++ src/adapters/interfaces/controllers/i_book_controller.hpp | 2 ++ src/application/interfaces/services/i_book_service.hpp | 4 +++- src/application/services/book_service.cpp | 7 +++++++ src/application/services/book_service.hpp | 2 ++ src/domain/entities/book.cpp | 2 +- .../readingPage/readingToolbar/MReadingOptionsPopup.qml | 2 ++ src/presentation/translations/librum_de.ts | 6 +++--- src/presentation/translations/librum_en.ts | 6 +++--- src/presentation/translations/librum_ru.ts | 6 +++--- 11 files changed, 33 insertions(+), 11 deletions(-) diff --git a/src/adapters/controllers/book_controller.cpp b/src/adapters/controllers/book_controller.cpp index 21a841421..a84557407 100644 --- a/src/adapters/controllers/book_controller.cpp +++ b/src/adapters/controllers/book_controller.cpp @@ -155,6 +155,11 @@ void BookController::goToBookmark(const QString& uuid) } } +void BookController::setColorTheme(const QString& colorTheme) +{ + m_bookService->setColorTheme(colorTheme); +} + void BookController::followLink(const char* uri) { return m_bookService->followLink(uri); diff --git a/src/adapters/controllers/book_controller.hpp b/src/adapters/controllers/book_controller.hpp index 7a0b6b98d..a7ff510ad 100644 --- a/src/adapters/controllers/book_controller.hpp +++ b/src/adapters/controllers/book_controller.hpp @@ -41,6 +41,8 @@ class ADAPTERS_EXPORT BookController : public IBookController void removeBookmark(const QString& uuid) override; void goToBookmark(const QString& uuid) override; + void setColorTheme(const QString& colorTheme) override; + void followLink(const char* uri) override; QString getFilePath() const override; diff --git a/src/adapters/interfaces/controllers/i_book_controller.hpp b/src/adapters/interfaces/controllers/i_book_controller.hpp index f98788748..70856bf26 100644 --- a/src/adapters/interfaces/controllers/i_book_controller.hpp +++ b/src/adapters/interfaces/controllers/i_book_controller.hpp @@ -62,6 +62,8 @@ class ADAPTERS_EXPORT IBookController : public QObject Q_INVOKABLE virtual void removeBookmark(const QString& uuid) = 0; Q_INVOKABLE virtual void goToBookmark(const QString& uuid) = 0; + Q_INVOKABLE virtual void setColorTheme(const QString& colorTheme) = 0; + virtual void followLink(const char* uri) = 0; virtual QString getFilePath() const = 0; diff --git a/src/application/interfaces/services/i_book_service.hpp b/src/application/interfaces/services/i_book_service.hpp index 23428fe77..7017cd7e6 100644 --- a/src/application/interfaces/services/i_book_service.hpp +++ b/src/application/interfaces/services/i_book_service.hpp @@ -57,6 +57,8 @@ class APPLICATION_EXPORT IBookService : public QObject virtual float getZoom() const = 0; virtual void setZoom(float newZoom) = 0; + virtual void setColorTheme(const QString& colorTheme) = 0; + virtual core::FilteredTOCModel* getTableOfContents() = 0; signals: @@ -71,4 +73,4 @@ class APPLICATION_EXPORT IBookService : public QObject void bookmarkNameChanged(int index); }; -} // namespace application \ No newline at end of file +} // namespace application diff --git a/src/application/services/book_service.cpp b/src/application/services/book_service.cpp index f2670f844..cb5d97601 100644 --- a/src/application/services/book_service.cpp +++ b/src/application/services/book_service.cpp @@ -223,6 +223,13 @@ void BookService::setZoom(float newZoom) m_zoom = newZoom; } +void BookService::setColorTheme(const QString& colorTheme) +{ + auto book = getBook(); + book->setColorTheme(colorTheme); + m_libraryService->updateBook(*book); +} + core::FilteredTOCModel* BookService::getTableOfContents() { if(m_TOCModel == nullptr) diff --git a/src/application/services/book_service.hpp b/src/application/services/book_service.hpp index 154a841ee..a99ae6a6c 100644 --- a/src/application/services/book_service.hpp +++ b/src/application/services/book_service.hpp @@ -47,6 +47,8 @@ class BookService : public IBookService float getZoom() const override; void setZoom(float newZoom) override; + void setColorTheme(const QString& colorTheme) override; + core::FilteredTOCModel* getTableOfContents() override; domain::entities::Book* getBook(); diff --git a/src/domain/entities/book.cpp b/src/domain/entities/book.cpp index 95cdee10c..f10ff3a5d 100644 --- a/src/domain/entities/book.cpp +++ b/src/domain/entities/book.cpp @@ -678,7 +678,6 @@ Book Book::fromJson(const QJsonObject& jsonBook) Book book(filePath, metaData, currentPage, uuid); book.setProjectGutenbergId(projectGutenbergId); book.setExistsOnlyOnClient(existsOnlyOnClient); - book.setColorTheme(jsonBook["colorTheme"].toString()); addTagsToBook(book, jsonBook["tags"].toArray()); addHighlightsToBook(book, jsonBook["highlights"].toArray()); addBookmarksToBook(book, jsonBook["bookmarks"].toArray()); @@ -713,6 +712,7 @@ BookMetaData Book::getBookMetaDataFromJson(const QJsonObject& jsonBook) jsonBook["coverLastModified"].toString(), dateTimeStringFormat), .hasCover = jsonBook["hasCover"].toBool(), .coverPath = jsonBook["coverPath"].toString(), + .colorTheme = jsonBook["colorTheme"].toString(), }; // Specify that the dates are UTC, else Qt thinks its local time diff --git a/src/presentation/readingPage/readingToolbar/MReadingOptionsPopup.qml b/src/presentation/readingPage/readingToolbar/MReadingOptionsPopup.qml index a93706d33..48a454461 100644 --- a/src/presentation/readingPage/readingToolbar/MReadingOptionsPopup.qml +++ b/src/presentation/readingPage/readingToolbar/MReadingOptionsPopup.qml @@ -136,6 +136,8 @@ Popup { SettingsController.setSetting( SettingKeys.PageColorMode, value, SettingGroups.Appearance) + + BookController.setColorTheme(value) } } diff --git a/src/presentation/translations/librum_de.ts b/src/presentation/translations/librum_de.ts index 2257ba258..cec0b2c95 100644 --- a/src/presentation/translations/librum_de.ts +++ b/src/presentation/translations/librum_de.ts @@ -1477,17 +1477,17 @@ Lösche alte Bücher um Speicherplatzu freizugeben oder upgrade deinen Account.< Invers - + Sync book Buch synchronisieren - + More options Mehr Optionen - + Save Speichern diff --git a/src/presentation/translations/librum_en.ts b/src/presentation/translations/librum_en.ts index 2992eb3e9..c90bea00c 100644 --- a/src/presentation/translations/librum_en.ts +++ b/src/presentation/translations/librum_en.ts @@ -1296,17 +1296,17 @@ Delete unused books to free up space or upgrade. - + Sync book - + More options - + Save diff --git a/src/presentation/translations/librum_ru.ts b/src/presentation/translations/librum_ru.ts index 118b2f83f..a3a76f09b 100644 --- a/src/presentation/translations/librum_ru.ts +++ b/src/presentation/translations/librum_ru.ts @@ -1410,17 +1410,17 @@ Delete unused books to free up space or upgrade. Поменять цвета - + Sync book Обновить - + More options Ещё - + Save Сохранить From b360aae7075840c83405a9cd3daf73c3b6b60e63 Mon Sep 17 00:00:00 2001 From: DmitryFedorov Date: Sun, 26 Nov 2023 22:34:24 +0900 Subject: [PATCH 04/20] Removed color theme setting from Appearance settings --- src/presentation/settings/MAppearancePage.qml | 30 --------------- src/presentation/translations/librum_de.ts | 33 ++++++++--------- src/presentation/translations/librum_en.ts | 37 ++++++------------- src/presentation/translations/librum_ru.ts | 33 ++++++++--------- 4 files changed, 41 insertions(+), 92 deletions(-) diff --git a/src/presentation/settings/MAppearancePage.qml b/src/presentation/settings/MAppearancePage.qml index dbb2db224..c0e3fbae6 100644 --- a/src/presentation/settings/MAppearancePage.qml +++ b/src/presentation/settings/MAppearancePage.qml @@ -137,36 +137,6 @@ Page { SettingKeys.Theme, newSelected) } - Label { - id: pageColorModeTitle - Layout.fillWidth: true - Layout.topMargin: 18 - text: qsTr("Page Color Mode") - font.pointSize: Fonts.size13 - font.weight: Font.DemiBold - color: Style.colorText - } - - MDualToggle { - id: pageColorModeSwitch - property string savedValue: SettingsController.appearanceSettings.PageColorMode - - Layout.topMargin: 4 - leftText: "Normal" - leftDisplayText: qsTr("Normal") - rightText: "Inverted" - rightDisplayText: qsTr("Inverted") - leftSelected: savedValue === leftText - rightSelected: savedValue === rightText - - // Need rebinding on reset - onSavedValueChanged: savedValue === leftText ? selectLeft( - ) : selectRight() - onToggled: newSelected => internal.saveSetting( - SettingKeys.PageColorMode, - newSelected) - } - Label { id: languageTitle Layout.fillWidth: true diff --git a/src/presentation/translations/librum_de.ts b/src/presentation/translations/librum_de.ts index cec0b2c95..d146ed9b1 100644 --- a/src/presentation/translations/librum_de.ts +++ b/src/presentation/translations/librum_de.ts @@ -334,37 +334,34 @@ Wir hoffen, dass du eine tolle Zeit hast! Lass uns doch eine Bewertung da.Hell - Page Color Mode - Seiten Farben Modus + Seiten Farben Modus - Normal - Normal + Normal - Inverted - Invers + Invers - + Language Sprache - + Reading Lesen - + Page spacing Seiten Abstand - + Display book title in titlebar Den Buchtitel in der Titelleiste anzeigen @@ -413,22 +410,22 @@ Wir hoffen, dass du eine tolle Zeit hast! Lass uns doch eine Bewertung da.Tauschen - + Default Zoom Standard-Zoom - + Highlights Markierungen - + Colors Farben - + Opacity Transparenz @@ -457,24 +454,24 @@ Wir hoffen, dass du eine tolle Zeit hast! Lass uns doch eine Bewertung da.Immer sichtbar - + Reset settings? Zurücksetzen? - + Resetting your settings is a permanent action, there will be no way to restore them! Einstellungen zurückzusetzen ist eine endgültige Aktion, es gibt keine Möglichkeit sie wiederherzustellen! - + No, Keep Nein, behalte - + Yes, Reset Ja, zurücksetzen diff --git a/src/presentation/translations/librum_en.ts b/src/presentation/translations/librum_en.ts index c90bea00c..227202935 100644 --- a/src/presentation/translations/librum_en.ts +++ b/src/presentation/translations/librum_en.ts @@ -326,77 +326,62 @@ We hope you have a great time using it! Feel free to leave us a rating and some - Page Color Mode - - - - - Normal - - - - - Inverted - - - - Language - + Reading - + Page spacing - + Display book title in titlebar - + Default Zoom - + Highlights - + Colors - + Opacity - + Reset settings? - + Resetting your settings is a permanent action, there will be no way to restore them! - + No, Keep - + Yes, Reset diff --git a/src/presentation/translations/librum_ru.ts b/src/presentation/translations/librum_ru.ts index a3a76f09b..544287e11 100644 --- a/src/presentation/translations/librum_ru.ts +++ b/src/presentation/translations/librum_ru.ts @@ -326,37 +326,34 @@ We hope you have a great time using it! Feel free to leave us a rating and some Светлая - Page Color Mode - Цветовой Режим Страницы + Цветовой Режим Страницы - Normal - Нормальный + Нормальный - Inverted - Инвертированный + Инвертированный - + Language Язык - + Reading Чтение - + Page spacing Расстояние между страницами - + Display book title in titlebar Отображать название книги в строке с названием @@ -405,22 +402,22 @@ We hope you have a great time using it! Feel free to leave us a rating and some Замена - + Default Zoom Увеличение по-умолчанию - + Highlights Выделение - + Colors Цвета - + Opacity Непрозрачность @@ -449,23 +446,23 @@ We hope you have a great time using it! Feel free to leave us a rating and some Всегда виден - + Reset settings? Сбросить? - + Resetting your settings is a permanent action, there will be no way to restore them! Сброс настроек необратим, Вы не сможете потом их восстановить! - + No, Keep Нет, Оставить - + Yes, Reset Да, Сбросить From 0237c194ad0ed4a366e9776b05c57cf8ebe9ca08 Mon Sep 17 00:00:00 2001 From: DmitryFedorov Date: Thu, 7 Dec 2023 18:03:59 +0900 Subject: [PATCH 05/20] Made books save and restore their own color theme --- src/adapters/controllers/book_controller.cpp | 16 +++++++++++----- src/adapters/controllers/book_controller.hpp | 5 +++-- .../interfaces/controllers/i_book_controller.hpp | 8 ++++++-- .../interfaces/services/i_book_service.hpp | 1 + src/application/services/book_service.cpp | 6 ++++++ src/application/services/book_service.hpp | 1 + src/domain/entities/book.cpp | 2 ++ src/presentation/readingPage/MDocumentView.qml | 2 +- .../readingToolbar/MReadingOptionsPopup.qml | 8 ++------ src/presentation/translations/librum_de.ts | 6 +++--- src/presentation/translations/librum_en.ts | 6 +++--- src/presentation/translations/librum_ru.ts | 6 +++--- 12 files changed, 42 insertions(+), 25 deletions(-) diff --git a/src/adapters/controllers/book_controller.cpp b/src/adapters/controllers/book_controller.cpp index a84557407..5f7effcde 100644 --- a/src/adapters/controllers/book_controller.cpp +++ b/src/adapters/controllers/book_controller.cpp @@ -155,11 +155,6 @@ void BookController::goToBookmark(const QString& uuid) } } -void BookController::setColorTheme(const QString& colorTheme) -{ - m_bookService->setColorTheme(colorTheme); -} - void BookController::followLink(const char* uri) { return m_bookService->followLink(uri); @@ -232,6 +227,17 @@ void BookController::setSearchFromStart(bool newSearchFromStart) emit searchFromStartChanged(); } +QString BookController::getColorTheme() +{ + return m_bookService->getColorTheme(); +} + +void BookController::setColorTheme(const QString& colorTheme) +{ + m_bookService->setColorTheme(colorTheme); + emit colorThemeChanged(colorTheme); +} + FilteredTOCModel* BookController::getTableOfContents() { return m_bookService->getTableOfContents(); diff --git a/src/adapters/controllers/book_controller.hpp b/src/adapters/controllers/book_controller.hpp index a7ff510ad..72ad96e5d 100644 --- a/src/adapters/controllers/book_controller.hpp +++ b/src/adapters/controllers/book_controller.hpp @@ -41,8 +41,6 @@ class ADAPTERS_EXPORT BookController : public IBookController void removeBookmark(const QString& uuid) override; void goToBookmark(const QString& uuid) override; - void setColorTheme(const QString& colorTheme) override; - void followLink(const char* uri) override; QString getFilePath() const override; @@ -63,6 +61,9 @@ class ADAPTERS_EXPORT BookController : public IBookController bool getSearchFromStart() const override; void setSearchFromStart(bool newSearchFromStart) override; + QString getColorTheme() override; + void setColorTheme(const QString& colorTheme) override; + application::core::FilteredTOCModel* getTableOfContents() override; data_models::BookmarksProxyModel* getBookmarksModel() override; diff --git a/src/adapters/interfaces/controllers/i_book_controller.hpp b/src/adapters/interfaces/controllers/i_book_controller.hpp index 70856bf26..e114935e6 100644 --- a/src/adapters/interfaces/controllers/i_book_controller.hpp +++ b/src/adapters/interfaces/controllers/i_book_controller.hpp @@ -34,6 +34,8 @@ class ADAPTERS_EXPORT IBookController : public QObject setSearchCaseSensitive NOTIFY searchCaseSensitiveChanged) Q_PROPERTY(bool searchFromStart READ getSearchFromStart WRITE setSearchFromStart NOTIFY searchFromStartChanged) + Q_PROPERTY(QString colorTheme READ getColorTheme WRITE setColorTheme NOTIFY + colorThemeChanged) public: virtual ~IBookController() noexcept = default; @@ -62,8 +64,6 @@ class ADAPTERS_EXPORT IBookController : public QObject Q_INVOKABLE virtual void removeBookmark(const QString& uuid) = 0; Q_INVOKABLE virtual void goToBookmark(const QString& uuid) = 0; - Q_INVOKABLE virtual void setColorTheme(const QString& colorTheme) = 0; - virtual void followLink(const char* uri) = 0; virtual QString getFilePath() const = 0; @@ -84,6 +84,9 @@ class ADAPTERS_EXPORT IBookController : public QObject virtual bool getSearchFromStart() const = 0; virtual void setSearchFromStart(bool newSearchFromStart) = 0; + virtual QString getColorTheme() = 0; + virtual void setColorTheme(const QString& colorTheme) = 0; + virtual application::core::FilteredTOCModel* getTableOfContents() = 0; virtual adapters::data_models::BookmarksProxyModel* getBookmarksModel() = 0; @@ -102,6 +105,7 @@ class ADAPTERS_EXPORT IBookController : public QObject void searchCaseSensitiveChanged(); void searchFromStartChanged(); void bookmarksModelChanged(); + void colorThemeChanged(const QString& colorTheme); }; } // namespace adapters diff --git a/src/application/interfaces/services/i_book_service.hpp b/src/application/interfaces/services/i_book_service.hpp index 7017cd7e6..5666b1a73 100644 --- a/src/application/interfaces/services/i_book_service.hpp +++ b/src/application/interfaces/services/i_book_service.hpp @@ -57,6 +57,7 @@ class APPLICATION_EXPORT IBookService : public QObject virtual float getZoom() const = 0; virtual void setZoom(float newZoom) = 0; + virtual QString getColorTheme() = 0; virtual void setColorTheme(const QString& colorTheme) = 0; virtual core::FilteredTOCModel* getTableOfContents() = 0; diff --git a/src/application/services/book_service.cpp b/src/application/services/book_service.cpp index cb5d97601..193029455 100644 --- a/src/application/services/book_service.cpp +++ b/src/application/services/book_service.cpp @@ -223,6 +223,12 @@ void BookService::setZoom(float newZoom) m_zoom = newZoom; } +QString BookService::getColorTheme() +{ + auto book = getBook(); + return book->getColorTheme(); +} + void BookService::setColorTheme(const QString& colorTheme) { auto book = getBook(); diff --git a/src/application/services/book_service.hpp b/src/application/services/book_service.hpp index a99ae6a6c..5bce65411 100644 --- a/src/application/services/book_service.hpp +++ b/src/application/services/book_service.hpp @@ -47,6 +47,7 @@ class BookService : public IBookService float getZoom() const override; void setZoom(float newZoom) override; + QString getColorTheme() override; void setColorTheme(const QString& colorTheme) override; core::FilteredTOCModel* getTableOfContents() override; diff --git a/src/domain/entities/book.cpp b/src/domain/entities/book.cpp index f10ff3a5d..b5dab281f 100644 --- a/src/domain/entities/book.cpp +++ b/src/domain/entities/book.cpp @@ -507,6 +507,8 @@ void Book::update(const Book& other) m_metaData.hasCover = other.hasCover(); if(m_metaData.coverPath != other.getCoverPath()) m_metaData.coverPath = other.getCoverPath(); + if(m_metaData.colorTheme != other.getColorTheme()) + m_metaData.colorTheme = other.getColorTheme(); if(!tagsAreTheSame(other.getTags())) m_tags = other.getTags(); diff --git a/src/presentation/readingPage/MDocumentView.qml b/src/presentation/readingPage/MDocumentView.qml index 148013516..7e2816e0a 100644 --- a/src/presentation/readingPage/MDocumentView.qml +++ b/src/presentation/readingPage/MDocumentView.qml @@ -141,7 +141,7 @@ Pane { bookController: BookController height: implicitHeight width: implicitWidth - colorInverted: SettingsController.appearanceSettings.PageColorMode === "Inverted" + colorInverted: BookController.colorTheme === "Inverted" includeNewLinesInCopiedText: SettingsController.behaviorSettings.IncludeNewLinesInCopiedText === "ON" anchors.horizontalCenter: if (parent != null) parent.horizontalCenter diff --git a/src/presentation/readingPage/readingToolbar/MReadingOptionsPopup.qml b/src/presentation/readingPage/readingToolbar/MReadingOptionsPopup.qml index 48a454461..e4d12e57e 100644 --- a/src/presentation/readingPage/readingToolbar/MReadingOptionsPopup.qml +++ b/src/presentation/readingPage/readingToolbar/MReadingOptionsPopup.qml @@ -127,17 +127,13 @@ Popup { onClicked: { let value = "" - let current = SettingsController.appearanceSettings.PageColorMode + let current = BookController.colorTheme if (current === "Normal") value = "Inverted" else value = "Normal" - SettingsController.setSetting( - SettingKeys.PageColorMode, value, - SettingGroups.Appearance) - - BookController.setColorTheme(value) + BookController.colorTheme = value } } diff --git a/src/presentation/translations/librum_de.ts b/src/presentation/translations/librum_de.ts index d146ed9b1..603a63e23 100644 --- a/src/presentation/translations/librum_de.ts +++ b/src/presentation/translations/librum_de.ts @@ -1474,17 +1474,17 @@ Lösche alte Bücher um Speicherplatzu freizugeben oder upgrade deinen Account.< Invers - + Sync book Buch synchronisieren - + More options Mehr Optionen - + Save Speichern diff --git a/src/presentation/translations/librum_en.ts b/src/presentation/translations/librum_en.ts index 227202935..56cd4103d 100644 --- a/src/presentation/translations/librum_en.ts +++ b/src/presentation/translations/librum_en.ts @@ -1281,17 +1281,17 @@ Delete unused books to free up space or upgrade. - + Sync book - + More options - + Save diff --git a/src/presentation/translations/librum_ru.ts b/src/presentation/translations/librum_ru.ts index 544287e11..defc6df1f 100644 --- a/src/presentation/translations/librum_ru.ts +++ b/src/presentation/translations/librum_ru.ts @@ -1407,17 +1407,17 @@ Delete unused books to free up space or upgrade. Поменять цвета - + Sync book Обновить - + More options Ещё - + Save Сохранить From 03f0ff8bc1a683e1b003b9d505c983b1a274ec1f Mon Sep 17 00:00:00 2001 From: DavidLazarescu Date: Mon, 11 Dec 2023 13:32:47 +0100 Subject: [PATCH 06/20] Fixed handling of not-specified color theme Books created prior to this change will have an empty 'ColorTheme' property. This should be valued as 'Normal' so we need to change the default. --- .../readingPage/readingToolbar/MReadingOptionsPopup.qml | 7 +++---- src/presentation/translations/librum_de.ts | 6 +++--- src/presentation/translations/librum_en.ts | 6 +++--- src/presentation/translations/librum_ru.ts | 6 +++--- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/presentation/readingPage/readingToolbar/MReadingOptionsPopup.qml b/src/presentation/readingPage/readingToolbar/MReadingOptionsPopup.qml index e4d12e57e..5333c40d7 100644 --- a/src/presentation/readingPage/readingToolbar/MReadingOptionsPopup.qml +++ b/src/presentation/readingPage/readingToolbar/MReadingOptionsPopup.qml @@ -126,12 +126,11 @@ Popup { onClicked: { let value = "" - let current = BookController.colorTheme - if (current === "Normal") - value = "Inverted" - else + if (current === "Inverted") value = "Normal" + else + value = "Inverted" BookController.colorTheme = value } diff --git a/src/presentation/translations/librum_de.ts b/src/presentation/translations/librum_de.ts index 603a63e23..d68af38b3 100644 --- a/src/presentation/translations/librum_de.ts +++ b/src/presentation/translations/librum_de.ts @@ -1474,17 +1474,17 @@ Lösche alte Bücher um Speicherplatzu freizugeben oder upgrade deinen Account.< Invers - + Sync book Buch synchronisieren - + More options Mehr Optionen - + Save Speichern diff --git a/src/presentation/translations/librum_en.ts b/src/presentation/translations/librum_en.ts index 56cd4103d..c2ac39287 100644 --- a/src/presentation/translations/librum_en.ts +++ b/src/presentation/translations/librum_en.ts @@ -1281,17 +1281,17 @@ Delete unused books to free up space or upgrade. - + Sync book - + More options - + Save diff --git a/src/presentation/translations/librum_ru.ts b/src/presentation/translations/librum_ru.ts index defc6df1f..b043b1fd0 100644 --- a/src/presentation/translations/librum_ru.ts +++ b/src/presentation/translations/librum_ru.ts @@ -1407,17 +1407,17 @@ Delete unused books to free up space or upgrade. Поменять цвета - + Sync book Обновить - + More options Ещё - + Save Сохранить From fe4d1e784930c7cef0b13d985dc88b52dc083ce9 Mon Sep 17 00:00:00 2001 From: DavidLazarescu Date: Mon, 11 Dec 2023 13:40:28 +0100 Subject: [PATCH 07/20] Fixed book's 'lastModified' not being updated correctly atfer changing the theme --- src/application/services/book_service.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/application/services/book_service.cpp b/src/application/services/book_service.cpp index 193029455..8a79091fa 100644 --- a/src/application/services/book_service.cpp +++ b/src/application/services/book_service.cpp @@ -233,7 +233,7 @@ void BookService::setColorTheme(const QString& colorTheme) { auto book = getBook(); book->setColorTheme(colorTheme); - m_libraryService->updateBook(*book); + updateBook(); } core::FilteredTOCModel* BookService::getTableOfContents() From 8f535d174d1ed90c6bfdb472fcf66846fda952ca Mon Sep 17 00:00:00 2001 From: chenmo Date: Thu, 7 Dec 2023 23:59:44 +0800 Subject: [PATCH 08/20] add-chinese-translation --- src/presentation/translations/librum_zh_cn.ts | 2014 +++++++++++++++++ 1 file changed, 2014 insertions(+) create mode 100644 src/presentation/translations/librum_zh_cn.ts diff --git a/src/presentation/translations/librum_zh_cn.ts b/src/presentation/translations/librum_zh_cn.ts new file mode 100644 index 000000000..daea58eeb --- /dev/null +++ b/src/presentation/translations/librum_zh_cn.ts @@ -0,0 +1,2014 @@ + + + + + MAboutPage + + + About + 关于 + + + + About this application + 关于此应用 + + + + Details + 详细信息 + + + + CURRENT VERSION + Keep it capitalized + 当前版本 + + + + QT VERSION + Keep it capitalized + QT 版本 + + + + Up-to date + 已为最新 + + + + Creator + 作者 + + + + COMPANY NAME + Keep it capitalized + 公司名称 + + + + WEBSITE + Keep it capitalized + 官方网站 + + + + CONTACT + Keep it capitalized + 联系我们 + + + + GITHUB + Keep it capitalized + GITHUB + + + + This App + 此应用 + + + + Librum is here for everyone who just wants to enjoy a good book. +We hope you have a great time using it! Feel free to leave us a rating and some feedback. + Librum 为每个想享受一本好书的人而存在。 +我们希望您在使用时度过一段美好的时光!不妨给我们留下评价和一些反馈。 + + + + MAcceptPolicy + + + I accept the + Make sure to translate the following words together to make a logical sentence + 我同意 + + + + Terms of Service + 服务条款 + + + + and the + + + + + Privacy Policy + 隐私政策 + + + + MAccountPage + + + Account + 账户 + + + + + Save + 保存 + + + + Profile + 个人资料 + + + + First name + + + + + Last name + + + + + Email + 电子邮箱 + + + + Change password + 更改密码 + + + + Password + 密码 + + + + Password confirmation + 确认密码 + + + + Your data + 您的数据 + + + + Analyse your reading to make better recommendations + 分析您的阅读以提供更好的推荐 + + + + Anonymously share information about the books you read to help us improve Librum + 匿名分享您阅读的书籍信息以帮助我们改进 Librum + + + + Collect data on crashes so that we can prevent it from happening again + 收集崩溃信息以避免再次发生 + + + + Collect data to display in your statistics + 收集信息以在您的统计数据中展示 + + + + Your Account + 您的账户 + + + + Logout + 登出 + + + + Delete Your Account + 删除您的账户 + + + + Whoops + 哎呀 + + + + It looks like you forgot to save your changes, are you sure that you dont want to save them? + 看起来您忘记了保存您的修改,是否放弃修改? + + + + Don't save + 不保存 + + + + + Passwords don't match! + 密码不匹配! + + + + MAddOnsPage + + + Add-ons Page + 插件页面 + + + + Currently in Development + 正在开发中 + + + + MAddShortcutPopup + + + Edit Shortcuts + 编辑快捷键 + + + + Action + 动作 + + + + None selected + 未选择 + + + + The shortcut + 快捷键 + + + + is already used for + 已被此动作使用: + + + + Apply + 应用 + + + + Cancel + 取消 + + + + MAddTagBox + + + Add a tag... + 添加一个标签... + + + + MAddTagBoxPopup + + + Add + 添加 + + + + Rename + 重命名 + + + + Delete + 删除 + + + + MAppearancePage + + + Appearance + 外观 + + + + Make your own experience + 定制您的体验 + + + + Restore Defaults + 恢复默认 + + + + Display + 显示 + + + + Theme + 主题 + + + + Dark + Dark + + + + Light + Light + + + + Page Color Mode + 页面颜色模式 + + + + Normal + 常规 + + + + Inverted + 反转 + + + + Language + 语言 + + + + Reading + 阅读 + + + + Page spacing + 页间距 + + + + Display book title in titlebar + 在标题栏显示书名 + + + + Default Zoom + 默认缩放 + + + + Highlights + 高亮 + + + + Colors + 颜色 + + + + Opacity + 不透明度 + + + + Reset settings? + 重置设置? + + + + Resetting your settings is a permanent action, there + will be no way to restore them! + 重置您的设置是一个永久性的操作,您将无法恢复! + + + + No, Keep + 保持 + + + + Yes, Reset + 重置 + + + + MBehaviorPage + + + Behavior + 行为 + + + + Change the way Librum works + 修改 Librum 的工作方式 + + + + Restore Defaults + 恢复默认 + + + + Books + 书籍 + + + + Cursor mode + 鼠标 + + + + Hidden after delay + 超时后隐藏 + + + + Always visible + 总是可见 + + + + Hide cursor after delay + 超时时间 + + + + ms + ms + + + + Reset settings? + 重置设置? + + + + Resetting your settings is a permanent action, there + will be no way to restore them! + 重置您的设置是一个永久性的操作,您将无法恢复! + + + + No, Keep + 保持 + + + + Yes, Reset + 重置 + + + + MBook + + + + Unknown + 未知 + + + + Your book has not been uploaded to the cloud. +Either you are offline, or your storage is full. + 您的书籍未上传到云端,您已离线或您的储存空间已满。 + + + + MBookDetailsPopup + + + Book details + 详细信息 + + + + Change + 修改 + + + + + Delete + 删除 + + + + Title + 标题 + + + + + + + + Unknown + 未知 + + + + Authors + 作者 + + + + Pages + 页数 + + + + Language + 语言 + + + + Document creator + 创作者 + + + + Creation date + 创建日期 + + + + Format + 格式 + + + + Document size + 文件大小 + + + + Added + 添加日期 + + + + Last opened + 最后打开 + + + + Apply + 应用 + + + + Cancel + 取消 + + + + Select + 选择 + + + + All files + 全部文件 + + + + + + files + 文件 + + + + MBookRightClickPopup + + + Download + 下载 + + + + Read book + 阅读此书 + + + + Book details + 详细信息 + + + + Save to files + 保存到文件 + + + + Manage tags + 管理标签 + + + + Mark as read + If this is too long in any language, use "Read" (past form) instead + 标记为已读 + + + + Remove book + 移除此书 + + + + MBookmarksSidebar + + + Bookmarks + 书签 + + + + Search + 搜索 + + + + Add Bookmark + 添加书签 + + + + New Bookmark + 新书签 + + + + Follow + Context: "Follow" the bookmark (go to its page) + 前往 + + + + Rename + 重命名 + + + + Delete + 删除 + + + + MChapterSidebar + + + Contents + Context: Contents of the book, also known as outline + 目录 + + + + Search + 搜索 + + + + MComboBox + + + Any + 任意 + + + + MConfirmAccountDeletionPopup + + + Confirm Account Deletion + 确认删除账户 + + + + Deleting your account is an irreversible action.<br>Once you delete your account, there is <b>no</b> going back. Please be certain. + 删除您的账户是不可逆的操作。<br>一旦您删除了您的账户,将<b>无法</b>挽回,请确认。 + + + + Your Email + 您的邮箱 + + + + Confirm the deletion by entering your Account's email. + 输入您的邮箱以确认删除。 + + + + Cancel + 取消 + + + + Delete + 删除 + + + + Your email is wrong + 邮箱错误 + + + + MDictionaryPopup + + + Search + 搜索 + + + + No definitions found + 未找到定义 + + + + Search online + 在线搜索 + + + + Source + 来源 + + + + MDownloadBookPopup + + + Download book + 下载此书 + + + + Title + 标题 + + + + Authors + 作者 + + + + Language + 语言 + + + + Downloads + 下载次数 + + + + Format + 格式 + + + + Download + 下载 + + + + Cancel + 取消 + + + + MDualToggle + + + Left + + + + + Right + + + + + MEmptyScreenContent + + + Quite empty here, what about adding your first book? + 这里空无一物,尝试添加您的第一本书? + + + + Add book + 添加书籍 + + + + MExplanationPopup + + + You have reached your daily limit. + Make sure that the words make a valid sentence + 您已到达当日限制。 + + + + Click + 点击 + + + + here + 此处 + + + + to learn more. + 发现更多。 + + + + Oops! The text is too long. Please shorten your selection. + 哎呀!文本太长了,请少选一些。 + + + + Explain + 解释 + + + + Explain like I'm five + 通俗解释 + + + + Summarize + 总结 + + + + Give more information + 提供更多信息 + + + + Explain visually + 直观解释 + + + + Mode + 模式 + + + + None selected + 未选中内容 + + + + Request + 请求 + + + + Note: AI responses can be inaccurate + 注意:AI的回答可能并不完全准确 + + + + Ask + 回答 + + + + MFilterByButton + + + Filters + 过滤 + + + + MFilterByPopup + + + e.g. Uncle bob + 例:Uncle bob + + + + Authors + 作者 + + + + e.g. 2d ago + 例:2d ago + + + + Added + 添加日期 + + + + Read + 已读完 + + + + Unread + 未读完 + + + + Format + 格式 + + + + Any + 任意 + + + + Pdf + Pdf + + + + Epub + Epub + + + + Mobi + Mobi + + + + Txt + Txt + + + + Only Books + 仅书籍 + + + + Only Files + 仅文件 + + + + Apply Filter + 应用 + + + + MForgotPasswordPage + + + Forgot Password + 忘记密码 + + + + Enter your email and we'll send you a link to reset your password + 输入您的邮箱,我们将向您发送一条链接来重设您的密码 + + + + Send Email + 发送邮件 + + + + Back to Login + 登录 + + + + Email sent! Keep an eye on your inbox + 邮件已发送,请注意查收 + + + + MFreeBook + + + .jpeg + .jpeg + + + + MFreeBooksPage + + + No books were found + 未找到任何书籍 + + + + Couldn't load free books. Please, check your network connection + 无法加载免费书籍。请检查您的网络连接 + + + + Free books + 免费书籍 + + + + Choose from over 70,000 books + 在超过 7,0000 本书中选择 + + + + MHomePage + + + A new version is available! + 有新版本可用! + + + + Update Now + 立即更新 + + + + Home + As in 'Home Page', might be closer to 'Start' in other languages + 主页 + + + + You have %1 books + 您有 %1 本书 + + + + Add books + 添加书籍 + + + + Remove Book? + 移除此书? + + + + Deleting a book is a permanent action, no one will be + able to restore it afterwards! + 删除书籍是永久性操作,删除后将无法恢复! + + + + Remove from Device + 从设备上移除 + + + + Delete Everywhere + 从所有地方删除 + + + + Save + 保存 + + + + Limit Reached + 到达限制 + + + + You have reached your upload limit. +Delete unused books to free up space or upgrade. + 您已达到您的上传限制。删除未使用的书籍以释放空间或更新。 + + + + + Ok + + + + + Upgrade + 更新 + + + + Unsupported File + 不支持的文件 + + + + Oops! This file is not supported by Librum. + 哎呀!Librum 不支持这个文件 + + + + Import + 导入 + + + + All files + 所有文件 + + + + + + files + 文件 + + + + MLoginPage + + + Welcome back! + 欢迎回来! + + + + Log into your account + 登录您的账户 + + + + Email + 电子邮箱 + + + + Password + 密码 + + + + Remember me + 记住我 + + + + Forgot password? + 忘记密码? + + + + Login + 登录 + + + + Don't have an account? Register + 还没有账户?注册 + + + + We're Sorry + 未尝抱歉 + + + + Logging you in failed, please try again later. + 登录失败,请稍候重试。 + + + + Ok + + + + + Report + 报告 + + + + MManageTagsPopup + + + TAGS + 标签 + + + + Manage Tags + 管理标签 + + + + Done + 完成 + + + + MNoBookSatisfiesFilterItem + + + No book satisfies the filter conditions + 没有书籍满足过滤条件 + + + + Remove Filters + 移除过滤 + + + + MOnOffToggle + + + OFF + OFF + + + + ON + ON + + + + MProfilePopup + + + Sync + 同步 + + + + Manage Profile + 管理个人资料 + + + + Logout + 登出 + + + + MReadingOptionsPopup + + + Invert colors + 反转颜色 + + + + Sync book + 同步书籍 + + + + More options + 更多选项 + + + + Save + 保存 + + + + MReadingSearchbar + + + Options + 选项 + + + + Find + 查找 + + + + Next + 下一个 + + + + Previous + 上一个 + + + + MReadingSearchbarOptionsPopup + + + From start + 从开始处 + + + + Case sensitive + 匹配大小写 + + + + Whole words + 全字匹配 + + + + MReadingToolBar + + + Unknown name + 未知名称 + + + + of + As in 21 "of" 400 + / + + + + MRecordKeyBox + + + Key + As in key on the keyboard + 快捷键 + + + + Press to record + As in recording a key that is pressed on the keyboard + 按下以输入 + + + + MRegisterPage + + + Welcome! + 欢迎! + + + + Your credentials are only used to authenticate yourself. Everything will be stored in a secure database. + 您的凭证仅用于验证您的身份。所有信息都将被存储在一个安全的数据库中。 + + + + First name + + + + + Last name + + + + + Email + 电子邮箱 + + + + Password + 密码 + + + + Confirmation password + 确认密码 + + + + Let's start + 让我们开始 + + + + Already have an account? Login + 已有账户?登录 + + + + Confirm Your Email + 确认您的邮箱 + + + + You're are almost ready to go! +Confirm your email by clicking the link we sent you. + 已经快好了!点击我们发送给您的链接以确认你的邮箱。 + + + + Resend + 重新发送 + + + + Passwords don't match + 密码不匹配 + + + + MSearchButton + + + Search for books + 搜索书籍 + + + + MSelectProfilePictureArea + + + Click to select an image or drop it into in this area + 点击选择一张图片或拖动图片到此区域 + + + + All files + 全部文件 + + + + files + 文件 + + + + MSelectionOptionsPopup + + + Copy + 复制 + + + + Highlight + 高亮 + + + + Look Up + 查找 + + + + Explain + 解释 + + + + Remove + 移除 + + + + MSettingsSidebar + + + Settings + 设置 + + + + GLOBAL SETTINGS + Keep it capitalized + 全局设置 + + + + About + 关于 + + + + Appearance + 外观 + + + + Behavior + 行为 + + + + Shortcuts + 快捷键 + + + + Updates + 更新 + + + + USER & ACCOUNT + Keep it capitalized + 用户和账户 + + + + Account + 账户 + + + + Storage + 存储 + + + + Support us + 支持我们 + + + + MShortcutDelegate + + + None + + + + + MShortcutsPage + + + Shortcuts + 快捷键 + + + + Make your own experience + 定制您的体验 + + + + Edit shortcut + 编辑快捷键 + + + + ACTION + Keep it capitalized + 动作 + + + + SHORTCUTS + Keep it capitalized + 快捷键 + + + + Search for shortcuts + 搜索快捷键 + + + + MSidebar + + + Free books + 免费书籍 + + + + Home + 主页 + + + + Statistics + 统计数据 + + + + Add-ons + 插件 + + + + Settings + 设置 + + + + MSortByButton + + + Sort + 排序 + + + + MSortByPopup + + + Recently added + 最近添加 + + + + Recently read + 最近阅读 + + + + Progress + 进度 + + + + Book (A-Z) + 书名 (A-Z) + + + + Authors (A-Z) + 作者 (A-Z) + + + + MStatisticsPage + + + Statistics Page + 统计数据页面 + + + + Currently in Development + 正在开发中 + + + + MStoragePage + + + Storage + 存储 + + + + Your storage + 您的存储空间 + + + + + Upgrade + 升级 + + + + YOUR TIER + Keep capitalized ("TIER" as in subscription) + 您的套餐 + + + + BASIC + Keep capitalized ("BASIC" is the name of the tier) + 基础 + + + + See why we offer multiple tiers + 了解我们为什么提供多个套餐 + + + + USED STORAGE + Keep capitalized + 已用存储空间 + + + + Used Storage + 已用存储空间 + + + + Remaining Storage + 剩余存储空间 + + + + YOUR BOOKS + Keep capitalized + 您的书籍 + + + + Books in your Library + 您的书籍 + + + + Upgrade Your Account + 升级您的账户 + + + + We don't offer upgrading options at the moment. + 我们当前不提供升级选项。 + + + + If you require additional storage, please contact us at + 如果您需要额外的额外的存储空间,请联系我们: + + + + Close + 关闭 + + + + Email Us + 发送邮件 + + + + MSupportUsPage + + + + Support us + 支持我们 + + + + Thanks for considering + 感谢您的考虑 + + + + We are a small team of opensource developers creating apps for the community. We love +working on fun projects, supporting our community and trying to make the world a better place. + 我们是一个由开源工作者组成的小团队,为社区开发应用程序。我们喜欢做有趣的项目以支持我们的社区,并努力让世界变得更美好。 + + + + If you feel like supporting us and our projects, feel free to support us: + 如果您想支持我们和我们的项目,请随意支持我们: + + + + You can support us in many other ways as well, if you are a developer or a designer, feel free to + 如果您是开发者或设计师,您也可以通过其他的方式支持我们。 + + + + contribute to Librum + 捐助 Librum + + + + If you are not, you can still help us by spreading the word about Librum. + 如果不,您仍然可以通过宣传 Librum 以帮助我们。 + + + + Thank you for your support. We hope you enjoy Librum! + 感谢您的支持。希望您可以享受 Librum! + + + + MTagSelectorButton + + + Tags + 标签 + + + + MTagSelectorPopup + + + Select + 选择 + + + + Rename + 重命名 + + + + Delete + 删除 + + + + MTitle + + + Title + 标题 + + + + Description + 描述 + + + + MToolbar + + + Remove Filters + 移除过滤 + + + + Remove Tags + 移除标签 + + + + You are offline + 您已离线 + + + + Your library is being synchronized with the cloud + 您的书库正在和云端同步 + + + + MUpToDate + + + You are up to date! + 您已经更新到最新版本了! + + + + Make sure to check for updates regularly, so you dont miss out on any great features. + 请定期检查更新,这样您就不会错过任何好用的功能 + + + + Your current version is: + 您当前的版本为: + + + + See our latest changes at: + 查看最新变化: + + + + MUpdatesAvailable + + + A new update is available! + 有新版本可用! + + + + Download the new version to get great new improvements. + 下载最新版本以获得重大改进 + + + + The newest version is: + 最新版本为: + + + + Update + 更新 + + + + See the exact changes on our website at: + 请查看我们网站上的具体变化: + + + + Updating on Linux + Linux 版本更新 + + + + Please use your package manager to update Librum or download the newest version from our + 请使用您的包管理器更新 Librum 或下载最新版本 + + + + + website + 网站 + + + + + Close + 关闭 + + + + + Email Us + 使用邮箱联系我们 + + + + The Update Failed + 更新失败 + + + + Please try again later or download the newest version from our + 请稍候重试或下载最新版本 + + + + MUpdatesPage + + + Updates + 更新 + + + + Any new update? + 有新的更新吗? + + + + MWarningPopup + + + Accept + 接受 + + + + Decline + 拒绝 + + + + Do you Accept? + 您是否接受? + + + + Message + 消息 + + + + MWindowsUpdatingPopup + + + Updating + 更新中 + + + + Downloading + 下载中 + + + + main + + + Librum - Your ebook reader + Librum - 电子书阅读器 + + + From 4daf151527fc637cb8c289a050a6c86da74397eb Mon Sep 17 00:00:00 2001 From: DavidLazarescu Date: Mon, 11 Dec 2023 19:17:34 +0100 Subject: [PATCH 09/20] Added zh translation to language model and added missing translations --- src/presentation/CMakeLists.txt | 1 + src/presentation/LanguageModel.qml | 4 + .../{librum_zh_cn.ts => librum_zh.ts} | 759 +++++++++--------- 3 files changed, 392 insertions(+), 372 deletions(-) rename src/presentation/translations/{librum_zh_cn.ts => librum_zh.ts} (71%) diff --git a/src/presentation/CMakeLists.txt b/src/presentation/CMakeLists.txt index 4c14a88f0..baaa3eb0c 100644 --- a/src/presentation/CMakeLists.txt +++ b/src/presentation/CMakeLists.txt @@ -19,6 +19,7 @@ set(translation_files translations/librum_en.ts translations/librum_de.ts translations/librum_ru.ts + translations/librum_zh.ts ) # Translations for the application diff --git a/src/presentation/LanguageModel.qml b/src/presentation/LanguageModel.qml index 31c9dc72b..24ddd6a75 100644 --- a/src/presentation/LanguageModel.qml +++ b/src/presentation/LanguageModel.qml @@ -17,4 +17,8 @@ ListModel { text: "Русский" code: "ru" } + ListElement { + text: "中文" + code: "zh" + } } diff --git a/src/presentation/translations/librum_zh_cn.ts b/src/presentation/translations/librum_zh.ts similarity index 71% rename from src/presentation/translations/librum_zh_cn.ts rename to src/presentation/translations/librum_zh.ts index daea58eeb..3cb57172f 100644 --- a/src/presentation/translations/librum_zh_cn.ts +++ b/src/presentation/translations/librum_zh.ts @@ -6,74 +6,74 @@ About - 关于 + 关于 About this application - 关于此应用 + 关于此应用 Details - 详细信息 + 详细信息 CURRENT VERSION Keep it capitalized - 当前版本 + 当前版本 QT VERSION Keep it capitalized - QT 版本 + QT 版本 Up-to date - 已为最新 + 已为最新 Creator - 作者 + 作者 COMPANY NAME Keep it capitalized - 公司名称 + 公司名称 WEBSITE Keep it capitalized - 官方网站 + 官方网站 CONTACT Keep it capitalized - 联系我们 + 联系我们 GITHUB Keep it capitalized - GITHUB + GITHUB This App - 此应用 + 此应用 Librum is here for everyone who just wants to enjoy a good book. We hope you have a great time using it! Feel free to leave us a rating and some feedback. - Librum 为每个想享受一本好书的人而存在。 + Librum 为每个想享受一本好书的人而存在。 我们希望您在使用时度过一段美好的时光!不妨给我们留下评价和一些反馈。 @@ -83,22 +83,22 @@ We hope you have a great time using it! Feel free to leave us a rating and some I accept the Make sure to translate the following words together to make a logical sentence - 我同意 + 我同意 Terms of Service - 服务条款 + 服务条款 and the - + Privacy Policy - 隐私政策 + 隐私政策 @@ -106,109 +106,109 @@ We hope you have a great time using it! Feel free to leave us a rating and some Account - 账户 + 账户 Save - 保存 + 保存 Profile - 个人资料 + 个人资料 First name - + Last name - + Email - 电子邮箱 + 电子邮箱 Change password - 更改密码 + 更改密码 Password - 密码 + 密码 Password confirmation - 确认密码 + 确认密码 Your data - 您的数据 + 您的数据 Analyse your reading to make better recommendations - 分析您的阅读以提供更好的推荐 + 分析您的阅读以提供更好的推荐 Anonymously share information about the books you read to help us improve Librum - 匿名分享您阅读的书籍信息以帮助我们改进 Librum + 匿名分享您阅读的书籍信息以帮助我们改进 Librum Collect data on crashes so that we can prevent it from happening again - 收集崩溃信息以避免再次发生 + 收集崩溃信息以避免再次发生 Collect data to display in your statistics - 收集信息以在您的统计数据中展示 + 收集信息以在您的统计数据中展示 Your Account - 您的账户 + 您的账户 Logout - 登出 + 登出 Delete Your Account - 删除您的账户 + 删除您的账户 Whoops - 哎呀 + 哎呀 It looks like you forgot to save your changes, are you sure that you dont want to save them? - 看起来您忘记了保存您的修改,是否放弃修改? + 看起来您忘记了保存您的修改,是否放弃修改? Don't save - 不保存 + 不保存 Passwords don't match! - 密码不匹配! + 密码不匹配! @@ -216,12 +216,12 @@ We hope you have a great time using it! Feel free to leave us a rating and some Add-ons Page - 插件页面 + 插件页面 Currently in Development - 正在开发中 + 正在开发中 @@ -229,37 +229,37 @@ We hope you have a great time using it! Feel free to leave us a rating and some Edit Shortcuts - 编辑快捷键 + 编辑快捷键 Action - 动作 + 动作 None selected - 未选择 + 未选择 The shortcut - 快捷键 + 快捷键 is already used for - 已被此动作使用: + 已被此动作使用: Apply - 应用 + 应用 Cancel - 取消 + 取消 @@ -267,7 +267,7 @@ We hope you have a great time using it! Feel free to leave us a rating and some Add a tag... - 添加一个标签... + 添加一个标签... @@ -275,17 +275,17 @@ We hope you have a great time using it! Feel free to leave us a rating and some Add - 添加 + 添加 Rename - 重命名 + 重命名 Delete - 删除 + 删除 @@ -293,113 +293,113 @@ We hope you have a great time using it! Feel free to leave us a rating and some Appearance - 外观 + 外观 Make your own experience - 定制您的体验 + 定制您的体验 Restore Defaults - 恢复默认 + 恢复默认 Display - 显示 + 显示 Theme - 主题 + 主题 Dark - Dark + 黑暗 Light - Light + 明亮 Page Color Mode - 页面颜色模式 + 页面颜色模式 Normal - 常规 + 常规 Inverted - 反转 + 反转 Language - 语言 + 语言 - + Reading - 阅读 + 阅读 - + Page spacing - 页间距 + 页间距 - + Display book title in titlebar - 在标题栏显示书名 + 在标题栏显示书名 - + Default Zoom - 默认缩放 + 默认缩放 - + Highlights - 高亮 + 高亮 - + Colors - 颜色 + 颜色 - + Opacity - 不透明度 + 不透明度 - + Reset settings? - 重置设置? + 重置设置? - + Resetting your settings is a permanent action, there will be no way to restore them! - 重置您的设置是一个永久性的操作,您将无法恢复! + 重置您的设置是一个永久性的操作,您将无法恢复! - + No, Keep - 保持 + 保持 - + Yes, Reset - 重置 + 重置 @@ -407,68 +407,83 @@ We hope you have a great time using it! Feel free to leave us a rating and some Behavior - 行为 + 行为 Change the way Librum works - 修改 Librum 的工作方式 + 修改 Librum 的工作方式 Restore Defaults - 恢复默认 + 恢复默认 Books - 书籍 + 书籍 Cursor mode - 鼠标 + 鼠标 Hidden after delay - 超时后隐藏 + 超时后隐藏 Always visible - 总是可见 + 总是可见 Hide cursor after delay - 超时时间 + 超时时间 ms - ms + ms + + + + Include new lines in copied text + 在复制的文本中包含新行 + + + + ON + - + + OFF + + + + Reset settings? - 重置设置? + 重置设置? - + Resetting your settings is a permanent action, there will be no way to restore them! - 重置您的设置是一个永久性的操作,您将无法恢复! + 重置您的设置是一个永久性的操作,您将无法恢复! - + No, Keep - 保持 + 保持 - + Yes, Reset - 重置 + 重置 @@ -477,13 +492,13 @@ We hope you have a great time using it! Feel free to leave us a rating and some Unknown - 未知 + 未知 Your book has not been uploaded to the cloud. Either you are offline, or your storage is full. - 您的书籍未上传到云端,您已离线或您的储存空间已满。 + 您的书籍未上传到云端,您已离线或您的储存空间已满。 @@ -491,23 +506,23 @@ Either you are offline, or your storage is full. Book details - 详细信息 + 详细信息 Change - 修改 + 修改 Delete - 删除 + 删除 Title - 标题 + 标题 @@ -516,79 +531,79 @@ Either you are offline, or your storage is full. Unknown - 未知 + 未知 Authors - 作者 + 作者 Pages - 页数 + 页数 Language - 语言 + 语言 Document creator - 创作者 + 创作者 Creation date - 创建日期 + 创建日期 Format - 格式 + 格式 Document size - 文件大小 + 文件大小 Added - 添加日期 + 添加日期 Last opened - 最后打开 + 最后打开 Apply - 应用 + 应用 Cancel - 取消 + 取消 Select - 选择 + 选择 All files - 全部文件 + 全部文件 files - 文件 + 文件 @@ -596,38 +611,38 @@ Either you are offline, or your storage is full. Download - 下载 + 下载 Read book - 阅读此书 + 阅读此书 Book details - 详细信息 + 详细信息 Save to files - 保存到文件 + 保存到文件 Manage tags - 管理标签 + 管理标签 Mark as read If this is too long in any language, use "Read" (past form) instead - 标记为已读 + 标记为已读 Remove book - 移除此书 + 移除此书 @@ -648,23 +663,23 @@ Either you are offline, or your storage is full. 添加书签 - + New Bookmark 新书签 - + Follow Context: "Follow" the bookmark (go to its page) 前往 - + Rename 重命名 - + Delete 删除 @@ -688,7 +703,7 @@ Either you are offline, or your storage is full. Any - 任意 + 任意 @@ -696,37 +711,37 @@ Either you are offline, or your storage is full. Confirm Account Deletion - 确认删除账户 + 确认删除账户 - + Deleting your account is an irreversible action.<br>Once you delete your account, there is <b>no</b> going back. Please be certain. - 删除您的账户是不可逆的操作。<br>一旦您删除了您的账户,将<b>无法</b>挽回,请确认。 + 删除您的账户是不可逆的操作。<br>一旦您删除了您的账户,将<b>无法</b>挽回,请确认。 - + Your Email - 您的邮箱 + 您的邮箱 - + Confirm the deletion by entering your Account's email. - 输入您的邮箱以确认删除。 + 输入您的邮箱以确认删除。 - + Cancel - 取消 + 取消 - + Delete - 删除 + 删除 - + Your email is wrong - 邮箱错误 + 邮箱错误 @@ -734,22 +749,22 @@ Either you are offline, or your storage is full. Search - 搜索 + 搜索 No definitions found - 未找到定义 + 未找到定义 Search online - 在线搜索 + 在线搜索 Source - 来源 + 来源 @@ -757,42 +772,42 @@ Either you are offline, or your storage is full. Download book - 下载此书 + 下载此书 Title - 标题 + 标题 Authors - 作者 + 作者 Language - 语言 + 语言 Downloads - 下载次数 + 下载次数 Format - 格式 + 格式 Download - 下载 + 下载 Cancel - 取消 + 取消 @@ -800,12 +815,12 @@ Either you are offline, or your storage is full. Left - + Right - + @@ -813,12 +828,12 @@ Either you are offline, or your storage is full. Quite empty here, what about adding your first book? - 这里空无一物,尝试添加您的第一本书? + 这里空无一物,尝试添加您的第一本书? Add book - 添加书籍 + 添加书籍 @@ -827,77 +842,77 @@ Either you are offline, or your storage is full. You have reached your daily limit. Make sure that the words make a valid sentence - 您已到达当日限制。 + 您已到达当日限制。 Click - 点击 + 点击 here - 此处 + 此处 to learn more. - 发现更多。 + 发现更多。 Oops! The text is too long. Please shorten your selection. - 哎呀!文本太长了,请少选一些。 + 哎呀!文本太长了,请少选一些。 Explain - 解释 + 解释 Explain like I'm five - 通俗解释 + 通俗解释 Summarize - 总结 + 总结 Give more information - 提供更多信息 + 提供更多信息 Explain visually - 直观解释 + 直观解释 Mode - 模式 + 模式 None selected - 未选中内容 + 未选中内容 Request - 请求 + 请求 Note: AI responses can be inaccurate - 注意:AI的回答可能并不完全准确 + 注意:AI的回答可能并不完全准确 Ask - 回答 + 回答 @@ -905,7 +920,7 @@ Either you are offline, or your storage is full. Filters - 过滤 + 过滤 @@ -913,77 +928,77 @@ Either you are offline, or your storage is full. e.g. Uncle bob - 例:Uncle bob + 例:Uncle bob Authors - 作者 + 作者 e.g. 2d ago - 例:2d ago + 例:2d ago Added - 添加日期 + 添加日期 Read - 已读完 + 已读完 Unread - 未读完 + 未读完 Format - 格式 + 格式 Any - 任意 + 任意 Pdf - Pdf + Pdf Epub - Epub + Epub Mobi - Mobi + Mobi Txt - Txt + Txt Only Books - 仅书籍 + 仅书籍 Only Files - 仅文件 + 仅文件 Apply Filter - 应用 + 应用 @@ -991,27 +1006,27 @@ Either you are offline, or your storage is full. Forgot Password - 忘记密码 + 忘记密码 Enter your email and we'll send you a link to reset your password - 输入您的邮箱,我们将向您发送一条链接来重设您的密码 + 输入您的邮箱,我们将向您发送一条链接来重设您的密码 Send Email - 发送邮件 + 发送邮件 Back to Login - 登录 + 登录 Email sent! Keep an eye on your inbox - 邮件已发送,请注意查收 + 邮件已发送,请注意查收 @@ -1019,7 +1034,7 @@ Either you are offline, or your storage is full. .jpeg - .jpeg + .jpeg @@ -1027,22 +1042,22 @@ Either you are offline, or your storage is full. No books were found - 未找到任何书籍 + 未找到任何书籍 Couldn't load free books. Please, check your network connection - 无法加载免费书籍。请检查您的网络连接 + 无法加载免费书籍。请检查您的网络连接 Free books - 免费书籍 + 免费书籍 Choose from over 70,000 books - 在超过 7,0000 本书中选择 + 在超过 7,0000 本书中选择 @@ -1050,103 +1065,103 @@ Either you are offline, or your storage is full. A new version is available! - 有新版本可用! + 有新版本可用! Update Now - 立即更新 + 立即更新 Home As in 'Home Page', might be closer to 'Start' in other languages - 主页 + 主页 You have %1 books - 您有 %1 本书 + 您有 %1 本书 Add books - 添加书籍 + 添加书籍 Remove Book? - 移除此书? + 移除此书? Deleting a book is a permanent action, no one will be able to restore it afterwards! - 删除书籍是永久性操作,删除后将无法恢复! + 删除书籍是永久性操作,删除后将无法恢复! Remove from Device - 从设备上移除 + 从设备上移除 Delete Everywhere - 从所有地方删除 + 从所有地方删除 Save - 保存 + 保存 Limit Reached - 到达限制 + 到达限制 You have reached your upload limit. Delete unused books to free up space or upgrade. - 您已达到您的上传限制。删除未使用的书籍以释放空间或更新。 + 您已达到您的上传限制。删除未使用的书籍以释放空间或更新。 Ok - + Upgrade - 更新 + 更新 Unsupported File - 不支持的文件 + 不支持的文件 Oops! This file is not supported by Librum. - 哎呀!Librum 不支持这个文件 + 哎呀!Librum 不支持这个文件 Import - 导入 + 导入 All files - 所有文件 + 所有文件 files - 文件 + 文件 @@ -1154,62 +1169,62 @@ Delete unused books to free up space or upgrade. Welcome back! - 欢迎回来! + 欢迎回来! Log into your account - 登录您的账户 + 登录您的账户 Email - 电子邮箱 + 电子邮箱 Password - 密码 + 密码 Remember me - 记住我 + 记住我 Forgot password? - 忘记密码? + 忘记密码? Login - 登录 + 登录 Don't have an account? Register - 还没有账户?注册 + 还没有账户?注册 We're Sorry - 未尝抱歉 + 未尝抱歉 Logging you in failed, please try again later. - 登录失败,请稍候重试。 + 登录失败,请稍候重试。 Ok - + Report - 报告 + 报告 @@ -1217,17 +1232,17 @@ Delete unused books to free up space or upgrade. TAGS - 标签 + 标签 Manage Tags - 管理标签 + 管理标签 Done - 完成 + 完成 @@ -1235,12 +1250,12 @@ Delete unused books to free up space or upgrade. No book satisfies the filter conditions - 没有书籍满足过滤条件 + 没有书籍满足过滤条件 Remove Filters - 移除过滤 + 移除过滤 @@ -1248,12 +1263,12 @@ Delete unused books to free up space or upgrade. OFF - OFF + ON - ON + @@ -1261,17 +1276,17 @@ Delete unused books to free up space or upgrade. Sync - 同步 + 同步 Manage Profile - 管理个人资料 + 管理个人资料 Logout - 登出 + 登出 @@ -1279,22 +1294,22 @@ Delete unused books to free up space or upgrade. Invert colors - 反转颜色 + 反转颜色 Sync book - 同步书籍 + 同步书籍 More options - 更多选项 + 更多选项 Save - 保存 + 保存 @@ -1302,22 +1317,22 @@ Delete unused books to free up space or upgrade. Options - 选项 + 选项 Find - 查找 + 查找 Next - 下一个 + 下一个 Previous - 上一个 + 上一个 @@ -1325,17 +1340,17 @@ Delete unused books to free up space or upgrade. From start - 从开始处 + 从开始处 Case sensitive - 匹配大小写 + 匹配大小写 Whole words - 全字匹配 + 全字匹配 @@ -1343,13 +1358,13 @@ Delete unused books to free up space or upgrade. Unknown name - 未知名称 + 未知名称 of As in 21 "of" 400 - / + / @@ -1358,13 +1373,13 @@ Delete unused books to free up space or upgrade. Key As in key on the keyboard - 快捷键 + 快捷键 Press to record As in recording a key that is pressed on the keyboard - 按下以输入 + 按下以输入 @@ -1372,68 +1387,68 @@ Delete unused books to free up space or upgrade. Welcome! - 欢迎! + 欢迎! Your credentials are only used to authenticate yourself. Everything will be stored in a secure database. - 您的凭证仅用于验证您的身份。所有信息都将被存储在一个安全的数据库中。 + 您的凭证仅用于验证您的身份。所有信息都将被存储在一个安全的数据库中。 First name - + Last name - + Email - 电子邮箱 + 电子邮箱 Password - 密码 + 密码 Confirmation password - 确认密码 + 确认密码 Let's start - 让我们开始 + 让我们开始 Already have an account? Login - 已有账户?登录 + 已有账户?登录 Confirm Your Email - 确认您的邮箱 + 确认您的邮箱 You're are almost ready to go! Confirm your email by clicking the link we sent you. - 已经快好了!点击我们发送给您的链接以确认你的邮箱。 + 已经快好了!点击我们发送给您的链接以确认你的邮箱。 Resend - 重新发送 + 重新发送 Passwords don't match - 密码不匹配 + 密码不匹配 @@ -1441,7 +1456,7 @@ Confirm your email by clicking the link we sent you. Search for books - 搜索书籍 + 搜索书籍 @@ -1449,17 +1464,17 @@ Confirm your email by clicking the link we sent you. Click to select an image or drop it into in this area - 点击选择一张图片或拖动图片到此区域 + 点击选择一张图片或拖动图片到此区域 All files - 全部文件 + 全部文件 files - 文件 + 文件 @@ -1467,27 +1482,27 @@ Confirm your email by clicking the link we sent you. Copy - 复制 + 复制 Highlight - 高亮 + 高亮 Look Up - 查找 + 查找 Explain - 解释 + 解释 Remove - 移除 + 移除 @@ -1495,59 +1510,59 @@ Confirm your email by clicking the link we sent you. Settings - 设置 + 设置 GLOBAL SETTINGS Keep it capitalized - 全局设置 + 全局设置 About - 关于 + 关于 Appearance - 外观 + 外观 Behavior - 行为 + 行为 Shortcuts - 快捷键 + 快捷键 Updates - 更新 + 更新 USER & ACCOUNT Keep it capitalized - 用户和账户 + 用户和账户 Account - 账户 + 账户 Storage - 存储 + 存储 Support us - 支持我们 + 支持我们 @@ -1555,7 +1570,7 @@ Confirm your email by clicking the link we sent you. None - + @@ -1563,34 +1578,34 @@ Confirm your email by clicking the link we sent you. Shortcuts - 快捷键 + 快捷键 Make your own experience - 定制您的体验 + 定制您的体验 Edit shortcut - 编辑快捷键 + 编辑快捷键 ACTION Keep it capitalized - 动作 + 动作 SHORTCUTS Keep it capitalized - 快捷键 + 快捷键 Search for shortcuts - 搜索快捷键 + 搜索快捷键 @@ -1598,27 +1613,27 @@ Confirm your email by clicking the link we sent you. Free books - 免费书籍 + 免费书籍 Home - 主页 + 主页 Statistics - 统计数据 + 统计数据 Add-ons - 插件 + 插件 Settings - 设置 + 设置 @@ -1626,7 +1641,7 @@ Confirm your email by clicking the link we sent you. Sort - 排序 + 排序 @@ -1634,27 +1649,27 @@ Confirm your email by clicking the link we sent you. Recently added - 最近添加 + 最近添加 Recently read - 最近阅读 + 最近阅读 Progress - 进度 + 进度 Book (A-Z) - 书名 (A-Z) + 书名 (A-Z) Authors (A-Z) - 作者 (A-Z) + 作者 (A-Z) @@ -1662,12 +1677,12 @@ Confirm your email by clicking the link we sent you. Statistics Page - 统计数据页面 + 统计数据页面 Currently in Development - 正在开发中 + 正在开发中 @@ -1675,87 +1690,87 @@ Confirm your email by clicking the link we sent you. Storage - 存储 + 存储 Your storage - 您的存储空间 + 您的存储空间 Upgrade - 升级 + 升级 YOUR TIER Keep capitalized ("TIER" as in subscription) - 您的套餐 + 您的套餐 BASIC Keep capitalized ("BASIC" is the name of the tier) - 基础 + 基础 See why we offer multiple tiers - 了解我们为什么提供多个套餐 + 了解我们为什么提供多个套餐 USED STORAGE Keep capitalized - 已用存储空间 + 已用存储空间 Used Storage - 已用存储空间 + 已用存储空间 Remaining Storage - 剩余存储空间 + 剩余存储空间 YOUR BOOKS Keep capitalized - 您的书籍 + 您的书籍 Books in your Library - 您的书籍 + 您的书籍 Upgrade Your Account - 升级您的账户 + 升级您的账户 We don't offer upgrading options at the moment. - 我们当前不提供升级选项。 + 我们当前不提供升级选项。 If you require additional storage, please contact us at - 如果您需要额外的额外的存储空间,请联系我们: + 如果您需要额外的额外的存储空间,请联系我们 Close - 关闭 + 关闭 Email Us - 发送邮件 + 发送邮件 @@ -1764,43 +1779,43 @@ Confirm your email by clicking the link we sent you. Support us - 支持我们 + 支持我们 Thanks for considering - 感谢您的考虑 + 感谢您的考虑 We are a small team of opensource developers creating apps for the community. We love working on fun projects, supporting our community and trying to make the world a better place. - 我们是一个由开源工作者组成的小团队,为社区开发应用程序。我们喜欢做有趣的项目以支持我们的社区,并努力让世界变得更美好。 + 我们是一个由开源工作者组成的小团队,为社区开发应用程序。我们喜欢做有趣的项目以支持我们的社区,并努力让世界变得更美好。 If you feel like supporting us and our projects, feel free to support us: - 如果您想支持我们和我们的项目,请随意支持我们: + 如果您想支持我们和我们的项目,请随意支持我们: You can support us in many other ways as well, if you are a developer or a designer, feel free to - 如果您是开发者或设计师,您也可以通过其他的方式支持我们。 + 如果您是开发者或设计师,您也可以通过其他的方式支持我们。 contribute to Librum - 捐助 Librum + 捐助 Librum If you are not, you can still help us by spreading the word about Librum. - 如果不,您仍然可以通过宣传 Librum 以帮助我们。 + 如果不,您仍然可以通过宣传 Librum 以帮助我们。 Thank you for your support. We hope you enjoy Librum! - 感谢您的支持。希望您可以享受 Librum! + 感谢您的支持。希望您可以享受 Librum! @@ -1808,7 +1823,7 @@ working on fun projects, supporting our community and trying to make the world a Tags - 标签 + 标签 @@ -1816,17 +1831,17 @@ working on fun projects, supporting our community and trying to make the world a Select - 选择 + 选择 Rename - 重命名 + 重命名 Delete - 删除 + 删除 @@ -1834,12 +1849,12 @@ working on fun projects, supporting our community and trying to make the world a Title - 标题 + 标题 Description - 描述 + 描述 @@ -1847,22 +1862,22 @@ working on fun projects, supporting our community and trying to make the world a Remove Filters - 移除过滤 + 移除过滤 Remove Tags - 移除标签 + 移除标签 You are offline - 您已离线 + 您已离线 Your library is being synchronized with the cloud - 您的书库正在和云端同步 + 您的书库正在和云端同步 @@ -1870,22 +1885,22 @@ working on fun projects, supporting our community and trying to make the world a You are up to date! - 您已经更新到最新版本了! + 您已经更新到最新版本了! Make sure to check for updates regularly, so you dont miss out on any great features. - 请定期检查更新,这样您就不会错过任何好用的功能 + 请定期检查更新,这样您就不会错过任何好用的功能 Your current version is: - 您当前的版本为: + 您当前的版本为: See our latest changes at: - 查看最新变化: + 查看最新变化: @@ -1893,65 +1908,65 @@ working on fun projects, supporting our community and trying to make the world a A new update is available! - 有新版本可用! + 有新版本可用! Download the new version to get great new improvements. - 下载最新版本以获得重大改进 + 下载最新版本以获得重大改进 The newest version is: - 最新版本为: + 最新版本为: Update - 更新 + 更新 See the exact changes on our website at: - 请查看我们网站上的具体变化: + 请查看我们网站上的具体变化: Updating on Linux - Linux 版本更新 + Linux 版本更新 Please use your package manager to update Librum or download the newest version from our - 请使用您的包管理器更新 Librum 或下载最新版本 + 请使用您的包管理器更新 Librum 或下载最新版本 website - 网站 + 网站 Close - 关闭 + 关闭 Email Us - 使用邮箱联系我们 + 使用邮箱联系我们 The Update Failed - 更新失败 + 更新失败 Please try again later or download the newest version from our - 请稍候重试或下载最新版本 + 请稍候重试或下载最新版本 @@ -1959,12 +1974,12 @@ working on fun projects, supporting our community and trying to make the world a Updates - 更新 + 更新 Any new update? - 有新的更新吗? + 有新的更新吗? @@ -1972,22 +1987,22 @@ working on fun projects, supporting our community and trying to make the world a Accept - 接受 + 接受 Decline - 拒绝 + 拒绝 Do you Accept? - 您是否接受? + 您是否接受? Message - 消息 + 消息 @@ -1995,12 +2010,12 @@ working on fun projects, supporting our community and trying to make the world a Updating - 更新中 + 更新中 Downloading - 下载中 + 下载中 @@ -2008,7 +2023,7 @@ working on fun projects, supporting our community and trying to make the world a Librum - Your ebook reader - Librum - 电子书阅读器 + Librum - 电子书阅读器 From db43a0285b22c183fb0568641348a58479fb5b25 Mon Sep 17 00:00:00 2001 From: DavidLazarescu Date: Mon, 11 Dec 2023 19:25:23 +0100 Subject: [PATCH 10/20] Fixed issues when switching to english --- src/adapters/controllers/app_info_controller.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/adapters/controllers/app_info_controller.cpp b/src/adapters/controllers/app_info_controller.cpp index 5cc013b71..0a2f83b8f 100644 --- a/src/adapters/controllers/app_info_controller.cpp +++ b/src/adapters/controllers/app_info_controller.cpp @@ -145,7 +145,9 @@ bool AppInfoController::switchToLanguage(const QString& language) return false; } - if(!QGuiApplication::installTranslator(&m_translator)) + // The english translation is empty since it is the default language. Thus + // it causes an error when trying to switch to english. Ignore it. + if(!QGuiApplication::installTranslator(&m_translator) && language != "en") { qWarning() << "Failed installing translator for language: " << language; return false; From 4f76ce266048fef361a0477cb8bc6edbab443a17 Mon Sep 17 00:00:00 2001 From: David Lazarescu <69865187+DavidLazarescu@users.noreply.github.com> Date: Mon, 11 Dec 2023 19:53:58 +0100 Subject: [PATCH 11/20] Improved the translation section --- README.md | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index bd72fa813..41ec61cc6 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,28 @@ If you want to build Librum from source, follow the instructions [here](#build-g # Translations -Do you want to translate Librum into your language? If so, then feel free to reach out to us at contact@librumreader.com and we can work on making that happen together! +Librum is currently available in: +- English +- German +- Russian +- Mandarin + +If you want to translate Librum to another language, follow the steps below: +- Download the file at: https://github.com/Librum-Reader/Librum/blob/main/src/presentation/translations/librum_en.ts +- Rename the file to contain your language's suffix, e.g. "librum_ru.ts" for Russian or "librum_de.ts" for German +- Download the translation software (Qt Linguist) either for Windows from https://github.com/thurask/Qt-Linguist or using the Qt Installer at https://www.qt.io/download-open-source +- Now start Qt Linguist, open the downloaded file, set the target language to the language you want to translate to and start translating. +(For a quick guide on Qt Linguist, check out: https://youtu.be/xNIz78IPBu0?t=347) + +Once you are done, create a pull request or an issue with your new translation file!
+If you run into any problems, need guidance or have questions, feel free to reach out to us at: contact@librumreader.com + +
+ +Notes: +- Make sure that your translations are approximately the same length as the original text +- Make sure that you keep to the punctuation and capitalisation +- Make sure that your translations make sense in the context they are in
From e374e166fc7e41241b8230bb822339de70858652 Mon Sep 17 00:00:00 2001 From: DavidLazarescu Date: Tue, 12 Dec 2023 16:10:19 +0100 Subject: [PATCH 12/20] Added book duplication prevention --- .../controllers/library_controller.cpp | 6 +- .../controllers/library_controller.hpp | 3 +- .../controllers/i_library_controller.hpp | 1 + .../common/enums/book_operation_status.hpp | 1 + src/application/core/metadata_extractor.cpp | 25 ++++- src/application/core/metadata_extractor.hpp | 3 +- .../interfaces/services/i_library_service.hpp | 1 + src/application/services/library_service.cpp | 20 +++- src/application/services/library_service.hpp | 3 +- src/domain/entities/book.cpp | 14 +++ src/domain/entities/book.hpp | 9 +- src/domain/value_objects/book_meta_data.hpp | 3 +- src/presentation/homePage/MHomePage.qml | 40 ++++++- src/presentation/main.qml | 2 +- src/presentation/translations/librum_de.ts | 65 +++++++---- src/presentation/translations/librum_en.ts | 65 +++++++---- src/presentation/translations/librum_ru.ts | 65 +++++++---- src/presentation/translations/librum_zh.ts | 104 ++++++++++-------- .../controllers/library_controller_tests.cpp | 2 +- 19 files changed, 305 insertions(+), 127 deletions(-) diff --git a/src/adapters/controllers/library_controller.cpp b/src/adapters/controllers/library_controller.cpp index 950c77f73..fdbd8f82c 100644 --- a/src/adapters/controllers/library_controller.cpp +++ b/src/adapters/controllers/library_controller.cpp @@ -100,7 +100,8 @@ void LibraryController::syncWithServer() m_bookService->downloadBooks(); } -int LibraryController::addBook(const QString& path, int projectGutenbergId) +int LibraryController::addBook(const QString& path, bool allowDuplicates, + int projectGutenbergId) { auto localPath = QUrl(path).toLocalFile(); QFileInfo fileInfo(localPath); @@ -108,7 +109,8 @@ int LibraryController::addBook(const QString& path, int projectGutenbergId) return 0; QApplication::setOverrideCursor(Qt::WaitCursor); - auto result = m_bookService->addBook(localPath, projectGutenbergId); + auto result = + m_bookService->addBook(localPath, allowDuplicates, projectGutenbergId); QApplication::restoreOverrideCursor(); emit addingBookFinished( diff --git a/src/adapters/controllers/library_controller.hpp b/src/adapters/controllers/library_controller.hpp index afd15cd9b..72df266a8 100644 --- a/src/adapters/controllers/library_controller.hpp +++ b/src/adapters/controllers/library_controller.hpp @@ -18,7 +18,8 @@ class ADAPTERS_EXPORT LibraryController : public ILibraryController public: LibraryController(application::ILibraryService* bookService); - int addBook(const QString& path, int projectGutenbergId = 0) override; + int addBook(const QString& path, bool allowDuplicates = false, + int projectGutenbergId = 0) override; int deleteBook(const QString& uuid) override; int deleteAllBooks() override; int uninstallBook(const QString& uuid) override; diff --git a/src/adapters/interfaces/controllers/i_library_controller.hpp b/src/adapters/interfaces/controllers/i_library_controller.hpp index d833fe287..b07f4203e 100644 --- a/src/adapters/interfaces/controllers/i_library_controller.hpp +++ b/src/adapters/interfaces/controllers/i_library_controller.hpp @@ -52,6 +52,7 @@ class ADAPTERS_EXPORT ILibraryController : public QObject Q_INVOKABLE virtual void syncWithServer() = 0; Q_INVOKABLE virtual int addBook(const QString& path, + bool allowDuplicates = false, int projectGutenbergId = 0) = 0; Q_INVOKABLE virtual int deleteBook(const QString& uuid) = 0; Q_INVOKABLE virtual int deleteAllBooks() = 0; diff --git a/src/application/common/enums/book_operation_status.hpp b/src/application/common/enums/book_operation_status.hpp index e7aba242d..48ed6c9f8 100644 --- a/src/application/common/enums/book_operation_status.hpp +++ b/src/application/common/enums/book_operation_status.hpp @@ -21,6 +21,7 @@ enum class BookOperationStatus PropertyDoesNotExist, TagDoesNotExist, TagAlreadyExists, + BookAlreadyExists, OperationFailed }; diff --git a/src/application/core/metadata_extractor.cpp b/src/application/core/metadata_extractor.cpp index 061547143..5c68fdfa0 100644 --- a/src/application/core/metadata_extractor.cpp +++ b/src/application/core/metadata_extractor.cpp @@ -1,4 +1,5 @@ #include "metadata_extractor.hpp" +#include #include #include #include "fz_utils.hpp" @@ -47,6 +48,7 @@ domain::value_objects::BookMetaData MetadataExtractor::getBookMetaData() .lastOpened = QDateTime(), .coverLastModified = QDateTime(), .coverPath = "", + .fileHash = generateFileHash(), }; if(metaData.format.isEmpty()) @@ -105,6 +107,27 @@ QString MetadataExtractor::getDocumentSize() double MetadataExtractor::roundToPrecisionOf2(double raw) { return (static_cast(raw * 100 + .5) / 100.0); +} + +QString MetadataExtractor::generateFileHash() +{ + QFile file(m_filePath); + if(!file.open(QIODevice::ReadOnly)) + { + qWarning() << QString( + "Could not open book at path: %1 for hash generation") + .arg(m_filePath); + } + + QCryptographicHash hashGen(QCryptographicHash::Sha1); + if(hashGen.addData(&file)) + { + return hashGen.result().toHex(); + } + + qWarning() << "Error reading file for hash calculation:" + << file.errorString(); + return ""; }; QImage MetadataExtractor::getBookCover() @@ -149,4 +172,4 @@ QImage MetadataExtractor::getCover() } } -} // namespace application::core \ No newline at end of file +} // namespace application::core diff --git a/src/application/core/metadata_extractor.hpp b/src/application/core/metadata_extractor.hpp index 79fe0d08c..42e6eb0b3 100644 --- a/src/application/core/metadata_extractor.hpp +++ b/src/application/core/metadata_extractor.hpp @@ -19,9 +19,10 @@ class MetadataExtractor : public IMetadataExtractor QString getTitleFromPath(); QString getDocumentSize(); double roundToPrecisionOf2(double raw); + QString generateFileHash(); std::unique_ptr m_document; QString m_filePath; }; -} // namespace application::core \ No newline at end of file +} // namespace application::core diff --git a/src/application/interfaces/services/i_library_service.hpp b/src/application/interfaces/services/i_library_service.hpp index 0b29f8bfa..7037d5785 100644 --- a/src/application/interfaces/services/i_library_service.hpp +++ b/src/application/interfaces/services/i_library_service.hpp @@ -23,6 +23,7 @@ class APPLICATION_EXPORT ILibraryService : public QObject virtual void downloadBooks() = 0; virtual BookOperationStatus addBook(const QString& filePath, + bool allowDuplicates, int projectGutenbergId) = 0; virtual BookOperationStatus deleteBook(const QUuid& uuid) = 0; virtual BookOperationStatus deleteAllBooks() = 0; diff --git a/src/application/services/library_service.cpp b/src/application/services/library_service.cpp index 8737af8a7..e61ae6954 100644 --- a/src/application/services/library_service.cpp +++ b/src/application/services/library_service.cpp @@ -6,7 +6,6 @@ #include #include #include -#include #include "book_for_deletion.hpp" #include "book_merger.hpp" #include "book_operation_status.hpp" @@ -109,6 +108,7 @@ void LibraryService::downloadBooks() } BookOperationStatus LibraryService::addBook(const QString& filePath, + bool allowDuplicates, int projectGutenbergId) { auto success = m_bookMetadataHelper->setup(filePath); @@ -120,6 +120,12 @@ BookOperationStatus LibraryService::addBook(const QString& filePath, auto bookMetaData = m_bookMetadataHelper->getBookMetaData(); Book book(filePath, bookMetaData); + if(!allowDuplicates && bookWithFileHashAlreadyExists(book.getFileHash())) + { + qWarning() << QString("Book with file hash: %1 already exists.") + .arg(book.getFileHash()); + return BookOperationStatus::BookAlreadyExists; + } auto cover = m_bookMetadataHelper->getBookCover(); cover = cover.scaled(Book::maxCoverWidth, Book::maxCoverHeight, @@ -736,6 +742,18 @@ void LibraryService::deleteBookLocally(const domain::entities::Book& book) m_libraryStorageManager->deleteBookLocally(std::move(bookToDelete)); } +bool LibraryService::bookWithFileHashAlreadyExists( + const QString& fileHash) const +{ + auto bookPosition = + std::ranges::find_if(m_books, + [&fileHash](const Book& book) + { + return book.getFileHash() == fileHash; + }); + return bookPosition != m_books.end(); +} + std::set LibraryService::getProjectGutenbergIds() { std::set result; diff --git a/src/application/services/library_service.hpp b/src/application/services/library_service.hpp index 9cb310d46..3472250fa 100644 --- a/src/application/services/library_service.hpp +++ b/src/application/services/library_service.hpp @@ -1,7 +1,6 @@ #pragma once #include #include -#include #include "application_export.hpp" #include "book.hpp" #include "i_library_service.hpp" @@ -21,6 +20,7 @@ class APPLICATION_EXPORT LibraryService : public ILibraryService void downloadBooks() override; BookOperationStatus addBook(const QString& filePath, + bool allowDuplicates = false, int projectGutenbergId = 0) override; BookOperationStatus deleteBook(const QUuid& uuid) override; BookOperationStatus deleteAllBooks() override; @@ -76,6 +76,7 @@ private slots: qint64 bytesReceived, qint64 bytesTotal); void deleteBookLocally(const domain::entities::Book& book); + bool bookWithFileHashAlreadyExists(const QString& fileHash) const; std::set getProjectGutenbergIds(); IMetadataExtractor* m_bookMetadataHelper; diff --git a/src/domain/entities/book.cpp b/src/domain/entities/book.cpp index b5dab281f..8954fa2bf 100644 --- a/src/domain/entities/book.cpp +++ b/src/domain/entities/book.cpp @@ -364,6 +364,16 @@ void Book::setColorTheme(const QString& newColorTheme) m_metaData.colorTheme = newColorTheme; } +QString Book::getFileHash() const +{ + return m_metaData.fileHash; +} + +void Book::setFileHash(const QString& newFileHash) +{ + m_metaData.fileHash = newFileHash; +} + const QList& Book::getTags() const { return m_tags; @@ -509,6 +519,8 @@ void Book::update(const Book& other) m_metaData.coverPath = other.getCoverPath(); if(m_metaData.colorTheme != other.getColorTheme()) m_metaData.colorTheme = other.getColorTheme(); + if(m_metaData.fileHash != other.getFileHash()) + m_metaData.fileHash = other.getFileHash(); if(!tagsAreTheSame(other.getTags())) m_tags = other.getTags(); @@ -620,6 +632,7 @@ QByteArray Book::toJson() const { "hasCover", hasCover() }, { "coverPath", getCoverPath() }, { "colorTheme", getColorTheme() }, + { "fileHash", getFileHash() }, { "existsOnlyOnClient", existsOnlyOnClient() }, { "tags", serializeTags() }, { "highlights", serializeHighlights() }, @@ -715,6 +728,7 @@ BookMetaData Book::getBookMetaDataFromJson(const QJsonObject& jsonBook) .hasCover = jsonBook["hasCover"].toBool(), .coverPath = jsonBook["coverPath"].toString(), .colorTheme = jsonBook["colorTheme"].toString(), + .fileHash = jsonBook["fileHash"].toString(), }; // Specify that the dates are UTC, else Qt thinks its local time diff --git a/src/domain/entities/book.hpp b/src/domain/entities/book.hpp index c085e2ef1..adb31d57a 100644 --- a/src/domain/entities/book.hpp +++ b/src/domain/entities/book.hpp @@ -80,6 +80,12 @@ class DOMAIN_EXPORT Book double getMediaDownloadProgress() const; void setMediaDownloadProgress(double newProgress); + QString getColorTheme() const; + void setColorTheme(const QString& newColorTheme); + + QString getFileHash() const; + void setFileHash(const QString& newFileHash); + const QList& getHighlights() const; void setHighlights(QList&& highlights); void addHighlight(const Highlight& highlight); @@ -104,9 +110,6 @@ class DOMAIN_EXPORT Book int getBookReadingProgress() const; - QString getColorTheme() const; - void setColorTheme(const QString& newColorTheme); - domain::entities::Tag* getTagByUuid(const QUuid& uuid); domain::entities::Tag* getTagByName(const QString& name); bool addTag(const Tag& tag); diff --git a/src/domain/value_objects/book_meta_data.hpp b/src/domain/value_objects/book_meta_data.hpp index 34fd4eeb7..9e4e10d17 100644 --- a/src/domain/value_objects/book_meta_data.hpp +++ b/src/domain/value_objects/book_meta_data.hpp @@ -26,6 +26,7 @@ struct DOMAIN_EXPORT BookMetaData double bookMediaDownloadProgress = 0.0; QString coverPath; QString colorTheme; + QString fileHash; bool operator==(const BookMetaData& rhs) const { @@ -47,7 +48,7 @@ struct DOMAIN_EXPORT BookMetaData coverLastModified.toSecsSinceEpoch() == rhs.coverLastModified.toSecsSinceEpoch() && hasCover == rhs.hasCover && coverPath == coverPath && - colorTheme == rhs.colorTheme; + colorTheme == rhs.colorTheme && fileHash == rhs.fileHash; } }; diff --git a/src/presentation/homePage/MHomePage.qml b/src/presentation/homePage/MHomePage.qml index a3677f47d..37dedc506 100644 --- a/src/presentation/homePage/MHomePage.qml +++ b/src/presentation/homePage/MHomePage.qml @@ -42,9 +42,14 @@ Page { onDropped: drop => { for (var i = 0; i < drop.urls.length; ++i) { - let result = LibraryController.addBook(drop.urls[i]) - if (result === BookOperationStatus.OpeningBookFailed) - unsupportedFilePopup.open() + internal.lastAddedBookPath = drop.urls[i] + let result = LibraryController.addBook( + internal.lastAddedBookPath) + if (result === BookOperationStatus.OpeningBookFailed) { + unsupportedFilePopup.open() + } else if (result === BookOperationStatus.BookAlreadyExists) { + bookAlreadyExistsPopup.open() + } } } @@ -424,6 +429,27 @@ Page { onDecisionMade: close() } + MWarningPopup { + id: bookAlreadyExistsPopup + x: Math.round( + root.width / 2 - implicitWidth / 2 - sidebar.width / 2 - root.horizontalPadding) + y: Math.round( + root.height / 2 - implicitHeight / 2 - root.topPadding - 50) + visible: false + title: qsTr("Book already exists") + message: qsTr("It looks like this book is already in your library.\nAre you sure you want to add it again?") + leftButtonText: qsTr("Add") + rightButtonText: qsTr("Don't add") + messageBottomSpacing: 16 + minButtonWidth: 180 + onOpenedChanged: if (opened) + bookAlreadyExistsPopup.giveFocus() + onDecisionMade: close() + + onLeftButtonClicked: LibraryController.addBook( + internal.lastAddedBookPath, true) + } + MWarningPopup { id: unsupportedFilePopup x: Math.round( @@ -454,9 +480,13 @@ Page { onAccepted: { for (var i = 0; i < files.length; ++i) { - let result = LibraryController.addBook(files[i]) + internal.lastAddedBookPath = files[i] + let result = LibraryController.addBook( + internal.lastAddedBookPath) if (result === BookOperationStatus.OpeningBookFailed) unsupportedFilePopup.open() + else if (result === BookOperationStatus.BookAlreadyExists) + bookAlreadyExistsPopup.open() } } } @@ -464,7 +494,7 @@ Page { QtObject { id: internal property bool libraryIsEmpty: LibraryController.bookCount === 0 - + property string lastAddedBookPath: "" property int bookWidth: 190 property int bookHeight: 300 property int horizontalBookSpacing: 64 diff --git a/src/presentation/main.qml b/src/presentation/main.qml index 5e668ae1f..e1721bee4 100644 --- a/src/presentation/main.qml +++ b/src/presentation/main.qml @@ -172,7 +172,7 @@ ApplicationWindow { target: FreeBooksController function onGettingBookFinished(path, projectGutenbergId) { - LibraryController.addBook(path, projectGutenbergId) + LibraryController.addBook(path, false, projectGutenbergId) } } diff --git a/src/presentation/translations/librum_de.ts b/src/presentation/translations/librum_de.ts index d68af38b3..f6fe94806 100644 --- a/src/presentation/translations/librum_de.ts +++ b/src/presentation/translations/librum_de.ts @@ -1218,105 +1218,126 @@ es gibt keine Möglichkeit sie wiederherzustellen! MHomePage - + A new version is available! Eine neue Version ist verfügbar! - + Update Now Aktualisieren - + Home As in 'Home Page', might be closer to 'Start' in other languages Start - + You have %1 books Du hast %1 Bücher - + Add books Bücher hinzufügen - + Remove Book? Buch Löschen? - + Deleting a book is a permanent action, no one will be able to restore it afterwards! Das Löschen eines Buches ist eine dauerhafte Aktion, niemand wird es wiederherstellen können! - + Remove from Device Vom Gerät entfernen - + Delete Everywhere Überall Löschen - + Save Speichern - + Limit Reached Limit erreicht - + You have reached your upload limit. Delete unused books to free up space or upgrade. Du hast dein Upload-Limit erreicht. Lösche alte Bücher um Speicherplatzu freizugeben oder upgrade deinen Account. - - + + Ok Ok - + Upgrade Upgrade - + + Book already exists + + + + + It looks like this book is already in your library. +Are you sure you want to add it again? + + + + + Add + Hinzufügen + + + + Don't add + + + + Unsupported File Nicht unterstützt - + Oops! This file is not supported by Librum. Oops! Dieses Format wird von Librum nicht unterstützt. - + Import Importieren - + All files Alle Dokumente - - - + + + files Dokumente diff --git a/src/presentation/translations/librum_en.ts b/src/presentation/translations/librum_en.ts index c2ac39287..cbd4be271 100644 --- a/src/presentation/translations/librum_en.ts +++ b/src/presentation/translations/librum_en.ts @@ -1047,103 +1047,124 @@ Either you are offline, or your storage is full. MHomePage - + A new version is available! - + Update Now - + Home As in 'Home Page', might be closer to 'Start' in other languages - + You have %1 books - + Add books - + Remove Book? - + Deleting a book is a permanent action, no one will be able to restore it afterwards! - + Remove from Device - + Delete Everywhere - + Save - + Limit Reached - + You have reached your upload limit. Delete unused books to free up space or upgrade. - - + + Ok - + Upgrade - + + Book already exists + + + + + It looks like this book is already in your library. +Are you sure you want to add it again? + + + + + Add + + + + + Don't add + + + + Unsupported File - + Oops! This file is not supported by Librum. - + Import - + All files - - - + + + files diff --git a/src/presentation/translations/librum_ru.ts b/src/presentation/translations/librum_ru.ts index b043b1fd0..a25926ae6 100644 --- a/src/presentation/translations/librum_ru.ts +++ b/src/presentation/translations/librum_ru.ts @@ -1171,105 +1171,126 @@ Either you are offline, or your storage is full. MHomePage - + A new version is available! Доступна новая версия! - + Update Now Обновить Сейчас - + Home As in 'Home Page', might be closer to 'Start' in other languages Главная - + You have %1 books У Вас %1 книг - + Add books Добавить книги - + Remove Book? Удалить Книгу? - + Deleting a book is a permanent action, no one will be able to restore it afterwards! Удаление книги необратимо, после этого её нельзя будет восстановить! - + Remove from Device Удалить с Устройства - + Delete Everywhere Удалить Везде - + Save Сохранить - + Limit Reached Достигнут Лимит - + You have reached your upload limit. Delete unused books to free up space or upgrade. Вы достигли лимита загрузок на сервер. Удалите ненужные книги или приобретите улучшение для аккаунта. - - + + Ok Хорошо - + Upgrade Приобрести улучшение - + + Book already exists + + + + + It looks like this book is already in your library. +Are you sure you want to add it again? + + + + + Add + Добавить + + + + Don't add + + + + Unsupported File Не поддерживается - + Oops! This file is not supported by Librum. Ой! Librum не поддерживает этот файл. - + Import Добавить - + All files Все файлы - - - + + + files файлы diff --git a/src/presentation/translations/librum_zh.ts b/src/presentation/translations/librum_zh.ts index 3cb57172f..cf6c7da01 100644 --- a/src/presentation/translations/librum_zh.ts +++ b/src/presentation/translations/librum_zh.ts @@ -326,78 +326,75 @@ We hope you have a great time using it! Feel free to leave us a rating and some 明亮 - Page Color Mode - 页面颜色模式 + 页面颜色模式 - Normal - 常规 + 常规 - Inverted - 反转 + 反转 - + Language 语言 - + Reading 阅读 - + Page spacing 页间距 - + Display book title in titlebar 在标题栏显示书名 - + Default Zoom 默认缩放 - + Highlights 高亮 - + Colors 颜色 - + Opacity 不透明度 - + Reset settings? 重置设置? - + Resetting your settings is a permanent action, there will be no way to restore them! 重置您的设置是一个永久性的操作,您将无法恢复! - + No, Keep 保持 - + Yes, Reset 重置 @@ -1063,103 +1060,124 @@ Either you are offline, or your storage is full. MHomePage - + A new version is available! 有新版本可用! - + Update Now 立即更新 - + Home As in 'Home Page', might be closer to 'Start' in other languages 主页 - + You have %1 books 您有 %1 本书 - + Add books 添加书籍 - + Remove Book? 移除此书? - + Deleting a book is a permanent action, no one will be able to restore it afterwards! 删除书籍是永久性操作,删除后将无法恢复! - + Remove from Device 从设备上移除 - + Delete Everywhere 从所有地方删除 - + Save 保存 - + Limit Reached 到达限制 - + You have reached your upload limit. Delete unused books to free up space or upgrade. 您已达到您的上传限制。删除未使用的书籍以释放空间或更新。 - - + + Ok - + Upgrade 更新 - + + Book already exists + + + + + It looks like this book is already in your library. +Are you sure you want to add it again? + + + + + Add + 添加 + + + + Don't add + + + + Unsupported File 不支持的文件 - + Oops! This file is not supported by Librum. 哎呀!Librum 不支持这个文件 - + Import 导入 - + All files 所有文件 - - - + + + files 文件 @@ -1297,17 +1315,17 @@ Delete unused books to free up space or upgrade. 反转颜色 - + Sync book 同步书籍 - + More options 更多选项 - + Save 保存 diff --git a/tests/adapters_unit_tests/controllers/library_controller_tests.cpp b/tests/adapters_unit_tests/controllers/library_controller_tests.cpp index c0b67bfe2..9c03d0202 100644 --- a/tests/adapters_unit_tests/controllers/library_controller_tests.cpp +++ b/tests/adapters_unit_tests/controllers/library_controller_tests.cpp @@ -29,7 +29,7 @@ class LibraryServiceMock : public ILibraryService { public: MOCK_METHOD(void, downloadBooks, (), (override)); - MOCK_METHOD(BookOperationStatus, addBook, (const QString&, int), + MOCK_METHOD(BookOperationStatus, addBook, (const QString&, bool, int), (override)); MOCK_METHOD(BookOperationStatus, deleteBook, (const QUuid&), (override)); MOCK_METHOD(BookOperationStatus, deleteAllBooks, (), (override)); From 10b2bfd3173364df4e9085fd26091046976504e9 Mon Sep 17 00:00:00 2001 From: DavidLazarescu Date: Tue, 12 Dec 2023 17:25:05 +0100 Subject: [PATCH 13/20] Fixed error handling when adding multiple books --- src/application/CMakeLists.txt | 1 + src/application/core/metadata_extractor.cpp | 24 +----- src/application/core/metadata_extractor.hpp | 1 - src/application/utility/book_utils.hpp | 25 +++++++ src/application/utility/save_book_helper.hpp | 4 + src/presentation/homePage/MHomePage.qml | 77 +++++++++++++------- src/presentation/translations/librum_de.ts | 57 ++++++++------- src/presentation/translations/librum_en.ts | 57 ++++++++------- src/presentation/translations/librum_ru.ts | 57 ++++++++------- src/presentation/translations/librum_zh.ts | 57 ++++++++------- 10 files changed, 206 insertions(+), 154 deletions(-) create mode 100644 src/application/utility/book_utils.hpp diff --git a/src/application/CMakeLists.txt b/src/application/CMakeLists.txt index 5c9979cd6..5c9adbbcf 100644 --- a/src/application/CMakeLists.txt +++ b/src/application/CMakeLists.txt @@ -60,6 +60,7 @@ set(application_SRC utility/book_merger.cpp utility/automatic_login_helper.hpp utility/error_code_converter.hpp + utility/book_utils.hpp core/page_generator.hpp core/page_generator.cpp diff --git a/src/application/core/metadata_extractor.cpp b/src/application/core/metadata_extractor.cpp index 5c68fdfa0..71a1cc0e3 100644 --- a/src/application/core/metadata_extractor.cpp +++ b/src/application/core/metadata_extractor.cpp @@ -2,6 +2,7 @@ #include #include #include +#include "book_utils.hpp" #include "fz_utils.hpp" #include "page_generator.hpp" @@ -48,7 +49,7 @@ domain::value_objects::BookMetaData MetadataExtractor::getBookMetaData() .lastOpened = QDateTime(), .coverLastModified = QDateTime(), .coverPath = "", - .fileHash = generateFileHash(), + .fileHash = utility::generateFileHash(m_filePath), }; if(metaData.format.isEmpty()) @@ -109,27 +110,6 @@ double MetadataExtractor::roundToPrecisionOf2(double raw) return (static_cast(raw * 100 + .5) / 100.0); } -QString MetadataExtractor::generateFileHash() -{ - QFile file(m_filePath); - if(!file.open(QIODevice::ReadOnly)) - { - qWarning() << QString( - "Could not open book at path: %1 for hash generation") - .arg(m_filePath); - } - - QCryptographicHash hashGen(QCryptographicHash::Sha1); - if(hashGen.addData(&file)) - { - return hashGen.result().toHex(); - } - - qWarning() << "Error reading file for hash calculation:" - << file.errorString(); - return ""; -}; - QImage MetadataExtractor::getBookCover() { try diff --git a/src/application/core/metadata_extractor.hpp b/src/application/core/metadata_extractor.hpp index 42e6eb0b3..7afa158d1 100644 --- a/src/application/core/metadata_extractor.hpp +++ b/src/application/core/metadata_extractor.hpp @@ -19,7 +19,6 @@ class MetadataExtractor : public IMetadataExtractor QString getTitleFromPath(); QString getDocumentSize(); double roundToPrecisionOf2(double raw); - QString generateFileHash(); std::unique_ptr m_document; QString m_filePath; diff --git a/src/application/utility/book_utils.hpp b/src/application/utility/book_utils.hpp new file mode 100644 index 000000000..f9795a077 --- /dev/null +++ b/src/application/utility/book_utils.hpp @@ -0,0 +1,25 @@ +#pragma once +#include +#include +#include +#include + +namespace application::utility +{ + +QString generateFileHash(const QString& filePath) +{ + QFile file(filePath); + if(!file.open(QIODevice::ReadOnly)) + qWarning() << QString("Could not open book at path: %1").arg(filePath); + + QCryptographicHash hashGen(QCryptographicHash::Sha1); + if(hashGen.addData(&file)) + return hashGen.result().toHex(); + + qWarning() << "Error reading file for hash calculation:" + << file.errorString(); + return ""; +}; + +} // namespace application::utility \ No newline at end of file diff --git a/src/application/utility/save_book_helper.hpp b/src/application/utility/save_book_helper.hpp index 1bbeb4436..1c205c819 100644 --- a/src/application/utility/save_book_helper.hpp +++ b/src/application/utility/save_book_helper.hpp @@ -1,4 +1,8 @@ #pragma once +#include +#include +#include +#include namespace application::utility { diff --git a/src/presentation/homePage/MHomePage.qml b/src/presentation/homePage/MHomePage.qml index 37dedc506..a6c3bd63f 100644 --- a/src/presentation/homePage/MHomePage.qml +++ b/src/presentation/homePage/MHomePage.qml @@ -40,18 +40,7 @@ Page { id: dropArea anchors.fill: parent - onDropped: drop => { - for (var i = 0; i < drop.urls.length; ++i) { - internal.lastAddedBookPath = drop.urls[i] - let result = LibraryController.addBook( - internal.lastAddedBookPath) - if (result === BookOperationStatus.OpeningBookFailed) { - unsupportedFilePopup.open() - } else if (result === BookOperationStatus.BookAlreadyExists) { - bookAlreadyExistsPopup.open() - } - } - } + onDropped: drop => internal.addBooks(drop.urls) ColumnLayout { id: layout @@ -437,14 +426,22 @@ Page { root.height / 2 - implicitHeight / 2 - root.topPadding - 50) visible: false title: qsTr("Book already exists") - message: qsTr("It looks like this book is already in your library.\nAre you sure you want to add it again?") + message: qsTr("It looks like this book already exists in your library:") + + "
" + "" + + internal.lastAddedBookPath.split("/").slice( + -1)[0] + "
" + qsTr( + "Are you sure you that want to add it again?\n") + richText: true leftButtonText: qsTr("Add") rightButtonText: qsTr("Don't add") messageBottomSpacing: 16 minButtonWidth: 180 onOpenedChanged: if (opened) bookAlreadyExistsPopup.giveFocus() - onDecisionMade: close() + onDecisionMade: { + close() + internal.continueAddingBooks() + } onLeftButtonClicked: LibraryController.addBook( internal.lastAddedBookPath, true) @@ -465,7 +462,11 @@ Page { onOpenedChanged: if (opened) giveFocus() - onDecisionMade: close() + + onDecisionMade: { + close() + internal.continueAddingBooks() + } } FileDialog { @@ -478,27 +479,18 @@ Page { "files") + " (*.epub)", "MOBI " + qsTr("files") + " (*.mobi)", "HTML " + qsTr( "files") + " (*.html *.htm)", "Text " + qsTr("files") + " (*.txt)"] - onAccepted: { - for (var i = 0; i < files.length; ++i) { - internal.lastAddedBookPath = files[i] - let result = LibraryController.addBook( - internal.lastAddedBookPath) - if (result === BookOperationStatus.OpeningBookFailed) - unsupportedFilePopup.open() - else if (result === BookOperationStatus.BookAlreadyExists) - bookAlreadyExistsPopup.open() - } - } + onAccepted: internal.addBooks(files) } QtObject { id: internal property bool libraryIsEmpty: LibraryController.bookCount === 0 - property string lastAddedBookPath: "" property int bookWidth: 190 property int bookHeight: 300 property int horizontalBookSpacing: 64 property int verticalBookSpacing: 48 + property var booksCurrentlyAdding: [] + property string lastAddedBookPath: "" function openBookOptionsPopup(item) { Globals.selectedBook = LibraryController.getBook(item.uuid) @@ -517,5 +509,36 @@ Page { LibraryController.refreshLastOpenedFlag(Globals.selectedBook.uuid) loadPage(readingPage) } + + // This function adds books to the library. When errors happen in the process, + // it interrupts the adding and shows a popup. After the popup is closed, the + // adding is resumed by calling continueAddingBooks(). + function addBooks(container) { + internal.booksCurrentlyAdding = container + for (var i = container.length - 1; i >= 0; i--) { + internal.lastAddedBookPath = container[i] + let result = LibraryController.addBook( + internal.lastAddedBookPath) + + // Remove the already added book + container.splice(i, 1) + + if (result === BookOperationStatus.OpeningBookFailed) { + unsupportedFilePopup.open() + return + } + + if (result === BookOperationStatus.BookAlreadyExists) { + bookAlreadyExistsPopup.open() + return + } + } + } + + // When an error occurs while adding multiple books, this method is called + // after the error was dealt with to continue adding the rest of the books. + function continueAddingBooks() { + internal.addBooks(internal.booksCurrentlyAdding) + } } } diff --git a/src/presentation/translations/librum_de.ts b/src/presentation/translations/librum_de.ts index f6fe94806..6b5675784 100644 --- a/src/presentation/translations/librum_de.ts +++ b/src/presentation/translations/librum_de.ts @@ -1218,126 +1218,131 @@ es gibt keine Möglichkeit sie wiederherzustellen! MHomePage - + A new version is available! Eine neue Version ist verfügbar! - + Update Now Aktualisieren - + Home As in 'Home Page', might be closer to 'Start' in other languages Start - + You have %1 books Du hast %1 Bücher - + Add books Bücher hinzufügen - + Remove Book? Buch Löschen? - + Deleting a book is a permanent action, no one will be able to restore it afterwards! Das Löschen eines Buches ist eine dauerhafte Aktion, niemand wird es wiederherstellen können! - + Remove from Device Vom Gerät entfernen - + Delete Everywhere Überall Löschen - + Save Speichern - + Limit Reached Limit erreicht - + You have reached your upload limit. Delete unused books to free up space or upgrade. Du hast dein Upload-Limit erreicht. Lösche alte Bücher um Speicherplatzu freizugeben oder upgrade deinen Account. - - + + Ok Ok - + Upgrade Upgrade - + Book already exists - - It looks like this book is already in your library. -Are you sure you want to add it again? + + It looks like this book already exists in your library: - + + Are you sure you that want to add it again? + + + + + Add Hinzufügen - + Don't add - + Unsupported File Nicht unterstützt - + Oops! This file is not supported by Librum. Oops! Dieses Format wird von Librum nicht unterstützt. - + Import Importieren - + All files Alle Dokumente - + files Dokumente diff --git a/src/presentation/translations/librum_en.ts b/src/presentation/translations/librum_en.ts index cbd4be271..6385f9343 100644 --- a/src/presentation/translations/librum_en.ts +++ b/src/presentation/translations/librum_en.ts @@ -1047,124 +1047,129 @@ Either you are offline, or your storage is full. MHomePage - + A new version is available! - + Update Now - + Home As in 'Home Page', might be closer to 'Start' in other languages - + You have %1 books - + Add books - + Remove Book? - + Deleting a book is a permanent action, no one will be able to restore it afterwards! - + Remove from Device - + Delete Everywhere - + Save - + Limit Reached - + You have reached your upload limit. Delete unused books to free up space or upgrade. - - + + Ok - + Upgrade - + Book already exists - - It looks like this book is already in your library. -Are you sure you want to add it again? + + It looks like this book already exists in your library: - + + Are you sure you that want to add it again? + + + + + Add - + Don't add - + Unsupported File - + Oops! This file is not supported by Librum. - + Import - + All files - + files diff --git a/src/presentation/translations/librum_ru.ts b/src/presentation/translations/librum_ru.ts index a25926ae6..3448ebce1 100644 --- a/src/presentation/translations/librum_ru.ts +++ b/src/presentation/translations/librum_ru.ts @@ -1171,126 +1171,131 @@ Either you are offline, or your storage is full. MHomePage - + A new version is available! Доступна новая версия! - + Update Now Обновить Сейчас - + Home As in 'Home Page', might be closer to 'Start' in other languages Главная - + You have %1 books У Вас %1 книг - + Add books Добавить книги - + Remove Book? Удалить Книгу? - + Deleting a book is a permanent action, no one will be able to restore it afterwards! Удаление книги необратимо, после этого её нельзя будет восстановить! - + Remove from Device Удалить с Устройства - + Delete Everywhere Удалить Везде - + Save Сохранить - + Limit Reached Достигнут Лимит - + You have reached your upload limit. Delete unused books to free up space or upgrade. Вы достигли лимита загрузок на сервер. Удалите ненужные книги или приобретите улучшение для аккаунта. - - + + Ok Хорошо - + Upgrade Приобрести улучшение - + Book already exists - - It looks like this book is already in your library. -Are you sure you want to add it again? + + It looks like this book already exists in your library: - + + Are you sure you that want to add it again? + + + + + Add Добавить - + Don't add - + Unsupported File Не поддерживается - + Oops! This file is not supported by Librum. Ой! Librum не поддерживает этот файл. - + Import Добавить - + All files Все файлы - + files файлы diff --git a/src/presentation/translations/librum_zh.ts b/src/presentation/translations/librum_zh.ts index cf6c7da01..270f79a56 100644 --- a/src/presentation/translations/librum_zh.ts +++ b/src/presentation/translations/librum_zh.ts @@ -1060,124 +1060,129 @@ Either you are offline, or your storage is full. MHomePage - + A new version is available! 有新版本可用! - + Update Now 立即更新 - + Home As in 'Home Page', might be closer to 'Start' in other languages 主页 - + You have %1 books 您有 %1 本书 - + Add books 添加书籍 - + Remove Book? 移除此书? - + Deleting a book is a permanent action, no one will be able to restore it afterwards! 删除书籍是永久性操作,删除后将无法恢复! - + Remove from Device 从设备上移除 - + Delete Everywhere 从所有地方删除 - + Save 保存 - + Limit Reached 到达限制 - + You have reached your upload limit. Delete unused books to free up space or upgrade. 您已达到您的上传限制。删除未使用的书籍以释放空间或更新。 - - + + Ok - + Upgrade 更新 - + Book already exists - - It looks like this book is already in your library. -Are you sure you want to add it again? + + It looks like this book already exists in your library: - + + Are you sure you that want to add it again? + + + + + Add 添加 - + Don't add - + Unsupported File 不支持的文件 - + Oops! This file is not supported by Librum. 哎呀!Librum 不支持这个文件 - + Import 导入 - + All files 所有文件 - + files 文件 From 4f94cfbde49f46864e6c1f326b15b178c5937ff2 Mon Sep 17 00:00:00 2001 From: DavidLazarescu Date: Tue, 12 Dec 2023 20:33:36 +0100 Subject: [PATCH 14/20] Set colortheme to 'Normal' by default --- src/application/core/metadata_extractor.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/application/core/metadata_extractor.cpp b/src/application/core/metadata_extractor.cpp index 71a1cc0e3..d02b1b1d1 100644 --- a/src/application/core/metadata_extractor.cpp +++ b/src/application/core/metadata_extractor.cpp @@ -49,6 +49,7 @@ domain::value_objects::BookMetaData MetadataExtractor::getBookMetaData() .lastOpened = QDateTime(), .coverLastModified = QDateTime(), .coverPath = "", + .colorTheme = "Normal", .fileHash = utility::generateFileHash(m_filePath), }; From 862611abce91fda4c5821bac68ca64df92e64bc3 Mon Sep 17 00:00:00 2001 From: DavidLazarescu Date: Wed, 13 Dec 2023 12:48:32 +0100 Subject: [PATCH 15/20] Added safety to prevent duplication error when getting file hash fails --- src/application/services/library_service.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/application/services/library_service.cpp b/src/application/services/library_service.cpp index e61ae6954..529ccb0b0 100644 --- a/src/application/services/library_service.cpp +++ b/src/application/services/library_service.cpp @@ -120,7 +120,9 @@ BookOperationStatus LibraryService::addBook(const QString& filePath, auto bookMetaData = m_bookMetadataHelper->getBookMetaData(); Book book(filePath, bookMetaData); - if(!allowDuplicates && bookWithFileHashAlreadyExists(book.getFileHash())) + auto hash = book.getFileHash(); + if(!allowDuplicates && !hash.isEmpty() && + bookWithFileHashAlreadyExists(hash)) { qWarning() << QString("Book with file hash: %1 already exists.") .arg(book.getFileHash()); From 7c3c4456bae3c53c46e2c3ce3b6f87aee82db4d9 Mon Sep 17 00:00:00 2001 From: DavidLazarescu Date: Wed, 13 Dec 2023 14:23:15 +0100 Subject: [PATCH 16/20] Renamed variable --- .../controllers/library_controller.cpp | 89 ++++++++++--------- .../controllers/library_controller.hpp | 2 +- src/application/CMakeLists.txt | 1 + src/application/utility/save_book_helper.hpp | 2 +- 4 files changed, 50 insertions(+), 44 deletions(-) diff --git a/src/adapters/controllers/library_controller.cpp b/src/adapters/controllers/library_controller.cpp index fdbd8f82c..b6b7baaaf 100644 --- a/src/adapters/controllers/library_controller.cpp +++ b/src/adapters/controllers/library_controller.cpp @@ -18,28 +18,30 @@ using namespace dtos; LibraryController::LibraryController( application::ILibraryService* bookService) : - m_bookService(bookService), - m_libraryModel(m_bookService->getBooks()) + m_libraryService(bookService), + m_libraryModel(m_libraryService->getBooks()) { // book insertion - connect(m_bookService, &application::ILibraryService::bookInsertionStarted, + connect(m_libraryService, + &application::ILibraryService::bookInsertionStarted, &m_libraryModel, &data_models::LibraryModel::startInsertingRow); - connect(m_bookService, &application::ILibraryService::bookInsertionEnded, + connect(m_libraryService, &application::ILibraryService::bookInsertionEnded, &m_libraryModel, &data_models::LibraryModel::endInsertingRow); - connect(m_bookService, &application::ILibraryService::bookInsertionEnded, + connect(m_libraryService, &application::ILibraryService::bookInsertionEnded, this, &LibraryController::bookCountChanged); // Library syncing - connect(m_bookService, &application::ILibraryService::syncingLibraryStarted, + connect(m_libraryService, + &application::ILibraryService::syncingLibraryStarted, [this]() { m_currentlySyncing = true; emit isSyncingChanged(); }); - connect(m_bookService, + connect(m_libraryService, &application::ILibraryService::syncingLibraryFinished, [this]() { @@ -49,46 +51,49 @@ LibraryController::LibraryController( // book deletion - connect(m_bookService, &application::ILibraryService::bookDeletionStarted, - &m_libraryModel, &data_models::LibraryModel::startDeletingBook); + connect(m_libraryService, + &application::ILibraryService::bookDeletionStarted, &m_libraryModel, + &data_models::LibraryModel::startDeletingBook); - connect(m_bookService, &application::ILibraryService::bookDeletionEnded, + connect(m_libraryService, &application::ILibraryService::bookDeletionEnded, &m_libraryModel, &data_models::LibraryModel::endDeletingBook); - connect(m_bookService, &application::ILibraryService::bookDeletionEnded, + connect(m_libraryService, &application::ILibraryService::bookDeletionEnded, this, &LibraryController::bookCountChanged); // book clearing - connect(m_bookService, &application::ILibraryService::bookClearingStarted, - &m_libraryModel, &data_models::LibraryModel::startBookClearing); + connect(m_libraryService, + &application::ILibraryService::bookClearingStarted, &m_libraryModel, + &data_models::LibraryModel::startBookClearing); - connect(m_bookService, &application::ILibraryService::bookClearingEnded, + connect(m_libraryService, &application::ILibraryService::bookClearingEnded, &m_libraryModel, &data_models::LibraryModel::endBookClearing); - connect(m_bookService, &application::ILibraryService::bookClearingEnded, + connect(m_libraryService, &application::ILibraryService::bookClearingEnded, this, &LibraryController::bookCountChanged); // Storage limit exceeded - connect(m_bookService, &application::ILibraryService::storageLimitExceeded, - this, &LibraryController::storageLimitExceeded); + connect(m_libraryService, + &application::ILibraryService::storageLimitExceeded, this, + &LibraryController::storageLimitExceeded); // tags changed - connect(m_bookService, &application::ILibraryService::tagsChanged, + connect(m_libraryService, &application::ILibraryService::tagsChanged, &m_libraryModel, &data_models::LibraryModel::refreshTags); // data changed - connect(m_bookService, &application::ILibraryService::dataChanged, + connect(m_libraryService, &application::ILibraryService::dataChanged, &m_libraryModel, &data_models::LibraryModel::refreshBook); // download book media progress changed - connect(m_bookService, + connect(m_libraryService, &application::ILibraryService::downloadingBookMediaProgressChanged, &m_libraryModel, &data_models::LibraryModel::downloadingBookMediaProgressChanged); // downloaded Project Gutenberg books - connect(m_bookService, + connect(m_libraryService, &application::ILibraryService::downloadedProjectGutenbergIdsReady, this, &LibraryController::downloadedProjectGutenbergIdsReady); @@ -97,7 +102,7 @@ LibraryController::LibraryController( void LibraryController::syncWithServer() { - m_bookService->downloadBooks(); + m_libraryService->downloadBooks(); } int LibraryController::addBook(const QString& path, bool allowDuplicates, @@ -109,8 +114,8 @@ int LibraryController::addBook(const QString& path, bool allowDuplicates, return 0; QApplication::setOverrideCursor(Qt::WaitCursor); - auto result = - m_bookService->addBook(localPath, allowDuplicates, projectGutenbergId); + auto result = m_libraryService->addBook(localPath, allowDuplicates, + projectGutenbergId); QApplication::restoreOverrideCursor(); emit addingBookFinished( @@ -122,32 +127,32 @@ int LibraryController::addBook(const QString& path, bool allowDuplicates, int LibraryController::deleteBook(const QString& uuid) { - auto result = m_bookService->deleteBook(QUuid(uuid)); + auto result = m_libraryService->deleteBook(QUuid(uuid)); return static_cast(result); } int LibraryController::deleteAllBooks() { - auto result = m_bookService->deleteAllBooks(); + auto result = m_libraryService->deleteAllBooks(); return static_cast(result); } int LibraryController::uninstallBook(const QString& uuid) { - auto result = m_bookService->uninstallBook(QUuid(uuid)); + auto result = m_libraryService->uninstallBook(QUuid(uuid)); return static_cast(result); } int LibraryController::downloadBookMedia(const QString& uuid) { - auto result = m_bookService->downloadBookMedia(QUuid(uuid)); + auto result = m_libraryService->downloadBookMedia(QUuid(uuid)); return static_cast(result); } int LibraryController::updateBook(const QString& uuid, const QVariant& operations) { - auto bookToUpdate = m_bookService->getBook(QUuid(uuid)); + auto bookToUpdate = m_libraryService->getBook(QUuid(uuid)); if(!bookToUpdate) return static_cast(BookOperationStatus::BookDoesNotExist); @@ -209,14 +214,14 @@ int LibraryController::updateBook(const QString& uuid, } } - auto result = m_bookService->updateBook(updatedBook); + auto result = m_libraryService->updateBook(updatedBook); return static_cast(result); } int LibraryController::changeBookCover(const QString& uuid, const QString& path) { - auto result = - m_bookService->changeBookCover(QUuid(uuid), QUrl(path).toLocalFile()); + auto result = m_libraryService->changeBookCover(QUuid(uuid), + QUrl(path).toLocalFile()); return static_cast(result); } @@ -232,7 +237,7 @@ int LibraryController::addTag(const QString& bookUuid, const QString& tagName, } Tag tag(tagName, tagUuid); - auto result = m_bookService->addTagToBook(QUuid(bookUuid), tag); + auto result = m_libraryService->addTagToBook(QUuid(bookUuid), tag); return static_cast(result); } @@ -242,12 +247,12 @@ void LibraryController::removeAllTagsWithUuid(const QString& tagUuid) if(QUuid(tagUuid).isNull()) return; - auto& books = m_bookService->getBooks(); + auto& books = m_libraryService->getBooks(); for(const auto& book : books) { if(listContainsTag(book.getTags(), QUuid(tagUuid))) { - m_bookService->removeTagFromBook(book.getUuid(), QUuid(tagUuid)); + m_libraryService->removeTagFromBook(book.getUuid(), QUuid(tagUuid)); } } } @@ -255,12 +260,12 @@ void LibraryController::removeAllTagsWithUuid(const QString& tagUuid) void LibraryController::renameTags(const QString& oldName, const QString& newName) { - auto& books = m_bookService->getBooks(); + auto& books = m_libraryService->getBooks(); for(const auto& book : books) { auto tagUuid = getTagUuidByName(book, oldName); if(!tagUuid.isNull()) - m_bookService->renameTagOfBook(book.getUuid(), tagUuid, newName); + m_libraryService->renameTagOfBook(book.getUuid(), tagUuid, newName); } } @@ -268,13 +273,13 @@ int LibraryController::removeTag(const QString& bookUuid, const QString& tagUuid) { auto result = - m_bookService->removeTagFromBook(QUuid(bookUuid), QUuid(tagUuid)); + m_libraryService->removeTagFromBook(QUuid(bookUuid), QUuid(tagUuid)); return static_cast(result); } dtos::BookDto LibraryController::getBook(const QString& uuid) { - const auto& books = m_bookService->getBooks(); + const auto& books = m_libraryService->getBooks(); auto book = std::ranges::find_if(books, [&uuid](const Book& b) { @@ -286,7 +291,7 @@ dtos::BookDto LibraryController::getBook(const QString& uuid) int LibraryController::getBookCount() const { - return m_bookService->getBookCount(); + return m_libraryService->getBookCount(); } bool LibraryController::isSyncing() const @@ -302,14 +307,14 @@ data_models::LibraryProxyModel* LibraryController::getLibraryModel() int LibraryController::saveBookToFile(const QString& uuid, const QUrl& path) { auto result = - m_bookService->saveBookToFile(QUuid(uuid), path.toLocalFile()); + m_libraryService->saveBookToFile(QUuid(uuid), path.toLocalFile()); return static_cast(result); } void LibraryController::refreshLastOpenedFlag(const QString& uuid) { - m_bookService->refreshLastOpenedDateOfBook(QUuid(uuid)); + m_libraryService->refreshLastOpenedDateOfBook(QUuid(uuid)); } dtos::BookDto LibraryController::getDtoFromBook( diff --git a/src/adapters/controllers/library_controller.hpp b/src/adapters/controllers/library_controller.hpp index 72df266a8..41ac739d0 100644 --- a/src/adapters/controllers/library_controller.hpp +++ b/src/adapters/controllers/library_controller.hpp @@ -52,7 +52,7 @@ public slots: dtos::BookDto& bookDto); bool listContainsTag(const QList& tags, QUuid uuid); - application::ILibraryService* m_bookService; + application::ILibraryService* m_libraryService; data_models::LibraryModel m_libraryModel; data_models::LibraryProxyModel m_libraryProxyModel; bool m_currentlySyncing = false; diff --git a/src/application/CMakeLists.txt b/src/application/CMakeLists.txt index 5c9adbbcf..d990c8915 100644 --- a/src/application/CMakeLists.txt +++ b/src/application/CMakeLists.txt @@ -61,6 +61,7 @@ set(application_SRC utility/automatic_login_helper.hpp utility/error_code_converter.hpp utility/book_utils.hpp + utility/save_book_helper.hpp core/page_generator.hpp core/page_generator.cpp diff --git a/src/application/utility/save_book_helper.hpp b/src/application/utility/save_book_helper.hpp index 1c205c819..d75514d05 100644 --- a/src/application/utility/save_book_helper.hpp +++ b/src/application/utility/save_book_helper.hpp @@ -1,8 +1,8 @@ #pragma once -#include #include #include #include +#include namespace application::utility { From bfc5478981f946462568ea8f6dd7feff89c1d31b Mon Sep 17 00:00:00 2001 From: DavidLazarescu Date: Wed, 13 Dec 2023 14:28:05 +0100 Subject: [PATCH 17/20] Ensured that 'syncingLibraryStarted' is always emitted when loading books --- src/application/services/library_service.cpp | 40 ++++++++++---------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/src/application/services/library_service.cpp b/src/application/services/library_service.cpp index 529ccb0b0..3362723fa 100644 --- a/src/application/services/library_service.cpp +++ b/src/application/services/library_service.cpp @@ -27,25 +27,7 @@ LibraryService::LibraryService(IMetadataExtractor* bookMetadataHelper, connect(&m_fetchChangesTimer, &QTimer::timeout, this, [this]() { - m_libraryStorageManager->downloadRemoteBooks(); - - auto success = QNetworkInformation::loadDefaultBackend(); - if(!success) - qWarning() << "Failed loading QNetworkInformation backend"; - - auto networkInfo = QNetworkInformation::instance(); - if(networkInfo == nullptr) - { - qWarning() << "Failed loading QNetworkInformation instance"; - } - else - { - if(networkInfo->reachability() == - QNetworkInformation::Reachability::Online) - { - emit syncingLibraryStarted(); - } - } + downloadBooks(); }); // Apply updates timer @@ -105,6 +87,26 @@ LibraryService::LibraryService(IMetadataExtractor* bookMetadataHelper, void LibraryService::downloadBooks() { m_libraryStorageManager->downloadRemoteBooks(); + + auto success = QNetworkInformation::loadDefaultBackend(); + if(!success) + qWarning() << "Failed loading QNetworkInformation backend"; + + // We only want to emit the library sync signal if we know that we are + // online. Else the loading indicator would be spinning forever. + auto networkInfo = QNetworkInformation::instance(); + if(networkInfo == nullptr) + { + qWarning() << "Failed loading QNetworkInformation instance"; + } + else + { + if(networkInfo->reachability() == + QNetworkInformation::Reachability::Online) + { + emit syncingLibraryStarted(); + } + } } BookOperationStatus LibraryService::addBook(const QString& filePath, From 439390822820ee11587147b359d80f96320ebb8b Mon Sep 17 00:00:00 2001 From: DavidLazarescu Date: Fri, 15 Dec 2023 15:49:18 +0100 Subject: [PATCH 18/20] Fixed issues caused by automatically updating translations at every build --- scripts/update_translations.sh | 11 ++ src/presentation/CMakeLists.txt | 7 +- src/presentation/translations/librum_it.ts | 166 +++++++++++++-------- 3 files changed, 113 insertions(+), 71 deletions(-) create mode 100755 scripts/update_translations.sh diff --git a/scripts/update_translations.sh b/scripts/update_translations.sh new file mode 100755 index 000000000..4c8f3974f --- /dev/null +++ b/scripts/update_translations.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +# Get the directory of the script +SCRIPT_DIR=$(dirname "$0") + +# Find translation files using find command +TRANSLATION_FILES=$(find "$SCRIPT_DIR/../src/presentation/translations" -name "librum_*.ts") + +# Use lupdate with the list of translation files +lupdate "$SCRIPT_DIR/../src/presentation" -ts $TRANSLATION_FILES + diff --git a/src/presentation/CMakeLists.txt b/src/presentation/CMakeLists.txt index baaa3eb0c..1ce4b564d 100644 --- a/src/presentation/CMakeLists.txt +++ b/src/presentation/CMakeLists.txt @@ -15,19 +15,14 @@ add_library(presentation ) +# Translations set(translation_files translations/librum_en.ts translations/librum_de.ts translations/librum_ru.ts translations/librum_zh.ts ) - -# Translations for the application qt_add_translations(presentation TS_FILES ${translation_files}) -add_dependencies(presentation presentation_lupdate) -add_dependencies(presentation presentation_lrelease) -add_dependencies(presentation update_translations) - target_compile_definitions(presentation PRIVATE PRESENTATION_LIBRARY) diff --git a/src/presentation/translations/librum_it.ts b/src/presentation/translations/librum_it.ts index db544875d..1a3068bf9 100644 --- a/src/presentation/translations/librum_it.ts +++ b/src/presentation/translations/librum_it.ts @@ -326,77 +326,62 @@ We hope you have a great time using it! Feel free to leave us a rating and some - Page Color Mode - - - - - Normal - - - - - Inverted - - - - Language - + Reading - + Page spacing - + Display book title in titlebar - + Default Zoom - + Highlights - + Colors - + Opacity - + Reset settings? - + Resetting your settings is a permanent action, there will be no way to restore them! - + No, Keep - + Yes, Reset @@ -439,23 +424,48 @@ We hope you have a great time using it! Feel free to leave us a rating and some - + + Hide cursor after delay + + + + + ms + + + + + Include new lines in copied text + + + + + ON + + + + + OFF + + + + Reset settings? - + Resetting your settings is a permanent action, there will be no way to restore them! - + No, Keep - + Yes, Reset @@ -637,23 +647,23 @@ Either you are offline, or your storage is full. - + New Bookmark - + Follow Context: "Follow" the bookmark (go to its page) - + Rename - + Delete @@ -688,32 +698,32 @@ Either you are offline, or your storage is full. - + Deleting your account is an irreversible action.<br>Once you delete your account, there is <b>no</b> going back. Please be certain. - + Your Email - + Confirm the deletion by entering your Account's email. - + Cancel - + Delete - + Your email is wrong @@ -1037,103 +1047,129 @@ Either you are offline, or your storage is full. MHomePage - + A new version is available! - + Update Now - + Home As in 'Home Page', might be closer to 'Start' in other languages - + You have %1 books - + Add books - + Remove Book? - + Deleting a book is a permanent action, no one will be able to restore it afterwards! - + Remove from Device - + Delete Everywhere - + Save - + Limit Reached - + You have reached your upload limit. Delete unused books to free up space or upgrade. - - + + Ok - + Upgrade - - Unsupported File + + Book already exists + + + + + It looks like this book already exists in your library: + + + + + Are you sure you that want to add it again? + + Add + + + + + Don't add + + + + + Unsupported File + + + + Oops! This file is not supported by Librum. - + Import - + All files - - - + + + files @@ -1271,17 +1307,17 @@ Delete unused books to free up space or upgrade. - + Sync book - + More options - + Save From 971e7d313745cd078a2d47438269d0891606dd6e Mon Sep 17 00:00:00 2001 From: David Lazarescu <69865187+DavidLazarescu@users.noreply.github.com> Date: Fri, 15 Dec 2023 16:01:58 +0100 Subject: [PATCH 19/20] Update CI clang issue workaround --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a0adae708..222dc25de 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -29,7 +29,7 @@ jobs: echo "TEMPORARY WORKAROUND FOR GITHUB RUNNER BUG #8659\n\nRemoving GCC 13 as it breaks Clang14" sudo rm -f /etc/apt/sources.list.d/ubuntu-toolchain-r-ubuntu-test-jammy.list sudo apt-get update - sudo apt-get install -y --allow-downgrades libc6=2.35-0ubuntu3.4 libc6-dev=2.35-0ubuntu3.4 libstdc++6=12.3.0-1ubuntu1~22.04 libgcc-s1=12.3.0-1ubuntu1~22.04 + sudo apt-get install -y --allow-downgrades libc6=2.35-0ubuntu3.5 libc6-dev=2.35-0ubuntu3.5 libstdc++6=12.3.0-1ubuntu1~22.04 libgcc-s1=12.3.0-1ubuntu1~22.04 - name: Install Qt uses: jurplel/install-qt-action@v3 From 651dda3235480abb348ecf7f16c57747ccaddb3e Mon Sep 17 00:00:00 2001 From: DavidLazarescu Date: Sat, 16 Dec 2023 00:30:35 +0100 Subject: [PATCH 20/20] Added missing russian and german translation for new strings --- src/presentation/translations/librum_de.ts | 11 ++++++----- src/presentation/translations/librum_ru.ts | 11 ++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/presentation/translations/librum_de.ts b/src/presentation/translations/librum_de.ts index 6b5675784..037bbb1e7 100644 --- a/src/presentation/translations/librum_de.ts +++ b/src/presentation/translations/librum_de.ts @@ -1296,28 +1296,29 @@ Lösche alte Bücher um Speicherplatzu freizugeben oder upgrade deinen Account.< Book already exists - + Buch existiert bereits It looks like this book already exists in your library: - + Dieses Buch ist bereits in deiner Bibliothek: Are you sure you that want to add it again? - + Willst du es erneut hinzufügen? + Add - Hinzufügen + Hinzufügen Don't add - + Nicht hinzufügen diff --git a/src/presentation/translations/librum_ru.ts b/src/presentation/translations/librum_ru.ts index 3448ebce1..40d05552e 100644 --- a/src/presentation/translations/librum_ru.ts +++ b/src/presentation/translations/librum_ru.ts @@ -1249,28 +1249,29 @@ Delete unused books to free up space or upgrade. Book already exists - + Книга уже есть It looks like this book already exists in your library: - + Похоже, эта книга уже есть в Вашей библиотеке: Are you sure you that want to add it again? - + Вы уверены, что хотите добавить её снова? + Add - Добавить + Добавить Don't add - + Не добавлять