diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index ac001aee..d98c1c91 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -57,8 +57,8 @@ jobs: - name: Install Qt uses: jurplel/install-qt-action@v3 with: - aqtversion: "==3.1.*" - version: "6.7.*" + aqtversion: ==3.1.* + version: 6.8.0 host: linux target: desktop arch: linux_gcc_64 @@ -155,8 +155,8 @@ jobs: - name: Install Qt uses: jurplel/install-qt-action@v3 with: - aqtversion: "==3.1.*" - version: "6.7.*" + aqtversion: ==3.1.* + version: 6.8.0 host: "mac" cache: true target: "desktop" diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ccc3d2d..ba928db1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,12 +2,22 @@ ### التحديثات 💭 -- إضافة الترجمة الإندونيسية لواجهة البرنامج -- تحديث Qt للإصدار 6.7 +- تصليح عطل في ترجمة أسماء التفاسير +- تصليح بعض الأعطال عند استخدام خط QCF v2 (#113) +- إضافة خط الآيات لرواية ورش عن نافع (#115) +- إضافة القارئ إبراهيم الدوسري (ورش) (#115) +- إضافة القارئ ياسين الجزائري (ورش) (#115) +- إضافة تذكر حالة شريط القوائم (مرئي/مخفي) (#114) +- تحديث Qt للإصدار 6.8 ### What's Changed 💭 -- Added Indonesian UI translation -- Upgrade to Qt 6.7 \ No newline at end of file +- Bug fix for issue with the translation of Tafsir names +- Bug fixes for QCF v2 font (#113) +- Added the Ayat font for Warsh 'an Nafi' narration (#115) +- New reciter Ibrahim Al-Dosari (Warsh) (#115) +- New reciter Yassine Al-Jazairi (Warsh) (#115) +- Added saving of the state of the menu bar (visible/hidden) (#114) +- Updating Qt to version 6.8 \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 60a61a4c..3b9eba4b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.22) project( quran-companion LANGUAGES CXX - VERSION 1.3.1 + VERSION 1.3.2 DESCRIPTION "Quran reader and player" HOMEPAGE_URL "https://0xzer0x.github.io/projects/quran-companion/") @@ -153,6 +153,8 @@ set(PROJECT_SOURCES src/notifiers/jobnotifier.cpp src/utils/configuration.h src/utils/configuration.cpp + src/utils/configurationschema.h + src/utils/configurationschema.cpp src/utils/shortcuthandler.h src/utils/shortcuthandler.cpp src/utils/logger.h @@ -264,28 +266,10 @@ list(APPEND SUPPORTED_LANGUAGES ar tr ru id) foreach(lang IN LISTS SUPPORTED_LANGUAGES) message(STATUS "Adding ${lang} translation file to QC_TS") list(APPEND QC_TS "dist/translations/out/qc_${lang}.ts") - - if(EXISTS "dist/translations/qtbase/${lang}.qm") - message(STATUS "Copying ${lang} qt translations to build tree") - configure_file("dist/translations/qtbase/${lang}.qm" - "${CMAKE_BINARY_DIR}/${lang}.qm" COPYONLY) - - message(STATUS "Adding ${lang} qtbase qm file to QTBASE_QM") - list(APPEND QTBASE_QM "${CMAKE_BINARY_DIR}/${lang}.qm") - endif() endforeach() message(STATUS "Creating qt translations resource file") qt_add_translations(quran-companion TS_FILES ${QC_TS}) -qt_add_resources( - quran-companion - "qttranslations" - PREFIX - "/qtbase" - BASE - ${CMAKE_BINARY_DIR} - FILES - ${QTBASE_QM}) if(QT_VERSION_MAJOR EQUAL 6) qt_finalize_executable(quran-companion) diff --git a/README-AR.md b/README-AR.md index 2e54ae19..7bbb8e91 100644 --- a/README-AR.md +++ b/README-AR.md @@ -138,7 +138,7 @@ Download Flatpak - + Download AppImage @@ -329,4 +329,4 @@ cmake --build . [win-installer]: https://github.com/0xzer0x/quran-companion/releases/download/v1.1.9/qc_online_installer_x64_win.exe [translation-wiki]: https://github.com/0xzer0x/quran-companion/wiki/Contributing-Translations [recitations-wiki]: https://github.com/0xzer0x/quran-companion/wiki/Contributing-Recitations -[macos-dmg-url]: https://github.com/0xzer0x/quran-companion/releases/download/v1.3.1/Quran_Companion-1.3.1-x86_64.dmg +[macos-dmg-url]: https://github.com/0xzer0x/quran-companion/releases/download/v1.3.2/Quran_Companion-1.3.2-x86_64.dmg diff --git a/README.md b/README.md index 5929c5b5..56a32a4a 100644 --- a/README.md +++ b/README.md @@ -135,7 +135,7 @@ The application can be downloaded in any of the available packages (snap, flatpa Download Flatpak - + Download AppImage @@ -311,4 +311,4 @@ Distributed under the [Waqf General Public License](https://ojuba.org/waqf-2.0:% [win-installer]: https://github.com/0xzer0x/quran-companion/releases/download/v1.1.9/qc_online_installer_x64_win.exe [translation-wiki]: https://github.com/0xzer0x/quran-companion/wiki/Contributing-Translations [recitations-wiki]: https://github.com/0xzer0x/quran-companion/wiki/Contributing-Recitations -[macos-dmg-url]: https://github.com/0xzer0x/quran-companion/releases/download/v1.3.1/Quran_Companion-1.3.1-x86_64.dmg +[macos-dmg-url]: https://github.com/0xzer0x/quran-companion/releases/download/v1.3.2/Quran_Companion-1.3.2-x86_64.dmg diff --git a/VERSION b/VERSION index 3a3cd8cc..1892b926 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.3.1 +1.3.2 diff --git a/assets/fonts/uthmanic_warsh_v21.ttf b/assets/fonts/uthmanic_warsh_v21.ttf new file mode 100644 index 00000000..087135bb Binary files /dev/null and b/assets/fonts/uthmanic_warsh_v21.ttf differ diff --git a/assets/quran.db b/assets/quran.db index fe117ad3..0eed08fb 100644 Binary files a/assets/quran.db and b/assets/quran.db differ diff --git a/bismillah/warsh-ibrahim-aldosary.mp3 b/bismillah/warsh-ibrahim-aldosary.mp3 new file mode 100644 index 00000000..8f0603b1 Binary files /dev/null and b/bismillah/warsh-ibrahim-aldosary.mp3 differ diff --git a/bismillah/warsh-yassin-al-jazaery.mp3 b/bismillah/warsh-yassin-al-jazaery.mp3 new file mode 100644 index 00000000..8b121bb0 Binary files /dev/null and b/bismillah/warsh-yassin-al-jazaery.mp3 differ diff --git a/dist/translations/generate-template b/dist/translations/generate-template index 8dddbff8..4e3276c1 100755 --- a/dist/translations/generate-template +++ b/dist/translations/generate-template @@ -5,62 +5,64 @@ set -euo pipefail _SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd) _QT_DIR=$(find "$HOME" -maxdepth 3 -path "$HOME/Qt/6.*/gcc_64" -type d | head -n 1) #COLORS -CDEF="\033[0m" # default color -b_CCIN="\033[1;36m" # bold info color -b_CGSC="\033[1;32m" # bold success color -b_CRER="\033[1;31m" # bold error color -b_CWAR="\033[1;33m" # bold warning color +__CDEF="\033[0m" # default color +__b_CCIN="\033[1;36m" # bold info color +__b_CGSC="\033[1;32m" # bold success color +__b_CRER="\033[1;31m" # bold error color +__b_CWAR="\033[1;33m" # bold warning color # echo like with flag type and display message colors -prompt() { +__prompt() { case ${1} in "-s" | "--success") - echo -ne "${b_CGSC}${2}${CDEF}" + echo -e "${__b_CGSC}${2}${__CDEF}" ;; # print success message "-e" | "--error") - echo -ne "${b_CRER}${2}${CDEF}" + echo -e "${__b_CRER}${2}${__CDEF}" ;; # print error message "-w" | "--warning") - echo -ne "${b_CWAR}${2}${CDEF}" + echo -e "${__b_CWAR}${2}${__CDEF}" ;; # print warning message "-i" | "--info") - echo -ne "${b_CCIN}${2}${CDEF}" + echo -e "${__b_CCIN}${2}${__CDEF}" ;; # print info message *) - echo -ne "$@" + echo -e "$@" ;; esac } extract-reciters() { - prompt -s "-- generating reciters ts file\n" - local __tsfile=$_SCRIPT_DIR/generated/tafasir.ts - local __xmlfile=$_SCRIPT_DIR/../../resources/files.xml + __prompt -s "-- generating reciters ts file" + local __tsfile=$_SCRIPT_DIR/generated/reciters.ts + local __xmlfile=$_SCRIPT_DIR/../../resources/reciters.xml - mapfile -t __reciters_names <<<"$(awk -F'"' '/name/ { for(i=1;i\n\n\n" >"$__tsfile" - printf "\n\tMainWindow" >>"$__tsfile" + printf "\n\n\n" >"${__tsfile}" + printf "\n\tMainWindow" >>"${__tsfile}" for n in "${__reciters_names[@]}"; do - printf "\n\t\n\t\t\n\t\t%s\n\t\t\n\t" "$n" >>"$__tsfile" + __prompt -i "-- adding '${n}'" + printf "\n\t\n\t\t\n\t\t%s\n\t\t\n\t" "$n" >>"${__tsfile}" done - printf "\n\n" >>"$__tsfile" + printf "\n\n" >>"${__tsfile}" echo "-- extracted ${#__reciters_names[@]} reciters" } extract-tafasir() { - prompt -s "-- generating tafasir ts file\n" + __prompt -s "-- generating tafasir ts file" local __tsfile=$_SCRIPT_DIR/generated/tafasir.ts local __xmlfile=$_SCRIPT_DIR/../../resources/files.xml - mapfile -t __tafasir_names <<<"$(awk -F'"' '/name/ { for(i=1;i\n\n\n" >"$__tsfile" printf "\n\tMainWindow" >>"$__tsfile" for n in "${__tafasir_names[@]}"; do + __prompt -i "-- adding '${n}'" printf "\n\t\n\t\t\n\t\t%s\n\t\t\n\t" "$n" >>"$__tsfile" done @@ -69,16 +71,17 @@ extract-tafasir() { } extract-shortcuts() { - prompt -s "-- generating shortcuts ts file\n" + __prompt -s "-- generating shortcuts ts file" local __tsfile=$_SCRIPT_DIR/generated/shortcuts.ts local __xmlfile=$_SCRIPT_DIR/../../resources/shortcuts.xml - mapfile -t __shortcuts_desc <<<"$(awk -F'"' '/desc/ { for(i=1;i\n\n\n" >"$__tsfile" printf "\n\tSettingsDialog" >>"$__tsfile" for n in "${__shortcuts_desc[@]}"; do + __prompt -i "-- adding '${n}'" printf "\n\t\n\t\t\n\t\t%s\n\t\t\n\t" "$n" >>"$__tsfile" done @@ -87,12 +90,12 @@ extract-shortcuts() { } extract-source-strings() { - prompt -s "-- generating sources ts file\n" + __prompt -s "-- generating sources ts file" "$_QT_DIR/bin/lupdate" -recursive -no-obsolete "$_SCRIPT_DIR/../../src" -ts "$_SCRIPT_DIR/generated/sources.ts" } update-template() { - prompt -s "-- updating template ts file\n" + __prompt -s "-- updating template ts file" local templatefile="$_SCRIPT_DIR/template.ts" declare -a generated for f in "$_SCRIPT_DIR/generated/"*; do diff --git a/dist/translations/out/qc_ar.ts b/dist/translations/out/qc_ar.ts index 4c9bf4be..4e4b19cc 100644 --- a/dist/translations/out/qc_ar.ts +++ b/dist/translations/out/qc_ar.ts @@ -123,9 +123,19 @@ Muhammad Jibreel محمد جبريل + + + Ibrahim Al-Dosary (Warsh) + إبراهيم الدوسري (ورش) + + + + Yassin Al-Jazaery (Warsh) + ياسين الجزائري (ورش) + - + Quran Companion رفيق القرآن @@ -152,7 +162,7 @@ - + Navigation التصفح @@ -213,7 +223,7 @@ - + About Qt عن كيوت @@ -258,49 +268,49 @@ التحكم بالمشغل - + Default افتراضي - + Now playing: يقرأ الآن: - + Surah سورة - - - + + + Files Missing الملفات مفقودة - + The selected font files are missing, would you like to download it? ملفات الخط المحدد مفقودة، هل ترغب في تحميلها؟ - + The selected tafsir is missing, would you like to download it? التفسير المحدد مفقود، هل ترغب في تحميله؟ - + The selected translation is missing, would you like to download it? الترجمة المحددة مفقود، هل ترغب في تحميله؟ - + Recitation not found التلاوة غير موجودة - + The recitation files for the current surah is missing, would you like to download it? ملفات التلاوة الخاصة بالسورة الحالية غير متوفرة، هل تود الذَّهاب إلى صفحة التحميل؟ @@ -657,8 +667,8 @@ - - + + size الحجم @@ -674,32 +684,37 @@ - Uthmanic - عثماني + Hafs + حفص - Uthmanic (annotated) - عثماني (مرمز) + Hafs (annotated) + حفص (مرمّز) + + + + Warsh + ورش - + Side content المحتوى الجانبي - + Font Family نوع الخط - + Translation الترجمة - + Shortcuts الاختصارات @@ -806,27 +821,32 @@ المترجمون - + Credits شكر وتقدير - + + Quran Text + نص القرآن + + + Recitations التلاوات - + Tafsir/Translations التفسير/الترجمات - + Surah Cards بطاقات السور - + Libraries المكتبات @@ -1223,7 +1243,7 @@ PlayerControls - + Reciter القارئ diff --git a/dist/translations/out/qc_id.ts b/dist/translations/out/qc_id.ts index fbc13bdb..52ebf2b2 100644 --- a/dist/translations/out/qc_id.ts +++ b/dist/translations/out/qc_id.ts @@ -123,9 +123,19 @@ Muhammad Jibreel Muhammad Jibreel + + + Ibrahim Al-Dosary (Warsh) + Ibrahim Al-Dosary (Warsh) + + + + Yassin Al-Jazaery (Warsh) + Yassin Al-Jazaery (Warsh) + - + Quran Companion Teman Quran @@ -152,7 +162,7 @@ - + Navigation Navigasi @@ -213,7 +223,7 @@ - + About Qt Tentang Qt @@ -258,49 +268,49 @@ Kontrol player - + Default Default - + Now playing: Sedang diputar: - + Surah Surah - - - + + + Files Missing Berkas Kurang - + The selected font files are missing, would you like to download it? Berkas font yang dipilih tidak ditemukan, apakah anda ingin mengunduhnya? - + The selected tafsir is missing, would you like to download it? Tafsir yang dipilih tidak ditemukan, apakah anda ingin mengunduhnya? - + The selected translation is missing, would you like to download it? Terjemahan yang dipilih tidak ditemukan, apakah anda ingin mengunduhnya? - + Recitation not found Qiraah tidak ditemukan - + The recitation files for the current surah is missing, would you like to download it? Berkas qiraah untuk surah saat ini tidak ditemukan, apakah anda ingin mengunduhnya? @@ -657,8 +667,8 @@ - - + + size ukuran @@ -674,32 +684,37 @@ - Uthmanic - Utsmani + Hafs + Hafs - Uthmanic (annotated) - Utsmani (dengan harakat) + Hafs (annotated) + Hafs (annotated) + + + + Warsh + Warsh - + Side content Konten sisi - + Font Family Keluarga Font - + Translation Terjemahan - + Shortcuts Pintasan @@ -806,27 +821,32 @@ Penerjemah - + Credits Kredit - + + Quran Text + Quran Text + + + Recitations Qiraah - + Tafsir/Translations Tafsir/Terjemahan - + Surah Cards Kartu Surah - + Libraries Pustaka @@ -1223,7 +1243,7 @@ PlayerControls - + Reciter Qori diff --git a/dist/translations/out/qc_ru.ts b/dist/translations/out/qc_ru.ts index 45bf9145..9c9a8c50 100644 --- a/dist/translations/out/qc_ru.ts +++ b/dist/translations/out/qc_ru.ts @@ -123,9 +123,19 @@ Muhammad Jibreel Мухаммад Джибриль + + + Ibrahim Al-Dosary (Warsh) + Ibrahim Al-Dosary (Warsh) + + + + Yassin Al-Jazaery (Warsh) + Yassin Al-Jazaery (Warsh) + - + Quran Companion Компаньон Корана @@ -152,7 +162,7 @@ - + Navigation Навигация @@ -213,7 +223,7 @@ - + About Qt О платформе Qt @@ -258,49 +268,49 @@ Управление плеером - + Default По умолчанию - + Now playing: Сейчас проигрывается: - + Surah Сура - - - + + + Files Missing Файл не найден - + The selected font files are missing, would you like to download it? Файлы выбранного шрифта отсутствуют, вы хотите загрузить их? - + The selected tafsir is missing, would you like to download it? Файлы выбранного тафсира отсутствуют, вы хотите загрузить его? - + The selected translation is missing, would you like to download it? Файлы выбранного перевода отсутствуют, вы хотите загрузить их? - + Recitation not found Чтец не найден - + The recitation files for the current surah is missing, would you like to download it? Файл чтения для текущей суры отсутствует, вы хотите скачать его? @@ -657,8 +667,8 @@ - - + + size размер @@ -674,32 +684,37 @@ - Uthmanic - Uthmanic + Hafs + Hafs - Uthmanic (annotated) - Uthmanic (аннотированный) + Hafs (annotated) + Hafs (annotated) + + + + Warsh + Warsh - + Side content Содержимое боковой панели - + Font Family Семейство шрифта - + Translation Перевод - + Shortcuts Сочетания клавиш @@ -806,27 +821,32 @@ Переводчики - + Credits Авторы - + + Quran Text + Quran Text + + + Recitations Чтецы - + Tafsir/Translations Тафсир/Переводы - + Surah Cards Карточки Сур - + Libraries Библиотеки @@ -1223,7 +1243,7 @@ PlayerControls - + Reciter Чтец diff --git a/dist/translations/out/qc_tr.ts b/dist/translations/out/qc_tr.ts index 29bcaa0a..00e3de48 100644 --- a/dist/translations/out/qc_tr.ts +++ b/dist/translations/out/qc_tr.ts @@ -123,9 +123,19 @@ Muhammad Jibreel Muhammed Cibril + + + Ibrahim Al-Dosary (Warsh) + Ibrahim Al-Dosary (Warsh) + + + + Yassin Al-Jazaery (Warsh) + Yassin Al-Jazaery (Warsh) + - + Quran Companion Kura-an'ı Kerim Arkadaşı @@ -152,7 +162,7 @@ - + Navigation Gezinme @@ -213,7 +223,7 @@ - + About Qt Qt Hakkında @@ -258,49 +268,49 @@ Player controls - + Default Varsayılan - + Now playing: Şimdi oynatılıyor: - + Surah Sure - - - + + + Files Missing Files Missing - + The selected font files are missing, would you like to download it? The selected font files are missing, would you like to download it? - + The selected tafsir is missing, would you like to download it? The selected tafsir is missing, would you like to download it? - + The selected translation is missing, would you like to download it? The selected translation is missing, would you like to download it? - + Recitation not found Kıraat bulunamadı - + The recitation files for the current surah is missing, would you like to download it? Güncel Surenin kıraat dosyaları eksik, indirmek ister misiniz? @@ -657,8 +667,8 @@ - - + + size size @@ -674,32 +684,37 @@ - Uthmanic - Uthmanic + Hafs + Hafs - Uthmanic (annotated) - Uthmanic (annotated) + Hafs (annotated) + Hafs (annotated) + + + + Warsh + Warsh - + Side content Yan içerik - + Font Family Yazı Tipi Ailesi - + Translation Çeviri - + Shortcuts Kısayollar @@ -806,27 +821,32 @@ Translators - + Credits Credits - + + Quran Text + Quran Text + + + Recitations Recitations - + Tafsir/Translations Tafsir/Translations - + Surah Cards Surah Cards - + Libraries Libraries @@ -1223,7 +1243,7 @@ PlayerControls - + Reciter Reciter diff --git a/dist/translations/template.ts b/dist/translations/template.ts index 5c4cdbb7..5c31780e 100644 --- a/dist/translations/template.ts +++ b/dist/translations/template.ts @@ -123,9 +123,19 @@ Muhammad Jibreel + + + Ibrahim Al-Dosary (Warsh) + + + + + Yassin Al-Jazaery (Warsh) + + - + Quran Companion @@ -152,7 +162,7 @@ - + Navigation @@ -213,7 +223,7 @@ - + About Qt @@ -258,49 +268,49 @@ - + Default - + Now playing: - + Surah - - - + + + Files Missing - + The selected font files are missing, would you like to download it? - + The selected tafsir is missing, would you like to download it? - + The selected translation is missing, would you like to download it? - + Recitation not found - + The recitation files for the current surah is missing, would you like to download it? @@ -657,8 +667,8 @@ - - + + size @@ -674,32 +684,37 @@ - Uthmanic + Hafs - Uthmanic (annotated) + Hafs (annotated) - + + Warsh + + + + Side content - + Font Family - + Translation - + Shortcuts @@ -811,22 +826,27 @@ - + + Quran Text + + + + Recitations - + Tafsir/Translations - + Surah Cards - + Libraries @@ -1223,7 +1243,7 @@ PlayerControls - + Reciter diff --git a/dist/xdg/io.github._0xzer0x.qurancompanion.metainfo.xml b/dist/xdg/io.github._0xzer0x.qurancompanion.metainfo.xml index 9a6cd71e..4d16c05c 100644 --- a/dist/xdg/io.github._0xzer0x.qurancompanion.metainfo.xml +++ b/dist/xdg/io.github._0xzer0x.qurancompanion.metainfo.xml @@ -55,6 +55,19 @@ + + +
    +
  • Bug fixes for QCF v2 font
  • +
  • Bug fix for issue with the translation of Tafsir names
  • +
  • Added the Ayat font for Warsh 'an Nafi' narration
  • +
  • New reciter Ibrahim Al-Dosari (Warsh)
  • +
  • New reciter Yassine Al-Jazairi (Warsh)
  • +
  • Added saving of the state of the menu bar (visible/hidden)
  • +
  • Updating Qt to version 6.8
  • +
