2004-08-26 21:17:24 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* Copyright (C) 2002 by Wilco Greven <greven@kde.org> *
|
|
|
|
* Copyright (C) 2002 by Chris Cheney <ccheney@cheney.cx> *
|
|
|
|
* Copyright (C) 2003 by Benjamin Meyer <benjamin@csh.rit.edu> *
|
|
|
|
* Copyright (C) 2003-2004 by Christophe Devriese *
|
|
|
|
* <Christophe.Devriese@student.kuleuven.ac.be> *
|
|
|
|
* Copyright (C) 2003 by Laurent Montel <montel@kde.org> *
|
|
|
|
* Copyright (C) 2003-2004 by Albert Astals Cid <tsdgeos@terra.es> *
|
|
|
|
* Copyright (C) 2003 by Luboš Luňák <l.lunak@kde.org> *
|
|
|
|
* Copyright (C) 2003 by Malcolm Hunter <malcolm.hunter@gmx.co.uk> *
|
|
|
|
* Copyright (C) 2004 by Dominique Devriese <devriese@kde.org> *
|
|
|
|
* Copyright (C) 2004 by Dirk Mueller <mueller@kde.org> *
|
|
|
|
* *
|
|
|
|
* This program 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. *
|
|
|
|
***************************************************************************/
|
2004-01-15 05:42:12 +00:00
|
|
|
|
2005-01-02 14:29:37 +00:00
|
|
|
// qt/kde includes
|
|
|
|
#include <qcursor.h>
|
2005-06-24 16:43:45 +00:00
|
|
|
#include <qtimer.h>
|
2002-09-02 21:56:00 +00:00
|
|
|
#include <kaction.h>
|
2004-09-04 22:52:25 +00:00
|
|
|
#include <kapplication.h>
|
2004-11-25 22:27:01 +00:00
|
|
|
#include <kedittoolbar.h>
|
2002-09-02 21:56:00 +00:00
|
|
|
#include <kfiledialog.h>
|
2002-09-02 20:21:47 +00:00
|
|
|
#include <klibloader.h>
|
|
|
|
#include <kmessagebox.h>
|
2006-12-19 12:23:43 +00:00
|
|
|
#include <kstandardaction.h>
|
2006-03-21 20:03:08 +00:00
|
|
|
#include <ktoolbar.h>
|
2002-09-02 21:56:00 +00:00
|
|
|
#include <kurl.h>
|
2003-09-14 19:04:36 +00:00
|
|
|
#include <kdebug.h>
|
2003-09-14 20:23:01 +00:00
|
|
|
#include <klocale.h>
|
2003-09-15 12:12:53 +00:00
|
|
|
#include <kmenubar.h>
|
|
|
|
#include <kparts/componentfactory.h>
|
2003-10-21 08:49:43 +00:00
|
|
|
#include <kio/netaccess.h>
|
2006-05-08 19:26:45 +00:00
|
|
|
#include <krecentfilesaction.h>
|
2006-05-22 14:02:24 +00:00
|
|
|
#include <kservicetypetrader.h>
|
2006-05-08 19:26:45 +00:00
|
|
|
#include <ktoggleaction.h>
|
|
|
|
#include <ktogglefullscreenaction.h>
|
2006-12-30 20:16:09 +00:00
|
|
|
#include <ktemporaryfile.h>
|
2005-07-15 17:17:13 +00:00
|
|
|
#include <kfilterbase.h>
|
|
|
|
#include <kfilterdev.h>
|
2003-10-21 08:49:43 +00:00
|
|
|
|
2005-01-02 14:29:37 +00:00
|
|
|
// local includes
|
|
|
|
#include "shell.h"
|
2002-09-02 20:21:47 +00:00
|
|
|
|
|
|
|
Shell::Shell()
|
2006-06-19 10:55:13 +00:00
|
|
|
: KParts::MainWindow(), m_menuBarWasShown(true), m_toolBarWasShown(true)
|
2005-06-24 16:43:45 +00:00
|
|
|
{
|
|
|
|
init();
|
|
|
|
}
|
|
|
|
|
2006-03-21 20:03:08 +00:00
|
|
|
Shell::Shell(const KUrl &url)
|
2006-06-19 10:55:13 +00:00
|
|
|
: KParts::MainWindow(), m_menuBarWasShown(true), m_toolBarWasShown(true)
|
2005-06-24 16:43:45 +00:00
|
|
|
{
|
|
|
|
m_openUrl = url;
|
|
|
|
init();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Shell::init()
|
2002-09-02 20:21:47 +00:00
|
|
|
{
|
2006-06-19 10:55:13 +00:00
|
|
|
setObjectName( QLatin1String( "okular::Shell" ) );
|
2002-09-02 20:21:47 +00:00
|
|
|
// set the shell's ui resource file
|
2005-01-02 14:29:37 +00:00
|
|
|
setXMLFile("shell.rc");
|
2005-08-11 03:41:30 +00:00
|
|
|
m_fileformats=0L;
|
|
|
|
m_tempfile=0L;
|
2002-09-02 20:21:47 +00:00
|
|
|
// this routine will find and load our Part. it finds the Part by
|
|
|
|
// name which is a bad idea usually.. but it's alright in this
|
|
|
|
// case since our Part is made for this Shell
|
2006-06-12 18:25:18 +00:00
|
|
|
KParts::Factory *factory = (KParts::Factory *) KLibLoader::self()->factory("libokularpart");
|
2002-09-02 20:21:47 +00:00
|
|
|
if (factory)
|
|
|
|
{
|
|
|
|
// now that the Part is loaded, we cast it to a Part to get
|
|
|
|
// our hands on it
|
2006-05-08 19:26:45 +00:00
|
|
|
m_part = (KParts::ReadOnlyPart*) factory->createPart(this, this);
|
2002-09-02 20:21:47 +00:00
|
|
|
if (m_part)
|
|
|
|
{
|
2004-04-27 21:57:30 +00:00
|
|
|
// then, setup our actions
|
|
|
|
setupActions();
|
2002-09-02 20:21:47 +00:00
|
|
|
// tell the KParts::MainWindow that this is indeed the main widget
|
|
|
|
setCentralWidget(m_part->widget());
|
|
|
|
// and integrate the part's GUI with the shell's
|
2004-11-25 22:27:01 +00:00
|
|
|
setupGUI(Keys | Save);
|
2002-09-02 20:21:47 +00:00
|
|
|
createGUI(m_part);
|
2004-12-13 00:27:09 +00:00
|
|
|
m_showToolBarAction = static_cast<KToggleAction*>(toolBarMenuAction());
|
2002-09-02 20:21:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// if we couldn't find our Part, we exit since the Shell by
|
|
|
|
// itself can't do anything useful
|
2006-06-12 18:25:18 +00:00
|
|
|
KMessageBox::error(this, i18n("Unable to find okular part."));
|
2004-11-01 19:06:27 +00:00
|
|
|
m_part = 0;
|
2002-09-02 20:21:47 +00:00
|
|
|
return;
|
|
|
|
}
|
2006-09-15 21:08:48 +00:00
|
|
|
connect( this, SIGNAL( restoreDocument(KConfig*) ),m_part, SLOT( restoreDocument(KConfig*)));
|
2004-11-01 21:56:08 +00:00
|
|
|
connect( this, SIGNAL( saveDocumentRestoreInfo(KConfig*) ), m_part, SLOT( saveDocumentRestoreInfo(KConfig*)));
|
2005-11-04 11:59:51 +00:00
|
|
|
connect( m_part, SIGNAL( enablePrintAction(bool) ), m_printAction, SLOT( setEnabled(bool)));
|
2004-08-29 11:24:11 +00:00
|
|
|
|
2003-09-14 17:44:18 +00:00
|
|
|
readSettings();
|
2006-06-05 14:55:36 +00:00
|
|
|
|
2004-12-10 22:27:55 +00:00
|
|
|
if (!KGlobal::config()->hasGroup("MainWindow"))
|
|
|
|
{
|
2006-06-05 14:55:36 +00:00
|
|
|
showMaximized();
|
2004-12-10 22:27:55 +00:00
|
|
|
}
|
2005-06-24 16:43:45 +00:00
|
|
|
setAutoSaveSettings();
|
|
|
|
|
|
|
|
if (m_openUrl.isValid()) QTimer::singleShot(0, this, SLOT(delayedOpen()));
|
2005-07-15 18:20:57 +00:00
|
|
|
|
2005-06-24 16:43:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Shell::delayedOpen()
|
|
|
|
{
|
2006-08-30 13:02:48 +00:00
|
|
|
openUrl(m_openUrl);
|
2002-09-02 20:21:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Shell::~Shell()
|
|
|
|
{
|
2005-08-11 03:41:30 +00:00
|
|
|
if ( m_part ) writeSettings();
|
|
|
|
if ( m_fileformats ) delete m_fileformats;
|
|
|
|
if ( m_tempfile ) delete m_tempfile;
|
2002-09-02 20:21:47 +00:00
|
|
|
}
|
|
|
|
|
2006-08-30 13:02:48 +00:00
|
|
|
void Shell::openUrl( const KUrl & url )
|
2003-09-14 17:44:18 +00:00
|
|
|
{
|
2005-01-27 17:31:07 +00:00
|
|
|
if ( m_part )
|
|
|
|
{
|
2006-08-29 21:09:55 +00:00
|
|
|
bool openOk = m_part->openUrl( url );
|
2006-03-23 19:02:55 +00:00
|
|
|
if ( openOk ) m_recent->addUrl( url );
|
|
|
|
else m_recent->removeUrl( url );
|
2005-01-27 17:31:07 +00:00
|
|
|
}
|
2003-09-14 17:44:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Shell::readSettings()
|
2002-09-02 20:21:47 +00:00
|
|
|
{
|
2004-09-18 16:41:23 +00:00
|
|
|
m_recent->loadEntries( KGlobal::config() );
|
2005-01-27 17:31:07 +00:00
|
|
|
m_recent->setEnabled( true ); // force enabling
|
|
|
|
m_recent->setToolTip( i18n("Click to open a file\nClick and hold to open a recent file") );
|
|
|
|
|
2003-09-15 12:12:53 +00:00
|
|
|
KGlobal::config()->setDesktopGroup();
|
2006-04-02 12:36:55 +00:00
|
|
|
bool fullScreen = KGlobal::config()->readEntry( "FullScreen", false );
|
2003-09-15 12:12:53 +00:00
|
|
|
setFullScreen( fullScreen );
|
2002-09-02 20:21:47 +00:00
|
|
|
}
|
|
|
|
|
2003-09-14 17:44:18 +00:00
|
|
|
void Shell::writeSettings()
|
|
|
|
{
|
2004-09-18 16:41:23 +00:00
|
|
|
m_recent->saveEntries( KGlobal::config() );
|
2003-09-15 12:12:53 +00:00
|
|
|
KGlobal::config()->setDesktopGroup();
|
2003-12-15 16:26:49 +00:00
|
|
|
KGlobal::config()->writeEntry( "FullScreen", m_fullScreenAction->isChecked());
|
2003-09-15 12:12:53 +00:00
|
|
|
KGlobal::config()->sync();
|
|
|
|
}
|
|
|
|
|
2005-01-20 17:33:05 +00:00
|
|
|
void Shell::setupActions()
|
2002-09-02 20:21:47 +00:00
|
|
|
{
|
2006-12-19 12:23:43 +00:00
|
|
|
KStandardAction::open(this, SLOT(fileOpen()), actionCollection());
|
|
|
|
m_recent = KStandardAction::openRecent( this, SLOT( openUrl( const KUrl& ) ), actionCollection() );
|
2006-04-25 12:37:27 +00:00
|
|
|
m_recent->setToolBarMode( KRecentFilesAction::MenuMode );
|
2006-05-06 17:12:13 +00:00
|
|
|
connect( m_recent, SIGNAL( triggered() ), this, SLOT( fileOpen() ) );
|
2005-01-27 17:31:07 +00:00
|
|
|
m_recent->setWhatsThis( i18n( "<b>Click</b> to open a file or <b>Click and hold</b> to select a recent file" ) );
|
2006-12-19 12:23:43 +00:00
|
|
|
m_printAction = KStandardAction::print( m_part, SLOT( slotPrint() ), actionCollection() );
|
2005-01-27 17:31:07 +00:00
|
|
|
m_printAction->setEnabled( false );
|
2006-12-19 12:23:43 +00:00
|
|
|
KStandardAction::quit(this, SLOT(slotQuit()), actionCollection());
|
2002-09-02 20:21:47 +00:00
|
|
|
|
2003-03-17 04:10:33 +00:00
|
|
|
setStandardToolBarMenuEnabled(true);
|
2002-09-02 20:21:47 +00:00
|
|
|
|
2006-12-19 12:23:43 +00:00
|
|
|
m_showMenuBarAction = KStandardAction::showMenubar( this, SLOT( slotShowMenubar() ), actionCollection());
|
|
|
|
KStandardAction::configureToolbars(this, SLOT(optionsConfigureToolbars()), actionCollection());
|
|
|
|
m_fullScreenAction = KStandardAction::fullScreen( this, SLOT( slotUpdateFullScreen() ), actionCollection(), this );
|
2002-09-02 20:21:47 +00:00
|
|
|
}
|
|
|
|
|
2005-01-03 15:51:05 +00:00
|
|
|
void Shell::saveProperties(KConfig* config)
|
2002-09-02 20:21:47 +00:00
|
|
|
{
|
|
|
|
// the 'config' object points to the session managed
|
|
|
|
// config file. anything you write here will be available
|
|
|
|
// later when this app is restored
|
2004-11-01 21:56:08 +00:00
|
|
|
emit saveDocumentRestoreInfo(config);
|
2002-09-02 20:21:47 +00:00
|
|
|
}
|
|
|
|
|
2003-09-14 19:04:36 +00:00
|
|
|
void Shell::readProperties(KConfig* config)
|
2002-09-02 20:21:47 +00:00
|
|
|
{
|
|
|
|
// the 'config' object points to the session managed
|
|
|
|
// config file. this function is automatically called whenever
|
|
|
|
// the app is being restored. read in here whatever you wrote
|
|
|
|
// in 'saveProperties'
|
2004-11-01 19:06:27 +00:00
|
|
|
if(m_part)
|
|
|
|
{
|
2006-09-15 21:08:48 +00:00
|
|
|
emit restoreDocument(config);
|
2004-11-01 19:06:27 +00:00
|
|
|
}
|
2002-09-02 20:21:47 +00:00
|
|
|
}
|
|
|
|
|
2005-07-15 17:17:13 +00:00
|
|
|
// this comes from kviewpart/kviewpart.cpp, fileformats function
|
|
|
|
|
|
|
|
QStringList* Shell::fileFormats()
|
|
|
|
{
|
|
|
|
QString constraint("([X-KDE-Priority] > 0) and (exist Library) ") ;
|
2006-06-12 18:25:18 +00:00
|
|
|
KService::List offers = KServiceTypeTrader::self()->query("okular/Generator",constraint);
|
2005-07-15 17:17:13 +00:00
|
|
|
QStringList supportedMimeTypes;
|
|
|
|
QStringList * supportedPattern;
|
|
|
|
|
|
|
|
if (offers.isEmpty())
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-05-24 08:57:40 +00:00
|
|
|
KFilterBase* filter = KFilterBase::findFilterByMimeType( "application/x-bzip2" );
|
|
|
|
bool bzip2Available = (filter != 0L);
|
|
|
|
delete filter;
|
2005-07-15 17:17:13 +00:00
|
|
|
supportedPattern = new QStringList;
|
2006-05-22 14:02:24 +00:00
|
|
|
KService::List::ConstIterator iterator = offers.begin();
|
|
|
|
KService::List::ConstIterator end = offers.end();
|
2006-11-25 22:32:13 +00:00
|
|
|
QStringList::ConstIterator mimeType;
|
2005-07-15 17:17:13 +00:00
|
|
|
QString tmp;
|
|
|
|
QStringList mimeTypes,pattern,extensions;
|
|
|
|
QString allExt,comment;
|
|
|
|
for (; iterator != end; ++iterator)
|
|
|
|
{
|
|
|
|
KService::Ptr service = *iterator;
|
|
|
|
mimeTypes = service->serviceTypes();
|
|
|
|
|
|
|
|
for (mimeType=mimeTypes.begin();mimeType!=mimeTypes.end();++mimeType)
|
|
|
|
{
|
2006-06-12 18:25:18 +00:00
|
|
|
if (! (*mimeType).contains("okular"))
|
2005-07-15 17:17:13 +00:00
|
|
|
{
|
2006-06-16 17:48:40 +00:00
|
|
|
KMimeType::Ptr mimePtr = KMimeType::mimeType(*mimeType);
|
|
|
|
if ( mimePtr )
|
|
|
|
{
|
|
|
|
pattern = mimePtr->patterns();
|
2005-07-15 17:17:13 +00:00
|
|
|
supportedMimeTypes << *mimeType;
|
|
|
|
|
|
|
|
extensions.clear();
|
|
|
|
while(!pattern.isEmpty())
|
|
|
|
{
|
2006-03-29 17:16:46 +00:00
|
|
|
tmp=pattern.front().trimmed();
|
2005-07-15 17:17:13 +00:00
|
|
|
extensions.append(tmp);
|
2006-03-29 20:43:48 +00:00
|
|
|
if (tmp.indexOf(".gz", -3) == -1)
|
2005-07-15 17:17:13 +00:00
|
|
|
extensions.append(tmp+".gz");
|
2006-03-29 20:43:48 +00:00
|
|
|
if ((bzip2Available) && (tmp.indexOf(".bz2", -4) == -1))
|
2005-07-15 17:17:13 +00:00
|
|
|
extensions.append(tmp+".bz2");
|
|
|
|
pattern.pop_front();
|
|
|
|
}
|
2006-06-16 17:48:40 +00:00
|
|
|
comment=mimePtr->comment();
|
2005-07-15 17:17:13 +00:00
|
|
|
if (! comment.contains("Unknown"))
|
2006-11-18 21:36:56 +00:00
|
|
|
supportedPattern->append(extensions.join(" ") + '|' + comment);
|
2005-07-15 17:17:13 +00:00
|
|
|
allExt+=extensions.join(" ");
|
2006-06-16 17:48:40 +00:00
|
|
|
}
|
2005-07-15 17:17:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
supportedPattern->prepend(allExt + "|All Files");
|
|
|
|
|
|
|
|
|
|
|
|
return supportedPattern;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2006-03-21 20:03:08 +00:00
|
|
|
bool Shell::handleCompressed(KUrl & url, const QString &path, const KMimeType::Ptr mimetype)
|
2002-09-02 21:56:00 +00:00
|
|
|
{
|
|
|
|
|
2005-07-15 17:17:13 +00:00
|
|
|
// we are working with a compressed file, decompressing
|
|
|
|
// temporary file for decompressing
|
2006-12-30 20:16:09 +00:00
|
|
|
m_tempfile = new KTemporaryFile;
|
2005-08-11 03:41:30 +00:00
|
|
|
if ( !m_tempfile )
|
2005-07-15 17:17:13 +00:00
|
|
|
{
|
|
|
|
KMessageBox::error(this,
|
|
|
|
i18n("<qt><strong>File Error!</strong> Could not create "
|
|
|
|
"temporary file.</qt>"));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2006-12-30 20:16:09 +00:00
|
|
|
m_tempfile->setAutoRemove(true);
|
2005-07-15 17:17:13 +00:00
|
|
|
|
|
|
|
// something failed while creating the tempfile
|
2006-12-30 20:16:09 +00:00
|
|
|
if ( ! m_tempfile->open() )
|
2005-07-15 17:17:13 +00:00
|
|
|
{
|
|
|
|
KMessageBox::error( this,
|
|
|
|
i18n("<qt><strong>File Error!</strong> Could not create temporary file "
|
2006-12-07 14:01:19 +00:00
|
|
|
"<nobr><strong>%1</strong></nobr>.</qt>",
|
2006-12-30 20:16:09 +00:00
|
|
|
strerror(m_tempfile->error())));
|
2005-08-11 03:41:30 +00:00
|
|
|
delete m_tempfile;
|
2005-07-15 17:17:13 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// decompression filer
|
|
|
|
QIODevice* filterDev;
|
|
|
|
if (( mimetype->parentMimeType() == "application/x-gzip" ) ||
|
|
|
|
( mimetype->parentMimeType() == "application/x-bzip2" ))
|
|
|
|
filterDev = KFilterDev::deviceForFile(path, mimetype->parentMimeType());
|
|
|
|
else
|
|
|
|
filterDev = KFilterDev::deviceForFile(path);
|
|
|
|
|
|
|
|
if (!filterDev)
|
|
|
|
{
|
2005-08-11 03:41:30 +00:00
|
|
|
delete m_tempfile;
|
2005-07-15 17:17:13 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2006-05-15 21:31:53 +00:00
|
|
|
if ( !filterDev->open(QIODevice::ReadOnly) )
|
2005-07-15 17:17:13 +00:00
|
|
|
{
|
|
|
|
KMessageBox::detailedError( this,
|
|
|
|
i18n("<qt><strong>File Error!</strong> Could not open the file "
|
|
|
|
"<nobr><strong>%1</strong></nobr> for uncompression. "
|
2006-04-10 19:50:00 +00:00
|
|
|
"The file will not be loaded.</qt>", path),
|
2005-07-15 17:17:13 +00:00
|
|
|
i18n("<qt>This error typically occurs if you do "
|
|
|
|
"not have enough permissions to read the file. "
|
|
|
|
"You can check ownership and permissions if you "
|
|
|
|
"right-click on the file in the Konqueror "
|
|
|
|
"file manager and then choose the 'Properties' menu.</qt>"));
|
|
|
|
|
|
|
|
delete filterDev;
|
2005-08-11 03:41:30 +00:00
|
|
|
delete m_tempfile;
|
2005-07-15 17:17:13 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2006-05-06 17:12:13 +00:00
|
|
|
QByteArray buf(1024, '\0');
|
2005-07-15 17:17:13 +00:00
|
|
|
int read = 0, wrtn = 0;
|
|
|
|
|
2006-03-31 21:51:45 +00:00
|
|
|
while ((read = filterDev->read(buf.data(), buf.size())) > 0)
|
2005-07-15 17:17:13 +00:00
|
|
|
{
|
2006-12-30 20:16:09 +00:00
|
|
|
wrtn = m_tempfile->write(buf.data(), read);
|
2005-07-15 17:17:13 +00:00
|
|
|
if ( read != wrtn )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
delete filterDev;
|
2006-12-30 20:16:09 +00:00
|
|
|
if ((read != 0) || (m_tempfile->size() == 0))
|
2005-07-15 17:17:13 +00:00
|
|
|
{
|
|
|
|
KMessageBox::detailedError(this,
|
|
|
|
i18n("<qt><strong>File Error!</strong> Could not uncompress "
|
|
|
|
"the file <nobr><strong>%1</strong></nobr>. "
|
2006-04-10 19:50:00 +00:00
|
|
|
"The file will not be loaded.</qt>", path ),
|
2005-07-15 17:17:13 +00:00
|
|
|
i18n("<qt>This error typically occurs if the file is corrupt. "
|
|
|
|
"If you want to be sure, try to decompress the file manually "
|
|
|
|
"using command-line tools.</qt>"));
|
2005-08-11 03:41:30 +00:00
|
|
|
delete m_tempfile;
|
2005-07-15 17:17:13 +00:00
|
|
|
return false;
|
|
|
|
}
|
2006-12-30 20:16:09 +00:00
|
|
|
url=m_tempfile->fileName();
|
2006-04-02 12:36:55 +00:00
|
|
|
return true;
|
2005-07-15 17:17:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Shell::fileOpen()
|
|
|
|
{
|
|
|
|
// this slot is called whenever the File->Open menu is selected,
|
|
|
|
// the Open shortcut is pressed (usually CTRL+O) or the Open toolbar
|
|
|
|
// button is clicked
|
|
|
|
if (!m_fileformats)
|
|
|
|
m_fileformats = fileFormats();
|
|
|
|
|
|
|
|
if (m_fileformats)
|
|
|
|
{
|
2006-06-18 14:06:21 +00:00
|
|
|
QString startDir;
|
|
|
|
if ( m_openUrl.isLocalFile() )
|
|
|
|
startDir = m_openUrl.path();
|
2006-07-04 23:09:39 +00:00
|
|
|
KUrl url = KFileDialog::getOpenUrl( startDir, m_fileformats->join("\n") );//getOpenFileName();
|
2005-07-15 17:17:13 +00:00
|
|
|
bool reallyOpen=!url.isEmpty();
|
|
|
|
if (reallyOpen)
|
|
|
|
{
|
|
|
|
QString path = url.path();
|
|
|
|
KMimeType::Ptr mimetype = KMimeType::findByPath( path );
|
|
|
|
if (( mimetype->name() == "application/x-gzip" )
|
|
|
|
|| ( mimetype->name() == "application/x-bzip2" )
|
|
|
|
|| ( mimetype->parentMimeType() == "application/x-gzip" )
|
|
|
|
|| ( mimetype->parentMimeType() == "application/x-bzip2" )
|
|
|
|
)
|
|
|
|
{
|
|
|
|
reallyOpen=handleCompressed(url,path,mimetype);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (reallyOpen)
|
2006-08-30 13:02:48 +00:00
|
|
|
openUrl(url);
|
2005-07-15 17:17:13 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-06-12 18:25:18 +00:00
|
|
|
KMessageBox::error(this, i18n("No okular plugins were found."));
|
2005-07-15 17:17:13 +00:00
|
|
|
slotQuit();
|
|
|
|
}
|
2002-09-02 20:21:47 +00:00
|
|
|
}
|
|
|
|
|
2004-11-25 22:27:01 +00:00
|
|
|
void
|
|
|
|
Shell::optionsConfigureToolbars()
|
|
|
|
{
|
|
|
|
KEditToolbar dlg(factory());
|
|
|
|
connect(&dlg, SIGNAL(newToolbarConfig()), this, SLOT(applyNewToolbarConfig()));
|
|
|
|
dlg.exec();
|
|
|
|
}
|
|
|
|
|
2002-09-02 20:21:47 +00:00
|
|
|
void
|
|
|
|
Shell::applyNewToolbarConfig()
|
|
|
|
{
|
|
|
|
applyMainWindowSettings(KGlobal::config(), "MainWindow");
|
|
|
|
}
|
|
|
|
|
2003-09-14 19:04:36 +00:00
|
|
|
void Shell::slotQuit()
|
|
|
|
{
|
|
|
|
kapp->closeAllWindows();
|
|
|
|
}
|
2003-09-15 12:12:53 +00:00
|
|
|
|
2004-12-13 00:27:09 +00:00
|
|
|
// only called when starting the program
|
2003-09-15 12:12:53 +00:00
|
|
|
void Shell::setFullScreen( bool useFullScreen )
|
|
|
|
{
|
2003-12-15 16:26:49 +00:00
|
|
|
if( useFullScreen )
|
|
|
|
showFullScreen();
|
|
|
|
else
|
|
|
|
showNormal();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Shell::slotUpdateFullScreen()
|
|
|
|
{
|
2004-12-13 00:27:09 +00:00
|
|
|
if(m_fullScreenAction->isChecked())
|
2003-09-15 12:12:53 +00:00
|
|
|
{
|
2004-12-13 00:27:09 +00:00
|
|
|
m_menuBarWasShown = m_showMenuBarAction->isChecked();
|
|
|
|
m_showMenuBarAction->setChecked(false);
|
|
|
|
menuBar()->hide();
|
|
|
|
|
|
|
|
m_toolBarWasShown = m_showToolBarAction->isChecked();
|
|
|
|
m_showToolBarAction->setChecked(false);
|
|
|
|
toolBar()->hide();
|
|
|
|
|
|
|
|
showFullScreen();
|
2003-09-15 12:12:53 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-12-13 00:27:09 +00:00
|
|
|
if (m_menuBarWasShown)
|
|
|
|
{
|
|
|
|
m_showMenuBarAction->setChecked(true);
|
|
|
|
menuBar()->show();
|
|
|
|
}
|
|
|
|
if (m_toolBarWasShown)
|
|
|
|
{
|
|
|
|
m_showToolBarAction->setChecked(true);
|
|
|
|
toolBar()->show();
|
|
|
|
}
|
|
|
|
showNormal();
|
2003-09-15 12:12:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-01-03 15:51:05 +00:00
|
|
|
void Shell::slotShowMenubar()
|
|
|
|
{
|
|
|
|
if ( m_showMenuBarAction->isChecked() )
|
|
|
|
menuBar()->show();
|
|
|
|
else
|
|
|
|
menuBar()->hide();
|
|
|
|
}
|
|
|
|
|
2005-01-02 14:29:37 +00:00
|
|
|
#include "shell.moc"
|