summaryrefslogtreecommitdiff
path: root/noncore/apps/dagger/mainwindow.cpp
Unidiff
Diffstat (limited to 'noncore/apps/dagger/mainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/dagger/mainwindow.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/noncore/apps/dagger/mainwindow.cpp b/noncore/apps/dagger/mainwindow.cpp
index ace8f36..b2e00e8 100644
--- a/noncore/apps/dagger/mainwindow.cpp
+++ b/noncore/apps/dagger/mainwindow.cpp
@@ -64,24 +64,27 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags /*fl*/ )
64 connect( &m_autoScrollTimer, SIGNAL(timeout()), this, SLOT(slotNavNextVerse()) ); 64 connect( &m_autoScrollTimer, SIGNAL(timeout()), this, SLOT(slotNavNextVerse()) );
65 65
66 m_bibleIcon = new QPixmap( Resource::loadPixmap( "dagger/bibletext" ) ); 66 m_bibleIcon = new QPixmap( Resource::loadPixmap( "dagger/bibletext" ) );
67 m_commentaryIcon = new QPixmap( Resource::loadPixmap( "dagger/commentary" ) ); 67 m_commentaryIcon = new QPixmap( Resource::loadPixmap( "dagger/commentary" ) );
68 m_lexiconIcon = new QPixmap( Resource::loadPixmap( "dagger/lexicon" ) ); 68 m_lexiconIcon = new QPixmap( Resource::loadPixmap( "dagger/lexicon" ) );
69 69
70 // Load initial configuration 70 // Load initial configuration
71 QTimer::singleShot( 100, this, SLOT( initConfig() ) ); 71 QTimer::singleShot( 100, this, SLOT( initConfig() ) );
72} 72}
73 73
74MainWindow::~MainWindow() 74MainWindow::~MainWindow()
75{ 75{
76 // Re-enable screen blanking if it was disabled
77 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
78
76 // Save Sword options 79 // Save Sword options
77 m_config.setGroup( "Sword" ); 80 m_config.setGroup( "Sword" );
78 m_config.writeEntry( "ModPath", m_modulePath ); 81 m_config.writeEntry( "ModPath", m_modulePath );
79 82
80 for ( QAction *a = m_actionSwordOpts.first(); a; a = m_actionSwordOpts.next() ) 83 for ( QAction *a = m_actionSwordOpts.first(); a; a = m_actionSwordOpts.next() )
81 m_config.writeEntry( a->text(), a->isOn() ); 84 m_config.writeEntry( a->text(), a->isOn() );
82 85
83 // Save configuration options 86 // Save configuration options
84 m_config.setGroup( "Config" ); 87 m_config.setGroup( "Config" );
85 m_config.writeEntry( "AlwaysOpenNew", m_alwaysOpenNew ); 88 m_config.writeEntry( "AlwaysOpenNew", m_alwaysOpenNew );
86 m_config.writeEntry( "AutoScroll", m_navToolbar->autoScrollRate() ); 89 m_config.writeEntry( "AutoScroll", m_navToolbar->autoScrollRate() );
87 m_config.writeEntry( "DisableScreenBlanking", m_disableScreenBlank ); 90 m_config.writeEntry( "DisableScreenBlanking", m_disableScreenBlank );
@@ -160,29 +163,29 @@ void MainWindow::initUI()
160 m_tabs.installEventFilter( this ); 163 m_tabs.installEventFilter( this );
161 164
162 setToolBarsMovable( false ); 165 setToolBarsMovable( false );
163 m_barDock = new QToolBar( this ); 166 m_barDock = new QToolBar( this );
164 m_barDock->setHorizontalStretchable( true ); 167 m_barDock->setHorizontalStretchable( true );
165 168
166 m_menuBar = new QMenuBar( m_barDock ); 169 m_menuBar = new QMenuBar( m_barDock );
167 m_menuBar->setMargin( 0 ); 170 m_menuBar->setMargin( 0 );
168 171
169 // Allocate toolbars 172 // Allocate toolbars
170 m_navToolbar = new NavBar( this ); 173 m_navToolbar = new NavBar( this );
171 m_navToolbar->navBtnsEnable( false ); 174 m_navToolbar->navBtnsEnable( false );
172 connect( m_navToolbar, SIGNAL(prevChapter()), this, SLOT(slotNavPrevChapter()) ); 175 connect( m_navToolbar, SIGNAL(prevPage()), this, SLOT(slotNavPrevPage()) );
173 connect( m_navToolbar, SIGNAL(prevVerse()), this, SLOT(slotNavPrevVerse()) ); 176 connect( m_navToolbar, SIGNAL(prevVerse()), this, SLOT(slotNavPrevVerse()) );
174 connect( m_navToolbar, SIGNAL(keyChanged(const QString &)), this, SLOT(slotNavKeyChanged(const QString &)) ); 177 connect( m_navToolbar, SIGNAL(keyChanged(const QString &)), this, SLOT(slotNavKeyChanged(const QString &)) );
175 connect( m_navToolbar, SIGNAL(nextVerse()), this, SLOT(slotNavNextVerse()) ); 178 connect( m_navToolbar, SIGNAL(nextVerse()), this, SLOT(slotNavNextVerse()) );
176 connect( m_navToolbar, SIGNAL(nextChapter()), this, SLOT(slotNavNextChapter()) ); 179 connect( m_navToolbar, SIGNAL(nextPage()), this, SLOT(slotNavNextPage()) );
177 connect( m_navToolbar, SIGNAL(autoScroll(bool)), this, SLOT(slotNavAutoScroll(bool)) ); 180 connect( m_navToolbar, SIGNAL(autoScroll(bool)), this, SLOT(slotNavAutoScroll(bool)) );
178 connect( m_navToolbar, SIGNAL(scrollRateChanged(int)), this, SLOT(slotNavScrollRateChanged(int)) ); 181 connect( m_navToolbar, SIGNAL(scrollRateChanged(int)), this, SLOT(slotNavScrollRateChanged(int)) );
179 182
180 m_searchToolbar = new SearchBar( this ); 183 m_searchToolbar = new SearchBar( this );
181 connect( m_searchToolbar, SIGNAL(sigResultClicked(const QString &)), this, SLOT(slotSearchResultClicked(const QString &)) ); 184 connect( m_searchToolbar, SIGNAL(sigResultClicked(const QString &)), this, SLOT(slotSearchResultClicked(const QString &)) );
182 185
183 // Text menu 186 // Text menu
184 QPopupMenu *popup = new QPopupMenu( this ); 187 QPopupMenu *popup = new QPopupMenu( this );
185 188
186 QAction *a = new QAction( tr( "Open..." ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); 189 QAction *a = new QAction( tr( "Open..." ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 );
187 connect( a, SIGNAL(activated()), this, SLOT(slotTextOpen()) ); 190 connect( a, SIGNAL(activated()), this, SLOT(slotTextOpen()) );
188 a->addTo( popup ); 191 a->addTo( popup );
@@ -323,25 +326,25 @@ int MainWindow::findBookmark( const QString &bookmark )
323 while ( ( id != -1 ) && ( m_bookmarkMenu->text( id ) != bookmark ) ) 326 while ( ( id != -1 ) && ( m_bookmarkMenu->text( id ) != bookmark ) )
324 { 327 {
325 ++index; 328 ++index;
326 id = m_bookmarkMenu->idAt( index ); 329 id = m_bookmarkMenu->idAt( index );
327 } 330 }
328 331
329 return id; 332 return id;
330} 333}
331 334
332void MainWindow::enableScreenBlanking( bool enable ) 335void MainWindow::enableScreenBlanking( bool enable )
333{ 336{
334 enable ? QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable 337 enable ? QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable
335 : QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable; 338 : QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::DisableSuspend;
336} 339}
337 340
338void MainWindow::initConfig() 341void MainWindow::initConfig()
339{ 342{
340 bool show; 343 bool show;
341 344
342 m_config.setGroup( "Sword" ); 345 m_config.setGroup( "Sword" );
343 for ( QAction *a = m_actionSwordOpts.first(); a; a = m_actionSwordOpts.next() ) 346 for ( QAction *a = m_actionSwordOpts.first(); a; a = m_actionSwordOpts.next() )
344 { 347 {
345 show = m_config.readBoolEntry( a->text(), false ); 348 show = m_config.readBoolEntry( a->text(), false );
346 a->setOn( show ); 349 a->setOn( show );
347 m_swordMgr->setGlobalOption ( a->text(), show ? "On" : "Off" ); 350 m_swordMgr->setGlobalOption ( a->text(), show ? "On" : "Off" );
@@ -588,30 +591,30 @@ void MainWindow::slotViewSwordOption( bool enabled )
588void MainWindow::slotViewNavToolbar( bool enabled ) 591void MainWindow::slotViewNavToolbar( bool enabled )
589{ 592{
590 enabled ? m_navToolbar->show() 593 enabled ? m_navToolbar->show()
591 : m_navToolbar->hide(); 594 : m_navToolbar->hide();
592} 595}
593 596
594void MainWindow::slotViewSearchToolbar( bool enabled ) 597void MainWindow::slotViewSearchToolbar( bool enabled )
595{ 598{
596 enabled ? m_searchToolbar->show() 599 enabled ? m_searchToolbar->show()
597 : m_searchToolbar->hide(); 600 : m_searchToolbar->hide();
598} 601}
599 602
600void MainWindow::slotNavPrevChapter() 603void MainWindow::slotNavPrevPage()
601{ 604{
602 TextWidget *text = reinterpret_cast<TextWidget *>(m_tabs.currentWidget()); 605 TextWidget *text = reinterpret_cast<TextWidget *>(m_tabs.currentWidget());
603 if ( text ) 606 if ( text )
604 { 607 {
605 text->prevChapter(); 608 text->prevPage();
606 setCaption( QString( "%1 - Dagger" ).arg( text->getFullKey() ) ); 609 setCaption( QString( "%1 - Dagger" ).arg( text->getFullKey() ) );
607 m_navToolbar->setKey( text->getAbbrevKey() ); 610 m_navToolbar->setKey( text->getAbbrevKey() );
608 } 611 }
609} 612}
610 613
611void MainWindow::slotNavPrevVerse() 614void MainWindow::slotNavPrevVerse()
612{ 615{
613 TextWidget *text = reinterpret_cast<TextWidget *>(m_tabs.currentWidget()); 616 TextWidget *text = reinterpret_cast<TextWidget *>(m_tabs.currentWidget());
614 if ( text ) 617 if ( text )
615 { 618 {
616 text->prevVerse(); 619 text->prevVerse();
617 setCaption( QString( "%1 - Dagger" ).arg( text->getFullKey() ) ); 620 setCaption( QString( "%1 - Dagger" ).arg( text->getFullKey() ) );
@@ -634,30 +637,30 @@ void MainWindow::slotNavKeyChanged( const QString &newKey )
634 637
635void MainWindow::slotNavNextVerse() 638void MainWindow::slotNavNextVerse()
636{ 639{
637 TextWidget *text = reinterpret_cast<TextWidget *>(m_tabs.currentWidget()); 640 TextWidget *text = reinterpret_cast<TextWidget *>(m_tabs.currentWidget());
638 if ( text ) 641 if ( text )
639 { 642 {
640 text->nextVerse(); 643 text->nextVerse();
641 setCaption( QString( "%1 - Dagger" ).arg( text->getFullKey() ) ); 644 setCaption( QString( "%1 - Dagger" ).arg( text->getFullKey() ) );
642 m_navToolbar->setKey( text->getAbbrevKey() ); 645 m_navToolbar->setKey( text->getAbbrevKey() );
643 } 646 }
644} 647}
645 648
646void MainWindow::slotNavNextChapter() 649void MainWindow::slotNavNextPage()
647{ 650{
648 TextWidget *text = reinterpret_cast<TextWidget *>(m_tabs.currentWidget()); 651 TextWidget *text = reinterpret_cast<TextWidget *>(m_tabs.currentWidget());
649 if ( text ) 652 if ( text )
650 { 653 {
651 text->nextChapter(); 654 text->nextPage();
652 setCaption( QString( "%1 - Dagger" ).arg( text->getFullKey() ) ); 655 setCaption( QString( "%1 - Dagger" ).arg( text->getFullKey() ) );
653 m_navToolbar->setKey( text->getAbbrevKey() ); 656 m_navToolbar->setKey( text->getAbbrevKey() );
654 } 657 }
655} 658}
656 659
657void MainWindow::slotNavAutoScroll( bool enabled ) 660void MainWindow::slotNavAutoScroll( bool enabled )
658{ 661{
659 m_autoScrollTimer.stop(); 662 m_autoScrollTimer.stop();
660 663
661 if ( enabled ) 664 if ( enabled )
662 m_autoScrollTimer.start( m_navToolbar->autoScrollRate() * 100 ); 665 m_autoScrollTimer.start( m_navToolbar->autoScrollRate() * 100 );
663} 666}