summaryrefslogtreecommitdiffstats
path: root/fbreader/src/optionsDialog
diff options
context:
space:
mode:
authorMichele Calgaro <[email protected]>2024-05-11 21:28:48 +0900
committerMichele Calgaro <[email protected]>2024-05-11 21:28:48 +0900
commit2462d03f322261bd616721c2b2065c4004b36c9c (patch)
tree239947a0737bb8386703a1497f12c09aebd3080a /fbreader/src/optionsDialog
downloadtde-ebook-reader-2462d03f322261bd616721c2b2065c4004b36c9c.tar.gz
tde-ebook-reader-2462d03f322261bd616721c2b2065c4004b36c9c.zip
Initial import (as is) from Debian Snapshot's 'fbreader' source code (https://snapshot.debian.org/package/fbreader/0.99.4%2Bdfsg-6).
The Debian code is provided under GPL2 license. Signed-off-by: Michele Calgaro <[email protected]>
Diffstat (limited to 'fbreader/src/optionsDialog')
-rw-r--r--fbreader/src/optionsDialog/AbstractOptionsDialog.cpp48
-rw-r--r--fbreader/src/optionsDialog/AbstractOptionsDialog.h50
-rw-r--r--fbreader/src/optionsDialog/IntegrationTab.cpp159
-rw-r--r--fbreader/src/optionsDialog/bookInfo/BookInfoDialog.cpp564
-rw-r--r--fbreader/src/optionsDialog/bookInfo/BookInfoDialog.h80
-rw-r--r--fbreader/src/optionsDialog/library/LibraryOptionsDialog.cpp39
-rw-r--r--fbreader/src/optionsDialog/library/LibraryOptionsDialog.h32
-rw-r--r--fbreader/src/optionsDialog/lookAndFeel/FormatOptionsPage.cpp112
-rw-r--r--fbreader/src/optionsDialog/lookAndFeel/FormatOptionsPage.h33
-rw-r--r--fbreader/src/optionsDialog/lookAndFeel/LookAndFeelOptionsDialog.cpp78
-rw-r--r--fbreader/src/optionsDialog/lookAndFeel/LookAndFeelOptionsDialog.h38
-rw-r--r--fbreader/src/optionsDialog/lookAndFeel/OptionsPage.cpp52
-rw-r--r--fbreader/src/optionsDialog/lookAndFeel/OptionsPage.h76
-rw-r--r--fbreader/src/optionsDialog/lookAndFeel/StyleOptionsPage.cpp127
-rw-r--r--fbreader/src/optionsDialog/lookAndFeel/StyleOptionsPage.h34
-rw-r--r--fbreader/src/optionsDialog/network/NetworkOptionsDialog.cpp104
-rw-r--r--fbreader/src/optionsDialog/network/NetworkOptionsDialog.h32
-rw-r--r--fbreader/src/optionsDialog/reading/IndicatorTab.cpp171
-rw-r--r--fbreader/src/optionsDialog/reading/KeyBindingsTab.cpp285
-rw-r--r--fbreader/src/optionsDialog/reading/ReadingOptionsDialog.cpp125
-rw-r--r--fbreader/src/optionsDialog/reading/ReadingOptionsDialog.h36
-rw-r--r--fbreader/src/optionsDialog/system/SystemOptionsDialog.cpp86
-rw-r--r--fbreader/src/optionsDialog/system/SystemOptionsDialog.h32
23 files changed, 2393 insertions, 0 deletions
diff --git a/fbreader/src/optionsDialog/AbstractOptionsDialog.cpp b/fbreader/src/optionsDialog/AbstractOptionsDialog.cpp
new file mode 100644
index 0000000..eb687b8
--- /dev/null
+++ b/fbreader/src/optionsDialog/AbstractOptionsDialog.cpp
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2010-2012 Geometer Plus <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#include <ZLDialogManager.h>
+#include <ZLOptionsDialog.h>
+
+#include "AbstractOptionsDialog.h"
+
+#include "../fbreader/FBReader.h"
+
+
+class OptionsApplyRunnable : public ZLRunnable {
+
+public:
+ void run();
+};
+
+void OptionsApplyRunnable::run() {
+ FBReader &fbreader = FBReader::Instance();
+ fbreader.grabAllKeys(fbreader.KeyboardControlOption.value());
+ fbreader.clearTextCaches();
+ fbreader.refreshWindow();
+}
+
+
+AbstractOptionsDialog::AbstractOptionsDialog(const ZLResourceKey &key, bool showApplyButton) {
+ myDialog = ZLDialogManager::Instance().createOptionsDialog(key, new OptionsApplyRunnable(), showApplyButton);
+}
+
+void AbstractOptionsDialog::storeTemporaryOption(ZLOption *option) {
+ myTemporaryOptions.push_back(option);
+}
diff --git a/fbreader/src/optionsDialog/AbstractOptionsDialog.h b/fbreader/src/optionsDialog/AbstractOptionsDialog.h
new file mode 100644
index 0000000..31f4904
--- /dev/null
+++ b/fbreader/src/optionsDialog/AbstractOptionsDialog.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2010-2012 Geometer Plus <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#ifndef __ABSTRACTOPTIONSDIALOG_H__
+#define __ABSTRACTOPTIONSDIALOG_H__
+
+#include <vector>
+#include <shared_ptr.h>
+
+class ZLOptionsDialog;
+class ZLResourceKey;
+class ProgramCollection;
+class ZLOption;
+class ZLOptionEntry;
+
+class AbstractOptionsDialog {
+
+public:
+ AbstractOptionsDialog(const ZLResourceKey &key, bool showApplyButton);
+
+ ZLOptionsDialog &dialog();
+
+protected:
+ void createIntegrationTab(shared_ptr<ProgramCollection> collection, const ZLResourceKey &key, std::vector<std::pair<ZLResourceKey,ZLOptionEntry*> > &additionalOptions);
+ void storeTemporaryOption(ZLOption *option);
+
+private:
+ shared_ptr<ZLOptionsDialog> myDialog;
+ std::vector<shared_ptr<ZLOption> > myTemporaryOptions;
+};
+
+inline ZLOptionsDialog &AbstractOptionsDialog::dialog() { return *myDialog; }
+
+#endif /* __ABSTRACTOPTIONSDIALOG_H__ */
diff --git a/fbreader/src/optionsDialog/IntegrationTab.cpp b/fbreader/src/optionsDialog/IntegrationTab.cpp
new file mode 100644
index 0000000..c1026f0
--- /dev/null
+++ b/fbreader/src/optionsDialog/IntegrationTab.cpp
@@ -0,0 +1,159 @@
+/*
+ * Copyright (C) 2004-2012 Geometer Plus <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#include <ZLOptionsDialog.h>
+#include <ZLOptionEntry.h>
+#include <ZLStringUtil.h>
+
+#include <optionEntries/ZLToggleBooleanOptionEntry.h>
+#include <optionEntries/ZLSimpleOptionEntry.h>
+
+#include "AbstractOptionsDialog.h"
+
+#include "../options/FBCategoryKey.h"
+#include "../external/ProgramCollection.h"
+
+
+class ProgramChoiceEntry : public ZLComboOptionEntry {
+
+public:
+ ProgramChoiceEntry(const ProgramCollection &collection);
+
+private:
+ const std::vector<std::string> &values() const;
+ void onAccept(const std::string &value);
+ void onValueSelected(int index);
+
+public:
+ const std::string &initialValue() const;
+ void addDependentEntry(const std::string &name, ZLOptionEntry *dependentEntry);
+ void updateDependentEntries(bool visible);
+
+private:
+ const ProgramCollection &myCollection;
+ std::string myValue;
+ std::map<ZLOptionEntry*,std::string> myDependentEntries;
+};
+
+class EnableIntegrationEntry : public ZLToggleBooleanOptionEntry {
+
+public:
+ EnableIntegrationEntry(ZLBooleanOption &option);
+ void setProgramChoiceEntry(ProgramChoiceEntry *programChoiceEntry);
+ void onStateChanged(bool state);
+
+private:
+ ProgramChoiceEntry *myProgramChoiceEntry;
+};
+
+ProgramChoiceEntry::ProgramChoiceEntry(const ProgramCollection &collection) : myCollection(collection) {
+ myValue = initialValue();
+}
+
+const std::string &ProgramChoiceEntry::initialValue() const {
+ return myCollection.CurrentNameOption.value();
+}
+
+const std::vector<std::string> &ProgramChoiceEntry::values() const {
+ return myCollection.names();
+}
+
+void ProgramChoiceEntry::onAccept(const std::string &value) {
+ myCollection.CurrentNameOption.setValue(value);
+}
+
+void ProgramChoiceEntry::addDependentEntry(const std::string &name, ZLOptionEntry *dependentEntry) {
+ myDependentEntries[dependentEntry] = name;
+}
+
+void ProgramChoiceEntry::onValueSelected(int index) {
+ myValue = values()[index];
+ updateDependentEntries(true);
+}
+
+void ProgramChoiceEntry::updateDependentEntries(bool visible) {
+ for (std::map<ZLOptionEntry*,std::string>::const_iterator it = myDependentEntries.begin(); it != myDependentEntries.end(); ++it) {
+ it->first->setVisible(visible && (it->second == myValue));
+ }
+}
+
+EnableIntegrationEntry::EnableIntegrationEntry(ZLBooleanOption &option) : ZLToggleBooleanOptionEntry(option), myProgramChoiceEntry(0) {
+}
+
+void EnableIntegrationEntry::setProgramChoiceEntry(ProgramChoiceEntry *programChoiceEntry) {
+ addDependentEntry(programChoiceEntry);
+ myProgramChoiceEntry = programChoiceEntry;
+}
+
+void EnableIntegrationEntry::onStateChanged(bool state) {
+ ZLToggleBooleanOptionEntry::onStateChanged(state);
+ if (myProgramChoiceEntry != 0) {
+ myProgramChoiceEntry->updateDependentEntries(state);
+ }
+}
+
+void AbstractOptionsDialog::createIntegrationTab(shared_ptr<ProgramCollection> collection, const ZLResourceKey &key, std::vector<std::pair<ZLResourceKey,ZLOptionEntry*> > &additionalOptions) {
+ if (!collection.isNull()) {
+ const std::vector<std::string> &programNames = collection->names();
+ if (!programNames.empty()) {
+ ZLDialogContent &tab = myDialog->createTab(key);
+ std::string optionName;
+ if (programNames.size() == 1) {
+ optionName = ZLStringUtil::printf(tab.value(ZLResourceKey("enableIntegration")), programNames[0]);
+ } else {
+ optionName = tab.value(ZLResourceKey("defaultText"));
+ }
+ EnableIntegrationEntry *enableIntegrationEntry =
+ new EnableIntegrationEntry(collection->EnableCollectionOption);
+ tab.addOption(optionName, "", enableIntegrationEntry);
+
+ ProgramChoiceEntry *programChoiceEntry = 0;
+ if (programNames.size() > 1) {
+ programChoiceEntry = new ProgramChoiceEntry(*collection);
+ tab.addOption(ZLResourceKey("choice"), programChoiceEntry);
+ enableIntegrationEntry->setProgramChoiceEntry(programChoiceEntry);
+ }
+
+ for (std::vector<std::string>::const_iterator it = programNames.begin(); it != programNames.end(); ++it) {
+ const std::vector<Program::OptionDescription> &options = collection->program(*it)->options();
+ for (std::vector<Program::OptionDescription>::const_iterator jt = options.begin(); jt != options.end(); ++jt) {
+ ZLStringOption *parameterOption = new ZLStringOption(FBCategoryKey::EXTERNAL, *it, jt->OptionName, jt->DefaultValue);
+ storeTemporaryOption(parameterOption);
+ ZLOptionEntry *parameterEntry = new ZLSimpleStringOptionEntry(*parameterOption);
+ if (programChoiceEntry != 0) {
+ programChoiceEntry->addDependentEntry(*it, parameterEntry);
+ } else {
+ enableIntegrationEntry->addDependentEntry(parameterEntry);
+ }
+ tab.addOption(ZLResourceKey(jt->OptionName), parameterEntry);
+ }
+ }
+ for (std::vector<std::pair<ZLResourceKey,ZLOptionEntry*> >::const_iterator it = additionalOptions.begin(); it != additionalOptions.end(); ++it) {
+ enableIntegrationEntry->addDependentEntry(it->second);
+ tab.addOption(it->first, it->second);
+ }
+ enableIntegrationEntry->onStateChanged(enableIntegrationEntry->initialState());
+ return;
+ }
+ }
+
+ for (std::vector<std::pair<ZLResourceKey,ZLOptionEntry*> >::const_iterator it = additionalOptions.begin(); it != additionalOptions.end(); ++it) {
+ delete it->second;
+ }
+}
diff --git a/fbreader/src/optionsDialog/bookInfo/BookInfoDialog.cpp b/fbreader/src/optionsDialog/bookInfo/BookInfoDialog.cpp
new file mode 100644
index 0000000..09b1061
--- /dev/null
+++ b/fbreader/src/optionsDialog/bookInfo/BookInfoDialog.cpp
@@ -0,0 +1,564 @@
+/*
+ * Copyright (C) 2004-2012 Geometer Plus <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#include <algorithm>
+
+#include <ZLDialogManager.h>
+#include <ZLOptionsDialog.h>
+#include <ZLOptionEntry.h>
+#include <ZLFile.h>
+#include <ZLLanguageList.h>
+#include <ZLStringUtil.h>
+
+#include <optionEntries/ZLStringInfoEntry.h>
+#include <optionEntries/ZLSimpleOptionEntry.h>
+#include <optionEntries/ZLLanguageOptionEntry.h>
+
+#include "BookInfoDialog.h"
+
+#include "../../library/Library.h"
+#include "../../encodingOption/EncodingOptionEntry.h"
+#include "../../library/Book.h"
+#include "../../library/Tag.h"
+#include "../../library/Author.h"
+
+static const std::size_t AUTHOR_ENTRIES_POOL_SIZE = 64;
+static const std::size_t TAG_ENTRIES_POOL_SIZE = 64;
+
+class AuthorDisplayNameEntry : public ZLComboOptionEntry {
+
+public:
+ AuthorDisplayNameEntry(BookInfoDialog &dialog, shared_ptr<Author> initialAuthor, bool &visible);
+
+ const std::string &initialValue() const;
+ const std::vector<std::string> &values() const;
+ void onAccept(const std::string &value);
+
+ bool useOnValueEdited() const;
+ void onValueEdited(const std::string &value);
+ void onValueSelected(int index);
+
+private:
+ void onValueChanged(const std::string &value);
+
+private:
+ BookInfoDialog &myInfoDialog;
+ mutable std::vector<std::string> myValues;
+ shared_ptr<Author> myCurrentAuthor;
+
+ std::string myInitialValue;
+ bool myEmpty;
+
+friend class SeriesTitleEntry;
+friend class BookInfoApplyAction;
+};
+
+
+class SeriesTitleEntry : public ZLComboOptionEntry {
+
+public:
+ SeriesTitleEntry(BookInfoDialog &dialog);
+
+ const std::string &initialValue() const;
+ const std::vector<std::string> &values() const;
+ void onAccept(const std::string &value);
+
+ bool useOnValueEdited() const;
+ void onValueEdited(const std::string &value);
+ void onValueSelected(int index);
+
+private:
+ BookInfoDialog &myInfoDialog;
+ std::set<std::string> myOriginalValuesSet;
+ mutable std::vector<std::string> myValues;
+};
+
+
+class BookIndexEntry : public ZLStringOptionEntry {
+
+public:
+ BookIndexEntry(BookInfoDialog &dialog);
+
+ const std::string &initialValue() const;
+ void onAccept(const std::string &value);
+
+private:
+ BookInfoDialog &myInfoDialog;
+};
+
+
+
+
+AuthorDisplayNameEntry::AuthorDisplayNameEntry(BookInfoDialog &dialog, shared_ptr<Author> initialAuthor, bool &visible) :
+ ZLComboOptionEntry(true), myInfoDialog(dialog), myCurrentAuthor(initialAuthor) {
+
+ if (myCurrentAuthor.isNull()) {
+ myInitialValue = "";
+ myEmpty = true;
+ } else {
+ myInitialValue = myCurrentAuthor->name();
+ myEmpty = myInitialValue.empty();
+ }
+ setVisible(visible || !myEmpty);
+ if (visible && myEmpty) {
+ visible = false;
+ }
+}
+
+const std::string &AuthorDisplayNameEntry::initialValue() const {
+ return myInitialValue;
+}
+
+const std::vector<std::string> &AuthorDisplayNameEntry::values() const {
+ if (myValues.empty()) {
+ const std::string &initial = initialValue();
+ bool addInitial = true;
+ const AuthorList &authors = Library::Instance().authors();
+ for (AuthorList::const_iterator it = authors.begin(); it != authors.end(); ++it) {
+ if (it->isNull()) {
+ continue;
+ }
+ const std::string name = (*it)->name();
+ if (addInitial && (name == initial)) {
+ addInitial = false;
+ }
+ myValues.push_back(name);
+ }
+ if (addInitial) {
+ myValues.push_back(initial);
+ }
+ }
+ return myValues;
+}
+
+void AuthorDisplayNameEntry::onAccept(const std::string &value) {
+ if (!isVisible() || value.empty()) {
+ myCurrentAuthor = 0;
+ return;
+ }
+ if (!myCurrentAuthor.isNull() && value == myCurrentAuthor->name()) {
+ //myCurrentAuthor = myCurrentAuthor;
+ return;
+ }
+ myCurrentAuthor = Author::getAuthor(value);
+}
+
+
+bool AuthorDisplayNameEntry::useOnValueEdited() const {
+ return true;
+}
+
+void AuthorDisplayNameEntry::onValueEdited(const std::string &value) {
+ onValueChanged(value);
+}
+
+void AuthorDisplayNameEntry::onValueSelected(int index) {
+ const AuthorList &authors = Library::Instance().authors();
+ myCurrentAuthor = (((std::size_t)index) < authors.size()) ? authors[index] : 0;
+ myInfoDialog.mySeriesTitleEntry->resetView();
+ onValueChanged(myValues[index]);
+}
+
+void AuthorDisplayNameEntry::onValueChanged(const std::string &value) {
+ if (!myInfoDialog.myAuthorsDone || !isVisible()) {
+ return;
+ }
+
+ myEmpty = value.empty();
+ if (myEmpty) {
+ for (std::size_t i = 0; i < myInfoDialog.myAuthorEntries.size(); ++i) {
+ AuthorDisplayNameEntry &entry = *myInfoDialog.myAuthorEntries[i];
+ if (entry.myEmpty && entry.isVisible() && this != &entry) {
+ entry.setVisible(false);
+ }
+ }
+ } else {
+ std::size_t i, lastvisible = (std::size_t) -1;
+ for (i = 0; i < myInfoDialog.myAuthorEntries.size(); ++i) {
+ AuthorDisplayNameEntry &entry = *myInfoDialog.myAuthorEntries[i];
+ if (entry.isVisible()) {
+ lastvisible = i;
+ if (entry.myEmpty) {
+ break;
+ }
+ }
+ }
+ if (i == myInfoDialog.myAuthorEntries.size()) {
+ if (lastvisible + 1 < i) {
+ AuthorDisplayNameEntry &entry = *myInfoDialog.myAuthorEntries[lastvisible + 1];
+ entry.setVisible(true);
+ }
+ // else pool is over
+ }
+ }
+}
+
+
+
+
+SeriesTitleEntry::SeriesTitleEntry(BookInfoDialog &dialog) : ZLComboOptionEntry(true), myInfoDialog(dialog) {
+ const AuthorList &authors = myInfoDialog.myBook->authors();
+ myOriginalValuesSet.insert(initialValue());
+ myOriginalValuesSet.insert("");
+ const Library &library = Library::Instance();
+ for (AuthorList::const_iterator it = authors.begin(); it != authors.end(); ++it) {
+ library.collectSeriesTitles(*it, myOriginalValuesSet);
+ }
+}
+
+const std::string &SeriesTitleEntry::initialValue() const {
+ return myInfoDialog.myBook->seriesTitle();
+}
+
+const std::vector<std::string> &SeriesTitleEntry::values() const {
+ std::set<std::string> valuesSet(myOriginalValuesSet);
+
+ const Library &library = Library::Instance();
+ const AuthorList &authors = myInfoDialog.myBook->authors();
+ for (std::vector<AuthorDisplayNameEntry*>::const_iterator it = myInfoDialog.myAuthorEntries.begin(); it != myInfoDialog.myAuthorEntries.end(); ++it) {
+ shared_ptr<Author> currentAuthor = (*it)->myCurrentAuthor;
+ if (!currentAuthor.isNull() && std::find(authors.begin(), authors.end(), currentAuthor) == authors.end()) {
+ library.collectSeriesTitles(currentAuthor, valuesSet);
+ }
+ }
+
+ /*myValues.clear();
+ for (std::set<std::string>::const_iterator it = valuesSet.begin(); it != valuesSet.end(); ++it) {
+ myValues.push_back(*it);
+ }*/
+ myValues.assign(valuesSet.begin(), valuesSet.end());
+ return myValues;
+}
+
+void SeriesTitleEntry::onAccept(const std::string &value) {
+ Book &book = *myInfoDialog.myBook;
+ book.setSeries(value, book.indexInSeries());
+}
+
+void SeriesTitleEntry::onValueSelected(int index) {
+ myInfoDialog.myBookIndexEntry->setVisible(index != 0);
+}
+
+bool SeriesTitleEntry::useOnValueEdited() const {
+ return true;
+}
+
+void SeriesTitleEntry::onValueEdited(const std::string &value) {
+ myInfoDialog.myBookIndexEntry->setVisible(!value.empty());
+}
+
+BookIndexEntry::BookIndexEntry(BookInfoDialog &dialog) : myInfoDialog(dialog) {
+}
+
+const std::string &BookIndexEntry::initialValue() const {
+ return myInfoDialog.myBook->indexInSeries().value();
+}
+
+void BookIndexEntry::onAccept(const std::string &value) {
+ Book &book = *myInfoDialog.myBook;
+ //TODO implement validation
+ book.setSeries(book.seriesTitle(), Number(value));
+}
+
+class BookTitleEntry : public ZLStringOptionEntry {
+
+public:
+ BookTitleEntry(BookInfoDialog &dialog);
+
+ const std::string &initialValue() const;
+ void onAccept(const std::string &value);
+
+private:
+ BookInfoDialog &myInfoDialog;
+};
+
+BookTitleEntry::BookTitleEntry(BookInfoDialog &dialog) : myInfoDialog(dialog) {
+}
+
+const std::string &BookTitleEntry::initialValue() const {
+ return myInfoDialog.myBook->title();
+}
+
+void BookTitleEntry::onAccept(const std::string &value) {
+ myInfoDialog.myBook->setTitle(value);
+}
+
+
+
+
+
+
+class BookEncodingEntry : public AbstractEncodingEntry {
+
+public:
+ BookEncodingEntry(BookInfoDialog &dialog);
+
+ void onAcceptValue(const std::string &value);
+
+private:
+ BookInfoDialog &myInfoDialog;
+};
+
+BookEncodingEntry::BookEncodingEntry(BookInfoDialog &dialog) :
+ AbstractEncodingEntry(dialog.myBook->encoding()),
+ myInfoDialog(dialog) {
+}
+
+void BookEncodingEntry::onAcceptValue(const std::string &value) {
+ myInfoDialog.myBook->setEncoding(value);
+}
+
+
+
+class BookLanguageEntry : public ZLAbstractLanguageOptionEntry {
+
+public:
+ BookLanguageEntry(BookInfoDialog &dialog, const std::vector<std::string> &languageCodes);
+
+ void onAcceptCode(const std::string &code);
+
+private:
+ BookInfoDialog &myInfoDialog;
+};
+
+BookLanguageEntry::BookLanguageEntry(BookInfoDialog &dialog, const std::vector<std::string> &languageCodes) :
+ ZLAbstractLanguageOptionEntry(dialog.myBook->language(), languageCodes),
+ myInfoDialog(dialog) {
+}
+
+void BookLanguageEntry::onAcceptCode(const std::string &code) {
+ myInfoDialog.myBook->setLanguage(code);
+}
+
+
+
+
+
+class BookTagEntry : public ZLComboOptionEntry {
+
+public:
+ BookTagEntry(BookInfoDialog &dialog, std::string initialTag, bool &visible);
+
+ const std::string &initialValue() const;
+ const std::vector<std::string> &values() const;
+ void onAccept(const std::string &value);
+
+ bool useOnValueEdited() const;
+ void onValueEdited(const std::string &value);
+ void onValueSelected(int index);
+
+private:
+ void onValueChanged(const std::string &value);
+
+private:
+ BookInfoDialog &myInfoDialog;
+ std::string myInitialValue;
+ bool myEmpty;
+
+ mutable std::vector<std::string> myValues;
+};
+
+BookTagEntry::BookTagEntry(BookInfoDialog &dialog, std::string initialTag, bool &visible) :
+ ZLComboOptionEntry(true), myInfoDialog(dialog), myInitialValue(initialTag) {
+
+ myEmpty = myInitialValue.empty();
+ setVisible(visible || !myEmpty);
+ if (visible && myEmpty) {
+ visible = false;
+ }
+}
+
+const std::string &BookTagEntry::initialValue() const {
+ return myInitialValue;
+}
+
+const std::vector<std::string> &BookTagEntry::values() const {
+ if (myValues.empty()) {
+ myValues.push_back("");
+ Tag::collectTagNames(myValues);
+ }
+ return myValues;
+}
+
+void BookTagEntry::onAccept(const std::string &value) {
+ if (isVisible() && !value.empty()) {
+ myInfoDialog.myNewTags.push_back(value);
+ }
+}
+
+bool BookTagEntry::useOnValueEdited() const {
+ return true;
+}
+
+void BookTagEntry::onValueEdited(const std::string &value) {
+ onValueChanged(value);
+}
+
+void BookTagEntry::onValueSelected(int index) {
+ onValueChanged(myValues[index]);
+}
+
+void BookTagEntry::onValueChanged(const std::string &value) {
+ if (!myInfoDialog.myTagsDone || !isVisible()) {
+ return;
+ }
+
+ myEmpty = value.empty();
+ if (myEmpty) {
+ for (std::size_t i = 0; i < myInfoDialog.myTagEntries.size(); ++i) {
+ BookTagEntry &entry = *myInfoDialog.myTagEntries[i];
+ if (entry.myEmpty && entry.isVisible() && this != &entry) {
+ entry.setVisible(false);
+ }
+ }
+ } else {
+ std::size_t i, lastvisible = (std::size_t) -1;
+ for (i = 0; i < myInfoDialog.myTagEntries.size(); ++i) {
+ BookTagEntry &entry = *myInfoDialog.myTagEntries[i];
+ if (entry.isVisible()) {
+ lastvisible = i;
+ if (entry.myEmpty) {
+ break;
+ }
+ }
+ }
+ if (i == myInfoDialog.myTagEntries.size()) {
+ if (lastvisible + 1 < i) {
+ BookTagEntry &entry = *myInfoDialog.myTagEntries[lastvisible + 1];
+ entry.setVisible(true);
+ }
+ }
+ }
+}
+
+class BookInfoApplyAction : public ZLRunnable {
+
+public:
+ BookInfoApplyAction(BookInfoDialog &dialog);
+ void run();
+
+private:
+ BookInfoDialog &myInfoDialog;
+};
+
+BookInfoApplyAction::BookInfoApplyAction(BookInfoDialog &dialog) : myInfoDialog(dialog) {}
+
+void BookInfoApplyAction::run() {
+ Book &book = *myInfoDialog.myBook;
+
+ AuthorList authors;
+ for (std::size_t i = 0; i < myInfoDialog.myAuthorEntries.size(); ++i) {
+ shared_ptr<Author> a = myInfoDialog.myAuthorEntries[i]->myCurrentAuthor;
+ if (!a.isNull() &&
+ std::find(authors.begin(), authors.end(), a) == authors.end()) {
+ authors.push_back(a);
+ }
+ }
+
+ book.removeAllAuthors();
+ for (AuthorList::const_iterator it = authors.begin(); it != authors.end(); ++it) {
+ book.addAuthor(*it);
+ }
+
+ book.removeAllTags();
+ for (std::size_t i = 0; i < myInfoDialog.myNewTags.size(); ++i) {
+ book.addTag(myInfoDialog.myNewTags[i]);
+ }
+
+ Library::Instance().updateBook(myInfoDialog.myBook);
+}
+
+BookInfoDialog::BookInfoDialog(shared_ptr<Book> book) : myBook(book) {
+ myDialog = ZLDialogManager::Instance().createOptionsDialog(ZLResourceKey("InfoDialog"), new BookInfoApplyAction(*this));
+
+ ZLDialogContent &commonTab = myDialog->createTab(ZLResourceKey("Common"));
+ commonTab.addOption(ZLResourceKey("file"),
+ new ZLStringInfoEntry(ZLFile::fileNameToUtf8(book->file().path()))
+ );
+ commonTab.addOption(ZLResourceKey("title"), new BookTitleEntry(*this));
+
+ myEncodingEntry = new BookEncodingEntry(*this);
+ myEncodingSetEntry =
+ (myEncodingEntry->initialValue() != Book::AutoEncoding) ?
+ new EncodingSetEntry(*(EncodingEntry*)myEncodingEntry) : 0;
+ std::vector<std::string> languageCodes = ZLLanguageList::languageCodes();
+ languageCodes.push_back("de-traditional");
+ myLanguageEntry = new BookLanguageEntry(*this, languageCodes);
+ mySeriesTitleEntry = new SeriesTitleEntry(*this);
+ myBookIndexEntry = new BookIndexEntry(*this);
+
+ commonTab.addOption(ZLResourceKey("language"), myLanguageEntry);
+ if (myEncodingSetEntry != 0) {
+ commonTab.addOption(ZLResourceKey("encodingSet"), myEncodingSetEntry);
+ }
+ commonTab.addOption(ZLResourceKey("encoding"), myEncodingEntry);
+
+ initAuthorEntries();
+
+ ZLDialogContent &seriesTab = myDialog->createTab(ZLResourceKey("Series"));
+ seriesTab.addOption(ZLResourceKey("seriesTitle"), mySeriesTitleEntry);
+ seriesTab.addOption(ZLResourceKey("bookIndex"), myBookIndexEntry);
+
+ mySeriesTitleEntry->onValueEdited(mySeriesTitleEntry->initialValue());
+ /*
+ ZLOrderOptionEntry *orderEntry = new ZLOrderOptionEntry();
+ orderEntry->values().push_back("First");
+ orderEntry->values().push_back("Second");
+ orderEntry->values().push_back("Third");
+ orderEntry->values().push_back("Fourth");
+ orderEntry->values().push_back("Fifth");
+ seriesTab.addOption(orderEntry);
+ */
+
+ initTagEntries();
+
+ shared_ptr<FormatPlugin> plugin = PluginCollection::Instance().plugin(*book);
+ if (!plugin.isNull()) {
+ myFormatInfoPage = plugin->createInfoPage(*myDialog, book->file());
+ }
+}
+
+void BookInfoDialog::initTagEntries() {
+ bool visible = true;
+ const TagList &tags = myBook->tags();
+ myTagsDone = false;
+ myTagsTab = &myDialog->createTab(ZLResourceKey("Tags"));
+ for (std::size_t i = 0; i < TAG_ENTRIES_POOL_SIZE; ++i) {
+ std::string tag = (i < tags.size()) ? tags[i]->fullName() : "";
+ BookTagEntry *entry = new BookTagEntry(*this, tag, visible);
+ myTagEntries.push_back(entry);
+ myTagsTab->addOption(ZLResourceKey("tags"), entry);
+ }
+ myTagsDone = true;
+}
+
+void BookInfoDialog::initAuthorEntries() {
+ bool visible = true;
+ const AuthorList &authors = myBook->authors();
+ myAuthorsDone = false;
+ myAuthorsTab = &myDialog->createTab(ZLResourceKey("Authors"));
+ for (std::size_t i = 0; i < AUTHOR_ENTRIES_POOL_SIZE; ++i) {
+ shared_ptr<Author> author = (i < authors.size()) ? authors[i] : 0;
+ AuthorDisplayNameEntry *entry = new AuthorDisplayNameEntry(*this, author, visible);
+ myAuthorEntries.push_back(entry);
+ myAuthorsTab->addOption(ZLResourceKey("authorDisplayName"), entry);
+ }
+ myAuthorsDone = true;
+}
+
diff --git a/fbreader/src/optionsDialog/bookInfo/BookInfoDialog.h b/fbreader/src/optionsDialog/bookInfo/BookInfoDialog.h
new file mode 100644
index 0000000..a5bb75d
--- /dev/null
+++ b/fbreader/src/optionsDialog/bookInfo/BookInfoDialog.h
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2004-2012 Geometer Plus <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#ifndef __BOOKINFODIALOG_H__
+#define __BOOKINFODIALOG_H__
+
+#include <string>
+
+#include <ZLOptionEntry.h>
+
+#include "../../formats/FormatPlugin.h"
+
+class ZLOptionsDialog;
+class ZLDialogContent;
+class AuthorDisplayNameEntry;
+class SeriesTitleEntry;
+class BookIndexEntry;
+class BookTagEntry;
+
+class BookInfoDialog {
+
+public:
+ BookInfoDialog(shared_ptr<Book> book);
+
+ ZLOptionsDialog &dialog();
+
+private:
+ void initAuthorEntries();
+ void initTagEntries();
+
+private:
+ shared_ptr<ZLOptionsDialog> myDialog;
+ shared_ptr<Book> myBook;
+ shared_ptr<FormatInfoPage> myFormatInfoPage;
+
+ ZLComboOptionEntry *myEncodingSetEntry;
+ ZLComboOptionEntry *myEncodingEntry;
+ ZLComboOptionEntry *myLanguageEntry;
+ SeriesTitleEntry *mySeriesTitleEntry;
+ BookIndexEntry *myBookIndexEntry;
+
+ ZLDialogContent *myTagsTab;
+ std::vector<BookTagEntry *> myTagEntries;
+ bool myTagsDone;
+
+ std::vector<std::string> myNewTags;
+
+ ZLDialogContent *myAuthorsTab;
+ std::vector<AuthorDisplayNameEntry *> myAuthorEntries;
+ bool myAuthorsDone;
+
+friend class AuthorDisplayNameEntry;
+friend class SeriesTitleEntry;
+friend class BookIndexEntry;
+friend class BookTitleEntry;
+friend class BookEncodingEntry;
+friend class BookLanguageEntry;
+friend class BookTagEntry;
+friend class BookInfoApplyAction;
+};
+
+inline ZLOptionsDialog &BookInfoDialog::dialog() { return *myDialog; }
+
+#endif /* __BOOKINFODIALOG_H__ */
diff --git a/fbreader/src/optionsDialog/library/LibraryOptionsDialog.cpp b/fbreader/src/optionsDialog/library/LibraryOptionsDialog.cpp
new file mode 100644
index 0000000..1c4608a
--- /dev/null
+++ b/fbreader/src/optionsDialog/library/LibraryOptionsDialog.cpp
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2010-2012 Geometer Plus <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#include "LibraryOptionsDialog.h"
+
+#include <ZLDialogManager.h>
+#include <ZLOptionsDialog.h>
+
+#include "../../fbreader/FBReader.h"
+
+#include "../../network/NetworkLinkCollection.h"
+
+
+LibraryOptionsDialog::LibraryOptionsDialog() : AbstractOptionsDialog(ZLResourceKey("LibraryOptionsDialog"), true) {
+
+ ZLDialogContent &libraryTab = dialog().createTab(ZLResourceKey("Library"));
+
+ Library &library = Library::Instance();
+ libraryTab.addOption(ZLResourceKey("bookPath"), library.PathOption);
+ libraryTab.addOption(ZLResourceKey("lookInSubdirectories"), library.ScanSubdirsOption);
+ libraryTab.addOption(ZLResourceKey("collectBooksWithoutMetaInfo"), library.CollectAllBooksOption);
+ libraryTab.addOption(ZLResourceKey("downloadDirectory"), NetworkLinkCollection::Instance().DirectoryOption);
+}
diff --git a/fbreader/src/optionsDialog/library/LibraryOptionsDialog.h b/fbreader/src/optionsDialog/library/LibraryOptionsDialog.h
new file mode 100644
index 0000000..da217f6
--- /dev/null
+++ b/fbreader/src/optionsDialog/library/LibraryOptionsDialog.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2010-2012 Geometer Plus <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#ifndef __LIBRARYOPTIONSDIALOG_H__
+#define __LIBRARYOPTIONSDIALOG_H__
+
+#include "../AbstractOptionsDialog.h"
+
+
+class LibraryOptionsDialog : public AbstractOptionsDialog {
+
+public:
+ LibraryOptionsDialog();
+};
+
+#endif /* __LIBRARYOPTIONSDIALOG_H__ */
diff --git a/fbreader/src/optionsDialog/lookAndFeel/FormatOptionsPage.cpp b/fbreader/src/optionsDialog/lookAndFeel/FormatOptionsPage.cpp
new file mode 100644
index 0000000..3e24b87
--- /dev/null
+++ b/fbreader/src/optionsDialog/lookAndFeel/FormatOptionsPage.cpp
@@ -0,0 +1,112 @@
+/*
+ * Copyright (C) 2004-2012 Geometer Plus <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#include <ZLOptionsDialog.h>
+
+#include <optionEntries/ZLSimpleOptionEntry.h>
+
+#include <ZLTextStyle.h>
+#include <ZLTextStyleCollection.h>
+#include <ZLTextStyleOptions.h>
+
+#include "FormatOptionsPage.h"
+
+#include "../../options/FBTextStyle.h"
+#include "../../bookmodel/FBTextKind.h"
+
+static const ZLResourceKey KEY_STYLE("style");
+static const ZLResourceKey KEY_BASE("Base");
+
+static const ZLResourceKey KEY_DUMMY("");
+static const ZLResourceKey KEY_LINESPACING("lineSpacing");
+static const ZLResourceKey KEY_FIRSTLINEINDENT("firstLineIndent");
+static const ZLResourceKey KEY_ALIGNMENT("alignment");
+static const ZLResourceKey KEY_SPACEBEFORE("spaceBefore");
+static const ZLResourceKey KEY_SPACEAFTER("spaceAfter");
+static const ZLResourceKey KEY_STARTINDENT("startIndent");
+static const ZLResourceKey KEY_ENDINDENT("endIndent");
+
+FormatOptionsPage::FormatOptionsPage(ZLDialogContent &dialogTab) {
+ const ZLResource &styleResource = ZLResource::resource(KEY_STYLE);
+
+ myComboEntry = new ComboOptionEntry(*this, styleResource[KEY_BASE].value());
+ myComboEntry->addValue(myComboEntry->initialValue());
+
+ ZLTextStyleCollection &collection = ZLTextStyleCollection::Instance();
+ ZLTextKind styles[] = { REGULAR, TITLE, SECTION_TITLE, SUBTITLE, H1, H2, H3, H4, H5, H6, ANNOTATION, EPIGRAPH, PREFORMATTED, AUTHOR, DATEKIND, POEM_TITLE, STANZA, VERSE };
+ const int STYLES_NUMBER = sizeof(styles) / sizeof(ZLTextKind);
+ for (int i = 0; i < STYLES_NUMBER; ++i) {
+ const ZLTextStyleDecoration *decoration = collection.decoration(styles[i]);
+ if (decoration != 0) {
+ myComboEntry->addValue(styleResource[decoration->name()].value());
+ }
+ }
+ dialogTab.addOption(ZLResourceKey("optionsFor"), myComboEntry);
+
+ {
+ const std::string &name = myComboEntry->initialValue();
+ FBTextStyle &baseStyle = FBTextStyle::Instance();
+
+ registerEntries(dialogTab,
+ KEY_LINESPACING, new ZLTextLineSpaceOptionEntry(baseStyle.LineSpacePercentOption, dialogTab.resource(KEY_LINESPACING), false),
+ KEY_DUMMY, 0,//new ZLSimpleSpinOptionEntry("First Line Indent", baseStyle.firstLineIndentDeltaOption(), -300, 300, 1),
+ name
+ );
+
+ registerEntries(dialogTab,
+ KEY_ALIGNMENT, new ZLTextAlignmentOptionEntry(baseStyle.AlignmentOption, dialogTab.resource(KEY_ALIGNMENT), false),
+ KEY_DUMMY, 0,
+ name
+ );
+ }
+
+ for (int i = 0; i < STYLES_NUMBER; ++i) {
+ ZLTextStyleDecoration *d = collection.decoration(styles[i]);
+ if ((d != 0) && (d->isFullDecoration())) {
+ ZLTextFullStyleDecoration *decoration = (ZLTextFullStyleDecoration*)d;
+ const std::string &name = styleResource[decoration->name()].value();
+
+ registerEntries(dialogTab,
+ KEY_SPACEBEFORE, new ZLSimpleSpinOptionEntry(decoration->SpaceBeforeOption, 1),
+ KEY_STARTINDENT, new ZLSimpleSpinOptionEntry(decoration->LineStartIndentOption, 1),
+ name
+ );
+
+ registerEntries(dialogTab,
+ KEY_SPACEAFTER, new ZLSimpleSpinOptionEntry(decoration->SpaceAfterOption, 1),
+ KEY_ENDINDENT, new ZLSimpleSpinOptionEntry(decoration->LineEndIndentOption, 1),
+ name
+ );
+
+ registerEntries(dialogTab,
+ KEY_LINESPACING, new ZLTextLineSpaceOptionEntry(decoration->LineSpacePercentOption, dialogTab.resource(KEY_LINESPACING), true),
+ KEY_FIRSTLINEINDENT, new ZLSimpleSpinOptionEntry(decoration->FirstLineIndentDeltaOption, 1),
+ name
+ );
+
+ registerEntries(dialogTab,
+ KEY_ALIGNMENT, new ZLTextAlignmentOptionEntry(decoration->AlignmentOption, dialogTab.resource(KEY_ALIGNMENT), true),
+ KEY_DUMMY, 0,
+ name
+ );
+ }
+ }
+
+ myComboEntry->onValueSelected(0);
+}
diff --git a/fbreader/src/optionsDialog/lookAndFeel/FormatOptionsPage.h b/fbreader/src/optionsDialog/lookAndFeel/FormatOptionsPage.h
new file mode 100644
index 0000000..81aa33a
--- /dev/null
+++ b/fbreader/src/optionsDialog/lookAndFeel/FormatOptionsPage.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2004-2012 Geometer Plus <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#ifndef __FORMATOPTIONSPAGE_H__
+#define __FORMATOPTIONSPAGE_H__
+
+#include "OptionsPage.h"
+
+class ZLDialogContent;
+
+class FormatOptionsPage : public OptionsPage {
+
+public:
+ FormatOptionsPage(ZLDialogContent &dialogTab);
+};
+
+#endif /* __FORMATOPTIONSPAGE_H__ */
diff --git a/fbreader/src/optionsDialog/lookAndFeel/LookAndFeelOptionsDialog.cpp b/fbreader/src/optionsDialog/lookAndFeel/LookAndFeelOptionsDialog.cpp
new file mode 100644
index 0000000..f33c915
--- /dev/null
+++ b/fbreader/src/optionsDialog/lookAndFeel/LookAndFeelOptionsDialog.cpp
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2010-2012 Geometer Plus <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#include <ZLDialogManager.h>
+#include <ZLOptionsDialog.h>
+#include <ZLPaintContext.h>
+
+#include <optionEntries/ZLSimpleOptionEntry.h>
+#include <optionEntries/ZLColorOptionBuilder.h>
+
+#include <ZLTextStyleCollection.h>
+
+#include "LookAndFeelOptionsDialog.h"
+
+#include "FormatOptionsPage.h"
+#include "StyleOptionsPage.h"
+
+#include "../../fbreader/FBReader.h"
+#include "../../fbreader/FBView.h"
+#include "../../options/FBOptions.h"
+
+
+LookAndFeelOptionsDialog::LookAndFeelOptionsDialog() : AbstractOptionsDialog(ZLResourceKey("LookAndFeelOptionsDialog"), true) {
+ FBReader &fbreader = FBReader::Instance();
+ FBOptions &options = FBOptions::Instance();
+
+ ZLOptionsDialog &dialog = this->dialog();
+
+ ZLDialogContent &cssTab = dialog.createTab(ZLResourceKey("CSS"));
+ cssTab.addOption(ZLResourceKey("overrideSpecifiedFonts"), ZLTextStyleCollection::Instance().OverrideSpecifiedFontsOption);
+
+ ZLDialogContent &marginTab = dialog.createTab(ZLResourceKey("Margins"));
+ marginTab.addOptions(
+ ZLResourceKey("left"), new ZLSimpleSpinOptionEntry(options.LeftMarginOption, 1),
+ ZLResourceKey("right"), new ZLSimpleSpinOptionEntry(options.RightMarginOption, 1)
+ );
+ marginTab.addOptions(
+ ZLResourceKey("top"), new ZLSimpleSpinOptionEntry(options.TopMarginOption, 1),
+ ZLResourceKey("bottom"), new ZLSimpleSpinOptionEntry(options.BottomMarginOption, 1)
+ );
+
+ myFormatPage = new FormatOptionsPage(dialog.createTab(ZLResourceKey("Format")));
+ myStylePage = new StyleOptionsPage(dialog.createTab(ZLResourceKey("Styles")), *fbreader.context());
+
+ ZLDialogContent &colorsTab = dialog.createTab(ZLResourceKey("Colors"));
+ ZLResourceKey colorKey("colorFor");
+ const ZLResource &resource = colorsTab.resource(colorKey);
+ ZLColorOptionBuilder builder;
+ const std::string BACKGROUND = resource["background"].value();
+ builder.addOption(BACKGROUND, options.BackgroundColorOption);
+ builder.addOption(resource["selectionBackground"].value(), options.colorOption(ZLTextStyle::SELECTION_BACKGROUND));
+ builder.addOption(resource["text"].value(), options.RegularTextColorOption);
+ builder.addOption(resource["internalLink"].value(), options.colorOption("internal"));
+ builder.addOption(resource["externalLink"].value(), options.colorOption("external"));
+ builder.addOption(resource["bookLink"].value(), options.colorOption("book"));
+ builder.addOption(resource["highlighted"].value(), options.colorOption(ZLTextStyle::HIGHLIGHTED_TEXT));
+ builder.addOption(resource["treeLines"].value(), options.colorOption(ZLTextStyle::TREE_LINES));
+ builder.addOption(resource["indicator"].value(), (FBView::commonIndicatorInfo().ColorOption));
+ builder.setInitial(BACKGROUND);
+ colorsTab.addOption(colorKey, builder.comboEntry());
+ colorsTab.addOption("", "", builder.colorEntry());
+}
diff --git a/fbreader/src/optionsDialog/lookAndFeel/LookAndFeelOptionsDialog.h b/fbreader/src/optionsDialog/lookAndFeel/LookAndFeelOptionsDialog.h
new file mode 100644
index 0000000..b908285
--- /dev/null
+++ b/fbreader/src/optionsDialog/lookAndFeel/LookAndFeelOptionsDialog.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2010-2012 Geometer Plus <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#ifndef __LOOKANDFEELOPTIONSDIALOG_H__
+#define __LOOKANDFEELOPTIONSDIALOG_H__
+
+#include "../AbstractOptionsDialog.h"
+
+class OptionsPage;
+
+
+class LookAndFeelOptionsDialog : public AbstractOptionsDialog {
+
+public:
+ LookAndFeelOptionsDialog();
+
+private:
+ shared_ptr<OptionsPage> myFormatPage;
+ shared_ptr<OptionsPage> myStylePage;
+};
+
+#endif /* __LOOKANDFEELOPTIONSDIALOG_H__ */
diff --git a/fbreader/src/optionsDialog/lookAndFeel/OptionsPage.cpp b/fbreader/src/optionsDialog/lookAndFeel/OptionsPage.cpp
new file mode 100644
index 0000000..55a6970
--- /dev/null
+++ b/fbreader/src/optionsDialog/lookAndFeel/OptionsPage.cpp
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2004-2012 Geometer Plus <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#include <ZLOptionsDialog.h>
+#include <ZLOptionEntry.h>
+
+#include "OptionsPage.h"
+
+void ComboOptionEntry::onValueSelected(int index) {
+ const std::string &selectedValue = values()[index];
+ const std::map<ZLOptionEntry*,std::string> &entries = myPage.myEntries;
+ int count = 0;
+ for (std::map<ZLOptionEntry*,std::string>::const_iterator it = entries.begin(); it != entries.end(); ++it, ++count) {
+ it->first->setVisible(it->second == selectedValue);
+ }
+}
+
+void OptionsPage::registerEntry(ZLDialogContent &tab, const ZLResourceKey &entryKey, ZLOptionEntry *entry, const std::string &name) {
+ if (entry != 0) {
+ entry->setVisible(false);
+ myEntries[entry] = name;
+ }
+ tab.addOption(entryKey, entry);
+}
+
+void OptionsPage::registerEntries(ZLDialogContent &tab, const ZLResourceKey &entry0Key, ZLOptionEntry *entry0, const ZLResourceKey &entry1Key, ZLOptionEntry *entry1, const std::string &name) {
+ if (entry0 != 0) {
+ entry0->setVisible(false);
+ myEntries[entry0] = name;
+ }
+ if (entry1 != 0) {
+ entry1->setVisible(false);
+ myEntries[entry1] = name;
+ }
+ tab.addOptions(entry0Key, entry0, entry1Key, entry1);
+}
diff --git a/fbreader/src/optionsDialog/lookAndFeel/OptionsPage.h b/fbreader/src/optionsDialog/lookAndFeel/OptionsPage.h
new file mode 100644
index 0000000..a175c2b
--- /dev/null
+++ b/fbreader/src/optionsDialog/lookAndFeel/OptionsPage.h
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2004-2012 Geometer Plus <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#ifndef __OPTIONSPAGE_H__
+#define __OPTIONSPAGE_H__
+
+#include <map>
+
+#include <ZLOptionEntry.h>
+
+class ZLDialogContent;
+
+class OptionsPage;
+
+class ComboOptionEntry : public ZLComboOptionEntry {
+
+public:
+ ComboOptionEntry(OptionsPage &page, const std::string &initialValue);
+ const std::string &initialValue() const;
+ const std::vector<std::string> &values() const;
+ void onAccept(const std::string&);
+ void onValueSelected(int index);
+ void addValue(const std::string &value);
+
+protected:
+ OptionsPage &myPage;
+ std::vector<std::string> myValues;
+ std::string myInitialValue;
+};
+
+class OptionsPage {
+
+public:
+ virtual ~OptionsPage();
+
+protected:
+ OptionsPage();
+
+ void registerEntry(ZLDialogContent &tab, const ZLResourceKey &entryKey, ZLOptionEntry *entry, const std::string &name);
+ void registerEntries(ZLDialogContent &tab, const ZLResourceKey &entry0Key, ZLOptionEntry *entry0, const ZLResourceKey &entry1Key, ZLOptionEntry *entry1, const std::string &name);
+
+protected:
+ ComboOptionEntry *myComboEntry;
+
+private:
+ std::map<ZLOptionEntry*,std::string> myEntries;
+
+friend class ComboOptionEntry;
+};
+
+inline ComboOptionEntry::ComboOptionEntry(OptionsPage &page, const std::string &initialValue) : myPage(page), myInitialValue(initialValue) {}
+inline const std::string &ComboOptionEntry::initialValue() const { return myInitialValue; }
+inline const std::vector<std::string> &ComboOptionEntry::values() const { return myValues; }
+inline void ComboOptionEntry::onAccept(const std::string&) {}
+inline void ComboOptionEntry::addValue(const std::string &value) { myValues.push_back(value); }
+
+inline OptionsPage::OptionsPage() {}
+inline OptionsPage::~OptionsPage() {}
+
+#endif /* __OPTIONSPAGE_H__ */
diff --git a/fbreader/src/optionsDialog/lookAndFeel/StyleOptionsPage.cpp b/fbreader/src/optionsDialog/lookAndFeel/StyleOptionsPage.cpp
new file mode 100644
index 0000000..6fc00e6
--- /dev/null
+++ b/fbreader/src/optionsDialog/lookAndFeel/StyleOptionsPage.cpp
@@ -0,0 +1,127 @@
+/*
+ * Copyright (C) 2004-2012 Geometer Plus <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#include <ZLOptionsDialog.h>
+#include <ZLPaintContext.h>
+
+#include <optionEntries/ZLSimpleOptionEntry.h>
+
+#include <ZLTextView.h>
+#include <ZLTextStyle.h>
+#include <ZLTextStyleCollection.h>
+#include <ZLTextStyleOptions.h>
+
+#include "StyleOptionsPage.h"
+
+#include "../../options/FBTextStyle.h"
+#include "../../bookmodel/FBTextKind.h"
+
+static const ZLResourceKey KEY_STYLE("style");
+static const ZLResourceKey KEY_BASE("Base");
+
+static const ZLResourceKey KEY_BOLD("bold");
+static const ZLResourceKey KEY_ITALIC("italic");
+static const ZLResourceKey KEY_FONTFAMILY("fontFamily");
+static const ZLResourceKey KEY_FONTSIZE("fontSize");
+static const ZLResourceKey KEY_FONTSIZEDIFFERENCE("fontSizeDifference");
+static const ZLResourceKey KEY_ALLOWHYPHENATIONS("allowHyphenations");
+static const ZLResourceKey KEY_AUTOHYPHENATIONS("autoHyphenations");
+static const ZLResourceKey KEY_DUMMY("");
+
+StyleOptionsPage::StyleOptionsPage(ZLDialogContent &dialogTab, ZLPaintContext &context) {
+ const ZLResource &styleResource = ZLResource::resource(KEY_STYLE);
+
+ myComboEntry = new ComboOptionEntry(*this, styleResource[KEY_BASE].value());
+ myComboEntry->addValue(myComboEntry->initialValue());
+
+ ZLTextStyleCollection &collection = ZLTextStyleCollection::Instance();
+ ZLTextKind styles[] = { REGULAR, TITLE, SECTION_TITLE, SUBTITLE, H1, H2, H3, H4, H5, H6, CONTENTS_TABLE_ENTRY, LIBRARY_ENTRY, ANNOTATION, EPIGRAPH, AUTHOR, DATEKIND, POEM_TITLE, STANZA, VERSE, CITE, INTERNAL_HYPERLINK, EXTERNAL_HYPERLINK, BOOK_HYPERLINK, FOOTNOTE, ITALIC, EMPHASIS, BOLD, STRONG, DEFINITION, DEFINITION_DESCRIPTION, PREFORMATTED, CODE };
+ const int STYLES_NUMBER = sizeof(styles) / sizeof(ZLTextKind);
+ for (int i = 0; i < STYLES_NUMBER; ++i) {
+ const ZLTextStyleDecoration *decoration = collection.decoration(styles[i]);
+ if (decoration != 0) {
+ myComboEntry->addValue(styleResource[decoration->name()].value());
+ }
+ }
+ dialogTab.addOption(ZLResourceKey("optionsFor"), myComboEntry);
+
+ {
+ const std::string &name = myComboEntry->initialValue();
+ FBTextStyle &baseStyle = FBTextStyle::Instance();
+
+ registerEntry(dialogTab,
+ KEY_FONTFAMILY, new ZLFontFamilyOptionEntry(baseStyle.FontFamilyOption, context),
+ name
+ );
+
+ registerEntry(dialogTab,
+ KEY_FONTSIZE, new ZLSimpleSpinOptionEntry(baseStyle.FontSizeOption, 2),
+ name
+ );
+
+ registerEntry(dialogTab,
+ KEY_BOLD, new ZLSimpleBooleanOptionEntry(baseStyle.BoldOption),
+ name
+ );
+
+ registerEntry(dialogTab,
+ KEY_ITALIC, new ZLSimpleBooleanOptionEntry(baseStyle.ItalicOption),
+ name
+ );
+
+ registerEntry(dialogTab,
+ KEY_AUTOHYPHENATIONS, new ZLSimpleBooleanOptionEntry(collection.AutoHyphenationOption),
+ name
+ );
+ }
+
+ for (int i = 0; i < STYLES_NUMBER; ++i) {
+ ZLTextStyleDecoration *decoration = collection.decoration(styles[i]);
+ if (decoration != 0) {
+ const std::string &name = styleResource[decoration->name()].value();
+
+ registerEntry(dialogTab,
+ KEY_FONTFAMILY, new ZLTextFontFamilyWithBaseOptionEntry(decoration->FontFamilyOption, dialogTab.resource(KEY_FONTFAMILY), context),
+ name
+ );
+
+ registerEntry(dialogTab,
+ KEY_FONTSIZEDIFFERENCE, new ZLSimpleSpinOptionEntry(decoration->FontSizeDeltaOption, 2),
+ name
+ );
+
+ registerEntry(dialogTab,
+ KEY_BOLD, new ZLSimpleBoolean3OptionEntry(decoration->BoldOption),
+ name
+ );
+
+ registerEntry(dialogTab,
+ KEY_ITALIC, new ZLSimpleBoolean3OptionEntry(decoration->ItalicOption),
+ name
+ );
+
+ registerEntry(dialogTab,
+ KEY_ALLOWHYPHENATIONS, new ZLSimpleBoolean3OptionEntry(decoration->AllowHyphenationsOption),
+ name
+ );
+ }
+ }
+
+ myComboEntry->onValueSelected(0);
+}
diff --git a/fbreader/src/optionsDialog/lookAndFeel/StyleOptionsPage.h b/fbreader/src/optionsDialog/lookAndFeel/StyleOptionsPage.h
new file mode 100644
index 0000000..c61709d
--- /dev/null
+++ b/fbreader/src/optionsDialog/lookAndFeel/StyleOptionsPage.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2004-2012 Geometer Plus <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#ifndef __STYLEOPTIONSPAGE_H__
+#define __STYLEOPTIONSPAGE_H__
+
+#include "OptionsPage.h"
+
+class ZLDialogContent;
+class ZLPaintContext;
+
+class StyleOptionsPage : public OptionsPage {
+
+public:
+ StyleOptionsPage(ZLDialogContent &dialogTab, ZLPaintContext &context);
+};
+
+#endif /* __STYLEOPTIONSPAGE_H__ */
diff --git a/fbreader/src/optionsDialog/network/NetworkOptionsDialog.cpp b/fbreader/src/optionsDialog/network/NetworkOptionsDialog.cpp
new file mode 100644
index 0000000..aa165e1
--- /dev/null
+++ b/fbreader/src/optionsDialog/network/NetworkOptionsDialog.cpp
@@ -0,0 +1,104 @@
+/*
+ * Copyright (C) 2010-2012 Geometer Plus <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#include "NetworkOptionsDialog.h"
+
+#include <ZLDialogManager.h>
+#include <ZLOptionsDialog.h>
+#include <ZLStringUtil.h>
+
+#include <ZLOptionEntry.h>
+#include <ZLOptionsDialog.h>
+#include <ZLNetworkManager.h>
+#include <optionEntries/ZLSimpleOptionEntry.h>
+#include <optionEntries/ZLToggleBooleanOptionEntry.h>
+
+#include "../../fbreader/FBReader.h"
+
+//#include "../../network/NetworkLinkCollection.h"
+//#include "../../network/NetworkLink.h"
+#include "../../network/UserList.h"
+
+
+class NetworkLinkBooleanOptionEntry : public ZLBooleanOptionEntry {
+
+public:
+ NetworkLinkBooleanOptionEntry(ZLBooleanOption &option);
+ bool initialState() const;
+ void onAccept(bool state);
+
+private:
+ ZLBooleanOption &myOption;
+};
+
+NetworkLinkBooleanOptionEntry::NetworkLinkBooleanOptionEntry(ZLBooleanOption &option) : myOption(option) {
+}
+
+bool NetworkLinkBooleanOptionEntry::initialState() const {
+ return myOption.value();
+}
+
+void NetworkLinkBooleanOptionEntry::onAccept(bool state) {
+ bool oldState = myOption.value();
+ myOption.setValue(state);
+ if (state != oldState) {
+// FBReader::Instance().invalidateNetworkView();
+ }
+}
+
+
+
+NetworkOptionsDialog::NetworkOptionsDialog() : AbstractOptionsDialog(ZLResourceKey("NetworkOptionsDialog"), true) {
+ FBReader &fbreader = FBReader::Instance();
+
+ ZLDialogContent &connectionTab = dialog().createTab(ZLResourceKey("Connection"));
+
+ ZLNetworkManager &networkManager = ZLNetworkManager::Instance();
+ connectionTab.addOption(ZLResourceKey("timeout"), new ZLSimpleSpinOptionEntry(networkManager.TimeoutOption(), 5));
+ if (!networkManager.providesProxyInfo()) {
+ ZLToggleBooleanOptionEntry *useProxyEntry = new ZLToggleBooleanOptionEntry(networkManager.UseProxyOption());
+ connectionTab.addOption(ZLResourceKey("useProxy"), useProxyEntry);
+ ZLSimpleStringOptionEntry *proxyHostEntry = new ZLSimpleStringOptionEntry(networkManager.ProxyHostOption());
+ connectionTab.addOption(ZLResourceKey("proxyHost"), proxyHostEntry);
+ ZLSimpleStringOptionEntry *proxyPortEntry = new ZLSimpleStringOptionEntry(networkManager.ProxyPortOption());
+ connectionTab.addOption(ZLResourceKey("proxyPort"), proxyPortEntry);
+ useProxyEntry->addDependentEntry(proxyHostEntry);
+ useProxyEntry->addDependentEntry(proxyPortEntry);
+ useProxyEntry->onStateChanged(useProxyEntry->initialState());
+ }
+
+// ZLDialogContent &libraryTab = dialog().createTab(ZLResourceKey("NetworkLibrary"));
+
+// NetworkLinkCollection &linkCollection = NetworkLinkCollection::Instance();
+// const std::size_t linkCollectionSize = linkCollection.size();
+// const std::size_t linkCollectionSizeMinusOne = linkCollectionSize - 1;
+// for (std::size_t i = 0; i < linkCollectionSize; ++i) {
+// NetworkLink &link = linkCollection.link(i);
+// if (i < linkCollectionSizeMinusOne) {
+// NetworkLink &link2 = linkCollection.link(++i);
+// libraryTab.addOptions(link.SiteName, "", new NetworkLinkBooleanOptionEntry(link.OnOption),
+// link2.SiteName, "", new NetworkLinkBooleanOptionEntry(link2.OnOption));
+// } else {
+// libraryTab.addOption(link.SiteName, "", new NetworkLinkBooleanOptionEntry(link.OnOption));
+// }
+// }
+
+ std::vector<std::pair<ZLResourceKey,ZLOptionEntry*> > additional;
+ createIntegrationTab(fbreader.webBrowserCollection(), ZLResourceKey("Web"), additional);
+}
diff --git a/fbreader/src/optionsDialog/network/NetworkOptionsDialog.h b/fbreader/src/optionsDialog/network/NetworkOptionsDialog.h
new file mode 100644
index 0000000..3c6ca32
--- /dev/null
+++ b/fbreader/src/optionsDialog/network/NetworkOptionsDialog.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2010-2012 Geometer Plus <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#ifndef __NETWORKOPTIONSDIALOG_H__
+#define __NETWORKOPTIONSDIALOG_H__
+
+#include "../AbstractOptionsDialog.h"
+
+
+class NetworkOptionsDialog : public AbstractOptionsDialog {
+
+public:
+ NetworkOptionsDialog();
+};
+
+#endif /* __NETWORKOPTIONSDIALOG_H__ */
diff --git a/fbreader/src/optionsDialog/reading/IndicatorTab.cpp b/fbreader/src/optionsDialog/reading/IndicatorTab.cpp
new file mode 100644
index 0000000..ac8b549
--- /dev/null
+++ b/fbreader/src/optionsDialog/reading/IndicatorTab.cpp
@@ -0,0 +1,171 @@
+/*
+ * Copyright (C) 2004-2012 Geometer Plus <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#include <ZLOptionsDialog.h>
+
+#include <optionEntries/ZLToggleBooleanOptionEntry.h>
+
+#include <ZLTextStyleOptions.h>
+
+#include "ReadingOptionsDialog.h"
+
+#include "../../fbreader/FBReader.h"
+#include "../../fbreader/FBView.h"
+#include "../../fbreader/BookTextView.h"
+
+class StateOptionEntry : public ZLToggleBooleanOptionEntry {
+
+public:
+ StateOptionEntry(ZLBooleanOption &option);
+ void onStateChanged(bool state);
+
+private:
+ bool myState;
+
+friend class SpecialFontSizeEntry;
+};
+
+class SpecialFontSizeEntry : public ZLSimpleSpinOptionEntry {
+
+public:
+ SpecialFontSizeEntry(ZLIntegerRangeOption &option, int step, StateOptionEntry &first, StateOptionEntry &second);
+ void setVisible(bool state);
+
+private:
+ StateOptionEntry &myFirst;
+ StateOptionEntry &mySecond;
+};
+
+StateOptionEntry::StateOptionEntry(ZLBooleanOption &option) : ZLToggleBooleanOptionEntry(option) {
+ myState = option.value();
+}
+
+void StateOptionEntry::onStateChanged(bool state) {
+ myState = state;
+ ZLToggleBooleanOptionEntry::onStateChanged(state);
+}
+
+SpecialFontSizeEntry::SpecialFontSizeEntry(ZLIntegerRangeOption &option, int step, StateOptionEntry &first, StateOptionEntry &second) : ZLSimpleSpinOptionEntry(option, step), myFirst(first), mySecond(second) {
+}
+
+void SpecialFontSizeEntry::setVisible(bool) {
+ ZLSimpleSpinOptionEntry::setVisible(
+ (myFirst.isVisible() && myFirst.myState) ||
+ (mySecond.isVisible() && mySecond.myState)
+ );
+}
+
+class IndicatorTypeEntry : public ZLComboOptionEntry {
+
+public:
+ IndicatorTypeEntry(const ZLResource &resource, ZLIntegerRangeOption &typeOption);
+ void addDependentEntry(ZLOptionEntry *entry);
+ const std::string &initialValue() const;
+
+private:
+ const std::vector<std::string> &values() const;
+ void onAccept(const std::string &value);
+ void onValueSelected(int index);
+
+private:
+ ZLIntegerRangeOption &myOption;
+ std::vector<std::string> myValues;
+ std::vector<ZLOptionEntry*> myDependentEntries;
+};
+
+IndicatorTypeEntry::IndicatorTypeEntry(const ZLResource &resource, ZLIntegerRangeOption &typeOption) : myOption(typeOption) {
+ myValues.push_back(resource["osScrollbar"].value());
+ myValues.push_back(resource["fbIndicator"].value());
+ myValues.push_back(resource["none"].value());
+}
+
+const std::string &IndicatorTypeEntry::initialValue() const {
+ return myValues[myOption.value()];
+}
+
+const std::vector<std::string> &IndicatorTypeEntry::values() const {
+ return myValues;
+}
+
+void IndicatorTypeEntry::addDependentEntry(ZLOptionEntry *entry) {
+ myDependentEntries.push_back(entry);
+}
+
+void IndicatorTypeEntry::onAccept(const std::string &value) {
+ for (std::size_t index = 0; index != myValues.size(); ++index) {
+ if (myValues[index] == value) {
+ myOption.setValue(index);
+ break;
+ }
+ }
+}
+
+void IndicatorTypeEntry::onValueSelected(int index) {
+ for (std::vector<ZLOptionEntry*>::iterator it = myDependentEntries.begin(); it != myDependentEntries.end(); ++it) {
+ (*it)->setVisible(index == FBIndicatorStyle::FB_INDICATOR);
+ }
+}
+
+void ReadingOptionsDialog::createIndicatorTab() {
+ ZLDialogContent &indicatorTab = dialog().createTab(ZLResourceKey("Indicator"));
+ FBIndicatorStyle &indicatorInfo = FBView::commonIndicatorInfo();
+ static ZLResourceKey typeKey("type");
+ IndicatorTypeEntry *indicatorTypeEntry =
+ new IndicatorTypeEntry(indicatorTab.resource(typeKey), indicatorInfo.TypeOption);
+ indicatorTab.addOption(typeKey, indicatorTypeEntry);
+
+ ZLOptionEntry *heightEntry =
+ new ZLSimpleSpinOptionEntry(indicatorInfo.HeightOption, 1);
+ ZLOptionEntry *offsetEntry =
+ new ZLSimpleSpinOptionEntry(indicatorInfo.OffsetOption, 1);
+ indicatorTab.addOptions(ZLResourceKey("height"), heightEntry, ZLResourceKey("offset"), offsetEntry);
+ indicatorTypeEntry->addDependentEntry(heightEntry);
+ indicatorTypeEntry->addDependentEntry(offsetEntry);
+
+ StateOptionEntry *showTextPositionEntry =
+ new StateOptionEntry(indicatorInfo.ShowTextPositionOption);
+ indicatorTab.addOption(ZLResourceKey("pageNumber"), showTextPositionEntry);
+ indicatorTypeEntry->addDependentEntry(showTextPositionEntry);
+
+ StateOptionEntry *showTimeEntry =
+ new StateOptionEntry(indicatorInfo.ShowTimeOption);
+ indicatorTab.addOption(ZLResourceKey("time"), showTimeEntry);
+ indicatorTypeEntry->addDependentEntry(showTimeEntry);
+
+ SpecialFontSizeEntry *fontSizeEntry =
+ new SpecialFontSizeEntry(indicatorInfo.FontSizeOption, 2, *showTextPositionEntry, *showTimeEntry);
+ indicatorTab.addOption(ZLResourceKey("fontSize"), fontSizeEntry);
+ indicatorTypeEntry->addDependentEntry(fontSizeEntry);
+ showTextPositionEntry->addDependentEntry(fontSizeEntry);
+ showTimeEntry->addDependentEntry(fontSizeEntry);
+
+ ZLOptionEntry *tocMarksEntry =
+ new ZLSimpleBooleanOptionEntry(FBReader::Instance().bookTextView().ShowTOCMarksOption);
+ indicatorTab.addOption(ZLResourceKey("tocMarks"), tocMarksEntry);
+ indicatorTypeEntry->addDependentEntry(tocMarksEntry);
+
+ ZLOptionEntry *navigationEntry =
+ new ZLSimpleBooleanOptionEntry(indicatorInfo.IsSensitiveOption);
+ indicatorTab.addOption(ZLResourceKey("navigation"), navigationEntry);
+ indicatorTypeEntry->addDependentEntry(navigationEntry);
+
+ indicatorTypeEntry->onStringValueSelected(indicatorTypeEntry->initialValue());
+ showTextPositionEntry->onStateChanged(showTextPositionEntry->initialState());
+ showTimeEntry->onStateChanged(showTimeEntry->initialState());
+}
diff --git a/fbreader/src/optionsDialog/reading/KeyBindingsTab.cpp b/fbreader/src/optionsDialog/reading/KeyBindingsTab.cpp
new file mode 100644
index 0000000..4d4cc10
--- /dev/null
+++ b/fbreader/src/optionsDialog/reading/KeyBindingsTab.cpp
@@ -0,0 +1,285 @@
+/*
+ * Copyright (C) 2004-2012 Geometer Plus <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#include <ZLOptionsDialog.h>
+#include <ZLApplication.h>
+#include <ZLOptionEntry.h>
+
+#include <optionEntries/ZLSimpleOptionEntry.h>
+#include <optionEntries/ZLSimpleKeyOptionEntry.h>
+
+#include "ReadingOptionsDialog.h"
+
+#include "../../fbreader/FBReader.h"
+#include "../../fbreader/FBReaderActions.h"
+
+class KeyboardControlEntry : public ZLSimpleBooleanOptionEntry {
+
+public:
+ KeyboardControlEntry();
+ void onStateChanged(bool state);
+};
+
+KeyboardControlEntry::KeyboardControlEntry() : ZLSimpleBooleanOptionEntry(FBReader::Instance().KeyboardControlOption) {
+}
+
+void KeyboardControlEntry::onStateChanged(bool state) {
+ ZLSimpleBooleanOptionEntry::onStateChanged(state);
+ FBReader::Instance().grabAllKeys(state);
+}
+
+class SingleKeyOptionEntry : public ZLSimpleKeyOptionEntry {
+
+public:
+ SingleKeyOptionEntry(const CodeIndexBimap &bimap, ZLKeyBindings &bindings);
+ const CodeIndexBimap &codeIndexBimap() const;
+
+private:
+ const CodeIndexBimap &myBimap;
+};
+
+SingleKeyOptionEntry::SingleKeyOptionEntry(const CodeIndexBimap &bimap, ZLKeyBindings &bindings) : ZLSimpleKeyOptionEntry(bindings), myBimap(bimap) {
+}
+
+const ZLSimpleKeyOptionEntry::CodeIndexBimap &SingleKeyOptionEntry::codeIndexBimap() const {
+ return myBimap;
+}
+
+class MultiKeyOptionEntry : public ZLKeyOptionEntry {
+
+public:
+ MultiKeyOptionEntry(const ZLResource &resource);
+ void onAccept();
+ int actionIndex(const std::string &key);
+ void onValueChanged(const std::string &key, int index);
+ void onKeySelected(const std::string &key);
+
+ void setOrientation(ZLView::Angle);
+ void setExitOnCancelEntry(ZLOptionEntry *exitOnCancelEntry);
+
+private:
+ void addAction(const std::string &actionId);
+
+private:
+ const ZLResource &myResource;
+ ZLSimpleKeyOptionEntry::CodeIndexBimap myBimap;
+
+ SingleKeyOptionEntry myEntry0;
+ SingleKeyOptionEntry myEntry90;
+ SingleKeyOptionEntry myEntry180;
+ SingleKeyOptionEntry myEntry270;
+ SingleKeyOptionEntry *myCurrentEntry;
+ ZLOptionEntry *myExitOnCancelEntry;
+};
+
+void MultiKeyOptionEntry::addAction(const std::string &actionId) {
+ myBimap.insert(actionId);
+ addActionName(myResource[ZLResourceKey(actionId)].value());
+}
+
+MultiKeyOptionEntry::MultiKeyOptionEntry(const ZLResource &resource) :
+ ZLKeyOptionEntry(),
+ myResource(resource),
+ myEntry0(myBimap, *FBReader::Instance().keyBindings(ZLView::DEGREES0)),
+ myEntry90(myBimap, *FBReader::Instance().keyBindings(ZLView::DEGREES90)),
+ myEntry180(myBimap, *FBReader::Instance().keyBindings(ZLView::DEGREES180)),
+ myEntry270(myBimap, *FBReader::Instance().keyBindings(ZLView::DEGREES270)),
+ myCurrentEntry(&myEntry0),
+ myExitOnCancelEntry(0) {
+ addAction(ZLApplication::NoAction);
+
+ // switch view
+ addAction(ActionCode::SHOW_LIBRARY);
+ addAction(ActionCode::OPEN_PREVIOUS_BOOK);
+ addAction(ActionCode::SHOW_TOC);
+
+ // navigation
+ addAction(ActionCode::SCROLL_TO_HOME);
+ addAction(ActionCode::SCROLL_TO_START_OF_TEXT);
+ addAction(ActionCode::SCROLL_TO_END_OF_TEXT);
+ addAction(ActionCode::GOTO_NEXT_TOC_SECTION);
+ addAction(ActionCode::GOTO_PREVIOUS_TOC_SECTION);
+ addAction(ActionCode::PAGE_SCROLL_FORWARD);
+ addAction(ActionCode::PAGE_SCROLL_BACKWARD);
+ addAction(ActionCode::LINE_SCROLL_FORWARD);
+ addAction(ActionCode::LINE_SCROLL_BACKWARD);
+ addAction(ActionCode::UNDO);
+ addAction(ActionCode::REDO);
+
+ // selection
+ addAction(ActionCode::COPY_SELECTED_TEXT_TO_CLIPBOARD);
+ addAction(ActionCode::OPEN_SELECTED_TEXT_IN_DICTIONARY);
+ addAction(ActionCode::CLEAR_SELECTION);
+
+ // search
+ addAction(ActionCode::SEARCH);
+ addAction(ActionCode::FIND_PREVIOUS);
+ addAction(ActionCode::FIND_NEXT);
+
+ // look
+ addAction(ActionCode::INCREASE_FONT);
+ addAction(ActionCode::DECREASE_FONT);
+ addAction(ActionCode::SHOW_HIDE_POSITION_INDICATOR);
+ addAction(ActionCode::TOGGLE_FULLSCREEN);
+ addAction(ActionCode::ROTATE_SCREEN);
+
+ // dialogs
+ addAction(ActionCode::SHOW_OPTIONS_DIALOG);
+ addAction(ActionCode::SHOW_BOOK_INFO_DIALOG);
+ addAction(ActionCode::ADD_BOOK);
+
+ // quit
+ addAction(ActionCode::CANCEL);
+ addAction(ActionCode::QUIT);
+}
+
+void MultiKeyOptionEntry::setOrientation(ZLView::Angle angle) {
+ switch (angle) {
+ case ZLView::DEGREES0:
+ myCurrentEntry = &myEntry0;
+ break;
+ case ZLView::DEGREES90:
+ myCurrentEntry = &myEntry90;
+ break;
+ case ZLView::DEGREES180:
+ myCurrentEntry = &myEntry180;
+ break;
+ case ZLView::DEGREES270:
+ myCurrentEntry = &myEntry270;
+ break;
+ }
+ resetView();
+}
+
+void MultiKeyOptionEntry::onAccept() {
+ myEntry0.onAccept();
+ myEntry90.onAccept();
+ myEntry180.onAccept();
+ myEntry270.onAccept();
+}
+
+int MultiKeyOptionEntry::actionIndex(const std::string &key) {
+ return myCurrentEntry->actionIndex(key);
+}
+
+void MultiKeyOptionEntry::onValueChanged(const std::string &key, int index) {
+ myCurrentEntry->onValueChanged(key, index);
+ if (myExitOnCancelEntry != 0) {
+ myExitOnCancelEntry->setVisible(myBimap.codeByIndex(index) == ActionCode::CANCEL);
+ }
+}
+
+void MultiKeyOptionEntry::setExitOnCancelEntry(ZLOptionEntry *exitOnCancelEntry) {
+ myExitOnCancelEntry = exitOnCancelEntry;
+}
+
+void MultiKeyOptionEntry::onKeySelected(const std::string &key) {
+ if (myExitOnCancelEntry != 0) {
+ myExitOnCancelEntry->setVisible(myBimap.codeByIndex(myCurrentEntry->actionIndex(key)) == ActionCode::CANCEL);
+ }
+}
+
+class OrientationEntry : public ZLComboOptionEntry {
+
+public:
+ OrientationEntry(MultiKeyOptionEntry &keyEntry, const ZLResource &resource);
+ const std::string &initialValue() const;
+ const std::vector<std::string> &values() const;
+ void onValueSelected(int index);
+ void onAccept(const std::string &value);
+
+private:
+ MultiKeyOptionEntry &myKeyEntry;
+ const ZLResource &myResource;
+};
+
+OrientationEntry::OrientationEntry(MultiKeyOptionEntry &keyEntry, const ZLResource &resource) : myKeyEntry(keyEntry), myResource(resource) {
+}
+
+const std::string &OrientationEntry::initialValue() const {
+ return values()[0];
+}
+
+const std::vector<std::string> &OrientationEntry::values() const {
+ static std::vector<std::string> _values;
+ if (_values.empty()) {
+ _values.push_back(myResource["degrees0"].value());
+ _values.push_back(myResource["degrees90ccw"].value());
+ _values.push_back(myResource["degrees180"].value());
+ _values.push_back(myResource["degrees90cw"].value());
+ }
+ return _values;
+}
+
+void OrientationEntry::onValueSelected(int index) {
+ static ZLView::Angle angles[] = {
+ ZLView::DEGREES0,
+ ZLView::DEGREES90,
+ ZLView::DEGREES180,
+ ZLView::DEGREES270
+ };
+ myKeyEntry.setOrientation(angles[index]);
+}
+
+void OrientationEntry::onAccept(const std::string&) {
+}
+
+class UseSeparateOptionsEntry : public ZLSimpleBooleanOptionEntry {
+
+public:
+ UseSeparateOptionsEntry(ZLOptionEntry &keyEntry, OrientationEntry &orientationEntry);
+ void onStateChanged(bool state);
+
+private:
+ ZLOptionEntry &myKeyEntry;
+ OrientationEntry &myOrientationEntry;
+};
+
+UseSeparateOptionsEntry::UseSeparateOptionsEntry(ZLOptionEntry &keyEntry, OrientationEntry &orientationEntry) : ZLSimpleBooleanOptionEntry(FBReader::Instance().UseSeparateBindingsOption), myKeyEntry(keyEntry), myOrientationEntry(orientationEntry) {
+}
+
+void UseSeparateOptionsEntry::onStateChanged(bool state) {
+ ZLSimpleBooleanOptionEntry::onStateChanged(state);
+ myOrientationEntry.setVisible(state);
+ myKeyEntry.resetView();
+}
+
+
+void ReadingOptionsDialog::createKeyBindingsTab() {
+ ZLDialogContent &dialogTab = dialog().createTab(ZLResourceKey("Keys"));
+ FBReader &fbreader = FBReader::Instance();
+ if (ZLBooleanOption(ZLCategoryKey::EMPTY, ZLOption::PLATFORM_GROUP, ZLOption::FULL_KEYBOARD_CONTROL, false).value()) {
+ dialogTab.addOption(ZLResourceKey("grabSystemKeys"), new KeyboardControlEntry());
+ }
+ ZLResourceKey actionKey("action");
+ ZLResourceKey separateKey("separate");
+ ZLResourceKey orientationKey("orientation");
+ MultiKeyOptionEntry *keyEntry = new MultiKeyOptionEntry(dialogTab.resource(actionKey));
+ OrientationEntry *orientationEntry = new OrientationEntry(*keyEntry, dialogTab.resource(orientationKey));
+ ZLBooleanOptionEntry *useSeparateBindingsEntry = new UseSeparateOptionsEntry(*keyEntry, *orientationEntry);
+ dialogTab.addOption(separateKey, useSeparateBindingsEntry);
+ dialogTab.addOption(orientationKey, orientationEntry);
+ dialogTab.addOption("", "", keyEntry);
+ ZLOptionEntry *exitOnCancelEntry = new ZLSimpleBooleanOptionEntry(fbreader.QuitOnCancelOption);
+ keyEntry->setExitOnCancelEntry(exitOnCancelEntry);
+ dialogTab.addOption(ZLResourceKey("quitOnCancel"), exitOnCancelEntry);
+ exitOnCancelEntry->setVisible(false);
+ useSeparateBindingsEntry->onStateChanged(useSeparateBindingsEntry->initialState());
+ dialogTab.addOption(ZLResourceKey("keyDelay"), new ZLSimpleSpinOptionEntry(fbreader.KeyDelayOption, 50));
+}
diff --git a/fbreader/src/optionsDialog/reading/ReadingOptionsDialog.cpp b/fbreader/src/optionsDialog/reading/ReadingOptionsDialog.cpp
new file mode 100644
index 0000000..1ccb54d
--- /dev/null
+++ b/fbreader/src/optionsDialog/reading/ReadingOptionsDialog.cpp
@@ -0,0 +1,125 @@
+/*
+ * Copyright (C) 2010-2012 Geometer Plus <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#include <ZLDialogManager.h>
+#include <ZLOptionsDialog.h>
+
+#include <optionEntries/ZLSimpleOptionEntry.h>
+#include <optionEntries/ZLToggleBooleanOptionEntry.h>
+
+#include "ReadingOptionsDialog.h"
+
+#include "../../fbreader/FBReader.h"
+#include "../../fbreader/FBView.h"
+
+
+class RotationTypeEntry : public ZLComboOptionEntry {
+
+public:
+ RotationTypeEntry(const ZLResource &resource, ZLIntegerOption &angleOption);
+
+ const std::string &initialValue() const;
+ const std::vector<std::string> &values() const;
+ void onAccept(const std::string &value);
+
+private:
+ ZLIntegerOption &myAngleOption;
+ std::vector<std::string> myValues;
+};
+
+RotationTypeEntry::RotationTypeEntry(const ZLResource &resource, ZLIntegerOption &angleOption) : myAngleOption(angleOption) {
+ myValues.push_back(resource["disabled"].value());
+ myValues.push_back(resource["counterclockwise"].value());
+ myValues.push_back(resource["180"].value());
+ myValues.push_back(resource["clockwise"].value());
+ myValues.push_back(resource["cycle"].value());
+}
+
+const std::string &RotationTypeEntry::initialValue() const {
+ switch (myAngleOption.value()) {
+ default:
+ return myValues[0];
+ case ZLView::DEGREES90:
+ return myValues[1];
+ case ZLView::DEGREES180:
+ return myValues[2];
+ case ZLView::DEGREES270:
+ return myValues[3];
+ case -1:
+ return myValues[4];
+ }
+}
+
+const std::vector<std::string> &RotationTypeEntry::values() const {
+ return myValues;
+}
+
+void RotationTypeEntry::onAccept(const std::string &value) {
+ int angle = ZLView::DEGREES0;
+ if (value == myValues[1]) {
+ angle = ZLView::DEGREES90;
+ } else if (value == myValues[2]) {
+ angle = ZLView::DEGREES180;
+ } else if (value == myValues[3]) {
+ angle = ZLView::DEGREES270;
+ } else if (value == myValues[4]) {
+ angle = -1;
+ }
+ myAngleOption.setValue(angle);
+}
+
+
+
+ReadingOptionsDialog::ReadingOptionsDialog() : AbstractOptionsDialog(ZLResourceKey("ReadingOptionsDialog"), true) {
+ FBReader &fbreader = FBReader::Instance();
+
+ ZLOptionsDialog &dialog = this->dialog();
+
+ ZLDialogContent &scrollingTab = dialog.createTab(ZLResourceKey("Scrolling"));
+ scrollingTab.addOption(ZLResourceKey("keyLinesToScroll"), new ZLSimpleSpinOptionEntry(fbreader.LinesToScrollOption, 1));
+ scrollingTab.addOption(ZLResourceKey("keyLinesToKeep"), new ZLSimpleSpinOptionEntry(fbreader.LinesToKeepOption, 1));
+ scrollingTab.addOption(ZLResourceKey("keyScrollDelay"), new ZLSimpleSpinOptionEntry(fbreader.KeyScrollingDelayOption, 50));
+ const bool hasTouchScreen =
+ ZLBooleanOption(ZLCategoryKey::EMPTY, ZLOption::PLATFORM_GROUP, ZLOption::TOUCHSCREEN_PRESENTED, false).value();
+ if (hasTouchScreen) {
+ ZLToggleBooleanOptionEntry *enableTapScrollingEntry =
+ new ZLToggleBooleanOptionEntry(fbreader.EnableTapScrollingOption);
+ scrollingTab.addOption(ZLResourceKey("enableTapScrolling"), enableTapScrollingEntry);
+ const bool isFingerTapDetectionSupported =
+ ZLBooleanOption(ZLCategoryKey::EMPTY, ZLOption::PLATFORM_GROUP, ZLOption::FINGER_TAP_DETECTABLE, false).value();
+ if (isFingerTapDetectionSupported) {
+ ZLOptionEntry *fingerOnlyEntry =
+ new ZLSimpleBooleanOptionEntry(fbreader.TapScrollingOnFingerOnlyOption);
+ scrollingTab.addOption(ZLResourceKey("fingerOnly"), fingerOnlyEntry);
+ enableTapScrollingEntry->addDependentEntry(fingerOnlyEntry);
+ enableTapScrollingEntry->onStateChanged(enableTapScrollingEntry->initialState());
+ }
+ }
+
+ ZLDialogContent &selectionTab = dialog.createTab(ZLResourceKey("Selection"));
+ selectionTab.addOption(ZLResourceKey("enableSelection"), FBView::selectionOption());
+
+ createIndicatorTab();
+
+ ZLDialogContent &rotationTab = dialog.createTab(ZLResourceKey("Rotation"));
+ ZLResourceKey directionKey("direction");
+ rotationTab.addOption(directionKey, new RotationTypeEntry(rotationTab.resource(directionKey), fbreader.RotationAngleOption));
+
+ createKeyBindingsTab();
+}
diff --git a/fbreader/src/optionsDialog/reading/ReadingOptionsDialog.h b/fbreader/src/optionsDialog/reading/ReadingOptionsDialog.h
new file mode 100644
index 0000000..83a101a
--- /dev/null
+++ b/fbreader/src/optionsDialog/reading/ReadingOptionsDialog.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2010-2012 Geometer Plus <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#ifndef __READINGOPTIONSDIALOG_H__
+#define __READINGOPTIONSDIALOG_H__
+
+#include "../AbstractOptionsDialog.h"
+
+
+class ReadingOptionsDialog : public AbstractOptionsDialog {
+
+private:
+ void createIndicatorTab();
+ void createKeyBindingsTab();
+
+public:
+ ReadingOptionsDialog();
+};
+
+#endif /* __READINGOPTIONSDIALOG_H__ */
diff --git a/fbreader/src/optionsDialog/system/SystemOptionsDialog.cpp b/fbreader/src/optionsDialog/system/SystemOptionsDialog.cpp
new file mode 100644
index 0000000..91b3c7a
--- /dev/null
+++ b/fbreader/src/optionsDialog/system/SystemOptionsDialog.cpp
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2010-2012 Geometer Plus <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#include <ZLDialogManager.h>
+#include <ZLOptionsDialog.h>
+#include <ZLLanguageList.h>
+#include <ZLOptionEntry.h>
+
+#include <optionEntries/ZLSimpleOptionEntry.h>
+#include <optionEntries/ZLLanguageOptionEntry.h>
+#include <optionEntries/ZLToggleBooleanOptionEntry.h>
+
+#include "SystemOptionsDialog.h"
+
+#include "../../fbreader/FBReader.h"
+#include "../../formats/FormatPlugin.h"
+#include "../../encodingOption/EncodingOptionEntry.h"
+
+
+class TimeoutEntry : public ZLSimpleSpinOptionEntry {
+
+public:
+ TimeoutEntry(ZLIntegerRangeOption &option);
+ void onAccept(int value);
+};
+
+TimeoutEntry::TimeoutEntry(ZLIntegerRangeOption &option) : ZLSimpleSpinOptionEntry(option, 5) {
+}
+
+void TimeoutEntry::onAccept(int value) {
+ ZLOption::startAutoSave(isVisible() ? value : 0);
+ ZLSimpleSpinOptionEntry::onAccept(value);
+}
+
+
+SystemOptionsDialog::SystemOptionsDialog() : AbstractOptionsDialog(ZLResourceKey("SystemOptionsDialog"), true) {
+ ZLOptionsDialog &dialog = this->dialog();
+
+ ZLDialogContent &encodingTab = dialog.createTab(ZLResourceKey("Language"));
+ encodingTab.addOption(ZLResourceKey("autoDetect"), new ZLSimpleBooleanOptionEntry(PluginCollection::Instance().LanguageAutoDetectOption));
+ encodingTab.addOption(ZLResourceKey("defaultLanguage"), new ZLLanguageOptionEntry(PluginCollection::Instance().DefaultLanguageOption, ZLLanguageList::languageCodes()));
+ EncodingEntry *encodingEntry = new EncodingEntry(PluginCollection::Instance().DefaultEncodingOption);
+ EncodingSetEntry *encodingSetEntry = new EncodingSetEntry(*encodingEntry);
+ encodingTab.addOption(ZLResourceKey("defaultEncodingSet"), encodingSetEntry);
+ encodingTab.addOption(ZLResourceKey("defaultEncoding"), encodingEntry);
+
+ if (ZLOption::isAutoSavingSupported()) {
+ ZLDialogContent &configTab = dialog.createTab(ZLResourceKey("Config"));
+ FBReader &fbreader = FBReader::Instance();
+ ZLToggleBooleanOptionEntry *enableEntry =
+ new ZLToggleBooleanOptionEntry(fbreader.ConfigAutoSavingOption);
+ configTab.addOption(ZLResourceKey("autoSave"), enableEntry);
+
+ ZLOptionEntry *timeoutEntry = new TimeoutEntry(fbreader.ConfigAutoSaveTimeoutOption);
+ enableEntry->addDependentEntry(timeoutEntry);
+ configTab.addOption(ZLResourceKey("timeout"), timeoutEntry);
+
+ enableEntry->onStateChanged(enableEntry->initialState());
+ }
+
+ FBReader &fbreader = FBReader::Instance();
+
+ std::vector<std::pair<ZLResourceKey,ZLOptionEntry*> > additional;
+ ZLOptionEntry *entry =
+ new ZLSimpleBooleanOptionEntry(fbreader.EnableSingleClickDictionaryOption);
+ additional.push_back(std::make_pair(ZLResourceKey("singleClickOpen"), entry));
+ createIntegrationTab(fbreader.dictionaryCollection(), ZLResourceKey("Dictionary"), additional);
+
+ dialog.createPlatformDependentTabs();
+}
diff --git a/fbreader/src/optionsDialog/system/SystemOptionsDialog.h b/fbreader/src/optionsDialog/system/SystemOptionsDialog.h
new file mode 100644
index 0000000..171b6ba
--- /dev/null
+++ b/fbreader/src/optionsDialog/system/SystemOptionsDialog.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2010-2012 Geometer Plus <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#ifndef __SYSTEMOPTIONSDIALOG_H__
+#define __SYSTEMOPTIONSDIALOG_H__
+
+#include "../AbstractOptionsDialog.h"
+
+
+class SystemOptionsDialog: public AbstractOptionsDialog {
+
+public:
+ SystemOptionsDialog();
+};
+
+#endif /* __SYSTEMOPTIONSDIALOG_H__ */