void CPlainWriteWindow::storeProfileSettings(const QString & windowGroup) { CDisplayWindow::storeProfileSettings(windowGroup); QAction * action = actionCollection()->action(CResMgr::displaywindows::commentaryWindow::syncWindow::actionName); Q_ASSERT(action); Q_ASSERT(windowGroup.endsWith('/')); btConfig().setSessionValue(windowGroup + "writeWindowType", static_cast<int>(writeWindowType())); btConfig().setSessionValue(windowGroup + "syncWindowEnabled", action->isChecked()); }
void BtBookshelfWizard::accept() { if (currentPage() == m_installFinalPage) { // Save settings: btConfig().setValue(SourcesKey, selectedSources()); btConfig().setValue(LanguagesKey, selectedLanguages()); } btConfig().setValue(GeometryKey, saveGeometry()); // Save wizard geometry QDialog::accept(); }
void CRangeChooserDialog::restoreDefaults() { typedef BtConfig::StringMap::ConstIterator SMCI; m_rangeList->clear(); btConfig().deleteSearchScopesWithCurrentLocale(); const BtConfig::StringMap map = btConfig().getSearchScopesForCurrentLocale(); for (SMCI it = map.begin(); it != map.end(); ++it) { new RangeItem(it.key(), it.value(), m_rangeList); }; m_rangeList->setCurrentItem(0); resetEditControls(); }
List(QString &name) { init(); _name = name; // TODO view now not supports row without items at all _maxEntries = 1; _displayOptions = btConfig().getDisplayOptions(); _filterOptions = btConfig().getFilterOptions(); setModule(_name); }
void BtBookshelfLanguagesPage::initializePage() { { // Select languages: QStringList languages; if (m_firstTimeInit) { languages << btConfig().value<QStringList>(LanguagesKey, QStringList{}); if (languages.isEmpty()) languages << tr("English"); m_firstTimeInit = false; } else { languages << selectedLanguages(); } bool scrolledToFirstSelected = false; for (int row = 0; row < m_model->rowCount(); ++row) { QStandardItem * const item = m_model->item(row, 0); if (languages.contains(item->text())) { item->setCheckState(Qt::Checked); // Scroll to first selected item: if (!scrolledToFirstSelected) { m_languagesListView->scrollTo(m_model->indexFromItem(item)); scrolledToFirstSelected = true; } } } } retranslateUi(); }
void CCommentaryReadWindow::applyProfileSettings(const QString & windowGroup) { CLexiconReadWindow::applyProfileSettings(windowGroup); BT_ASSERT(windowGroup.endsWith('/')); BT_ASSERT(m_syncButton); m_syncButton->setChecked(btConfig().sessionValue<bool>(windowGroup + "syncEnabled", false)); }
CSwordModuleInfo::CSwordModuleInfo(sword::SWModule & module, CSwordBackend & backend, ModuleType type) : m_module(module) , m_backend(backend) , m_type(type) , m_cancelIndexing(false) , m_cachedName(QString::fromUtf8(module.getName())) , m_cachedCategory(retrieveCategory(type, module)) , m_cachedLanguage( CLanguageMgr::instance()->languageForAbbrev( m_cachedCategory == Glossary /* Special handling for glossaries, we use the "from language" as language for the module: */ ? config(GlossaryFrom) : module.getLanguage())) , m_cachedHasVersion(!QString((*m_backend.getConfig())[module.getName()]["Version"]).isEmpty()) { m_hidden = btConfig().value<QStringList>("state/hiddenModules", QStringList()).contains(m_cachedName); if (m_cachedHasVersion && (minimumSwordVersion() > sword::SWVersion::currentVersion)) { qWarning("The module \"%s\" requires a newer Sword library. Please " "update to \"Sword %s\".", m_cachedName.toUtf8().constData(), minimumSwordVersion().getText()); /// \todo if this is the case, can we use the module at all? } }
void CCommentaryReadWindow::storeProfileSettings(const QString & windowGroup) { CLexiconReadWindow::storeProfileSettings(windowGroup); Q_ASSERT(windowGroup.endsWith('/')); Q_ASSERT(m_syncButton); btConfig().setSessionValue(windowGroup + "syncEnabled", m_syncButton->isChecked()); }
BibleTimeApp::~BibleTimeApp() { // Prevent writing to the log file before the directory cache is init: if (!m_init || BtConfig::m_instance == 0) return; //we can set this safely now because we close now (hopyfully without crash) btConfig().setValue("state/crashedLastTime", false); btConfig().setValue("state/crashedTwoTimes", false); delete CDisplayTemplateMgr::instance(); CLanguageMgr::destroyInstance(); CSwordBackend::destroyInstance(); util::clearIconCache(); BtConfig::destroyInstance(); }
void CPlainWriteWindow::applyProfileSettings(const QString & windowGroup) { CDisplayWindow::applyProfileSettings(windowGroup); QAction * action = actionCollection()->action(CResMgr::displaywindows::commentaryWindow::syncWindow::actionName); Q_ASSERT(action != 0); Q_ASSERT(windowGroup.endsWith('/')); action->setChecked(btConfig().sessionValue<bool>(windowGroup + "syncWindowEnabled", false)); }
void CBibleReadWindow::storeProfileSettings(const QString & windowGroup) { BtConfig & conf = btConfig(); conf.beginGroup(windowGroup); conf.setFilterOptions(filterOptions()); conf.setDisplayOptions(displayOptions()); conf.endGroup(); CLexiconReadWindow::storeProfileSettings(windowGroup); }
void setModule(QString module) { if(module == "[Commentary]") setModule(btConfig().getDefaultSwordModuleByType("standardCommentary")); else if(module.contains(',')) setModule(CSwordBackend::instance()->findModuleByName(module.section(',', 0, 0))); else setModule(CSwordBackend::instance()->findModuleByName(module)); }
void setupModule(int i, QString module) { _lists[i] = List(module); BtMiniLevelOption o; _isSearch = false; if(module.isEmpty()) { ; } else if(module == "[Search]") { o.scrollBarPolicy = Qt::ScrollBarAsNeeded; o.limitItems = true; o.perCycle = 1; o.scrollPerItem = true; o.allowStaticText = false; _isSearch = true; _lists[i]._simpleVerseNumber = false; _lists[i]._introdutions = false; } else if(module == "[Contents]") { o.scrollBarPolicy = Qt::ScrollBarAlwaysOn; o.limitItems = false; o.perCycle = 0; } else if(module == "[Commentary]") { o.scrollBarPolicy = Qt::ScrollBarAlwaysOn; } else { Q_CHECK_PTR(_lists[i]._module); o.scrollBarPolicy = Qt::ScrollBarAlwaysOff; o.limitItems = true; o.perCycle = 1; if(_lists[i]._module->type() == CSwordModuleInfo::Lexicon) ; else if(btConfig().value<bool>("mini/threadedTextRetrieving")) { o.perCycle = 3; o.useThread = true; } } Q_ASSERT(i < _ld->levelOptionsCount()); _ld->setLevelOption(i, o); }
void BtFontSettingsPage::save() const { for (FontMap::ConstIterator it = m_fontMap.constBegin(); it != m_fontMap.constEnd(); it++) { const QString &k = it.key(); const CLanguageMgr::Language * const lang = CLanguageMgr::instance()->languageForTranslatedName(k); if (!lang->isValid()) { // We possibly use a language, for which we have only the abbrevation if (!lang->abbrev().isEmpty()) { // Create a temp language: const CLanguageMgr::Language l(k, k, k); btConfig().setFontForLanguage(l, it.value()); } } else { btConfig().setFontForLanguage(*lang, it.value()); } } }
/** Sets the module chooser bar. */ void CDisplayWindow::setModuleChooserBar( BtModuleChooserBar* bar ) { if (m_moduleChooserBar) { m_moduleChooserBar->deleteLater(); } //if a new bar should be set! if (bar) { m_moduleChooserBar = bar; bar->setWindowTitle(tr("Work chooser buttons")); bar->setLayoutDirection(Qt::LeftToRight); bar->setVisible(btConfig().sessionValue<bool>("GUI/showTextWindowModuleSelectorButtons", true)); } }
qreal ModuleInterface::getFontSizeForLanguage(const QString& language) { auto lang = getLanguageFromEnglishName(language); if (lang) { BtConfig::FontSettingsPair fontPair = btConfig().getFontForLanguage(*lang); if (fontPair.first) { QFont font = fontPair.second; int fontPointSize = font.pointSize(); return fontPointSize; } } qreal pointSize = getDefaultFont().pointSizeF(); return pointSize; }
QString ModuleInterface::getFontNameForLanguage(const QString& language) { auto lang = getLanguageFromEnglishName(language); if (lang) { BtConfig::FontSettingsPair fontPair = btConfig().getFontForLanguage(*lang); if (fontPair.first) { QFont font = fontPair.second; QString fontFamily = font.family(); return fontFamily; } } QString fontFamily = getDefaultFont().family(); return fontFamily; }
void CBibleReadWindow::applyProfileSettings(const QString & windowGroup) { CLexiconReadWindow::applyProfileSettings(windowGroup); BtConfig & conf = btConfig(); conf.beginGroup(windowGroup); filterOptions() = conf.getFilterOptions(); displayOptions() = conf.getDisplayOptions(); conf.endGroup(); emit sigFilterOptionsChanged(filterOptions()); emit sigDisplayOptionsChanged(displayOptions()); // Apply settings to display: lookup(); }
void ModuleInterface::saveCurrentFonts() { savedFontSettings.clear(); CLanguageMgr::LangMap langMap = CLanguageMgr::instance()->availableLanguages(); for (auto lang: langMap) { BtConfig::FontSettingsPair fontPair = btConfig().getFontForLanguage(*lang); if (fontPair.first) { FontSettings fontSettings; QFont font = fontPair.second; fontSettings.language = lang->englishName(); fontSettings.fontName = font.family(); fontSettings.fontSize = font.pointSize(); savedFontSettings.append(fontSettings); } } }
void ModuleInterface::setFontForLanguage(const QString& language, const QString& fontName, qreal fontSize) { if (CLanguageMgr::instance() == nullptr) return; auto lang = getLanguageFromEnglishName(language); if (lang) { QFont font; font.setFamily(fontName); font.setPointSizeF(fontSize); BtConfig::FontSettingsPair fontPair; fontPair.first = true; fontPair.second = font; btConfig().setFontForLanguage(*lang, fontPair); } }
CRangeChooserDialog::CRangeChooserDialog(QWidget *parentDialog) : QDialog(parentDialog) { initView(); initConnections(); retranslateUi(); // Add the existing scopes BtConfig::StringMap map = btConfig().getSearchScopesForCurrentLocale(); BtConfig::StringMap::Iterator it; for (it = map.begin(); it != map.end(); ++it) { new RangeItem(it.key(), it.value(), m_rangeList); } resetEditControls(); }
/** Store the settings of this window in the given CProfileWindow object. */ void CDisplayWindow::storeProfileSettings(const QString & windowGroup) { BtConfig & conf = btConfig(); conf.beginGroup(windowGroup); QWidget * w = getProfileWindow(); /** \note We don't use saveGeometry/restoreGeometry for MDI subwindows, because they give slightly incorrect results with some window managers. Might be related to Qt bug QTBUG-7634. */ const QRect rect(w->x(), w->y(), w->width(), w->height()); conf.setSessionValue<QRect>("windowRect", rect); conf.setSessionValue("maximized", w->isMaximized()); bool hasFocus = (w == dynamic_cast<CDisplayWindow *>(mdi()->activeSubWindow())); conf.setSessionValue("hasFocus", hasFocus); // conf.setSessionValue("type", static_cast<int>(modules().first()->type())); // Save current key: if (key()) { CSwordKey * k = key(); sword::VerseKey * vk = dynamic_cast<sword::VerseKey*>(k); QString oldLang; if (vk) { // Save keys in english only: const QString oldLang = QString::fromLatin1(vk->getLocale()); vk->setLocale("en"); conf.setSessionValue("key", k->key()); vk->setLocale(oldLang.toLatin1()); } else { conf.setSessionValue("key", k->key()); } } // Save list of modules: QStringList mods; Q_FOREACH (const CSwordModuleInfo * module, modules()) mods.append(module->name()); conf.setSessionValue("modules", mods); conf.endGroup(); }
void CSwordModuleSearch::startSearch() { // Clear old search results: m_results.clear(); m_foundItems = 0u; /// \todo What is the purpose of the following statement? CSwordBackend::instance()->setFilterOptions(btConfig().getFilterOptions()); // Search module-by-module: Q_FOREACH(CSwordModuleInfo const * const m, m_searchModules) { sword::ListKey results; size_t const found = m->searchIndexed(m_searchText, m_searchScope, results); if (found > 0u) { m_results.insert(m, results); m_foundItems += found; } }
void CRangeChooserDialog::accept() { // Update the active item: QListWidgetItem *currentItem = m_rangeList->currentItem(); if (currentItem != 0) { Q_ASSERT(dynamic_cast<RangeItem*>(currentItem) != 0); saveCurrentToRange(static_cast<RangeItem*>(currentItem)); } // Save the new sorted map of search scopes: m_rangeList->sortItems(); BtConfig::StringMap map; for (int i = 0; i < m_rangeList->count(); i++) { Q_ASSERT(dynamic_cast<RangeItem*>(m_rangeList->item(i)) != 0); const RangeItem * item = static_cast<RangeItem*>(m_rangeList->item(i)); map[item->caption()] = item->range(); } btConfig().setSearchScopesWithCurrentLocale(map); QDialog::accept(); }
bool CSwordModuleInfo::unlock(const QString & unlockKey) { if (!isEncrypted()) return false; bool unlocked = unlockKeyIsValid(); btConfig().setModuleEncryptionKey(m_cachedName, unlockKey); /// \todo remove this comment once it is no longer needed /* There is currently a deficiency in sword 1.6.1 in that backend->setCipherKey() does not work correctly for modules from which data was already fetched. Therefore we have to reload the modules in bibletime.cpp */ m_backend.setCipherKey(m_module.getName(), unlockKey.toUtf8().constData()); /// \todo write to Sword config as well if (unlockKeyIsValid() != unlocked) emit unlockedChanged(!unlocked); return true; }
QVector<QString> BtLanguageSettingsPage::bookNameAbbreviationsTryVector() { QVector<QString> atv; atv.reserve(4); { QString settingsLanguage = btConfig().value<QString>("language"); if (!settingsLanguage.isEmpty()) atv.append(settingsLanguage); } { const QString localeLanguageAndCountry = QLocale::system().name(); if (!localeLanguageAndCountry.isEmpty()) { atv.append(localeLanguageAndCountry); int i = localeLanguageAndCountry.indexOf('_'); if (i > 0) atv.append(localeLanguageAndCountry.left(i)); } } Q_ASSERT(CLanguageMgr::instance()->languageForAbbrev("en_US")); atv.append("en_US"); return atv; }
void BtLanguageSettingsPage::resetLanguage() { QVector<QString> atv = bookNameAbbreviationsTryVector(); QString best = "en_US"; Q_ASSERT(atv.contains(best)); int i = atv.indexOf(best); if (i > 0) { atv.resize(i); const std::list<sword::SWBuf> locales = sword::LocaleMgr::getSystemLocaleMgr()->getAvailableLocales(); for (SBLCI it = locales.begin(); it != locales.end(); ++it) { const char * abbr = sword::LocaleMgr::getSystemLocaleMgr()->getLocale((*it).c_str())->getName(); i = atv.indexOf(abbr); if (i >= 0) { best = abbr; if (i == 0) break; atv.resize(i); } } } btConfig().setValue("language", best); }
void CDisplayWindow::applyProfileSettings(const QString & windowGroup) { BtConfig & conf = btConfig(); conf.beginGroup(windowGroup); setUpdatesEnabled(false); QWidget * w = getProfileWindow(); /** \note We don't use restoreGeometry/saveGeometry for MDI subwindows, because they give slightly incorrect results with some window managers. Might be related to Qt bug QTBUG-7634. */ const QRect rect = conf.sessionValue<QRect>("windowRect"); w->resize(rect.width(), rect.height()); w->move(rect.x(), rect.y()); if (conf.sessionValue<bool>("maximized")) w->showMaximized(); setUpdatesEnabled(true); conf.endGroup(); }
BtBookshelfWizard::BtBookshelfWizard(QWidget * parent, Qt::WindowFlags flags) : QWizard(parent, flags) , m_downloadInProgress(false) , m_closeRequested(false) , m_closeMessageBox(new QMessageBox(this)) , m_taskPage(new BtBookshelfTaskPage(this)) , m_sourcesPage(new BtBookshelfSourcesPage(this)) , m_sourcesProgressPage(new BtBookshelfSourcesProgressPage(this)) , m_languagesPage(new BtBookshelfLanguagesPage(this)) , m_installWorksPage(new BtBookshelfWorksPage(WizardTaskType::installWorks, this)) , m_updateWorksPage(new BtBookshelfWorksPage(WizardTaskType::updateWorks, this)) , m_removeWorksPage(new BtBookshelfWorksPage(WizardTaskType::removeWorks, this)) , m_installFinalPage(new BtBookshelfInstallFinalPage(this)) // For install and update { setPage(WizardPage::taskPage, m_taskPage); setPage(WizardPage::sourcesProgressPage,m_sourcesProgressPage); setPage(WizardPage::sourcesPage, m_sourcesPage); setPage(WizardPage::languagesPage, m_languagesPage); setPage(WizardPage::installWorksPage, m_installWorksPage); setPage(WizardPage::updateWorksPage, m_updateWorksPage); setPage(WizardPage::removeWorksPage, m_removeWorksPage); setPage(WizardPage::removeFinalPage, new BtBookshelfRemoveFinalPage(this)); setPage(WizardPage::installFinalPage, m_installFinalPage); setStartId(WizardPage::taskPage); QRect rect = geometry(); rect.setWidth(780); rect.setHeight(600); setGeometry(rect); setOption(QWizard::NoBackButtonOnLastPage); retranslateUi(); // Load wizard geometry: restoreGeometry(btConfig().value<QByteArray>(GeometryKey, QByteArray())); }
QVariant BtMiniModuleTextModel::data(const QModelIndex &index, int role) const { Q_D(const BtMiniModuleTextModel); switch(role) { case BtMini::PreviewUpdateRole: case BtMini::PreviewRole: { const BtMiniModuleTextModelPrivate::List *list = d->indexList(index); // put to thread processing if(role == BtMini::PreviewUpdateRole) { ; } if(list->_module->type() == CSwordModuleInfo::GenericBook) { CSwordBookModuleInfo *b = qobject_cast<CSwordBookModuleInfo*>(list->_module); CSwordTreeKey k(b->tree(), b); k.setIndex(index.row() * 4); return QString("<word-breaks/><font color='#aaaaaa'><center>%1</center></font><font size='1'><br>" " </br></font>").arg(k.key().replace('/', ' ')); } else { // there was issue with VerseKey::freshtext at simoultaneous call static CSwordVerseKey vk(list->_module); vk.setModule(list->_module); vk.setIndex(index.row() + list->_firstEntry); int v = vk.getVerse(); if(v == 0) return QString(); QString r("<font color='#aaaaaa'>"); if(v == 1) r += QString("<center><b><font size='+1'>%1 %2</font></b></center>" "<font size='1'><br> </br></font>").arg(vk.book()).arg(vk.getChapter()); if(v > 0) r += QString("<center>%1</center></font><font size='1'><br> </br>").arg(v); return r + "</font>"; } } case Qt::DisplayRole: { switch(d->indexDepth(index)) { case 1: { const BtMiniModuleTextModelPrivate::List & l = d->_lists[index.internalId()]; return l._module == 0 ? "" : l._module->name(); } case 2: { QString r; const BtMiniModuleTextModelPrivate::List *l = d->indexList(index); if(l->_module && (l->_module->type() == CSwordModuleInfo::Bible || l->_module->type() == CSwordModuleInfo::Commentary)) { CSwordVerseKey key(d->indexToVerseKey(index)); const int v = key.getVerse(); QList<const CSwordModuleInfo*> modules; modules << l->_module; // parallel display if(l->_name.contains(',')) foreach(QString s, l->_name.split(',').mid(1)) if(CSwordModuleInfo *m = CSwordBackend::instance()->findModuleByName(s)) modules << m; if(!d->_isSearch && v == 1) r += "<center><b><font size='+2' face=\"" + btConfig().getDefaultFont().family() + "\">" + key.book() + " " + QString::number(key.getChapter()) + "</font></b></center>"; if(v != 0) r += Rendering::CEntryDisplay().textKeyRendering(modules, key.key(), l->_displayOptions, l->_filterOptions, l->_simpleVerseNumber ? Rendering::CTextRendering::KeyTreeItem::Settings::SimpleKey : Rendering::CTextRendering::KeyTreeItem::Settings::CompleteShort, l->_introdutions); if(!d->_isSearch && v == key.getVerseMax()) r += "<font size='1'><br> </font>"; } else if(l->_module && l->_module->type() == CSwordModuleInfo::Lexicon) { CSwordLexiconModuleInfo *lm = qobject_cast<CSwordLexiconModuleInfo*>(l->_module); Rendering::CEntryDisplay ed; r += ed.textKeyRendering(QList<const CSwordModuleInfo*>() << lm, lm->entries()[l->_hasScope ? l->_scopeMap[index.row()] : index.row()], l->_displayOptions, l->_filterOptions, l->_simpleVerseNumber ? Rendering::CTextRendering::KeyTreeItem::Settings::SimpleKey : Rendering::CTextRendering::KeyTreeItem::Settings::CompleteShort, l->_introdutions); } else if(l->_module && l->_module->type() == CSwordModuleInfo::GenericBook) { CSwordBookModuleInfo *b = reinterpret_cast<CSwordBookModuleInfo*>(l->_module); CSwordTreeKey key(b->tree(), b); key.setIndex(l->_hasScope ? l->_scopeMap[index.row()] : index.row() * 4); Rendering::CEntryDisplay ed; r += ed.textKeyRendering(QList<const CSwordModuleInfo*>() << l->_module, key.key(), l->_displayOptions, l->_filterOptions, l->_simpleVerseNumber ? Rendering::CTextRendering::KeyTreeItem::Settings::SimpleKey : Rendering::CTextRendering::KeyTreeItem::Settings::CompleteShort, l->_introdutions); } if(d->_isSearch && !d->_searchText.isEmpty()) r = CSwordModuleSearch::highlightSearchedText(r, d->_searchText); if(l->_hasContents) r += l->_contents.toString(); return r; } } }