diff options
author | Your Name <you@example.com> | 2021-02-24 11:26:27 -0500 |
---|---|---|
committer | Your Name <you@example.com> | 2021-02-24 11:26:27 -0500 |
commit | cafdd193b62acfaf556491eaa46ccb3dfdff82dd (patch) | |
tree | 757f0f397a34dfc0d236cafca1de5a54bcb13b04 | |
parent | a01ae21aa395aa094a1e66d3e2b450e699878359 (diff) | |
download | biblereader-cafdd193b62acfaf556491eaa46ccb3dfdff82dd.tar.gz biblereader-cafdd193b62acfaf556491eaa46ccb3dfdff82dd.tar.bz2 biblereader-cafdd193b62acfaf556491eaa46ccb3dfdff82dd.zip |
Now remembers most recently used module
-rw-r--r-- | sword.cc | 24 | ||||
-rw-r--r-- | sword.h | 2 |
2 files changed, 17 insertions, 9 deletions
@@ -10,11 +10,18 @@ bool isNoMods; Sword::Sword() { auto mods = libbible::getModules(); isNoMods = mods.empty(); - defaultMod = libbible::settingsRead("module"); - if(mods.find(defaultMod) == mods.end()) { - defaultMod = string(); + string defaultMod = libbible::settingsRead("module"); + currMod = libbible::settingsRead("biblereader::currMod"); + if(mods.find(currMod) == mods.end()) { + currMod = defaultMod; + } + if(mods.find(currMod) == mods.end()) { + currMod = string(); if(! mods.empty()) { + // New default mod (previous was deleted) defaultMod = mods.begin()->first; + libbible::settingsWrite("module", defaultMod); + currMod = defaultMod; } } } @@ -31,7 +38,8 @@ vector<string> Sword::getModules() { } void Sword::setModule(string version) { - defaultMod = version; + currMod = version; + libbible::settingsWrite("biblereader::currMod", currMod); } void Sword::fillBuffer(string ref, Glib::RefPtr<Gtk::TextBuffer> buf) { @@ -46,7 +54,7 @@ void Sword::fillBuffer(string ref, Glib::RefPtr<Gtk::TextBuffer> buf) { return; } - auto texts = libbible::getText(libbible::getPassage(defaultMod, ref)); + auto texts = libbible::getText(libbible::getPassage(currMod, ref)); auto iter = buf->get_iter_at_offset(0); @@ -128,12 +136,12 @@ void Sword::getConfig(string book, int chapter, struct config *conf) { conf->maxChapter = 0; conf->version = ""; } else { - auto passages = libbible::getPassages(defaultMod, book); + auto passages = libbible::getPassages(currMod, book); conf->chapter = chapter; conf->book = passages[0].bookShort; conf->bookFull = passages[0].book; conf->maxChapter = passages.back().chapterStart; - conf->version = defaultMod; + conf->version = currMod; } } @@ -141,5 +149,5 @@ vector<string> Sword::getBooks() { if(isNoMods) { return vector<string>(); } - return libbible::getModules()[defaultMod]; + return libbible::getModules()[currMod]; } @@ -16,7 +16,7 @@ public: void getConfig(std::string book, int chapter, struct config *conf); protected: - std::string defaultMod; + std::string currMod; }; |