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> *
|
2013-03-14 22:09:07 +00:00
|
|
|
* Copyright (C) 2003-2004 by Albert Astals Cid <aacid@kde.org> *
|
2004-08-26 21:17:24 +00:00
|
|
|
* 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
|
|
|
|
2007-04-19 18:30:20 +00:00
|
|
|
#include "shell.h"
|
|
|
|
|
2005-01-02 14:29:37 +00:00
|
|
|
// qt/kde includes
|
2014-08-13 20:57:48 +00:00
|
|
|
#include <QDesktopWidget>
|
|
|
|
#include <QTimer>
|
|
|
|
#include <QDBusConnection>
|
|
|
|
#include <QMenuBar>
|
|
|
|
#include <QApplication>
|
2016-05-30 22:13:36 +00:00
|
|
|
#include <QFileDialog>
|
2014-08-13 20:57:48 +00:00
|
|
|
#include <KPluginLoader>
|
|
|
|
#include <KMessageBox>
|
2014-09-11 13:18:05 +00:00
|
|
|
#include <QMimeType>
|
|
|
|
#include <QMimeDatabase>
|
2014-08-13 20:57:48 +00:00
|
|
|
#include <KStandardAction>
|
|
|
|
#include <KToolBar>
|
|
|
|
#include <KRecentFilesAction>
|
|
|
|
#include <KServiceTypeTrader>
|
|
|
|
#include <KToggleFullScreenAction>
|
|
|
|
#include <KActionCollection>
|
|
|
|
#include <KWindowSystem>
|
2014-10-17 21:30:54 +00:00
|
|
|
#include <QTabWidget>
|
2014-08-13 20:57:48 +00:00
|
|
|
#include <KXMLGUIFactory>
|
2014-04-09 21:29:13 +00:00
|
|
|
#include <QDragMoveEvent>
|
2014-07-30 22:15:21 +00:00
|
|
|
#include <QTabBar>
|
2014-08-13 20:57:48 +00:00
|
|
|
#include <KConfigGroup>
|
2014-08-13 11:07:44 +00:00
|
|
|
#include <KUrlMimeData>
|
2014-10-19 13:17:37 +00:00
|
|
|
#include <KLocalizedString>
|
|
|
|
#include <KSharedConfig>
|
2016-05-30 22:13:36 +00:00
|
|
|
#include <KIO/Global>
|
2012-10-04 18:17:13 +00:00
|
|
|
#include <KActivities/ResourceInstance>
|
|
|
|
|
2005-01-02 14:29:37 +00:00
|
|
|
// local includes
|
2007-01-04 00:20:50 +00:00
|
|
|
#include "kdocumentviewer.h"
|
2014-02-08 11:15:15 +00:00
|
|
|
#include "../interfaces/viewerinterface.h"
|
2009-10-08 23:48:04 +00:00
|
|
|
#include "shellutils.h"
|
2002-09-02 20:21:47 +00:00
|
|
|
|
2010-10-14 19:22:55 +00:00
|
|
|
static const char *shouldShowMenuBarComingFromFullScreen = "shouldShowMenuBarComingFromFullScreen";
|
|
|
|
static const char *shouldShowToolBarComingFromFullScreen = "shouldShowToolBarComingFromFullScreen";
|
|
|
|
|
2015-03-16 22:55:57 +00:00
|
|
|
static const char* const SESSION_URL_KEY = "Urls";
|
|
|
|
static const char* const SESSION_TAB_KEY = "ActiveTab";
|
|
|
|
|
2014-08-08 20:35:53 +00:00
|
|
|
Shell::Shell( const QString &serializedOptions )
|
|
|
|
: KParts::MainWindow(), m_menuBarWasShown(true), m_toolBarWasShown(true)
|
2012-10-04 18:17:13 +00:00
|
|
|
, m_activityResource(0)
|
2014-10-01 22:56:00 +00:00
|
|
|
, m_isValid(true)
|
2002-09-02 20:21:47 +00:00
|
|
|
{
|
2015-10-29 12:37:11 +00:00
|
|
|
setObjectName( QStringLiteral( "okular::Shell#" ) );
|
2007-01-04 21:06:44 +00:00
|
|
|
setContextMenuPolicy( Qt::NoContextMenu );
|
2015-11-28 15:08:19 +00:00
|
|
|
// otherwise .rc file won't be found by unit test
|
|
|
|
setComponentName(QStringLiteral("okular"), QString());
|
2002-09-02 20:21:47 +00:00
|
|
|
// set the shell's ui resource file
|
2015-10-29 12:37:11 +00:00
|
|
|
setXMLFile(QStringLiteral("shell.rc"));
|
2007-07-29 21:36:02 +00:00
|
|
|
m_fileformatsscanned = false;
|
2011-06-02 19:26:20 +00:00
|
|
|
m_showMenuBarAction = 0;
|
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
|
2015-10-29 12:37:11 +00:00
|
|
|
KPluginLoader loader(QStringLiteral("okularpart"));
|
2014-08-10 20:01:13 +00:00
|
|
|
m_partFactory = loader.factory();
|
2014-02-08 10:44:26 +00:00
|
|
|
if (!m_partFactory)
|
2002-09-02 20:21:47 +00:00
|
|
|
{
|
|
|
|
// if we couldn't find our Part, we exit since the Shell by
|
|
|
|
// itself can't do anything useful
|
2014-10-01 22:56:00 +00:00
|
|
|
m_isValid = false;
|
2014-08-10 20:01:13 +00:00
|
|
|
KMessageBox::error(this, i18n("Unable to find the Okular component: %1", loader.errorString()));
|
2002-09-02 20:21:47 +00:00
|
|
|
return;
|
|
|
|
}
|
2008-10-06 17:39:30 +00:00
|
|
|
|
2012-10-08 21:51:58 +00:00
|
|
|
// now that the Part plugin is loaded, create the part
|
2014-02-08 10:44:26 +00:00
|
|
|
KParts::ReadWritePart* const firstPart = m_partFactory->create< KParts::ReadWritePart >( this );
|
|
|
|
if (firstPart)
|
2008-10-06 17:39:30 +00:00
|
|
|
{
|
2014-02-08 10:44:26 +00:00
|
|
|
// Setup tab bar
|
2014-10-17 21:30:54 +00:00
|
|
|
m_tabWidget = new QTabWidget( this );
|
2014-02-08 10:44:26 +00:00
|
|
|
m_tabWidget->setTabsClosable( true );
|
|
|
|
m_tabWidget->setElideMode( Qt::ElideRight );
|
2014-09-09 15:49:10 +00:00
|
|
|
m_tabWidget->tabBar()->hide();
|
2014-02-13 22:24:40 +00:00
|
|
|
m_tabWidget->setDocumentMode( true );
|
2014-07-30 22:15:21 +00:00
|
|
|
m_tabWidget->setMovable( true );
|
2016-01-30 18:28:41 +00:00
|
|
|
|
|
|
|
m_tabWidget->setAcceptDrops(true);
|
|
|
|
m_tabWidget->installEventFilter(this);
|
|
|
|
|
2015-10-29 12:37:11 +00:00
|
|
|
connect( m_tabWidget, &QTabWidget::currentChanged, this, &Shell::setActiveTab );
|
|
|
|
connect( m_tabWidget, &QTabWidget::tabCloseRequested, this, &Shell::closeTab );
|
|
|
|
connect( m_tabWidget->tabBar(), &QTabBar::tabMoved, this, &Shell::moveTabData );
|
2014-02-08 10:44:26 +00:00
|
|
|
|
|
|
|
setCentralWidget( m_tabWidget );
|
|
|
|
|
2008-10-06 17:39:30 +00:00
|
|
|
// then, setup our actions
|
|
|
|
setupActions();
|
2015-10-29 12:37:11 +00:00
|
|
|
connect( QCoreApplication::instance(), &QCoreApplication::aboutToQuit, this, &QObject::deleteLater );
|
2008-10-06 17:39:30 +00:00
|
|
|
// and integrate the part's GUI with the shell's
|
2008-10-12 16:28:57 +00:00
|
|
|
setupGUI(Keys | ToolBar | Save);
|
2014-02-08 10:44:26 +00:00
|
|
|
createGUI(firstPart);
|
|
|
|
connectPart( firstPart );
|
|
|
|
|
|
|
|
m_tabs.append( firstPart );
|
|
|
|
m_tabWidget->addTab( firstPart->widget(), QString() );
|
2008-10-06 17:39:30 +00:00
|
|
|
|
2012-12-20 23:32:27 +00:00
|
|
|
readSettings();
|
|
|
|
|
2014-08-08 20:35:53 +00:00
|
|
|
m_unique = ShellUtils::unique(serializedOptions);
|
|
|
|
if (m_unique)
|
2012-10-08 21:58:47 +00:00
|
|
|
{
|
2015-10-29 12:37:11 +00:00
|
|
|
m_unique = QDBusConnection::sessionBus().registerService(QStringLiteral("org.kde.okular"));
|
2012-10-08 21:58:47 +00:00
|
|
|
if (!m_unique)
|
|
|
|
KMessageBox::information(this, i18n("There is already a unique Okular instance running. This instance won't be the unique one."));
|
|
|
|
}
|
2016-07-12 19:12:58 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
QString serviceName = QStringLiteral("org.kde.okular-") + QString::number(qApp->applicationPid());
|
|
|
|
QDBusConnection::sessionBus().registerService(serviceName);
|
|
|
|
}
|
2014-08-08 20:35:53 +00:00
|
|
|
if (ShellUtils::noRaise(serializedOptions))
|
2013-03-09 15:34:45 +00:00
|
|
|
{
|
|
|
|
setAttribute(Qt::WA_ShowWithoutActivating);
|
|
|
|
}
|
2015-04-03 20:29:38 +00:00
|
|
|
|
2015-10-29 12:37:11 +00:00
|
|
|
QDBusConnection::sessionBus().registerObject(QStringLiteral("/okularshell"), this, QDBusConnection::ExportScriptableSlots);
|
2008-09-21 22:52:02 +00:00
|
|
|
}
|
2012-10-08 22:08:05 +00:00
|
|
|
else
|
|
|
|
{
|
2014-10-01 22:56:00 +00:00
|
|
|
m_isValid = false;
|
2012-10-08 22:08:05 +00:00
|
|
|
KMessageBox::error(this, i18n("Unable to find the Okular component."));
|
|
|
|
}
|
2005-06-24 16:43:45 +00:00
|
|
|
}
|
|
|
|
|
2016-01-30 18:28:41 +00:00
|
|
|
bool Shell::eventFilter(QObject *obj, QEvent *event)
|
|
|
|
{
|
2016-07-11 20:57:11 +00:00
|
|
|
Q_UNUSED(obj);
|
|
|
|
|
2016-01-30 18:28:41 +00:00
|
|
|
QDragMoveEvent* dmEvent = dynamic_cast<QDragMoveEvent*>(event);
|
|
|
|
if (dmEvent) {
|
|
|
|
bool accept = dmEvent->mimeData()->hasUrls();
|
|
|
|
event->setAccepted(accept);
|
|
|
|
return accept;
|
|
|
|
}
|
|
|
|
|
|
|
|
QDropEvent* dEvent = dynamic_cast<QDropEvent*>(event);
|
|
|
|
if (dEvent) {
|
|
|
|
const QList<QUrl> list = KUrlMimeData::urlsFromMimeData(dEvent->mimeData());
|
|
|
|
handleDroppedUrls(list);
|
|
|
|
dEvent->setAccepted(true);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-10-01 22:56:00 +00:00
|
|
|
bool Shell::isValid() const
|
|
|
|
{
|
|
|
|
return m_isValid;
|
|
|
|
}
|
|
|
|
|
2012-08-20 22:35:41 +00:00
|
|
|
void Shell::showOpenRecentMenu()
|
|
|
|
{
|
|
|
|
m_recent->menu()->popup(QCursor::pos());
|
|
|
|
}
|
|
|
|
|
2002-09-02 20:21:47 +00:00
|
|
|
Shell::~Shell()
|
|
|
|
{
|
2014-02-08 10:44:26 +00:00
|
|
|
if( !m_tabs.empty() )
|
2012-08-18 16:36:30 +00:00
|
|
|
{
|
|
|
|
writeSettings();
|
2014-02-08 10:44:26 +00:00
|
|
|
for( QList<TabState>::iterator it = m_tabs.begin(); it != m_tabs.end(); ++it )
|
|
|
|
{
|
|
|
|
it->part->closeUrl( false );
|
|
|
|
}
|
2015-03-16 22:55:57 +00:00
|
|
|
m_tabs.clear();
|
2012-08-18 16:36:30 +00:00
|
|
|
}
|
2014-08-08 20:35:53 +00:00
|
|
|
if (m_unique)
|
2015-10-29 12:37:11 +00:00
|
|
|
QDBusConnection::sessionBus().unregisterService(QStringLiteral("org.kde.okular"));
|
2015-11-04 10:59:10 +00:00
|
|
|
|
|
|
|
delete m_tabWidget;
|
2002-09-02 20:21:47 +00:00
|
|
|
}
|
|
|
|
|
2014-04-09 21:29:13 +00:00
|
|
|
// Open a new document if we have space for it
|
|
|
|
// This can hang if called on a unique instance and openUrl pops a messageBox
|
2016-02-26 16:04:40 +00:00
|
|
|
bool Shell::openDocument( const QUrl& url, const QString &serializedOptions )
|
2014-04-09 21:29:13 +00:00
|
|
|
{
|
|
|
|
if( m_tabs.size() <= 0 )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
KParts::ReadWritePart* const part = m_tabs[0].part;
|
|
|
|
|
|
|
|
// Return false if we can't open new tabs and the only part is occupied
|
2014-08-08 20:35:53 +00:00
|
|
|
if ( !dynamic_cast<Okular::ViewerInterface*>(part)->openNewFilesInTabs()
|
|
|
|
&& !part->url().isEmpty()
|
|
|
|
&& !ShellUtils::unique(serializedOptions))
|
|
|
|
{
|
2014-04-09 21:29:13 +00:00
|
|
|
return false;
|
2014-08-08 20:35:53 +00:00
|
|
|
}
|
2014-04-09 21:29:13 +00:00
|
|
|
|
2016-02-26 16:04:40 +00:00
|
|
|
openUrl( url, serializedOptions );
|
2014-04-09 21:29:13 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-02-26 16:04:40 +00:00
|
|
|
bool Shell::openDocument( const QString& urlString, const QString &serializedOptions )
|
|
|
|
{
|
|
|
|
return openDocument(QUrl(urlString), serializedOptions);
|
|
|
|
}
|
|
|
|
|
2014-04-09 21:29:13 +00:00
|
|
|
bool Shell::canOpenDocs( int numDocs, int desktop )
|
|
|
|
{
|
|
|
|
if( m_tabs.size() <= 0 || numDocs <= 0 || m_unique )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
KParts::ReadWritePart* const part = m_tabs[0].part;
|
|
|
|
const bool allowTabs = dynamic_cast<Okular::ViewerInterface*>(part)->openNewFilesInTabs();
|
|
|
|
|
|
|
|
if( !allowTabs && (numDocs > 1 || !part->url().isEmpty()) )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
const KWindowInfo winfo( window()->effectiveWinId(), KWindowSystem::WMDesktop );
|
|
|
|
if( winfo.desktop() != desktop )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-08-14 11:35:43 +00:00
|
|
|
void Shell::openUrl( const QUrl & url, const QString &serializedOptions )
|
2003-09-14 17:44:18 +00:00
|
|
|
{
|
2014-02-08 10:44:26 +00:00
|
|
|
const int activeTab = m_tabWidget->currentIndex();
|
|
|
|
if ( activeTab < m_tabs.size() )
|
2005-01-27 17:31:07 +00:00
|
|
|
{
|
2014-02-08 11:15:15 +00:00
|
|
|
KParts::ReadWritePart* const activePart = m_tabs[activeTab].part;
|
|
|
|
if( !activePart->url().isEmpty() )
|
2012-09-04 18:04:01 +00:00
|
|
|
{
|
2012-09-19 20:40:06 +00:00
|
|
|
if( m_unique )
|
|
|
|
{
|
2014-08-08 20:35:53 +00:00
|
|
|
applyOptionsToPart( activePart, serializedOptions );
|
|
|
|
activePart->openUrl( url );
|
2012-09-19 20:40:06 +00:00
|
|
|
}
|
2012-09-19 20:44:18 +00:00
|
|
|
else
|
|
|
|
{
|
2014-02-08 11:15:15 +00:00
|
|
|
if( dynamic_cast<Okular::ViewerInterface *>(activePart)->openNewFilesInTabs() )
|
2014-02-08 10:44:26 +00:00
|
|
|
{
|
2014-08-08 20:35:53 +00:00
|
|
|
openNewTab( url, serializedOptions );
|
2014-02-08 10:44:26 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-08-08 20:35:53 +00:00
|
|
|
Shell* newShell = new Shell( serializedOptions );
|
|
|
|
newShell->openUrl( url, serializedOptions );
|
2014-02-08 10:44:26 +00:00
|
|
|
newShell->show();
|
|
|
|
}
|
2012-09-19 20:44:18 +00:00
|
|
|
}
|
2012-09-04 18:04:01 +00:00
|
|
|
}
|
2012-09-19 20:44:18 +00:00
|
|
|
else
|
2008-11-09 21:40:06 +00:00
|
|
|
{
|
2014-02-08 10:44:26 +00:00
|
|
|
m_tabWidget->setTabText( activeTab, url.fileName() );
|
2014-08-08 20:35:53 +00:00
|
|
|
applyOptionsToPart( activePart, serializedOptions );
|
2014-02-08 11:15:15 +00:00
|
|
|
bool openOk = activePart->openUrl( url );
|
2014-08-13 16:33:42 +00:00
|
|
|
const bool isstdin = url.fileName() == QLatin1String( "-" );
|
2012-09-19 20:44:18 +00:00
|
|
|
if ( !isstdin )
|
|
|
|
{
|
|
|
|
if ( openOk )
|
2012-10-04 18:17:13 +00:00
|
|
|
{
|
|
|
|
if ( !m_activityResource )
|
|
|
|
m_activityResource = new KActivities::ResourceInstance( window()->winId(), this );
|
|
|
|
|
|
|
|
m_activityResource->setUri( url );
|
2012-09-19 20:44:18 +00:00
|
|
|
m_recent->addUrl( url );
|
2012-10-04 18:17:13 +00:00
|
|
|
}
|
2012-09-19 20:44:18 +00:00
|
|
|
else
|
|
|
|
m_recent->removeUrl( url );
|
|
|
|
}
|
2008-11-09 21:40:06 +00:00
|
|
|
}
|
2005-01-27 17:31:07 +00:00
|
|
|
}
|
2003-09-14 17:44:18 +00:00
|
|
|
}
|
|
|
|
|
2012-09-04 18:04:01 +00:00
|
|
|
void Shell::closeUrl()
|
|
|
|
{
|
2014-02-08 10:44:26 +00:00
|
|
|
closeTab( m_tabWidget->currentIndex() );
|
2012-09-04 18:04:01 +00:00
|
|
|
}
|
2003-09-14 17:44:18 +00:00
|
|
|
|
|
|
|
void Shell::readSettings()
|
2002-09-02 20:21:47 +00:00
|
|
|
{
|
2014-09-12 08:54:00 +00:00
|
|
|
m_recent->loadEntries( KSharedConfig::openConfig()->group( "Recent Files" ) );
|
2005-01-27 17:31:07 +00:00
|
|
|
m_recent->setEnabled( true ); // force enabling
|
|
|
|
|
2014-09-12 08:54:00 +00:00
|
|
|
const KConfigGroup group = KSharedConfig::openConfig()->group( "Desktop Entry" );
|
2007-02-20 15:25:05 +00:00
|
|
|
bool fullScreen = group.readEntry( "FullScreen", false );
|
2003-09-15 12:12:53 +00:00
|
|
|
setFullScreen( fullScreen );
|
2015-04-03 20:29:38 +00:00
|
|
|
|
2010-10-14 19:22:55 +00:00
|
|
|
if (fullScreen)
|
|
|
|
{
|
|
|
|
m_menuBarWasShown = group.readEntry( shouldShowMenuBarComingFromFullScreen, true );
|
|
|
|
m_toolBarWasShown = group.readEntry( shouldShowToolBarComingFromFullScreen, true );
|
|
|
|
}
|
2002-09-02 20:21:47 +00:00
|
|
|
}
|
|
|
|
|
2003-09-14 17:44:18 +00:00
|
|
|
void Shell::writeSettings()
|
|
|
|
{
|
2014-09-12 08:54:00 +00:00
|
|
|
m_recent->saveEntries( KSharedConfig::openConfig()->group( "Recent Files" ) );
|
|
|
|
KConfigGroup group = KSharedConfig::openConfig()->group( "Desktop Entry" );
|
2007-02-20 15:25:05 +00:00
|
|
|
group.writeEntry( "FullScreen", m_fullScreenAction->isChecked() );
|
2010-10-14 19:22:55 +00:00
|
|
|
if (m_fullScreenAction->isChecked())
|
|
|
|
{
|
|
|
|
group.writeEntry( shouldShowMenuBarComingFromFullScreen, m_menuBarWasShown );
|
|
|
|
group.writeEntry( shouldShowToolBarComingFromFullScreen, m_toolBarWasShown );
|
|
|
|
}
|
2014-09-12 08:54:00 +00:00
|
|
|
KSharedConfig::openConfig()->sync();
|
2003-09-15 12:12:53 +00:00
|
|
|
}
|
|
|
|
|
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());
|
2014-08-13 16:33:42 +00:00
|
|
|
m_recent = KStandardAction::openRecent( this, SLOT(openUrl(QUrl)), actionCollection() );
|
2006-04-25 12:37:27 +00:00
|
|
|
m_recent->setToolBarMode( KRecentFilesAction::MenuMode );
|
2016-10-29 14:32:24 +00:00
|
|
|
connect( m_recent, &QAction::triggered, this, &Shell::showOpenRecentMenu );
|
2007-09-12 00:09:35 +00:00
|
|
|
m_recent->setToolTip( i18n("Click to open a file\nClick and hold to open a recent file") );
|
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" ) );
|
2014-02-08 10:44:26 +00:00
|
|
|
m_printAction = KStandardAction::print( this, SLOT(print()), actionCollection() );
|
2005-01-27 17:31:07 +00:00
|
|
|
m_printAction->setEnabled( false );
|
2012-09-04 18:04:01 +00:00
|
|
|
m_closeAction = KStandardAction::close( this, SLOT(closeUrl()), actionCollection() );
|
|
|
|
m_closeAction->setEnabled( false );
|
2014-02-08 10:44:26 +00:00
|
|
|
KStandardAction::quit(this, SLOT(close()), 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
|
|
|
|
2011-07-31 19:22:04 +00:00
|
|
|
m_showMenuBarAction = KStandardAction::showMenubar( this, SLOT(slotShowMenubar()), actionCollection());
|
|
|
|
m_fullScreenAction = KStandardAction::fullScreen( this, SLOT(slotUpdateFullScreen()), this,actionCollection() );
|
2014-02-08 10:44:26 +00:00
|
|
|
|
2015-10-29 12:37:11 +00:00
|
|
|
m_nextTabAction = actionCollection()->addAction(QStringLiteral("tab-next"));
|
2014-02-08 10:44:26 +00:00
|
|
|
m_nextTabAction->setText( i18n("Next Tab") );
|
2014-10-04 19:48:01 +00:00
|
|
|
actionCollection()->setDefaultShortcuts(m_nextTabAction, KStandardShortcut::tabNext());
|
2014-02-08 10:44:26 +00:00
|
|
|
m_nextTabAction->setEnabled( false );
|
2015-10-29 12:37:11 +00:00
|
|
|
connect( m_nextTabAction, &QAction::triggered, this, &Shell::activateNextTab );
|
2014-02-08 10:44:26 +00:00
|
|
|
|
2015-10-29 12:37:11 +00:00
|
|
|
m_prevTabAction = actionCollection()->addAction(QStringLiteral("tab-previous"));
|
2014-02-08 10:44:26 +00:00
|
|
|
m_prevTabAction->setText( i18n("Previous Tab") );
|
2014-10-04 19:48:01 +00:00
|
|
|
actionCollection()->setDefaultShortcuts(m_prevTabAction, KStandardShortcut::tabPrev());
|
2014-02-08 10:44:26 +00:00
|
|
|
m_prevTabAction->setEnabled( false );
|
2015-10-29 12:37:11 +00:00
|
|
|
connect( m_prevTabAction, &QAction::triggered, this, &Shell::activatePrevTab );
|
2002-09-02 20:21:47 +00:00
|
|
|
}
|
|
|
|
|
2007-02-20 15:48:18 +00:00
|
|
|
void Shell::saveProperties(KConfigGroup &group)
|
2002-09-02 20:21:47 +00:00
|
|
|
{
|
2015-08-03 10:58:30 +00:00
|
|
|
if ( !m_isValid ) // part couldn't be loaded, nothing to save
|
|
|
|
return;
|
|
|
|
|
2015-03-16 22:55:57 +00:00
|
|
|
// Gather lists of settings to preserve
|
|
|
|
QStringList urls;
|
|
|
|
for( int i = 0; i < m_tabs.size(); ++i )
|
|
|
|
{
|
|
|
|
urls.append( m_tabs[i].part->url().url() );
|
|
|
|
}
|
|
|
|
group.writePathEntry( SESSION_URL_KEY, urls );
|
|
|
|
group.writeEntry( SESSION_TAB_KEY, m_tabWidget->currentIndex() );
|
2002-09-02 20:21:47 +00:00
|
|
|
}
|
|
|
|
|
2007-02-21 15:12:57 +00:00
|
|
|
void Shell::readProperties(const KConfigGroup &group)
|
2002-09-02 20:21:47 +00:00
|
|
|
{
|
2015-03-16 22:55:57 +00:00
|
|
|
// Reopen documents based on saved settings
|
|
|
|
QStringList urls = group.readPathEntry( SESSION_URL_KEY, QStringList() );
|
|
|
|
|
|
|
|
while( !urls.isEmpty() )
|
|
|
|
{
|
2015-03-17 07:47:52 +00:00
|
|
|
openUrl( QUrl(urls.takeFirst()) );
|
2015-03-16 22:55:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int desiredTab = group.readEntry<int>( SESSION_TAB_KEY, 0 );
|
|
|
|
if( desiredTab < m_tabs.size() )
|
|
|
|
{
|
|
|
|
setActiveTab( desiredTab );
|
|
|
|
}
|
2002-09-02 20:21:47 +00:00
|
|
|
}
|
|
|
|
|
2007-02-07 17:25:51 +00:00
|
|
|
QStringList Shell::fileFormats() const
|
2005-07-15 17:17:13 +00:00
|
|
|
{
|
2007-02-07 17:25:51 +00:00
|
|
|
QStringList supportedPatterns;
|
2005-07-15 17:17:13 +00:00
|
|
|
|
2015-10-29 12:37:11 +00:00
|
|
|
QString constraint( QStringLiteral("(Library == 'okularpart')") );
|
2008-01-02 00:37:51 +00:00
|
|
|
QLatin1String basePartService( "KParts/ReadOnlyPart" );
|
|
|
|
KService::List offers = KServiceTypeTrader::self()->query( basePartService, constraint );
|
2008-11-11 18:24:06 +00:00
|
|
|
KService::List::ConstIterator it = offers.constBegin(), itEnd = offers.constEnd();
|
2008-01-02 00:37:51 +00:00
|
|
|
for ( ; it != itEnd; ++it )
|
2007-02-07 17:25:51 +00:00
|
|
|
{
|
2008-01-02 00:37:51 +00:00
|
|
|
KService::Ptr service = *it;
|
2016-07-12 23:43:30 +00:00
|
|
|
QStringList mimeTypes = service->mimeTypes();
|
2016-05-30 22:13:36 +00:00
|
|
|
|
|
|
|
supportedPatterns += mimeTypes;
|
2005-07-15 17:17:13 +00:00
|
|
|
}
|
|
|
|
|
2007-02-07 17:25:51 +00:00
|
|
|
return supportedPatterns;
|
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
|
2014-02-08 10:44:26 +00:00
|
|
|
const int activeTab = m_tabWidget->currentIndex();
|
2007-07-29 21:36:02 +00:00
|
|
|
if ( !m_fileformatsscanned )
|
2007-05-24 20:41:29 +00:00
|
|
|
{
|
2014-02-08 10:44:26 +00:00
|
|
|
const KDocumentViewer* const doc = qobject_cast<KDocumentViewer*>(m_tabs[activeTab].part);
|
|
|
|
if ( doc )
|
|
|
|
m_fileformats = doc->supportedMimeTypes();
|
2007-05-24 20:41:29 +00:00
|
|
|
|
|
|
|
if ( m_fileformats.isEmpty() )
|
|
|
|
m_fileformats = fileFormats();
|
2005-07-15 17:17:13 +00:00
|
|
|
|
2007-07-29 21:36:02 +00:00
|
|
|
m_fileformatsscanned = true;
|
2005-07-15 17:17:13 +00:00
|
|
|
}
|
2007-07-29 21:36:02 +00:00
|
|
|
|
2016-01-30 19:00:25 +00:00
|
|
|
QUrl startDir;
|
2014-02-08 10:44:26 +00:00
|
|
|
const KParts::ReadWritePart* const curPart = m_tabs[activeTab].part;
|
|
|
|
if ( curPart->url().isLocalFile() )
|
2016-05-30 22:13:36 +00:00
|
|
|
startDir = KIO::upUrl(curPart->url());
|
2015-10-21 11:30:36 +00:00
|
|
|
|
2016-05-30 22:13:36 +00:00
|
|
|
QPointer<QFileDialog> dlg( new QFileDialog( this ));
|
|
|
|
dlg->setDirectoryUrl( startDir );
|
|
|
|
dlg->setAcceptMode( QFileDialog::AcceptOpen );
|
2016-07-13 00:16:05 +00:00
|
|
|
dlg->setOption( QFileDialog::HideNameFilterDetails, true );
|
|
|
|
|
|
|
|
QMimeDatabase mimeDatabase;
|
|
|
|
QSet<QString> globPatterns;
|
2016-08-13 19:57:04 +00:00
|
|
|
QMap<QString, QStringList> namedGlobs;
|
2016-07-13 00:16:05 +00:00
|
|
|
foreach ( const QString &mimeName, m_fileformats ) {
|
|
|
|
QMimeType mimeType = mimeDatabase.mimeTypeForName( mimeName );
|
2016-08-13 19:59:17 +00:00
|
|
|
const QStringList globs( mimeType.globPatterns() );
|
|
|
|
if ( globs.isEmpty() ) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
globPatterns.unite( globs.toSet() ) ;
|
2016-07-13 00:16:05 +00:00
|
|
|
|
2016-08-13 19:59:17 +00:00
|
|
|
namedGlobs[ mimeType.comment() ].append( globs );
|
2016-08-13 19:57:04 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
QStringList namePatterns;
|
|
|
|
foreach( const QString &name, namedGlobs.keys()) {
|
|
|
|
namePatterns.append( name +
|
2016-07-13 00:16:05 +00:00
|
|
|
QStringLiteral(" (") +
|
2016-08-13 19:57:04 +00:00
|
|
|
namedGlobs[name].join( QLatin1Char(' ') ) +
|
2016-07-13 00:16:05 +00:00
|
|
|
QStringLiteral(")")
|
|
|
|
);
|
|
|
|
}
|
2016-08-13 19:57:04 +00:00
|
|
|
|
2016-07-13 00:16:05 +00:00
|
|
|
namePatterns.prepend( i18n("All files (*)") );
|
2016-08-13 19:50:37 +00:00
|
|
|
namePatterns.prepend( i18n("All supported files (%1)", globPatterns.toList().join( QLatin1Char(' ') ) ) );
|
2016-07-13 00:16:05 +00:00
|
|
|
dlg->setNameFilters( namePatterns );
|
2011-05-05 20:52:46 +00:00
|
|
|
|
2016-07-13 00:16:05 +00:00
|
|
|
dlg->setWindowTitle( i18n("Open Document") );
|
2016-08-13 20:20:43 +00:00
|
|
|
if ( dlg->exec() && dlg ) {
|
|
|
|
foreach(const QUrl& url, dlg->selectedUrls())
|
|
|
|
{
|
|
|
|
openUrl( url );
|
|
|
|
}
|
|
|
|
}
|
2016-05-30 22:13:36 +00:00
|
|
|
|
2016-08-13 20:20:43 +00:00
|
|
|
if ( dlg ) {
|
|
|
|
delete dlg.data();
|
2012-05-23 21:43:44 +00:00
|
|
|
}
|
2002-09-02 20:21:47 +00:00
|
|
|
}
|
|
|
|
|
2012-08-21 22:41:31 +00:00
|
|
|
void Shell::tryRaise()
|
|
|
|
{
|
2014-04-09 21:29:13 +00:00
|
|
|
KWindowSystem::forceActiveWindow( window()->effectiveWinId() );
|
2012-08-21 22:41:31 +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 )
|
2008-03-10 23:02:01 +00:00
|
|
|
setWindowState( windowState() | Qt::WindowFullScreen ); // set
|
2003-12-15 16:26:49 +00:00
|
|
|
else
|
2008-03-10 23:02:01 +00:00
|
|
|
setWindowState( windowState() & ~Qt::WindowFullScreen ); // reset
|
2003-12-15 16:26:49 +00:00
|
|
|
}
|
|
|
|
|
2008-12-18 22:08:39 +00:00
|
|
|
void Shell::showEvent(QShowEvent *e)
|
|
|
|
{
|
2011-06-02 19:26:20 +00:00
|
|
|
if (m_showMenuBarAction)
|
|
|
|
m_showMenuBarAction->setChecked( menuBar()->isVisible() );
|
2008-12-18 22:08:39 +00:00
|
|
|
|
|
|
|
KParts::MainWindow::showEvent(e);
|
|
|
|
}
|
|
|
|
|
2003-12-15 16:26:49 +00:00
|
|
|
void Shell::slotUpdateFullScreen()
|
|
|
|
{
|
2004-12-13 00:27:09 +00:00
|
|
|
if(m_fullScreenAction->isChecked())
|
2003-09-15 12:12:53 +00:00
|
|
|
{
|
2009-01-19 19:13:32 +00:00
|
|
|
m_menuBarWasShown = !menuBar()->isHidden();
|
2004-12-13 00:27:09 +00:00
|
|
|
menuBar()->hide();
|
2015-04-03 20:29:38 +00:00
|
|
|
|
2009-01-19 19:13:32 +00:00
|
|
|
m_toolBarWasShown = !toolBar()->isHidden();
|
2004-12-13 00:27:09 +00:00
|
|
|
toolBar()->hide();
|
2008-03-10 23:02:01 +00:00
|
|
|
|
2015-04-03 20:29:38 +00:00
|
|
|
KToggleFullScreenAction::setFullScreen(this, true);
|
2003-09-15 12:12:53 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-12-13 00:27:09 +00:00
|
|
|
if (m_menuBarWasShown)
|
|
|
|
{
|
|
|
|
menuBar()->show();
|
|
|
|
}
|
|
|
|
if (m_toolBarWasShown)
|
|
|
|
{
|
|
|
|
toolBar()->show();
|
|
|
|
}
|
2015-04-03 20:29:38 +00:00
|
|
|
KToggleFullScreenAction::setFullScreen(this, false);
|
2003-09-15 12:12:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-01-03 15:51:05 +00:00
|
|
|
void Shell::slotShowMenubar()
|
|
|
|
{
|
2009-01-19 19:13:32 +00:00
|
|
|
if ( menuBar()->isHidden() )
|
2005-01-03 15:51:05 +00:00
|
|
|
menuBar()->show();
|
|
|
|
else
|
|
|
|
menuBar()->hide();
|
|
|
|
}
|
|
|
|
|
2009-01-17 13:39:21 +00:00
|
|
|
QSize Shell::sizeHint() const
|
|
|
|
{
|
|
|
|
return QApplication::desktop()->availableGeometry( this ).size() * 0.75;
|
|
|
|
}
|
|
|
|
|
2012-05-23 21:43:44 +00:00
|
|
|
bool Shell::queryClose()
|
|
|
|
{
|
2014-02-08 10:44:26 +00:00
|
|
|
for( int i = 0; i < m_tabs.size(); ++i )
|
|
|
|
{
|
|
|
|
KParts::ReadWritePart* const part = m_tabs[i].part;
|
|
|
|
|
|
|
|
// To resolve confusion about multiple modified docs, switch to relevant tab
|
|
|
|
if( part->isModified() )
|
|
|
|
setActiveTab( i );
|
|
|
|
|
|
|
|
if( !part->queryClose() )
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Shell::setActiveTab( int tab )
|
|
|
|
{
|
|
|
|
m_tabWidget->setCurrentIndex( tab );
|
|
|
|
createGUI( m_tabs[tab].part );
|
|
|
|
m_printAction->setEnabled( m_tabs[tab].printEnabled );
|
|
|
|
m_closeAction->setEnabled( m_tabs[tab].closeEnabled );
|
|
|
|
}
|
|
|
|
|
|
|
|
void Shell::closeTab( int tab )
|
|
|
|
{
|
|
|
|
KParts::ReadWritePart* const part = m_tabs[tab].part;
|
|
|
|
if( part->closeUrl() && m_tabs.count() > 1 )
|
|
|
|
{
|
|
|
|
if( part->factory() )
|
|
|
|
part->factory()->removeClient( part );
|
|
|
|
part->disconnect();
|
|
|
|
part->deleteLater();
|
|
|
|
m_tabs.removeAt( tab );
|
|
|
|
m_tabWidget->removeTab( tab );
|
|
|
|
|
|
|
|
if( m_tabWidget->count() == 1 )
|
|
|
|
{
|
2014-09-09 15:49:10 +00:00
|
|
|
m_tabWidget->tabBar()->hide();
|
2014-02-08 10:44:26 +00:00
|
|
|
m_nextTabAction->setEnabled( false );
|
|
|
|
m_prevTabAction->setEnabled( false );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-08-14 11:35:43 +00:00
|
|
|
void Shell::openNewTab( const QUrl& url, const QString &serializedOptions )
|
2014-02-08 10:44:26 +00:00
|
|
|
{
|
|
|
|
// Tabs are hidden when there's only one, so show it
|
|
|
|
if( m_tabs.size() == 1 )
|
|
|
|
{
|
2014-09-09 15:49:10 +00:00
|
|
|
m_tabWidget->tabBar()->show();
|
2014-02-08 10:44:26 +00:00
|
|
|
m_nextTabAction->setEnabled( true );
|
|
|
|
m_prevTabAction->setEnabled( true );
|
|
|
|
}
|
|
|
|
|
|
|
|
const int newIndex = m_tabs.size();
|
|
|
|
|
|
|
|
// Make new part
|
|
|
|
m_tabs.append( m_partFactory->create<KParts::ReadWritePart>(this) );
|
|
|
|
connectPart( m_tabs[newIndex].part );
|
|
|
|
|
|
|
|
// Update GUI
|
|
|
|
KParts::ReadWritePart* const part = m_tabs[newIndex].part;
|
|
|
|
m_tabWidget->addTab( part->widget(), url.fileName() );
|
|
|
|
|
2014-08-08 20:35:53 +00:00
|
|
|
applyOptionsToPart(part, serializedOptions);
|
|
|
|
|
|
|
|
int previousActiveTab = m_tabWidget->currentIndex();
|
|
|
|
setActiveTab( m_tabs.size() - 1 );
|
|
|
|
|
2014-02-08 10:44:26 +00:00
|
|
|
if( part->openUrl(url) )
|
|
|
|
m_recent->addUrl( url );
|
2014-08-08 20:35:53 +00:00
|
|
|
else
|
|
|
|
setActiveTab( previousActiveTab );
|
|
|
|
}
|
|
|
|
|
|
|
|
void Shell::applyOptionsToPart( QObject* part, const QString &serializedOptions )
|
|
|
|
{
|
|
|
|
KDocumentViewer* const doc = qobject_cast<KDocumentViewer*>(part);
|
|
|
|
if ( ShellUtils::startInPresentation(serializedOptions) )
|
|
|
|
doc->startPresentation();
|
|
|
|
if ( ShellUtils::showPrintDialog(serializedOptions) )
|
|
|
|
QMetaObject::invokeMethod( part, "enableStartWithPrint" );
|
2014-02-08 10:44:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Shell::connectPart( QObject* part )
|
|
|
|
{
|
2015-03-16 23:20:11 +00:00
|
|
|
connect( this, SIGNAL(moveSplitter(int)), part, SLOT(moveSplitter(int)) );
|
2014-02-08 10:44:26 +00:00
|
|
|
connect( part, SIGNAL(enablePrintAction(bool)), this, SLOT(setPrintEnabled(bool)));
|
|
|
|
connect( part, SIGNAL(enableCloseAction(bool)), this, SLOT(setCloseEnabled(bool)));
|
2014-09-11 13:18:05 +00:00
|
|
|
connect( part, SIGNAL(mimeTypeChanged(QMimeType)), this, SLOT(setTabIcon(QMimeType)));
|
2014-08-13 11:07:44 +00:00
|
|
|
connect( part, SIGNAL(urlsDropped(QList<QUrl>)), this, SLOT(handleDroppedUrls(QList<QUrl>)) );
|
2015-03-16 23:20:11 +00:00
|
|
|
connect( part, SIGNAL(fitWindowToPage(QSize,QSize)), this, SLOT(slotFitWindowToPage(QSize,QSize)) );
|
2014-02-08 10:44:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Shell::print()
|
|
|
|
{
|
|
|
|
QMetaObject::invokeMethod( m_tabs[m_tabWidget->currentIndex()].part, "slotPrint" );
|
|
|
|
}
|
|
|
|
|
|
|
|
void Shell::setPrintEnabled( bool enabled )
|
|
|
|
{
|
|
|
|
int i = findTabIndex( sender() );
|
|
|
|
if( i != -1 )
|
|
|
|
{
|
|
|
|
m_tabs[i].printEnabled = enabled;
|
|
|
|
if( i == m_tabWidget->currentIndex() )
|
|
|
|
m_printAction->setEnabled( enabled );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Shell::setCloseEnabled( bool enabled )
|
|
|
|
{
|
|
|
|
int i = findTabIndex( sender() );
|
|
|
|
if( i != -1 )
|
|
|
|
{
|
|
|
|
m_tabs[i].closeEnabled = enabled;
|
|
|
|
if( i == m_tabWidget->currentIndex() )
|
|
|
|
m_closeAction->setEnabled( enabled );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Shell::activateNextTab()
|
|
|
|
{
|
|
|
|
if( m_tabs.size() < 2 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
const int activeTab = m_tabWidget->currentIndex();
|
|
|
|
const int nextTab = (activeTab == m_tabs.size()-1) ? 0 : activeTab+1;
|
|
|
|
|
|
|
|
setActiveTab( nextTab );
|
|
|
|
}
|
|
|
|
|
|
|
|
void Shell::activatePrevTab()
|
|
|
|
{
|
|
|
|
if( m_tabs.size() < 2 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
const int activeTab = m_tabWidget->currentIndex();
|
|
|
|
const int prevTab = (activeTab == 0) ? m_tabs.size()-1 : activeTab-1;
|
|
|
|
|
|
|
|
setActiveTab( prevTab );
|
|
|
|
}
|
|
|
|
|
2014-09-11 13:18:05 +00:00
|
|
|
void Shell::setTabIcon( const QMimeType& mimeType )
|
2014-02-08 10:44:26 +00:00
|
|
|
{
|
|
|
|
int i = findTabIndex( sender() );
|
|
|
|
if( i != -1 )
|
|
|
|
{
|
2014-09-11 13:18:05 +00:00
|
|
|
m_tabWidget->setTabIcon( i, QIcon::fromTheme(mimeType.iconName()) );
|
2014-02-08 10:44:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int Shell::findTabIndex( QObject* sender )
|
|
|
|
{
|
|
|
|
for( int i = 0; i < m_tabs.size(); ++i )
|
|
|
|
{
|
|
|
|
if( m_tabs[i].part == sender )
|
|
|
|
{
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
2012-05-23 21:43:44 +00:00
|
|
|
}
|
|
|
|
|
2014-08-13 11:07:44 +00:00
|
|
|
void Shell::handleDroppedUrls( const QList<QUrl>& urls )
|
2014-04-09 21:29:13 +00:00
|
|
|
{
|
2014-08-13 16:33:42 +00:00
|
|
|
foreach( const QUrl& url, urls )
|
2014-04-09 21:29:13 +00:00
|
|
|
{
|
|
|
|
openUrl( url );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-30 22:15:21 +00:00
|
|
|
void Shell::moveTabData( int from, int to )
|
|
|
|
{
|
|
|
|
m_tabs.move( from, to );
|
|
|
|
}
|
|
|
|
|
2015-03-16 23:20:11 +00:00
|
|
|
void Shell::slotFitWindowToPage(const QSize& pageViewSize, const QSize& pageSize )
|
|
|
|
{
|
|
|
|
const int xOffset = pageViewSize.width() - pageSize.width();
|
|
|
|
const int yOffset = pageViewSize.height() - pageSize.height();
|
|
|
|
showNormal();
|
|
|
|
resize( width() - xOffset, height() - yOffset);
|
|
|
|
moveSplitter(pageSize.width());
|
|
|
|
}
|
|
|
|
|
2010-10-14 19:22:55 +00:00
|
|
|
/* kate: replace-tabs on; indent-width 4; */
|