summaryrefslogtreecommitdiff
path: root/noncore/apps/dagger/configuredlg.cpp
blob: e4dd60f4a6822dfb828d8acde6933072b48f5528 (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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/*
Dagger - A Bible study program utilizing the Sword library.
Copyright (c) 2004 Dan Williams <drw@handhelds.org>

This file 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 file 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
file; see the file COPYING. If not, write to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

#include "configuredlg.h"

#include <qvbuttongroup.h>
#include <qlabel.h>
#include <qlayout.h>

ConfigureDlg::ConfigureDlg( QWidget *parent, const QString &swordPath, bool alwaysOpenNew, int numVerses,
                            bool disableBlanking, int copyFormat, const QFont *font )
    : QDialog( parent, QString::null, true )
    , m_tabs( this )
{
    setCaption( tr( "Configure Dagger" ) );

    QVBoxLayout *layout = new QVBoxLayout( this );
    layout->setMargin( 4 );
    layout->addWidget( &m_tabs );

    // General tab
    QWidget *widget = new QWidget( this );
    QGridLayout *grid = new QGridLayout( widget, 1, 2, 4, 2 );
    grid->setRowStretch( 9, 5 );
    grid->setColStretch( 0, 2 );

    QLabel *label = new QLabel( tr( "Path where Sword modules are located:" ), widget );
    label->setAlignment( Qt::AlignLeft | Qt::AlignTop | Qt::WordBreak );
    grid->addMultiCellWidget( label, 0, 0, 0, 1 );
    m_swordPath = new QLineEdit( swordPath, widget );
    grid->addMultiCellWidget( m_swordPath, 1, 1, 0, 1 );
    label = new QLabel( tr( "(Note: Dagger must be restarted for this option to take affect.)" ), widget );
    label->setAlignment( Qt::AlignHCenter | Qt::AlignTop | Qt::WordBreak );
    grid->addMultiCellWidget( label, 2, 2, 0, 1 );

    grid->addRowSpacing( 3, 15 );

    m_alwaysOpenNew = new QCheckBox( tr( "Always open texts in new window?" ), widget );
    m_alwaysOpenNew->setChecked( alwaysOpenNew );
    grid->addMultiCellWidget( m_alwaysOpenNew, 4, 4, 0, 1 );

    grid->addRowSpacing( 5, 15 );

    label = new QLabel( tr( "Number of verses to display at a time:" ), widget );
    label->setAlignment( Qt::AlignLeft | Qt::AlignTop | Qt::WordBreak );
    grid->addWidget( label, 6, 0 );
    m_numVerses = new QSpinBox( 1, 20, 1, widget );
    m_numVerses->setValue( numVerses );
    grid->addWidget( m_numVerses, 6, 1 );

    grid->addRowSpacing( 7, 15 );

    m_disableScreenBlank = new QCheckBox( tr( "Disable automatic screen power-down?" ), widget );
    m_disableScreenBlank->setChecked( disableBlanking );
    grid->addMultiCellWidget( m_disableScreenBlank, 8, 8, 0, 1 );

    m_tabs.addTab( widget, "SettingsIcon", tr( "General" ) );

    // Copy tab
    widget = new QWidget( this );
    layout = new QVBoxLayout( widget );
    layout->setMargin( 4 );

    QVButtonGroup *bg = new QVButtonGroup( tr( "Select copy format" ), widget );
    m_copyTextFull = new QRadioButton( tr( "\"Verse (Book cc:vv, text)\"" ), bg );
    connect( m_copyTextFull, SIGNAL(clicked()), this, SLOT(slotCopyFormatSelected()) );
    m_copyFull = new QRadioButton( tr( "\"Verse (Book cc:vv)\"" ), bg );
    connect( m_copyFull, SIGNAL(clicked()), this, SLOT(slotCopyFormatSelected()) );
    m_copyVerse = new QRadioButton( tr( "\"Verse\"" ), bg );
    connect( m_copyVerse, SIGNAL(clicked()), this, SLOT(slotCopyFormatSelected()) );
    m_copyKey = new QRadioButton( tr( "\"Book cc:vv\"" ), bg );
    connect( m_copyKey, SIGNAL(clicked()), this, SLOT(slotCopyFormatSelected()) );
    layout->addWidget( bg );

    layout->addSpacing( 15 );

    label = new QLabel( tr( "Example:" ), widget );
    label->setAlignment( Qt::AlignLeft | Qt::AlignTop | Qt::WordBreak );
    layout->addWidget( label );

    layout->addSpacing( 15 );

    m_copyExample = new QLabel( widget );
    m_copyExample->setAlignment( Qt::AlignLeft | Qt::AlignTop | Qt::WordBreak );
    layout->addWidget( m_copyExample );

    if ( copyFormat == 0 )
        m_copyTextFull->animateClick();
    else if ( copyFormat == 1 )
        m_copyFull->animateClick();
    else if ( copyFormat == 2 )
        m_copyVerse->animateClick();
    else if ( copyFormat == 3 )
        m_copyKey->animateClick();

    layout->addStretch();

    m_tabs.addTab( widget, "copy", tr( "Copy" ) );

    // Font tab
    m_font = new Opie::Ui::OFontSelector( true, this );
    if ( font )
        m_font->setSelectedFont( *font );
    m_tabs.addTab( m_font, "font", tr( "Font" ) );

    m_tabs.setCurrentTab( tr( "General" ) );
}

void ConfigureDlg::slotCopyFormatSelected()
{
    const QObject *option = sender();

    QString text = tr( "KJV" );
    QString verse = tr( "In the beginning God created the heaven and the earth." );
    QString key = tr( "Gen 1:1" );

    if ( option == m_copyTextFull && m_copyTextFull->isChecked() )
        m_copyExample->setText( QString( "%1 (%2, %3)" ).arg( verse ).arg( key ).arg( text ) );
    else if ( option == m_copyFull && m_copyFull->isChecked() )
        m_copyExample->setText( QString( "%1 (%2)" ).arg( verse ).arg( key ) );
    else if ( option == m_copyVerse && m_copyVerse->isChecked() )
        m_copyExample->setText( verse );
    else if ( option == m_copyKey && m_copyKey->isChecked() )
        m_copyExample->setText( key );
}