summaryrefslogtreecommitdiff
path: root/noncore/apps/dagger/navbar.cpp
Unidiff
Diffstat (limited to 'noncore/apps/dagger/navbar.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/dagger/navbar.cpp93
1 files changed, 93 insertions, 0 deletions
diff --git a/noncore/apps/dagger/navbar.cpp b/noncore/apps/dagger/navbar.cpp
new file mode 100644
index 0000000..4781af0
--- a/dev/null
+++ b/noncore/apps/dagger/navbar.cpp
@@ -0,0 +1,93 @@
1/*
2Dagger - A Bible study program utilizing the Sword library.
3Copyright (c) 2004 Dan Williams <drw@handhelds.org>
4
5This file is free software; you can redistribute it and/or modify it under
6the terms of the GNU General Public License as published by the Free Software
7Foundation; either version 2 of the License, or (at your option) any later version.
8
9This file is distributed in the hope that it will be useful, but WITHOUT ANY
10WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
11PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
13You should have received a copy of the GNU General Public License along with this
14file; see the file COPYING. If not, write to the Free Software Foundation, Inc.,
1559 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16*/
17
18#include "navbar.h"
19
20#include <qpe/config.h>
21#include <qpe/resource.h>
22
23#include <qaction.h>
24#include <qlineedit.h>
25
26NavBar::NavBar( QMainWindow *parent )
27 : QToolBar( QString::null, parent, QMainWindow::Top, true )
28{
29 // Initialize UI
30 m_actionPrevChapter = new QAction( tr( "Previous chapter" ), Resource::loadPixmap( "fastback" ),
31 QString::null, 0, this, 0 );
32 m_actionPrevChapter->addTo( this );
33 connect( m_actionPrevChapter, SIGNAL(activated()), this, SIGNAL(prevChapter()) );
34
35 m_actionPrevVerse = new QAction( tr( "Previous verse" ), Resource::loadPixmap( "back" ),
36 QString::null, 0, this, 0 );
37 m_actionPrevVerse->addTo( this );
38 connect( m_actionPrevVerse, SIGNAL(activated()), this, SIGNAL(prevVerse()) );
39
40 m_key = new QLineEdit( this );
41 setStretchableWidget( m_key );
42 connect(m_key, SIGNAL(textChanged(const QString &)), this, SIGNAL(keyChanged(const QString &)) );
43
44 m_actionNextVerse = new QAction( tr( "Next verse" ), Resource::loadPixmap( "forward" ),
45 QString::null, 0, this, 0 );
46 m_actionNextVerse->addTo( this );
47 connect( m_actionNextVerse, SIGNAL(activated()), this, SIGNAL(nextVerse()) );
48
49 m_actionNextChapter = new QAction( tr( "Next chapter" ), Resource::loadPixmap( "fastforward" ),
50 QString::null, 0, this, 0 );
51 m_actionNextChapter->addTo( this );
52 connect( m_actionNextChapter, SIGNAL(activated()), this, SIGNAL(nextChapter()) );
53
54 addSeparator();
55
56 m_scrollRate = new QSpinBox( 1, 100, 1, this );
57 m_scrollRate->setMinimumWidth( 35 );
58 connect( m_scrollRate, SIGNAL(valueChanged(int)), this, SIGNAL(scrollRateChanged(int)) );
59
60 m_actionScroll = new QAction( tr( "Auto-scroll" ), Resource::loadPixmap( "dagger/autoscroll" ),
61 QString::null, 0, this, 0 );
62 m_actionScroll->setToggleAction( true );
63 connect( m_actionScroll, SIGNAL(toggled(bool)), this, SIGNAL(autoScroll(bool)) );
64 m_actionScroll->addTo( this );
65
66 if ( parent )
67 {
68 installEventFilter( parent );
69 m_key->installEventFilter( parent );
70 }
71}
72
73void NavBar::navBtnsEnable( bool enabled )
74{
75 m_actionPrevChapter->setEnabled( enabled );
76 m_actionPrevVerse->setEnabled( enabled );
77 m_actionNextVerse->setEnabled( enabled );
78 m_actionNextChapter->setEnabled( enabled );
79 m_scrollRate->setEnabled( enabled );
80 m_actionScroll->setEnabled( enabled );
81}
82
83void NavBar::setKey( const QString &newKey )
84{
85 disconnect( m_key, SIGNAL(textChanged(const QString &)), 0, 0 );
86 m_key->setText( newKey );
87 connect(m_key, SIGNAL(textChanged(const QString &)), this, SIGNAL(keyChanged(const QString &)) );
88}
89
90void NavBar::setAutoScrollRate( int scrollRate )
91{
92 m_scrollRate->setValue( scrollRate );
93}