author | drw <drw> | 2005-04-24 19:29:20 (UTC) |
---|---|---|
committer | drw <drw> | 2005-04-24 19:29:20 (UTC) |
commit | 9f4dd8e0d2cbe83d23c5405394d5e076dd6c2c6b (patch) (unidiff) | |
tree | ef243e01fd5347d74d06e7d90e9c3fc19d990534 | |
parent | d1ca2bbae79743f9f8a2c5ac1d702cc1c789fd27 (diff) | |
download | opie-9f4dd8e0d2cbe83d23c5405394d5e076dd6c2c6b.zip opie-9f4dd8e0d2cbe83d23c5405394d5e076dd6c2c6b.tar.gz opie-9f4dd8e0d2cbe83d23c5405394d5e076dd6c2c6b.tar.bz2 |
Resource -> OResource
-rw-r--r-- | noncore/apps/dagger/mainwindow.cpp | 31 | ||||
-rw-r--r-- | noncore/apps/dagger/navbar.cpp | 14 | ||||
-rw-r--r-- | noncore/apps/dagger/searchbar.cpp | 9 |
3 files changed, 35 insertions, 19 deletions
diff --git a/noncore/apps/dagger/mainwindow.cpp b/noncore/apps/dagger/mainwindow.cpp index 3dd9eff..1f2d521 100644 --- a/noncore/apps/dagger/mainwindow.cpp +++ b/noncore/apps/dagger/mainwindow.cpp | |||
@@ -1,422 +1,431 @@ | |||
1 | /* | 1 | /* |
2 | Dagger - A Bible study program utilizing the Sword library. | 2 | Dagger - A Bible study program utilizing the Sword library. |
3 | Copyright (c) 2004 Dan Williams <drw@handhelds.org> | 3 | Copyright (c) 2004 Dan Williams <drw@handhelds.org> |
4 | 4 | ||
5 | This file is free software; you can redistribute it and/or modify it under | 5 | This file is free software; you can redistribute it and/or modify it under |
6 | the terms of the GNU General Public License as published by the Free Software | 6 | the terms of the GNU General Public License as published by the Free Software |
7 | Foundation; either version 2 of the License, or (at your option) any later version. | 7 | Foundation; either version 2 of the License, or (at your option) any later version. |
8 | 8 | ||
9 | This file is distributed in the hope that it will be useful, but WITHOUT ANY | 9 | This file is distributed in the hope that it will be useful, but WITHOUT ANY |
10 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A | 10 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
11 | PARTICULAR PURPOSE. See the GNU General Public License for more details. | 11 | PARTICULAR PURPOSE. See the GNU General Public License for more details. |
12 | 12 | ||
13 | You should have received a copy of the GNU General Public License along with this | 13 | You should have received a copy of the GNU General Public License along with this |
14 | file; see the file COPYING. If not, write to the Free Software Foundation, Inc., | 14 | file; see the file COPYING. If not, write to the Free Software Foundation, Inc., |
15 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 15 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
16 | */ | 16 | */ |
17 | 17 | ||
18 | #include "mainwindow.h" | 18 | #include "mainwindow.h" |
19 | #include "navbar.h" | 19 | #include "navbar.h" |
20 | #include "searchbar.h" | 20 | #include "searchbar.h" |
21 | #include "opentextdlg.h" | 21 | #include "opentextdlg.h" |
22 | #include "configuredlg.h" | 22 | #include "configuredlg.h" |
23 | #include "textwidget.h" | 23 | #include "textwidget.h" |
24 | 24 | ||
25 | #include <opie2/odebug.h> | 25 | #include <opie2/odebug.h> |
26 | #include <opie2/oresource.h> | ||
26 | 27 | ||
27 | #include <qpe/qcopenvelope_qws.h> | 28 | #include <qpe/qcopenvelope_qws.h> |
28 | #include <qpe/qpeapplication.h> | 29 | #include <qpe/qpeapplication.h> |
29 | #include <qpe/resource.h> | ||
30 | 30 | ||
31 | #include <qaction.h> | 31 | #include <qaction.h> |
32 | #include <qclipboard.h> | 32 | #include <qclipboard.h> |
33 | #include <qmenubar.h> | 33 | #include <qmenubar.h> |
34 | #include <qmessagebox.h> | 34 | #include <qmessagebox.h> |
35 | #include <qobjectlist.h> | 35 | #include <qobjectlist.h> |
36 | #include <qpopupmenu.h> | 36 | #include <qpopupmenu.h> |
37 | #include <qtimer.h> | 37 | #include <qtimer.h> |
38 | #include <qtoolbar.h> | 38 | #include <qtoolbar.h> |
39 | 39 | ||
40 | #include <markupfiltmgr.h> | 40 | #include <markupfiltmgr.h> |
41 | 41 | ||
42 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags /*fl*/ ) | 42 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags /*fl*/ ) |
43 | : QMainWindow( parent, name, WStyle_ContextHelp ) | 43 | : QMainWindow( parent, name, WStyle_ContextHelp ) |
44 | , m_config( "dagger" ) | 44 | , m_config( "dagger" ) |
45 | , m_tabs( this ) | 45 | , m_tabs( this ) |
46 | , m_autoScrollTimer( this ) | 46 | , m_autoScrollTimer( this ) |
47 | { | 47 | { |
48 | // Initialize sword library manager | 48 | // Initialize sword library manager |
49 | m_config.setGroup( "Sword" ); | 49 | m_config.setGroup( "Sword" ); |
50 | m_modulePath = m_config.readEntry( "ModPath", "/usr/local/share/sword" ); | 50 | m_modulePath = m_config.readEntry( "ModPath", "/usr/local/share/sword" ); |
51 | m_swordMgr = new sword::SWMgr( m_modulePath.latin1(), true, | 51 | m_swordMgr = new sword::SWMgr( m_modulePath.latin1(), true, |
52 | new sword::MarkupFilterMgr( sword::FMT_HTMLHREF ) ); | 52 | new sword::MarkupFilterMgr( sword::FMT_HTMLHREF ) ); |
53 | 53 | ||
54 | // Retrieve list of available Sword module options (e.g. footnotes, Strong's numbers, etc.) | 54 | // Retrieve list of available Sword module options (e.g. footnotes, Strong's numbers, etc.) |
55 | sword::StringList swordOpts = m_swordMgr->getGlobalOptions(); | 55 | sword::StringList swordOpts = m_swordMgr->getGlobalOptions(); |
56 | for ( sword::StringList::iterator it = swordOpts.begin(); it != swordOpts.end(); it++ ) | 56 | for ( sword::StringList::iterator it = swordOpts.begin(); it != swordOpts.end(); it++ ) |
57 | m_actionSwordOpts.append( new QAction( (*it).c_str(), QString::null, 0, this, 0 ) ); | 57 | m_actionSwordOpts.append( new QAction( (*it).c_str(), QString::null, 0, this, 0 ) ); |
58 | m_actionSwordOpts.sort(); | 58 | m_actionSwordOpts.sort(); |
59 | 59 | ||
60 | // Initialize user interface | 60 | // Initialize user interface |
61 | setCaption( tr( "Dagger" ) ); | 61 | setCaption( tr( "Dagger" ) ); |
62 | initUI(); | 62 | initUI(); |
63 | 63 | ||
64 | connect( &m_tabs, SIGNAL(currentChanged(QWidget *)), this, SLOT( slotTextDisplayed(QWidget *)) ); | 64 | connect( &m_tabs, SIGNAL(currentChanged(QWidget *)), this, SLOT( slotTextDisplayed(QWidget *)) ); |
65 | connect( &m_autoScrollTimer, SIGNAL(timeout()), this, SLOT(slotNavNextVerse()) ); | 65 | connect( &m_autoScrollTimer, SIGNAL(timeout()), this, SLOT(slotNavNextVerse()) ); |
66 | 66 | ||
67 | m_bibleIcon = new QPixmap( Resource::loadPixmap( "dagger/bibletext" ) ); | 67 | m_bibleIcon = new QPixmap( Opie::Core::OResource::loadPixmap( "dagger/bibletext", Opie::Core::OResource::SmallIcon ) ); |
68 | m_commentaryIcon = new QPixmap( Resource::loadPixmap( "dagger/commentary" ) ); | 68 | m_commentaryIcon = new QPixmap( Opie::Core::OResource::loadPixmap( "dagger/commentary", Opie::Core::OResource::SmallIcon ) ); |
69 | m_lexiconIcon = new QPixmap( Resource::loadPixmap( "dagger/lexicon" ) ); | 69 | m_lexiconIcon = new QPixmap( Opie::Core::OResource::loadPixmap( "dagger/lexicon", Opie::Core::OResource::SmallIcon ) ); |
70 | 70 | ||
71 | // Load initial configuration | 71 | // Load initial configuration |
72 | QTimer::singleShot( 100, this, SLOT( initConfig() ) ); | 72 | QTimer::singleShot( 100, this, SLOT( initConfig() ) ); |
73 | } | 73 | } |
74 | 74 | ||
75 | MainWindow::~MainWindow() | 75 | MainWindow::~MainWindow() |
76 | { | 76 | { |
77 | // Re-enable screen blanking if it was disabled | 77 | // Re-enable screen blanking if it was disabled |
78 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 78 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
79 | 79 | ||
80 | // Save Sword options | 80 | // Save Sword options |
81 | m_config.setGroup( "Sword" ); | 81 | m_config.setGroup( "Sword" ); |
82 | m_config.writeEntry( "ModPath", m_modulePath ); | 82 | m_config.writeEntry( "ModPath", m_modulePath ); |
83 | 83 | ||
84 | for ( QAction *a = m_actionSwordOpts.first(); a; a = m_actionSwordOpts.next() ) | 84 | for ( QAction *a = m_actionSwordOpts.first(); a; a = m_actionSwordOpts.next() ) |
85 | m_config.writeEntry( a->text(), a->isOn() ); | 85 | m_config.writeEntry( a->text(), a->isOn() ); |
86 | 86 | ||
87 | // Save configuration options | 87 | // Save configuration options |
88 | m_config.setGroup( "Config" ); | 88 | m_config.setGroup( "Config" ); |
89 | m_config.writeEntry( "AlwaysOpenNew", m_alwaysOpenNew ); | 89 | m_config.writeEntry( "AlwaysOpenNew", m_alwaysOpenNew ); |
90 | m_config.writeEntry( "AutoScroll", m_navToolbar->autoScrollRate() ); | 90 | m_config.writeEntry( "AutoScroll", m_navToolbar->autoScrollRate() ); |
91 | m_config.writeEntry( "DisableScreenBlanking", m_disableScreenBlank ); | 91 | m_config.writeEntry( "DisableScreenBlanking", m_disableScreenBlank ); |
92 | m_config.writeEntry( "CopyFormat", m_copyFormat ); | 92 | m_config.writeEntry( "CopyFormat", m_copyFormat ); |
93 | m_config.writeEntry( "NavBar", m_actionViewNavToolbar->isOn() ); | 93 | m_config.writeEntry( "NavBar", m_actionViewNavToolbar->isOn() ); |
94 | m_config.writeEntry( "NumVerses", m_numVerses ); | 94 | m_config.writeEntry( "NumVerses", m_numVerses ); |
95 | m_config.writeEntry( "SearchBar", m_actionViewSearchToolbar->isOn() ); | 95 | m_config.writeEntry( "SearchBar", m_actionViewSearchToolbar->isOn() ); |
96 | 96 | ||
97 | // Save text font | 97 | // Save text font |
98 | m_config.setGroup( "Font"); | 98 | m_config.setGroup( "Font"); |
99 | m_config.writeEntry( "Family", m_textFont.family() ); | 99 | m_config.writeEntry( "Family", m_textFont.family() ); |
100 | m_config.writeEntry( "Italic", m_textFont.italic() ); | 100 | m_config.writeEntry( "Italic", m_textFont.italic() ); |
101 | m_config.writeEntry( "Size", m_textFont.pointSize() ); | 101 | m_config.writeEntry( "Size", m_textFont.pointSize() ); |
102 | m_config.writeEntry( "Weight", m_textFont.weight() ); | 102 | m_config.writeEntry( "Weight", m_textFont.weight() ); |
103 | 103 | ||
104 | // Save bookmarks | 104 | // Save bookmarks |
105 | m_config.setGroup( "Bookmarks"); | 105 | m_config.setGroup( "Bookmarks"); |
106 | m_config.clearGroup(); | 106 | m_config.clearGroup(); |
107 | int index = 3; | 107 | int index = 3; |
108 | int id = m_bookmarkMenu->idAt( index ); | 108 | int id = m_bookmarkMenu->idAt( index ); |
109 | while ( id != -1 ) | 109 | while ( id != -1 ) |
110 | { | 110 | { |
111 | QString bookmark = m_bookmarkMenu->text( id ); | 111 | QString bookmark = m_bookmarkMenu->text( id ); |
112 | int pos = bookmark.find( " (" ); | 112 | int pos = bookmark.find( " (" ); |
113 | QString key = bookmark.left( pos ); | 113 | QString key = bookmark.left( pos ); |
114 | pos += 2; | 114 | pos += 2; |
115 | QString module = bookmark.mid( pos, bookmark.find( ")", pos ) - pos ); | 115 | QString module = bookmark.mid( pos, bookmark.find( ")", pos ) - pos ); |
116 | QString modkey; | 116 | QString modkey; |
117 | modkey.sprintf( "%s/%s", module.latin1(), key.latin1() ); | 117 | modkey.sprintf( "%s/%s", module.latin1(), key.latin1() ); |
118 | m_config.writeEntry( QString::number( index - 2 ), modkey ); | 118 | m_config.writeEntry( QString::number( index - 2 ), modkey ); |
119 | 119 | ||
120 | ++index; | 120 | ++index; |
121 | id = m_bookmarkMenu->idAt( index ); | 121 | id = m_bookmarkMenu->idAt( index ); |
122 | } | 122 | } |
123 | 123 | ||
124 | // Save opened modules | 124 | // Save opened modules |
125 | m_config.setGroup( "Session"); | 125 | m_config.setGroup( "Session"); |
126 | m_config.clearGroup(); | 126 | m_config.clearGroup(); |
127 | QObjectList *childlist = queryList( "TextWidget" ); | 127 | QObjectList *childlist = queryList( "TextWidget" ); |
128 | QObjectListIt it( *childlist ); | 128 | QObjectListIt it( *childlist ); |
129 | TextWidget *module; | 129 | TextWidget *module; |
130 | int count = 1; | 130 | int count = 1; |
131 | while ( ( module = reinterpret_cast<TextWidget *>(it.current()) ) != 0 ) | 131 | while ( ( module = reinterpret_cast<TextWidget *>(it.current()) ) != 0 ) |
132 | { | 132 | { |
133 | QString modkey; | 133 | QString modkey; |
134 | modkey.sprintf( "%s/%s", module->getModuleName().latin1(), module->getAbbrevKey().latin1() ); | 134 | modkey.sprintf( "%s/%s", module->getModuleName().latin1(), module->getAbbrevKey().latin1() ); |
135 | m_config.writeEntry( QString::number( count ), modkey ); | 135 | m_config.writeEntry( QString::number( count ), modkey ); |
136 | ++count; | 136 | ++count; |
137 | ++it; | 137 | ++it; |
138 | } | 138 | } |
139 | } | 139 | } |
140 | 140 | ||
141 | bool MainWindow::eventFilter( QObject *obj, QEvent *event ) | 141 | bool MainWindow::eventFilter( QObject *obj, QEvent *event ) |
142 | { | 142 | { |
143 | if ( event->type() == QEvent::KeyPress ) | 143 | if ( event->type() == QEvent::KeyPress ) |
144 | { | 144 | { |
145 | QKeyEvent *keyev = reinterpret_cast<QKeyEvent *>(event); | 145 | QKeyEvent *keyev = reinterpret_cast<QKeyEvent *>(event); |
146 | if ( keyev->key() == Key_Up ) | 146 | if ( keyev->key() == Key_Up ) |
147 | { | 147 | { |
148 | slotNavPrevVerse(); | 148 | slotNavPrevVerse(); |
149 | return true; | 149 | return true; |
150 | } | 150 | } |
151 | else if ( keyev->key() == Key_Down ) | 151 | else if ( keyev->key() == Key_Down ) |
152 | { | 152 | { |
153 | slotNavNextVerse(); | 153 | slotNavNextVerse(); |
154 | return true; | 154 | return true; |
155 | } | 155 | } |
156 | } | 156 | } |
157 | 157 | ||
158 | return QWidget::eventFilter( obj, event ); | 158 | return QWidget::eventFilter( obj, event ); |
159 | } | 159 | } |
160 | 160 | ||
161 | void MainWindow::initUI() | 161 | void MainWindow::initUI() |
162 | { | 162 | { |
163 | setCentralWidget( &m_tabs ); | 163 | setCentralWidget( &m_tabs ); |
164 | m_tabs.installEventFilter( this ); | 164 | m_tabs.installEventFilter( this ); |
165 | 165 | ||
166 | setToolBarsMovable( false ); | 166 | setToolBarsMovable( false ); |
167 | m_barDock = new QToolBar( this ); | 167 | m_barDock = new QToolBar( this ); |
168 | m_barDock->setHorizontalStretchable( true ); | 168 | m_barDock->setHorizontalStretchable( true ); |
169 | 169 | ||
170 | m_menuBar = new QMenuBar( m_barDock ); | 170 | m_menuBar = new QMenuBar( m_barDock ); |
171 | m_menuBar->setMargin( 0 ); | 171 | m_menuBar->setMargin( 0 ); |
172 | 172 | ||
173 | // Allocate toolbars | 173 | // Allocate toolbars |
174 | m_navToolbar = new NavBar( this ); | 174 | m_navToolbar = new NavBar( this ); |
175 | m_navToolbar->navBtnsEnable( false ); | 175 | m_navToolbar->navBtnsEnable( false ); |
176 | connect( m_navToolbar, SIGNAL(prevPage()), this, SLOT(slotNavPrevPage()) ); | 176 | connect( m_navToolbar, SIGNAL(prevPage()), this, SLOT(slotNavPrevPage()) ); |
177 | connect( m_navToolbar, SIGNAL(prevVerse()), this, SLOT(slotNavPrevVerse()) ); | 177 | connect( m_navToolbar, SIGNAL(prevVerse()), this, SLOT(slotNavPrevVerse()) ); |
178 | connect( m_navToolbar, SIGNAL(keyChanged(const QString &)), this, SLOT(slotNavKeyChanged(const QString &)) ); | 178 | connect( m_navToolbar, SIGNAL(keyChanged(const QString &)), this, SLOT(slotNavKeyChanged(const QString &)) ); |
179 | connect( m_navToolbar, SIGNAL(nextVerse()), this, SLOT(slotNavNextVerse()) ); | 179 | connect( m_navToolbar, SIGNAL(nextVerse()), this, SLOT(slotNavNextVerse()) ); |
180 | connect( m_navToolbar, SIGNAL(nextPage()), this, SLOT(slotNavNextPage()) ); | 180 | connect( m_navToolbar, SIGNAL(nextPage()), this, SLOT(slotNavNextPage()) ); |
181 | connect( m_navToolbar, SIGNAL(autoScroll(bool)), this, SLOT(slotNavAutoScroll(bool)) ); | 181 | connect( m_navToolbar, SIGNAL(autoScroll(bool)), this, SLOT(slotNavAutoScroll(bool)) ); |
182 | connect( m_navToolbar, SIGNAL(scrollRateChanged(int)), this, SLOT(slotNavScrollRateChanged(int)) ); | 182 | connect( m_navToolbar, SIGNAL(scrollRateChanged(int)), this, SLOT(slotNavScrollRateChanged(int)) ); |
183 | 183 | ||
184 | m_searchToolbar = new SearchBar( this ); | 184 | m_searchToolbar = new SearchBar( this ); |
185 | connect( m_searchToolbar, SIGNAL(sigResultClicked(const QString &)), this, SLOT(slotSearchResultClicked(const QString &)) ); | 185 | connect( m_searchToolbar, SIGNAL(sigResultClicked(const QString &)), this, SLOT(slotSearchResultClicked(const QString &)) ); |
186 | 186 | ||
187 | // Text menu | 187 | // Text menu |
188 | QPopupMenu *popup = new QPopupMenu( this ); | 188 | QPopupMenu *popup = new QPopupMenu( this ); |
189 | 189 | ||
190 | QAction *a = new QAction( tr( "Open..." ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); | 190 | QAction *a = new QAction( tr( "Open..." ), Opie::Core::OResource::loadPixmap( "fileopen", Opie::Core::OResource::SmallIcon ), |
191 | QString::null, 0, this, 0 ); | ||
191 | connect( a, SIGNAL(activated()), this, SLOT(slotTextOpen()) ); | 192 | connect( a, SIGNAL(activated()), this, SLOT(slotTextOpen()) ); |
192 | a->addTo( popup ); | 193 | a->addTo( popup ); |
193 | 194 | ||
194 | m_actionTextClose = new QAction( tr( "Close" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 195 | m_actionTextClose = new QAction( tr( "Close" ), Opie::Core::OResource::loadPixmap( "close", Opie::Core::OResource::SmallIcon ), |
196 | QString::null, 0, this, 0 ); | ||
195 | connect( m_actionTextClose, SIGNAL(activated()), this, SLOT(slotTextClose()) ); | 197 | connect( m_actionTextClose, SIGNAL(activated()), this, SLOT(slotTextClose()) ); |
196 | m_actionTextClose->addTo( popup ); | 198 | m_actionTextClose->addTo( popup ); |
197 | 199 | ||
198 | popup->insertSeparator(); | 200 | popup->insertSeparator(); |
199 | 201 | ||
200 | // TODO - need to implent | 202 | // TODO - need to implent |
201 | a = new QAction( tr( "Install..." ), Resource::loadPixmap( "install" ), QString::null, 0, this, 0 ); | 203 | a = new QAction( tr( "Install" ), Opie::Core::OResource::loadPixmap( "install", Opie::Core::OResource::SmallIcon ), |
204 | QString::null, 0, this, 0 ); | ||
202 | a->setEnabled( false ); | 205 | a->setEnabled( false ); |
203 | connect( a, SIGNAL(activated()), this, SLOT(slotTextInstall()) ); | 206 | connect( a, SIGNAL(activated()), this, SLOT(slotTextInstall()) ); |
204 | a->addTo( popup ); | 207 | a->addTo( popup ); |
205 | 208 | ||
206 | m_menuBar->insertItem( tr( "Text" ), popup ); | 209 | m_menuBar->insertItem( tr( "Text" ), popup ); |
207 | 210 | ||
208 | // Edit menu | 211 | // Edit menu |
209 | popup = new QPopupMenu( this ); | 212 | popup = new QPopupMenu( this ); |
210 | 213 | ||
211 | m_actionEditCopy = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), QString::null, 0, this, 0 ); | 214 | m_actionEditCopy = new QAction( tr( "Copy" ), Opie::Core::OResource::loadPixmap( "copy", Opie::Core::OResource::SmallIcon ), |
215 | QString::null, 0, this, 0 ); | ||
212 | connect( m_actionEditCopy, SIGNAL(activated()), this, SLOT(slotEditCopy()) ); | 216 | connect( m_actionEditCopy, SIGNAL(activated()), this, SLOT(slotEditCopy()) ); |
213 | m_actionEditCopy->addTo( popup ); | 217 | m_actionEditCopy->addTo( popup ); |
214 | 218 | ||
215 | popup->insertSeparator(); | 219 | popup->insertSeparator(); |
216 | 220 | ||
217 | a = new QAction( tr( "Configure..." ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 ); | 221 | a = new QAction( tr( "Configure" ), Opie::Core::OResource::loadPixmap( "SettingsIcon", Opie::Core::OResource::SmallIcon ), |
222 | QString::null, 0, this, 0 ); | ||
218 | connect( a, SIGNAL(activated()), this, SLOT(slotEditConfigure()) ); | 223 | connect( a, SIGNAL(activated()), this, SLOT(slotEditConfigure()) ); |
219 | a->addTo( popup ); | 224 | a->addTo( popup ); |
220 | 225 | ||
221 | m_menuBar->insertItem( tr( "Edit" ), popup ); | 226 | m_menuBar->insertItem( tr( "Edit" ), popup ); |
222 | 227 | ||
223 | // Bookmark menu | 228 | // Bookmark menu |
224 | m_bookmarkMenu = new QPopupMenu( this ); | 229 | m_bookmarkMenu = new QPopupMenu( this ); |
225 | 230 | ||
226 | m_actionBookmarkAdd = new QAction( tr( "Add" ), Resource::loadPixmap( "dagger/bookmarkadd" ), QString::null, 0, this, 0 ); | 231 | m_actionBookmarkAdd = new QAction( tr( "Add" ), |
232 | Opie::Core::OResource::loadPixmap( "dagger/bookmarkadd", Opie::Core::OResource::SmallIcon ), | ||
233 | QString::null, 0, this, 0 ); | ||
227 | connect( m_actionBookmarkAdd, SIGNAL(activated()), this, SLOT(slotBookmarkAdd()) ); | 234 | connect( m_actionBookmarkAdd, SIGNAL(activated()), this, SLOT(slotBookmarkAdd()) ); |
228 | m_actionBookmarkAdd->addTo( m_bookmarkMenu ); | 235 | m_actionBookmarkAdd->addTo( m_bookmarkMenu ); |
229 | 236 | ||
230 | m_actionBookmarkRemove = new QAction( tr( "Remove" ), Resource::loadPixmap( "dagger/bookmarkremove" ), QString::null, 0, this, 0 ); | 237 | m_actionBookmarkRemove = new QAction( tr( "Remove" ), |
238 | Opie::Core::OResource::loadPixmap( "dagger/bookmarkremove", Opie::Core::OResource::SmallIcon ), | ||
239 | QString::null, 0, this, 0 ); | ||
231 | connect( m_actionBookmarkRemove, SIGNAL(activated()), this, SLOT(slotBookmarkRemove()) ); | 240 | connect( m_actionBookmarkRemove, SIGNAL(activated()), this, SLOT(slotBookmarkRemove()) ); |
232 | m_actionBookmarkRemove->addTo( m_bookmarkMenu ); | 241 | m_actionBookmarkRemove->addTo( m_bookmarkMenu ); |
233 | 242 | ||
234 | m_bookmarkMenu->insertSeparator(); | 243 | m_bookmarkMenu->insertSeparator(); |
235 | 244 | ||
236 | m_menuBar->insertItem( tr( "Bookmark" ), m_bookmarkMenu ); | 245 | m_menuBar->insertItem( tr( "Bookmark" ), m_bookmarkMenu ); |
237 | 246 | ||
238 | // View menu | 247 | // View menu |
239 | popup = new QPopupMenu( this ); | 248 | popup = new QPopupMenu( this ); |
240 | 249 | ||
241 | // Retrieve list of available Sword module options (e.g. footnotes, Strong's numbers, etc.) | 250 | // Retrieve list of available Sword module options (e.g. footnotes, Strong's numbers, etc.) |
242 | for ( a = m_actionSwordOpts.first(); a; a = m_actionSwordOpts.next() ) | 251 | for ( a = m_actionSwordOpts.first(); a; a = m_actionSwordOpts.next() ) |
243 | { | 252 | { |
244 | a->setToggleAction( true ); | 253 | a->setToggleAction( true ); |
245 | connect( a, SIGNAL(toggled(bool)), this, SLOT(slotViewSwordOption(bool)) ); | 254 | connect( a, SIGNAL(toggled(bool)), this, SLOT(slotViewSwordOption(bool)) ); |
246 | a->addTo( popup ); | 255 | a->addTo( popup ); |
247 | } | 256 | } |
248 | 257 | ||
249 | popup->insertSeparator(); | 258 | popup->insertSeparator(); |
250 | 259 | ||
251 | m_actionViewNavToolbar = new QAction( tr( "Navigation toolbar" ), QString::null, 0, this, 0 ); | 260 | m_actionViewNavToolbar = new QAction( tr( "Navigation toolbar" ), QString::null, 0, this, 0 ); |
252 | m_actionViewNavToolbar->setToggleAction( true ); | 261 | m_actionViewNavToolbar->setToggleAction( true ); |
253 | connect( m_actionViewNavToolbar, SIGNAL(toggled(bool)), this, SLOT(slotViewNavToolbar(bool)) ); | 262 | connect( m_actionViewNavToolbar, SIGNAL(toggled(bool)), this, SLOT(slotViewNavToolbar(bool)) ); |
254 | m_actionViewNavToolbar->addTo( popup ); | 263 | m_actionViewNavToolbar->addTo( popup ); |
255 | 264 | ||
256 | m_actionViewSearchToolbar = new QAction( tr( "Search toolbar" ), QString::null, 0, this, 0 ); | 265 | m_actionViewSearchToolbar = new QAction( tr( "Search toolbar" ), QString::null, 0, this, 0 ); |
257 | m_actionViewSearchToolbar->setToggleAction( true ); | 266 | m_actionViewSearchToolbar->setToggleAction( true ); |
258 | connect( m_actionViewSearchToolbar, SIGNAL(toggled(bool)), this, SLOT(slotViewSearchToolbar(bool)) ); | 267 | connect( m_actionViewSearchToolbar, SIGNAL(toggled(bool)), this, SLOT(slotViewSearchToolbar(bool)) ); |
259 | m_actionViewSearchToolbar->addTo( popup ); | 268 | m_actionViewSearchToolbar->addTo( popup ); |
260 | 269 | ||
261 | m_menuBar->insertItem( tr( "View" ), popup ); | 270 | m_menuBar->insertItem( tr( "View" ), popup ); |
262 | } | 271 | } |
263 | 272 | ||
264 | void MainWindow::openModule( const QString &modulename, const QString &key ) | 273 | void MainWindow::openModule( const QString &modulename, const QString &key ) |
265 | { | 274 | { |
266 | sword::SWModule *module = m_swordMgr->Modules[ modulename.latin1() ]; | 275 | sword::SWModule *module = m_swordMgr->Modules[ modulename.latin1() ]; |
267 | if ( module ) | 276 | if ( module ) |
268 | { | 277 | { |
269 | TextWidget *tw = 0x0; | 278 | TextWidget *tw = 0x0; |
270 | 279 | ||
271 | if ( !m_alwaysOpenNew ) | 280 | if ( !m_alwaysOpenNew ) |
272 | { | 281 | { |
273 | // Try to find if the module is already opened, if so will use that TextWidget | 282 | // Try to find if the module is already opened, if so will use that TextWidget |
274 | QObjectList *childlist = queryList( "TextWidget" ); | 283 | QObjectList *childlist = queryList( "TextWidget" ); |
275 | QObjectListIt it( *childlist ); | 284 | QObjectListIt it( *childlist ); |
276 | while ( ( tw = reinterpret_cast<TextWidget *>(it.current()) ) != 0 && | 285 | while ( ( tw = reinterpret_cast<TextWidget *>(it.current()) ) != 0 && |
277 | tw->getModuleName() != modulename ) | 286 | tw->getModuleName() != modulename ) |
278 | ++it; | 287 | ++it; |
279 | if ( tw && tw->getModuleName() == modulename ) | 288 | if ( tw && tw->getModuleName() == modulename ) |
280 | { | 289 | { |
281 | // Set key if one is present | 290 | // Set key if one is present |
282 | if ( !key.isNull() ) | 291 | if ( !key.isNull() ) |
283 | tw->setKey( key ); | 292 | tw->setKey( key ); |
284 | 293 | ||
285 | // Raise tab | 294 | // Raise tab |
286 | m_tabs.setCurrentTab( tw ); | 295 | m_tabs.setCurrentTab( tw ); |
287 | } | 296 | } |
288 | } | 297 | } |
289 | 298 | ||
290 | if ( m_alwaysOpenNew || !tw ) | 299 | if ( m_alwaysOpenNew || !tw ) |
291 | { | 300 | { |
292 | // Open module in new tab | 301 | // Open module in new tab |
293 | QString icon; | 302 | QString icon; |
294 | QString type = module->Type(); | 303 | QString type = module->Type(); |
295 | 304 | ||
296 | if ( type == "Biblical Texts" ) | 305 | if ( type == "Biblical Texts" ) |
297 | icon = "dagger/bibletext"; | 306 | icon = "dagger/bibletext"; |
298 | else if ( type == "Commentaries" ) | 307 | else if ( type == "Commentaries" ) |
299 | icon = "dagger/commentary"; | 308 | icon = "dagger/commentary"; |
300 | else if ( type == "Lexicons / Dictionaries" ) | 309 | else if ( type == "Lexicons / Dictionaries" ) |
301 | icon = "dagger/lexicon"; | 310 | icon = "dagger/lexicon"; |
302 | 311 | ||
303 | tw = new TextWidget( this, module, m_numVerses, &m_textFont ); | 312 | tw = new TextWidget( this, module, m_numVerses, &m_textFont ); |
304 | connect( tw, SIGNAL(sigRefClicked(const QString &)), | 313 | connect( tw, SIGNAL(sigRefClicked(const QString &)), |
305 | this, SLOT(slotTextRefClicked(const QString &)) ); | 314 | this, SLOT(slotTextRefClicked(const QString &)) ); |
306 | connect( this, SIGNAL(sigNumVersesChanged(int)), tw, SLOT(slotNumVersesChanged(int)) ); | 315 | connect( this, SIGNAL(sigNumVersesChanged(int)), tw, SLOT(slotNumVersesChanged(int)) ); |
307 | connect( this, SIGNAL(sigFontChanged(const QFont *)), tw, SLOT(slotFontChanged(const QFont *)) ); | 316 | connect( this, SIGNAL(sigFontChanged(const QFont *)), tw, SLOT(slotFontChanged(const QFont *)) ); |
308 | connect( this, SIGNAL(sigOptionChanged()), tw, SLOT(slotOptionChanged()) ); | 317 | connect( this, SIGNAL(sigOptionChanged()), tw, SLOT(slotOptionChanged()) ); |
309 | 318 | ||
310 | m_tabs.addTab( tw, icon, modulename ); | 319 | m_tabs.addTab( tw, icon, modulename ); |
311 | 320 | ||
312 | m_actionTextClose->setEnabled( true ); | 321 | m_actionTextClose->setEnabled( true ); |
313 | m_actionEditCopy->setEnabled( true ); | 322 | m_actionEditCopy->setEnabled( true ); |
314 | m_actionBookmarkAdd->setEnabled( true ); | 323 | m_actionBookmarkAdd->setEnabled( true ); |
315 | 324 | ||
316 | // Set key if one is present | 325 | // Set key if one is present |
317 | if ( !key.isNull() ) | 326 | if ( !key.isNull() ) |
318 | tw->setKey( key ); | 327 | tw->setKey( key ); |
319 | } | 328 | } |
320 | } | 329 | } |
321 | } | 330 | } |
322 | 331 | ||
323 | int MainWindow::findBookmark( const QString &bookmark ) | 332 | int MainWindow::findBookmark( const QString &bookmark ) |
324 | { | 333 | { |
325 | int index = 3; | 334 | int index = 3; |
326 | int id = m_bookmarkMenu->idAt( index ); | 335 | int id = m_bookmarkMenu->idAt( index ); |
327 | while ( ( id != -1 ) && ( m_bookmarkMenu->text( id ) != bookmark ) ) | 336 | while ( ( id != -1 ) && ( m_bookmarkMenu->text( id ) != bookmark ) ) |
328 | { | 337 | { |
329 | ++index; | 338 | ++index; |
330 | id = m_bookmarkMenu->idAt( index ); | 339 | id = m_bookmarkMenu->idAt( index ); |
331 | } | 340 | } |
332 | 341 | ||
333 | return id; | 342 | return id; |
334 | } | 343 | } |
335 | 344 | ||
336 | void MainWindow::enableScreenBlanking( bool enable ) | 345 | void MainWindow::enableScreenBlanking( bool enable ) |
337 | { | 346 | { |
338 | enable ? QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable | 347 | enable ? QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable |
339 | : QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::DisableSuspend; | 348 | : QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::DisableSuspend; |
340 | } | 349 | } |
341 | 350 | ||
342 | void MainWindow::initConfig() | 351 | void MainWindow::initConfig() |
343 | { | 352 | { |
344 | bool show; | 353 | bool show; |
345 | 354 | ||
346 | m_config.setGroup( "Sword" ); | 355 | m_config.setGroup( "Sword" ); |
347 | for ( QAction *a = m_actionSwordOpts.first(); a; a = m_actionSwordOpts.next() ) | 356 | for ( QAction *a = m_actionSwordOpts.first(); a; a = m_actionSwordOpts.next() ) |
348 | { | 357 | { |
349 | show = m_config.readBoolEntry( a->text(), false ); | 358 | show = m_config.readBoolEntry( a->text(), false ); |
350 | a->setOn( show ); | 359 | a->setOn( show ); |
351 | m_swordMgr->setGlobalOption ( a->text(), show ? "On" : "Off" ); | 360 | m_swordMgr->setGlobalOption ( a->text(), show ? "On" : "Off" ); |
352 | } | 361 | } |
353 | 362 | ||
354 | // Display/hide toolbars based on last run | 363 | // Display/hide toolbars based on last run |
355 | m_config.setGroup( "Config" ); | 364 | m_config.setGroup( "Config" ); |
356 | 365 | ||
357 | m_alwaysOpenNew = m_config.readBoolEntry( "AlwaysOpenNew", false ); | 366 | m_alwaysOpenNew = m_config.readBoolEntry( "AlwaysOpenNew", false ); |
358 | m_navToolbar->setAutoScrollRate( m_config.readNumEntry( "AutoScroll", 50 ) ); | 367 | m_navToolbar->setAutoScrollRate( m_config.readNumEntry( "AutoScroll", 50 ) ); |
359 | m_disableScreenBlank = m_config.readBoolEntry( "DisableScreenBlanking", false ); | 368 | m_disableScreenBlank = m_config.readBoolEntry( "DisableScreenBlanking", false ); |
360 | enableScreenBlanking( !m_disableScreenBlank ); | 369 | enableScreenBlanking( !m_disableScreenBlank ); |
361 | m_copyFormat = m_config.readNumEntry( "CopyFormat", 0 ); | 370 | m_copyFormat = m_config.readNumEntry( "CopyFormat", 0 ); |
362 | 371 | ||
363 | show = m_config.readBoolEntry( "NavBar", false ); | 372 | show = m_config.readBoolEntry( "NavBar", false ); |
364 | m_actionViewNavToolbar->setOn( show ); | 373 | m_actionViewNavToolbar->setOn( show ); |
365 | slotViewNavToolbar( show ); | 374 | slotViewNavToolbar( show ); |
366 | 375 | ||
367 | m_numVerses = m_config.readNumEntry( "NumVerses", 5 ); | 376 | m_numVerses = m_config.readNumEntry( "NumVerses", 5 ); |
368 | 377 | ||
369 | show = m_config.readBoolEntry( "SearchBar", false ); | 378 | show = m_config.readBoolEntry( "SearchBar", false ); |
370 | m_actionViewSearchToolbar->setOn( show ); | 379 | m_actionViewSearchToolbar->setOn( show ); |
371 | slotViewSearchToolbar( show ); | 380 | slotViewSearchToolbar( show ); |
372 | 381 | ||
373 | // Set text font | 382 | // Set text font |
374 | m_config.setGroup( "Font" ); | 383 | m_config.setGroup( "Font" ); |
375 | QString fontFamily = m_config.readEntry( "Family", QString::null ); | 384 | QString fontFamily = m_config.readEntry( "Family", QString::null ); |
376 | !fontFamily.isNull() ? m_textFont = QFont( fontFamily, | 385 | !fontFamily.isNull() ? m_textFont = QFont( fontFamily, |
377 | m_config.readNumEntry( "Size", -1 ), | 386 | m_config.readNumEntry( "Size", -1 ), |
378 | m_config.readNumEntry( "Weight", QFont::Normal ), | 387 | m_config.readNumEntry( "Weight", QFont::Normal ), |
379 | m_config.readBoolEntry( "Italic", false ) ) | 388 | m_config.readBoolEntry( "Italic", false ) ) |
380 | : m_textFont = font(); // If font is not configured, set to default widget font | 389 | : m_textFont = font(); // If font is not configured, set to default widget font |
381 | 390 | ||
382 | // Load bookmarks | 391 | // Load bookmarks |
383 | m_config.setGroup( "Bookmarks"); | 392 | m_config.setGroup( "Bookmarks"); |
384 | int count = 1; | 393 | int count = 1; |
385 | QString key = m_config.readEntry( QString::number( count ), QString::null ); | 394 | QString key = m_config.readEntry( QString::number( count ), QString::null ); |
386 | while ( !key.isNull() ) | 395 | while ( !key.isNull() ) |
387 | { | 396 | { |
388 | int pos = key.find( "/" ); | 397 | int pos = key.find( "/" ); |
389 | if ( pos > -1 ) | 398 | if ( pos > -1 ) |
390 | { | 399 | { |
391 | QString bookmark; | 400 | QString bookmark; |
392 | bookmark.sprintf( "%s (%s)", key.right( key.length() - ( pos + 1 ) ).latin1(), | 401 | bookmark.sprintf( "%s (%s)", key.right( key.length() - ( pos + 1 ) ).latin1(), |
393 | key.left( pos ).latin1() ); | 402 | key.left( pos ).latin1() ); |
394 | QAction *a = new QAction( bookmark, QString::null, 0, this, 0 ); | 403 | QAction *a = new QAction( bookmark, QString::null, 0, this, 0 ); |
395 | a->addTo( m_bookmarkMenu ); | 404 | a->addTo( m_bookmarkMenu ); |
396 | connect( a, SIGNAL(activated()), this, SLOT(slotBookmarkSelected()) ); | 405 | connect( a, SIGNAL(activated()), this, SLOT(slotBookmarkSelected()) ); |
397 | } | 406 | } |
398 | 407 | ||
399 | ++count; | 408 | ++count; |
400 | key = m_config.readEntry( QString::number( count ), QString::null ); | 409 | key = m_config.readEntry( QString::number( count ), QString::null ); |
401 | } | 410 | } |
402 | m_actionBookmarkRemove->setEnabled( count > 1 ); | 411 | m_actionBookmarkRemove->setEnabled( count > 1 ); |
403 | 412 | ||
404 | // Load opened modules | 413 | // Load opened modules |
405 | m_config.setGroup( "Session"); | 414 | m_config.setGroup( "Session"); |
406 | QString first; | 415 | QString first; |
407 | count = 1; | 416 | count = 1; |
408 | key = m_config.readEntry( QString::number( count ), QString::null ); | 417 | key = m_config.readEntry( QString::number( count ), QString::null ); |
409 | while ( !key.isNull() ) | 418 | while ( !key.isNull() ) |
410 | { | 419 | { |
411 | int pos = key.find( "/" ); | 420 | int pos = key.find( "/" ); |
412 | if ( pos > -1 ) | 421 | if ( pos > -1 ) |
413 | { | 422 | { |
414 | if ( count == 1 ) | 423 | if ( count == 1 ) |
415 | first = key.left( pos ); | 424 | first = key.left( pos ); |
416 | openModule( key.left( pos ), key.right( key.length() - ( pos + 1 ) ) ); | 425 | openModule( key.left( pos ), key.right( key.length() - ( pos + 1 ) ) ); |
417 | } | 426 | } |
418 | 427 | ||
419 | ++count; | 428 | ++count; |
420 | key = m_config.readEntry( QString::number( count ), QString::null ); | 429 | key = m_config.readEntry( QString::number( count ), QString::null ); |
421 | } | 430 | } |
422 | m_tabs.setCurrentTab( first ); | 431 | m_tabs.setCurrentTab( first ); |
diff --git a/noncore/apps/dagger/navbar.cpp b/noncore/apps/dagger/navbar.cpp index 97761f7..ac49613 100644 --- a/noncore/apps/dagger/navbar.cpp +++ b/noncore/apps/dagger/navbar.cpp | |||
@@ -1,101 +1,105 @@ | |||
1 | /* | 1 | /* |
2 | Dagger - A Bible study program utilizing the Sword library. | 2 | Dagger - A Bible study program utilizing the Sword library. |
3 | Copyright (c) 2004 Dan Williams <drw@handhelds.org> | 3 | Copyright (c) 2004 Dan Williams <drw@handhelds.org> |
4 | 4 | ||
5 | This file is free software; you can redistribute it and/or modify it under | 5 | This file is free software; you can redistribute it and/or modify it under |
6 | the terms of the GNU General Public License as published by the Free Software | 6 | the terms of the GNU General Public License as published by the Free Software |
7 | Foundation; either version 2 of the License, or (at your option) any later version. | 7 | Foundation; either version 2 of the License, or (at your option) any later version. |
8 | 8 | ||
9 | This file is distributed in the hope that it will be useful, but WITHOUT ANY | 9 | This file is distributed in the hope that it will be useful, but WITHOUT ANY |
10 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A | 10 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
11 | PARTICULAR PURPOSE. See the GNU General Public License for more details. | 11 | PARTICULAR PURPOSE. See the GNU General Public License for more details. |
12 | 12 | ||
13 | You should have received a copy of the GNU General Public License along with this | 13 | You should have received a copy of the GNU General Public License along with this |
14 | file; see the file COPYING. If not, write to the Free Software Foundation, Inc., | 14 | file; see the file COPYING. If not, write to the Free Software Foundation, Inc., |
15 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 15 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
16 | */ | 16 | */ |
17 | 17 | ||
18 | #include "navbar.h" | 18 | #include "navbar.h" |
19 | 19 | ||
20 | #include <opie2/oresource.h> | ||
21 | |||
20 | #include <qpe/config.h> | 22 | #include <qpe/config.h> |
21 | #include <qpe/resource.h> | 23 | #include <qpe/resource.h> |
22 | 24 | ||
23 | #include <qaction.h> | 25 | #include <qaction.h> |
24 | #include <qlineedit.h> | 26 | #include <qlineedit.h> |
25 | #include <qwhatsthis.h> | 27 | #include <qwhatsthis.h> |
26 | 28 | ||
29 | using Opie::Core::OResource; | ||
30 | |||
27 | NavBar::NavBar( QMainWindow *parent ) | 31 | NavBar::NavBar( QMainWindow *parent ) |
28 | : QToolBar( QString::null, parent, QMainWindow::Top, true ) | 32 | : QToolBar( QString::null, parent, QMainWindow::Top, true ) |
29 | { | 33 | { |
30 | // Initialize UI | 34 | // Initialize UI |
31 | m_actionPrevPage = new QAction( tr( "Previous page" ), Resource::loadPixmap( "fastback" ), | 35 | m_actionPrevPage = new QAction( tr( "Previous page" ), OResource::loadPixmap( "fastback", OResource::SmallIcon ), |
32 | QString::null, 0, this, 0 ); | 36 | QString::null, 0, this, 0 ); |
33 | m_actionPrevPage->setWhatsThis( tr( "Tap here to scroll backward one page." ) ); | 37 | m_actionPrevPage->setWhatsThis( tr( "Tap here to scroll backward one page." ) ); |
34 | m_actionPrevPage->addTo( this ); | 38 | m_actionPrevPage->addTo( this ); |
35 | connect( m_actionPrevPage, SIGNAL(activated()), this, SIGNAL(prevPage()) ); | 39 | connect( m_actionPrevPage, SIGNAL(activated()), this, SIGNAL(prevPage()) ); |
36 | 40 | ||
37 | m_actionPrevVerse = new QAction( tr( "Previous verse" ), Resource::loadPixmap( "back" ), | 41 | m_actionPrevVerse = new QAction( tr( "Previous verse" ), OResource::loadPixmap( "back", OResource::SmallIcon ), |
38 | QString::null, 0, this, 0 ); | 42 | QString::null, 0, this, 0 ); |
39 | m_actionPrevVerse->setWhatsThis( tr( "Tap here to scroll backward one verse." ) ); | 43 | m_actionPrevVerse->setWhatsThis( tr( "Tap here to scroll backward one verse." ) ); |
40 | m_actionPrevVerse->addTo( this ); | 44 | m_actionPrevVerse->addTo( this ); |
41 | connect( m_actionPrevVerse, SIGNAL(activated()), this, SIGNAL(prevVerse()) ); | 45 | connect( m_actionPrevVerse, SIGNAL(activated()), this, SIGNAL(prevVerse()) ); |
42 | 46 | ||
43 | m_key = new QLineEdit( this ); | 47 | m_key = new QLineEdit( this ); |
44 | setStretchableWidget( m_key ); | 48 | setStretchableWidget( m_key ); |
45 | QWhatsThis::add( m_key, tr( "Enter location to display here." ) ); | 49 | QWhatsThis::add( m_key, tr( "Enter location to display here." ) ); |
46 | connect(m_key, SIGNAL(textChanged(const QString &)), this, SIGNAL(keyChanged(const QString &)) ); | 50 | connect(m_key, SIGNAL(textChanged(const QString &)), this, SIGNAL(keyChanged(const QString &)) ); |
47 | 51 | ||
48 | m_actionNextVerse = new QAction( tr( "Next verse" ), Resource::loadPixmap( "forward" ), | 52 | m_actionNextVerse = new QAction( tr( "Next verse" ), OResource::loadPixmap( "forward", OResource::SmallIcon ), |
49 | QString::null, 0, this, 0 ); | 53 | QString::null, 0, this, 0 ); |
50 | m_actionNextVerse->setWhatsThis( tr( "Tap here to scroll forward one verse." ) ); | 54 | m_actionNextVerse->setWhatsThis( tr( "Tap here to scroll forward one verse." ) ); |
51 | m_actionNextVerse->addTo( this ); | 55 | m_actionNextVerse->addTo( this ); |
52 | connect( m_actionNextVerse, SIGNAL(activated()), this, SIGNAL(nextVerse()) ); | 56 | connect( m_actionNextVerse, SIGNAL(activated()), this, SIGNAL(nextVerse()) ); |
53 | 57 | ||
54 | m_actionNextPage = new QAction( tr( "Next page" ), Resource::loadPixmap( "fastforward" ), | 58 | m_actionNextPage = new QAction( tr( "Next page" ), OResource::loadPixmap( "fastforward", OResource::SmallIcon ), |
55 | QString::null, 0, this, 0 ); | 59 | QString::null, 0, this, 0 ); |
56 | m_actionNextPage->setWhatsThis( tr( "Tap here to scroll forward one page." ) ); | 60 | m_actionNextPage->setWhatsThis( tr( "Tap here to scroll forward one page." ) ); |
57 | m_actionNextPage->addTo( this ); | 61 | m_actionNextPage->addTo( this ); |
58 | connect( m_actionNextPage, SIGNAL(activated()), this, SIGNAL(nextPage()) ); | 62 | connect( m_actionNextPage, SIGNAL(activated()), this, SIGNAL(nextPage()) ); |
59 | 63 | ||
60 | addSeparator(); | 64 | addSeparator(); |
61 | 65 | ||
62 | m_scrollRate = new QSpinBox( 1, 100, 1, this ); | 66 | m_scrollRate = new QSpinBox( 1, 100, 1, this ); |
63 | m_scrollRate->setMinimumWidth( 35 ); | 67 | m_scrollRate->setMinimumWidth( 35 ); |
64 | QWhatsThis::add( m_scrollRate, tr( "Adjust auto-scroll rate here. A larger value represents a slower scrolling rate." ) ); | 68 | QWhatsThis::add( m_scrollRate, tr( "Adjust auto-scroll rate here. A larger value represents a slower scrolling rate." ) ); |
65 | connect( m_scrollRate, SIGNAL(valueChanged(int)), this, SIGNAL(scrollRateChanged(int)) ); | 69 | connect( m_scrollRate, SIGNAL(valueChanged(int)), this, SIGNAL(scrollRateChanged(int)) ); |
66 | 70 | ||
67 | m_actionScroll = new QAction( tr( "Auto-scroll" ), Resource::loadPixmap( "dagger/autoscroll" ), | 71 | m_actionScroll = new QAction( tr( "Auto-scroll" ), OResource::loadPixmap( "dagger/autoscroll", OResource::SmallIcon ), |
68 | QString::null, 0, this, 0 ); | 72 | QString::null, 0, this, 0 ); |
69 | m_actionScroll->setToggleAction( true ); | 73 | m_actionScroll->setToggleAction( true ); |
70 | m_actionScroll->setWhatsThis( tr( "Tap here to start or stop auto-scrolling." ) ); | 74 | m_actionScroll->setWhatsThis( tr( "Tap here to start or stop auto-scrolling." ) ); |
71 | connect( m_actionScroll, SIGNAL(toggled(bool)), this, SIGNAL(autoScroll(bool)) ); | 75 | connect( m_actionScroll, SIGNAL(toggled(bool)), this, SIGNAL(autoScroll(bool)) ); |
72 | m_actionScroll->addTo( this ); | 76 | m_actionScroll->addTo( this ); |
73 | 77 | ||
74 | if ( parent ) | 78 | if ( parent ) |
75 | { | 79 | { |
76 | installEventFilter( parent ); | 80 | installEventFilter( parent ); |
77 | m_key->installEventFilter( parent ); | 81 | m_key->installEventFilter( parent ); |
78 | } | 82 | } |
79 | } | 83 | } |
80 | 84 | ||
81 | void NavBar::navBtnsEnable( bool enabled ) | 85 | void NavBar::navBtnsEnable( bool enabled ) |
82 | { | 86 | { |
83 | m_actionPrevPage->setEnabled( enabled ); | 87 | m_actionPrevPage->setEnabled( enabled ); |
84 | m_actionPrevVerse->setEnabled( enabled ); | 88 | m_actionPrevVerse->setEnabled( enabled ); |
85 | m_actionNextVerse->setEnabled( enabled ); | 89 | m_actionNextVerse->setEnabled( enabled ); |
86 | m_actionNextPage->setEnabled( enabled ); | 90 | m_actionNextPage->setEnabled( enabled ); |
87 | m_scrollRate->setEnabled( enabled ); | 91 | m_scrollRate->setEnabled( enabled ); |
88 | m_actionScroll->setEnabled( enabled ); | 92 | m_actionScroll->setEnabled( enabled ); |
89 | } | 93 | } |
90 | 94 | ||
91 | void NavBar::setKey( const QString &newKey ) | 95 | void NavBar::setKey( const QString &newKey ) |
92 | { | 96 | { |
93 | disconnect( m_key, SIGNAL(textChanged(const QString &)), 0, 0 ); | 97 | disconnect( m_key, SIGNAL(textChanged(const QString &)), 0, 0 ); |
94 | m_key->setText( newKey ); | 98 | m_key->setText( newKey ); |
95 | connect(m_key, SIGNAL(textChanged(const QString &)), this, SIGNAL(keyChanged(const QString &)) ); | 99 | connect(m_key, SIGNAL(textChanged(const QString &)), this, SIGNAL(keyChanged(const QString &)) ); |
96 | } | 100 | } |
97 | 101 | ||
98 | void NavBar::setAutoScrollRate( int scrollRate ) | 102 | void NavBar::setAutoScrollRate( int scrollRate ) |
99 | { | 103 | { |
100 | m_scrollRate->setValue( scrollRate ); | 104 | m_scrollRate->setValue( scrollRate ); |
101 | } | 105 | } |
diff --git a/noncore/apps/dagger/searchbar.cpp b/noncore/apps/dagger/searchbar.cpp index 9953e8f..b794bfd 100644 --- a/noncore/apps/dagger/searchbar.cpp +++ b/noncore/apps/dagger/searchbar.cpp | |||
@@ -1,179 +1,182 @@ | |||
1 | /* | 1 | /* |
2 | Dagger - A Bible study program utilizing the Sword library. | 2 | Dagger - A Bible study program utilizing the Sword library. |
3 | Copyright (c) 2004 Dan Williams <drw@handhelds.org> | 3 | Copyright (c) 2004 Dan Williams <drw@handhelds.org> |
4 | 4 | ||
5 | This file is free software; you can redistribute it and/or modify it under | 5 | This file is free software; you can redistribute it and/or modify it under |
6 | the terms of the GNU General Public License as published by the Free Software | 6 | the terms of the GNU General Public License as published by the Free Software |
7 | Foundation; either version 2 of the License, or (at your option) any later version. | 7 | Foundation; either version 2 of the License, or (at your option) any later version. |
8 | 8 | ||
9 | This file is distributed in the hope that it will be useful, but WITHOUT ANY | 9 | This file is distributed in the hope that it will be useful, but WITHOUT ANY |
10 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A | 10 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
11 | PARTICULAR PURPOSE. See the GNU General Public License for more details. | 11 | PARTICULAR PURPOSE. See the GNU General Public License for more details. |
12 | 12 | ||
13 | You should have received a copy of the GNU General Public License along with this | 13 | You should have received a copy of the GNU General Public License along with this |
14 | file; see the file COPYING. If not, write to the Free Software Foundation, Inc., | 14 | file; see the file COPYING. If not, write to the Free Software Foundation, Inc., |
15 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 15 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
16 | */ | 16 | */ |
17 | 17 | ||
18 | #include "searchbar.h" | 18 | #include "searchbar.h" |
19 | #include "textwidget.h" | 19 | #include "textwidget.h" |
20 | 20 | ||
21 | #include <opie2/oresource.h> | ||
21 | #include <opie2/owait.h> | 22 | #include <opie2/owait.h> |
22 | 23 | ||
23 | #include <qpe/qpeapplication.h> | 24 | #include <qpe/qpeapplication.h> |
24 | #include <qpe/resource.h> | 25 | #include <qpe/resource.h> |
25 | 26 | ||
26 | #include <qaction.h> | 27 | #include <qaction.h> |
27 | #include <qcombobox.h> | 28 | #include <qcombobox.h> |
28 | #include <qlineedit.h> | 29 | #include <qlineedit.h> |
29 | #include <qwhatsthis.h> | 30 | #include <qwhatsthis.h> |
30 | 31 | ||
31 | #include <listkey.h> | 32 | #include <listkey.h> |
32 | #include <regex.h> | 33 | #include <regex.h> |
33 | #include <versekey.h> | 34 | #include <versekey.h> |
34 | 35 | ||
36 | using Opie::Core::OResource; | ||
37 | |||
35 | void searchCallback( char /*percent*/, void */*userData*/ ) | 38 | void searchCallback( char /*percent*/, void */*userData*/ ) |
36 | { | 39 | { |
37 | qApp->processEvents(); | 40 | qApp->processEvents(); |
38 | } | 41 | } |
39 | 42 | ||
40 | SearchBar::SearchBar( QMainWindow *parent ) | 43 | SearchBar::SearchBar( QMainWindow *parent ) |
41 | : QToolBar( QString::null, parent, QMainWindow::Top, true ) | 44 | : QToolBar( QString::null, parent, QMainWindow::Top, true ) |
42 | , m_currText( 0x0 ) | 45 | , m_currText( 0x0 ) |
43 | { | 46 | { |
44 | // Initialize UI | 47 | // Initialize UI |
45 | m_searchText = new QLineEdit( this ); | 48 | m_searchText = new QLineEdit( this ); |
46 | setStretchableWidget( m_searchText ); | 49 | setStretchableWidget( m_searchText ); |
47 | QWhatsThis::add( m_searchText, tr( "Enter text to search for here." ) ); | 50 | QWhatsThis::add( m_searchText, tr( "Enter text to search for here." ) ); |
48 | connect(m_searchText, SIGNAL(textChanged(const QString &)), | 51 | connect(m_searchText, SIGNAL(textChanged(const QString &)), |
49 | this, SLOT(slotTextChanged(const QString &)) ); | 52 | this, SLOT(slotTextChanged(const QString &)) ); |
50 | 53 | ||
51 | m_actionFind = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), QString::null, | 54 | m_actionFind = new QAction( tr( "Find" ), OResource::loadPixmap( "find", OResource::SmallIcon ), QString::null, |
52 | 0, this, 0 ); | 55 | 0, this, 0 ); |
53 | m_actionFind->setEnabled( false ); | 56 | m_actionFind->setEnabled( false ); |
54 | m_actionFind->addTo( this ); | 57 | m_actionFind->addTo( this ); |
55 | m_actionFind->setWhatsThis( tr( "Tap here search the current module for the text entered to the left." ) ); | 58 | m_actionFind->setWhatsThis( tr( "Tap here search the current module for the text entered to the left." ) ); |
56 | connect( m_actionFind, SIGNAL(activated()), this, SLOT(slotFind()) ); | 59 | connect( m_actionFind, SIGNAL(activated()), this, SLOT(slotFind()) ); |
57 | 60 | ||
58 | addSeparator(); | 61 | addSeparator(); |
59 | 62 | ||
60 | m_actionPrev = new QAction( tr( "Previous result" ), Resource::loadPixmap( "back" ), | 63 | m_actionPrev = new QAction( tr( "Previous result" ), OResource::loadPixmap( "back", OResource::SmallIcon ), |
61 | QString::null, 0, this, 0 ); | 64 | QString::null, 0, this, 0 ); |
62 | m_actionPrev->setEnabled( false ); | 65 | m_actionPrev->setEnabled( false ); |
63 | m_actionPrev->addTo( this ); | 66 | m_actionPrev->addTo( this ); |
64 | m_actionPrev->setWhatsThis( tr( "Tap here to view the previous search result." ) ); | 67 | m_actionPrev->setWhatsThis( tr( "Tap here to view the previous search result." ) ); |
65 | connect( m_actionPrev, SIGNAL(activated()), this, SLOT(slotPrev()) ); | 68 | connect( m_actionPrev, SIGNAL(activated()), this, SLOT(slotPrev()) ); |
66 | 69 | ||
67 | m_resultList = new QComboBox( this ); | 70 | m_resultList = new QComboBox( this ); |
68 | m_resultList->setEnabled( false ); | 71 | m_resultList->setEnabled( false ); |
69 | QWhatsThis::add( m_resultList, tr( "Select the desired search result here." ) ); | 72 | QWhatsThis::add( m_resultList, tr( "Select the desired search result here." ) ); |
70 | connect( m_resultList, SIGNAL(activated(const QString &)), this, SIGNAL(sigResultClicked(const QString &)) ); | 73 | connect( m_resultList, SIGNAL(activated(const QString &)), this, SIGNAL(sigResultClicked(const QString &)) ); |
71 | 74 | ||
72 | m_actionNext = new QAction( tr( "Next result" ), Resource::loadPixmap( "forward" ), | 75 | m_actionNext = new QAction( tr( "Next result" ), OResource::loadPixmap( "forward", OResource::SmallIcon ), |
73 | QString::null, 0, this, 0 ); | 76 | QString::null, 0, this, 0 ); |
74 | m_actionNext->setEnabled( false ); | 77 | m_actionNext->setEnabled( false ); |
75 | m_actionNext->addTo( this ); | 78 | m_actionNext->addTo( this ); |
76 | m_actionNext->setWhatsThis( tr( "Tap here to view the next search result." ) ); | 79 | m_actionNext->setWhatsThis( tr( "Tap here to view the next search result." ) ); |
77 | connect( m_actionNext, SIGNAL(activated()), this, SLOT(slotNext()) ); | 80 | connect( m_actionNext, SIGNAL(activated()), this, SLOT(slotNext()) ); |
78 | 81 | ||
79 | if ( parent ) | 82 | if ( parent ) |
80 | { | 83 | { |
81 | installEventFilter( parent ); | 84 | installEventFilter( parent ); |
82 | // TODO - install for all controls | 85 | // TODO - install for all controls |
83 | m_searchText->installEventFilter( parent ); | 86 | m_searchText->installEventFilter( parent ); |
84 | } | 87 | } |
85 | } | 88 | } |
86 | 89 | ||
87 | void SearchBar::setCurrModule( TextWidget *currText ) | 90 | void SearchBar::setCurrModule( TextWidget *currText ) |
88 | { | 91 | { |
89 | m_actionFind->setEnabled( ( m_searchText->text() != "" ) && currText ); | 92 | m_actionFind->setEnabled( ( m_searchText->text() != "" ) && currText ); |
90 | 93 | ||
91 | if ( !m_currText || ( currText->getModuleName() != m_currText->getModuleName() ) ) | 94 | if ( !m_currText || ( currText->getModuleName() != m_currText->getModuleName() ) ) |
92 | { | 95 | { |
93 | m_actionPrev->setEnabled( false ); | 96 | m_actionPrev->setEnabled( false ); |
94 | m_resultList->clear(); | 97 | m_resultList->clear(); |
95 | m_resultList->setEnabled( false ); | 98 | m_resultList->setEnabled( false ); |
96 | m_actionNext->setEnabled( false ); | 99 | m_actionNext->setEnabled( false ); |
97 | } | 100 | } |
98 | 101 | ||
99 | m_currText = currText; | 102 | m_currText = currText; |
100 | } | 103 | } |
101 | 104 | ||
102 | void SearchBar::slotTextChanged( const QString &newText ) | 105 | void SearchBar::slotTextChanged( const QString &newText ) |
103 | { | 106 | { |
104 | m_actionFind->setEnabled( ( newText != "" ) && m_currText ); | 107 | m_actionFind->setEnabled( ( newText != "" ) && m_currText ); |
105 | } | 108 | } |
106 | 109 | ||
107 | void SearchBar::slotFind() | 110 | void SearchBar::slotFind() |
108 | { | 111 | { |
109 | m_resultList->clear(); | 112 | m_resultList->clear(); |
110 | 113 | ||
111 | // Change application title and display Opie wait dialog to indicate search is beginning | 114 | // Change application title and display Opie wait dialog to indicate search is beginning |
112 | QWidget *pWidget = reinterpret_cast<QWidget *>(parent()); | 115 | QWidget *pWidget = reinterpret_cast<QWidget *>(parent()); |
113 | QString caption = pWidget->caption(); | 116 | QString caption = pWidget->caption(); |
114 | pWidget->setCaption( "Searching..." ); | 117 | pWidget->setCaption( "Searching..." ); |
115 | 118 | ||
116 | Opie::Ui::OWait wait( pWidget ); | 119 | Opie::Ui::OWait wait( pWidget ); |
117 | wait.show(); | 120 | wait.show(); |
118 | qApp->processEvents(); | 121 | qApp->processEvents(); |
119 | 122 | ||
120 | // Perform search | 123 | // Perform search |
121 | // TODO - implement search callback function to animate wait cursor | 124 | // TODO - implement search callback function to animate wait cursor |
122 | sword::ListKey results = m_currText->getModule()->Search( m_searchText->text().latin1(), 0, REG_ICASE, 0, 0, | 125 | sword::ListKey results = m_currText->getModule()->Search( m_searchText->text().latin1(), 0, REG_ICASE, 0, 0, |
123 | &searchCallback ); | 126 | &searchCallback ); |
124 | 127 | ||
125 | // Process results | 128 | // Process results |
126 | int count = results.Count(); | 129 | int count = results.Count(); |
127 | bool found = count > 0; | 130 | bool found = count > 0; |
128 | if ( found ) | 131 | if ( found ) |
129 | { | 132 | { |
130 | // Populate results combo box | 133 | // Populate results combo box |
131 | sword::VerseKey key; | 134 | sword::VerseKey key; |
132 | for ( int i = 0; i < count; i++ ) | 135 | for ( int i = 0; i < count; i++ ) |
133 | { | 136 | { |
134 | key.setText( results.GetElement( i )->getText() ); | 137 | key.setText( results.GetElement( i )->getText() ); |
135 | m_resultList->insertItem( key.getShortText() ); | 138 | m_resultList->insertItem( key.getShortText() ); |
136 | } | 139 | } |
137 | 140 | ||
138 | // Goto first result in list | 141 | // Goto first result in list |
139 | m_resultList->setCurrentItem( 0 ); | 142 | m_resultList->setCurrentItem( 0 ); |
140 | emit sigResultClicked( m_resultList->currentText() ); | 143 | emit sigResultClicked( m_resultList->currentText() ); |
141 | } | 144 | } |
142 | else | 145 | else |
143 | { | 146 | { |
144 | // Reset application title | 147 | // Reset application title |
145 | pWidget->setCaption( caption ); | 148 | pWidget->setCaption( caption ); |
146 | } | 149 | } |
147 | 150 | ||
148 | // UI clean-up | 151 | // UI clean-up |
149 | wait.hide(); | 152 | wait.hide(); |
150 | 153 | ||
151 | m_actionPrev->setEnabled( false ); | 154 | m_actionPrev->setEnabled( false ); |
152 | m_resultList->setEnabled( found ); | 155 | m_resultList->setEnabled( found ); |
153 | m_actionNext->setEnabled( count > 1 ); | 156 | m_actionNext->setEnabled( count > 1 ); |
154 | } | 157 | } |
155 | 158 | ||
156 | void SearchBar::slotPrev() | 159 | void SearchBar::slotPrev() |
157 | { | 160 | { |
158 | int item = m_resultList->currentItem() - 1; | 161 | int item = m_resultList->currentItem() - 1; |
159 | m_resultList->setCurrentItem( item ); | 162 | m_resultList->setCurrentItem( item ); |
160 | emit sigResultClicked( m_resultList->currentText() ); | 163 | emit sigResultClicked( m_resultList->currentText() ); |
161 | 164 | ||
162 | m_actionPrev->setEnabled( item > 0 ); | 165 | m_actionPrev->setEnabled( item > 0 ); |
163 | m_actionNext->setEnabled( item < m_resultList->count() - 1 ); | 166 | m_actionNext->setEnabled( item < m_resultList->count() - 1 ); |
164 | } | 167 | } |
165 | 168 | ||
166 | void SearchBar::slotNext() | 169 | void SearchBar::slotNext() |
167 | { | 170 | { |
168 | int item = m_resultList->currentItem() + 1; | 171 | int item = m_resultList->currentItem() + 1; |
169 | m_resultList->setCurrentItem( item ); | 172 | m_resultList->setCurrentItem( item ); |
170 | emit sigResultClicked( m_resultList->currentText() ); | 173 | emit sigResultClicked( m_resultList->currentText() ); |
171 | 174 | ||
172 | m_actionPrev->setEnabled( true ); | 175 | m_actionPrev->setEnabled( true ); |
173 | m_actionNext->setEnabled( item < m_resultList->count() - 1 ); | 176 | m_actionNext->setEnabled( item < m_resultList->count() - 1 ); |
174 | } | 177 | } |
175 | 178 | ||
176 | void SearchBar::slotCloseBtn() | 179 | void SearchBar::slotCloseBtn() |
177 | { | 180 | { |
178 | hide(); | 181 | hide(); |
179 | } | 182 | } |