+
+
    diff --git a/resources.qrc b/resources.qrc index b34e6ec4..06346e76 100644 --- a/resources.qrc +++ b/resources.qrc @@ -17,4 +17,9 @@ resources/tray.png resources/files.xml + + dist/translations/qtbase/ar.qm + dist/translations/qtbase/ru.qm + dist/translations/qtbase/tr.qm + diff --git a/resources/files.xml b/resources/files.xml index 99139c29..3f1909cb 100644 --- a/resources/files.xml +++ b/resources/files.xml @@ -1,58 +1,58 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/reciters.xml b/resources/reciters.xml index 287a394e..68afcf44 100644 --- a/resources/reciters.xml +++ b/resources/reciters.xml @@ -1,97 +1,29 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/shortcuts.xml b/resources/shortcuts.xml index 12598fe0..c9505ef0 100644 --- a/resources/shortcuts.xml +++ b/resources/shortcuts.xml @@ -1,31 +1,29 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 6664d766..0c1765eb 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -1,6 +1,6 @@ name: quran-companion base: core22 -version: 1.3.1 +version: 1.3.2 title: Quran Companion website: https://0xzer0x.github.io/projects/quran-companion source-code: https://github.com/0xzer0x/quran-companion diff --git a/src/components/mainwindow.cpp b/src/components/mainwindow.cpp index 566c7631..38b7b4e5 100644 --- a/src/components/mainwindow.cpp +++ b/src/components/mainwindow.cpp @@ -35,10 +35,10 @@ MainWindow::MainWindow(QWidget* parent) loadVerse(); loadComponents(); - if (m_config.settings().value("WindowState").isNull()) - m_config.settings().setValue("WindowState", saveState()); + if (m_config.settings().value("Window/State").isNull()) + m_config.settings().setValue("Window/State", saveState()); else - restoreState(m_config.settings().value("WindowState").toByteArray()); + restoreState(m_config.settings().value("Window/State").toByteArray()); // connectors setupShortcuts(); @@ -48,6 +48,9 @@ MainWindow::MainWindow(QWidget* parent) this->show(); m_popup->setDockArea(dockWidgetArea(ui->sideDock)); + if (!m_config.settings().value("Window/VisibleMenubar").toBool()) { + toggleMenubar(); + } } void @@ -115,9 +118,9 @@ MainWindow::loadComponents() controls->setAlignment(Qt::AlignCenter); controls->setContentsMargins(0, 0, 0, 0); controls->setSpacing(0); - controls->addStretch(1); - controls->addWidget(m_playerControls); - controls->addStretch(1); + controls->addStretch(0); + controls->addWidget(m_playerControls, 1); + controls->addStretch(0); controlsFrame->setLayout(controls); ui->scrollAreaWidgetContents->layout()->addWidget(controlsFrame); ui->scrollAreaWidgetContents->layout()->addWidget(m_reader); @@ -789,6 +792,8 @@ MainWindow::toggleMenubar() else ui->menubar->show(); m_repeater->adjustPosition(); + m_config.settings().setValue("Window/VisibleMenubar", + ui->menubar->isVisible()); } void @@ -822,12 +827,13 @@ MainWindow::resizeEvent(QResizeEvent* event) m_popup->move(m_popup->notificationPos()); m_betaqaViewer->center(); m_repeater->adjustPosition(); + m_playerControls->adjustWidth(); } void MainWindow::saveReaderState() { - m_config.settings().setValue("WindowState", saveState()); + m_config.settings().setValue("Window/State", saveState()); m_config.settings().setValue("Reciter", m_playerControls->currentReciter()); m_config.settings().sync(); diff --git a/src/components/playercontrols.cpp b/src/components/playercontrols.cpp index 6d2fa251..d71dbc2e 100644 --- a/src/components/playercontrols.cpp +++ b/src/components/playercontrols.cpp @@ -1,7 +1,7 @@ #include "playercontrols.h" #include "ui_playercontrols.h" #include -#include +#include #include #include using namespace fa; @@ -207,6 +207,13 @@ PlayerControls::currentReciter() const return ui->cmbReciter->currentIndex(); } +void +PlayerControls::adjustWidth() +{ + QFrame* readerFrame = m_reader->findChild("frmReader"); + this->setMaximumWidth(std::min(readerFrame->width(), 950)); +} + void PlayerControls::hideEvent(QHideEvent* event) { diff --git a/src/components/playercontrols.h b/src/components/playercontrols.h index f3c43376..f46bb68c 100644 --- a/src/components/playercontrols.h +++ b/src/components/playercontrols.h @@ -40,6 +40,7 @@ public slots: * @brief toggle play/pause of the current verse */ void togglePlayback(); + void adjustWidth(); protected: void hideEvent(QHideEvent* event); diff --git a/src/components/playercontrols.ui b/src/components/playercontrols.ui index 374ebb43..38cf748f 100644 --- a/src/components/playercontrols.ui +++ b/src/components/playercontrols.ui @@ -16,12 +16,6 @@ 0 - - - 900 - 16777215 - - @@ -44,10 +38,10 @@ - QFrame::StyledPanel + QFrame::Shape::StyledPanel - QFrame::Raised + QFrame::Shadow::Raised @@ -78,7 +72,7 @@ - + 0 0 @@ -89,12 +83,6 @@ 0 - - - 150 - 16777215 - - PointingHandCursor @@ -103,20 +91,14 @@ - + 0 0 - - - 200 - 0 - - - 350 + 300 16777215 @@ -124,7 +106,7 @@ PointingHandCursor - Qt::Horizontal + Qt::Orientation::Horizontal @@ -221,23 +203,17 @@ - + 0 0 - 115 + 80 0 - - - 200 - 16777215 - - PointingHandCursor @@ -254,7 +230,7 @@ 100 - Qt::Horizontal + Qt::Orientation::Horizontal false @@ -294,13 +270,13 @@ - Qt::PlainText + Qt::TextFormat::PlainText true - Qt::AlignCenter + Qt::AlignmentFlag::AlignCenter 0 diff --git a/src/components/quranreader.cpp b/src/components/quranreader.cpp index 7919e5ed..92119bff 100644 --- a/src/components/quranreader.cpp +++ b/src/components/quranreader.cpp @@ -163,8 +163,9 @@ QuranReader::updateSideFont() void QuranReader::updateVerseType() { - Configuration::VerseType type = qvariant_cast( - m_config.settings().value("Reader/VerseType")); + ConfigurationSchema::VerseType type = + qvariant_cast( + m_config.settings().value("Reader/VerseType")); m_versesFont.setFamily( FontManager::getInstance().verseFontname(type, m_currVerse.page())); m_versesFont.setPointSize( @@ -195,7 +196,7 @@ QuranReader::redrawQuranPage(bool manualSz) { if (m_activeQuranBrowser == m_quranBrowsers[0]) { m_quranBrowsers[0]->constructPage(m_currVerse.page(), manualSz); - if (m_config.readerMode() == Configuration::DoublePage && + if (m_config.readerMode() == ConfigurationSchema::DoublePage && m_quranBrowsers[1]) m_quranBrowsers[1]->constructPage(m_currVerse.page() + 1, manualSz); } else { @@ -222,7 +223,7 @@ QuranReader::addSideContent() QLabel* contentLb; VerseFrame* verseContFrame; QString prevLbContent, currLbContent, glyphs; - if (m_config.verseType() == Configuration::Qcf) + if (m_config.verseType() == ConfigurationSchema::Qcf) m_versesFont.setFamily( FontManager::getInstance().pageFontname(m_currVerse.page())); @@ -233,7 +234,7 @@ QuranReader::addSideContent() verseContFrame = new VerseFrame(m_scrlVerseByVerse->widget()); verselb = new ClickableLabel(verseContFrame); contentLb = new QLabel(verseContFrame); - glyphs = m_config.verseType() == Configuration::Qcf + glyphs = m_config.verseType() == ConfigurationSchema::Qcf ? m_glyphService->getVerseGlyphs(verse->surah(), verse->number()) : m_quranService->verseText(verse->surah(), verse->number()); @@ -311,7 +312,7 @@ QuranReader::updatePageVerseInfoList() { if (m_activeQuranBrowser == m_quranBrowsers[0]) { m_vLists[0] = m_quranService->verseInfoList(m_currVerse.page()); - if (m_config.readerMode() == Configuration::DoublePage) + if (m_config.readerMode() == ConfigurationSchema::DoublePage) m_vLists[1] = m_quranService->verseInfoList(m_currVerse.page() + 1); m_activeVList = &m_vLists[0]; diff --git a/src/components/quranreader.h b/src/components/quranreader.h index d005c2e7..f330c515 100644 --- a/src/components/quranreader.h +++ b/src/components/quranreader.h @@ -17,9 +17,10 @@ #include #include #include +#include #include #include -typedef Configuration::ReaderMode ReaderMode; +typedef ConfigurationSchema::ReaderMode ReaderMode; namespace Ui { class QuranReader; diff --git a/src/dialogs/aboutdialog.ui b/src/dialogs/aboutdialog.ui index a06a2dfb..f558a778 100644 --- a/src/dialogs/aboutdialog.ui +++ b/src/dialogs/aboutdialog.ui @@ -1,654 +1,686 @@ - AboutDialog - - - - 0 - 0 - 381 - 448 - - - - About Quran Companion - - - - - - - 0 - 0 - - - - - 64 - 80 - - - - - 16777215 - 80 - - - + AboutDialog + + + + 0 + 0 + 388 + 480 + + + + About Quran Companion + + - - - - 0 - 0 - - - - - 64 - 64 - - - - - 64 - 64 - - - - - - - :/resources/tray.png - - - true - - - - - - - 2 - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - SF Pro Display - 11 - true - - - - Quran Companion - - - - - - - - - + + + 0 0 - - - - Version - - - - - - - - 0 - 0 - - - - - SF Pro Display - 10 - - - - 1.x.x - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - + - - - - - - - - - - - - - - QTabWidget::North - - - 0 - - - Qt::ElideLeft - - - false - - - - About - - - - - - - - A free, open-source Quran reader & player - - - - - - - %0 <a href="https://ojuba.org/waqf-2.0:%D8%B1%D8%AE%D8%B5%D8%A9_%D9%88%D9%82%D9%81_%D8%A7%D9%84%D8%B9%D8%A7%D9%85%D8%A9">%1</a> - - - true - - - - - - - - - 0 - - - - - - SF Pro Display - 10 - true - - - - Useful Links - - - - - - - https://0xzer0x.github.io/projects/quran-companion - - - - <a href="https://0xzer0x.github.io/projects/quran-companion">%0</a> - - - true - - - - - - - https://github.com/0xzer0x/quran-companion/issues - - - - <a href="https://github.com/0xzer0x/quran-companion/issues">%0</a> - - - true - - - - - - - https://github.com/0xzer0x/quran-companion/wiki/Contributing-Translations - - - - <a href="https://github.com/0xzer0x/quran-companion/wiki/Contributing-Translations">%0</a> - - - true - - - - - - - - - - Translators - - - - - - - - Türkçe - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - https://crowdin.com/profile/halak0013 - - - <a href="https://crowdin.com/profile/halak0013">@halak0013</a> - - - true - - - - - - - - - - - Русский - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - https://crowdin.com/profile/k-zamanov - - - <a href="https://crowdin.com/profile/k-zamanov">@k-zamanov</a> - - - true - - - - - - - - - - - Bahasa Indonesia - - - - - - - Qt::Horizontal - - + - 40 - 20 + 64 + 80 - - - - - - - https://crowdin.com/profile/tap - - - <a href="https://crowdin.com/profile/tap">@tap</a> - - - true - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - Credits - - - - - - 0 - - - - - - SF Pro Display - 10 - true - - - - - - - Recitations - - - - - - - - <a href="https://everyayah.com/recitations_ayat.html">EveryAyah</a> -<br/> -- <a href="https://alquran.cloud/cdn">AlQuran Cloud CDN</a> -<br/> -- <a href="https://quran.ksu.edu.sa/index.php">Ayat</a> - - - true - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - 0 - - - - - - SF Pro Display - 10 - true - - - - Tafsir/Translations - - - - - - - - <a href="https://quran.ksu.edu.sa/index.php">Ayat</a> -<br/> -- <a href="https://api-docs.quran.com/">Quran.com API</a> -<br/> -- <a href="https://mosshaf.com">Mosshaf</a> - - - true - - - - - - - Qt::Vertical - - + + - 20 - 40 + 16777215 + 80 - - - - - - - - - 0 - - - - - - SF Pro Display - 10 - true - - - - - - - Surah Cards - - - - - - - - <a href="https://albitaqat.com">AlBitaqat</a> - - - - - true - + + + + + + + 0 + 0 + + + + + 64 + 64 + + + + + 64 + 64 + + + + + + + :/resources/tray.png + + + true + + + + + + + 2 + + + + + Qt::Orientation::Vertical + + + + 20 + 40 + + + + + + + + + 11 + true + + + + Quran Companion + + + + + + + + + + 0 + 0 + + + + + 10 + + + + Version + + + + + + + + 0 + 0 + + + + + 10 + + + + 1.x.x + + + + + + + Qt::Orientation::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Orientation::Vertical + + + + 20 + 40 + + + + + + + + + + + + + + + + QTabWidget::TabPosition::North + + + 0 + + + Qt::TextElideMode::ElideLeft + + + false + + + + About + + + + + + + + A free, open-source Quran reader & player + + + + + + + %0 <a href="https://ojuba.org/waqf-2.0:%D8%B1%D8%AE%D8%B5%D8%A9_%D9%88%D9%82%D9%81_%D8%A7%D9%84%D8%B9%D8%A7%D9%85%D8%A9">%1</a> + + + true + + + + + + + + + 0 + + + + + + SF Pro Display + 10 + true + + + + Useful Links + + + + + + + https://0xzer0x.github.io/projects/quran-companion + + + - <a href="https://0xzer0x.github.io/projects/quran-companion">%0</a> + + + true + + + + + + + https://github.com/0xzer0x/quran-companion/issues + + + - <a href="https://github.com/0xzer0x/quran-companion/issues">%0</a> + + + true + + + + + + + https://github.com/0xzer0x/quran-companion/wiki/Contributing-Translations + + + - <a href="https://github.com/0xzer0x/quran-companion/wiki/Contributing-Translations">%0</a> + + + true + + + + + + - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - 0 - - - - - - SF Pro Display - 10 - true - - - - Libraries - + + + Translators + + + + + + + + Türkçe + + + + + + + Qt::Orientation::Horizontal + + + + 40 + 20 + + + + + + + + https://crowdin.com/profile/halak0013 + + + <a href="https://crowdin.com/profile/halak0013">@halak0013</a> + + + true + + + + + + + + + + + Русский + + + + + + + Qt::Orientation::Horizontal + + + + 40 + 20 + + + + + + + + https://crowdin.com/profile/k-zamanov + + + <a href="https://crowdin.com/profile/k-zamanov">@k-zamanov</a> + + + true + + + + + + + + + + + Bahasa Indonesia + + + + + + + Qt::Orientation::Horizontal + + + + 40 + 20 + + + + + + + + https://crowdin.com/profile/tap + + + <a href="https://crowdin.com/profile/tap">@tap</a> + + + true + + + + + + + + + Qt::Orientation::Vertical + + + + 20 + 40 + + + + + - - - - - - <a href="https://github.com/gamecreature/QtAwesome">QtAwesome</a> - - - true - + + + Credits + + + + + + 0 + + + + + + 10 + true + + + + Quran Text + + + + + + + - <a href="https://qurancomplex.gov.sa/en/techquran/dev/">QPC Developer Portal</a> <br/> - <a href="https://github.com/fawazahmed0/quran-api">fawazahmed0/quran-api</a> + + + true + + + + + + + Qt::Orientation::Vertical + + + + 20 + 40 + + + + + + + + + + 0 + + + + + + 10 + true + + + + + + + Recitations + + + + + + + - <a href="https://everyayah.com/recitations_ayat.html">EveryAyah</a> <br/> - <a href="https://alquran.cloud/cdn">AlQuran Cloud CDN</a> <br/> - <a href="https://quran.ksu.edu.sa/index.php">Ayat</a> + + + true + + + + + + + Qt::Orientation::Vertical + + + + 20 + 40 + + + + + + + + + + 0 + + + + + + 10 + true + + + + Tafsir/Translations + + + + + + + - <a href="https://quran.ksu.edu.sa/index.php">Ayat</a> <br/> - <a href="https://api-docs.quran.com/">Quran.com API</a> <br/> - <a href="https://mosshaf.com">Mosshaf</a> + + + true + + + + + + + Qt::Orientation::Vertical + + + + 20 + 40 + + + + + + + + + + 0 + + + + + + 10 + true + + + + + + + Surah Cards + + + + + + + - <a href="https://albitaqat.com">AlBitaqat</a> + + + true + + + + + + + Qt::Orientation::Vertical + + + + 20 + 40 + + + + + + + + + + 0 + + + + + + 10 + true + + + + Libraries + + + + + + + - <a href="https://github.com/gamecreature/QtAwesome">QtAwesome</a> + + + true + + + + + + + Qt::Orientation::Vertical + + + + 20 + 40 + + + + + + + - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Ok - - - - - - - - - - - btnBox - accepted() - AboutDialog - accept() - - - 248 - 254 - - - 157 - 274 - - - - - btnBox - rejected() - AboutDialog - reject() - - - 316 - 260 - - - 286 - 274 - - - - + + + + + + Qt::Orientation::Horizontal + + + QDialogButtonBox::StandardButton::Ok + + + + + + + + + + + btnBox + accepted() + AboutDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + btnBox + rejected() + AboutDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + diff --git a/src/dialogs/bookmarksdialog.cpp b/src/dialogs/bookmarksdialog.cpp index aad4324f..03240983 100644 --- a/src/dialogs/bookmarksdialog.cpp +++ b/src/dialogs/bookmarksdialog.cpp @@ -5,9 +5,9 @@ #include "bookmarksdialog.h" #include "ui_bookmarksdialog.h" +#include #include #include -#include #include BookmarksDialog::BookmarksDialog(QWidget* parent) @@ -141,7 +141,7 @@ BookmarksDialog::loadBookmarks(int surah) m_quranService->surahNames().at(verse.surah() - 1) + " - " + tr("Verse: ") + QString::number(verse.number()); QString glyphs = - m_config.verseType() == Configuration::Qcf + m_config.verseType() == ConfigurationSchema::Qcf ? m_glyphService->getVerseGlyphs(verse.surah(), verse.number()) : m_quranService->verseText(verse.surah(), verse.number()); diff --git a/src/dialogs/contentdialog.cpp b/src/dialogs/contentdialog.cpp index ac34731e..1b27955f 100644 --- a/src/dialogs/contentdialog.cpp +++ b/src/dialogs/contentdialog.cpp @@ -131,7 +131,7 @@ ContentDialog::setShownVerse(const Verse& newShownVerse) m_quranService->surahName(m_shownVerse.surah()) + " - " + tr("Verse: ") + QString::number(m_shownVerse.number()); QString glyphs = - m_config.verseType() == Configuration::Qcf + m_config.verseType() == ConfigurationSchema::Qcf ? m_glyphService->getVerseGlyphs(m_shownVerse.surah(), m_shownVerse.number()) : m_quranService->verseText(m_shownVerse.surah(), m_shownVerse.number()); diff --git a/src/dialogs/searchdialog.cpp b/src/dialogs/searchdialog.cpp index 3b056dbd..ffbcac94 100644 --- a/src/dialogs/searchdialog.cpp +++ b/src/dialogs/searchdialog.cpp @@ -5,8 +5,8 @@ #include "searchdialog.h" #include "ui_searchdialog.h" -#include #include +#include #include #include @@ -125,7 +125,7 @@ SearchDialog::showResults() QString info = tr("Surah: ") + m_quranService->surahNames().at(v.surah() - 1) + " - " + tr("Verse: ") + QString::number(v.number()); - QString glyphs = m_config.verseType() == Configuration::Qcf + QString glyphs = m_config.verseType() == ConfigurationSchema::Qcf ? m_glyphService->getVerseGlyphs(v.surah(), v.number()) : m_quranService->verseText(v.surah(), v.number()); diff --git a/src/dialogs/settingsdialog.h b/src/dialogs/settingsdialog.h index 645ab463..218e130c 100644 --- a/src/dialogs/settingsdialog.h +++ b/src/dialogs/settingsdialog.h @@ -28,7 +28,7 @@ #include #include #include -typedef Configuration::ReaderMode ReaderMode; +typedef ConfigurationSchema::ReaderMode ReaderMode; namespace Ui { class SettingsDialog; @@ -125,7 +125,7 @@ public slots: void updateSideFontSize(QString size); /** * @brief Update the type of font to use for displaying verses - * @param vt - value corresponding to entry in Configuration::VerseType + * @param vt - value corresponding to entry in ConfigurationSchema::VerseType */ void updateVerseType(int vt); void updateVerseFontsize(QString size); @@ -271,7 +271,7 @@ private slots: */ int m_translation; /** - * @brief Configuration::VerseType configuration value + * @brief ConfigurationSchema::VerseType configuration value */ int m_verseType; /** diff --git a/src/dialogs/settingsdialog.ui b/src/dialogs/settingsdialog.ui index 100be22c..ebef7444 100644 --- a/src/dialogs/settingsdialog.ui +++ b/src/dialogs/settingsdialog.ui @@ -23,16 +23,16 @@ - QTabWidget::West + QTabWidget::TabPosition::West - QTabWidget::Rounded + QTabWidget::TabShape::Rounded 0 - Qt::ElideNone + Qt::TextElideMode::ElideNone @@ -109,7 +109,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -147,7 +147,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -198,7 +198,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -397,12 +397,17 @@ - Uthmanic + Hafs - Uthmanic (annotated) + Hafs (annotated) + + + + + Warsh @@ -520,7 +525,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -665,7 +670,7 @@ - QAbstractItemView::DoubleClicked|QAbstractItemView::SelectedClicked + QAbstractItemView::EditTrigger::DoubleClicked|QAbstractItemView::EditTrigger::SelectedClicked false @@ -674,7 +679,7 @@ false - QAbstractItemView::SingleSelection + QAbstractItemView::SelectionMode::SingleSelection false @@ -694,7 +699,7 @@ - QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok + QDialogButtonBox::StandardButton::Apply|QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok diff --git a/src/main.cpp b/src/main.cpp index e673e916..d49c1a93 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -28,7 +28,7 @@ main(int argc, char* argv[]) QApplication a(argc, argv); QApplication::setApplicationName("Quran Companion"); QApplication::setOrganizationName("0xzer0x"); - QApplication::setApplicationVersion("1.3.1"); + QApplication::setApplicationVersion("1.3.2"); QSplashScreen splash(QPixmap(":/resources/splash.png")); splash.show(); diff --git a/src/repository/quranrepository.cpp b/src/repository/quranrepository.cpp index 73d236b6..147f82fe 100644 --- a/src/repository/quranrepository.cpp +++ b/src/repository/quranrepository.cpp @@ -171,13 +171,22 @@ QString QuranRepository::verseText(const int sIdx, const int vIdx) const { QSqlQuery dbQuery(*this); - if (m_config.verseType() == Configuration::Annotated) - dbQuery.prepare("SELECT aya_text_annotated FROM verses_v1 WHERE sura_no=:s " - "AND aya_no=:v"); - else - dbQuery.prepare( - "SELECT aya_text FROM verses_v1 WHERE sura_no=:s AND aya_no=:v"); + QString columnName; + switch (m_config.verseType()) { + case ConfigurationSchema::HafsAnnotated: + columnName = "aya_text_annotated"; + break; + case ConfigurationSchema::Warsh: + columnName = "aya_text_warsh"; + break; + default: + columnName = "aya_text"; + break; + } + dbQuery.prepare("SELECT " + columnName + + " FROM verses_v1 WHERE sura_no=:s " + "AND aya_no=:v"); dbQuery.bindValue(0, sIdx); dbQuery.bindValue(1, vIdx); @@ -225,7 +234,8 @@ Verse QuranRepository::verseById(const int id) const { QSqlQuery dbQuery(*this); - dbQuery.prepare("SELECT page,sura_no,aya_no FROM verses_v1 WHERE id=:i"); + dbQuery.prepare("SELECT page,sura_no,aya_no FROM verses_v" + + QString::number(m_config.qcfVersion()) + " WHERE id=:i"); dbQuery.bindValue(0, id); executeQuery(dbQuery, diff --git a/src/types/tafsir.cpp b/src/types/tafsir.cpp index 2f10d23b..d486a3b2 100644 --- a/src/types/tafsir.cpp +++ b/src/types/tafsir.cpp @@ -21,7 +21,7 @@ Tafsir::populateTafasir() if (token == QXmlStreamReader::StartElement) { if (reader.name().toString() == "tafsir") { QString name = qApp->translate( - "SettingsDialog", reader.attributes().value("name").toLatin1()); + "MainWindow", reader.attributes().value("name").toLatin1()); QString file = reader.attributes().value("file").toString(); bool isText = reader.attributes().value("text").toInt(); bool isExtra = reader.attributes().value("extra").toInt(); diff --git a/src/utils/configuration.cpp b/src/utils/configuration.cpp index ac83a5ba..0ec4176b 100644 --- a/src/utils/configuration.cpp +++ b/src/utils/configuration.cpp @@ -23,7 +23,8 @@ Configuration::Configuration() m_themeId = m_settings.value("Theme").toInt(); m_qcfVersion = m_settings.value("Reader/QCF").toInt(); m_language = qvariant_cast(m_settings.value("Language")); - m_readerMode = qvariant_cast(m_settings.value("Reader/Mode")); + m_readerMode = qvariant_cast( + m_settings.value("Reader/Mode")); m_darkMode = m_themeId == 2; } @@ -41,50 +42,16 @@ Configuration::setCustomPaths() void Configuration::checkGroups() { - for (int i = 0; i < 2; i++) - checkConfGroup(i); -} - -void -Configuration::checkConfGroup(int gId) -{ - switch (gId) { - case 0: - m_settings.setValue("Language", - m_settings.value("Language", (int)QLocale::English)); - m_settings.setValue( - "Theme", - m_settings.value("Theme", - QGuiApplication::styleHints()->colorScheme() == - Qt::ColorScheme::Dark - ? 2 - : 0)); - m_settings.setValue("VOTD", m_settings.value("VOTD", true)); - m_settings.setValue("MissingFileWarning", - m_settings.value("MissingFileWarning", true)); - m_settings.setValue("DownloadsDir", m_settings.value("DownloadsDir", "")); - break; - case 1: - m_settings.beginGroup("Reader"); - m_settings.setValue("Mode", m_settings.value("Mode", 0)); - m_settings.setValue("FGHighlight", m_settings.value("FGHighlight", 1)); - m_settings.setValue("Khatmah", m_settings.value("Khatmah", 0)); - m_settings.setValue("AdaptiveFont", - m_settings.value("AdaptiveFont", true)); - m_settings.setValue("QCF1Size", m_settings.value("QCF1Size", 22)); - m_settings.setValue("QCF2Size", m_settings.value("QCF2Size", 20)); - m_settings.setValue("QCF", m_settings.value("QCF", 1)); - m_settings.setValue("VerseType", m_settings.value("VerseType", 0)); - m_settings.setValue("VerseFontSize", - m_settings.value("VerseFontSize", 20)); - m_settings.setValue("Tafsir", m_settings.value("Tafsir", "sa3dy")); - m_settings.setValue("Translation", - m_settings.value("Translation", "en_khattab")); - m_settings.setValue( - "SideContentFont", - m_settings.value("SideContentFont", QFont("Expo Arabic", 14))); - m_settings.endGroup(); - break; + const ConfigurationSchema& schema = ConfigurationSchema::getInstance(); + QList allKeys = schema.getKeys().value(); + for (const QString& fullKey : allKeys) { + QString settingsKey = fullKey; + if (settingsKey.startsWith("General/")) { + settingsKey.remove(0, 8); + } + m_settings.setValue( + settingsKey, + m_settings.value(settingsKey, schema.getDefault(fullKey).value())); } } @@ -144,20 +111,20 @@ Configuration::language() const return m_language; } -Configuration::ReaderMode +ConfigurationSchema::ReaderMode Configuration::readerMode() const { return m_readerMode; } -Configuration::VerseType +ConfigurationSchema::VerseType Configuration::verseType() const { return m_verseType; } void -Configuration::setVerseType(VerseType newVerseType) +Configuration::setVerseType(ConfigurationSchema::VerseType newVerseType) { m_verseType = newVerseType; } diff --git a/src/utils/configuration.h b/src/utils/configuration.h index 84ec7439..a5c65758 100644 --- a/src/utils/configuration.h +++ b/src/utils/configuration.h @@ -4,30 +4,12 @@ #include #include #include +#include class Configuration { public: - enum VerseType - { - Qcf, - Uthmanic, - Annotated - }; - /** - * @brief ReaderMode enum represents the available modes for the Quran reader - * in MainWindow - */ - enum ReaderMode - { - SinglePage, ///< Single Quran page, side panel is used for displaying verses - ///< with translation - DoublePage ///< Two Quran pages, both panels are used to display Quran - ///< pages, no translation - }; - static Configuration& getInstance(); - void checkConfGroup(int gId); void loadUiTranslation(); void checkGroups(); @@ -36,9 +18,9 @@ class Configuration bool darkMode() const; int qcfVersion() const; QLocale::Language language() const; - ReaderMode readerMode() const; - VerseType verseType() const; - void setVerseType(VerseType newVerseType); + ConfigurationSchema::ReaderMode readerMode() const; + ConfigurationSchema::VerseType verseType() const; + void setVerseType(ConfigurationSchema::VerseType newVerseType); private: Configuration(); @@ -48,8 +30,8 @@ class Configuration int m_qcfVersion; QLocale::Language m_language; QSettings m_settings; - ReaderMode m_readerMode; - VerseType m_verseType; + ConfigurationSchema::ReaderMode m_readerMode; + ConfigurationSchema::VerseType m_verseType; }; #endif // CONFIGURATION_H diff --git a/src/utils/configurationschema.cpp b/src/utils/configurationschema.cpp new file mode 100644 index 00000000..a618c255 --- /dev/null +++ b/src/utils/configurationschema.cpp @@ -0,0 +1,97 @@ +#include +#include +#include +#include +#include +#include +#include +using std::make_pair; + +ConfigurationSchema& +ConfigurationSchema::getInstance() +{ + static ConfigurationSchema configurationSchema; + return configurationSchema; +} + +ConfigurationSchema::ConfigurationSchema() +{ + QHash general = { + make_pair("Language", (int)QLocale::English), + make_pair("Theme", + QGuiApplication::styleHints()->colorScheme() == + Qt::ColorScheme::Dark + ? 2 + : 0), + make_pair("VOTD", true), + make_pair("MissingFileWarning", true), + make_pair("DownloadsDir", QVariant()), + }; + QHash window = { + make_pair("State", QVariant()), + make_pair("VisibleMenubar", true), + }; + QHash reader = { + make_pair("Mode", 0), + make_pair("QCF", 1), + make_pair("VerseType", 0), + make_pair("VerseFontSize", 20), + make_pair("FGHighlight", 1), + make_pair("AdaptiveFont", true), + make_pair("QCF1Size", 22), + make_pair("QCF2Size", 20), + make_pair("Khatmah", 0), + make_pair("SideContentFont", QFont("Expo Arabic", 14)), + make_pair("Tafsir", "sa3dy"), + make_pair("Translation", "en_khattab"), + }; + + m_schema = { + make_pair("General", general), + make_pair("Window", window), + make_pair("Reader", reader), + }; +} + +optional +ConfigurationSchema::getDefault(QString key) const +{ + QString group = "General"; + if (key.contains("/")) { + QStringList parts = key.split("/"); + group = parts.at(0); + key = parts.at(1); + } + + if (!m_schema.contains(group) || !m_schema.value(group).contains(key)) { + return nullopt; + } + + return m_schema.value(group).value(key); +} + +optional> +ConfigurationSchema::getKeys(optional group) const +{ + if (!group.has_value()) { + QList allKeys; + for (const auto& group : m_schema.keys()) { + for (const auto& key : m_schema.value(group).keys()) { + allKeys.append(QString(group + "/" + key)); + } + } + return allKeys; + } + + if (!m_schema.contains(group.value())) { + return nullopt; + } + + return m_schema.value(group.value()).keys(); +} + +QList +ConfigurationSchema::getGroups() const +{ + return m_schema.keys(); +} diff --git a/src/utils/configurationschema.h b/src/utils/configurationschema.h new file mode 100644 index 00000000..5caad254 --- /dev/null +++ b/src/utils/configurationschema.h @@ -0,0 +1,42 @@ +#ifndef CONFIGURATIONSCHEMA_H +#define CONFIGURATIONSCHEMA_H + +#include +#include +#include +using std::nullopt; +using std::optional; + +class ConfigurationSchema +{ +public: + enum VerseType + { + Qcf, + Hafs, + HafsAnnotated, + Warsh + }; + /** + * @brief ReaderMode enum represents the available modes for the Quran reader + * in MainWindow + */ + enum ReaderMode + { + SinglePage, ///< Single Quran page, side panel is used for displaying verses + ///< with translation + DoublePage ///< Two Quran pages, both panels are used to display Quran + ///< pages, no translation + }; + + static ConfigurationSchema& getInstance(); + QList getGroups() const; + optional> getKeys(optional group = nullopt) const; + optional getDefault(QString key) const; + +private: + ConfigurationSchema(); + QHash> m_schema; +}; + +#endif // CONFIGURATIONSCHEMA_H diff --git a/src/utils/dbmanager.cpp b/src/utils/dbmanager.cpp deleted file mode 100644 index 3bfe0f34..00000000 --- a/src/utils/dbmanager.cpp +++ /dev/null @@ -1,932 +0,0 @@ -/** - * @file dbmanager.cpp - * @brief Implementation for DBManager - */ - -#include "dbmanager.h" - -QSharedPointer -DBManager::current() -{ - static QSharedPointer controller = - QSharedPointer::create(); - return controller; -} - -DBManager::DBManager(QObject* parent) - : QObject(parent) -{ - m_quranDbPath.setFile(m_assetsDir->filePath("quran.db")); - m_glyphsDbPath.setFile(m_assetsDir->filePath("glyphs.db")); - m_betaqatDbPath.setFile(m_assetsDir->filePath("betaqat.db")); - - // set database driver, set the path & open a connection with the db - QSqlDatabase::addDatabase("QSQLITE", "QuranCon"); - QSqlDatabase::addDatabase("QSQLITE", "GlyphsCon"); - QSqlDatabase::addDatabase("QSQLITE", "BetaqatCon"); - QSqlDatabase::addDatabase("QSQLITE", "BookmarksCon"); - QSqlDatabase::addDatabase("QSQLITE", "TafsirCon"); - QSqlDatabase::addDatabase("QSQLITE", "TranslationCon"); - - for (int i = 1; i <= 114; i++) - m_surahNames.append(getSurahName(i)); - - updateLoadedTafsir(); - updateLoadedTranslation(); -} - -/* ---------------- Database handling ---------------- */ - -void -DBManager::setOpenDatabase(Database db, QString path) -{ - if (m_currentDb == db) - return; - - m_currentDb = db; - m_openDBCon.close(); - switch (db) { - case Null: - break; - - case Quran: - m_openDBCon = QSqlDatabase::database("QuranCon"); - break; - - case Glyphs: - m_openDBCon = QSqlDatabase::database("GlyphsCon"); - break; - - case Bookmarks: - m_openDBCon = QSqlDatabase::database("BookmarksCon"); - break; - - case Tafsir: - m_openDBCon = QSqlDatabase::database("TafsirCon"); - break; - - case Translation: - m_openDBCon = QSqlDatabase::database("TranslationCon"); - break; - - case Betaqat: - m_openDBCon = QSqlDatabase::database("BetaqatCon"); - break; - } - - updateOpenDbFile(path); -} - -void -DBManager::updateOpenDbFile(const QString& filepath) -{ - m_openDBCon.setDatabaseName(filepath); - if (!m_openDBCon.open()) - qFatal("Couldn't open Database!"); -} - -bool -DBManager::setCurrentTafsir(int idx) -{ - if (idx < 0 || idx >= m_tafasir.size()) - return false; - if (m_currTafsir == m_tafasir[idx]) - return true; - - m_currTafsir = m_tafasir[idx]; - const QDir& baseDir = - m_currTafsir->isExtra() ? *m_downloadsDir : *m_assetsDir; - QString path = "tafasir/" + m_currTafsir->filename(); - if (!baseDir.exists(path)) - return false; - - m_tafsirDbPath.setFile(baseDir.filePath(path)); - updateOpenDbFile(m_tafsirDbPath.absoluteFilePath()); - return true; -} - -bool -DBManager::setCurrentTranslation(int idx) -{ - if (idx < 0 || idx >= m_translations.size()) - return false; - if (m_currTr == m_translations[idx]) - return true; - - m_currTr = m_translations[idx]; - const QDir& baseDir = m_currTr->isExtra() ? *m_downloadsDir : *m_assetsDir; - QString path = "translations/" + m_currTr->filename(); - if (!baseDir.exists(path)) - return false; - - m_transDbPath.setFile(baseDir.filePath(path)); - updateOpenDbFile(m_transDbPath.absoluteFilePath()); - return true; -} - -/* ---------------- Page-related methods ---------------- */ - -QPair -DBManager::getPageMetadata(const int page) -{ - setOpenDatabase(Database::Quran, m_quranDbPath.filePath()); - QSqlQuery dbQuery(m_openDBCon); - dbQuery.prepare( - "SELECT sura_no,jozz FROM verses_v1 WHERE page=:p ORDER BY id"); - dbQuery.bindValue(0, page); - - if (!dbQuery.exec()) - qCritical() << "Error occurred during getPageMetadata SQL statment exec"; - - dbQuery.next(); - // { surahIdx, jozz } - return { dbQuery.value(0).toInt(), dbQuery.value(1).toInt() }; -} - -QStringList -DBManager::getPageLines(const int page) -{ - setOpenDatabase(Database::Glyphs, m_glyphsDbPath.filePath()); - QSqlQuery dbQuery(m_openDBCon); - - QString query = "SELECT %0 FROM pages WHERE page_no=%1"; - query = query.arg("qcf_v" + QString::number(m_qcfVer), QString::number(page)); - - dbQuery.prepare(query); - if (!dbQuery.exec()) - qFatal("Couldn't execute getPageLines query!"); - - dbQuery.next(); - QStringList lines = dbQuery.value(0).toString().trimmed().split('\n'); - - return lines; -} - -QList> -DBManager::getVerseInfoList(int page) -{ - QList> viList; - setOpenDatabase(Database::Quran, m_quranDbPath.filePath()); - QSqlQuery dbQuery(m_openDBCon); - - QString query = - "SELECT sura_no,aya_no FROM verses_v%0 WHERE page=%1 ORDER BY id"; - dbQuery.prepare(query.arg(QString::number(m_qcfVer), QString::number(page))); - - if (!dbQuery.exec()) { - qCritical() << "Error occurred during getVerseInfoList SQL statment exec"; - } - - while (dbQuery.next()) { - QList v{ page, dbQuery.value(0).toInt(), dbQuery.value(1).toInt() }; - viList.append(v); - } - - return viList; -} - -int -DBManager::getJuzStartPage(const int juz) -{ - setOpenDatabase(Database::Glyphs, m_glyphsDbPath.filePath()); - QSqlQuery dbQuery(m_openDBCon); - - QString query = - "SELECT page FROM juz_glyphs WHERE juz=" + QString::number(juz); - dbQuery.prepare(query); - - if (!dbQuery.exec()) { - qCritical() << "Error occurred during getJuzStartPage SQL statment exec"; - } - dbQuery.next(); - - return dbQuery.value(0).toInt(); -} - -int -DBManager::getJuzOfPage(const int page) -{ - // returns the jozz number which the passed page belongs to - setOpenDatabase(Database::Glyphs, m_glyphsDbPath.filePath()); - QSqlQuery dbQuery(m_openDBCon); - - QString query = - "SELECT juz FROM juz_glyphs WHERE page=" + QString::number(page); - dbQuery.prepare(query); - - if (!dbQuery.exec()) { - qCritical() << "Error occurred during getJuzOfPage SQL statment exec"; - } - dbQuery.next(); - - return dbQuery.value(0).toInt(); -} - -/* ---------------- Glyph-related methods ---------------- */ - -QString -DBManager::getSurahNameGlyph(const int sura) -{ - setOpenDatabase(Database::Glyphs, m_glyphsDbPath.filePath()); - QSqlQuery dbQuery(m_openDBCon); - - dbQuery.prepare("SELECT qcf_v1 FROM surah_glyphs WHERE surah=:i"); - dbQuery.bindValue(0, sura); - if (!dbQuery.exec()) { - qCritical() << "Error occurred during getSurahNameGlyph SQL statment exec"; - } - - dbQuery.next(); - - return dbQuery.value(0).toString(); -} - -QString -DBManager::getJuzGlyph(const int juz) -{ - setOpenDatabase(Database::Glyphs, m_glyphsDbPath.filePath()); - QSqlQuery dbQuery(m_openDBCon); - - dbQuery.prepare("SELECT text FROM juz_glyphs WHERE juz=:j"); - dbQuery.bindValue(0, juz); - if (!dbQuery.exec()) { - qCritical() << "Error occurred during getJuzGlyph SQL statment exec"; - } - - dbQuery.next(); - - return dbQuery.value(0).toString(); -} - -QString -DBManager::getVerseGlyphs(const int sIdx, const int vIdx) -{ - if (m_verseType != VerseType::Qcf) - return getVerseText(sIdx, vIdx); - - setOpenDatabase(Database::Glyphs, m_glyphsDbPath.filePath()); - - QSqlQuery dbQuery(m_openDBCon); - - QString query = "SELECT %0 FROM ayah_glyphs WHERE surah=%1 AND ayah=%2"; - query = query.arg("qcf_v" + QString::number(m_qcfVer), - QString::number(sIdx), - QString::number(vIdx)); - - dbQuery.prepare(query); - if (!dbQuery.exec()) - qFatal("Couldn't execute getVerseGlyphs query!"); - - dbQuery.next(); - - return dbQuery.value(0).toString(); -} - -/* ---------------- Surah-related methods ---------------- */ - -QString -DBManager::getSurahName(const int sIdx, bool ar) -{ - setOpenDatabase(Database::Quran, m_quranDbPath.filePath()); - QSqlQuery dbQuery(m_openDBCon); - - if (m_languageCode == QLocale::Arabic || ar) - dbQuery.prepare("SELECT sura_name_ar FROM verses_v1 WHERE sura_no=:i"); - else - dbQuery.prepare("SELECT sura_name_en FROM verses_v1 WHERE sura_no=:i"); - - dbQuery.bindValue(0, sIdx); - if (!dbQuery.exec()) { - qCritical() << "Error occurred during getSurahName SQL statment exec"; - } - - dbQuery.next(); - return dbQuery.value(0).toString(); -} - -QString -DBManager::getBetaqa(const int surah) -{ - setOpenDatabase(Betaqat, m_betaqatDbPath.filePath()); - QSqlQuery dbQuery(m_openDBCon); - - if (m_languageCode == QLocale::Arabic) - dbQuery.prepare("SELECT text FROM content WHERE sura=:i"); - else - dbQuery.prepare("SELECT text_en FROM content WHERE sura=:i"); - - dbQuery.bindValue(0, surah); - if (!dbQuery.exec()) { - qCritical() << "Error occurred during getBetaqa SQL statment exec"; - } - - dbQuery.next(); - return dbQuery.value(0).toString(); -} - -int -DBManager::getVerseId(const int sIdx, const int vIdx) -{ - setOpenDatabase(Database::Quran, m_quranDbPath.filePath()); - QSqlQuery dbQuery(m_openDBCon); - dbQuery.prepare("SELECT id FROM verses_v1 WHERE sura_no=:s AND aya_no=:v"); - dbQuery.bindValue(0, sIdx); - dbQuery.bindValue(1, vIdx); - - if (!dbQuery.exec()) { - qCritical() << "Error occurred during getVerseId SQL statment exec"; - } - - dbQuery.next(); - return dbQuery.value(0).toInt(); -} - -QList -DBManager::getVerseById(const int id) -{ - setOpenDatabase(Database::Quran, m_quranDbPath.filePath()); - QSqlQuery dbQuery(m_openDBCon); - dbQuery.prepare("SELECT page,sura_no,aya_no FROM verses_v1 WHERE id=:i"); - dbQuery.bindValue(0, id); - - if (!dbQuery.exec()) - qCritical() << "Error occurred during getVerseById SQL statement exec"; - - dbQuery.next(); - - return { dbQuery.value(0).toInt(), - dbQuery.value(1).toInt(), - dbQuery.value(2).toInt() }; -} - -int -DBManager::getSurahVerseCount(const int surahIdx) -{ - setOpenDatabase(Database::Quran, m_quranDbPath.filePath()); - QSqlQuery dbQuery(m_openDBCon); - - dbQuery.prepare( - "SELECT aya_no FROM verses_v1 WHERE sura_no=:idx ORDER BY aya_no DESC"); - dbQuery.bindValue(0, surahIdx); - - if (!dbQuery.exec()) { - qCritical() << "Error occurred during getSurahVerseCount SQL statment exec"; - return -1; - } - - dbQuery.next(); - return dbQuery.value(0).toInt(); -} - -int -DBManager::getSurahStartPage(int surahIdx) -{ - setOpenDatabase(Database::Quran, m_quranDbPath.filePath()); - QSqlQuery dbQuery(m_openDBCon); - - dbQuery.prepare("SELECT page FROM verses_v1 WHERE sura_no=:sn AND aya_no=1"); - dbQuery.bindValue(0, surahIdx); - - if (!dbQuery.exec()) { - qCritical() << "Error occurred during getSurahStartPage SQL statment exec"; - } - dbQuery.next(); - - return dbQuery.value(0).toInt(); -} - -QList -DBManager::surahNameList() -{ - - return m_surahNames; -} - -QList> -DBManager::searchSurahs(QString searchText, - const QList surahs, - const bool whole) -{ - QList> results; - setOpenDatabase(Database::Quran, m_quranDbPath.filePath()); - QSqlQuery dbQuery(m_openDBCon); - - QString q = "SELECT page,sura_no,aya_no FROM verses_v" + - QString::number(m_qcfVer) + " WHERE ("; - for (int i = 0; i < surahs.size(); i++) { - q.append("sura_no=" + QString::number(surahs.at(i)) + ' '); - if (i != surahs.size() - 1) - q.append("OR "); - } - - if (whole) - q.append(") AND (aya_text_emlaey like '" + searchText + - " %' OR aya_text_emlaey like '% " + searchText + - " %') ORDER BY id"); - else - q.append(") AND (aya_text_emlaey like '%" + searchText + "%') ORDER BY id"); - - dbQuery.prepare(q); - if (!dbQuery.exec()) { - qCritical() << "Error occurred during searchSurahs SQL statment exec"; - } - - while (dbQuery.next()) { - results.append({ dbQuery.value(0).toInt(), - dbQuery.value(1).toInt(), - dbQuery.value(2).toInt() }); - } - - return results; -} - -QList -DBManager::searchSurahNames(QString text) -{ - QList results; - setOpenDatabase(Database::Quran, m_quranDbPath.filePath()); - QSqlQuery dbQuery(m_openDBCon); - QString q = - "SELECT DISTINCT sura_no FROM verses_v1 WHERE (sura_name_ar like '%" + - text + - "%' OR " - "sura_name_en like '%" + - text + "%')"; - - dbQuery.prepare(q); - if (!dbQuery.exec()) { - qCritical() << "Error occurred during searchSurahNames SQL statment exec"; - } - - while (dbQuery.next()) { - results.append(dbQuery.value(0).toInt()); - } - - return results; -} - -/* ---------------- Verse-related methods ---------------- */ - -bool -DBManager::loadVerse(const int khatmahId, QList& vInfo) -{ - setOpenDatabase(Database::Bookmarks, m_bookmarksFilepath); - QSqlQuery dbQuery(m_openDBCon); - - QString q = QString::asprintf( - "SELECT page,surah,number FROM khatmah WHERE id=%i", khatmahId); - if (!dbQuery.exec(q)) { - qCritical() << "Couldn't execute getPosition SQL query!"; - return false; - } - if (!dbQuery.next()) - return false; - - vInfo[0] = dbQuery.value(0).toInt(); - vInfo[1] = dbQuery.value(1).toInt(); - vInfo[2] = dbQuery.value(2).toInt(); - return true; -} - -int -DBManager::addKhatmah(QList vInfo, const QString name, const int id) -{ - setOpenDatabase(Database::Bookmarks, m_bookmarksFilepath); - QSqlQuery dbQuery(m_openDBCon); - dbQuery.exec( - "CREATE TABLE IF NOT EXISTS khatmah(id INTEGER PRIMARY KEY " - "AUTOINCREMENT, name TEXT, page INTEGER, surah INTEGER, number INTEGER)"); - QString q; - if (id == -1) { - q = "INSERT INTO khatmah(name, page, surah, number) VALUES ('%0', %1, %2, " - "%3)"; - dbQuery.prepare(q.arg(name, - QString::number(vInfo[0]), - QString::number(vInfo[1]), - QString::number(vInfo[2]))); - } else { - q = "REPLACE INTO khatmah VALUES " - "(%0, " - "'%1', %2, %3, %4)"; - dbQuery.prepare(q.arg(QString::number(id), - name, - QString::number(vInfo[0]), - QString::number(vInfo[1]), - QString::number(vInfo[2]))); - } - - if (!dbQuery.exec()) { - qCritical() << "Couldn't create new khatmah entry!"; - qDebug() << m_openDBCon.lastError(); - return -1; - } - - if (id != -1) - return id; - - dbQuery.exec("SELECT id FROM khatmah ORDER BY id DESC limit 1"); - dbQuery.next(); - return dbQuery.value(0).toInt(); -} - -bool -DBManager::editKhatmahName(const int khatmahId, QString newName) -{ - setOpenDatabase(Database::Bookmarks, m_bookmarksFilepath); - QSqlQuery dbQuery(m_openDBCon); - QString q = "SELECT DISTINCT id FROM khatmah WHERE name='%0'"; - if (!dbQuery.exec(q.arg(newName))) { - qCritical() << "Couldn't execute sql query: " << dbQuery.lastQuery(); - qDebug() << m_openDBCon.lastError(); - return false; - } - if (dbQuery.next()) - return false; - - q = "UPDATE khatmah SET name='%0' WHERE id=%1"; - if (!dbQuery.exec(q.arg(newName, QString::number(khatmahId)))) { - qCritical() << "Couldn't rename khatmah entry!"; - qDebug() << m_openDBCon.lastError(); - return false; - } - - m_openDBCon.commit(); - return true; -} - -void -DBManager::removeKhatmah(const int id) -{ - setOpenDatabase(Database::Bookmarks, m_bookmarksFilepath); - QSqlQuery dbQuery(m_openDBCon); - if (!dbQuery.exec(QString::asprintf("DELETE FROM khatmah WHERE id=%i", id))) - qDebug() << "Couldn't execute query: " << dbQuery.lastQuery(); -} - -bool -DBManager::saveActiveKhatmah(QList vInfo) -{ - setOpenDatabase(Database::Bookmarks, m_bookmarksFilepath); - QSqlQuery dbQuery(m_openDBCon); - QString q = QString::asprintf( - "UPDATE khatmah SET page=%i, surah=%i, number=%i WHERE id=%i", - vInfo[0], - vInfo[1], - vInfo[2], - m_activeKhatmah); - if (!dbQuery.exec(q)) { - qCritical() << "Couldn't save position in mushaf"; - return false; - } - if (!m_openDBCon.commit()) - return false; - - return true; -} - -QString -DBManager::getVerseText(const int sIdx, const int vIdx) -{ - setOpenDatabase(Database::Quran, m_quranDbPath.filePath()); - QSqlQuery dbQuery(m_openDBCon); - if (m_verseType == VerseType::Annotated) - dbQuery.prepare("SELECT aya_text_annotated FROM verses_v1 WHERE sura_no=:s " - "AND aya_no=:v"); - else - dbQuery.prepare( - "SELECT aya_text FROM verses_v1 WHERE sura_no=:s AND aya_no=:v"); - - dbQuery.bindValue(0, sIdx); - dbQuery.bindValue(1, vIdx); - - if (!dbQuery.exec()) { - qCritical() << "Error occurred during getVerseText SQL statment exec"; - } - dbQuery.next(); - - return dbQuery.value(0).toString(); -} - -QList -DBManager::getAllKhatmah() -{ - QList res; - setOpenDatabase(Database::Bookmarks, m_bookmarksFilepath); - QSqlQuery dbQuery(m_openDBCon); - if (!dbQuery.exec("SELECT id FROM khatmah")) - qCritical() << "Couldn't execute sql query: " << dbQuery.lastQuery(); - - while (dbQuery.next()) - res.append(dbQuery.value(0).toInt()); - - return res; -} - -QString -DBManager::getKhatmahName(const int id) -{ - setOpenDatabase(Database::Bookmarks, m_bookmarksFilepath); - QSqlQuery dbQuery(m_openDBCon); - if (!dbQuery.exec("SELECT name FROM khatmah WHERE id=" + QString::number(id))) - qCritical() << "Couldn't execute sql query: " << dbQuery.lastQuery(); - - dbQuery.next(); - return dbQuery.value(0).toString(); -} - -QList -DBManager::randomVerse() -{ - setOpenDatabase(Database::Quran, m_quranDbPath.filePath()); - QSqlQuery dbQuery(m_openDBCon); - - int id = QRandomGenerator::global()->bounded(1, 6237); - dbQuery.prepare("SELECT page,sura_no,aya_no FROM verses_v" + - QString::number(m_qcfVer) + - " WHERE id=" + QString::number(id)); - - if (!dbQuery.exec()) { - qCritical() << "Error occurred during randomVerse SQL statment exec"; - } - dbQuery.next(); - return { dbQuery.value(0).toInt(), - dbQuery.value(1).toInt(), - dbQuery.value(2).toInt() }; -} - -int -DBManager::getVersePage(const int& surahIdx, const int& verse) -{ - setOpenDatabase(Database::Quran, m_quranDbPath.filePath()); - QSqlQuery dbQuery(m_openDBCon); - - QString query = "SELECT page FROM verses_v%0 WHERE sura_no=%1 AND aya_no=%2"; - dbQuery.prepare(query.arg(QString::number(m_qcfVer), - QString::number(surahIdx), - QString::number(verse))); - - if (!dbQuery.exec()) { - qCritical() << "Error occurred during getVersePage SQL statment exec"; - } - dbQuery.next(); - - return dbQuery.value(0).toInt(); -} - -QList> -DBManager::searchVerses(QString searchText, - const int range[2], - const bool whole) -{ - QList> results; - setOpenDatabase(Database::Quran, m_quranDbPath.filePath()); - QSqlQuery dbQuery(m_openDBCon); - - QString q = "SELECT page,sura_no,aya_no FROM verses_v" + - QString::number(m_qcfVer) + - " WHERE (page >= " + QString::number(range[0]) + - " AND page <= " + QString::number(range[1]) + ")"; - - if (whole) - q.append(" AND (aya_text_emlaey like '" + searchText + - " %' OR aya_text_emlaey like '% " + searchText + - " %') ORDER BY id"); - else - q.append(" AND (aya_text_emlaey like '%" + searchText + "%') ORDER BY id"); - - dbQuery.prepare(q); - if (!dbQuery.exec()) { - qCritical() << "Error occurred during searchVerses SQL statment exec"; - } - - while (dbQuery.next()) { - QList entry{ dbQuery.value(0).toInt(), - dbQuery.value(1).toInt(), - dbQuery.value(2).toInt() }; - results.append(entry); - } - - return results; -} - -QList> -DBManager::bookmarkedVerses(int surahIdx) -{ - QList> results; - setOpenDatabase(Database::Bookmarks, m_bookmarksFilepath); - QSqlQuery dbQuery(m_openDBCon); - QString q = "SELECT page,surah,number FROM favorites"; - if (surahIdx != -1) - q.append(" WHERE surah=" + QString::number(surahIdx)); - - dbQuery.prepare(q.append(" ORDER BY surah, number")); - if (!dbQuery.exec()) - qCritical() << "Couldn't execute bookmarkedVerses SELECT query"; - - while (dbQuery.next()) { - results.append({ dbQuery.value(0).toInt(), - dbQuery.value(1).toInt(), - dbQuery.value(2).toInt() }); - } - - return results; -} - -bool -DBManager::isBookmarked(QList vInfo) -{ - setOpenDatabase(Database::Bookmarks, m_bookmarksFilepath); - QSqlQuery dbQuery(m_openDBCon); - - dbQuery.prepare( - "SELECT page FROM favorites WHERE page=:p AND surah=:s AND number=:n"); - dbQuery.bindValue(0, vInfo[0]); - dbQuery.bindValue(1, vInfo[1]); - dbQuery.bindValue(2, vInfo[2]); - - if (!dbQuery.exec()) { - qWarning() << "Couldn't check if verse is bookmarked"; - return false; - } - - dbQuery.next(); - - return dbQuery.isValid(); -} - -bool -DBManager::addBookmark(QList vInfo) -{ - setOpenDatabase(Database::Bookmarks, m_bookmarksFilepath); - QSqlQuery dbQuery(m_openDBCon); - dbQuery.exec("CREATE TABLE IF NOT EXISTS favorites(id INTEGER PRIMARY KEY " - "AUTOINCREMENT," - "page INTEGER, surah INTEGER, number INTEGER)"); - - dbQuery.prepare( - "INSERT INTO favorites(page, surah, number) VALUES (:p, :s, :n)"); - dbQuery.bindValue(0, vInfo[0]); - dbQuery.bindValue(1, vInfo[1]); - dbQuery.bindValue(2, vInfo[2]); - - if (!dbQuery.exec()) { - qWarning() << "Couldn't add verse to bookmarks db"; - return false; - } - - m_openDBCon.commit(); - emit bookmarkAdded(); - return true; -} - -bool -DBManager::removeBookmark(QList vInfo) -{ - setOpenDatabase(Database::Bookmarks, m_bookmarksFilepath); - QSqlQuery dbQuery(m_openDBCon); - dbQuery.prepare( - "DELETE FROM favorites WHERE page=:p AND surah=:s AND number=:n"); - dbQuery.bindValue(0, vInfo[0]); - dbQuery.bindValue(1, vInfo[1]); - dbQuery.bindValue(2, vInfo[2]); - - if (!dbQuery.exec()) { - qWarning() << "Couldn't remove verse from bookmarks"; - return false; - } - - emit bookmarkRemoved(); - return true; -} - -/* ---------------- Side content methods ---------------- */ - -QString -DBManager::getTafsir(const int sIdx, const int vIdx) -{ - setOpenDatabase(Database::Tafsir, m_tafsirDbPath.filePath()); - - QSqlQuery dbQuery(m_openDBCon); - - dbQuery.prepare("SELECT text FROM content WHERE sura=:s AND aya=:v"); - dbQuery.bindValue(0, sIdx); - dbQuery.bindValue(1, vIdx); - - if (!dbQuery.exec()) - qCritical("Couldn't execute getTafsir query!"); - - dbQuery.next(); - - return dbQuery.value(0).toString(); -} - -QString -DBManager::getTranslation(const int sIdx, const int vIdx) -{ - setOpenDatabase(Database::Translation, m_transDbPath.filePath()); - - QSqlQuery dbQuery(m_openDBCon); - - dbQuery.prepare("SELECT text FROM content WHERE sura=:s AND aya=:v"); - dbQuery.bindValue(0, sIdx); - dbQuery.bindValue(1, vIdx); - - if (!dbQuery.exec()) - qCritical("Couldn't execute getTranslation query!"); - - dbQuery.next(); - - return dbQuery.value(0).toString(); -} - -void -DBManager::saveThoughts(QList vInfo, const QString& text) -{ - int id = getVerseId(vInfo[1], vInfo[2]); - setOpenDatabase(Database::Bookmarks, m_bookmarksFilepath); - QSqlQuery dbQuery(m_openDBCon); - dbQuery.exec("CREATE TABLE IF NOT EXISTS thoughts(id INTEGER PRIMARY KEY " - "UNIQUE," - "page INTEGER, surah INTEGER, number INTEGER, text TEXT)"); - - dbQuery.prepare("REPLACE INTO thoughts(id, page, surah, number, text) " - "VALUES(:i, :p, :s, :n, :t)"); - dbQuery.bindValue(0, id); - dbQuery.bindValue(1, vInfo[0]); - dbQuery.bindValue(2, vInfo[1]); - dbQuery.bindValue(3, vInfo[2]); - dbQuery.bindValue(4, text); - - if (!dbQuery.exec()) - qCritical() << "SQL statement execution error:" << dbQuery.lastError(); - - m_openDBCon.commit(); -} - -QString -DBManager::getThoughts(QList vInfo) -{ - setOpenDatabase(Database::Bookmarks, m_bookmarksFilepath); - QSqlQuery dbQuery(m_openDBCon); - dbQuery.prepare( - "SELECT text FROM thoughts WHERE page=:p AND surah=:s AND number=:n"); - dbQuery.bindValue(0, vInfo[0]); - dbQuery.bindValue(1, vInfo[1]); - dbQuery.bindValue(2, vInfo[2]); - - if (!dbQuery.exec()) - qCritical() << "SQL statement execution error:" << dbQuery.lastError(); - - dbQuery.next(); - return dbQuery.value(0).toString(); -} - -void -DBManager::updateLoadedTafsir() -{ - int currTafsir = m_settings->value("Reader/Tafsir").toInt(); - setCurrentTafsir(currTafsir); -} - -void -DBManager::updateLoadedTranslation() -{ - int currTrans = m_settings->value("Reader/Translation").toInt(); - setCurrentTranslation(currTrans); -} - -void -DBManager::setActiveKhatmah(const int id) -{ - m_activeKhatmah = id; -} - -void -DBManager::setVerseType(VerseType newVerseType) -{ - m_verseType = newVerseType; -} - -VerseType -DBManager::getVerseType() const -{ - return m_verseType; -} - -const int -DBManager::activeKhatmah() const -{ - return m_activeKhatmah; -} - -QSharedPointer -DBManager::currTafsir() const -{ - return m_currTafsir; -} - -QSharedPointer -DBManager::currTranslation() const -{ - return m_currTr; -} diff --git a/src/utils/dbmanager.h b/src/utils/dbmanager.h deleted file mode 100644 index 58a2b0c0..00000000 --- a/src/utils/dbmanager.h +++ /dev/null @@ -1,423 +0,0 @@ -/** - * @file dbmanager.h - * @brief Header file for DBManager - */ - -#ifndef DBMANAGER_H -#define DBMANAGER_H - -#include "types/tafsir.h" -#include "types/translation.h" -#include "utils/dirmanager.h" -#include "utils/settings.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -typedef Settings::VerseType VerseType; - -/** - * @brief DBManager is as an interface for preforming queries to - * different database files holding application data. - */ -class DBManager : public QObject -{ - Q_OBJECT - -public: - static QSharedPointer current(); - /** - * @brief Database enum holds different values representing database files - * used in different member functions. - */ - enum Database - { - Null, ///< default value - Quran, ///< (quran.db) main Quran database file - Glyphs, ///< (glyphs.db) QCF glyphs database - Betaqat, - Bookmarks, ///< (bookmarks.db) bookmarked verses and khatmah database - Tafsir, ///< currently selected tafsir database file - Translation ///< currently selected translation database file - }; - - /** - * @brief Class constructor - * @param parent - pointer to parent widget - */ - explicit DBManager(QObject* parent = nullptr); - /** - * @brief getter for translated Surah names QList - * @return QList of Surah name strings - */ - QList surahNameList(); - /** - * @brief sets the active tafsir - * @param tafsirName - DBManager::Tafsir entry - */ - bool setCurrentTafsir(int idx); - /** - * @brief sets the active translation - * @param translationName - DBManager::Translation entry - */ - bool setCurrentTranslation(int idx); - /** - * @brief gets the surah number and juz number of the first verse in the page, - * used to display page header information - * @param page - Quran page number - * @return QList of 2 integers [0: surah index, 1: juz number] - */ - QPair getPageMetadata(const int page); - /** - * @brief get Quran page QCF glyphs separated as lines - * @param page - Quran page number - * @return QList of page lines - */ - QStringList getPageLines(const int page); - /** - * @brief gets a QList of ::Verse instances for the page verses - * @param page - Quran page number - * @return QList of ::Verse instances - */ - QList> getVerseInfoList(const int page); - /** - * @brief gets the surah name glyph for the QCF_BSML font, used to render - * surah frame in Quran page - * @param sura - sura number (1-114) - * @return QString of glyphs - */ - QString getSurahNameGlyph(const int sura); - /** - * @brief gets the juz name in arabic, used in page header - * @param juz - juz number - * @return QString of the juz name - */ - QString getJuzGlyph(const int juz); - /** - * @brief gets the verse QCF glyphs for the corresponding QCF page font - * @param sIdx - sura number (1-114) - * @param vIdx - verse number - * @return QString of verse glyphs - */ - QString getVerseGlyphs(const int sIdx, const int vIdx); - /** - * @brief gets the verse text - * @param sIdx - sura number (1-114) - * @param vIdx - verse number - * @return QString of the verse text - */ - QString getVerseText(const int sIdx, const int vIdx); - /** - * @brief sets the given ::Verse as the last position reached in the current - * active khatmah - * @param v - ::Verse reached in khatmah - */ - bool saveActiveKhatmah(QList vInfo); - /** - * @brief get all available khatmah ids - * @return QList of khatmah id(s) - */ - QList getAllKhatmah(); - /** - * @brief get the name of the khatmah with id given - * @return QString containing the khatmah name - */ - QString getKhatmahName(const int id); - /** - * @brief gets the last position saved for the khatmah with the id given and - * stores the position in the ::Verse v - * @return boolean indicating a successful operation (false in case of error - * and in case id does not exist) - */ - bool loadVerse(const int khatmahId, QList& vInfo); - /** - * @brief add a new khatmah/replace khatmah with given id with position of - * ::Verse v - * @param v - ::Verse to set as the khatmah position - * @param name - new khatmah name - * @param id - id of khatmah to replace, -1 means do not replace (default: -1) - * @return id of newly added khatmah or id parameter if defined - */ - int addKhatmah(QList vInfo, const QString name, const int id = -1); - /** - * @brief rename the khatmah with the given id to newName - * @param khatmahId - id of khatmah to rename - * @param newName - new name to set - * @return boolean indicating a successful operation (false in case the name - * exists) - */ - bool editKhatmahName(const int khatmahId, QString newName); - /** - * @brief remove the khatmah with the given id from database - * @param id - id of khatmah to remove - */ - void removeKhatmah(const int id); - /** - * @brief gets the number of the last verse in the surah passed - * @param surahIdx - surah number (1-114) - * @return number of verses in the sura - */ - int getSurahVerseCount(const int surahIdx); - /** - * @brief gets the page where the surah begins - * @param surahIdx - sura number - * @return page of the first verse in the sura - */ - int getSurahStartPage(int surahIdx); - /** - * @brief gets the surah name in English or Arabic (default is English) - * @param sIdx - sura number - * @param ar - boolean to return arabic sura name - * @return QString containing the sura name - */ - QString getSurahName(const int sIdx, bool ar = false); - /** - * @brief get the surah card (betaqa) content - * @param surah - surah number - * @return QString of the surah card text - */ - QString getBetaqa(const int surah); - /** - * @brief gets the corresponding id for the verse in the database - * @param sIdx - sura number - * @param vIdx - verse number - * @return id of the verse - */ - int getVerseId(const int sIdx, const int vIdx); - /** - * @brief get the verse with the corresponding id and return it as a ::Verse - * instance - * @param id - verse id - * @return ::Verse instance - */ - QList getVerseById(const int id); - /** - * @brief gets the page where the verse is found - * @param surahIdx - sura number - * @param verse - verse number - * @return page number - */ - int getVersePage(const int& surahIdx, const int& verse); - /** - * @brief gets the page where the corresponding juz starts - * @param juz - juz number - * @return page number - */ - int getJuzStartPage(const int juz); - /** - * @brief get the juz which the passed page is a part of - * @param page - page number - * @return juz number - */ - int getJuzOfPage(const int page); - /** - * @brief searches the database for surahs matching the given text pattern, - * the pattern can be either in English or Arabic - * @param text - name / part of the name of the sura - * @return QList of sura numbers which contain the given text - */ - QList searchSurahNames(QString text); - /** - * @brief search specific surahs for the given search text - * @param searchText - text to search for - * @param surahs - QList of surah numbers to search in - * @param whole - boolean value to search for whole words only - * @return QList of ::Verse instances representing the search results - */ - QList> searchSurahs(QString searchText, - const QList surahs, - const bool whole = false); - /** - * @brief search a range of pages for the given search text - * @param searchText - text to search for - * @param range - array of start & end page numbers - * @param whole - boolean value to indicate search for whole words only - * @return QList of ::Verse instances representing the search results - */ - QList> searchVerses(QString searchText, - const int range[2] = new int[2]{ 1, 604 }, - const bool whole = false); - /** - * @brief gets the tafsir content for the given verse using the active - * DBManager::Tafsir - * @param sIdx - surah number - * @param vIdx - verse number - * @return QString containing the tafsir of the verse - */ - QString getTafsir(const int sIdx, const int vIdx); - /** - * @brief gets the translation of the given verse using the active - * DBManager::Translation - * @param sIdx - surah number - * @param vIdx - verse number - * @return QString containing the verse translation - */ - QString getTranslation(const int sIdx, const int vIdx); - /** - * @brief gets a random verse from the Quran - * @return QPair of ::Verse instance and verse text - */ - QList randomVerse(); - /** - * @brief gets a QList of ::Verse instances representing the bookmarked verse - * within the given sura (default gets all) - * @param surahIdx - sura number (-1 returns all bookmarks) - * @return QList of bookmarked verses - */ - QList> bookmarkedVerses(int surahIdx = -1); - /** - * @brief checks whether the given ::Verse is bookmarked - * @param vInfo - ::Verse instance to check - * @return boolean - */ - bool isBookmarked(QList vInfo); - /** - * @brief add the given ::Verse to bookmarks - * @param vInfo - ::Verse instance to add - * @return boolean - */ - bool addBookmark(QList vInfo); - /** - * @brief remove the given ::Verse from bookmarks - * @param vInfo - ::Verse instance to remove - * @return boolean indicating successful removal - */ - bool removeBookmark(QList vInfo); - /** - * @brief setter for m_activeKhatmah - * @param id - id of the active khatmah - */ - void setActiveKhatmah(const int id); - /** - * @brief Set the VerseType shown - * @param newVerseType - */ - void setVerseType(VerseType newVerseType); - /** - * MODIFIED - */ - void saveThoughts(QList vInfo, const QString& text); - /** - * MODIFIED - */ - QString getThoughts(QList vInfo); - /** - * @brief getter for m_activeKhatmah - * @return the currently active khatmah id - */ - const int activeKhatmah() const; - /** - * @brief getter for m_verseType - * @return VerseType - */ - VerseType getVerseType() const; - /** - * @brief getter for m_currTafsir - * @return the currently set DBManager::Tafasir - */ - QSharedPointer<::Tafsir> currTafsir() const; - /** - * @brief currTranslation - * @return - * - * MODIFIED - */ - QSharedPointer<::Translation> currTranslation() const; - -public slots: - /** - * @brief set tafsir to the one in the settings, update the selected db - */ - void updateLoadedTafsir(); - /** - * @brief set translation to the one in the settings, update the selected db - */ - void updateLoadedTranslation(); - -signals: - void bookmarkAdded(); - void bookmarkRemoved(); - -private: - const int m_qcfVer = Settings::qcfVersion; - const QLocale::Language m_languageCode = Settings::language; - const QSharedPointer m_assetsDir = DirManager::assetsDir; - const QSharedPointer m_downloadsDir = DirManager::downloadsDir; - const QSharedPointer m_settings = Settings::settings; - const QList>& m_tafasir = Tafsir::tafasir; - const QList>& m_translations = - Translation::translations; - const QString m_bookmarksFilepath = - DirManager::configDir->absoluteFilePath("bookmarks.db"); - /** - * @brief sets the currently active sqlite database file and opens - * corresponding connection based on the DBManager::Database type - * @param db - DBManager::Database entry - * @param filePath - path to the database file - */ - void setOpenDatabase(Database db, QString path); - /** - * MODIFIED - */ - void updateOpenDbFile(const QString& filepath); - /** - * @brief integer id of the current active khatmah - */ - int m_activeKhatmah = 0; - /** - * @brief the currently active database type - */ - Database m_currentDb = Null; - /** - * @brief QSqlDatabase instance to interact with the different sqlite - * databases - */ - QSqlDatabase m_openDBCon; - /** - * @brief m_verseType - * - * MODIFIED - */ - VerseType m_verseType = Settings::Qcf; - /** - * @brief the current active DBManager::Tafasir - */ - QSharedPointer<::Tafsir> m_currTafsir; - /** - * @brief the current active DBManager::Translation - */ - QSharedPointer<::Translation> m_currTr; - /** - * @brief path to the currently active tafsir database file - */ - QFileInfo m_tafsirDbPath; - /** - * @brief path to the currently active translation database file - */ - QFileInfo m_transDbPath; - /** - * @brief path to the Quran database file - */ - QFileInfo m_quranDbPath; - /** - * @brief path to the QCF glyphs database file - */ - QFileInfo m_glyphsDbPath; - /** - * MODIFIED - */ - QFileInfo m_betaqatDbPath; - /** - * @brief QList of sura names (Arabic if UI language is Arabic, Otherwise - * English) - */ - QStringList m_surahNames; -}; - -#endif // DBMANAGER_H diff --git a/src/utils/fontmanager.cpp b/src/utils/fontmanager.cpp index f78da54a..deb34a03 100644 --- a/src/utils/fontmanager.cpp +++ b/src/utils/fontmanager.cpp @@ -87,19 +87,22 @@ FontManager::pageFontname(int page) } QString -FontManager::verseFontname(Configuration::VerseType type, int page) +FontManager::verseFontname(ConfigurationSchema::VerseType type, int page) { QString fontname; switch (type) { - case Configuration::Qcf: + case ConfigurationSchema::Qcf: fontname = pageFontname(page); break; - case Configuration::Uthmanic: + case ConfigurationSchema::Hafs: fontname = "kfgqpc_hafs_uthmanic _script"; break; - case Configuration::Annotated: + case ConfigurationSchema::HafsAnnotated: fontname = "Emine"; break; + case ConfigurationSchema::Warsh: + fontname = "kfgqpc_warsh_uthmanic_script"; + break; } return fontname; } diff --git a/src/utils/fontmanager.h b/src/utils/fontmanager.h index 5cc2edc7..befe9a66 100644 --- a/src/utils/fontmanager.h +++ b/src/utils/fontmanager.h @@ -4,13 +4,14 @@ #include "configuration.h" #include "dirmanager.h" #include +#include class FontManager { public: static FontManager& getInstance(); QString pageFontname(int page); - QString verseFontname(Configuration::VerseType type, int page); + QString verseFontname(ConfigurationSchema::VerseType type, int page); void loadFonts(); bool qcfExists();