Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

configuredlg.cpp

Go to the documentation of this file.
00001 /*
00002 Dagger - A Bible study program utilizing the Sword library.
00003 Copyright (c) 2004 Dan Williams <drw@handhelds.org>
00004 
00005 This file is free software; you can redistribute it and/or modify it under
00006 the terms of the GNU General Public License as published by the Free Software
00007 Foundation; either version 2 of the License, or (at your option) any later version.
00008 
00009 This file is distributed in the hope that it will be useful, but WITHOUT ANY
00010 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
00011 PARTICULAR PURPOSE. See the GNU General Public License for more details.
00012 
00013 You should have received a copy of the GNU General Public License along with this
00014 file; see the file COPYING. If not, write to the Free Software Foundation, Inc.,
00015 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00016 */
00017 
00018 #include "configuredlg.h"
00019 
00020 #include <opie2/ofiledialog.h>
00021 #include <opie2/oresource.h>
00022 
00023 #include <qlabel.h>
00024 #include <qlayout.h>
00025 #include <qpushbutton.h>
00026 #include <qvbuttongroup.h>
00027 #include <qwhatsthis.h>
00028 
00029 ConfigureDlg::ConfigureDlg( QWidget *parent, const QString &swordPath, bool alwaysOpenNew, int numVerses,
00030                             bool disableBlanking, int copyFormat, const QFont *font )
00031     : QDialog( parent, QString::null, true, WStyle_ContextHelp )
00032     , m_tabs( this )
00033 {
00034     setCaption( tr( "Configure Dagger" ) );
00035 
00036     QVBoxLayout *layout = new QVBoxLayout( this );
00037     layout->setMargin( 4 );
00038     layout->addWidget( &m_tabs );
00039 
00040     // General tab
00041     QWidget *widget = new QWidget( this );
00042     QGridLayout *grid = new QGridLayout( widget, 1, 2, 4, 2 );
00043     grid->setRowStretch( 9, 5 );
00044     grid->setColStretch( 0, 2 );
00045 
00046     QLabel *label = new QLabel( tr( "Path where Sword texts are located:" ), widget );
00047     label->setAlignment( Qt::AlignLeft | Qt::AlignTop | Qt::WordBreak );
00048     QWhatsThis::add( label, tr( "Enter the path where the Sword modules (Bible texts, commentaries, etc.) can be found.  This path should contain either the 'mods.conf' file or 'mods.d' sub-directory." ) );
00049     grid->addMultiCellWidget( label, 0, 0, 0, 1 );
00050     m_swordPath = new QLineEdit( swordPath, widget );
00051     QWhatsThis::add( m_swordPath, tr( "Enter the path where the Sword texts (Bibles, commentaries, etc.) can be found.  This path should contain either the 'mods.conf' file or 'mods.d' sub-directory." ) );
00052     grid->addWidget( m_swordPath, 1, 0 );
00053     QPushButton *btn = new QPushButton( Opie::Core::OResource::loadPixmap( "folder", Opie::Core::OResource::SmallIcon ),
00054                                         QString::null, widget );
00055     btn->setMaximumWidth( btn->height() );
00056     QWhatsThis::add( btn, tr( "Tap here to select the path where the Sword texts (Bibles, commentaries, etc.) can be found.  This path should contain either the 'mods.conf' file or 'mods.d' sub-directory." ) );
00057     connect( btn, SIGNAL(clicked()), this, SLOT(slotSelectSwordPath()) );
00058     grid->addWidget( btn, 1, 1 );
00059 
00060     label = new QLabel( tr( "(Note: Dagger must be restarted for this option to take affect.)" ), widget );
00061     label->setAlignment( Qt::AlignHCenter | Qt::AlignTop | Qt::WordBreak );
00062     QWhatsThis::add( label, tr( "Enter the path where the Sword modules (Bible texts, commentaries, etc.) can be found.  This path should contain either the 'mods.conf' file or 'mods.d' sub-directory." ) );
00063     grid->addMultiCellWidget( label, 2, 2, 0, 1 );
00064 
00065     grid->addRowSpacing( 3, 15 );
00066 
00067     m_alwaysOpenNew = new QCheckBox( tr( "Always open texts in new window?" ), widget );
00068     m_alwaysOpenNew->setChecked( alwaysOpenNew );
00069     QWhatsThis::add( m_alwaysOpenNew, tr( "Tap here to always open texts in a new window.  If this option is not selected, only one copy of a Sword text will be opened." ) );
00070     grid->addMultiCellWidget( m_alwaysOpenNew, 4, 4, 0, 1 );
00071 
00072     grid->addRowSpacing( 5, 15 );
00073 
00074     label = new QLabel( tr( "Number of verses to display at a time:" ), widget );
00075     label->setAlignment( Qt::AlignLeft | Qt::AlignTop | Qt::WordBreak );
00076     QWhatsThis::add( label, tr( "Enter the number of verses to display at a time.  This also affects how far the scroll to previous/next page buttons on the Navigation bar scroll." ) );
00077     grid->addWidget( label, 6, 0 );
00078     m_numVerses = new QSpinBox( 1, 20, 1, widget );
00079     m_numVerses->setValue( numVerses );
00080     QWhatsThis::add( m_numVerses, tr( "Enter the number of verses to display at a time.  This also affects how far the scroll to previous/next page buttons on the Navigation bar scroll." ) );
00081     grid->addWidget( m_numVerses, 6, 1 );
00082 
00083     grid->addRowSpacing( 7, 15 );
00084 
00085     m_disableScreenBlank = new QCheckBox( tr( "Disable automatic screen power-down?" ), widget );
00086     m_disableScreenBlank->setChecked( disableBlanking );
00087     QWhatsThis::add( m_disableScreenBlank, tr( "Tap here to disable Opie's automatic power management feature which will dim and turn off the screen after a specified time.  This will only be effective while Dagger is running." ) );
00088     grid->addMultiCellWidget( m_disableScreenBlank, 8, 8, 0, 1 );
00089 
00090     m_tabs.addTab( widget, "SettingsIcon", tr( "General" ) );
00091 
00092     // Copy tab
00093     widget = new QWidget( this );
00094     QWhatsThis::add( widget, tr( "Select the format used when copying the current verse to the clipboard." ) );
00095     layout = new QVBoxLayout( widget );
00096     layout->setMargin( 4 );
00097 
00098     QVButtonGroup *bg = new QVButtonGroup( tr( "Select copy format" ), widget );
00099     m_copyTextFull = new QRadioButton( tr( "\"Verse (Book cc:vv, text)\"" ), bg );
00100     connect( m_copyTextFull, SIGNAL(clicked()), this, SLOT(slotCopyFormatSelected()) );
00101     m_copyFull = new QRadioButton( tr( "\"Verse (Book cc:vv)\"" ), bg );
00102     connect( m_copyFull, SIGNAL(clicked()), this, SLOT(slotCopyFormatSelected()) );
00103     m_copyVerse = new QRadioButton( tr( "\"Verse\"" ), bg );
00104     connect( m_copyVerse, SIGNAL(clicked()), this, SLOT(slotCopyFormatSelected()) );
00105     m_copyKey = new QRadioButton( tr( "\"Book cc:vv\"" ), bg );
00106     connect( m_copyKey, SIGNAL(clicked()), this, SLOT(slotCopyFormatSelected()) );
00107     layout->addWidget( bg );
00108 
00109     layout->addSpacing( 15 );
00110 
00111     label = new QLabel( tr( "Example:" ), widget );
00112     label->setAlignment( Qt::AlignLeft | Qt::AlignTop | Qt::WordBreak );
00113     layout->addWidget( label );
00114 
00115     layout->addSpacing( 15 );
00116 
00117     m_copyExample = new QLabel( widget );
00118     m_copyExample->setAlignment( Qt::AlignLeft | Qt::AlignTop | Qt::WordBreak );
00119     layout->addWidget( m_copyExample );
00120 
00121     if ( copyFormat == 0 )
00122         m_copyTextFull->animateClick();
00123     else if ( copyFormat == 1 )
00124         m_copyFull->animateClick();
00125     else if ( copyFormat == 2 )
00126         m_copyVerse->animateClick();
00127     else if ( copyFormat == 3 )
00128         m_copyKey->animateClick();
00129 
00130     layout->addStretch();
00131 
00132     m_tabs.addTab( widget, "copy", tr( "Copy" ) );
00133 
00134     // Font tab
00135     m_font = new Opie::Ui::OFontSelector( true, this );
00136     if ( font )
00137         m_font->setSelectedFont( *font );
00138     QWhatsThis::add( m_font, tr( "Select the font, style and size used for displaying texts." ) );
00139 
00140     m_tabs.addTab( m_font, "font", tr( "Font" ) );
00141 
00142     m_tabs.setCurrentTab( tr( "General" ) );
00143 }
00144 
00145 void ConfigureDlg::slotCopyFormatSelected()
00146 {
00147     const QObject *option = sender();
00148 
00149     QString text = tr( "KJV" );
00150     QString verse = tr( "In the beginning God created the heaven and the earth." );
00151     QString key = tr( "Gen 1:1" );
00152 
00153     if ( option == m_copyTextFull && m_copyTextFull->isChecked() )
00154         m_copyExample->setText( QString( "%1 (%2, %3)" ).arg( verse ).arg( key ).arg( text ) );
00155     else if ( option == m_copyFull && m_copyFull->isChecked() )
00156         m_copyExample->setText( QString( "%1 (%2)" ).arg( verse ).arg( key ) );
00157     else if ( option == m_copyVerse && m_copyVerse->isChecked() )
00158         m_copyExample->setText( verse );
00159     else if ( option == m_copyKey && m_copyKey->isChecked() )
00160         m_copyExample->setText( key );
00161 }
00162 
00163 void ConfigureDlg::slotSelectSwordPath()
00164 {
00165     QString path = Opie::Ui::OFileDialog::getDirectory( 0, m_swordPath->text() );
00166     if ( path.at( path.length() - 1 ) == '/' )
00167         path.truncate( path.length() - 1 );
00168     m_swordPath->setText( path );
00169 }

Generated on Sat Nov 5 16:16:48 2005 for OPIE by  doxygen 1.4.2