summaryrefslogtreecommitdiff
path: root/src/frontend/settingsdialogs/bttextfilterstab.cpp
blob: e8da03897e49642fcbc133d1061aa1b144c90768 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/*********
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/

#include "frontend/settingsdialogs/bttextfilterstab.h"

#include <QCheckBox>
#include <QLabel>
#include <QVBoxLayout>
#include "backend/config/btconfig.h"
#include "frontend/settingsdialogs/cswordsettings.h"
#include "util/tool.h"


#define TEXT_FILTERS_TAB_ADD_ROW(name,def) \
        m_ ## name ## Check = new QCheckBox(this); \
        m_ ## name ## Check->setChecked(btConfig().sessionValue<bool>(#name,(def))); \
        layout->addWidget(m_ ## name ## Check);

BtTextFiltersTab::BtTextFiltersTab(CSwordSettingsPage *parent)
    : QWidget(parent)
{
    QVBoxLayout *layout = new QVBoxLayout(this);
    layout->setMargin(5);
    layout->setSpacing(2);

    m_explanationLabel = new QLabel(this);
    m_explanationLabel->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
    m_explanationLabel->setMaximumHeight(50);
    layout->addWidget(m_explanationLabel);

    btConfig().beginGroup("presentation");
        TEXT_FILTERS_TAB_ADD_ROW(lineBreaks, false);
        TEXT_FILTERS_TAB_ADD_ROW(verseNumbers, false);
        TEXT_FILTERS_TAB_ADD_ROW(headings, true);
        TEXT_FILTERS_TAB_ADD_ROW(hebrewPoints, true);
        TEXT_FILTERS_TAB_ADD_ROW(hebrewCantillation, true);
        TEXT_FILTERS_TAB_ADD_ROW(morphSegmentation, true);
        TEXT_FILTERS_TAB_ADD_ROW(greekAccents, true);
        TEXT_FILTERS_TAB_ADD_ROW(textualVariants, false);
        TEXT_FILTERS_TAB_ADD_ROW(scriptureReferences, true);
    btConfig().endGroup();

    layout->addStretch(4);

    retranslateUi();
}

#define TEXT_FILTERS_TAB_SAVE(name) \
    btConfig().setSessionValue(#name, m_ ## name ## Check->isChecked())

void BtTextFiltersTab::save() {
    btConfig().beginGroup("presentation");
        TEXT_FILTERS_TAB_SAVE(lineBreaks);
        TEXT_FILTERS_TAB_SAVE(verseNumbers);
        TEXT_FILTERS_TAB_SAVE(headings);
        TEXT_FILTERS_TAB_SAVE(hebrewPoints);
        TEXT_FILTERS_TAB_SAVE(hebrewCantillation);
        TEXT_FILTERS_TAB_SAVE(morphSegmentation);
        TEXT_FILTERS_TAB_SAVE(greekAccents);
        TEXT_FILTERS_TAB_SAVE(textualVariants);
        TEXT_FILTERS_TAB_SAVE(scriptureReferences);
    btConfig().endGroup();
}


void BtTextFiltersTab::retranslateUi() {
    util::tool::initExplanationLabel(m_explanationLabel, "",
          tr("Filters control the appearance of text. Here you can specify "
             "default settings for all filters. You can override these "
             "settings in each display window."));

    m_lineBreaksCheck->setText(tr("Insert line break after each verse"));
    m_verseNumbersCheck->setText(tr("Show verse numbers"));
    m_headingsCheck->setText(tr("Show section headings"));
    m_scriptureReferencesCheck->setText(tr("Show scripture cross-references"));
    m_greekAccentsCheck->setText(tr("Show Greek accents"));
    m_hebrewPointsCheck->setText(tr("Show Hebrew vowel points"));
    m_hebrewCantillationCheck->setText(tr("Show Hebrew cantillation marks"));
    m_morphSegmentationCheck->setText(tr("Show morph segmentation"));
    m_textualVariantsCheck->setText(tr("Use textual variants"));
}