//**************************************************************************** //! \file tmainwindow.cpp //! \date 02-10-2004 //**************************************************************************** // This file is part of Weird Reader. // // The Weird Reader 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. // // The Weird Reader 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 Weird Reader; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA //**************************************************************************** #include "tmainwindow.hpp" //*************************************************************************** // TMainWindow methods //*************************************************************************** // public methods //*************************************************************************** //*************************************************************************** TMainWindow::TMainWindow( QWidget *parent, char const *name, WFlags f) : KMainWindow ( parent, name, f) //*************************************************************************** { // Setup of the Main Widget with all its components cF = new QFrame(this); setCentralWidget( cF); topLayout = new QVBoxLayout( cF, 5); // Textview and the Buttons tePage = new WTextHandler( cF); topLayout->addWidget( tePage); cUI = new WCommentUI( tePage, cF); buttonLayout = new QHBoxLayout( topLayout); pbBackward = new KPushButton( KGuiItem( "", QPixmap( "images/back"), "browse back one page"), cF); pbForward = new KPushButton( KGuiItem( "", QPixmap( "images/forward"), "browse forward one page"), cF); buttonLayout->addStretch(); buttonLayout->addWidget( pbBackward); buttonLayout->addWidget( pbForward); buttonLayout->addStretch(); // The Actions actions = new KActionCollection( cF); actions->setHighlightingEnabled( true); aFileOpen = KStdAction::open( this, SLOT( fileOpen()), actions); aFileOpen->setToolTip( "open new e-book"); aExit = KStdAction::close( this, SLOT( close()), actions); aExit->setToolTip( "Exit Program"); aEditFind = KStdAction::find( this, SLOT( editFind()), actions); aEditFind->setToolTip( "Find in text"); aEditCb = new KAction( "&Browse comments", "browsecom", KShortcut( "CTRL+b"), cUI, SLOT( browseComment()), actions, "Browse the Comments"); // aEditCb->setToolTip( "Browse the Comments"); aHelpAbout = KStdAction::aboutApp( this, SLOT( helpAbout()), actions); aHelpAbout->setToolTip( "About WReader"); // Menu Bar mainMenu = new KMenuBar( cF); pmFile = new KPopupMenu( mainMenu); aFileOpen->plug( pmFile); pmFile->insertSeparator(); aExit->plug( pmFile); pmEdit = new KPopupMenu( mainMenu); aEditFind->plug( pmEdit); aEditCb->plug( pmEdit); pmHelp = new KPopupMenu( mainMenu); aHelpAbout->plug( pmHelp); mainMenu->insertItem( "&File", pmFile); mainMenu->insertItem( "&Edit", pmEdit); mainMenu->insertSeparator(); mainMenu->insertItem( "&Help", pmHelp); topLayout->setMenuBar( mainMenu); // Status Bar statusBar = new TStatusBar( cF); QToolTipGroup *tipGroup = new QToolTipGroup( cF); topLayout->addWidget( statusBar); connect( tipGroup, SIGNAL( showTip( const QString&)), statusBar, SLOT( message( const QString&))); connect( tipGroup, SIGNAL( removeTip()), statusBar, SLOT( clear())); connect( pbBackward, SIGNAL( pressed()), statusBar, SLOT( progBackward())); connect( pbForward, SIGNAL( pressed()), statusBar, SLOT( progForward())); connect( actions, SIGNAL( actionHighlighted( KAction*, bool)), statusBar, SLOT( menuStatus( KAction*, bool))); //connect the stuff related to the text view connect( pbBackward, SIGNAL( pressed()), tePage, SLOT( pgUp())); connect( pbForward, SIGNAL( pressed()), tePage, SLOT( pgDown())); connect( tePage, SIGNAL( doubleClicked( int, int)), cUI, SLOT( insertComment( int, int))); // tooltips QToolTip::add( pbBackward, "browse back", tipGroup, "browse back one page"); QToolTip::add( pbForward, "browse forward", tipGroup, "browse forward one page"); // topLayout->activate(); } //*************************************************************************** // protected slots //*************************************************************************** //*************************************************************************** void TMainWindow::fileOpen() //*************************************************************************** { QString fname = KFileDialog::getOpenFileName( QString::null, "*.* text/plain", cF); if( fname != QString::null) { int pages = tePage->open( fname); statusBar->resetProgLength( pages); statusBar->proGoto( 0); } } //*************************************************************************** void TMainWindow::editFind() //*************************************************************************** { } //*************************************************************************** void TMainWindow::helpAbout() //*************************************************************************** { KMessageBox::about( this, "

Weird E-Book Reader

Version: 0.01

" "

by The Weird Birds Corp.

License: GPL2

" "

Chief of Development: T.H.E.

" "

The Great and Honorous ShiFu: H.T.D.

", "About WReader"); }